summaryrefslogtreecommitdiff
path: root/manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-02-12 21:57:39 +0100
committerLennart Poettering <lennart@poettering.net>2010-02-12 21:57:39 +0100
commitdfcd764ea64a61280eeb3902505b58aca06111f9 (patch)
treeeda5b9d066b7b64922d70a6c6baea5d99817ad06 /manager.c
parent7898b0cf7ec1a30454538b415e25d544ecee5d5b (diff)
manager: identify the init/system/user mode we are running it and pick D-Bus bus accordingly
Diffstat (limited to 'manager.c')
-rw-r--r--manager.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/manager.c b/manager.c
index ace480c4dd..25bc752882 100644
--- a/manager.c
+++ b/manager.c
@@ -76,6 +76,15 @@ Manager* manager_new(void) {
if (!(m = new0(Manager, 1)))
return NULL;
+ if (getpid() == 1)
+ m->running_as = MANAGER_INIT;
+ else if (getuid() == 0)
+ m->running_as = MANAGER_SYSTEM;
+ else
+ m->running_as = MANAGER_USER;
+
+ log_debug("systemd running in %s mode.", manager_running_as_to_string(m->running_as));
+
m->signal_watch.fd = m->mount_watch.fd = m->udev_watch.fd = m->epoll_fd = -1;
m->current_job_id = 1; /* start as id #1, so that we can leave #0 around as "null-like" value */
@@ -1347,3 +1356,11 @@ int manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j) {
return 0;
}
+
+static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
+ [MANAGER_INIT] = "init",
+ [MANAGER_SYSTEM] = "system",
+ [MANAGER_USER] = "user"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(manager_running_as, ManagerRunningAs);