summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-19 03:15:59 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-19 03:15:59 +0200
commita3d4e06dfa234bf2a9398c8e534b705b68aa50a1 (patch)
tree41d9a99c9827fa9fac302c15c382ae6dc941a40c
parent5e8d1c9a9f15b7453474dc4879bdb4021c3f50a1 (diff)
manager: get rid of destinction between running_as=system and running_as=init, as there is little value in it and we cannot really test this
-rw-r--r--src/dbus-manager.c2
-rw-r--r--src/dbus.c10
-rw-r--r--src/install.c2
-rw-r--r--src/main.c16
-rw-r--r--src/manager.c15
-rw-r--r--src/manager.h5
-rw-r--r--src/mount.c8
-rw-r--r--src/path-lookup.c2
-rw-r--r--src/swap.c6
-rw-r--r--src/test-engine.c2
-rw-r--r--src/unit.c2
11 files changed, 32 insertions, 38 deletions
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index 781825782b..b3e42fc333 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -608,7 +608,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_INIT)
+ if (m->running_as == MANAGER_SYSTEM)
return bus_send_error_reply(m, connection, message, NULL, -ENOTSUP);
if (!(reply = dbus_message_new_method_return(message)))
diff --git a/src/dbus.c b/src/dbus.c
index a34c7dc17b..74b1c37dda 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -761,7 +761,7 @@ static int bus_init_system(Manager *m) {
if (m->system_bus)
return 0;
- if (m->running_as != MANAGER_SESSION && m->api_bus)
+ if (m->running_as == MANAGER_SYSTEM && m->api_bus)
m->system_bus = m->api_bus;
else {
if (!(m->system_bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error))) {
@@ -819,7 +819,7 @@ static int bus_init_api(Manager *m) {
if (m->api_bus)
return 0;
- if (m->running_as != MANAGER_SESSION && m->system_bus)
+ if (m->running_as == MANAGER_SYSTEM && m->system_bus)
m->api_bus = m->system_bus;
else {
if (!(m->api_bus = dbus_bus_get_private(m->running_as == MANAGER_SESSION ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error))) {
@@ -914,7 +914,7 @@ static int bus_init_private(Manager *m) {
return 0;
/* We want the private bus only when running as init */
- if (m->running_as != MANAGER_INIT)
+ if (m->running_as != MANAGER_SYSTEM)
return 0;
if (!(m->private_bus = dbus_server_listen("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
@@ -1348,11 +1348,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_SESSION)
+ if (c != m->system_bus || m->running_as == MANAGER_SYSTEM)
oom = !dbus_connection_send(c, message, NULL);
SET_FOREACH(c, m->bus_connections, i)
- if (c != m->system_bus || m->running_as != MANAGER_SESSION)
+ if (c != m->system_bus || m->running_as == MANAGER_SYSTEM)
oom = !dbus_connection_send(c, message, NULL);
return oom ? -ENOMEM : 0;
diff --git a/src/install.c b/src/install.c
index e30f623627..e59e108c02 100644
--- a/src/install.c
+++ b/src/install.c
@@ -535,7 +535,7 @@ int main(int argc, char *argv[]) {
goto finish;
}
- if ((r = lookup_paths_init(&paths, arg_where == WHERE_SYSTEM ? MANAGER_INIT : MANAGER_SESSION)) < 0) {
+ if ((r = lookup_paths_init(&paths, arg_where == WHERE_SYSTEM ? MANAGER_SYSTEM : MANAGER_SESSION)) < 0) {
log_error("Failed to determine lookup paths: %s", strerror(-r));
goto finish;
}
diff --git a/src/main.c b/src/main.c
index 21b4174a87..f00d43a7c5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -526,7 +526,7 @@ static int parse_argv(int argc, char *argv[]) {
* ignore and unconditionally read from
* /proc/cmdline. However, we need to ignore those arguments
* here. */
- if (running_as != MANAGER_INIT && optind < argc) {
+ if (running_as != MANAGER_SYSTEM && optind < argc) {
log_error("Excess arguments.");
return -EINVAL;
}
@@ -540,7 +540,7 @@ static int help(void) {
"Starts up and maintains the system or a session.\n\n"
" -h --help Show this help\n"
" --unit=UNIT Set default unit\n"
- " --running-as=AS Set running as (init, system, session)\n"
+ " --running-as=AS Set running as (system, session)\n"
" --test Determine startup sequence, dump it and exit\n"
" --dump-configuration-items Dump understood unit configuration items\n"
" --confirm-spawn Ask for confirmation when spawning processes\n"
@@ -631,7 +631,7 @@ int main(int argc, char *argv[]) {
log_set_max_level(LOG_DEBUG);
if (getpid() == 1) {
- running_as = MANAGER_INIT;
+ running_as = MANAGER_SYSTEM;
log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
} else {
running_as = MANAGER_SESSION;
@@ -653,7 +653,7 @@ int main(int argc, char *argv[]) {
/* If we are init, we can block sigkill. Yay. */
ignore_signals(SIGNALS_IGNORE, -1);
- if (running_as != MANAGER_SESSION)
+ if (running_as == MANAGER_SYSTEM)
if (parse_proc_cmdline() < 0)
goto finish;
@@ -690,12 +690,12 @@ int main(int argc, char *argv[]) {
/* Set up PATH unless it is already set */
setenv("PATH",
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
- running_as == MANAGER_INIT);
+ running_as == MANAGER_SYSTEM);
/* Move out of the way, so that we won't block unmounts */
assert_se(chdir("/") == 0);
- if (running_as != MANAGER_SESSION) {
+ if (running_as == MANAGER_SYSTEM) {
/* Become a session leader if we aren't one yet. */
setsid();
@@ -708,7 +708,7 @@ int main(int argc, char *argv[]) {
/* Reset the console, but only if this is really init and we
* are freshly booted */
- if (running_as != MANAGER_SESSION && action == ACTION_RUN) {
+ if (running_as == MANAGER_SYSTEM && action == ACTION_RUN) {
console_setup(getpid() == 1 && !serialization);
make_null_stdio();
}
@@ -723,7 +723,7 @@ int main(int argc, char *argv[]) {
log_debug("systemd running in %s mode.", manager_running_as_to_string(running_as));
- if (running_as == MANAGER_INIT) {
+ if (running_as == MANAGER_SYSTEM) {
kmod_setup();
hostname_setup();
loopback_setup();
diff --git a/src/manager.c b/src/manager.c
index 456241f6d2..e211ecaf56 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -177,7 +177,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_INIT)
+ if (m->running_as == MANAGER_SYSTEM)
return enable_special_signals(m);
return 0;
@@ -1780,7 +1780,7 @@ static int manager_process_signal_fd(Manager *m) {
break;
case SIGTERM:
- if (m->running_as == MANAGER_INIT) {
+ if (m->running_as == MANAGER_SYSTEM) {
/* This is for compatibility with the
* original sysvinit */
m->exit_code = MANAGER_REEXECUTE;
@@ -1790,7 +1790,7 @@ static int manager_process_signal_fd(Manager *m) {
/* Fall through */
case SIGINT:
- if (m->running_as == MANAGER_INIT) {
+ if (m->running_as == MANAGER_SYSTEM) {
manager_start_target(m, SPECIAL_CTRL_ALT_DEL_TARGET, JOB_REPLACE);
break;
}
@@ -1804,14 +1804,14 @@ static int manager_process_signal_fd(Manager *m) {
break;
case SIGWINCH:
- if (m->running_as == MANAGER_INIT)
+ if (m->running_as == MANAGER_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_INIT)
+ if (m->running_as == MANAGER_SYSTEM)
manager_start_target(m, SPECIAL_SIGPWR_TARGET, JOB_REPLACE);
/* This is a nop on non-init */
@@ -2105,7 +2105,7 @@ void manager_write_utmp_reboot(Manager *m) {
if (m->utmp_reboot_written)
return;
- if (m->running_as != MANAGER_INIT)
+ if (m->running_as != MANAGER_SYSTEM)
return;
if (!manager_utmp_good(m))
@@ -2131,7 +2131,7 @@ void manager_write_utmp_runlevel(Manager *m, Unit *u) {
if (u->meta.type != UNIT_TARGET)
return;
- if (m->running_as != MANAGER_INIT)
+ if (m->running_as != MANAGER_SYSTEM)
return;
if (!manager_utmp_good(m))
@@ -2337,7 +2337,6 @@ finish:
}
static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
- [MANAGER_INIT] = "init",
[MANAGER_SYSTEM] = "system",
[MANAGER_SESSION] = "session"
};
diff --git a/src/manager.h b/src/manager.h
index 2a04bc7ddd..6e74773f4d 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -46,9 +46,8 @@ typedef enum ManagerExitCode {
} ManagerExitCode;
typedef enum ManagerRunningAs {
- MANAGER_INIT, /* root and pid=1 */
- MANAGER_SYSTEM, /* root and pid!=1 */
- MANAGER_SESSION, /* non-root, for a session */
+ MANAGER_SYSTEM,
+ MANAGER_SESSION,
_MANAGER_RUNNING_AS_MAX,
_MANAGER_RUNNING_AS_INVALID = -1
} ManagerRunningAs;
diff --git a/src/mount.c b/src/mount.c
index 94f19294fd..c95581fd1e 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -254,7 +254,7 @@ static int mount_add_target_links(Mount *m) {
if ((r = manager_load_unit(UNIT(m)->meta.manager, target, NULL, &tu)) < 0)
return r;
- if (automount && m->meta.manager->running_as != MANAGER_SESSION) {
+ if (automount && m->meta.manager->running_as == MANAGER_SYSTEM) {
Unit *am;
if ((r = unit_load_related_unit(UNIT(m), ".automount", &am)) < 0)
@@ -268,7 +268,7 @@ static int mount_add_target_links(Mount *m) {
} else {
if (!noauto && handle)
- if (user || m->meta.manager->running_as != MANAGER_SESSION)
+ if (user || m->meta.manager->running_as == MANAGER_SYSTEM)
if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(m), true)) < 0)
return r;
@@ -341,9 +341,7 @@ static int mount_load(Unit *u) {
what = m->parameters_proc_self_mountinfo.what;
if (what)
- if ((r = unit_add_node_link(u, what,
- (u->meta.manager->running_as == MANAGER_INIT ||
- u->meta.manager->running_as == MANAGER_SYSTEM))) < 0)
+ if ((r = unit_add_node_link(u, what, u->meta.manager->running_as == MANAGER_SYSTEM)) < 0)
return r;
if ((r = mount_add_mount_links(m)) < 0)
diff --git a/src/path-lookup.c b/src/path-lookup.c
index 093e04de37..4160d55862 100644
--- a/src/path-lookup.c
+++ b/src/path-lookup.c
@@ -187,7 +187,7 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
return -ENOMEM;
}
- if (running_as == MANAGER_INIT) {
+ if (running_as == MANAGER_SYSTEM) {
/* /etc/init.d/ compatibility does not matter to users */
if ((e = getenv("SYSTEMD_SYSVINIT_PATH")))
diff --git a/src/swap.c b/src/swap.c
index 5b3073bd4a..501a1d96c8 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -116,7 +116,7 @@ static int swap_add_target_links(Swap *s) {
if ((r = manager_load_unit(s->meta.manager, SPECIAL_SWAP_TARGET, NULL, &tu)) < 0)
return r;
- if (!p->noauto && p->handle && s->meta.manager->running_as != MANAGER_SESSION)
+ if (!p->noauto && p->handle && s->meta.manager->running_as == MANAGER_SYSTEM)
if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(s), true)) < 0)
return r;
@@ -180,9 +180,7 @@ static int swap_load(Unit *u) {
if ((r = unit_set_description(u, s->what)) < 0)
return r;
- if ((r = unit_add_node_link(u, s->what,
- (u->meta.manager->running_as == MANAGER_INIT ||
- u->meta.manager->running_as == MANAGER_SYSTEM))) < 0)
+ if ((r = unit_add_node_link(u, s->what, u->meta.manager->running_as == MANAGER_SYSTEM)) < 0)
return r;
if ((r = swap_add_mount_links(s)) < 0)
diff --git a/src/test-engine.c b/src/test-engine.c
index eb17f580e2..60c6aa2f54 100644
--- a/src/test-engine.c
+++ b/src/test-engine.c
@@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
assert_se(set_unit_path("test2") >= 0);
- assert_se(manager_new(MANAGER_INIT, false, &m) >= 0);
+ assert_se(manager_new(MANAGER_SYSTEM, false, &m) >= 0);
printf("Load1:\n");
assert_se(manager_load_unit(m, "a.service", NULL, &a) >= 0);
diff --git a/src/unit.c b/src/unit.c
index c12c2a7deb..c546035ca1 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -542,7 +542,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
if ((r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_LOGGER_SOCKET, NULL, true)) < 0)
return r;
- if (u->meta.manager->running_as != MANAGER_SESSION)
+ if (u->meta.manager->running_as == MANAGER_SYSTEM)
if ((r = unit_add_dependency_by_name(u, UNIT_REQUIRES, SPECIAL_LOGGER_SOCKET, NULL, true)) < 0)
return r;