diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-15 11:38:01 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-15 15:47:23 +0200 |
commit | 494f4ee9c770e401ea3d570a9caf4b3058cf7758 (patch) | |
tree | 487af69bafd7d0bee4c1932f484b5ea3b001c739 /src/basic/log.c | |
parent | 17021368fc5b9b3800125414362e82daf43a785d (diff) | |
download | systemd-494f4ee9c770e401ea3d570a9caf4b3058cf7758.tar.gz |
basic/log: split out invoked_by_systemd() utility function
Diffstat (limited to 'src/basic/log.c')
-rw-r--r-- | src/basic/log.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/basic/log.c b/src/basic/log.c index 02fc2c6f92..cac17a76f4 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -1153,30 +1153,12 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat } static bool should_parse_proc_cmdline(void) { - const char *e; - pid_t p; - /* PID1 always reads the kernel command line. */ if (getpid_cached() == 1) return true; - /* If the process is directly executed by PID1 (e.g. ExecStart= or generator), systemd-importd, - * or systemd-homed, then $SYSTEMD_EXEC_PID= is set, and read the command line. */ - e = getenv("SYSTEMD_EXEC_PID"); - if (!e) - return false; - - if (streq(e, "*")) - /* For testing. */ - return true; - - if (parse_pid(e, &p) < 0) { - /* We know that systemd sets the variable correctly. Something else must have set it. */ - log_debug("Failed to parse \"$SYSTEMD_EXEC_PID=%s\". Ignoring.", e); - return false; - } - - return getpid_cached() == p; + /* Otherwise, parse the commandline if invoked directly by systemd. */ + return invoked_by_systemd(); } void log_parse_environment_variables(void) { |