diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-12-04 10:30:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-04 10:30:32 +0100 |
commit | b51d61fec650253bafc100e46efb11ee0e3c3e5a (patch) | |
tree | f7c7a64f91c4b6418839a03f416d9af1ed463dd0 /src/core/main.c | |
parent | core: reload SELinux label cache on daemon-reload (diff) | |
parent | initrd: fix systemd.debug-shell & friends (diff) | |
download | systemd-b51d61fec650253bafc100e46efb11ee0e3c3e5a.tar.xz systemd-b51d61fec650253bafc100e46efb11ee0e3c3e5a.zip |
Merge pull request #14177 from keszybz/use-initrd.target
Use initrd.target in the initramfs
Diffstat (limited to 'src/core/main.c')
-rw-r--r-- | src/core/main.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/core/main.c b/src/core/main.c index 40ac88fbb4..e800ac3ced 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1997,20 +1997,36 @@ static int do_queue_default_job( const char **ret_error_message) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + const char* default_unit; Job *default_unit_job; Unit *target = NULL; int r; - log_debug("Activating default unit: %s", arg_default_unit); + if (arg_default_unit) + default_unit = arg_default_unit; + else if (in_initrd()) + default_unit = SPECIAL_INITRD_TARGET; + else + default_unit = SPECIAL_DEFAULT_TARGET; + + log_debug("Activating default unit: %s", default_unit); + + r = manager_load_startable_unit_or_warn(m, default_unit, NULL, &target); + if (r < 0 && in_initrd() && !arg_default_unit) { + /* Fall back to default.target, which we used to always use by default. Only do this if no + * explicit configuration was given. */ + + log_info("Falling back to " SPECIAL_DEFAULT_TARGET "."); - r = manager_load_startable_unit_or_warn(m, arg_default_unit, NULL, &target); + r = manager_load_startable_unit_or_warn(m, SPECIAL_DEFAULT_TARGET, NULL, &target); + } if (r < 0) { - log_info("Falling back to rescue target: " SPECIAL_RESCUE_TARGET); + log_info("Falling back to " SPECIAL_RESCUE_TARGET "."); r = manager_load_startable_unit_or_warn(m, SPECIAL_RESCUE_TARGET, NULL, &target); if (r < 0) { - *ret_error_message = r == -ERFKILL ? "Rescue target masked" - : "Failed to load rescue target"; + *ret_error_message = r == -ERFKILL ? SPECIAL_RESCUE_TARGET " masked" + : "Failed to load " SPECIAL_RESCUE_TARGET; return r; } } @@ -2222,15 +2238,6 @@ static int load_configuration( return r; } - /* Initialize default unit */ - if (!arg_default_unit) { - arg_default_unit = strdup(SPECIAL_DEFAULT_TARGET); - if (!arg_default_unit) { - *ret_error_message = "Failed to set default unit"; - return log_oom(); - } - } - /* Initialize the show status setting if it hasn't been set explicitly yet */ if (arg_show_status == _SHOW_STATUS_INVALID) arg_show_status = SHOW_STATUS_YES; |