summaryrefslogtreecommitdiffstats
path: root/usr.bin/cpio
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2008-07-06 16:39:18 +0000
committerkientzle <kientzle@FreeBSD.org>2008-07-06 16:39:18 +0000
commitccded773b60aa7bc052dcda2fb45d74eff75b10d (patch)
treead855a312c378c902ae8696e6fe9871cc374a6a4 /usr.bin/cpio
parentb34bdf49f458bad25d2c90539b26f88da98f582d (diff)
downloadFreeBSD-src-ccded773b60aa7bc052dcda2fb45d74eff75b10d.zip
FreeBSD-src-ccded773b60aa7bc052dcda2fb45d74eff75b10d.tar.gz
Preserve ownership if cpio is run as root.
Diffstat (limited to 'usr.bin/cpio')
-rw-r--r--usr.bin/cpio/cpio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/cpio/cpio.c b/usr.bin/cpio/cpio.c
index f2c49ba..77c09cc 100644
--- a/usr.bin/cpio/cpio.c
+++ b/usr.bin/cpio/cpio.c
@@ -111,7 +111,8 @@ main(int argc, char *argv[])
cpio->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS;
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT;
- /* TODO: If run by root, set owner as well. */
+ if (geteuid() == 0)
+ cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER;
cpio->bytes_per_block = 512;
cpio->filename = NULL;
OpenPOWER on IntegriCloud