Skip to content

Commit 5f4a882

Browse files
keszybzpoettering
authored andcommitted
pid1: make sure we look at /proc/1/cmdline when parsing config
In recent systemd-nspawn we wouldn't parse init args like systemd.log-level=debug. This is because we wouldn't even look at /proc/1/cmdline. $ systemd-nspawn -n cat /proc/1/stat 1 (cat) R 0 1 1 34816 .... ^^^^^ 34816 is 136:0 a.k.a. /dev/pts/0.
1 parent 03909b1 commit 5f4a882

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/basic/log.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,10 @@ void log_parse_environment_realm(LogRealm realm) {
11011101

11021102
const char *e;
11031103

1104-
if (get_ctty_devnr(0, NULL) < 0)
1105-
/* Only try to read the command line in daemons. We assume that anything that has a controlling tty is
1106-
user stuff. */
1104+
if (getpid_cached() == 1 || get_ctty_devnr(0, NULL) < 0)
1105+
/* Only try to read the command line in daemons. We assume that anything that has a
1106+
* controlling tty is user stuff. For PID1 we do a special check in case it hasn't
1107+
* closed the console yet. */
11071108
(void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
11081109

11091110
e = getenv("SYSTEMD_LOG_TARGET");

0 commit comments

Comments
 (0)