chiark / gitweb /
selinux: close stdin/stdout/stderr before loading selinux policy
[elogind.git] / src / core / main.c
index 3c0f5f9a94d7c11121059ed7fb4608ae93a6324d..458fdca55e86f9b465ef8bd6347b95067fdb19ee 100644 (file)
@@ -727,12 +727,13 @@ static int parse_proc_cmdline(void) {
                 }
 
                 r = parse_proc_cmdline_word(word);
-                free(word);
-
                 if (r < 0) {
                         log_error("Failed on cmdline argument %s: %s", word, strerror(-r));
+                        free(word);
                         goto finish;
                 }
+
+                free(word);
         }
 
         r = 0;
@@ -1265,6 +1266,8 @@ int main(int argc, char *argv[]) {
                 }
 
                 arg_running_as = MANAGER_SYSTEM;
+
+                make_null_stdio();
                 log_set_target(detect_container(NULL) > 0 ? LOG_TARGET_JOURNAL : LOG_TARGET_JOURNAL_OR_KMSG);
 
                 if (!skip_setup) {
@@ -1297,18 +1300,20 @@ int main(int argc, char *argv[]) {
         }
 
         /* Initialize default unit */
-        if (r == set_default_unit(SPECIAL_DEFAULT_TARGET) < 0) {
+        r = set_default_unit(SPECIAL_DEFAULT_TARGET);
+        if (r < 0) {
                 log_error("Failed to set default unit %s: %s", SPECIAL_DEFAULT_TARGET, strerror(-r));
                 goto finish;
         }
 
         /* By default, mount "cpu" and "cpuacct" together */
-        arg_join_controllers = new(char**, 2);
+        arg_join_controllers = new(char**, 3);
         if (!arg_join_controllers)
                 goto finish;
 
-        arg_join_controllers[0] = strv_new("cpu", "cpuacct", NULL);
-        arg_join_controllers[1] = NULL;
+        arg_join_controllers[0] = strv_new("cpu", "cpuacct", "cpuset", NULL);
+        arg_join_controllers[1] = strv_new("net_cls", "net_prio", NULL);
+        arg_join_controllers[2] = NULL;
 
         if (!arg_join_controllers[0])
                 goto finish;
@@ -1436,10 +1441,8 @@ int main(int argc, char *argv[]) {
 
         /* Reset the console, but only if this is really init and we
          * are freshly booted */
-        if (arg_running_as == MANAGER_SYSTEM && arg_action == ACTION_RUN) {
+        if (arg_running_as == MANAGER_SYSTEM && arg_action == ACTION_RUN)
                 console_setup(getpid() == 1 && !skip_setup);
-                make_null_stdio();
-        }
 
         /* Open the logging devices, if possible and necessary */
         log_open();
@@ -1508,11 +1511,11 @@ int main(int argc, char *argv[]) {
 
         if (arg_running_as == MANAGER_USER) {
                 /* Become reaper of our children */
-                r = prctl(PR_SET_CHILD_SUBREAPER, 1);
-                if (r < 0)
-                        log_error("Failed to prctl(PR_SET_CHILD_SUBREAPER): %s", strerror(-r));
-                if (r == -EINVAL)
-                        log_error("Perhaps the kernel version is too old (< 3.4?)");
+                if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) {
+                        log_warning("Failed to make us a subreaper: %m");
+                        if (errno == EINVAL)
+                                log_info("Perhaps the kernel version is too old (< 3.4?)");
+                }
         }
 
         r = manager_new(arg_running_as, &m);