summaryrefslogtreecommitdiff
path: root/src/basic/verbs.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-20 19:38:15 +0100
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:50:00 +0200
commitc69b8d901ccd747ff9a2db02416653c9874df8a3 (patch)
tree630422623f03175c9afd28b606752679d31d10fd /src/basic/verbs.c
parent93cce5619b22ecac1a5834c5b66a1da1102952a4 (diff)
verbs: suppress debug log message if SYSTEMD_OFFLINE is not set
If SYSTEMD_OFFLINE is not set getenv_bool() for it will return -ENXIO, which is nothing we should log about, not even at LOG_DEBUG level.
Diffstat (limited to 'src/basic/verbs.c')
-rw-r--r--src/basic/verbs.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/basic/verbs.c b/src/basic/verbs.c
index ce1d304d9..4f17d39f8 100644
--- a/src/basic/verbs.c
+++ b/src/basic/verbs.c
@@ -30,45 +30,36 @@
#include "verbs.h"
#include "virt.h"
-/* Wraps running_in_chroot() which is used in various places,
- * but also adds an environment variable check so external processes
- * can reliably force this on.
+/* Wraps running_in_chroot() which is used in various places, but also adds an environment variable check so external
+ * processes can reliably force this on.
*/
bool running_in_chroot_or_offline(void) {
int r;
- /* Added to support use cases like rpm-ostree, where from %post
- * scripts we only want to execute "preset", but not "start"/"restart"
- * for example.
+ /* Added to support use cases like rpm-ostree, where from %post scripts we only want to execute "preset", but
+ * not "start"/"restart" for example.
*
* See ENVIRONMENT.md for docs.
*/
r = getenv_bool("SYSTEMD_OFFLINE");
- if (r < 0)
- log_debug_errno(r, "Parsing SYSTEMD_OFFLINE: %m");
- else if (r == 0)
- return false;
- else
- return true;
-
- /* We've had this condition check for a long time which basically
- * checks for legacy chroot case like Fedora's
- * "mock", which is used for package builds. We don't want
- * to try to start systemd services there, since without --new-chroot
- * we don't even have systemd running, and even if we did, adding
- * a concept of background daemons to builds would be an enormous change,
- * requiring considering things like how the journal output is handled, etc.
- * And there's really not a use case today for a build talking to a service.
+ if (r < 0 && r != -ENXIO)
+ log_debug_errno(r, "Failed to parse $SYSTEMD_OFFLINE: %m");
+ else if (r >= 0)
+ return r > 0;
+
+ /* We've had this condition check for a long time which basically checks for legacy chroot case like Fedora's
+ * "mock", which is used for package builds. We don't want to try to start systemd services there, since
+ * without --new-chroot we don't even have systemd running, and even if we did, adding a concept of background
+ * daemons to builds would be an enormous change, requiring considering things like how the journal output is
+ * handled, etc. And there's really not a use case today for a build talking to a service.
*
* Note this call itself also looks for a different variable SYSTEMD_IGNORE_CHROOT=1.
*/
r = running_in_chroot();
if (r < 0)
log_debug_errno(r, "running_in_chroot(): %m");
- else if (r > 0)
- return true;
- return false;
+ return r > 0;
}
int dispatch_verb(int argc, char *argv[], const Verb verbs[], void *userdata) {