summaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorDenis Vlasenko2009-04-21 00:52:21 +0000
committerDenis Vlasenko2009-04-21 00:52:21 +0000
commit8b814b4a349e2262c0ad25793b05206a14651ebb (patch)
treed58a9a4b05e6c662d1ccdcca8da82173d52c1e4b /archival/libunarchive
parent76478b8091d4c3472fb0c7e572c350d150ecd459 (diff)
downloadbusybox-8b814b4a349e2262c0ad25793b05206a14651ebb.zip
busybox-8b814b4a349e2262c0ad25793b05206a14651ebb.tar.gz
tar: support for tar --numeric-owner. By Natanael Copa.
function old new delta tar_longopts 221 237 +16 data_extract_all 692 705 +13 tar_main 690 702 +12
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/data_extract_all.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 8b1ee2a..a2dfcb9 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -114,22 +114,24 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
}
if (!(archive_handle->ah_flags & ARCHIVE_NOPRESERVE_OWN)) {
-#if ENABLE_FEATURE_TAR_UNAME_GNAME
- uid_t uid = file_header->uid;
- gid_t gid = file_header->gid;
+ if (ENABLE_FEATURE_TAR_UNAME_GNAME
+ && !(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)
+ ) {
+ uid_t uid = file_header->uid;
+ gid_t gid = file_header->gid;
- if (file_header->uname) {
- struct passwd *pwd = getpwnam(file_header->uname);
- if (pwd) uid = pwd->pw_uid;
- }
- if (file_header->gname) {
- struct group *grp = getgrnam(file_header->gname);
- if (grp) gid = grp->gr_gid;
+ if (file_header->uname) {
+ struct passwd *pwd = getpwnam(file_header->uname);
+ if (pwd) uid = pwd->pw_uid;
+ }
+ if (file_header->gname) {
+ struct group *grp = getgrnam(file_header->gname);
+ if (grp) gid = grp->gr_gid;
+ }
+ lchown(file_header->name, uid, gid);
+ } else {
+ lchown(file_header->name, file_header->uid, file_header->gid);
}
- lchown(file_header->name, uid, gid);
-#else
- lchown(file_header->name, file_header->uid, file_header->gid);
-#endif
}
if ((file_header->mode & S_IFMT) != S_IFLNK) {
/* uclibc has no lchmod, glibc is even stranger -