} 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)))
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))) {
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))) {
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))) {
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;
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;
}
* 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;
}
"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"
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;
/* 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;
/* 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();
/* 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();
}
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();
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;
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;
/* 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;
}
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 */
if (m->utmp_reboot_written)
return;
- if (m->running_as != MANAGER_INIT)
+ if (m->running_as != MANAGER_SYSTEM)
return;
if (!manager_utmp_good(m))
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))
}
static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
- [MANAGER_INIT] = "init",
[MANAGER_SYSTEM] = "system",
[MANAGER_SESSION] = "session"
};
} 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;
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)
} 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;
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)
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")))
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;
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)
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);
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;