[systemd-commits] 4 commits - TODO src/analyze src/core src/shared src/systemctl src/sysv-generator src/test
Lennart Poettering
lennart at kemper.freedesktop.org
Mon May 11 13:59:22 PDT 2015
TODO | 2 -
src/analyze/analyze-verify.c | 2 -
src/analyze/analyze-verify.h | 2 -
src/analyze/analyze.c | 2 -
src/core/automount.c | 2 -
src/core/busname.c | 4 +-
src/core/cgroup.c | 4 +-
src/core/dbus-manager.c | 30 +++++++--------
src/core/dbus.c | 16 ++++----
src/core/device.c | 2 -
src/core/failure-action.c | 2 -
src/core/job.c | 2 -
src/core/load-fragment.c | 2 -
src/core/main.c | 40 ++++++++++----------
src/core/manager.c | 70 ++++++++++++++++++------------------
src/core/manager.h | 4 +-
src/core/mount.c | 62 ++++---------------------------
src/core/mount.h | 3 -
src/core/path.c | 2 -
src/core/service.c | 4 +-
src/core/socket.c | 2 -
src/core/swap.c | 4 +-
src/core/timer.c | 4 +-
src/core/unit-printf.c | 8 ++--
src/core/unit.c | 66 ++++++++++++++++++++++++++++-----
src/core/unit.h | 3 +
src/shared/install-printf.c | 10 ++---
src/shared/install-printf.h | 3 +
src/shared/install.c | 36 +++++++++---------
src/shared/install.h | 36 +++++++++++-------
src/shared/path-lookup.c | 12 +++---
src/shared/path-lookup.h | 23 ++++++-----
src/systemctl/systemctl.c | 2 -
src/sysv-generator/sysv-generator.c | 2 -
src/test/test-cgroup-mask.c | 2 -
src/test/test-engine.c | 2 -
src/test/test-execute.c | 2 -
src/test/test-path-lookup.c | 18 ++++-----
src/test/test-path.c | 2 -
src/test/test-sched-prio.c | 2 -
src/test/test-unit-file.c | 8 ++--
src/test/test-unit-name.c | 2 -
42 files changed, 258 insertions(+), 248 deletions(-)
New commits:
commit 0a98c46d509ed03c3bdfc71e5d694dd40d2db4b0
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 11 22:56:31 2015 +0200
update TODO
diff --git a/TODO b/TODO
index d9cfa8d..3edb7fd 100644
--- a/TODO
+++ b/TODO
@@ -49,7 +49,7 @@ Before 220:
* introduce argv0array=
-* rework log_unit_error() to always prefix output with unit name
+* Assertion 'device' failed at src/network/networkd-network.c:280, function network_get(). Aborting.
Features:
commit cab6235f748e365198a7939f23c87ab3b8f59b2e
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 11 22:53:54 2015 +0200
install: when exporting prefix InstallInfo to become UnitFileInstallInfo
All other types exported from install.h should be namespaces like this,
hence namespace InstallInfo the same way.
Also, remove external forward definition of UnitFileScope type.
diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c
index 7c25d36..cbe984d 100644
--- a/src/shared/install-printf.c
+++ b/src/shared/install-printf.c
@@ -28,7 +28,7 @@
#include "formats-util.h"
static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) {
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
assert(i);
@@ -36,7 +36,7 @@ static int specifier_prefix_and_instance(char specifier, void *data, void *userd
}
static int specifier_prefix(char specifier, void *data, void *userdata, char **ret) {
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
assert(i);
@@ -44,7 +44,7 @@ static int specifier_prefix(char specifier, void *data, void *userdata, char **r
}
static int specifier_instance(char specifier, void *data, void *userdata, char **ret) {
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
char *instance;
int r;
@@ -65,7 +65,7 @@ static int specifier_instance(char specifier, void *data, void *userdata, char *
}
static int specifier_user_name(char specifier, void *data, void *userdata, char **ret) {
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
const char *username;
_cleanup_free_ char *tmp = NULL;
char *printed = NULL;
@@ -102,7 +102,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
}
-int install_full_printf(InstallInfo *i, const char *format, char **ret) {
+int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret) {
/* This is similar to unit_full_printf() but does not support
* anything path-related.
diff --git a/src/shared/install-printf.h b/src/shared/install-printf.h
index 6ffa488..6550337 100644
--- a/src/shared/install-printf.h
+++ b/src/shared/install-printf.h
@@ -22,4 +22,5 @@
#pragma once
#include "install.h"
-int install_full_printf(InstallInfo *i, const char *format, char **ret);
+
+int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret);
diff --git a/src/shared/install.c b/src/shared/install.c
index 9648c64..dc4cc62 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -809,7 +809,7 @@ void unit_file_changes_free(UnitFileChange *changes, unsigned n_changes) {
free(changes);
}
-static void install_info_free(InstallInfo *i) {
+static void install_info_free(UnitFileInstallInfo *i) {
assert(i);
free(i->name);
@@ -823,7 +823,7 @@ static void install_info_free(InstallInfo *i) {
}
static void install_info_hashmap_free(OrderedHashmap *m) {
- InstallInfo *i;
+ UnitFileInstallInfo *i;
if (!m)
return;
@@ -847,7 +847,7 @@ static int install_info_add(
InstallContext *c,
const char *name,
const char *path) {
- InstallInfo *i = NULL;
+ UnitFileInstallInfo *i = NULL;
int r;
assert(c);
@@ -867,7 +867,7 @@ static int install_info_add(
if (r < 0)
return r;
- i = new0(InstallInfo, 1);
+ i = new0(UnitFileInstallInfo, 1);
if (!i)
return -ENOMEM;
@@ -926,7 +926,7 @@ static int config_parse_also(
size_t l;
const char *word, *state;
InstallContext *c = data;
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
assert(filename);
assert(lvalue);
@@ -967,7 +967,7 @@ static int config_parse_user(
void *data,
void *userdata) {
- InstallInfo *i = data;
+ UnitFileInstallInfo *i = data;
char *printed;
int r;
@@ -997,7 +997,7 @@ static int config_parse_default_instance(
void *data,
void *userdata) {
- InstallInfo *i = data;
+ UnitFileInstallInfo *i = data;
char *printed;
int r;
@@ -1022,7 +1022,7 @@ static int config_parse_default_instance(
static int unit_file_load(
InstallContext *c,
- InstallInfo *info,
+ UnitFileInstallInfo *info,
const char *path,
const char *root_dir,
bool allow_symlink,
@@ -1082,7 +1082,7 @@ static int unit_file_load(
static int unit_file_search(
InstallContext *c,
- InstallInfo *info,
+ UnitFileInstallInfo *info,
const LookupPaths *paths,
const char *root_dir,
bool allow_symlink,
@@ -1159,7 +1159,7 @@ static int unit_file_can_install(
bool *also) {
_cleanup_(install_context_done) InstallContext c = {};
- InstallInfo *i;
+ UnitFileInstallInfo *i;
int r;
assert(paths);
@@ -1226,7 +1226,7 @@ static int create_symlink(
}
static int install_info_symlink_alias(
- InstallInfo *i,
+ UnitFileInstallInfo *i,
const char *config_path,
bool force,
UnitFileChange **changes,
@@ -1258,7 +1258,7 @@ static int install_info_symlink_alias(
}
static int install_info_symlink_wants(
- InstallInfo *i,
+ UnitFileInstallInfo *i,
const char *config_path,
char **list,
const char *suffix,
@@ -1315,7 +1315,7 @@ static int install_info_symlink_wants(
}
static int install_info_symlink_link(
- InstallInfo *i,
+ UnitFileInstallInfo *i,
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
@@ -1343,7 +1343,7 @@ static int install_info_symlink_link(
}
static int install_info_apply(
- InstallInfo *i,
+ UnitFileInstallInfo *i,
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
@@ -1383,7 +1383,7 @@ static int install_context_apply(
UnitFileChange **changes,
unsigned *n_changes) {
- InstallInfo *i;
+ UnitFileInstallInfo *i;
int r, q;
assert(c);
@@ -1428,7 +1428,7 @@ static int install_context_mark_for_removal(
const char *config_path,
const char *root_dir) {
- InstallInfo *i;
+ UnitFileInstallInfo *i;
int r, q;
assert(c);
@@ -1513,7 +1513,7 @@ int unit_file_add_dependency(
_cleanup_free_ char *config_path = NULL;
char **i;
int r;
- InstallInfo *info;
+ UnitFileInstallInfo *info;
assert(scope >= 0);
assert(scope < _UNIT_FILE_SCOPE_MAX);
@@ -1702,7 +1702,7 @@ int unit_file_set_default(
_cleanup_free_ char *config_path = NULL;
char *path;
int r;
- InstallInfo *i = NULL;
+ UnitFileInstallInfo *i = NULL;
assert(scope >= 0);
assert(scope < _UNIT_FILE_SCOPE_MAX);
diff --git a/src/shared/install.h b/src/shared/install.h
index 3ca3939..45eca42 100644
--- a/src/shared/install.h
+++ b/src/shared/install.h
@@ -21,19 +21,27 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+typedef enum UnitFileScope UnitFileScope;
+typedef enum UnitFileState UnitFileState;
+typedef enum UnitFilePresetMode UnitFilePresetMode;
+typedef enum UnitFileChangeType UnitFileChangeType;
+typedef struct UnitFileChange UnitFileChange;
+typedef struct UnitFileList UnitFileList;
+typedef struct UnitFileInstallInfo UnitFileInstallInfo;
+
#include "hashmap.h"
#include "unit-name.h"
#include "path-lookup.h"
-typedef enum UnitFileScope {
+enum UnitFileScope {
UNIT_FILE_SYSTEM,
UNIT_FILE_GLOBAL,
UNIT_FILE_USER,
_UNIT_FILE_SCOPE_MAX,
_UNIT_FILE_SCOPE_INVALID = -1
-} UnitFileScope;
+};
-typedef enum UnitFileState {
+enum UnitFileState {
UNIT_FILE_ENABLED,
UNIT_FILE_ENABLED_RUNTIME,
UNIT_FILE_LINKED,
@@ -46,35 +54,35 @@ typedef enum UnitFileState {
UNIT_FILE_INVALID,
_UNIT_FILE_STATE_MAX,
_UNIT_FILE_STATE_INVALID = -1
-} UnitFileState;
+};
-typedef enum UnitFilePresetMode {
+enum UnitFilePresetMode {
UNIT_FILE_PRESET_FULL,
UNIT_FILE_PRESET_ENABLE_ONLY,
UNIT_FILE_PRESET_DISABLE_ONLY,
_UNIT_FILE_PRESET_MAX,
_UNIT_FILE_PRESET_INVALID = -1
-} UnitFilePresetMode;
+};
-typedef enum UnitFileChangeType {
+enum UnitFileChangeType {
UNIT_FILE_SYMLINK,
UNIT_FILE_UNLINK,
_UNIT_FILE_CHANGE_TYPE_MAX,
_UNIT_FILE_CHANGE_TYPE_INVALID = -1
-} UnitFileChangeType;
+};
-typedef struct UnitFileChange {
+struct UnitFileChange {
UnitFileChangeType type;
char *path;
char *source;
-} UnitFileChange;
+};
-typedef struct UnitFileList {
+struct UnitFileList {
char *path;
UnitFileState state;
-} UnitFileList;
+};
-typedef struct {
+struct UnitFileInstallInfo {
char *name;
char *path;
char *user;
@@ -85,7 +93,7 @@ typedef struct {
char **also;
char *default_instance;
-} InstallInfo;
+};
int unit_file_enable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
int unit_file_disable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index 31b2df3..e35c8d3 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -23,8 +23,6 @@
#include "macro.h"
-typedef enum UnitFileScope UnitFileScope;
-
typedef struct LookupPaths {
char **unit_path;
#ifdef HAVE_SYSV_COMPAT
@@ -52,9 +50,12 @@ int lookup_paths_init(LookupPaths *p,
const char *generator,
const char *generator_early,
const char *generator_late);
-void lookup_paths_free(LookupPaths *p);
+
+#include "install.h"
+
int lookup_paths_init_from_scope(LookupPaths *paths,
UnitFileScope scope,
const char *root_dir);
+void lookup_paths_free(LookupPaths *p);
#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 5a9796d..f3f6c29 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -453,12 +453,12 @@ static void test_install_printf(void) {
char name[] = "name.service",
path[] = "/run/systemd/system/name.service",
user[] = "xxxx-no-such-user";
- InstallInfo i = {name, path, user};
- InstallInfo i2 = {name, path, NULL};
+ UnitFileInstallInfo i = {name, path, user};
+ UnitFileInstallInfo i2 = {name, path, NULL};
char name3[] = "name at inst.service",
path3[] = "/run/systemd/system/name.service";
- InstallInfo i3 = {name3, path3, user};
- InstallInfo i4 = {name3, path3, NULL};
+ UnitFileInstallInfo i3 = {name3, path3, user};
+ UnitFileInstallInfo i4 = {name3, path3, NULL};
_cleanup_free_ char *mid, *bid, *host;
commit b2c23da8cea1987a1a329f5a964d3299b7ca7890
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 11 22:51:49 2015 +0200
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.
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c
index e7df55f..f4255f9 100644
--- a/src/analyze/analyze-verify.c
+++ b/src/analyze/analyze-verify.c
@@ -192,7 +192,7 @@ static int verify_unit(Unit *u, bool check_man) {
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;
Manager *m = NULL;
FILE *serial = NULL;
diff --git a/src/analyze/analyze-verify.h b/src/analyze/analyze-verify.h
index f10c34c..d2d4a7f 100644
--- a/src/analyze/analyze-verify.h
+++ b/src/analyze/analyze-verify.h
@@ -25,4 +25,4 @@
#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);
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 17fc5c8..9583458 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -1328,7 +1328,7 @@ int main(int argc, char *argv[]) {
if (streq_ptr(argv[optind], "verify"))
r = verify_units(argv+optind+1,
- arg_user ? SYSTEMD_USER : SYSTEMD_SYSTEM,
+ arg_user ? MANAGER_USER : MANAGER_SYSTEM,
arg_man);
else {
_cleanup_bus_close_unref_ sd_bus *bus = NULL;
diff --git a/src/core/automount.c b/src/core/automount.c
index b747c6f..13f80c2 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 != SYSTEMD_SYSTEM)
+ if (UNIT(a)->manager->running_as != MANAGER_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/busname.c b/src/core/busname.c
index 2010ec0..eb95c8e 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -147,7 +147,7 @@ static int busname_add_default_default_dependencies(BusName *n) {
if (r < 0)
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);
if (r < 0)
return r;
@@ -312,7 +312,7 @@ static int busname_open_fd(BusName *n) {
if (n->starter_fd >= 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);
if (n->starter_fd < 0)
return log_unit_warning_errno(UNIT(n), n->starter_fd, "Failed to open %s: %m", path ?: "kdbus");
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index e337c0f..6474e08 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -908,7 +908,7 @@ int manager_setup_cgroup(Manager *m) {
/* LEGACY: Already in /system.slice? If so, let's cut this
* off. This is to support live upgrades from older systemd
* versions where PID 1 was moved there. */
- if (m->running_as == SYSTEMD_SYSTEM) {
+ if (m->running_as == MANAGER_SYSTEM) {
char *e;
e = endswith(m->cgroup_root, "/" SPECIAL_SYSTEM_SLICE);
@@ -933,7 +933,7 @@ int manager_setup_cgroup(Manager *m) {
if (!m->test_run) {
/* 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);
if (r < 0)
log_warning_errno(r, "Failed to install release agent, ignoring: %m");
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 18a379f..d8b39bd 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1206,7 +1206,7 @@ static int method_exit(sd_bus_message *message, void *userdata, sd_bus_error *er
if (r < 0)
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.");
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)
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.");
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)
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.");
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)
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.");
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)
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.");
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)
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.");
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)
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)
goto fail;
@@ -1528,7 +1528,7 @@ static int method_get_unit_file_state(sd_bus_message *message, void *userdata, s
if (r < 0)
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);
if (state < 0)
@@ -1552,7 +1552,7 @@ static int method_get_default_target(sd_bus_message *message, void *userdata, sd
if (r < 0)
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);
if (r < 0)
@@ -1661,7 +1661,7 @@ static int method_enable_unit_files_generic(
if (r == 0)
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);
if (r < 0)
@@ -1734,7 +1734,7 @@ static int method_preset_unit_files_with_mode(sd_bus_message *message, void *use
if (r == 0)
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);
if (r < 0)
@@ -1771,7 +1771,7 @@ static int method_disable_unit_files_generic(
if (r < 0)
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);
if (r < 0)
@@ -1819,7 +1819,7 @@ static int method_set_default_target(sd_bus_message *message, void *userdata, sd
if (r == 0)
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);
if (r < 0)
@@ -1862,7 +1862,7 @@ static int method_preset_all_unit_files(sd_bus_message *message, void *userdata,
if (r == 0)
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);
if (r < 0)
@@ -1907,7 +1907,7 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd
if (r < 0)
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);
if (r < 0)
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 1679242..86886e6 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -85,7 +85,7 @@ static int signal_agent_released(sd_bus_message *message, void *userdata, sd_bus
manager_notify_cgroup_empty(m, cgroup);
/* 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;
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;
}
- if (m->running_as == SYSTEMD_SYSTEM) {
+ if (m->running_as == MANAGER_SYSTEM) {
/* When we run as system instance we get the Released
* signal via a direct connection */
@@ -813,10 +813,10 @@ static int bus_init_api(Manager *m) {
return 0;
/* 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);
else {
- if (m->running_as == SYSTEMD_SYSTEM)
+ if (m->running_as == MANAGER_SYSTEM)
r = sd_bus_open_system(&bus);
else
r = sd_bus_open_user(&bus);
@@ -856,7 +856,7 @@ static int bus_setup_system(Manager *m, sd_bus *bus) {
assert(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(
bus,
NULL,
@@ -881,7 +881,7 @@ static int bus_init_system(Manager *m) {
return 0;
/* 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);
return 0;
}
@@ -932,7 +932,7 @@ static int bus_init_private(Manager *m) {
if (m->kdbus_fd >= 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 */
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
* 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);
/* And destroy the object */
diff --git a/src/core/device.c b/src/core/device.c
index a0eb0f4..8eca4c2 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -264,7 +264,7 @@ static int device_add_udev_wants(Unit *u, struct udev_device *dev) {
assert(u);
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);
if (!wants)
return 0;
diff --git a/src/core/failure-action.c b/src/core/failure-action.c
index 7c6abb3..b06a7d2 100644
--- a/src/core/failure-action.c
+++ b/src/core/failure-action.c
@@ -50,7 +50,7 @@ int failure_action(
if (action == FAILURE_ACTION_NONE)
return -ECANCELED;
- if (m->running_as == SYSTEMD_USER) {
+ if (m->running_as == MANAGER_USER) {
/* Downgrade all options to simply exiting if we run
* in user mode */
diff --git a/src/core/job.c b/src/core/job.c
index 49fcac9..9ad1f73 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -1152,7 +1152,7 @@ void job_shutdown_magic(Job *j) {
if (j->type != JOB_START)
return;
- if (j->unit->manager->running_as != SYSTEMD_SYSTEM)
+ if (j->unit->manager->running_as != MANAGER_SYSTEM)
return;
if (!unit_has_name(j->unit, SPECIAL_SHUTDOWN_TARGET))
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 970120a..33d9e27 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2408,7 +2408,7 @@ int config_parse_syscall_filter(
/* Turn on NNP, but only if it wasn't configured explicitly
* 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;
return 0;
diff --git a/src/core/main.c b/src/core/main.c
index ac2f117..08e84d8 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -85,7 +85,7 @@ static enum {
ACTION_DONE
} arg_action = ACTION_RUN;
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_crash_shell = false;
static int arg_crash_chvt = -1;
@@ -676,8 +676,8 @@ static int parse_config_file(void) {
const char *fn, *conf_dirs_nulstr;
- fn = arg_running_as == SYSTEMD_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");
+ fn = arg_running_as == MANAGER_SYSTEM ? PKGSYSCONFDIR "/system.conf" : PKGSYSCONFDIR "/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_item_table_lookup, items, false, NULL);
@@ -814,11 +814,11 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_SYSTEM:
- arg_running_as = SYSTEMD_SYSTEM;
+ arg_running_as = MANAGER_SYSTEM;
break;
case ARG_USER:
- arg_running_as = SYSTEMD_USER;
+ arg_running_as = MANAGER_USER;
break;
case ARG_TEST:
@@ -1275,7 +1275,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 = SYSTEMD_SYSTEM;
+ arg_running_as = MANAGER_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 = SYSTEMD_SYSTEM;
+ arg_running_as = MANAGER_SYSTEM;
log_set_target(LOG_TARGET_CONSOLE);
log_close_console(); /* force reopen of /dev/console */
log_open();
@@ -1364,7 +1364,7 @@ int main(int argc, char *argv[]) {
} else {
/* Running as user instance */
- arg_running_as = SYSTEMD_USER;
+ arg_running_as = MANAGER_USER;
log_set_target(LOG_TARGET_AUTO);
log_open();
@@ -1413,7 +1413,7 @@ int main(int argc, char *argv[]) {
goto finish;
}
- if (arg_running_as == SYSTEMD_SYSTEM) {
+ if (arg_running_as == MANAGER_SYSTEM) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
@@ -1434,14 +1434,14 @@ int main(int argc, char *argv[]) {
goto finish;
}
- if (arg_running_as == SYSTEMD_USER &&
+ if (arg_running_as == MANAGER_USER &&
arg_action == ACTION_RUN &&
sd_booted() <= 0) {
log_error("Trying to run as user instance, but the system has not been booted with systemd.");
goto finish;
}
- if (arg_running_as == SYSTEMD_SYSTEM &&
+ if (arg_running_as == MANAGER_SYSTEM &&
arg_action == ACTION_RUN &&
running_in_chroot() > 0) {
log_error("Cannot be run in a chroot() environment.");
@@ -1468,7 +1468,7 @@ int main(int argc, char *argv[]) {
goto finish;
}
- if (arg_running_as == SYSTEMD_USER &&
+ if (arg_running_as == MANAGER_USER &&
!getenv("XDG_RUNTIME_DIR")) {
log_error("Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.");
goto finish;
@@ -1491,7 +1491,7 @@ int main(int argc, char *argv[]) {
if (arg_serialization)
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. */
setsid();
@@ -1500,7 +1500,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 == 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
* /dev/null and make sure we don't have a controlling
@@ -1527,7 +1527,7 @@ int main(int argc, char *argv[]) {
goto finish;
}
- if (arg_running_as == SYSTEMD_SYSTEM) {
+ if (arg_running_as == MANAGER_SYSTEM) {
const char *virtualization = NULL;
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);
}
- if (arg_running_as == SYSTEMD_SYSTEM && !skip_setup) {
+ if (arg_running_as == MANAGER_SYSTEM && !skip_setup) {
if (arg_show_status > 0)
status_welcome();
@@ -1575,7 +1575,7 @@ int main(int argc, char *argv[]) {
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);
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 */
if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) {
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);
if (empty_etc) {
@@ -1895,7 +1895,7 @@ finish:
args[i++] = SYSTEMD_BINARY_PATH;
if (switch_root_dir)
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++] = sfd;
args[i++] = NULL;
diff --git a/src/core/manager.c b/src/core/manager.c
index 285abe1..28b9427 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -474,7 +474,7 @@ static int manager_setup_signals(Manager *m) {
if (r < 0)
return r;
- if (m->running_as == SYSTEMD_SYSTEM)
+ if (m->running_as == MANAGER_SYSTEM)
return enable_special_signals(m);
return 0;
@@ -500,7 +500,7 @@ static void manager_clean_environment(Manager *m) {
static int manager_default_environment(Manager *m) {
assert(m);
- if (m->running_as == SYSTEMD_SYSTEM) {
+ if (m->running_as == MANAGER_SYSTEM) {
/* The system manager always starts with a clean
* environment for its children. It does not import
* 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] = {
- [SYSTEMD_SYSTEM] = "UNIT=",
- [SYSTEMD_USER] = "USER_UNIT=",
+ static const char * const unit_log_fields[_MANAGER_RUNNING_AS_MAX] = {
+ [MANAGER_SYSTEM] = "UNIT=",
+ [MANAGER_USER] = "USER_UNIT=",
};
- static const char * const unit_log_format_strings[_SYSTEMD_RUNNING_AS_MAX] = {
- [SYSTEMD_SYSTEM] = "UNIT=%s",
- [SYSTEMD_USER] = "USER_UNIT=%s",
+ static const char * const unit_log_format_strings[_MANAGER_RUNNING_AS_MAX] = {
+ [MANAGER_SYSTEM] = "UNIT=%s",
+ [MANAGER_USER] = "USER_UNIT=%s",
};
Manager *m;
@@ -546,14 +546,14 @@ int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
assert(_m);
assert(running_as >= 0);
- assert(running_as < _SYSTEMD_RUNNING_AS_MAX);
+ assert(running_as < _MANAGER_RUNNING_AS_MAX);
m = new0(Manager, 1);
if (!m)
return -ENOMEM;
#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);
#endif
@@ -678,7 +678,7 @@ static int manager_setup_notify(Manager *m) {
if (fd < 0)
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");
else {
const char *e;
@@ -740,12 +740,12 @@ static int manager_setup_kdbus(Manager *m) {
if (!is_kdbus_available())
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();
m->kdbus_fd = bus_kernel_create_bus(
- m->running_as == SYSTEMD_SYSTEM ? "system" : "user",
- m->running_as == SYSTEMD_SYSTEM, &p);
+ m->running_as == MANAGER_SYSTEM ? "system" : "user",
+ m->running_as == MANAGER_SYSTEM, &p);
if (m->kdbus_fd < 0)
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 =
m->kdbus_fd >= 0 ||
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. */
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 ||
- (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
+ (sfsi.ssi_signo == SIGTERM && m->running_as == MANAGER_USER)
? LOG_DEBUG : LOG_INFO,
&sfsi);
@@ -1739,7 +1739,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
break;
case SIGTERM:
- if (m->running_as == SYSTEMD_SYSTEM) {
+ if (m->running_as == MANAGER_SYSTEM) {
/* This is for compatibility with the
* original sysvinit */
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 */
case SIGINT:
- if (m->running_as == SYSTEMD_SYSTEM) {
+ if (m->running_as == MANAGER_SYSTEM) {
/* If the user presses C-A-D more than
* 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;
case SIGWINCH:
- if (m->running_as == SYSTEMD_SYSTEM)
+ 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 == SYSTEMD_SYSTEM)
+ if (m->running_as == MANAGER_SYSTEM)
manager_start_target(m, SPECIAL_SIGPWR_TARGET, JOB_REPLACE);
/* 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;
case 24:
- if (m->running_as == SYSTEMD_USER) {
+ if (m->running_as == MANAGER_USER) {
m->exit_code = MANAGER_EXIT;
return 0;
}
@@ -2014,7 +2014,7 @@ int manager_loop(Manager *m) {
while (m->exit_code == MANAGER_OK) {
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();
if (!ratelimit_test(&rl)) {
@@ -2040,7 +2040,7 @@ int manager_loop(Manager *m) {
continue;
/* 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;
if (wait_usec <= 0)
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)
return;
- if (m->running_as != SYSTEMD_SYSTEM)
+ if (m->running_as != MANAGER_SYSTEM)
return;
if (u->type != UNIT_SERVICE)
@@ -2157,7 +2157,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
if (m->n_reloading > 0)
return;
- if (m->running_as != SYSTEMD_SYSTEM)
+ if (m->running_as != MANAGER_SYSTEM)
return;
if (detect_container(NULL) > 0)
@@ -2219,7 +2219,7 @@ int manager_open_serialization(Manager *m, FILE **_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);
if (fd < 0)
return -errno;
@@ -2635,7 +2635,7 @@ static void manager_notify_finished(Manager *m) {
if (m->test_run)
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,
* and m->firmware_usec.monotonic and
@@ -2751,7 +2751,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
if (*generator)
return 0;
- if (m->running_as == SYSTEMD_SYSTEM && getpid() == 1) {
+ if (m->running_as == MANAGER_SYSTEM && getpid() == 1) {
/* systemd --system, not running --test */
p = strappend("/run/systemd/", name);
@@ -2764,7 +2764,7 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
free(p);
return r;
}
- } else if (m->running_as == SYSTEMD_USER) {
+ } else if (m->running_as == MANAGER_USER) {
const char *s = NULL;
s = getenv("XDG_RUNTIME_DIR");
@@ -2951,7 +2951,7 @@ void manager_recheck_journal(Manager *m) {
assert(m);
- if (m->running_as != SYSTEMD_SYSTEM)
+ if (m->running_as != MANAGER_SYSTEM)
return;
u = manager_get_unit(m, SPECIAL_JOURNALD_SOCKET);
@@ -2975,7 +2975,7 @@ void manager_set_show_status(Manager *m, ShowStatus mode) {
assert(m);
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;
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) {
assert(m);
- if (m->running_as != SYSTEMD_SYSTEM)
+ if (m->running_as != MANAGER_SYSTEM)
return false;
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) {
assert(m);
- if (m->running_as != SYSTEMD_SYSTEM)
+ if (m->running_as != MANAGER_SYSTEM)
return;
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) {
assert(m);
- return m->running_as == SYSTEMD_SYSTEM ?
+ return m->running_as == MANAGER_SYSTEM ?
"/run" :
getenv("XDG_RUNTIME_DIR");
}
diff --git a/src/core/manager.h b/src/core/manager.h
index 524cdf9..4ef869d 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -226,7 +226,7 @@ struct Manager {
int pin_cgroupfs_fd;
/* Flags */
- SystemdRunningAs running_as;
+ ManagerRunningAs running_as;
ManagerExitCode exit_code:5;
bool dispatching_load_queue:1;
@@ -297,7 +297,7 @@ struct Manager {
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);
int manager_enumerate(Manager *m);
diff --git a/src/core/mount.c b/src/core/mount.c
index 6501be9..e143f6b 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -320,7 +320,7 @@ static int mount_add_device_links(Mount *m) {
if (path_equal(m->where, "/"))
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;
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);
- if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
+ if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
return 0;
p = get_mount_parameters_fragment(m);
@@ -379,7 +379,7 @@ static int mount_add_default_dependencies(Mount *m) {
assert(m);
- if (UNIT(m)->manager->running_as != SYSTEMD_SYSTEM)
+ if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
return 0;
/* 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;
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);
if (r < 0)
goto fail;
@@ -880,7 +880,7 @@ static void mount_enter_mounting(Mount *m) {
r = exec_command_set(m->control_command, "/bin/mount",
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);
if (r >= 0 && m->sloppy_options)
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",
m->parameters_fragment.what, m->where,
"-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);
if (r >= 0 && m->sloppy_options)
r = exec_command_append(m->control_command, "-s", NULL);
@@ -1376,7 +1376,7 @@ static int mount_setup_unit(
goto fail;
}
- if (m->running_as == SYSTEMD_SYSTEM) {
+ if (m->running_as == MANAGER_SYSTEM) {
const char* 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)) {
/* _netdev option may have shown up late, or on a
* remount. Add remote-fs dependencies, even though
diff --git a/src/core/path.c b/src/core/path.c
index fc27e33..6d26d89 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -314,7 +314,7 @@ static int path_add_default_dependencies(Path *p) {
if (r < 0)
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,
SPECIAL_SYSINIT_TARGET, NULL, true);
if (r < 0)
diff --git a/src/core/service.c b/src/core/service.c
index d11bcb1..0842ef1 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1121,7 +1121,7 @@ static int service_spawn(
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) {
r = -ENOMEM;
goto fail;
@@ -1181,7 +1181,7 @@ static int service_spawn(
#ifdef ENABLE_KDBUS
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);
if (r < 0)
goto fail;
diff --git a/src/core/socket.c b/src/core/socket.c
index 3368207..a655ec9 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -284,7 +284,7 @@ static int socket_add_default_dependencies(Socket *s) {
if (r < 0)
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);
if (r < 0)
return r;
diff --git a/src/core/swap.c b/src/core/swap.c
index 1cf3f2a..12ebf84 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -201,7 +201,7 @@ static int swap_add_device_links(Swap *s) {
return 0;
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
/* File based swap devices need to be ordered after
* 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) {
assert(s);
- if (UNIT(s)->manager->running_as != SYSTEMD_SYSTEM)
+ if (UNIT(s)->manager->running_as != MANAGER_SYSTEM)
return 0;
if (detect_container(NULL) > 0)
diff --git a/src/core/timer.c b/src/core/timer.c
index eb73b64..d427956 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -102,7 +102,7 @@ static int timer_add_default_dependencies(Timer *t) {
if (r < 0)
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);
if (r < 0)
return r;
@@ -128,7 +128,7 @@ static int timer_setup_persistent(Timer *t) {
if (!t->persistent)
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");
if (r < 0)
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
index 8050e2f..0889769 100644
--- a/src/core/unit-printf.c
+++ b/src/core/unit-printf.c
@@ -140,7 +140,7 @@ static int specifier_runtime(char specifier, void *data, void *userdata, char **
assert(u);
- if (u->manager->running_as == SYSTEMD_SYSTEM)
+ if (u->manager->running_as == MANAGER_SYSTEM)
e = "/run";
else {
e = getenv("XDG_RUNTIME_DIR");
@@ -168,7 +168,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
if (!c)
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
* 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)
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
* 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)
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
* best of it if we can, but fail if we can't */
diff --git a/src/core/unit.c b/src/core/unit.c
index 0a1278c..1c1d9cf 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -804,7 +804,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
return r;
}
- if (u->manager->running_as != SYSTEMD_SYSTEM)
+ if (u->manager->running_as != MANAGER_SYSTEM)
return 0;
if (c->private_tmp) {
@@ -2456,7 +2456,7 @@ int unit_add_default_slice(Unit *u, CGroupContext *c) {
if (!escaped)
return -ENOMEM;
- if (u->manager->running_as == SYSTEMD_SYSTEM)
+ if (u->manager->running_as == MANAGER_SYSTEM)
b = strjoin("system-", escaped, ".slice", NULL);
else
b = strappend(escaped, ".slice");
@@ -2466,7 +2466,7 @@ int unit_add_default_slice(Unit *u, CGroupContext *c) {
slice_name = b;
} else
slice_name =
- u->manager->running_as == SYSTEMD_SYSTEM
+ u->manager->running_as == MANAGER_SYSTEM
? SPECIAL_SYSTEM_SLICE
: SPECIAL_ROOT_SLICE;
@@ -2836,7 +2836,7 @@ int unit_add_node_link(Unit *u, const char *what, bool wants) {
if (r < 0)
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)
return r;
@@ -3111,7 +3111,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 == 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));
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)
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));
return u->unit_file_preset;
@@ -3172,7 +3172,7 @@ int unit_patch_contexts(Unit *u) {
return -ENOMEM;
}
- if (u->manager->running_as == SYSTEMD_USER &&
+ if (u->manager->running_as == MANAGER_USER &&
!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;
}
- if (u->manager->running_as == SYSTEMD_USER &&
+ if (u->manager->running_as == MANAGER_USER &&
(ec->syscall_whitelist ||
!set_isempty(ec->syscall_filter) ||
!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) {
- if (u->manager->running_as == SYSTEMD_USER) {
+ if (u->manager->running_as == MANAGER_USER) {
int r;
if (mode == UNIT_PERSISTENT && !transient)
@@ -3432,7 +3432,7 @@ int unit_make_transient(Unit *u) {
free(u->fragment_path);
u->fragment_path = NULL;
- if (u->manager->running_as == SYSTEMD_USER) {
+ if (u->manager->running_as == MANAGER_USER) {
_cleanup_free_ char *c = NULL;
r = user_runtime_dir(&c);
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c
index fb2c2c2..f6a1271 100644
--- a/src/shared/path-lookup.c
+++ b/src/shared/path-lookup.c
@@ -218,8 +218,8 @@ static char** user_dirs(
return tmp;
}
-char **generator_paths(SystemdRunningAs running_as) {
- if (running_as == SYSTEMD_USER)
+char **generator_paths(ManagerRunningAs running_as) {
+ if (running_as == MANAGER_USER)
return strv_new("/run/systemd/user-generators",
"/etc/systemd/user-generators",
"/usr/local/lib/systemd/user-generators",
@@ -235,7 +235,7 @@ char **generator_paths(SystemdRunningAs running_as) {
int lookup_paths_init(
LookupPaths *p,
- SystemdRunningAs running_as,
+ ManagerRunningAs running_as,
bool personal,
const char *root_dir,
const char *generator,
@@ -277,7 +277,7 @@ int lookup_paths_init(
* we include /lib in the search path for the system
* stuff but avoid it for user stuff. */
- if (running_as == SYSTEMD_USER) {
+ if (running_as == MANAGER_USER) {
if (personal)
unit_path = user_dirs(generator, generator_early, generator_late);
else
@@ -337,7 +337,7 @@ int lookup_paths_init(
p->unit_path = NULL;
}
- if (running_as == SYSTEMD_SYSTEM) {
+ if (running_as == MANAGER_SYSTEM) {
#ifdef HAVE_SYSV_COMPAT
/* /etc/init.d/ compatibility does not matter to users */
@@ -437,7 +437,7 @@ int lookup_paths_init_from_scope(LookupPaths *paths,
zero(*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,
root_dir,
NULL, NULL, NULL);
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index f1925ee..31b2df3 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -33,20 +33,20 @@ typedef struct LookupPaths {
#endif
} LookupPaths;
-typedef enum SystemdRunningAs {
- SYSTEMD_SYSTEM,
- SYSTEMD_USER,
- _SYSTEMD_RUNNING_AS_MAX,
- _SYSTEMD_RUNNING_AS_INVALID = -1
-} SystemdRunningAs;
+typedef enum ManagerRunningAs {
+ MANAGER_SYSTEM,
+ MANAGER_USER,
+ _MANAGER_RUNNING_AS_MAX,
+ _MANAGER_RUNNING_AS_INVALID = -1
+} ManagerRunningAs;
int user_config_home(char **config_home);
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,
- SystemdRunningAs running_as,
+ ManagerRunningAs running_as,
bool personal,
const char *root_dir,
const char *generator,
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index e4b301a..d48160e 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -5111,7 +5111,7 @@ static int enable_sysv_units(const char *verb, char **args) {
/* Processes all SysV units, and reshuffles the array so that
* 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)
return r;
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index aecae80..9ae518a 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -931,7 +931,7 @@ int main(int argc, char *argv[]) {
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) {
log_error("Failed to find lookup paths.");
return EXIT_FAILURE;
diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c
index d14a07e..289dddb 100644
--- a/src/test/test-cgroup-mask.c
+++ b/src/test/test-cgroup-mask.c
@@ -35,7 +35,7 @@ static int test_cgroup_mask(void) {
/* Prepare the manager. */
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) {
puts("manager_new: Permission denied. Skipping test.");
return EXIT_TEST_SKIP;
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index d543d23..a7ab21a 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
/* prepare the test */
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)) {
printf("Skipping test: manager_new: %s", strerror(-r));
return EXIT_TEST_SKIP;
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index a84a925..0f4172e 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -167,7 +167,7 @@ int main(int argc, char *argv[]) {
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)) {
printf("Skipping test: manager_new: %s", strerror(-r));
return EXIT_TEST_SKIP;
diff --git a/src/test/test-path-lookup.c b/src/test/test-path-lookup.c
index 66b0b99..aa4bac6 100644
--- a/src/test/test-path-lookup.c
+++ b/src/test/test-path-lookup.c
@@ -26,7 +26,7 @@
#include "strv.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";
_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);
}
-static void print_generator_paths(SystemdRunningAs running_as) {
+static void print_generator_paths(ManagerRunningAs running_as) {
_cleanup_strv_free_ char **paths;
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);
STRV_FOREACH(dir, paths)
@@ -62,13 +62,13 @@ int main(int argc, char **argv) {
log_parse_environment();
log_open();
- test_paths(SYSTEMD_SYSTEM, false);
- test_paths(SYSTEMD_SYSTEM, true);
- test_paths(SYSTEMD_USER, false);
- test_paths(SYSTEMD_USER, true);
+ test_paths(MANAGER_SYSTEM, false);
+ test_paths(MANAGER_SYSTEM, true);
+ test_paths(MANAGER_USER, false);
+ test_paths(MANAGER_USER, true);
- print_generator_paths(SYSTEMD_SYSTEM);
- print_generator_paths(SYSTEMD_USER);
+ print_generator_paths(MANAGER_SYSTEM);
+ print_generator_paths(MANAGER_USER);
return EXIT_SUCCESS;
}
diff --git a/src/test/test-path.c b/src/test/test-path.c
index 0504ae7..5d19037 100644
--- a/src/test/test-path.c
+++ b/src/test/test-path.c
@@ -39,7 +39,7 @@ static int setup_test(Manager **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)) {
printf("Skipping test: manager_new: %s", strerror(-r));
return -EXIT_TEST_SKIP;
diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c
index 6b3128d..f915539 100644
--- a/src/test/test-sched-prio.c
+++ b/src/test/test-sched-prio.c
@@ -34,7 +34,7 @@ int main(int argc, char *argv[]) {
/* prepare the test */
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)) {
printf("Skipping test: manager_new: %s", strerror(-r));
return EXIT_TEST_SKIP;
diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c
index de8f7dd..5053d69 100644
--- a/src/test/test-unit-name.c
+++ b/src/test/test-unit-name.c
@@ -200,7 +200,7 @@ static int test_unit_printf(void) {
assert_se((root = getpwnam("root")));
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) {
puts("manager_new: Permission denied. Skipping test.");
return EXIT_TEST_SKIP;
commit 8b4305c7354f572fa0390b7580ba30af741aa0a5
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon May 11 22:28:52 2015 +0200
unit: move unit_warn_if_dir_nonempty() and friend to unit.c
The call is only used by the mount and automount unit types, but that's
already enough to consider it generic unit functionality, hence move it
out of mount.c and into unit.c.
diff --git a/src/core/mount.c b/src/core/mount.c
index 155cd2d..6501be9 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -812,52 +812,6 @@ fail:
mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
}
-void unit_warn_if_dir_nonempty(Unit *u, const char* where) {
- int r;
-
- assert(u);
- assert(where);
-
- r = dir_is_empty(where);
- if (r > 0)
- return;
- if (r < 0) {
- log_unit_warning_errno(u, r, "Failed to check directory %s: %m", where);
- return;
- }
-
- log_struct(LOG_NOTICE,
- LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
- LOG_UNIT_ID(u),
- LOG_UNIT_MESSAGE(u, "Directory %s to mount over is not empty, mounting anyway.", where),
- "WHERE=%s", where,
- NULL);
-}
-
-int unit_fail_if_symlink(Unit *u, const char* where) {
- int r;
-
- assert(u);
- assert(where);
-
- r = is_symlink(where);
- if (r < 0) {
- log_unit_debug_errno(u, r, "Failed to check symlink %s, ignoring: %m", where);
- return 0;
- }
- if (r == 0)
- return 0;
-
- log_struct(LOG_ERR,
- LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
- LOG_UNIT_ID(u),
- LOG_UNIT_MESSAGE(u, "Mount on symlink %s not allowed.", where),
- "WHERE=%s", where,
- NULL);
-
- return -ELOOP;
-}
-
static void mount_enter_unmounting(Mount *m) {
int r;
diff --git a/src/core/mount.h b/src/core/mount.h
index 79cdc8d..a01e6da 100644
--- a/src/core/mount.h
+++ b/src/core/mount.h
@@ -128,6 +128,3 @@ MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
const char* mount_result_to_string(MountResult i) _const_;
MountResult mount_result_from_string(const char *s) _pure_;
-
-void unit_warn_if_dir_nonempty(Unit *u, const char* where);
-int unit_fail_if_symlink(Unit *u, const char* where);
diff --git a/src/core/unit.c b/src/core/unit.c
index 25d0859..0a1278c 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -3672,6 +3672,52 @@ bool unit_type_supported(UnitType t) {
return unit_vtable[t]->supported();
}
+void unit_warn_if_dir_nonempty(Unit *u, const char* where) {
+ int r;
+
+ assert(u);
+ assert(where);
+
+ r = dir_is_empty(where);
+ if (r > 0)
+ return;
+ if (r < 0) {
+ log_unit_warning_errno(u, r, "Failed to check directory %s: %m", where);
+ return;
+ }
+
+ log_struct(LOG_NOTICE,
+ LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
+ LOG_UNIT_ID(u),
+ LOG_UNIT_MESSAGE(u, "Directory %s to mount over is not empty, mounting anyway.", where),
+ "WHERE=%s", where,
+ NULL);
+}
+
+int unit_fail_if_symlink(Unit *u, const char* where) {
+ int r;
+
+ assert(u);
+ assert(where);
+
+ r = is_symlink(where);
+ if (r < 0) {
+ log_unit_debug_errno(u, r, "Failed to check symlink %s, ignoring: %m", where);
+ return 0;
+ }
+ if (r == 0)
+ return 0;
+
+ log_struct(LOG_ERR,
+ LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
+ LOG_UNIT_ID(u),
+ LOG_UNIT_MESSAGE(u, "Mount on symlink %s not allowed.", where),
+ "WHERE=%s", where,
+ NULL);
+
+ return -ELOOP;
+}
+
static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = {
[UNIT_ACTIVE] = "active",
[UNIT_RELOADING] = "reloading",
diff --git a/src/core/unit.h b/src/core/unit.h
index 094510b..62257c4 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -607,6 +607,9 @@ static inline bool unit_supported(Unit *u) {
return unit_type_supported(u->type);
}
+void unit_warn_if_dir_nonempty(Unit *u, const char* where);
+int unit_fail_if_symlink(Unit *u, const char* where);
+
const char *unit_active_state_to_string(UnitActiveState i) _const_;
UnitActiveState unit_active_state_from_string(const char *s) _pure_;
More information about the systemd-commits
mailing list