[systemd-commits] 5 commits - src/core src/shared src/systemctl src/test TODO

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Tue Sep 18 23:31:30 PDT 2012


 TODO                      |    9 -----
 src/core/automount.c      |    2 -
 src/core/cgroup.c         |    2 -
 src/core/dbus-manager.c   |   20 +++++------
 src/core/dbus.c           |   24 ++++++-------
 src/core/main.c           |   38 +++++++++++-----------
 src/core/manager.c        |   47 +++++++++++----------------
 src/core/manager.h        |   14 +-------
 src/core/mount.c          |    6 +--
 src/core/path.c           |    2 -
 src/core/service.c        |    6 +--
 src/core/socket.c         |    2 -
 src/core/swap.c           |    4 +-
 src/core/timer.c          |    2 -
 src/core/unit-printf.c    |    2 -
 src/core/unit.c           |    6 +--
 src/shared/dbus-common.c  |    6 +++
 src/shared/dbus-common.h  |    3 +
 src/shared/install.c      |    2 -
 src/shared/path-lookup.c  |   14 ++++++--
 src/shared/path-lookup.h  |   12 +++++-
 src/systemctl/systemctl.c |   79 ++++++++++++++++++++++------------------------
 src/test/test-engine.c    |    2 -
 23 files changed, 151 insertions(+), 153 deletions(-)

New commits:
commit 49111a708eb3bc8488c56c4695fa36c826bf3657
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Sep 18 22:03:34 2012 +0200

    systemctl: warn about triggering units only at the end
    
    Instead of checking each unit separately, check once at the end. This
    should avoid spurious warnings about a service being triggerable by
    other stuff.

diff --git a/TODO b/TODO
index c941cb0..ec961ea 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,4 @@
 Bugfixes:
-* there is nothing to warn about here :)
-  $ systemctl stop systemd-udevd.service systemd-udevd-kernel.socket systemd-udevd-control.socket
-  Warning: Stopping systemd-udevd.service, but it can still be activated by:
-  systemd-udevd-control.socket
-  systemd-udevd-kernel.socket
-
 * check systemd-tmpfiles for selinux context hookup for mknod(), symlink() and similar
 
 * swap units that are activated by one name but shown in the kernel under another are semi-broken
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 729d4dd..cc9c775 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1584,11 +1584,6 @@ static int start_unit_one(
                 p = NULL;
         }
 
-        /* When stopping a unit warn if it can still be triggered by
-         * another active unit (socket, path, timer) */
-        if (!arg_quiet && streq(method, "StopUnit"))
-                check_triggering_units(bus, name);
-
         return 0;
 }
 
@@ -1723,6 +1718,16 @@ static int start_unit(DBusConnection *bus, char **args) {
                         ret = r;
                         goto finish;
                 }
+
+                /* When stopping units, warn if they can still be triggered by
+                 * another active unit (socket, path, timer) */
+                if (!arg_quiet && streq(method, "StopUnit")) {
+                        if (one_name)
+                                check_triggering_units(bus, one_name);
+                        else
+                                STRV_FOREACH(name, args+1)
+                                        check_triggering_units(bus, *name);
+                }
         }
 
 finish:

commit d39b034af6f9795c4f17a8ddd186f026bb74193c
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Wed Sep 19 08:15:07 2012 +0200

    systemctl: properly report success
    
    Systemctl would always return 1, because it treated uninteresting dbus
    messages ("job added") as errors. Just ignore everything apart from
    interesting ("job removed") messages.

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 15c0866..729d4dd 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1322,7 +1322,10 @@ static int wait_for_jobs(DBusConnection *bus, Set *s) {
                         return -ECONNREFUSED;
                 }
 
-                if (!arg_quiet && d.result) {
+                if (!d.result)
+                        goto free_name;
+
+                if (!arg_quiet) {
                         if (streq(d.result, "timeout"))
                                 log_error("Job for %s timed out.", strna(d.name));
                         else if (streq(d.result, "canceled"))
@@ -1343,11 +1346,12 @@ static int wait_for_jobs(DBusConnection *bus, Set *s) {
                 free(d.result);
                 d.result = NULL;
 
+        free_name:
                 free(d.name);
                 d.name = NULL;
         }
 
-        /* This is slightly dirty, since we don't undo the filter registration. */
+        dbus_connection_remove_filter(bus, wait_filter, &d);
         return r;
 }
 

commit 46eddbb597a379ef64a3ee76029ce625902e8107
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Sep 18 20:37:15 2012 +0200

    systemctl: use automatic cleanup once more
    
    Semantics are slightly different, because before unit_name_mangle
    returning NULL was ignored, and now it is reported as oom. But
    unit_name_mangle only returns NULL on oom.

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 367dd80..15c0866 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1452,10 +1452,14 @@ static void check_triggering_units(
         int r;
 
         n = unit_name_mangle(unit_name);
-        unit_path = unit_dbus_path_from_name(n ? n : unit_name);
+        if (!n) {
+                log_oom();
+                return;
+        }
 
+        unit_path = unit_dbus_path_from_name(n);
         if (!unit_path) {
-                log_error("Could not allocate dbus path.");
+                log_oom();
                 return;
         }
 
@@ -1515,7 +1519,7 @@ static int start_unit_one(
                 DBusError *error,
                 Set *s) {
 
-        DBusMessage *reply = NULL;
+        DBusMessage _cleanup_dbus_msg_unref_ *reply = NULL;
         const char *path;
         int r;
         _cleanup_free_ char *n, *p = NULL;
@@ -1548,15 +1552,14 @@ static int start_unit_one(
                 else
                         log_error("Failed to issue method call: %s", bus_error_message(error));
 
-                goto finish;
+                return r;
         }
 
         if (!dbus_message_get_args(reply, error,
                                    DBUS_TYPE_OBJECT_PATH, &path,
                                    DBUS_TYPE_INVALID)) {
                 log_error("Failed to parse reply: %s", bus_error_message(error));
-                r = -EIO;
-                goto finish;
+                return -EIO;
         }
 
         if (need_daemon_reload(bus, n))
@@ -1565,15 +1568,13 @@ static int start_unit_one(
 
         if (s) {
                 p = strdup(path);
-                if (!p) {
-                        r = log_oom();
-                        goto finish;
-                }
+                if (!p)
+                        return log_oom();
 
                 r = set_put(s, p);
                 if (r < 0) {
                         log_error("Failed to add path to set.");
-                        goto finish;
+                        return r;
                 }
 
                 p = NULL;
@@ -1584,13 +1585,7 @@ static int start_unit_one(
         if (!arg_quiet && streq(method, "StopUnit"))
                 check_triggering_units(bus, name);
 
-        r = 0;
-
-finish:
-        if (reply)
-                dbus_message_unref(reply);
-
-        return r;
+        return 0;
 }
 
 static enum action verb_to_action(const char *verb) {

commit d3b52baff90876a648e321f3658a74bc58a8647c
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Sep 18 20:22:57 2012 +0200

    systemctl: use automatic cleanup
    
    Introduce a helper method to unref dbus messages and use it.

diff --git a/src/shared/dbus-common.c b/src/shared/dbus-common.c
index 0c73d6c..c53bf59 100644
--- a/src/shared/dbus-common.c
+++ b/src/shared/dbus-common.c
@@ -1318,3 +1318,9 @@ finish:
 
         return r;
 }
+
+
+void dbus_message_unref_p(DBusMessage **reply) {
+        if (*reply)
+                dbus_message_unref(*reply);
+}
diff --git a/src/shared/dbus-common.h b/src/shared/dbus-common.h
index e49c3b5..7294206 100644
--- a/src/shared/dbus-common.h
+++ b/src/shared/dbus-common.h
@@ -213,3 +213,6 @@ int bus_method_call_with_reply(DBusConnection *bus,
                                DBusMessage **return_reply,
                                DBusError *return_error,
                                int first_arg_type, ...);
+
+void dbus_message_unref_p(DBusMessage **reply);
+#define _cleanup_dbus_msg_unref_ __attribute__((cleanup(dbus_message_unref_p)))
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 0e564a5..367dd80 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1441,22 +1441,22 @@ static void check_triggering_units(
                 DBusConnection *bus,
                 const char *unit_name) {
 
-        DBusMessage *reply = NULL;
+        DBusMessage _cleanup_dbus_msg_unref_ *reply = NULL;
         DBusMessageIter iter, sub;
         char *service_trigger = NULL;
         const char *interface = "org.freedesktop.systemd1.Unit",
                    *triggered_by_property = "TriggeredBy";
 
-        char *unit_path = NULL, *n = NULL;
+        char _cleanup_free_ *unit_path = NULL, *n = NULL;
         bool print_warning_label = true;
         int r;
 
         n = unit_name_mangle(unit_name);
         unit_path = unit_dbus_path_from_name(n ? n : unit_name);
-        free(n);
+
         if (!unit_path) {
                 log_error("Could not allocate dbus path.");
-                goto finish;
+                return;
         }
 
         r = bus_method_call_with_reply (
@@ -1471,13 +1471,12 @@ static void check_triggering_units(
                         DBUS_TYPE_STRING, &triggered_by_property,
                         DBUS_TYPE_INVALID);
         if (r)
-                goto finish;
+                return;
 
         if (!dbus_message_iter_init(reply, &iter) ||
             dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
                 log_error("Failed to parse reply.");
-                goto finish;
-
+                return;
         }
 
         dbus_message_iter_recurse(&iter, &sub);
@@ -1488,14 +1487,14 @@ static void check_triggering_units(
 
                 if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
                         log_error("Failed to parse reply.");
-                        goto finish;
+                        return;
                 }
 
                 dbus_message_iter_get_basic(&sub, &service_trigger);
 
                 r = check_one_unit(bus, service_trigger, true);
                 if (r < 0)
-                        goto finish;
+                        return;
                 if (r == 0) {
                         if (print_warning_label) {
                                 log_warning("Warning: Stopping %s, but it can still be activated by:", unit_name);
@@ -1506,11 +1505,6 @@ static void check_triggering_units(
 
                 dbus_message_iter_next(&sub);
         }
-finish:
-        if (reply)
-                dbus_message_unref(reply);
-
-        free(unit_path);
 }
 
 static int start_unit_one(

commit 67445f4e22ad924394acdd4fd49e6f238244a5ca
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Sep 18 17:11:12 2012 +0200

    core: move ManagerRunningAs to shared
    
    Note: I did s/MANAGER/SYSTEMD/ everywhere, even though it makes the
    patch quite verbose. Nevertheless, keeping MANAGER prefix in some
    places, and SYSTEMD prefix in others would just lead to confusion down
    the road. Better to rip off the band-aid now.

diff --git a/TODO b/TODO
index 0eca82a..c941cb0 100644
--- a/TODO
+++ b/TODO
@@ -19,9 +19,6 @@ Bugfixes:
 
 * properly handle .mount unit state tracking when two mount points are stacked one on top of another on the exact same mount point.
 
-* we pull src/core/manager.h into src/shared/src/shared/path-lookup.c which is the wrong direction
-   rename enum "ManagerRunningAs" to "SystemdRunningAs" and move it to shared/
-
 F18:
 
 * https://bugzilla.gnome.org/show_bug.cgi?id=680689
diff --git a/src/core/automount.c b/src/core/automount.c
index c9b87d5..11b6a6a 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -156,7 +156,7 @@ static int automount_add_default_dependencies(Automount *a) {
 
         assert(a);
 
-        if (UNIT(a)->manager->running_as != MANAGER_SYSTEM)
+        if (UNIT(a)->manager->running_as != SYSTEMD_SYSTEM)
                 return 0;
 
         r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 8ddb111..8fc1731 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -313,7 +313,7 @@ int manager_setup_cgroup(Manager *m) {
                 goto finish;
         }
 
-        if (m->running_as == MANAGER_SYSTEM)
+        if (m->running_as == SYSTEMD_SYSTEM)
                 strcpy(suffix, "/system");
         else {
                 snprintf(suffix, sizeof(suffix), "/systemd-%lu", (unsigned long) getpid());
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 2235e36..276ad6c 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1100,7 +1100,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
 
         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Exit")) {
 
-                if (m->running_as == MANAGER_SYSTEM) {
+                if (m->running_as == SYSTEMD_SYSTEM) {
                         dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Exit is only supported for user service managers.");
                         return bus_send_error_reply(connection, message, &error, -ENOTSUP);
                 }
@@ -1112,7 +1112,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
 
         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Reboot")) {
 
-                if (m->running_as != MANAGER_SYSTEM) {
+                if (m->running_as != SYSTEMD_SYSTEM) {
                         dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers.");
                         return bus_send_error_reply(connection, message, &error, -ENOTSUP);
                 }
@@ -1124,7 +1124,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
 
         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "PowerOff")) {
 
-                if (m->running_as != MANAGER_SYSTEM) {
+                if (m->running_as != SYSTEMD_SYSTEM) {
                         dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers.");
                         return bus_send_error_reply(connection, message, &error, -ENOTSUP);
                 }
@@ -1136,7 +1136,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
 
         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Halt")) {
 
-                if (m->running_as != MANAGER_SYSTEM) {
+                if (m->running_as != SYSTEMD_SYSTEM) {
                         dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Halting is only supported for system managers.");
                         return bus_send_error_reply(connection, message, &error, -ENOTSUP);
                 }
@@ -1148,7 +1148,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
 
         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "KExec")) {
 
-                if (m->running_as != MANAGER_SYSTEM) {
+                if (m->running_as != SYSTEMD_SYSTEM) {
                         dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "kexec is only supported for system managers.");
                         return bus_send_error_reply(connection, message, &error, -ENOTSUP);
                 }
@@ -1177,7 +1177,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 if (!isempty(switch_root_init) && !path_is_absolute(switch_root_init))
                         return bus_send_error_reply(connection, message, NULL, -EINVAL);
 
-                if (m->running_as != MANAGER_SYSTEM) {
+                if (m->running_as != SYSTEMD_SYSTEM) {
                         dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Switching root is only supported for system managers.");
                         return bus_send_error_reply(connection, message, &error, -ENOTSUP);
                 }
@@ -1335,7 +1335,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 if (!h)
                         goto oom;
 
-                r = unit_file_get_list(m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h);
+                r = unit_file_get_list(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h);
                 if (r < 0) {
                         unit_file_list_free(h);
                         dbus_message_unref(reply);
@@ -1381,7 +1381,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                                     DBUS_TYPE_INVALID))
                         return bus_send_error_reply(connection, message, &error, -EINVAL);
 
-                state = unit_file_get_state(m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, name);
+                state = unit_file_get_state(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, name);
                 if (state < 0)
                         return bus_send_error_reply(connection, message, NULL, state);
 
@@ -1405,7 +1405,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
 
                 char **l = NULL;
                 DBusMessageIter iter;
-                UnitFileScope scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
+                UnitFileScope scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
                 UnitFileChange *changes = NULL;
                 unsigned n_changes = 0;
                 dbus_bool_t runtime, force;
@@ -1464,7 +1464,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
 
                 char **l = NULL;
                 DBusMessageIter iter;
-                UnitFileScope scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
+                UnitFileScope scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
                 UnitFileChange *changes = NULL;
                 unsigned n_changes = 0;
                 dbus_bool_t runtime;
diff --git a/src/core/dbus.c b/src/core/dbus.c
index f05f610..2a1c660 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -445,7 +445,7 @@ static DBusHandlerResult system_bus_message_filter(DBusConnection *connection, D
                 log_debug("System D-Bus connection terminated.");
                 bus_done_system(m);
 
-        } else if (m->running_as != MANAGER_SYSTEM &&
+        } else if (m->running_as != SYSTEMD_SYSTEM &&
                    dbus_message_is_signal(message, "org.freedesktop.systemd1.Agent", "Released")) {
 
                 const char *cgroup;
@@ -481,7 +481,7 @@ static DBusHandlerResult private_bus_message_filter(DBusConnection *connection,
 
         if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected"))
                 shutdown_connection(m, connection);
-        else if (m->running_as == MANAGER_SYSTEM &&
+        else if (m->running_as == SYSTEMD_SYSTEM &&
                  dbus_message_is_signal(message, "org.freedesktop.systemd1.Agent", "Released")) {
 
                 const char *cgroup;
@@ -776,7 +776,7 @@ static int init_registered_system_bus(Manager *m) {
         if (!dbus_connection_add_filter(m->system_bus, system_bus_message_filter, m, NULL))
                 return log_oom();
 
-        if (m->running_as != MANAGER_SYSTEM) {
+        if (m->running_as != SYSTEMD_SYSTEM) {
                 DBusError error;
 
                 dbus_error_init(&error);
@@ -838,7 +838,7 @@ static int init_registered_api_bus(Manager *m) {
         if (r < 0)
                 return r;
 
-        if (m->running_as == MANAGER_USER) {
+        if (m->running_as == SYSTEMD_USER) {
                 char *id;
                 log_debug("Successfully connected to API D-Bus bus %s as %s",
                          strnull((id = dbus_connection_get_server_id(m->api_bus))),
@@ -889,7 +889,7 @@ static void bus_register_cb(DBusPendingCall *pending, void *userdata) {
 
                 if (conn == &m->system_bus) {
                         r = init_registered_system_bus(m);
-                        if (r == 0 && m->running_as == MANAGER_SYSTEM)
+                        if (r == 0 && m->running_as == SYSTEMD_SYSTEM)
                                 r = init_registered_api_bus(m);
                 } else
                         r = init_registered_api_bus(m);
@@ -1019,7 +1019,7 @@ static int bus_init_api(Manager *m) {
         if (m->api_bus)
                 return 0;
 
-        if (m->running_as == MANAGER_SYSTEM) {
+        if (m->running_as == SYSTEMD_SYSTEM) {
                 m->api_bus = m->system_bus;
                 /* In this mode there is no distinct connection to the API bus,
                  * the API is published on the system bus.
@@ -1066,7 +1066,7 @@ static int bus_init_private(Manager *m) {
         if (m->private_bus)
                 return 0;
 
-        if (m->running_as == MANAGER_SYSTEM) {
+        if (m->running_as == SYSTEMD_SYSTEM) {
 
                 /* We want the private bus only when running as init */
                 if (getpid() != 1)
@@ -1190,7 +1190,7 @@ static void shutdown_connection(Manager *m, DBusConnection *c) {
 
         dbus_connection_set_dispatch_status_function(c, NULL, NULL, NULL);
         /* system manager cannot afford to block on DBus */
-        if (m->running_as != MANAGER_SYSTEM)
+        if (m->running_as != SYSTEMD_SYSTEM)
                 dbus_connection_flush(c);
         dbus_connection_close(c);
         dbus_connection_unref(c);
@@ -1200,7 +1200,7 @@ static void bus_done_api(Manager *m) {
         if (!m->api_bus)
                 return;
 
-        if (m->running_as == MANAGER_USER)
+        if (m->running_as == SYSTEMD_USER)
                 shutdown_connection(m, m->api_bus);
 
         m->api_bus = NULL;
@@ -1215,7 +1215,7 @@ static void bus_done_system(Manager *m) {
         if (!m->system_bus)
                 return;
 
-        if (m->running_as == MANAGER_SYSTEM)
+        if (m->running_as == SYSTEMD_SYSTEM)
                 bus_done_api(m);
 
         shutdown_connection(m, m->system_bus);
@@ -1362,11 +1362,11 @@ int bus_broadcast(Manager *m, DBusMessage *message) {
         assert(message);
 
         SET_FOREACH(c, m->bus_connections_for_dispatch, i)
-                if (c != m->system_bus || m->running_as == MANAGER_SYSTEM)
+                if (c != m->system_bus || m->running_as == SYSTEMD_SYSTEM)
                         oom = !dbus_connection_send(c, message, NULL);
 
         SET_FOREACH(c, m->bus_connections, i)
-                if (c != m->system_bus || m->running_as == MANAGER_SYSTEM)
+                if (c != m->system_bus || m->running_as == SYSTEMD_SYSTEM)
                         oom = !dbus_connection_send(c, message, NULL);
 
         return oom ? -ENOMEM : 0;
diff --git a/src/core/main.c b/src/core/main.c
index 9d2d551..04fc0b3 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -73,7 +73,7 @@ static enum {
 } arg_action = ACTION_RUN;
 
 static char *arg_default_unit = NULL;
-static ManagerRunningAs arg_running_as = _MANAGER_RUNNING_AS_INVALID;
+static SystemdRunningAs arg_running_as = _SYSTEMD_RUNNING_AS_INVALID;
 
 static bool arg_dump_core = true;
 static bool arg_crash_shell = false;
@@ -684,7 +684,7 @@ static int parse_config_file(void) {
         const char *fn;
         int r;
 
-        fn = arg_running_as == MANAGER_SYSTEM ? SYSTEM_CONFIG_FILE : USER_CONFIG_FILE;
+        fn = arg_running_as == SYSTEMD_SYSTEM ? SYSTEM_CONFIG_FILE : USER_CONFIG_FILE;
         f = fopen(fn, "re");
         if (!f) {
                 if (errno == ENOENT)
@@ -872,11 +872,11 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case ARG_SYSTEM:
-                        arg_running_as = MANAGER_SYSTEM;
+                        arg_running_as = SYSTEMD_SYSTEM;
                         break;
 
                 case ARG_USER:
-                        arg_running_as = MANAGER_USER;
+                        arg_running_as = SYSTEMD_USER;
                         break;
 
                 case ARG_TEST:
@@ -1289,7 +1289,7 @@ int main(int argc, char *argv[]) {
         if (getpid() == 1 && detect_container(NULL) <= 0) {
 
                 /* Running outside of a container as PID 1 */
-                arg_running_as = MANAGER_SYSTEM;
+                arg_running_as = SYSTEMD_SYSTEM;
                 make_null_stdio();
                 log_set_target(LOG_TARGET_KMSG);
                 log_open();
@@ -1349,7 +1349,7 @@ int main(int argc, char *argv[]) {
         } else if (getpid() == 1) {
 
                 /* Running inside a container, as PID 1 */
-                arg_running_as = MANAGER_SYSTEM;
+                arg_running_as = SYSTEMD_SYSTEM;
                 log_set_target(LOG_TARGET_CONSOLE);
                 log_open();
 
@@ -1359,7 +1359,7 @@ int main(int argc, char *argv[]) {
         } else {
 
                 /* Running as user instance */
-                arg_running_as = MANAGER_USER;
+                arg_running_as = SYSTEMD_USER;
                 log_set_target(LOG_TARGET_AUTO);
                 log_open();
         }
@@ -1400,7 +1400,7 @@ int main(int argc, char *argv[]) {
         if (parse_config_file() < 0)
                 goto finish;
 
-        if (arg_running_as == MANAGER_SYSTEM)
+        if (arg_running_as == SYSTEMD_SYSTEM)
                 if (parse_proc_cmdline() < 0)
                         goto finish;
 
@@ -1414,7 +1414,7 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        if (arg_running_as == MANAGER_SYSTEM &&
+        if (arg_running_as == SYSTEMD_SYSTEM &&
             arg_action == ACTION_RUN &&
             running_in_chroot() > 0) {
                 log_error("Cannot be run in a chroot() environment.");
@@ -1460,9 +1460,9 @@ int main(int argc, char *argv[]) {
 #else
                "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin",
 #endif
-               arg_running_as == MANAGER_SYSTEM);
+               arg_running_as == SYSTEMD_SYSTEM);
 
-        if (arg_running_as == MANAGER_SYSTEM) {
+        if (arg_running_as == SYSTEMD_SYSTEM) {
                 /* Parse the data passed to us. We leave this
                  * variables set, but the manager later on will not
                  * pass them on to our children. */
@@ -1493,7 +1493,7 @@ int main(int argc, char *argv[]) {
         /* Move out of the way, so that we won't block unmounts */
         assert_se(chdir("/")  == 0);
 
-        if (arg_running_as == MANAGER_SYSTEM) {
+        if (arg_running_as == SYSTEMD_SYSTEM) {
                 /* Become a session leader if we aren't one yet. */
                 setsid();
 
@@ -1506,7 +1506,7 @@ int main(int argc, char *argv[]) {
 
         /* Reset the console, but only if this is really init and we
          * are freshly booted */
-        if (arg_running_as == MANAGER_SYSTEM && arg_action == ACTION_RUN)
+        if (arg_running_as == SYSTEMD_SYSTEM && arg_action == ACTION_RUN)
                 console_setup(getpid() == 1 && !skip_setup);
 
         /* Open the logging devices, if possible and necessary */
@@ -1523,7 +1523,7 @@ int main(int argc, char *argv[]) {
                         goto finish;
         }
 
-        if (arg_running_as == MANAGER_SYSTEM) {
+        if (arg_running_as == SYSTEMD_SYSTEM) {
                 const char *virtualization = NULL;
 
                 log_info(PACKAGE_STRING " running in system mode. (" SYSTEMD_FEATURES "; " DISTRIBUTION ")");
@@ -1538,7 +1538,7 @@ int main(int argc, char *argv[]) {
         } else
                 log_debug(PACKAGE_STRING " running in user mode. (" SYSTEMD_FEATURES "; " DISTRIBUTION ")");
 
-        if (arg_running_as == MANAGER_SYSTEM && !skip_setup) {
+        if (arg_running_as == SYSTEMD_SYSTEM && !skip_setup) {
                 locale_setup();
 
                 if (arg_show_status || plymouth_running())
@@ -1554,7 +1554,7 @@ int main(int argc, char *argv[]) {
                 test_cgroups();
         }
 
-        if (arg_running_as == MANAGER_SYSTEM && arg_runtime_watchdog > 0)
+        if (arg_running_as == SYSTEMD_SYSTEM && arg_runtime_watchdog > 0)
                 watchdog_set_timeout(&arg_runtime_watchdog);
 
         if (arg_timer_slack_nsec != (nsec_t) -1)
@@ -1574,7 +1574,7 @@ int main(int argc, char *argv[]) {
                 }
         }
 
-        if (arg_running_as == MANAGER_USER) {
+        if (arg_running_as == SYSTEMD_USER) {
                 /* Become reaper of our children */
                 if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) {
                         log_warning("Failed to make us a subreaper: %m");
@@ -1583,7 +1583,7 @@ int main(int argc, char *argv[]) {
                 }
         }
 
-        if (arg_running_as == MANAGER_SYSTEM)
+        if (arg_running_as == SYSTEMD_SYSTEM)
                 bump_rlimit_nofile(&saved_rlimit_nofile);
 
         r = manager_new(arg_running_as, &m);
@@ -1822,7 +1822,7 @@ finish:
                         args[i++] = SYSTEMD_BINARY_PATH;
                         if (switch_root_dir)
                                 args[i++] = "--switched-root";
-                        args[i++] = arg_running_as == MANAGER_SYSTEM ? "--system" : "--user";
+                        args[i++] = arg_running_as == SYSTEMD_SYSTEM ? "--system" : "--user";
                         args[i++] = "--deserialize";
                         args[i++] = sfd;
                         args[i++] = NULL;
diff --git a/src/core/manager.c b/src/core/manager.c
index f56d390..3cd9915 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -216,7 +216,7 @@ static int manager_setup_signals(Manager *m) {
         if (epoll_ctl(m->epoll_fd, EPOLL_CTL_ADD, m->signal_watch.fd, &ev) < 0)
                 return -errno;
 
-        if (m->running_as == MANAGER_SYSTEM)
+        if (m->running_as == SYSTEMD_SYSTEM)
                 return enable_special_signals(m);
 
         return 0;
@@ -237,13 +237,13 @@ static void manager_strip_environment(Manager *m) {
         strv_remove_prefix(m->environment, "RD_");
 }
 
-int manager_new(ManagerRunningAs running_as, Manager **_m) {
+int manager_new(SystemdRunningAs running_as, Manager **_m) {
         Manager *m;
         int r = -ENOMEM;
 
         assert(_m);
         assert(running_as >= 0);
-        assert(running_as < _MANAGER_RUNNING_AS_MAX);
+        assert(running_as < _SYSTEMD_RUNNING_AS_MAX);
 
         m = new0(Manager, 1);
         if (!m)
@@ -270,7 +270,7 @@ int manager_new(ManagerRunningAs running_as, Manager **_m) {
 
         manager_strip_environment(m);
 
-        if (running_as == MANAGER_SYSTEM) {
+        if (running_as == SYSTEMD_SYSTEM) {
                 m->default_controllers = strv_new("cpu", NULL);
                 if (!m->default_controllers)
                         goto fail;
@@ -304,7 +304,7 @@ int manager_new(ManagerRunningAs running_as, Manager **_m) {
                 goto fail;
 
         /* Try to connect to the busses, if possible. */
-        if ((r = bus_init(m, running_as != MANAGER_SYSTEM)) < 0)
+        if ((r = bus_init(m, running_as != SYSTEMD_SYSTEM)) < 0)
                 goto fail;
 
 #ifdef HAVE_AUDIT
@@ -1145,7 +1145,7 @@ static int manager_process_signal_fd(Manager *m) {
                         break;
 
                 case SIGTERM:
-                        if (m->running_as == MANAGER_SYSTEM) {
+                        if (m->running_as == SYSTEMD_SYSTEM) {
                                 /* This is for compatibility with the
                                  * original sysvinit */
                                 m->exit_code = MANAGER_REEXECUTE;
@@ -1155,7 +1155,7 @@ static int manager_process_signal_fd(Manager *m) {
                         /* Fall through */
 
                 case SIGINT:
-                        if (m->running_as == MANAGER_SYSTEM) {
+                        if (m->running_as == SYSTEMD_SYSTEM) {
                                 manager_start_target(m, SPECIAL_CTRL_ALT_DEL_TARGET, JOB_REPLACE);
                                 break;
                         }
@@ -1169,14 +1169,14 @@ static int manager_process_signal_fd(Manager *m) {
                         break;
 
                 case SIGWINCH:
-                        if (m->running_as == MANAGER_SYSTEM)
+                        if (m->running_as == SYSTEMD_SYSTEM)
                                 manager_start_target(m, SPECIAL_KBREQUEST_TARGET, JOB_REPLACE);
 
                         /* This is a nop on non-init */
                         break;
 
                 case SIGPWR:
-                        if (m->running_as == MANAGER_SYSTEM)
+                        if (m->running_as == SYSTEMD_SYSTEM)
                                 manager_start_target(m, SPECIAL_SIGPWR_TARGET, JOB_REPLACE);
 
                         /* This is a nop on non-init */
@@ -1440,7 +1440,7 @@ int manager_loop(Manager *m) {
                 int n;
                 int wait_msec = -1;
 
-                if (m->runtime_watchdog > 0 && m->running_as == MANAGER_SYSTEM)
+                if (m->runtime_watchdog > 0 && m->running_as == SYSTEMD_SYSTEM)
                         watchdog_ping();
 
                 if (!ratelimit_test(&rl)) {
@@ -1472,7 +1472,7 @@ int manager_loop(Manager *m) {
                         continue;
 
                 /* Sleep for half the watchdog time */
-                if (m->runtime_watchdog > 0 && m->running_as == MANAGER_SYSTEM) {
+                if (m->runtime_watchdog > 0 && m->running_as == SYSTEMD_SYSTEM) {
                         wait_msec = (int) (m->runtime_watchdog / 2 / USEC_PER_MSEC);
                         if (wait_msec <= 0)
                                 wait_msec = 1;
@@ -1562,7 +1562,7 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
         if (m->n_reloading > 0)
                 return;
 
-        if (m->running_as != MANAGER_SYSTEM)
+        if (m->running_as != SYSTEMD_SYSTEM)
                 return;
 
         if (u->type != UNIT_SERVICE)
@@ -1599,7 +1599,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
         if (m->n_reloading > 0)
                 return;
 
-        if (m->running_as != MANAGER_SYSTEM)
+        if (m->running_as != SYSTEMD_SYSTEM)
                 return;
 
         if (u->type != UNIT_SERVICE &&
@@ -1698,7 +1698,7 @@ int manager_open_serialization(Manager *m, FILE **_f) {
 
         assert(_f);
 
-        if (m->running_as == MANAGER_SYSTEM)
+        if (m->running_as == SYSTEMD_SYSTEM)
                 asprintf(&path, "/run/systemd/dump-%lu-XXXXXX", (unsigned long) getpid());
         else
                 asprintf(&path, "/tmp/systemd-dump-%lu-XXXXXX", (unsigned long) getpid());
@@ -2035,7 +2035,7 @@ void manager_check_finished(Manager *m) {
 
         dual_timestamp_get(&m->finish_timestamp);
 
-        if (m->running_as == MANAGER_SYSTEM && detect_container(NULL) <= 0) {
+        if (m->running_as == SYSTEMD_SYSTEM && detect_container(NULL) <= 0) {
 
                 /* Note that m->kernel_usec.monotonic is always at 0,
                  * and m->firmware_usec.monotonic and
@@ -2110,7 +2110,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
         if (*generator)
                 return 0;
 
-        if (m->running_as == MANAGER_SYSTEM && getpid() == 1) {
+        if (m->running_as == SYSTEMD_SYSTEM && getpid() == 1) {
 
                 p = strappend("/run/systemd/", name);
                 if (!p)
@@ -2162,7 +2162,7 @@ void manager_run_generators(Manager *m) {
 
         assert(m);
 
-        generator_path = m->running_as == MANAGER_SYSTEM ? SYSTEM_GENERATOR_PATH : USER_GENERATOR_PATH;
+        generator_path = m->running_as == SYSTEMD_SYSTEM ? SYSTEM_GENERATOR_PATH : USER_GENERATOR_PATH;
         d = opendir(generator_path);
         if (!d) {
                 if (errno == ENOENT)
@@ -2264,7 +2264,7 @@ void manager_recheck_journal(Manager *m) {
 
         assert(m);
 
-        if (m->running_as != MANAGER_SYSTEM)
+        if (m->running_as != SYSTEMD_SYSTEM)
                 return;
 
         u = manager_get_unit(m, SPECIAL_JOURNALD_SOCKET);
@@ -2287,7 +2287,7 @@ void manager_recheck_journal(Manager *m) {
 void manager_set_show_status(Manager *m, bool b) {
         assert(m);
 
-        if (m->running_as != MANAGER_SYSTEM)
+        if (m->running_as != SYSTEMD_SYSTEM)
                 return;
 
         m->show_status = b;
@@ -2301,7 +2301,7 @@ void manager_set_show_status(Manager *m, bool b) {
 bool manager_get_show_status(Manager *m) {
         assert(m);
 
-        if (m->running_as != MANAGER_SYSTEM)
+        if (m->running_as != SYSTEMD_SYSTEM)
                 return false;
 
         if (m->show_status)
@@ -2312,10 +2312,3 @@ bool manager_get_show_status(Manager *m) {
 
         return plymouth_running();
 }
-
-static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
-        [MANAGER_SYSTEM] = "system",
-        [MANAGER_USER] = "user"
-};
-
-DEFINE_STRING_TABLE_LOOKUP(manager_running_as, ManagerRunningAs);
diff --git a/src/core/manager.h b/src/core/manager.h
index 653496d..913752f 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -49,13 +49,6 @@ typedef enum ManagerExitCode {
         _MANAGER_EXIT_CODE_INVALID = -1
 } ManagerExitCode;
 
-typedef enum ManagerRunningAs {
-        MANAGER_SYSTEM,
-        MANAGER_USER,
-        _MANAGER_RUNNING_AS_MAX,
-        _MANAGER_RUNNING_AS_INVALID = -1
-} ManagerRunningAs;
-
 enum WatchType {
         WATCH_INVALID,
         WATCH_SIGNAL,
@@ -213,7 +206,7 @@ struct Manager {
 #endif
 
         /* Flags */
-        ManagerRunningAs running_as;
+        SystemdRunningAs running_as;
         ManagerExitCode exit_code:5;
 
         bool dispatching_load_queue:1;
@@ -242,7 +235,7 @@ struct Manager {
         char *switch_root_init;
 };
 
-int manager_new(ManagerRunningAs running_as, Manager **m);
+int manager_new(SystemdRunningAs running_as, Manager **m);
 void manager_free(Manager *m);
 
 int manager_enumerate(Manager *m);
@@ -303,6 +296,3 @@ void manager_recheck_journal(Manager *m);
 
 void manager_set_show_status(Manager *m, bool b);
 bool manager_get_show_status(Manager *m);
-
-const char *manager_running_as_to_string(ManagerRunningAs i);
-ManagerRunningAs manager_running_as_from_string(const char *s);
diff --git a/src/core/mount.c b/src/core/mount.c
index 78740a8..66ef0cd 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -362,7 +362,7 @@ static int mount_add_device_links(Mount *m) {
         if (p->passno > 0 &&
             !mount_is_bind(p) &&
             !path_equal(m->where, "/") &&
-            UNIT(m)->manager->running_as == MANAGER_SYSTEM) {
+            UNIT(m)->manager->running_as == SYSTEMD_SYSTEM) {
                 char *name;
                 Unit *fsck;
                 /* Let's add in the fsck service */
@@ -396,7 +396,7 @@ static int mount_add_quota_links(Mount *m) {
 
         assert(m);
 
-        if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
+        if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
                 return 0;
 
         p = get_mount_parameters_fragment(m);
@@ -424,7 +424,7 @@ static int mount_add_default_dependencies(Mount *m) {
 
         assert(m);
 
-        if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
+        if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
                 return 0;
 
         p = get_mount_parameters_fragment(m);
diff --git a/src/core/path.c b/src/core/path.c
index e3defeb..3936971 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -316,7 +316,7 @@ static int path_add_default_dependencies(Path *p) {
 
         assert(p);
 
-        if (UNIT(p)->manager->running_as == MANAGER_SYSTEM) {
+        if (UNIT(p)->manager->running_as == SYSTEMD_SYSTEM) {
                 if ((r = unit_add_dependency_by_name(UNIT(p), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
                         return r;
 
diff --git a/src/core/service.c b/src/core/service.c
index 39e1ab5..7c79dcd 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1192,12 +1192,12 @@ static int service_add_default_dependencies(Service *s) {
          * majority of services. */
 
         /* First, pull in base system */
-        if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
+        if (UNIT(s)->manager->running_as == SYSTEMD_SYSTEM) {
 
                 if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
                         return r;
 
-        } else if (UNIT(s)->manager->running_as == MANAGER_USER) {
+        } else if (UNIT(s)->manager->running_as == SYSTEMD_USER) {
 
                 if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SOCKETS_TARGET, NULL, true)) < 0)
                         return r;
@@ -3429,7 +3429,7 @@ static int service_enumerate(Manager *m) {
 
         assert(m);
 
-        if (m->running_as != MANAGER_SYSTEM)
+        if (m->running_as != SYSTEMD_SYSTEM)
                 return 0;
 
         zero(runlevel_services);
diff --git a/src/core/socket.c b/src/core/socket.c
index 3614045..26e7fd2 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -306,7 +306,7 @@ static int socket_add_default_dependencies(Socket *s) {
         int r;
         assert(s);
 
-        if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
+        if (UNIT(s)->manager->running_as == SYSTEMD_SYSTEM) {
                 if ((r = unit_add_dependency_by_name(UNIT(s), UNIT_BEFORE, SPECIAL_SOCKETS_TARGET, NULL, true)) < 0)
                         return r;
 
diff --git a/src/core/swap.c b/src/core/swap.c
index d5bf153..b4f53b7 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -197,7 +197,7 @@ static int swap_add_device_links(Swap *s) {
         if (is_device_path(s->what))
                 return unit_add_node_link(UNIT(s), s->what,
                                           !p->noauto && p->nofail &&
-                                          UNIT(s)->manager->running_as == MANAGER_SYSTEM);
+                                          UNIT(s)->manager->running_as == SYSTEMD_SYSTEM);
         else
                 /* File based swap devices need to be ordered after
                  * systemd-remount-fs.service, since they might need a
@@ -210,7 +210,7 @@ static int swap_add_default_dependencies(Swap *s) {
 
         assert(s);
 
-        if (UNIT(s)->manager->running_as != MANAGER_SYSTEM)
+        if (UNIT(s)->manager->running_as != SYSTEMD_SYSTEM)
                 return 0;
 
         if (detect_container(NULL) > 0)
diff --git a/src/core/timer.c b/src/core/timer.c
index 03c9610..7080b32 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -80,7 +80,7 @@ static int timer_add_default_dependencies(Timer *t) {
 
         assert(t);
 
-        if (UNIT(t)->manager->running_as == MANAGER_SYSTEM) {
+        if (UNIT(t)->manager->running_as == SYSTEMD_SYSTEM) {
                 if ((r = unit_add_dependency_by_name(UNIT(t), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
                         return r;
 
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
index 308bbd6..cbae45d 100644
--- a/src/core/unit-printf.c
+++ b/src/core/unit-printf.c
@@ -107,7 +107,7 @@ static char *specifier_runtime(char specifier, void *data, void *userdata) {
         Unit *u = userdata;
         assert(u);
 
-        if (u->manager->running_as == MANAGER_USER) {
+        if (u->manager->running_as == SYSTEMD_USER) {
                 const char *e;
 
                 e = getenv("XDG_RUNTIME_DIR");
diff --git a/src/core/unit.c b/src/core/unit.c
index 1e33936..ae43545 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -613,7 +613,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
         /* If syslog or kernel logging is requested, make sure our own
          * logging daemon is run first. */
 
-        if (u->manager->running_as == MANAGER_SYSTEM)
+        if (u->manager->running_as == SYSTEMD_SYSTEM)
                 if ((r = unit_add_two_dependencies_by_name(u, UNIT_REQUIRES, UNIT_AFTER, SPECIAL_JOURNALD_SOCKET, NULL, true)) < 0)
                         return r;
 
@@ -2590,7 +2590,7 @@ UnitFileState unit_get_unit_file_state(Unit *u) {
 
         if (u->unit_file_state < 0 && u->fragment_path)
                 u->unit_file_state = unit_file_get_state(
-                                u->manager->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
+                                u->manager->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
                                 NULL, path_get_file_name(u->fragment_path));
 
         return u->unit_file_state;
@@ -2673,7 +2673,7 @@ int unit_exec_context_defaults(Unit *u, ExecContext *c) {
                                 return -ENOMEM;
                 }
 
-        if (u->manager->running_as == MANAGER_USER &&
+        if (u->manager->running_as == SYSTEMD_USER &&
             !c->working_directory) {
 
                 r = get_home_dir(&c->working_directory);
diff --git a/src/shared/install.c b/src/shared/install.c
index c6215fb..f30bf83 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -59,7 +59,7 @@ static int lookup_paths_init_from_scope(LookupPaths *paths, UnitFileScope scope)
         zero(*paths);
 
         return lookup_paths_init(paths,
-                                 scope == UNIT_FILE_SYSTEM ? MANAGER_SYSTEM : MANAGER_USER,
+                                 scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER,
                                  scope == UNIT_FILE_USER,
                                  NULL, NULL, NULL);
 }
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c
index a9c3e21..6e5529e 100644
--- a/src/shared/path-lookup.c
+++ b/src/shared/path-lookup.c
@@ -22,6 +22,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <unistd.h>
 #include <errno.h>
 
@@ -31,6 +32,13 @@
 #include "path-util.h"
 #include "path-lookup.h"
 
+static const char* const systemd_running_as_table[_SYSTEMD_RUNNING_AS_MAX] = {
+        [SYSTEMD_SYSTEM] = "system",
+        [SYSTEMD_USER] = "user"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(systemd_running_as, SystemdRunningAs);
+
 int user_config_home(char **config_home) {
         const char *e;
 
@@ -224,7 +232,7 @@ fail:
 
 int lookup_paths_init(
                 LookupPaths *p,
-                ManagerRunningAs running_as,
+                SystemdRunningAs running_as,
                 bool personal,
                 const char *generator,
                 const char *generator_early,
@@ -256,7 +264,7 @@ int lookup_paths_init(
                  * for the system stuff but avoid it for user
                  * stuff. */
 
-                if (running_as == MANAGER_USER) {
+                if (running_as == SYSTEMD_USER) {
 
                         if (personal)
                                 p->unit_path = user_dirs(generator, generator_early, generator_late);
@@ -323,7 +331,7 @@ int lookup_paths_init(
                 p->unit_path = NULL;
         }
 
-        if (running_as == MANAGER_SYSTEM) {
+        if (running_as == SYSTEMD_SYSTEM) {
 #ifdef HAVE_SYSV_COMPAT
                 /* /etc/init.d/ compatibility does not matter to users */
 
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index 0aab956..baef622 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -29,9 +29,17 @@ typedef struct LookupPaths {
 #endif
 } LookupPaths;
 
-#include "manager.h"
+typedef enum SystemdRunningAs {
+        SYSTEMD_SYSTEM,
+        SYSTEMD_USER,
+        _SYSTEMD_RUNNING_AS_MAX,
+        _SYSTEMD_RUNNING_AS_INVALID = -1
+} SystemdRunningAs;
+
+const char* systemd_running_as_to_string(SystemdRunningAs i);
+SystemdRunningAs systemd_running_as_from_string(const char *s);
 
 int user_config_home(char **config_home);
 
-int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as, bool personal, const char *generator, const char *generator_early, const char *generator_late);
+int lookup_paths_init(LookupPaths *p, SystemdRunningAs running_as, bool personal, const char *generator, const char *generator_early, const char *generator_late);
 void lookup_paths_free(LookupPaths *p);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 17a8497..0e564a5 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -63,6 +63,7 @@
 #include "install.h"
 #include "logs-show.h"
 #include "path-util.h"
+#include "socket-util.h"
 
 static const char *arg_type = NULL;
 static const char *arg_load_state = NULL;
@@ -3410,7 +3411,7 @@ static int enable_sysv_units(char **args) {
          * afterwards only the native units remain */
 
         zero(paths);
-        r = lookup_paths_init(&paths, MANAGER_SYSTEM, false, NULL, NULL, NULL);
+        r = lookup_paths_init(&paths, SYSTEMD_SYSTEM, false, NULL, NULL, NULL);
         if (r < 0)
                 return r;
 
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index 11389a5..0f38622 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
 
         assert_se(set_unit_path("test") >= 0);
 
-        assert_se(manager_new(MANAGER_SYSTEM, &m) >= 0);
+        assert_se(manager_new(SYSTEMD_SYSTEM, &m) >= 0);
 
         printf("Load1:\n");
         assert_se(manager_load_unit(m, "a.service", NULL, NULL, &a) >= 0);



More information about the systemd-commits mailing list