chiark / gitweb /
Use _cleanup_ when reading config files
[elogind.git] / src / core / service.c
index 4451d38eefdbd103b9d54712e902ec4b51fa64f4..a104b300c3724994bf3c5a9df6d832617fc2322b 100644 (file)
@@ -762,7 +762,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                                 continue;
 
                                         if (unit_name_to_type(m) == UNIT_SERVICE)
-                                                r = unit_add_name(u, m);
+                                                r = unit_merge_by_name(u, m);
                                         else
                                                 /* NB: SysV targets
                                                  * which are provided
@@ -1148,6 +1148,16 @@ static int service_add_default_dependencies(Service *s) {
                                                       SPECIAL_SOCKETS_TARGET, NULL, true);
                 if (r < 0)
                         return r;
+
+                r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES,
+                                                      SPECIAL_TIMERS_TARGET, NULL, true);
+                if (r < 0)
+                        return r;
+
+                r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES,
+                                                      SPECIAL_PATHS_TARGET, NULL, true);
+                if (r < 0)
+                        return r;
         }
 
         /* Second, activate normal shutdown */
@@ -3436,7 +3446,7 @@ static int service_enumerate(Manager *m) {
         unsigned i;
         DIR _cleanup_closedir_ *d = NULL;
         char _cleanup_free_ *path = NULL, *fpath = NULL, *name = NULL;
-        Set *runlevel_services[ELEMENTSOF(rcnd_table)];
+        Set *runlevel_services[ELEMENTSOF(rcnd_table)] = {};
         Set _cleanup_set_free_ *shutdown_services = NULL;
         Unit *service;
         Iterator j;
@@ -3447,8 +3457,6 @@ static int service_enumerate(Manager *m) {
         if (m->running_as != SYSTEMD_SYSTEM)
                 return 0;
 
-        zero(runlevel_services);
-
         STRV_FOREACH(p, m->lookup_paths.sysvrcnd_path)
                 for (i = 0; i < ELEMENTSOF(rcnd_table); i ++) {
                         struct dirent *de;