chiark / gitweb /
execute: automatically record start/exit timestamps for forked processes
[elogind.git] / main.c
diff --git a/main.c b/main.c
index 15ed0f1e2e75af78048037e9bef537d995513778..139770edeccc5d230af7448277bd14bbd3c6e150 100644 (file)
--- a/main.c
+++ b/main.c
@@ -32,6 +32,8 @@
 #include "manager.h"
 #include "log.h"
 #include "mount-setup.h"
+#include "hostname-setup.h"
+#include "load-fragment.h"
 
 static enum {
         ACTION_RUN,
@@ -70,7 +72,7 @@ static int parse_proc_cmdline_word(const char *word) {
         };
 
         if (startswith(word, "systemd.default="))
-                return set_default_unit(word + 15);
+                return set_default_unit(word + 16);
 
         else if (startswith(word, "systemd.log_target=")) {
 
@@ -222,7 +224,7 @@ static int help(void) {
                "     --default=UNIT       Set default unit\n"
                "     --log-level=LEVEL    Set log level\n"
                "     --log-target=TARGET  Set log target (console, syslog, kmsg)\n"
-               "     --running-as=AS      Set running as (init, system, sesstion)\n"
+               "     --running-as=AS      Set running as (init, system, session)\n"
                "     --test               Determine startup sequence, dump it and exit\n",
                __progname);
 
@@ -247,7 +249,8 @@ int main(int argc, char *argv[]) {
 
         /* Mount /proc, /sys and friends, so that /proc/cmdline and
          * /proc/$PID/fd is available. */
-        mount_setup();
+        if (mount_setup() < 0)
+                goto finish;
 
         /* Reset all signal handlers. */
         assert_se(reset_all_signal_handlers() == 0);
@@ -271,6 +274,9 @@ int main(int argc, char *argv[]) {
 
         assert_se(action == ACTION_RUN || action == ACTION_TEST);
 
+        /* Set up PATH unless it is already set */
+        setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", false);
+
         /* Move out of the way, so that we won't block unmounts */
         assert_se(chdir("/")  == 0);
 
@@ -289,6 +295,10 @@ int main(int argc, char *argv[]) {
 
         log_debug("systemd running in %s mode.", manager_running_as_to_string(running_as));
 
+        if (running_as == MANAGER_INIT)
+                if (hostname_setup() < 0)
+                        goto finish;
+
         if ((r = manager_new(running_as, &m)) < 0) {
                 log_error("Failed to allocate manager object: %s", strerror(-r));
                 goto finish;
@@ -303,7 +313,12 @@ int main(int argc, char *argv[]) {
 
         if ((r = manager_load_unit(m, default_unit, &target)) < 0) {
                 log_error("Failed to load default target: %s", strerror(-r));
-                goto finish;
+
+                log_info("Trying to load rescue target...");
+                if ((r = manager_load_unit(m, SPECIAL_RESCUE_TARGET, &target)) < 0) {
+                        log_error("Failed to load rescue target: %s", strerror(-r));
+                        goto finish;
+                }
         }
 
         if (action == ACTION_TEST) {