chiark / gitweb /
service: properly remember if a sysv is actually enabled
authorLennart Poettering <lennart@poettering.net>
Mon, 9 Aug 2010 15:12:25 +0000 (17:12 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 9 Aug 2010 15:12:25 +0000 (17:12 +0200)
Previously we checked the SysV priority value to figure out if a SysV
unit was enabled or not, since th value was mostly read from the S
startup links. Since we read this value from the LSB headers as a
fallback we hence ended up considering a lot more services enabled than
were actually enabled.

This patch adds an explicit boolean which encodes whether a sysv service
is enabled or not via S links.

https://bugzilla.redhat.com/show_bug.cgi?id=615293

src/service.c
src/service.h

index fce1b27..f081705 100644 (file)
@@ -566,7 +566,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
 
                                         if (unit_name_to_type(m) == UNIT_SERVICE)
                                                 r = unit_add_name(u, m);
 
                                         if (unit_name_to_type(m) == UNIT_SERVICE)
                                                 r = unit_add_name(u, m);
-                                        else if (s->sysv_start_priority >= 0)
+                                        else if (s->sysv_enabled)
                                                 r = unit_add_two_dependencies_by_name_inverse(u, UNIT_AFTER, UNIT_WANTS, m, NULL, true);
                                         else
                                                 r = unit_add_dependency_by_name_inverse(u, UNIT_AFTER, m, NULL, true);
                                                 r = unit_add_two_dependencies_by_name_inverse(u, UNIT_AFTER, UNIT_WANTS, m, NULL, true);
                                         else
                                                 r = unit_add_dependency_by_name_inverse(u, UNIT_AFTER, m, NULL, true);
@@ -1006,8 +1006,10 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (s->sysv_start_priority >= 0)
                 fprintf(f,
 
         if (s->sysv_start_priority >= 0)
                 fprintf(f,
-                        "%sSysVStartPriority: %i\n",
-                        prefix, s->sysv_start_priority);
+                        "%sSysVStartPriority: %i\n"
+                        "%sSysVEnabled: %s\n",
+                        prefix, s->sysv_start_priority,
+                        prefix, yes_no(s->sysv_enabled));
 
         if (s->sysv_runlevels)
                 fprintf(f, "%sSysVRunLevels: %s\n",
 
         if (s->sysv_runlevels)
                 fprintf(f, "%sSysVRunLevels: %s\n",
@@ -2627,9 +2629,11 @@ static int service_enumerate(Manager *m) {
                                 }
 
                                 if (de->d_name[0] == 'S' &&
                                 }
 
                                 if (de->d_name[0] == 'S' &&
-                                    (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT))
+                                    (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);
                                         SERVICE(service)->sysv_start_priority =
                                                 MAX(a*10 + b, SERVICE(service)->sysv_start_priority);
+                                        SERVICE(service)->sysv_enabled = true;
+                                }
 
                                 manager_dispatch_load_queue(m);
                                 service = unit_follow_merge(service);
 
                                 manager_dispatch_load_queue(m);
                                 service = unit_follow_merge(service);
index 0ddaaa4..3e18d22 100644 (file)
@@ -111,18 +111,14 @@ struct Service {
         bool root_directory_start_only;
         bool valid_no_process;
 
         bool root_directory_start_only;
         bool valid_no_process;
 
-        bool main_pid_known:1;
-
         /* If we shut down, remember why */
         bool failure:1;
         /* If we shut down, remember why */
         bool failure:1;
-
+        bool main_pid_known:1;
         bool bus_name_good:1;
         bool bus_name_good:1;
-
         bool allow_restart:1;
         bool allow_restart:1;
-
         bool got_socket_fd:1;
         bool got_socket_fd:1;
-
         bool sysv_has_lsb:1;
         bool sysv_has_lsb:1;
+        bool sysv_enabled:1;
 
         int socket_fd;
         int sysv_start_priority;
 
         int socket_fd;
         int sysv_start_priority;