diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-04-27 01:06:31 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-04-27 01:06:31 +0000 |
commit | a6037888b637679bb961875402efb59929e44a34 (patch) | |
tree | 930c099bd2c1b11596b8d11bdc88076fe77883d8 /toys/posix/cpio.c | |
parent | 2e380b861863fed0d3aeaf94a0bc760774881ab8 (diff) | |
parent | 9f8ed39fcac14f0d61b9b2b8c14570b7604c112c (diff) | |
download | toybox-a6037888b637679bb961875402efb59929e44a34.tar.gz |
Snap for 7314842 from 9f8ed39fcac14f0d61b9b2b8c14570b7604c112c to sc-release
Change-Id: I7563e95ffffe89fe18e36a2568596b17f309847b
Diffstat (limited to 'toys/posix/cpio.c')
-rw-r--r-- | toys/posix/cpio.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c index 07c294f0..35b74b3b 100644 --- a/toys/posix/cpio.c +++ b/toys/posix/cpio.c @@ -166,11 +166,13 @@ void cpio_main(void) if (!test) err = mkdir(name, mode) && !FLAG(u); } else if (S_ISLNK(mode)) { data = strpad(afd, size, 0); - if (!test) err = symlink(data, name); + if (!test) { + err = symlink(data, name); + // Can't get a filehandle to a symlink, so do special chown + if (!err && !geteuid() && !FLAG(no_preserve_owner)) + err = lchown(name, uid, gid); + } free(data); - // Can't get a filehandle to a symlink, so do special chown - if (!err && !geteuid() && !FLAG(no_preserve_owner)) - err = lchown(name, uid, gid); } else if (S_ISREG(mode)) { int fd = test ? 0 : open(name, O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, mode); |