summaryrefslogtreecommitdiffstats
path: root/src/test/test-execute.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-04 18:02:57 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-04 18:45:44 +0200
commitcced2b98efcf60f9dce573451ff637bb8227d90b (patch)
treef08479a0819ebd6a8f815bc130b06fba1c00680f /src/test/test-execute.c
parentcore/manager: reindent table for readability (diff)
downloadsystemd-cced2b98efcf60f9dce573451ff637bb8227d90b.tar.xz
systemd-cced2b98efcf60f9dce573451ff637bb8227d90b.zip
test-execute: check if private directories have bad permissions before running test_exec_dynamicuser()
If the directory (/var/lib/private is most likely) has borked permissions, the test will fail with a cryptic message and EXIT_STATE_DIRECTORY or similar. The message from the child with more details gets lost somewhere. Let's avoid running the test in that case and provide a simple error message instead. E.g. systemd-238-12.git07f8cd5.fc28.ppc64 (which I encountered on a test machine) has /var/lib/private with 0755.
Diffstat (limited to 'src/test/test-execute.c')
-rw-r--r--src/test/test-execute.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index b759786eaf..e32e0c0b6c 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -543,7 +543,29 @@ static void test_exec_supplementarygroups(Manager *m) {
test(__func__, m, "exec-supplementarygroups-multiple-groups-withuid.service", 0, CLD_EXITED);
}
+static char* private_directory_bad(Manager *m) {
+ /* This mirrors setup_exec_directory(). */
+
+ for (ExecDirectoryType dt = 0; dt < _EXEC_DIRECTORY_TYPE_MAX; dt++) {
+ _cleanup_free_ char *p = NULL;
+ struct stat st;
+
+ assert_se(p = path_join(m->prefix[dt], "private"));
+
+ if (stat(p, &st) >= 0 &&
+ (st.st_mode & (S_IRWXG|S_IRWXO)))
+ return TAKE_PTR(p);
+ }
+
+ return NULL;
+}
+
static void test_exec_dynamicuser(Manager *m) {
+ _cleanup_free_ char *bad = private_directory_bad(m);
+ if (bad) {
+ log_warning("%s: %s has bad permissions, skipping test.", __func__, bad);
+ return;
+ }
test(__func__, m, "exec-dynamicuser-fixeduser.service", can_unshare ? 0 : EXIT_NAMESPACE, CLD_EXITED);
if (check_user_has_group_with_same_name("adm"))