1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-07-27 11:42:33 +03:00

core: rename SystemdRunningAs to ManagerRunningAs

It's primarily just a property of the Manager object after all, and we
try to refer to PID 1 as "manager" instead of "systemd", hence let's to
stick to this here too.
This commit is contained in:
Lennart Poettering
2015-05-11 22:51:49 +02:00
parent 8b4305c735
commit b2c23da8ce
34 changed files with 153 additions and 153 deletions

View File

@ -192,7 +192,7 @@ static int verify_unit(Unit *u, bool check_man) {
return r; return r;
} }
int verify_units(char **filenames, SystemdRunningAs running_as, bool check_man) { int verify_units(char **filenames, ManagerRunningAs running_as, bool check_man) {
_cleanup_bus_error_free_ sd_bus_error err = SD_BUS_ERROR_NULL; _cleanup_bus_error_free_ sd_bus_error err = SD_BUS_ERROR_NULL;
Manager *m = NULL; Manager *m = NULL;
FILE *serial = NULL; FILE *serial = NULL;

View File

@ -25,4 +25,4 @@
#include "path-lookup.h" #include "path-lookup.h"
int verify_units(char **filenames, SystemdRunningAs running_as, bool check_man); int verify_units(char **filenames, ManagerRunningAs running_as, bool check_man);

View File

@ -1328,7 +1328,7 @@ int main(int argc, char *argv[]) {
if (streq_ptr(argv[optind], "verify")) if (streq_ptr(argv[optind], "verify"))
r = verify_units(argv+optind+1, r = verify_units(argv+optind+1,
arg_user ? SYSTEMD_USER : SYSTEMD_SYSTEM, arg_user ? MANAGER_USER : MANAGER_SYSTEM,
arg_man); arg_man);
else { else {
_cleanup_bus_close_unref_ sd_bus *bus = NULL; _cleanup_bus_close_unref_ sd_bus *bus = NULL;

View File

@ -156,7 +156,7 @@ static int automount_add_default_dependencies(Automount *a) {
assert(a); assert(a);
if (UNIT(a)->manager->running_as != SYSTEMD_SYSTEM) if (UNIT(a)->manager->running_as != MANAGER_SYSTEM)
return 0; return 0;
r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true); r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true);

View File

@ -147,7 +147,7 @@ static int busname_add_default_default_dependencies(BusName *n) {
if (r < 0) if (r < 0)
return r; return r;
if (UNIT(n)->manager->running_as == SYSTEMD_SYSTEM) { if (UNIT(n)->manager->running_as == MANAGER_SYSTEM) {
r = unit_add_two_dependencies_by_name(UNIT(n), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true); r = unit_add_two_dependencies_by_name(UNIT(n), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true);
if (r < 0) if (r < 0)
return r; return r;
@ -312,7 +312,7 @@ static int busname_open_fd(BusName *n) {
if (n->starter_fd >= 0) if (n->starter_fd >= 0)
return 0; return 0;
mode = UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user"; mode = UNIT(n)->manager->running_as == MANAGER_SYSTEM ? "system" : "user";
n->starter_fd = bus_kernel_open_bus_fd(mode, &path); n->starter_fd = bus_kernel_open_bus_fd(mode, &path);
if (n->starter_fd < 0) if (n->starter_fd < 0)
return log_unit_warning_errno(UNIT(n), n->starter_fd, "Failed to open %s: %m", path ?: "kdbus"); return log_unit_warning_errno(UNIT(n), n->starter_fd, "Failed to open %s: %m", path ?: "kdbus");

View File

@ -908,7 +908,7 @@ int manager_setup_cgroup(Manager *m) {
/* LEGACY: Already in /system.slice? If so, let's cut this /* LEGACY: Already in /system.slice? If so, let's cut this
* off. This is to support live upgrades from older systemd * off. This is to support live upgrades from older systemd
* versions where PID 1 was moved there. */ * versions where PID 1 was moved there. */
if (m->running_as == SYSTEMD_SYSTEM) { if (m->running_as == MANAGER_SYSTEM) {
char *e; char *e;
e = endswith(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE); e = endswith(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE);
@ -933,7 +933,7 @@ int manager_setup_cgroup(Manager *m) {
if (!m->test_run) { if (!m->test_run) {
/* 3. Install agent */ /* 3. Install agent */
if (m->running_as == SYSTEMD_SYSTEM) { if (m->running_as == MANAGER_SYSTEM) {
r = cg_install_release_agent(SYSTEMD_CGROUP_CONTROLLER, SYSTEMD_CGROUP_AGENT_PATH); r = cg_install_release_agent(SYSTEMD_CGROUP_CONTROLLER, SYSTEMD_CGROUP_AGENT_PATH);
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to install release agent, ignoring: %m"); log_warning_errno(r, "Failed to install release agent, ignoring: %m");

View File

@ -1206,7 +1206,7 @@ static int method_exit(sd_bus_message *message, void *userdata, sd_bus_error *er
if (r < 0) if (r < 0)
return r; return r;
if (m->running_as == SYSTEMD_SYSTEM) if (m->running_as == MANAGER_SYSTEM)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Exit is only supported for user service managers."); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Exit is only supported for user service managers.");
m->exit_code = MANAGER_EXIT; m->exit_code = MANAGER_EXIT;
@ -1225,7 +1225,7 @@ static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error *
if (r < 0) if (r < 0)
return r; return r;
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers."); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers.");
m->exit_code = MANAGER_REBOOT; m->exit_code = MANAGER_REBOOT;
@ -1244,7 +1244,7 @@ static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error
if (r < 0) if (r < 0)
return r; return r;
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers."); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers.");
m->exit_code = MANAGER_POWEROFF; m->exit_code = MANAGER_POWEROFF;
@ -1263,7 +1263,7 @@ static int method_halt(sd_bus_message *message, void *userdata, sd_bus_error *er
if (r < 0) if (r < 0)
return r; return r;
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Halt is only supported for system managers."); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Halt is only supported for system managers.");
m->exit_code = MANAGER_HALT; m->exit_code = MANAGER_HALT;
@ -1282,7 +1282,7 @@ static int method_kexec(sd_bus_message *message, void *userdata, sd_bus_error *e
if (r < 0) if (r < 0)
return r; return r;
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers."); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers.");
m->exit_code = MANAGER_KEXEC; m->exit_code = MANAGER_KEXEC;
@ -1303,7 +1303,7 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
if (r < 0) if (r < 0)
return r; return r;
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Root switching is only supported by system manager."); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Root switching is only supported by system manager.");
r = sd_bus_message_read(message, "ss", &root, &init); r = sd_bus_message_read(message, "ss", &root, &init);
@ -1480,7 +1480,7 @@ static int method_list_unit_files(sd_bus_message *message, void *userdata, sd_bu
if (!h) if (!h)
return -ENOMEM; return -ENOMEM;
r = unit_file_get_list(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h); r = unit_file_get_list(m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h);
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -1528,7 +1528,7 @@ static int method_get_unit_file_state(sd_bus_message *message, void *userdata, s
if (r < 0) if (r < 0)
return r; return r;
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
state = unit_file_get_state(scope, NULL, name); state = unit_file_get_state(scope, NULL, name);
if (state < 0) if (state < 0)
@ -1552,7 +1552,7 @@ static int method_get_default_target(sd_bus_message *message, void *userdata, sd
if (r < 0) if (r < 0)
return r; return r;
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
r = unit_file_get_default(scope, NULL, &default_target); r = unit_file_get_default(scope, NULL, &default_target);
if (r < 0) if (r < 0)
@ -1661,7 +1661,7 @@ static int method_enable_unit_files_generic(
if (r == 0) if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
r = call(scope, runtime, NULL, l, force, &changes, &n_changes); r = call(scope, runtime, NULL, l, force, &changes, &n_changes);
if (r < 0) if (r < 0)
@ -1734,7 +1734,7 @@ static int method_preset_unit_files_with_mode(sd_bus_message *message, void *use
if (r == 0) if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
r = unit_file_preset(scope, runtime, NULL, l, mm, force, &changes, &n_changes); r = unit_file_preset(scope, runtime, NULL, l, mm, force, &changes, &n_changes);
if (r < 0) if (r < 0)
@ -1771,7 +1771,7 @@ static int method_disable_unit_files_generic(
if (r < 0) if (r < 0)
return r; return r;
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
r = bus_verify_manage_unit_files_async(m, message, error); r = bus_verify_manage_unit_files_async(m, message, error);
if (r < 0) if (r < 0)
@ -1819,7 +1819,7 @@ static int method_set_default_target(sd_bus_message *message, void *userdata, sd
if (r == 0) if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
r = unit_file_set_default(scope, NULL, name, force, &changes, &n_changes); r = unit_file_set_default(scope, NULL, name, force, &changes, &n_changes);
if (r < 0) if (r < 0)
@ -1862,7 +1862,7 @@ static int method_preset_all_unit_files(sd_bus_message *message, void *userdata,
if (r == 0) if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
r = unit_file_preset_all(scope, runtime, NULL, mm, force, &changes, &n_changes); r = unit_file_preset_all(scope, runtime, NULL, mm, force, &changes, &n_changes);
if (r < 0) if (r < 0)
@ -1907,7 +1907,7 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd
if (r < 0) if (r < 0)
return r; return r;
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER;
r = unit_file_add_dependency(scope, runtime, NULL, l, target, dep, force, &changes, &n_changes); r = unit_file_add_dependency(scope, runtime, NULL, l, target, dep, force, &changes, &n_changes);
if (r < 0) if (r < 0)

View File

@ -85,7 +85,7 @@ static int signal_agent_released(sd_bus_message *message, void *userdata, sd_bus
manager_notify_cgroup_empty(m, cgroup); manager_notify_cgroup_empty(m, cgroup);
/* only forward to system bus if running as system instance */ /* only forward to system bus if running as system instance */
if (m->running_as != SYSTEMD_SYSTEM || !m->system_bus) if (m->running_as != MANAGER_SYSTEM || !m->system_bus)
return 0; return 0;
r = sd_bus_message_rewind(message, 1); r = sd_bus_message_rewind(message, 1);
@ -685,7 +685,7 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
return 0; return 0;
} }
if (m->running_as == SYSTEMD_SYSTEM) { if (m->running_as == MANAGER_SYSTEM) {
/* When we run as system instance we get the Released /* When we run as system instance we get the Released
* signal via a direct connection */ * signal via a direct connection */
@ -813,10 +813,10 @@ static int bus_init_api(Manager *m) {
return 0; return 0;
/* The API and system bus is the same if we are running in system mode */ /* The API and system bus is the same if we are running in system mode */
if (m->running_as == SYSTEMD_SYSTEM && m->system_bus) if (m->running_as == MANAGER_SYSTEM && m->system_bus)
bus = sd_bus_ref(m->system_bus); bus = sd_bus_ref(m->system_bus);
else { else {
if (m->running_as == SYSTEMD_SYSTEM) if (m->running_as == MANAGER_SYSTEM)
r = sd_bus_open_system(&bus); r = sd_bus_open_system(&bus);
else else
r = sd_bus_open_user(&bus); r = sd_bus_open_user(&bus);
@ -856,7 +856,7 @@ static int bus_setup_system(Manager *m, sd_bus *bus) {
assert(bus); assert(bus);
/* On kdbus or if we are a user instance we get the Released message via the system bus */ /* On kdbus or if we are a user instance we get the Released message via the system bus */
if (m->running_as == SYSTEMD_USER || m->kdbus_fd >= 0) { if (m->running_as == MANAGER_USER || m->kdbus_fd >= 0) {
r = sd_bus_add_match( r = sd_bus_add_match(
bus, bus,
NULL, NULL,
@ -881,7 +881,7 @@ static int bus_init_system(Manager *m) {
return 0; return 0;
/* The API and system bus is the same if we are running in system mode */ /* The API and system bus is the same if we are running in system mode */
if (m->running_as == SYSTEMD_SYSTEM && m->api_bus) { if (m->running_as == MANAGER_SYSTEM && m->api_bus) {
m->system_bus = sd_bus_ref(m->api_bus); m->system_bus = sd_bus_ref(m->api_bus);
return 0; return 0;
} }
@ -932,7 +932,7 @@ static int bus_init_private(Manager *m) {
if (m->kdbus_fd >= 0) if (m->kdbus_fd >= 0)
return 0; return 0;
if (m->running_as == SYSTEMD_SYSTEM) { if (m->running_as == MANAGER_SYSTEM) {
/* We want the private bus only when running as init */ /* We want the private bus only when running as init */
if (getpid() != 1) if (getpid() != 1)
@ -1031,7 +1031,7 @@ static void destroy_bus(Manager *m, sd_bus **bus) {
/* Possibly flush unwritten data, but only if we are /* Possibly flush unwritten data, but only if we are
* unprivileged, since we don't want to sync here */ * unprivileged, since we don't want to sync here */
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
sd_bus_flush(*bus); sd_bus_flush(*bus);
/* And destroy the object */ /* And destroy the object */

View File

@ -264,7 +264,7 @@ static int device_add_udev_wants(Unit *u, struct udev_device *dev) {
assert(u); assert(u);
assert(dev); assert(dev);
property = u->manager->running_as == SYSTEMD_USER ? "SYSTEMD_USER_WANTS" : "SYSTEMD_WANTS"; property = u->manager->running_as == MANAGER_USER ? "MANAGER_USER_WANTS" : "SYSTEMD_WANTS";
wants = udev_device_get_property_value(dev, property); wants = udev_device_get_property_value(dev, property);
if (!wants) if (!wants)
return 0; return 0;

View File

@ -50,7 +50,7 @@ int failure_action(
if (action == FAILURE_ACTION_NONE) if (action == FAILURE_ACTION_NONE)
return -ECANCELED; return -ECANCELED;
if (m->running_as == SYSTEMD_USER) { if (m->running_as == MANAGER_USER) {
/* Downgrade all options to simply exiting if we run /* Downgrade all options to simply exiting if we run
* in user mode */ * in user mode */

View File

@ -1152,7 +1152,7 @@ void job_shutdown_magic(Job *j) {
if (j->type != JOB_START) if (j->type != JOB_START)
return; return;
if (j->unit->manager->running_as != SYSTEMD_SYSTEM) if (j->unit->manager->running_as != MANAGER_SYSTEM)
return; return;
if (!unit_has_name(j->unit, SPECIAL_SHUTDOWN_TARGET)) if (!unit_has_name(j->unit, SPECIAL_SHUTDOWN_TARGET))

View File

@ -2408,7 +2408,7 @@ int config_parse_syscall_filter(
/* Turn on NNP, but only if it wasn't configured explicitly /* Turn on NNP, but only if it wasn't configured explicitly
* before, and only if we are in user mode. */ * before, and only if we are in user mode. */
if (!c->no_new_privileges_set && u->manager->running_as == SYSTEMD_USER) if (!c->no_new_privileges_set && u->manager->running_as == MANAGER_USER)
c->no_new_privileges = true; c->no_new_privileges = true;
return 0; return 0;

View File

@ -85,7 +85,7 @@ static enum {
ACTION_DONE ACTION_DONE
} arg_action = ACTION_RUN; } arg_action = ACTION_RUN;
static char *arg_default_unit = NULL; static char *arg_default_unit = NULL;
static SystemdRunningAs arg_running_as = _SYSTEMD_RUNNING_AS_INVALID; static ManagerRunningAs arg_running_as = _MANAGER_RUNNING_AS_INVALID;
static bool arg_dump_core = true; static bool arg_dump_core = true;
static bool arg_crash_shell = false; static bool arg_crash_shell = false;
static int arg_crash_chvt = -1; static int arg_crash_chvt = -1;
@ -676,8 +676,8 @@ static int parse_config_file(void) {
const char *fn, *conf_dirs_nulstr; const char *fn, *conf_dirs_nulstr;
fn = arg_running_as == SYSTEMD_SYSTEM ? PKGSYSCONFDIR "/system.conf" : PKGSYSCONFDIR "/user.conf"; fn = arg_running_as == MANAGER_SYSTEM ? PKGSYSCONFDIR "/system.conf" : PKGSYSCONFDIR "/user.conf";
conf_dirs_nulstr = arg_running_as == SYSTEMD_SYSTEM ? CONF_DIRS_NULSTR("systemd/system.conf") : CONF_DIRS_NULSTR("systemd/user.conf"); conf_dirs_nulstr = arg_running_as == MANAGER_SYSTEM ? CONF_DIRS_NULSTR("systemd/system.conf") : CONF_DIRS_NULSTR("systemd/user.conf");
config_parse_many(fn, conf_dirs_nulstr, "Manager\0", config_parse_many(fn, conf_dirs_nulstr, "Manager\0",
config_item_table_lookup, items, false, NULL); config_item_table_lookup, items, false, NULL);
@ -814,11 +814,11 @@ static int parse_argv(int argc, char *argv[]) {
break; break;
case ARG_SYSTEM: case ARG_SYSTEM:
arg_running_as = SYSTEMD_SYSTEM; arg_running_as = MANAGER_SYSTEM;
break; break;
case ARG_USER: case ARG_USER:
arg_running_as = SYSTEMD_USER; arg_running_as = MANAGER_USER;
break; break;
case ARG_TEST: case ARG_TEST:
@ -1275,7 +1275,7 @@ int main(int argc, char *argv[]) {
if (getpid() == 1 && detect_container(NULL) <= 0) { if (getpid() == 1 && detect_container(NULL) <= 0) {
/* Running outside of a container as PID 1 */ /* Running outside of a container as PID 1 */
arg_running_as = SYSTEMD_SYSTEM; arg_running_as = MANAGER_SYSTEM;
make_null_stdio(); make_null_stdio();
log_set_target(LOG_TARGET_KMSG); log_set_target(LOG_TARGET_KMSG);
log_open(); log_open();
@ -1349,7 +1349,7 @@ int main(int argc, char *argv[]) {
} else if (getpid() == 1) { } else if (getpid() == 1) {
/* Running inside a container, as PID 1 */ /* Running inside a container, as PID 1 */
arg_running_as = SYSTEMD_SYSTEM; arg_running_as = MANAGER_SYSTEM;
log_set_target(LOG_TARGET_CONSOLE); log_set_target(LOG_TARGET_CONSOLE);
log_close_console(); /* force reopen of /dev/console */ log_close_console(); /* force reopen of /dev/console */
log_open(); log_open();
@ -1364,7 +1364,7 @@ int main(int argc, char *argv[]) {
} else { } else {
/* Running as user instance */ /* Running as user instance */
arg_running_as = SYSTEMD_USER; arg_running_as = MANAGER_USER;
log_set_target(LOG_TARGET_AUTO); log_set_target(LOG_TARGET_AUTO);
log_open(); log_open();
@ -1413,7 +1413,7 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
} }
if (arg_running_as == SYSTEMD_SYSTEM) { if (arg_running_as == MANAGER_SYSTEM) {
r = parse_proc_cmdline(parse_proc_cmdline_item); r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m"); log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
@ -1434,14 +1434,14 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
} }
if (arg_running_as == SYSTEMD_USER && if (arg_running_as == MANAGER_USER &&
arg_action == ACTION_RUN && arg_action == ACTION_RUN &&
sd_booted() <= 0) { sd_booted() <= 0) {
log_error("Trying to run as user instance, but the system has not been booted with systemd."); log_error("Trying to run as user instance, but the system has not been booted with systemd.");
goto finish; goto finish;
} }
if (arg_running_as == SYSTEMD_SYSTEM && if (arg_running_as == MANAGER_SYSTEM &&
arg_action == ACTION_RUN && arg_action == ACTION_RUN &&
running_in_chroot() > 0) { running_in_chroot() > 0) {
log_error("Cannot be run in a chroot() environment."); log_error("Cannot be run in a chroot() environment.");
@ -1468,7 +1468,7 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
} }
if (arg_running_as == SYSTEMD_USER && if (arg_running_as == MANAGER_USER &&
!getenv("XDG_RUNTIME_DIR")) { !getenv("XDG_RUNTIME_DIR")) {
log_error("Trying to run as user instance, but $XDG_RUNTIME_DIR is not set."); log_error("Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.");
goto finish; goto finish;
@ -1491,7 +1491,7 @@ int main(int argc, char *argv[]) {
if (arg_serialization) if (arg_serialization)
assert_se(fdset_remove(fds, fileno(arg_serialization)) >= 0); assert_se(fdset_remove(fds, fileno(arg_serialization)) >= 0);
if (arg_running_as == SYSTEMD_SYSTEM) if (arg_running_as == MANAGER_SYSTEM)
/* Become a session leader if we aren't one yet. */ /* Become a session leader if we aren't one yet. */
setsid(); setsid();
@ -1500,7 +1500,7 @@ int main(int argc, char *argv[]) {
/* Reset the console, but only if this is really init and we /* Reset the console, but only if this is really init and we
* are freshly booted */ * are freshly booted */
if (arg_running_as == SYSTEMD_SYSTEM && arg_action == ACTION_RUN) { if (arg_running_as == MANAGER_SYSTEM && arg_action == ACTION_RUN) {
/* If we are init, we connect stdin/stdout/stderr to /* If we are init, we connect stdin/stdout/stderr to
* /dev/null and make sure we don't have a controlling * /dev/null and make sure we don't have a controlling
@ -1527,7 +1527,7 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
} }
if (arg_running_as == SYSTEMD_SYSTEM) { if (arg_running_as == MANAGER_SYSTEM) {
const char *virtualization = NULL; const char *virtualization = NULL;
log_info(PACKAGE_STRING " running in %ssystem mode. (" SYSTEMD_FEATURES ")", log_info(PACKAGE_STRING " running in %ssystem mode. (" SYSTEMD_FEATURES ")",
@ -1563,7 +1563,7 @@ int main(int argc, char *argv[]) {
arg_action == ACTION_TEST ? " test" : "", getuid(), t); arg_action == ACTION_TEST ? " test" : "", getuid(), t);
} }
if (arg_running_as == SYSTEMD_SYSTEM && !skip_setup) { if (arg_running_as == MANAGER_SYSTEM && !skip_setup) {
if (arg_show_status > 0) if (arg_show_status > 0)
status_welcome(); status_welcome();
@ -1575,7 +1575,7 @@ int main(int argc, char *argv[]) {
test_usr(); test_usr();
} }
if (arg_running_as == SYSTEMD_SYSTEM && arg_runtime_watchdog > 0) if (arg_running_as == MANAGER_SYSTEM && arg_runtime_watchdog > 0)
watchdog_set_timeout(&arg_runtime_watchdog); watchdog_set_timeout(&arg_runtime_watchdog);
if (arg_timer_slack_nsec != NSEC_INFINITY) if (arg_timer_slack_nsec != NSEC_INFINITY)
@ -1605,7 +1605,7 @@ int main(int argc, char *argv[]) {
} }
} }
if (arg_running_as == SYSTEMD_USER) { if (arg_running_as == MANAGER_USER) {
/* Become reaper of our children */ /* Become reaper of our children */
if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) { if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) {
log_warning_errno(errno, "Failed to make us a subreaper: %m"); log_warning_errno(errno, "Failed to make us a subreaper: %m");
@ -1614,7 +1614,7 @@ int main(int argc, char *argv[]) {
} }
} }
if (arg_running_as == SYSTEMD_SYSTEM) { if (arg_running_as == MANAGER_SYSTEM) {
bump_rlimit_nofile(&saved_rlimit_nofile); bump_rlimit_nofile(&saved_rlimit_nofile);
if (empty_etc) { if (empty_etc) {
@ -1895,7 +1895,7 @@ finish:
args[i++] = SYSTEMD_BINARY_PATH; args[i++] = SYSTEMD_BINARY_PATH;
if (switch_root_dir) if (switch_root_dir)
args[i++] = "--switched-root"; args[i++] = "--switched-root";
args[i++] = arg_running_as == SYSTEMD_SYSTEM ? "--system" : "--user"; args[i++] = arg_running_as == MANAGER_SYSTEM ? "--system" : "--user";
args[i++] = "--deserialize"; args[i++] = "--deserialize";
args[i++] = sfd; args[i++] = sfd;
args[i++] = NULL; args[i++] = NULL;

View File

@ -474,7 +474,7 @@ static int manager_setup_signals(Manager *m) {
if (r < 0) if (r < 0)
return r; return r;
if (m->running_as == SYSTEMD_SYSTEM) if (m->running_as == MANAGER_SYSTEM)
return enable_special_signals(m); return enable_special_signals(m);
return 0; return 0;
@ -500,7 +500,7 @@ static void manager_clean_environment(Manager *m) {
static int manager_default_environment(Manager *m) { static int manager_default_environment(Manager *m) {
assert(m); assert(m);
if (m->running_as == SYSTEMD_SYSTEM) { if (m->running_as == MANAGER_SYSTEM) {
/* The system manager always starts with a clean /* The system manager always starts with a clean
* environment for its children. It does not import * environment for its children. It does not import
* the kernel or the parents exported variables. * the kernel or the parents exported variables.
@ -529,16 +529,16 @@ static int manager_default_environment(Manager *m) {
} }
int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) { int manager_new(ManagerRunningAs running_as, bool test_run, Manager **_m) {
static const char * const unit_log_fields[_SYSTEMD_RUNNING_AS_MAX] = { static const char * const unit_log_fields[_MANAGER_RUNNING_AS_MAX] = {
[SYSTEMD_SYSTEM] = "UNIT=", [MANAGER_SYSTEM] = "UNIT=",
[SYSTEMD_USER] = "USER_UNIT=", [MANAGER_USER] = "USER_UNIT=",
}; };
static const char * const unit_log_format_strings[_SYSTEMD_RUNNING_AS_MAX] = { static const char * const unit_log_format_strings[_MANAGER_RUNNING_AS_MAX] = {
[SYSTEMD_SYSTEM] = "UNIT=%s", [MANAGER_SYSTEM] = "UNIT=%s",
[SYSTEMD_USER] = "USER_UNIT=%s", [MANAGER_USER] = "USER_UNIT=%s",
}; };
Manager *m; Manager *m;
@ -546,14 +546,14 @@ int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
assert(_m); assert(_m);
assert(running_as >= 0); assert(running_as >= 0);
assert(running_as < _SYSTEMD_RUNNING_AS_MAX); assert(running_as < _MANAGER_RUNNING_AS_MAX);
m = new0(Manager, 1); m = new0(Manager, 1);
if (!m) if (!m)
return -ENOMEM; return -ENOMEM;
#ifdef ENABLE_EFI #ifdef ENABLE_EFI
if (running_as == SYSTEMD_SYSTEM && detect_container(NULL) <= 0) if (running_as == MANAGER_SYSTEM && detect_container(NULL) <= 0)
boot_timestamps(&m->userspace_timestamp, &m->firmware_timestamp, &m->loader_timestamp); boot_timestamps(&m->userspace_timestamp, &m->firmware_timestamp, &m->loader_timestamp);
#endif #endif
@ -678,7 +678,7 @@ static int manager_setup_notify(Manager *m) {
if (fd < 0) if (fd < 0)
return log_error_errno(errno, "Failed to allocate notification socket: %m"); return log_error_errno(errno, "Failed to allocate notification socket: %m");
if (m->running_as == SYSTEMD_SYSTEM) if (m->running_as == MANAGER_SYSTEM)
m->notify_socket = strdup("/run/systemd/notify"); m->notify_socket = strdup("/run/systemd/notify");
else { else {
const char *e; const char *e;
@ -740,12 +740,12 @@ static int manager_setup_kdbus(Manager *m) {
if (!is_kdbus_available()) if (!is_kdbus_available())
return -ESOCKTNOSUPPORT; return -ESOCKTNOSUPPORT;
if (m->running_as == SYSTEMD_SYSTEM && detect_container(NULL) <= 0) if (m->running_as == MANAGER_SYSTEM && detect_container(NULL) <= 0)
bus_kernel_fix_attach_mask(); bus_kernel_fix_attach_mask();
m->kdbus_fd = bus_kernel_create_bus( m->kdbus_fd = bus_kernel_create_bus(
m->running_as == SYSTEMD_SYSTEM ? "system" : "user", m->running_as == MANAGER_SYSTEM ? "system" : "user",
m->running_as == SYSTEMD_SYSTEM, &p); m->running_as == MANAGER_SYSTEM, &p);
if (m->kdbus_fd < 0) if (m->kdbus_fd < 0)
return log_debug_errno(m->kdbus_fd, "Failed to set up kdbus: %m"); return log_debug_errno(m->kdbus_fd, "Failed to set up kdbus: %m");
@ -767,7 +767,7 @@ static int manager_connect_bus(Manager *m, bool reexecuting) {
try_bus_connect = try_bus_connect =
m->kdbus_fd >= 0 || m->kdbus_fd >= 0 ||
reexecuting || reexecuting ||
(m->running_as == SYSTEMD_USER && getenv("DBUS_SESSION_BUS_ADDRESS")); (m->running_as == MANAGER_USER && getenv("DBUS_SESSION_BUS_ADDRESS"));
/* Try to connect to the buses, if possible. */ /* Try to connect to the buses, if possible. */
return bus_init(m, try_bus_connect); return bus_init(m, try_bus_connect);
@ -1728,7 +1728,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
} }
log_received_signal(sfsi.ssi_signo == SIGCHLD || log_received_signal(sfsi.ssi_signo == SIGCHLD ||
(sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER) (sfsi.ssi_signo == SIGTERM && m->running_as == MANAGER_USER)
? LOG_DEBUG : LOG_INFO, ? LOG_DEBUG : LOG_INFO,
&sfsi); &sfsi);
@ -1739,7 +1739,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
break; break;
case SIGTERM: case SIGTERM:
if (m->running_as == SYSTEMD_SYSTEM) { if (m->running_as == MANAGER_SYSTEM) {
/* This is for compatibility with the /* This is for compatibility with the
* original sysvinit */ * original sysvinit */
m->exit_code = MANAGER_REEXECUTE; m->exit_code = MANAGER_REEXECUTE;
@ -1749,7 +1749,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
/* Fall through */ /* Fall through */
case SIGINT: case SIGINT:
if (m->running_as == SYSTEMD_SYSTEM) { if (m->running_as == MANAGER_SYSTEM) {
/* If the user presses C-A-D more than /* If the user presses C-A-D more than
* 7 times within 2s, we reboot * 7 times within 2s, we reboot
@ -1775,14 +1775,14 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
break; break;
case SIGWINCH: case SIGWINCH:
if (m->running_as == SYSTEMD_SYSTEM) if (m->running_as == MANAGER_SYSTEM)
manager_start_target(m, SPECIAL_KBREQUEST_TARGET, JOB_REPLACE); manager_start_target(m, SPECIAL_KBREQUEST_TARGET, JOB_REPLACE);
/* This is a nop on non-init */ /* This is a nop on non-init */
break; break;
case SIGPWR: case SIGPWR:
if (m->running_as == SYSTEMD_SYSTEM) if (m->running_as == MANAGER_SYSTEM)
manager_start_target(m, SPECIAL_SIGPWR_TARGET, JOB_REPLACE); manager_start_target(m, SPECIAL_SIGPWR_TARGET, JOB_REPLACE);
/* This is a nop on non-init */ /* This is a nop on non-init */
@ -1896,7 +1896,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
break; break;
case 24: case 24:
if (m->running_as == SYSTEMD_USER) { if (m->running_as == MANAGER_USER) {
m->exit_code = MANAGER_EXIT; m->exit_code = MANAGER_EXIT;
return 0; return 0;
} }
@ -2014,7 +2014,7 @@ int manager_loop(Manager *m) {
while (m->exit_code == MANAGER_OK) { while (m->exit_code == MANAGER_OK) {
usec_t wait_usec; usec_t wait_usec;
if (m->runtime_watchdog > 0 && m->running_as == SYSTEMD_SYSTEM) if (m->runtime_watchdog > 0 && m->running_as == MANAGER_SYSTEM)
watchdog_ping(); watchdog_ping();
if (!ratelimit_test(&rl)) { if (!ratelimit_test(&rl)) {
@ -2040,7 +2040,7 @@ int manager_loop(Manager *m) {
continue; continue;
/* Sleep for half the watchdog time */ /* Sleep for half the watchdog time */
if (m->runtime_watchdog > 0 && m->running_as == SYSTEMD_SYSTEM) { if (m->runtime_watchdog > 0 && m->running_as == MANAGER_SYSTEM) {
wait_usec = m->runtime_watchdog / 2; wait_usec = m->runtime_watchdog / 2;
if (wait_usec <= 0) if (wait_usec <= 0)
wait_usec = 1; wait_usec = 1;
@ -2120,7 +2120,7 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
if (m->n_reloading > 0) if (m->n_reloading > 0)
return; return;
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return; return;
if (u->type != UNIT_SERVICE) if (u->type != UNIT_SERVICE)
@ -2157,7 +2157,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
if (m->n_reloading > 0) if (m->n_reloading > 0)
return; return;
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return; return;
if (detect_container(NULL) > 0) if (detect_container(NULL) > 0)
@ -2219,7 +2219,7 @@ int manager_open_serialization(Manager *m, FILE **_f) {
assert(_f); assert(_f);
path = m->running_as == SYSTEMD_SYSTEM ? "/run/systemd" : "/tmp"; path = m->running_as == MANAGER_SYSTEM ? "/run/systemd" : "/tmp";
fd = open_tmpfile(path, O_RDWR|O_CLOEXEC); fd = open_tmpfile(path, O_RDWR|O_CLOEXEC);
if (fd < 0) if (fd < 0)
return -errno; return -errno;
@ -2635,7 +2635,7 @@ static void manager_notify_finished(Manager *m) {
if (m->test_run) if (m->test_run)
return; return;
if (m->running_as == SYSTEMD_SYSTEM && detect_container(NULL) <= 0) { if (m->running_as == MANAGER_SYSTEM && detect_container(NULL) <= 0) {
/* Note that m->kernel_usec.monotonic is always at 0, /* Note that m->kernel_usec.monotonic is always at 0,
* and m->firmware_usec.monotonic and * and m->firmware_usec.monotonic and
@ -2751,7 +2751,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
if (*generator) if (*generator)
return 0; return 0;
if (m->running_as == SYSTEMD_SYSTEM && getpid() == 1) { if (m->running_as == MANAGER_SYSTEM && getpid() == 1) {
/* systemd --system, not running --test */ /* systemd --system, not running --test */
p = strappend("/run/systemd/", name); p = strappend("/run/systemd/", name);
@ -2764,7 +2764,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
free(p); free(p);
return r; return r;
} }
} else if (m->running_as == SYSTEMD_USER) { } else if (m->running_as == MANAGER_USER) {
const char *s = NULL; const char *s = NULL;
s = getenv("XDG_RUNTIME_DIR"); s = getenv("XDG_RUNTIME_DIR");
@ -2951,7 +2951,7 @@ void manager_recheck_journal(Manager *m) {
assert(m); assert(m);
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return; return;
u = manager_get_unit(m, SPECIAL_JOURNALD_SOCKET); u = manager_get_unit(m, SPECIAL_JOURNALD_SOCKET);
@ -2975,7 +2975,7 @@ void manager_set_show_status(Manager *m, ShowStatus mode) {
assert(m); assert(m);
assert(IN_SET(mode, SHOW_STATUS_AUTO, SHOW_STATUS_NO, SHOW_STATUS_YES, SHOW_STATUS_TEMPORARY)); assert(IN_SET(mode, SHOW_STATUS_AUTO, SHOW_STATUS_NO, SHOW_STATUS_YES, SHOW_STATUS_TEMPORARY));
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return; return;
m->show_status = mode; m->show_status = mode;
@ -2989,7 +2989,7 @@ void manager_set_show_status(Manager *m, ShowStatus mode) {
static bool manager_get_show_status(Manager *m, StatusType type) { static bool manager_get_show_status(Manager *m, StatusType type) {
assert(m); assert(m);
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return false; return false;
if (m->no_console_output) if (m->no_console_output)
@ -3011,7 +3011,7 @@ static bool manager_get_show_status(Manager *m, StatusType type) {
void manager_set_first_boot(Manager *m, bool b) { void manager_set_first_boot(Manager *m, bool b) {
assert(m); assert(m);
if (m->running_as != SYSTEMD_SYSTEM) if (m->running_as != MANAGER_SYSTEM)
return; return;
m->first_boot = b; m->first_boot = b;
@ -3079,7 +3079,7 @@ Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path) {
const char *manager_get_runtime_prefix(Manager *m) { const char *manager_get_runtime_prefix(Manager *m) {
assert(m); assert(m);
return m->running_as == SYSTEMD_SYSTEM ? return m->running_as == MANAGER_SYSTEM ?
"/run" : "/run" :
getenv("XDG_RUNTIME_DIR"); getenv("XDG_RUNTIME_DIR");
} }

View File

@ -226,7 +226,7 @@ struct Manager {
int pin_cgroupfs_fd; int pin_cgroupfs_fd;
/* Flags */ /* Flags */
SystemdRunningAs running_as; ManagerRunningAs running_as;
ManagerExitCode exit_code:5; ManagerExitCode exit_code:5;
bool dispatching_load_queue:1; bool dispatching_load_queue:1;
@ -297,7 +297,7 @@ struct Manager {
const char *unit_log_format_string; const char *unit_log_format_string;
}; };
int manager_new(SystemdRunningAs running_as, bool test_run, Manager **m); int manager_new(ManagerRunningAs running_as, bool test_run, Manager **m);
Manager* manager_free(Manager *m); Manager* manager_free(Manager *m);
int manager_enumerate(Manager *m); int manager_enumerate(Manager *m);

View File

@ -320,7 +320,7 @@ static int mount_add_device_links(Mount *m) {
if (path_equal(m->where, "/")) if (path_equal(m->where, "/"))
return 0; return 0;
if (mount_is_auto(p) && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM) if (mount_is_auto(p) && UNIT(m)->manager->running_as == MANAGER_SYSTEM)
device_wants_mount = true; device_wants_mount = true;
r = unit_add_node_link(UNIT(m), p->what, device_wants_mount); r = unit_add_node_link(UNIT(m), p->what, device_wants_mount);
@ -336,7 +336,7 @@ static int mount_add_quota_links(Mount *m) {
assert(m); assert(m);
if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM) if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
return 0; return 0;
p = get_mount_parameters_fragment(m); p = get_mount_parameters_fragment(m);
@ -379,7 +379,7 @@ static int mount_add_default_dependencies(Mount *m) {
assert(m); assert(m);
if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM) if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
return 0; return 0;
/* We do not add any default dependencies to / and /usr, since /* We do not add any default dependencies to / and /usr, since
@ -828,7 +828,7 @@ static void mount_enter_unmounting(Mount *m) {
m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT; m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL); r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL);
if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM) if (r >= 0 && UNIT(m)->manager->running_as == MANAGER_SYSTEM)
r = exec_command_append(m->control_command, "-n", NULL); r = exec_command_append(m->control_command, "-n", NULL);
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -880,7 +880,7 @@ static void mount_enter_mounting(Mount *m) {
r = exec_command_set(m->control_command, "/bin/mount", r = exec_command_set(m->control_command, "/bin/mount",
m->parameters_fragment.what, m->where, NULL); m->parameters_fragment.what, m->where, NULL);
if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM) if (r >= 0 && UNIT(m)->manager->running_as == MANAGER_SYSTEM)
r = exec_command_append(m->control_command, "-n", NULL); r = exec_command_append(m->control_command, "-n", NULL);
if (r >= 0 && m->sloppy_options) if (r >= 0 && m->sloppy_options)
r = exec_command_append(m->control_command, "-s", NULL); r = exec_command_append(m->control_command, "-s", NULL);
@ -928,7 +928,7 @@ static void mount_enter_remounting(Mount *m) {
r = exec_command_set(m->control_command, "/bin/mount", r = exec_command_set(m->control_command, "/bin/mount",
m->parameters_fragment.what, m->where, m->parameters_fragment.what, m->where,
"-o", o, NULL); "-o", o, NULL);
if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM) if (r >= 0 && UNIT(m)->manager->running_as == MANAGER_SYSTEM)
r = exec_command_append(m->control_command, "-n", NULL); r = exec_command_append(m->control_command, "-n", NULL);
if (r >= 0 && m->sloppy_options) if (r >= 0 && m->sloppy_options)
r = exec_command_append(m->control_command, "-s", NULL); r = exec_command_append(m->control_command, "-s", NULL);
@ -1376,7 +1376,7 @@ static int mount_setup_unit(
goto fail; goto fail;
} }
if (m->running_as == SYSTEMD_SYSTEM) { if (m->running_as == MANAGER_SYSTEM) {
const char* target; const char* target;
target = mount_needs_network(options, fstype) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET; target = mount_needs_network(options, fstype) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET;
@ -1404,7 +1404,7 @@ static int mount_setup_unit(
} }
} }
if (m->running_as == SYSTEMD_SYSTEM && if (m->running_as == MANAGER_SYSTEM &&
mount_needs_network(options, fstype)) { mount_needs_network(options, fstype)) {
/* _netdev option may have shown up late, or on a /* _netdev option may have shown up late, or on a
* remount. Add remote-fs dependencies, even though * remount. Add remote-fs dependencies, even though

View File

@ -314,7 +314,7 @@ static int path_add_default_dependencies(Path *p) {
if (r < 0) if (r < 0)
return r; return r;
if (UNIT(p)->manager->running_as == SYSTEMD_SYSTEM) { if (UNIT(p)->manager->running_as == MANAGER_SYSTEM) {
r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES,
SPECIAL_SYSINIT_TARGET, NULL, true); SPECIAL_SYSINIT_TARGET, NULL, true);
if (r < 0) if (r < 0)

View File

@ -1121,7 +1121,7 @@ static int service_spawn(
goto fail; goto fail;
} }
if (UNIT(s)->manager->running_as != SYSTEMD_SYSTEM) if (UNIT(s)->manager->running_as != MANAGER_SYSTEM)
if (asprintf(our_env + n_env++, "MANAGERPID="PID_FMT, getpid()) < 0) { if (asprintf(our_env + n_env++, "MANAGERPID="PID_FMT, getpid()) < 0) {
r = -ENOMEM; r = -ENOMEM;
goto fail; goto fail;
@ -1181,7 +1181,7 @@ static int service_spawn(
#ifdef ENABLE_KDBUS #ifdef ENABLE_KDBUS
if (s->exec_context.bus_endpoint) { if (s->exec_context.bus_endpoint) {
r = bus_kernel_create_endpoint(UNIT(s)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user", r = bus_kernel_create_endpoint(UNIT(s)->manager->running_as == MANAGER_SYSTEM ? "system" : "user",
UNIT(s)->id, &bus_endpoint_path); UNIT(s)->id, &bus_endpoint_path);
if (r < 0) if (r < 0)
goto fail; goto fail;

View File

@ -284,7 +284,7 @@ static int socket_add_default_dependencies(Socket *s) {
if (r < 0) if (r < 0)
return r; return r;
if (UNIT(s)->manager->running_as == SYSTEMD_SYSTEM) { if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true); r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -201,7 +201,7 @@ static int swap_add_device_links(Swap *s) {
return 0; return 0;
if (is_device_path(s->what)) if (is_device_path(s->what))
return unit_add_node_link(UNIT(s), s->what, UNIT(s)->manager->running_as == SYSTEMD_SYSTEM); return unit_add_node_link(UNIT(s), s->what, UNIT(s)->manager->running_as == MANAGER_SYSTEM);
else else
/* File based swap devices need to be ordered after /* File based swap devices need to be ordered after
* systemd-remount-fs.service, since they might need a * systemd-remount-fs.service, since they might need a
@ -212,7 +212,7 @@ static int swap_add_device_links(Swap *s) {
static int swap_add_default_dependencies(Swap *s) { static int swap_add_default_dependencies(Swap *s) {
assert(s); assert(s);
if (UNIT(s)->manager->running_as != SYSTEMD_SYSTEM) if (UNIT(s)->manager->running_as != MANAGER_SYSTEM)
return 0; return 0;
if (detect_container(NULL) > 0) if (detect_container(NULL) > 0)

View File

@ -102,7 +102,7 @@ static int timer_add_default_dependencies(Timer *t) {
if (r < 0) if (r < 0)
return r; return r;
if (UNIT(t)->manager->running_as == SYSTEMD_SYSTEM) { if (UNIT(t)->manager->running_as == MANAGER_SYSTEM) {
r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true); r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true);
if (r < 0) if (r < 0)
return r; return r;
@ -128,7 +128,7 @@ static int timer_setup_persistent(Timer *t) {
if (!t->persistent) if (!t->persistent)
return 0; return 0;
if (UNIT(t)->manager->running_as == SYSTEMD_SYSTEM) { if (UNIT(t)->manager->running_as == MANAGER_SYSTEM) {
r = unit_require_mounts_for(UNIT(t), "/var/lib/systemd/timers"); r = unit_require_mounts_for(UNIT(t), "/var/lib/systemd/timers");
if (r < 0) if (r < 0)

View File

@ -140,7 +140,7 @@ static int specifier_runtime(char specifier, void *data, void *userdata, char **
assert(u); assert(u);
if (u->manager->running_as == SYSTEMD_SYSTEM) if (u->manager->running_as == MANAGER_SYSTEM)
e = "/run"; e = "/run";
else { else {
e = getenv("XDG_RUNTIME_DIR"); e = getenv("XDG_RUNTIME_DIR");
@ -168,7 +168,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
if (!c) if (!c)
return -EINVAL; return -EINVAL;
if (u->manager->running_as == SYSTEMD_SYSTEM) { if (u->manager->running_as == MANAGER_SYSTEM) {
/* We cannot use NSS from PID 1, hence try to make the /* We cannot use NSS from PID 1, hence try to make the
* best of it in that case, and fail if we can't help * best of it in that case, and fail if we can't help
@ -231,7 +231,7 @@ static int specifier_user_home(char specifier, void *data, void *userdata, char
if (!c) if (!c)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (u->manager->running_as == SYSTEMD_SYSTEM) { if (u->manager->running_as == MANAGER_SYSTEM) {
/* We cannot use NSS from PID 1, hence try to make the /* We cannot use NSS from PID 1, hence try to make the
* best of it if we can, but fail if we can't */ * best of it if we can, but fail if we can't */
@ -279,7 +279,7 @@ static int specifier_user_shell(char specifier, void *data, void *userdata, char
if (!c) if (!c)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (u->manager->running_as == SYSTEMD_SYSTEM) { if (u->manager->running_as == MANAGER_SYSTEM) {
/* We cannot use NSS from PID 1, hence try to make the /* We cannot use NSS from PID 1, hence try to make the
* best of it if we can, but fail if we can't */ * best of it if we can, but fail if we can't */

View File

@ -804,7 +804,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
return r; return r;
} }
if (u->manager->running_as != SYSTEMD_SYSTEM) if (u->manager->running_as != MANAGER_SYSTEM)
return 0; return 0;
if (c->private_tmp) { if (c->private_tmp) {
@ -2456,7 +2456,7 @@ int unit_add_default_slice(Unit *u, CGroupContext *c) {
if (!escaped) if (!escaped)
return -ENOMEM; return -ENOMEM;
if (u->manager->running_as == SYSTEMD_SYSTEM) if (u->manager->running_as == MANAGER_SYSTEM)
b = strjoin("system-", escaped, ".slice", NULL); b = strjoin("system-", escaped, ".slice", NULL);
else else
b = strappend(escaped, ".slice"); b = strappend(escaped, ".slice");
@ -2466,7 +2466,7 @@ int unit_add_default_slice(Unit *u, CGroupContext *c) {
slice_name = b; slice_name = b;
} else } else
slice_name = slice_name =
u->manager->running_as == SYSTEMD_SYSTEM u->manager->running_as == MANAGER_SYSTEM
? SPECIAL_SYSTEM_SLICE ? SPECIAL_SYSTEM_SLICE
: SPECIAL_ROOT_SLICE; : SPECIAL_ROOT_SLICE;
@ -2836,7 +2836,7 @@ int unit_add_node_link(Unit *u, const char *what, bool wants) {
if (r < 0) if (r < 0)
return r; return r;
r = unit_add_two_dependencies(u, UNIT_AFTER, u->manager->running_as == SYSTEMD_SYSTEM ? UNIT_BINDS_TO : UNIT_WANTS, device, true); r = unit_add_two_dependencies(u, UNIT_AFTER, u->manager->running_as == MANAGER_SYSTEM ? UNIT_BINDS_TO : UNIT_WANTS, device, true);
if (r < 0) if (r < 0)
return r; return r;
@ -3111,7 +3111,7 @@ UnitFileState unit_get_unit_file_state(Unit *u) {
if (u->unit_file_state < 0 && u->fragment_path) if (u->unit_file_state < 0 && u->fragment_path)
u->unit_file_state = unit_file_get_state( u->unit_file_state = unit_file_get_state(
u->manager->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, u->manager->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
NULL, basename(u->fragment_path)); NULL, basename(u->fragment_path));
return u->unit_file_state; return u->unit_file_state;
@ -3122,7 +3122,7 @@ int unit_get_unit_file_preset(Unit *u) {
if (u->unit_file_preset < 0 && u->fragment_path) if (u->unit_file_preset < 0 && u->fragment_path)
u->unit_file_preset = unit_file_query_preset( u->unit_file_preset = unit_file_query_preset(
u->manager->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, u->manager->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
NULL, basename(u->fragment_path)); NULL, basename(u->fragment_path));
return u->unit_file_preset; return u->unit_file_preset;
@ -3172,7 +3172,7 @@ int unit_patch_contexts(Unit *u) {
return -ENOMEM; return -ENOMEM;
} }
if (u->manager->running_as == SYSTEMD_USER && if (u->manager->running_as == MANAGER_USER &&
!ec->working_directory) { !ec->working_directory) {
r = get_home_dir(&ec->working_directory); r = get_home_dir(&ec->working_directory);
@ -3184,7 +3184,7 @@ int unit_patch_contexts(Unit *u) {
ec->working_directory_missing_ok = true; ec->working_directory_missing_ok = true;
} }
if (u->manager->running_as == SYSTEMD_USER && if (u->manager->running_as == MANAGER_USER &&
(ec->syscall_whitelist || (ec->syscall_whitelist ||
!set_isempty(ec->syscall_filter) || !set_isempty(ec->syscall_filter) ||
!set_isempty(ec->syscall_archs) || !set_isempty(ec->syscall_archs) ||
@ -3263,7 +3263,7 @@ ExecRuntime *unit_get_exec_runtime(Unit *u) {
} }
static int unit_drop_in_dir(Unit *u, UnitSetPropertiesMode mode, bool transient, char **dir) { static int unit_drop_in_dir(Unit *u, UnitSetPropertiesMode mode, bool transient, char **dir) {
if (u->manager->running_as == SYSTEMD_USER) { if (u->manager->running_as == MANAGER_USER) {
int r; int r;
if (mode == UNIT_PERSISTENT && !transient) if (mode == UNIT_PERSISTENT && !transient)
@ -3432,7 +3432,7 @@ int unit_make_transient(Unit *u) {
free(u->fragment_path); free(u->fragment_path);
u->fragment_path = NULL; u->fragment_path = NULL;
if (u->manager->running_as == SYSTEMD_USER) { if (u->manager->running_as == MANAGER_USER) {
_cleanup_free_ char *c = NULL; _cleanup_free_ char *c = NULL;
r = user_runtime_dir(&c); r = user_runtime_dir(&c);

View File

@ -218,8 +218,8 @@ static char** user_dirs(
return tmp; return tmp;
} }
char **generator_paths(SystemdRunningAs running_as) { char **generator_paths(ManagerRunningAs running_as) {
if (running_as == SYSTEMD_USER) if (running_as == MANAGER_USER)
return strv_new("/run/systemd/user-generators", return strv_new("/run/systemd/user-generators",
"/etc/systemd/user-generators", "/etc/systemd/user-generators",
"/usr/local/lib/systemd/user-generators", "/usr/local/lib/systemd/user-generators",
@ -235,7 +235,7 @@ char **generator_paths(SystemdRunningAs running_as) {
int lookup_paths_init( int lookup_paths_init(
LookupPaths *p, LookupPaths *p,
SystemdRunningAs running_as, ManagerRunningAs running_as,
bool personal, bool personal,
const char *root_dir, const char *root_dir,
const char *generator, const char *generator,
@ -277,7 +277,7 @@ int lookup_paths_init(
* we include /lib in the search path for the system * we include /lib in the search path for the system
* stuff but avoid it for user stuff. */ * stuff but avoid it for user stuff. */
if (running_as == SYSTEMD_USER) { if (running_as == MANAGER_USER) {
if (personal) if (personal)
unit_path = user_dirs(generator, generator_early, generator_late); unit_path = user_dirs(generator, generator_early, generator_late);
else else
@ -337,7 +337,7 @@ int lookup_paths_init(
p->unit_path = NULL; p->unit_path = NULL;
} }
if (running_as == SYSTEMD_SYSTEM) { if (running_as == MANAGER_SYSTEM) {
#ifdef HAVE_SYSV_COMPAT #ifdef HAVE_SYSV_COMPAT
/* /etc/init.d/ compatibility does not matter to users */ /* /etc/init.d/ compatibility does not matter to users */
@ -437,7 +437,7 @@ int lookup_paths_init_from_scope(LookupPaths *paths,
zero(*paths); zero(*paths);
return lookup_paths_init(paths, return lookup_paths_init(paths,
scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER, scope == UNIT_FILE_SYSTEM ? MANAGER_SYSTEM : MANAGER_USER,
scope == UNIT_FILE_USER, scope == UNIT_FILE_USER,
root_dir, root_dir,
NULL, NULL, NULL); NULL, NULL, NULL);

View File

@ -33,20 +33,20 @@ typedef struct LookupPaths {
#endif #endif
} LookupPaths; } LookupPaths;
typedef enum SystemdRunningAs { typedef enum ManagerRunningAs {
SYSTEMD_SYSTEM, MANAGER_SYSTEM,
SYSTEMD_USER, MANAGER_USER,
_SYSTEMD_RUNNING_AS_MAX, _MANAGER_RUNNING_AS_MAX,
_SYSTEMD_RUNNING_AS_INVALID = -1 _MANAGER_RUNNING_AS_INVALID = -1
} SystemdRunningAs; } ManagerRunningAs;
int user_config_home(char **config_home); int user_config_home(char **config_home);
int user_runtime_dir(char **runtime_dir); int user_runtime_dir(char **runtime_dir);
char **generator_paths(SystemdRunningAs running_as); char **generator_paths(ManagerRunningAs running_as);
int lookup_paths_init(LookupPaths *p, int lookup_paths_init(LookupPaths *p,
SystemdRunningAs running_as, ManagerRunningAs running_as,
bool personal, bool personal,
const char *root_dir, const char *root_dir,
const char *generator, const char *generator,

View File

@ -5111,7 +5111,7 @@ static int enable_sysv_units(const char *verb, char **args) {
/* Processes all SysV units, and reshuffles the array so that /* Processes all SysV units, and reshuffles the array so that
* afterwards only the native units remain */ * afterwards only the native units remain */
r = lookup_paths_init(&paths, SYSTEMD_SYSTEM, false, arg_root, NULL, NULL, NULL); r = lookup_paths_init(&paths, MANAGER_SYSTEM, false, arg_root, NULL, NULL, NULL);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -931,7 +931,7 @@ int main(int argc, char *argv[]) {
umask(0022); umask(0022);
r = lookup_paths_init(&lp, SYSTEMD_SYSTEM, true, NULL, NULL, NULL, NULL); r = lookup_paths_init(&lp, MANAGER_SYSTEM, true, NULL, NULL, NULL, NULL);
if (r < 0) { if (r < 0) {
log_error("Failed to find lookup paths."); log_error("Failed to find lookup paths.");
return EXIT_FAILURE; return EXIT_FAILURE;

View File

@ -35,7 +35,7 @@ static int test_cgroup_mask(void) {
/* Prepare the manager. */ /* Prepare the manager. */
assert_se(set_unit_path(TEST_DIR) >= 0); assert_se(set_unit_path(TEST_DIR) >= 0);
r = manager_new(SYSTEMD_USER, true, &m); r = manager_new(MANAGER_USER, true, &m);
if (r == -EPERM || r == -EACCES) { if (r == -EPERM || r == -EACCES) {
puts("manager_new: Permission denied. Skipping test."); puts("manager_new: Permission denied. Skipping test.");
return EXIT_TEST_SKIP; return EXIT_TEST_SKIP;

View File

@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
/* prepare the test */ /* prepare the test */
assert_se(set_unit_path(TEST_DIR) >= 0); assert_se(set_unit_path(TEST_DIR) >= 0);
r = manager_new(SYSTEMD_USER, true, &m); r = manager_new(MANAGER_USER, true, &m);
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) { if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
printf("Skipping test: manager_new: %s", strerror(-r)); printf("Skipping test: manager_new: %s", strerror(-r));
return EXIT_TEST_SKIP; return EXIT_TEST_SKIP;

View File

@ -167,7 +167,7 @@ int main(int argc, char *argv[]) {
assert_se(set_unit_path(TEST_DIR) >= 0); assert_se(set_unit_path(TEST_DIR) >= 0);
r = manager_new(SYSTEMD_USER, true, &m); r = manager_new(MANAGER_USER, true, &m);
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) { if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
printf("Skipping test: manager_new: %s", strerror(-r)); printf("Skipping test: manager_new: %s", strerror(-r));
return EXIT_TEST_SKIP; return EXIT_TEST_SKIP;

View File

@ -26,7 +26,7 @@
#include "strv.h" #include "strv.h"
#include "rm-rf.h" #include "rm-rf.h"
static void test_paths(SystemdRunningAs running_as, bool personal) { static void test_paths(ManagerRunningAs running_as, bool personal) {
char template[] = "/tmp/test-path-lookup.XXXXXXX"; char template[] = "/tmp/test-path-lookup.XXXXXXX";
_cleanup_lookup_paths_free_ LookupPaths lp = {}; _cleanup_lookup_paths_free_ LookupPaths lp = {};
@ -46,11 +46,11 @@ static void test_paths(SystemdRunningAs running_as, bool personal) {
assert_se(rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0); assert_se(rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
} }
static void print_generator_paths(SystemdRunningAs running_as) { static void print_generator_paths(ManagerRunningAs running_as) {
_cleanup_strv_free_ char **paths; _cleanup_strv_free_ char **paths;
char **dir; char **dir;
log_info("Generators dirs (%s):", running_as == SYSTEMD_SYSTEM ? "system" : "user"); log_info("Generators dirs (%s):", running_as == MANAGER_SYSTEM ? "system" : "user");
paths = generator_paths(running_as); paths = generator_paths(running_as);
STRV_FOREACH(dir, paths) STRV_FOREACH(dir, paths)
@ -62,13 +62,13 @@ int main(int argc, char **argv) {
log_parse_environment(); log_parse_environment();
log_open(); log_open();
test_paths(SYSTEMD_SYSTEM, false); test_paths(MANAGER_SYSTEM, false);
test_paths(SYSTEMD_SYSTEM, true); test_paths(MANAGER_SYSTEM, true);
test_paths(SYSTEMD_USER, false); test_paths(MANAGER_USER, false);
test_paths(SYSTEMD_USER, true); test_paths(MANAGER_USER, true);
print_generator_paths(SYSTEMD_SYSTEM); print_generator_paths(MANAGER_SYSTEM);
print_generator_paths(SYSTEMD_USER); print_generator_paths(MANAGER_USER);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -39,7 +39,7 @@ static int setup_test(Manager **m) {
assert_se(m); assert_se(m);
r = manager_new(SYSTEMD_USER, true, &tmp); r = manager_new(MANAGER_USER, true, &tmp);
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) { if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
printf("Skipping test: manager_new: %s", strerror(-r)); printf("Skipping test: manager_new: %s", strerror(-r));
return -EXIT_TEST_SKIP; return -EXIT_TEST_SKIP;

View File

@ -34,7 +34,7 @@ int main(int argc, char *argv[]) {
/* prepare the test */ /* prepare the test */
assert_se(set_unit_path(TEST_DIR) >= 0); assert_se(set_unit_path(TEST_DIR) >= 0);
r = manager_new(SYSTEMD_USER, true, &m); r = manager_new(MANAGER_USER, true, &m);
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) { if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
printf("Skipping test: manager_new: %s", strerror(-r)); printf("Skipping test: manager_new: %s", strerror(-r));
return EXIT_TEST_SKIP; return EXIT_TEST_SKIP;

View File

@ -200,7 +200,7 @@ static int test_unit_printf(void) {
assert_se((root = getpwnam("root"))); assert_se((root = getpwnam("root")));
assert_se(asprintf(&root_uid, "%d", (int) root->pw_uid) > 0); assert_se(asprintf(&root_uid, "%d", (int) root->pw_uid) > 0);
r = manager_new(SYSTEMD_USER, true, &m); r = manager_new(MANAGER_USER, true, &m);
if (r == -EPERM || r == -EACCES || r == -EADDRINUSE) { if (r == -EPERM || r == -EACCES || r == -EADDRINUSE) {
puts("manager_new: Permission denied. Skipping test."); puts("manager_new: Permission denied. Skipping test.");
return EXIT_TEST_SKIP; return EXIT_TEST_SKIP;