summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0xAX <0xAX@users.noreply.github.com>2016-10-10 05:57:03 +0300
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-10-09 22:57:03 -0400
commit10c961b9c9625d4e0408b5f21e2ba815148ccf63 (patch)
tree51fa8bd19cac6e14fc504892320421c17e2ad368 /src
parent9fc932bff1e2058885fc458412b3c94d586cb586 (diff)
main: initialize default unit little later (#4321)
systemd fills arg_default_unit during startup with default.target value. But arg_default_unit may be overwritten in parse_argv() or parse_proc_cmdline_item(). Let's check value of arg_default_unit after calls of parse_argv() and parse_proc_cmdline_item() and fill it with default.target if it wasn't filled before. In this way we will not spend unnecessary time to for filling arg_default_unit with default.target.
Diffstat (limited to 'src')
-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.");