summaryrefslogtreecommitdiffhomepage
path: root/archival/libunarchive/data_extract_all.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-14 20:37:54 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-14 20:37:54 +0000
commite00e5025ecb2eb6160e7b94c0e93fc2a777f6eaa (patch)
treec08295d50b96a33d51c11b8601ac455333b8004a /archival/libunarchive/data_extract_all.c
parent39487e2d6a9a2b6e520969f65b4d326da82e354f (diff)
tar: real support for -p. +200 if selected.
By Natanael Copa <natanael.copa at gmail.com>
Diffstat (limited to 'archival/libunarchive/data_extract_all.c')
-rw-r--r--archival/libunarchive/data_extract_all.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 76e7edf24..4df9c09a7 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -112,7 +112,22 @@ void data_extract_all(archive_handle_t *archive_handle)
}
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
+#if ENABLE_FEATURE_TAR_UNAME_GNAME
+ 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;
+ }
+ 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 -