From 2771aaf571fda17bf3a5d83b78d2e016b9be46ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 26 Mar 2019 10:19:19 +0100 Subject: [PATCH 1/2] systemctl: define less stuff when !HAVE_SYSV_COMPAT We'd translate our action to sysv runlevel action, only to discard the result in talk_initctl(). Let's just ifdef the whole thing away. Fixes #12103. --- src/systemctl/systemctl.c | 3 ++- src/systemctl/sysv-compat.c | 6 ++---- src/systemctl/sysv-compat.h | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 4dd5cd37681..d162ddee5a4 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -8727,7 +8727,6 @@ _pure_ static int action_to_runlevel(void) { }; assert(arg_action >= 0 && arg_action < _ACTION_MAX); - return table[arg_action]; } #endif @@ -8826,9 +8825,11 @@ static int start_with_fallback(void) { if (start_unit(0, NULL, NULL) == 0) return 0; +#if HAVE_SYSV_COMPAT /* Nothing else worked, so let's try /dev/initctl */ if (talk_initctl(action_to_runlevel()) > 0) return 0; +#endif return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to talk to init daemon."); diff --git a/src/systemctl/sysv-compat.c b/src/systemctl/sysv-compat.c index 72a2f579657..a85b2dfe4b4 100644 --- a/src/systemctl/sysv-compat.c +++ b/src/systemctl/sysv-compat.c @@ -7,8 +7,8 @@ #include "strv.h" #include "sysv-compat.h" -int talk_initctl(char rl) { #if HAVE_SYSV_COMPAT +int talk_initctl(char rl) { struct init_request request; _cleanup_close_ int fd = -1; const char *p; @@ -44,10 +44,8 @@ int talk_initctl(char rl) { return log_error_errno(r, "Failed to write to %s: %m", p); return 1; -#else - return 0; -#endif } +#endif int parse_shutdown_time_spec(const char *t, usec_t *ret) { assert(t); diff --git a/src/systemctl/sysv-compat.h b/src/systemctl/sysv-compat.h index 73329ec42a4..e79919217ca 100644 --- a/src/systemctl/sysv-compat.h +++ b/src/systemctl/sysv-compat.h @@ -3,7 +3,10 @@ #include "time-util.h" +#if HAVE_SYSV_COMPAT int talk_initctl(char runlevel); +#endif + int parse_shutdown_time_spec(const char *t, usec_t *ret); /* The init script exit codes for the LSB 'status' verb. (This is different from the 'start' verb, whose exit From be3f37528e20bff766b181eab4cc4821cd40c2e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 26 Mar 2019 10:20:57 +0100 Subject: [PATCH 2/2] util-lib: fix sentence in comment --- src/shared/mount-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index 9dcf49c0a2a..9987b6f80ce 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -107,7 +107,7 @@ static int get_mount_flags(const char *path, unsigned long *flags) { return 0; } -/* Use this function only if do you have direct access to /proc/self/mountinfo and need the caller to open it +/* Use this function only if you do not have direct access to /proc/self/mountinfo but the caller can open it * for you. This is the case when /proc is masked or not mounted. Otherwise, use bind_remount_recursive. */ int bind_remount_recursive_with_mountinfo( const char *prefix,