chiark / gitweb /
reword a few log messages
[elogind.git] / src / service.c
index d4b874d62432292361625c198e709349fa964550..e1975eb119112c4e7c7d8b9adc72201714969454 100644 (file)
@@ -40,7 +40,7 @@
 typedef enum RunlevelType {
         RUNLEVEL_UP,
         RUNLEVEL_DOWN,
-        RUNLEVEL_BASIC
+        RUNLEVEL_SYSINIT
 } RunlevelType;
 
 static const struct {
@@ -58,10 +58,10 @@ static const struct {
         { "rc6.d",  SPECIAL_RUNLEVEL6_TARGET, RUNLEVEL_DOWN },
 
         /* SUSE style boot.d */
-        { "boot.d", SPECIAL_BASIC_TARGET,     RUNLEVEL_BASIC },
+        { "boot.d", SPECIAL_SYSINIT_TARGET,   RUNLEVEL_SYSINIT },
 
         /* Debian style rcS.d */
-        { "rcS.d",  SPECIAL_BASIC_TARGET,     RUNLEVEL_BASIC },
+        { "rcS.d",  SPECIAL_SYSINIT_TARGET,   RUNLEVEL_SYSINIT },
 };
 
 #define RUNLEVELS_UP "12345"
@@ -203,7 +203,7 @@ static int sysv_translate_facility(const char *name, char **_r) {
                 /* Debian extensions */
                 "$mail-transport-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
                 "$mail-transfer-agent",  SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
-                "$x-display-manager",    SPECIAL_DISPLAY_MANAGER_TARGET,
+                "$x-display-manager",    SPECIAL_DISPLAY_MANAGER_SERVICE
         };
 
         unsigned i;
@@ -340,9 +340,6 @@ static int service_load_sysv_path(Service *s, const char *path) {
                 goto finish;
         }
 
-        s->type = SERVICE_FORKING;
-        s->restart = SERVICE_ONCE;
-
         free(s->sysv_path);
         if (!(s->sysv_path = strdup(path))) {
                 r = -ENOMEM;
@@ -599,6 +596,19 @@ static int service_load_sysv_path(Service *s, const char *path) {
 
                                 u->meta.description = d;
 
+                        } else if (startswith_no_case(t, "X-Interactive:")) {
+                                int b;
+
+                                if ((b = parse_boolean(strstrip(t+14))) < 0) {
+                                        log_warning("[%s:%u] Couldn't parse interactive flag. Ignoring.", path, line);
+                                        continue;
+                                }
+
+                                if (b)
+                                        s->exec_context.std_input = EXEC_INPUT_TTY;
+                                else
+                                        s->exec_context.std_input = EXEC_INPUT_NULL;
+
                         } else if (state == LSB_DESCRIPTION) {
 
                                 if (startswith(l, "#\t") || startswith(l, "#  ")) {
@@ -637,8 +647,10 @@ static int service_load_sysv_path(Service *s, const char *path) {
                 s->timeout_usec = 0;
 
         /* Special setting for all SysV services */
+        s->type = SERVICE_FORKING;
         s->valid_no_process = true;
         s->kill_mode = KILL_PROCESS_GROUP;
+        s->restart = SERVICE_ONCE;
 
         u->meta.load_state = UNIT_LOADED;
         r = 0;
@@ -1365,7 +1377,7 @@ static void service_enter_stop_post(Service *s, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to run stop-post executable: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'stop-post' task: %s", UNIT(s)->meta.id, strerror(-r));
         service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
 }
 
@@ -1461,7 +1473,7 @@ static void service_enter_stop(Service *s, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to run stop executable: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'stop' task: %s", UNIT(s)->meta.id, strerror(-r));
         service_enter_signal(s, SERVICE_STOP_SIGTERM, false);
 }
 
@@ -1506,7 +1518,7 @@ static void service_enter_start_post(Service *s) {
         return;
 
 fail:
-        log_warning("%s failed to run start-post executable: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'start-post' task: %s", UNIT(s)->meta.id, strerror(-r));
         service_enter_stop(s, false);
 }
 
@@ -1572,7 +1584,7 @@ static void service_enter_start(Service *s) {
         return;
 
 fail:
-        log_warning("%s failed to run start exectuable: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'start' task: %s", UNIT(s)->meta.id, strerror(-r));
         service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
 }
 
@@ -1601,7 +1613,7 @@ static void service_enter_start_pre(Service *s) {
         return;
 
 fail:
-        log_warning("%s failed to run start-pre executable: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'start-pre' task: %s", UNIT(s)->meta.id, strerror(-r));
         service_enter_dead(s, false, true);
 }
 
@@ -1648,7 +1660,7 @@ static void service_enter_reload(Service *s) {
         return;
 
 fail:
-        log_warning("%s failed to run reload executable: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'reload' task: %s", UNIT(s)->meta.id, strerror(-r));
         service_enter_stop(s, false);
 }
 
@@ -1678,7 +1690,7 @@ static void service_run_next(Service *s, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to run spawn next executable: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run spawn next task: %s", UNIT(s)->meta.id, strerror(-r));
 
         if (s->state == SERVICE_START_PRE)
                 service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
@@ -1951,14 +1963,18 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                         break;
 
                 case SERVICE_START:
-                        assert(s->type == SERVICE_FINISH);
+                        if (s->type == SERVICE_FINISH) {
+                                /* This was our main goal, so let's go on */
+                                if (success)
+                                        service_enter_start_post(s);
+                                else
+                                        service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
+                                break;
+                        } else {
+                                assert(s->type == SERVICE_DBUS);
 
-                        /* This was our main goal, so let's go on */
-                        if (success)
-                                service_enter_start_post(s);
-                        else
-                                service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
-                        break;
+                                /* Fall through */
+                        }
 
                 case SERVICE_RUNNING:
                         service_enter_running(s, success);
@@ -2252,7 +2268,7 @@ static int service_enumerate(Manager *m) {
                                 }
 
                                 if (de->d_name[0] == 'S' &&
-                                    (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_BASIC))
+                                    (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT))
                                         SERVICE(service)->sysv_start_priority =
                                                 MAX(a*10 + b, SERVICE(service)->sysv_start_priority);
 
@@ -2271,7 +2287,9 @@ static int service_enumerate(Manager *m) {
                                         if ((r = unit_add_dependency(service, UNIT_BEFORE, runlevel_target, true)) < 0)
                                                 goto finish;
 
-                                } else if (de->d_name[0] == 'K' && rcnd_table[i].type == RUNLEVEL_DOWN) {
+                                } else if (de->d_name[0] == 'K' &&
+                                           (rcnd_table[i].type == RUNLEVEL_DOWN ||
+                                            rcnd_table[i].type == RUNLEVEL_SYSINIT)) {
                                         Unit *shutdown_target;
 
                                         /* We honour K links only for
@@ -2283,7 +2301,12 @@ static int service_enumerate(Manager *m) {
                                          * really distuingish here
                                          * between the runlevels 0 and
                                          * 6 and just add them to the
-                                         * special shutdown target. */
+                                         * special shutdown target. On
+                                         * SUSE the boot.d/ runlevel
+                                         * is also used for shutdown,
+                                         * so we add links for that
+                                         * too to the shutdown
+                                         * target.*/
 
                                         if ((r = manager_load_unit(m, SPECIAL_SHUTDOWN_TARGET, NULL, &shutdown_target)) < 0)
                                                 goto finish;