diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-08-19 17:45:33 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-08-19 18:06:12 +0200 |
commit | 3196e423931666511b24c701fb382416af5dc709 (patch) | |
tree | 319a6dd6683652478d437a9f5374f9845551a5e4 /src | |
parent | homed: default to "btrfs" as fs type in the LUKS backend (diff) | |
download | systemd-3196e423931666511b24c701fb382416af5dc709.tar.xz systemd-3196e423931666511b24c701fb382416af5dc709.zip |
core: merge a few if blocks
arg_system == true and getpid() == 1 hold under the very same condition
this early in the main() function (this only changes later when we start
parsing command lines, where arg_system = true is set if users invoke us
in test mode even when getpid() != 1.
Hence, let's simplify things, and merge a couple of if branches and not
pretend they were orthogonal.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/core/main.c b/src/core/main.c index 4a376976e9..8d53c0bf85 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2653,22 +2653,6 @@ int main(int argc, char *argv[]) { goto finish; } - } else { - /* Running as user instance */ - arg_system = false; - log_set_target(LOG_TARGET_AUTO); - log_open(); - - /* clear the kernel timestamp, because we are not PID 1 */ - kernel_timestamp = DUAL_TIMESTAMP_NULL; - - if (mac_selinux_init() < 0) { - error_message = "Failed to initialize SELinux support"; - goto finish; - } - } - - if (arg_system) { /* Try to figure out if we can use colors with the console. No need to do that for user instances since * they never log into the console. */ log_show_color(colors_enabled()); @@ -2676,15 +2660,12 @@ int main(int argc, char *argv[]) { r = make_null_stdio(); if (r < 0) log_warning_errno(r, "Failed to redirect standard streams to /dev/null, ignoring: %m"); - } - - /* Mount /proc, /sys and friends, so that /proc/cmdline and /proc/$PID/fd is available. */ - if (getpid_cached() == 1) { /* Load the kernel modules early. */ if (!skip_setup) kmod_setup(); + /* Mount /proc, /sys and friends, so that /proc/cmdline and /proc/$PID/fd is available. */ r = mount_setup(loaded_policy, skip_setup); if (r < 0) { error_message = "Failed to mount API filesystems"; @@ -2697,6 +2678,19 @@ int main(int argc, char *argv[]) { /* Cache command-line options passed from EFI variables */ if (!skip_setup) (void) cache_efi_options_variable(); + } else { + /* Running as user instance */ + arg_system = false; + log_set_target(LOG_TARGET_AUTO); + log_open(); + + /* clear the kernel timestamp, because we are not PID 1 */ + kernel_timestamp = DUAL_TIMESTAMP_NULL; + + if (mac_selinux_init() < 0) { + error_message = "Failed to initialize SELinux support"; + goto finish; + } } /* Save the original RLIMIT_NOFILE/RLIMIT_MEMLOCK so that we can reset it later when |