summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-08-17 13:20:09 +0200
committerMike Yuan <me@yhndnzj.com>2024-08-17 18:52:42 +0200
commit6c8ade30661f7d2d1b286c58050c4f9b1ed7b3e9 (patch)
tree48147942bd44670e5325990d4e2d39a057cdcd28
parentnetwork: refuse files under API VFS specified in PrivateKeyFile= and friends (diff)
downloadsystemd-6c8ade30661f7d2d1b286c58050c4f9b1ed7b3e9.tar.xz
systemd-6c8ade30661f7d2d1b286c58050c4f9b1ed7b3e9.zip
core/unit: rename set_unit_path() -> setenv_unit_path()
The previous name is quite vague on what this precisely do.
-rw-r--r--src/analyze/analyze-verify-util.c2
-rw-r--r--src/core/unit.c6
-rw-r--r--src/core/unit.h2
-rw-r--r--src/test/test-bpf-firewall.c2
-rw-r--r--src/test/test-bpf-foreign-programs.c2
-rw-r--r--src/test/test-bpf-restrict-fs.c2
-rw-r--r--src/test/test-cgroup-mask.c2
-rw-r--r--src/test/test-cgroup-unit-default.c2
-rw-r--r--src/test/test-engine.c4
-rw-r--r--src/test/test-execute.c2
-rw-r--r--src/test/test-path.c4
-rw-r--r--src/test/test-sched-prio.c4
-rw-r--r--src/test/test-socket-bind.c4
-rw-r--r--src/test/test-watch-pid.c4
14 files changed, 22 insertions, 20 deletions
diff --git a/src/analyze/analyze-verify-util.c b/src/analyze/analyze-verify-util.c
index 8e83c9a589..1fd3c79628 100644
--- a/src/analyze/analyze-verify-util.c
+++ b/src/analyze/analyze-verify-util.c
@@ -155,7 +155,7 @@ int verify_set_unit_path(char **filenames) {
!strextend_with_separator(&joined, ":", strempty(old)))
return -ENOMEM;
- assert_se(set_unit_path(joined) >= 0);
+ assert_se(setenv_unit_path(joined) >= 0);
return 0;
}
diff --git a/src/core/unit.c b/src/core/unit.c
index 6bd68c7d46..e0f9f9b84a 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -3317,9 +3317,11 @@ int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency
return unit_add_two_dependencies(u, d, e, other, add_reference, mask);
}
-int set_unit_path(const char *p) {
+int setenv_unit_path(const char *p) {
+ assert(p);
+
/* This is mostly for debug purposes */
- return RET_NERRNO(setenv("SYSTEMD_UNIT_PATH", p, 1));
+ return RET_NERRNO(setenv("SYSTEMD_UNIT_PATH", p, /* overwrite = */ true));
}
char* unit_dbus_path(Unit *u) {
diff --git a/src/core/unit.h b/src/core/unit.h
index 7f11539986..bb360e30ed 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -880,7 +880,7 @@ void unit_unwatch_bus_name(Unit *u, const char *name);
bool unit_job_is_applicable(Unit *u, JobType j);
-int set_unit_path(const char *p);
+int setenv_unit_path(const char *p);
char* unit_dbus_path(Unit *u);
char* unit_dbus_path_invocation_id(Unit *u);
diff --git a/src/test/test-bpf-firewall.c b/src/test/test-bpf-firewall.c
index cc677740d8..10bfa52e26 100644
--- a/src/test/test-bpf-firewall.c
+++ b/src/test/test-bpf-firewall.c
@@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = bpf_program_new(BPF_PROG_TYPE_CGROUP_SKB, "sd_trivial", &p);
diff --git a/src/test/test-bpf-foreign-programs.c b/src/test/test-bpf-foreign-programs.c
index 34ccb74ccb..658746afa0 100644
--- a/src/test/test-bpf-foreign-programs.c
+++ b/src/test/test-bpf-foreign-programs.c
@@ -298,7 +298,7 @@ int main(int argc, char *argv[]) {
return log_tests_skipped("cgroupfs not available");
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
ASSERT_OK(manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m));
diff --git a/src/test/test-bpf-restrict-fs.c b/src/test/test-bpf-restrict-fs.c
index 7ece33750b..11e97bf922 100644
--- a/src/test/test-bpf-restrict-fs.c
+++ b/src/test/test-bpf-restrict-fs.c
@@ -83,7 +83,7 @@ int main(int argc, char *argv[]) {
return log_tests_skipped("cgroupfs not available");
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
ASSERT_OK(manager_new(RUNTIME_SCOPE_SYSTEM, MANAGER_TEST_RUN_BASIC, &m));
diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c
index 857102f8a0..1050c4f47d 100644
--- a/src/test/test-cgroup-mask.c
+++ b/src/test/test-cgroup-mask.c
@@ -40,7 +40,7 @@ TEST_RET(cgroup_mask, .sd_booted = true) {
/* Prepare the manager. */
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);
if (IN_SET(r, -EPERM, -EACCES)) {
diff --git a/src/test/test-cgroup-unit-default.c b/src/test/test-cgroup-unit-default.c
index 97101d40a5..818d75eeac 100644
--- a/src/test/test-cgroup-unit-default.c
+++ b/src/test/test-cgroup-unit-default.c
@@ -24,7 +24,7 @@ TEST_RET(default_memory_low, .sd_booted = true) {
_cleanup_free_ char *unit_dir = NULL;
ASSERT_OK(get_testdata_dir("units", &unit_dir));
- ASSERT_OK(set_unit_path(unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);
if (IN_SET(r, -EPERM, -EACCES)) {
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index fa64fbefab..0169f8320f 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -89,8 +89,8 @@ int main(int argc, char *argv[]) {
/* prepare the test */
_cleanup_free_ char *unit_dir = NULL;
- assert_se(get_testdata_dir("units", &unit_dir) >= 0);
- assert_se(set_unit_path(unit_dir) >= 0);
+ ASSERT_OK(get_testdata_dir("units", &unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index 56f5e340be..b068c3aee0 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -1397,7 +1397,7 @@ static void run_tests(RuntimeScope scope, char **patterns) {
ASSERT_NOT_NULL(runtime_dir = setup_fake_runtime_dir());
ASSERT_NOT_NULL(user_runtime_unit_dir = path_join(runtime_dir, "systemd/user"));
ASSERT_NOT_NULL(unit_paths = strjoin(PRIVATE_UNIT_DIR, ":", user_runtime_unit_dir));
- ASSERT_OK(set_unit_path(unit_paths));
+ ASSERT_OK(setenv_unit_path(unit_paths));
r = manager_new(scope, MANAGER_TEST_RUN_BASIC, &m);
if (manager_errno_skip_test(r))
diff --git a/src/test/test-path.c b/src/test/test-path.c
index e49653a240..fd3120f922 100644
--- a/src/test/test-path.c
+++ b/src/test/test-path.c
@@ -397,8 +397,8 @@ int main(int argc, char *argv[]) {
test_setup_logging(LOG_INFO);
- assert_se(get_testdata_dir("test-path", &test_path) >= 0);
- assert_se(set_unit_path(test_path) >= 0);
+ ASSERT_OK(get_testdata_dir("test-path", &test_path));
+ ASSERT_OK(setenv_unit_path(test_path));
assert_se(runtime_dir = setup_fake_runtime_dir());
for (const test_function_t *test = tests; *test; test++) {
diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c
index 3c3b8dcf4a..ff90842a0a 100644
--- a/src/test/test-sched-prio.c
+++ b/src/test/test-sched-prio.c
@@ -26,8 +26,8 @@ int main(int argc, char *argv[]) {
/* prepare the test */
_cleanup_free_ char *unit_dir = NULL;
- assert_se(get_testdata_dir("units", &unit_dir) >= 0);
- assert_se(set_unit_path(unit_dir) >= 0);
+ ASSERT_OK(get_testdata_dir("units", &unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m);
diff --git a/src/test/test-socket-bind.c b/src/test/test-socket-bind.c
index 13ffa92cf1..63552013b2 100644
--- a/src/test/test-socket-bind.c
+++ b/src/test/test-socket-bind.c
@@ -126,8 +126,8 @@ int main(int argc, char *argv[]) {
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
- assert_se(get_testdata_dir("units", &unit_dir) >= 0);
- assert_se(set_unit_path(unit_dir) >= 0);
+ ASSERT_OK(get_testdata_dir("units", &unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());
assert_se(manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m) >= 0);
diff --git a/src/test/test-watch-pid.c b/src/test/test-watch-pid.c
index 423a9be380..22cb404cf8 100644
--- a/src/test/test-watch-pid.c
+++ b/src/test/test-watch-pid.c
@@ -22,8 +22,8 @@ int main(int argc, char *argv[]) {
return log_tests_skipped("cgroupfs not available");
_cleanup_free_ char *unit_dir = NULL;
- assert_se(get_testdata_dir("units/", &unit_dir) >= 0);
- assert_se(set_unit_path(unit_dir) >= 0);
+ ASSERT_OK(get_testdata_dir("units/", &unit_dir));
+ ASSERT_OK(setenv_unit_path(unit_dir));
assert_se(runtime_dir = setup_fake_runtime_dir());