check(m, unit, status_expected, code_expected);
}
+static void test_exec_bind_paths(Manager *m) {
+ assert_se(mkdir_p("/tmp/test-exec_bind_paths", 0755) >= 0);
+ assert_se(mkdir_p("/tmp/test-exec_bind_readonly_paths", 0755) >= 0);
+
+ test(m, "exec-bind-paths.service", 0, CLD_EXITED);
+
+ (void) rm_rf("/tmp/test-exec_bind_paths", REMOVE_ROOT|REMOVE_PHYSICAL);
+ (void) rm_rf("/tmp/test-exec_bind_readonly_paths", REMOVE_ROOT|REMOVE_PHYSICAL);
+}
+
static void test_exec_workingdirectory(Manager *m) {
assert_se(mkdir_p("/tmp/test-exec_workingdirectory", 0755) >= 0);
int main(int argc, char *argv[]) {
static const test_function_t user_tests[] = {
+ test_exec_bind_paths,
test_exec_workingdirectory,
test_exec_personality,
test_exec_ignoresigpipe,
test-path/path-makedirectory.path
test-path/path-modified.path
test-path/path-unit.path
+ test-execute/exec-bind-paths.service
test-execute/exec-environment-empty.service
test-execute/exec-environment-multiple.service
test-execute/exec-environment.service
--- /dev/null
+[Service]
+Type=oneshot
+# Create a file in /tmp/test-exec_bind_paths
+ExecStart=/bin/sh -c 'touch /tmp/test-exec_bind_paths/thisisasimpletest'
+# Then, the file can be access through /tmp
+ExecStart=/bin/sh -c 'test -f /tmp/thisisasimpletest'
+# Also, through /tmp/test-exec_bind_readonly_paths
+ExecStart=/bin/sh -c 'test -f /tmp/test-exec_bind_readonly_paths/thisisasimpletest'
+# The file cannot modify through /tmp/test-exec_bind_readonly_paths
+ExecStart=/bin/sh -x -c '! touch /tmp/test-exec_bind_readonly_paths/thisisasimpletest'
+# Cleanup
+ExecStart=/bin/sh -c 'rm /tmp/thisisasimpletest'
+BindPaths=/tmp:/tmp/test-exec_bind_paths
+BindReadOnlyPaths=/tmp:/tmp/test-exec_bind_readonly_paths