summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO3
-rw-r--r--src/core/automount.c2
-rw-r--r--src/core/cgroup.c2
-rw-r--r--src/core/dbus-manager.c20
-rw-r--r--src/core/dbus.c24
-rw-r--r--src/core/main.c38
-rw-r--r--src/core/manager.c47
-rw-r--r--src/core/manager.h14
-rw-r--r--src/core/mount.c6
-rw-r--r--src/core/path.c2
-rw-r--r--src/core/service.c6
-rw-r--r--src/core/socket.c2
-rw-r--r--src/core/swap.c4
-rw-r--r--src/core/timer.c2
-rw-r--r--src/core/unit-printf.c2
-rw-r--r--src/core/unit.c6
-rw-r--r--src/shared/install.c2
-rw-r--r--src/shared/path-lookup.c14
-rw-r--r--src/shared/path-lookup.h12
-rw-r--r--src/systemctl/systemctl.c3
-rw-r--r--src/test/test-engine.c2
21 files changed, 105 insertions, 108 deletions
diff --git a/TODO b/TODO
index 0eca82ad22..c941cb070c 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 c9b87d5174..11b6a6a45a 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 8ddb1118ed..8fc1731485 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 2235e36496..276ad6c634 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 f05f610718..2a1c66054a 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 9d2d55154c..04fc0b3b59 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 f56d39007a..3cd99154e6 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 653496ded0..913752f9ef 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 78740a8b2d..66ef0cd25c 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 e3defeb5ab..3936971b41 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 39e1ab5167..7c79dcdd14 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 361404512c..26e7fd24de 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 d5bf153f29..b4f53b7248 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 03c9610eb6..7080b32c6b 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 308bbd6351..cbae45d9f7 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 1e33936346..ae43545c6f 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 c6215fbb32..f30bf8317b 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 a9c3e21d51..6e5529e0c7 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 0aab956f25..baef62228a 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 17a8497dcc..0e564a5428 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 11389a5ac7..0f3862226a 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);