summaryrefslogtreecommitdiff
path: root/src/test/test-copy.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-04-29 14:21:22 +0200
committerLennart Poettering <lennart@poettering.net>2016-04-29 14:28:03 +0200
commit0e2b2caccde55ba777b84d667d19541a82c3f3a3 (patch)
tree52cf8a49ea5ebb4cf474540809ad0f045d4a18cc /src/test/test-copy.c
parent14e2baa369b120788322e727ecdd249127a13fa1 (diff)
copy: also copy AF_UNIX sockets
We previously would fail with EOPNOTSUPP when encountering an AF_UNIX socket in the directory tree to copy. Fix that, and copy them too (even if they are dead in the result). Fixes: #2914
Diffstat (limited to 'src/test/test-copy.c')
-rw-r--r--src/test/test-copy.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
index cb437754b4..d1bf376385 100644
--- a/src/test/test-copy.c
+++ b/src/test/test-copy.c
@@ -95,6 +95,8 @@ static void test_copy_tree(void) {
char **links = STRV_MAKE("link", "file",
"link2", "dir1/file");
char **p, **link;
+ const char *unixsockp;
+ struct stat st;
log_info("%s", __func__);
@@ -116,6 +118,9 @@ static void test_copy_tree(void) {
assert_se(symlink(f, l) == 0);
}
+ unixsockp = strjoina(original_dir, "unixsock");
+ assert_se(mknod(unixsockp, S_IFSOCK|0644, 0) >= 0);
+
assert_se(copy_tree(original_dir, copy_dir, true) == 0);
STRV_FOREACH(p, files) {
@@ -137,6 +142,10 @@ static void test_copy_tree(void) {
assert_se(path_equal(f, target));
}
+ unixsockp = strjoina(copy_dir, "unixsock");
+ assert_se(stat(unixsockp, &st) >= 0);
+ assert_se(S_ISSOCK(st.st_mode));
+
assert_se(copy_tree(original_dir, copy_dir, false) < 0);
assert_se(copy_tree("/tmp/inexistent/foo/bar/fsdoi", copy_dir, false) < 0);