summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/main.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core/main.c b/src/core/main.c
index e88362b7fe..0fad393323 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1536,14 +1536,6 @@ int main(int argc, char *argv[]) {
log_warning_errno(errno, "Failed to redirect standard streams to /dev/null: %m");
}
- /* Initialize default unit */
- r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET);
- if (r < 0) {
- log_emergency_errno(r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET);
- error_message = "Failed to set default unit";
- goto finish;
- }
-
r = initialize_join_controllers();
if (r < 0) {
error_message = "Failed to initialize cgroup controllers";
@@ -1591,6 +1583,16 @@ int main(int argc, char *argv[]) {
goto finish;
}
+ /* Initialize default unit */
+ if (!arg_default_unit) {
+ r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET);
+ if (r < 0) {
+ log_emergency_errno(r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET);
+ error_message = "Failed to set default unit";
+ goto finish;
+ }
+ }
+
if (arg_action == ACTION_TEST &&
geteuid() == 0) {
log_error("Don't run test mode as root.");