]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
log: make tools also read the kernel command line when run as a service
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 17 Jan 2021 05:52:22 +0000 (14:52 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 31 Jan 2021 16:13:44 +0000 (01:13 +0900)
This effectively reverts 41d1f469cf10f5f3e9cb4f4853ace9b0cfe5beae.

Before this, e.g., `networkctl reload` invoked by `systemctl reload systemd-networkd.service`
does not produce debugging logs even if systemd.log-level=debug is set. This fixes
the issue.

src/basic/log.c
src/basic/log.h
src/journal-remote/journal-remote-main.c
src/journal-remote/journal-upload.c
src/systemctl/systemctl.c

index 59181910ebc06a82b2a17ea6f5f03599a5ff5f3b..4163f2e8d93ddf6ce7ede4fa1fd67c57f37ab5e4 100644 (file)
@@ -1158,20 +1158,16 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
 }
 
 void log_parse_environment(void) {
+        const char *e;
+
+        /* Do not call from library code. */
+
         if (getpid_cached() == 1 || get_ctty_devnr(0, NULL) < 0)
                 /* Only try to read the command line in daemons. We assume that anything that has a
                  * controlling tty is user stuff. For PID1 we do a special check in case it hasn't
                  * closed the console yet. */
                 (void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
 
-        log_parse_environment_cli();
-}
-
-void log_parse_environment_cli(void) {
-        /* Do not call from library code. */
-
-        const char *e;
-
         e = getenv("SYSTEMD_LOG_TARGET");
         if (e && log_set_target_from_string(e) < 0)
                 log_warning("Failed to parse log target '%s'. Ignoring.", e);
@@ -1474,7 +1470,7 @@ void log_setup_cli(void) {
         /* Sets up logging the way it is most appropriate for running a program as a CLI utility. */
 
         log_set_target(LOG_TARGET_AUTO);
-        log_parse_environment_cli();
+        log_parse_environment();
         (void) log_open();
         if (log_on_console() && show_color < 0)
                 log_show_color(true);
index 9b106c57d8a3bbeb1312fefae63f3b5eb552a935..9421fc8b4942b3515e86ae165d3b46d809ab75eb 100644 (file)
@@ -69,7 +69,6 @@ void log_close(void);
 void log_forget_fds(void);
 
 void log_parse_environment(void);
-void log_parse_environment_cli(void);
 
 int log_dispatch_internal(
                 int level,
index 685ce5a16b8810119309409a4ada537208d18bca..972c13566f652615a17c56871e5fb1ced8d27d6f 100644 (file)
@@ -1121,7 +1121,7 @@ static int run(int argc, char **argv) {
         int r;
 
         log_show_color(true);
-        log_parse_environment_cli();
+        log_parse_environment();
 
         /* The journal merging logic potentially needs a lot of fds. */
         (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
index 2d84bdcae5ec04c08b91e1483044029d65079cb4..455a6c942ef1f9b90c668c1c5f0f78526a2bf071 100644 (file)
@@ -820,7 +820,7 @@ static int run(int argc, char **argv) {
         int r;
 
         log_show_color(true);
-        log_parse_environment_cli();
+        log_parse_environment();
 
         /* The journal merging logic potentially needs a lot of fds. */
         (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
index c53ed41cc325dd6e991917bd2b4ae088b1813796..e8e3d2438a3d6491a1fe06e56eaf540b2d94130e 100644 (file)
@@ -1085,7 +1085,7 @@ static int run(int argc, char *argv[]) {
         int r;
 
         setlocale(LC_ALL, "");
-        log_parse_environment_cli();
+        log_parse_environment();
         log_open();
 
         /* The journal merging logic potentially needs a lot of fds. */