chiark / gitweb /
path-lookup: make inclusion of user private units optional
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Jul 2011 02:17:38 +0000 (04:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Jul 2011 02:31:20 +0000 (04:31 +0200)
src/manager.c
src/path-lookup.c
src/path-lookup.h
src/systemctl.c

index 3291275d0a41d3c630d403569fdd4c60de694de8..c1242ae8b35b36d446eca84e73958e0290f591e8 100644 (file)
@@ -258,7 +258,7 @@ int manager_new(ManagerRunningAs running_as, Manager **_m) {
         if ((m->epoll_fd = epoll_create1(EPOLL_CLOEXEC)) < 0)
                 goto fail;
 
-        if ((r = lookup_paths_init(&m->lookup_paths, m->running_as)) < 0)
+        if ((r = lookup_paths_init(&m->lookup_paths, m->running_as, true)) < 0)
                 goto fail;
 
         if ((r = manager_setup_signals(m)) < 0)
@@ -2822,7 +2822,7 @@ int manager_reload(Manager *m) {
 
         /* Find new unit paths */
         lookup_paths_free(&m->lookup_paths);
-        if ((q = lookup_paths_init(&m->lookup_paths, m->running_as)) < 0)
+        if ((q = lookup_paths_init(&m->lookup_paths, m->running_as, true)) < 0)
                 r = q;
 
         manager_run_generators(m);
index b45467c98df35f6ce6476c50d6dd8d282e40fb8d..84a9859254eebcd263072b7efe193fd92cc4ce94 100644 (file)
@@ -163,7 +163,7 @@ fail:
         goto finish;
 }
 
-int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
+int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as, bool personal) {
         const char *e;
         char *t;
 
@@ -181,8 +181,27 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
                 strv_free(p->unit_path);
 
                 if (running_as == MANAGER_USER) {
-                        if (!(p->unit_path = user_dirs()))
+
+                        if (personal)
+                                p->unit_path = user_dirs();
+                        else
+                                p->unit_path = strv_new(
+                                                /* If you modify this you also want to modify
+                                                 * systemduserunitpath= in systemd.pc.in, and
+                                                 * the arrays in user_dirs() above! */
+                                                "/run/systemd/user",
+                                                USER_CONFIG_UNIT_PATH,
+                                                "/etc/systemd/system",
+                                                "/usr/local/lib/systemd/user",
+                                                "/usr/local/share/systemd/user",
+                                                USER_DATA_UNIT_PATH,
+                                                "/usr/lib/systemd/user",
+                                                "/usr/share/systemd/user",
+                                                NULL);
+
+                        if (!p->unit_path)
                                 return -ENOMEM;
+
                 } else
                         if (!(p->unit_path = strv_new(
                                               /* If you modify this you also want to modify
@@ -192,8 +211,8 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
                                               "/etc/systemd/system",
                                               "/usr/local/lib/systemd/system",
                                               "/usr/lib/systemd/system",
-                                              "/lib/systemd/system",
                                               SYSTEM_DATA_UNIT_PATH,
+                                              "/lib/systemd/system",
                                               NULL)))
                                 return -ENOMEM;
         }
index e06f9793d27c9841a5693404d0bac4decb26c954..fc2887d3c7cf956a4f4f87974d013fc45fd02796 100644 (file)
@@ -34,7 +34,7 @@ typedef struct LookupPaths {
 
 int user_config_home(char **config_home);
 
-int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as);
+int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as, bool personal);
 void lookup_paths_free(LookupPaths *p);
 
 #endif
index 3767e221354f7e8575f3a468d69eff4905b324fb..63eb3245d087acd2e0d650a75212917599ed55ee 100644 (file)
@@ -4139,7 +4139,7 @@ static int enable_unit(DBusConnection *bus, char **args, unsigned n) {
         dbus_error_init(&error);
 
         zero(paths);
-        if ((r = lookup_paths_init(&paths, arg_user ? MANAGER_USER : MANAGER_SYSTEM)) < 0) {
+        if ((r = lookup_paths_init(&paths, arg_user ? MANAGER_USER : MANAGER_SYSTEM, true)) < 0) {
                 log_error("Failed to determine lookup paths: %s", strerror(-r));
                 goto finish;
         }