aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/cp.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-01-12 15:32:14 -0600
committerRob Landley <rob@landley.net>2019-01-12 15:32:14 -0600
commitc68fa66380ab45957acbfb5dc3b498bb19fe880d (patch)
treeade183008e77dc295563223b018de09442aaa61a /toys/posix/cp.c
parentbf76b49e295bfa945e79666371e3dd127bc82708 (diff)
downloadtoybox-c68fa66380ab45957acbfb5dc3b498bb19fe880d.tar.gz
Fix cp permissions when copying symlink contents, and add test.
Diffstat (limited to 'toys/posix/cp.c')
-rw-r--r--toys/posix/cp.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index da658319..5e1a0163 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -268,6 +268,8 @@ static int cp_node(struct dirtree *try)
catch = try->name;
break;
}
+ // When copying contents use symlink target's attributes
+ if (S_ISLNK(try->st.st_mode)) fstat(fdin, &try->st);
fdout = openat(cfd, catch, O_RDWR|O_CREAT|O_TRUNC, try->st.st_mode);
if (fdout >= 0) {
xsendfile(fdin, fdout);