chiark / gitweb /
load-fragment: fix bad memory access
[elogind.git] / src / core / service.c
index 2a4e691e789fd0a9e3a44c9b1c0b755d72fdc111..7eaac0dc4cb7e9f4437cdaca5282be9be280e3c6 100644 (file)
@@ -326,13 +326,13 @@ static char *sysv_translate_name(const char *name) {
                 return NULL;
 
         if (endswith(name, ".sh"))
-                /* Drop Debian-style .sh suffix */
+                /* Drop .sh suffix */
                 strcpy(stpcpy(r, name) - 3, ".service");
         if (startswith(name, "rc."))
-                /* Drop Frugalware-style rc. prefix */
+                /* Drop rc. prefix */
                 strcpy(stpcpy(r, name + 3), ".service");
         else
-                /* Normal init scripts */
+                /* Normal init script name */
                 strcpy(stpcpy(r, name), ".service");
 
         return r;
@@ -1012,14 +1012,14 @@ static int service_load_sysv_name(Service *s, const char *name) {
                 r = service_load_sysv_path(s, path);
 
                 if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
-                        /* Try Debian style *.sh source'able init scripts */
+                        /* Try *.sh source'able init scripts */
                         strcat(path, ".sh");
                         r = service_load_sysv_path(s, path);
                 }
                 free(path);
 
                 if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
-                        /* Try Frugalware style rc.* init scripts */
+                        /* Try rc.* init scripts */
 
                         path = strjoin(*p, "/rc.", name, NULL);
                         if (!path)
@@ -2926,15 +2926,25 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                 s->main_pid = 0;
                 exec_status_exit(&s->main_exec_status, &s->exec_context, pid, code, status);
 
-                /* If this is not a forking service than the main
-                 * process got started and hence we copy the exit
-                 * status so that it is recorded both as main and as
-                 * control process exit status */
                 if (s->main_command) {
+                        /* If this is not a forking service than the
+                         * main process got started and hence we copy
+                         * the exit status so that it is recorded both
+                         * as main and as control process exit
+                         * status */
+
                         s->main_command->exec_status = s->main_exec_status;
 
                         if (s->main_command->ignore)
                                 f = SERVICE_SUCCESS;
+                } else if (s->exec_command[SERVICE_EXEC_START]) {
+
+                        /* If this is a forked process, then we should
+                         * ignore the return value if this was
+                         * configured for the starter process */
+
+                        if (s->exec_command[SERVICE_EXEC_START]->ignore)
+                                f = SERVICE_SUCCESS;
                 }
 
                 log_struct(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,