diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-18 02:00:55 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-18 02:00:55 +0200 |
commit | d86b4c3907a78ab8785bcd6342ca233d0fe23ed0 (patch) | |
tree | 82c99ea6266a0587236e7b17f39dc541ebbe1936 | |
parent | 0cc25945d8e6821d967bb97266774f9ee6c07197 (diff) | |
download | busybox-w32-d86b4c3907a78ab8785bcd6342ca233d0fe23ed0.tar.gz busybox-w32-d86b4c3907a78ab8785bcd6342ca233d0fe23ed0.tar.bz2 busybox-w32-d86b4c3907a78ab8785bcd6342ca233d0fe23ed0.zip |
data_extract_all: do not chmod symlink. Closes 2053
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/libunarchive/data_extract_all.c | 31 | ||||
-rwxr-xr-x | testsuite/cpio.tests | 30 |
2 files changed, 35 insertions, 26 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c index 815261036..c4ffe7ef8 100644 --- a/archival/libunarchive/data_extract_all.c +++ b/archival/libunarchive/data_extract_all.c | |||
@@ -152,35 +152,32 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
152 | bb_error_msg_and_die("unrecognized file type"); | 152 | bb_error_msg_and_die("unrecognized file type"); |
153 | } | 153 | } |
154 | 154 | ||
155 | if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) { | 155 | if (!S_ISLNK(file_header->mode)) { |
156 | #if ENABLE_FEATURE_TAR_UNAME_GNAME | 156 | if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) { |
157 | if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) { | ||
158 | uid_t uid = file_header->uid; | 157 | uid_t uid = file_header->uid; |
159 | gid_t gid = file_header->gid; | 158 | gid_t gid = file_header->gid; |
160 | 159 | #if ENABLE_FEATURE_TAR_UNAME_GNAME | |
161 | if (file_header->tar__uname) { | 160 | if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) { |
161 | if (file_header->tar__uname) { | ||
162 | //TODO: cache last name/id pair? | 162 | //TODO: cache last name/id pair? |
163 | struct passwd *pwd = getpwnam(file_header->tar__uname); | 163 | struct passwd *pwd = getpwnam(file_header->tar__uname); |
164 | if (pwd) uid = pwd->pw_uid; | 164 | if (pwd) uid = pwd->pw_uid; |
165 | } | 165 | } |
166 | if (file_header->tar__gname) { | 166 | if (file_header->tar__gname) { |
167 | struct group *grp = getgrnam(file_header->tar__gname); | 167 | struct group *grp = getgrnam(file_header->tar__gname); |
168 | if (grp) gid = grp->gr_gid; | 168 | if (grp) gid = grp->gr_gid; |
169 | } | ||
169 | } | 170 | } |
171 | #endif | ||
170 | /* GNU tar 1.15.1 uses chown, not lchown */ | 172 | /* GNU tar 1.15.1 uses chown, not lchown */ |
171 | chown(file_header->name, uid, gid); | 173 | chown(file_header->name, uid, gid); |
172 | } else | 174 | } |
173 | #endif | ||
174 | chown(file_header->name, file_header->uid, file_header->gid); | ||
175 | } | ||
176 | if (!S_ISLNK(file_header->mode)) { | ||
177 | /* uclibc has no lchmod, glibc is even stranger - | 175 | /* uclibc has no lchmod, glibc is even stranger - |
178 | * it has lchmod which seems to do nothing! | 176 | * it has lchmod which seems to do nothing! |
179 | * so we use chmod... */ | 177 | * so we use chmod... */ |
180 | if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) { | 178 | if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) { |
181 | chmod(file_header->name, file_header->mode); | 179 | chmod(file_header->name, file_header->mode); |
182 | } | 180 | } |
183 | /* same for utime */ | ||
184 | if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) { | 181 | if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) { |
185 | struct timeval t[2]; | 182 | struct timeval t[2]; |
186 | 183 | ||
diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests index 725e70eab..42e3ff8dc 100755 --- a/testsuite/cpio.tests +++ b/testsuite/cpio.tests | |||
@@ -40,8 +40,7 @@ ls -ln cpio.testdir | $FILTER_LS" \ | |||
40 | 0 | 40 | 0 |
41 | -rw-r--r-- 2 $user $group 0 x | 41 | -rw-r--r-- 2 $user $group 0 x |
42 | -rw-r--r-- 2 $user $group 0 y | 42 | -rw-r--r-- 2 $user $group 0 y |
43 | " \ | 43 | " "" "" |
44 | "" "" | ||
45 | SKIP= | 44 | SKIP= |
46 | 45 | ||
47 | 46 | ||
@@ -56,8 +55,7 @@ cpio.testdir/x | |||
56 | cpio.testdir/y | 55 | cpio.testdir/y |
57 | 1 blocks | 56 | 1 blocks |
58 | 0 | 57 | 0 |
59 | " \ | 58 | " "" "" |
60 | "" "" | ||
61 | } | 59 | } |
62 | 60 | ||
63 | 61 | ||
@@ -83,11 +81,9 @@ ls -ln cpio.testdir2/cpio.testdir | $FILTER_LS" \ | |||
83 | -rw-r--r-- 2 $user $group 2 nonempty | 81 | -rw-r--r-- 2 $user $group 2 nonempty |
84 | -rw-r--r-- 2 $user $group 2 nonempty1 | 82 | -rw-r--r-- 2 $user $group 2 nonempty1 |
85 | -rw-r--r-- 1 $user $group 0 solo | 83 | -rw-r--r-- 1 $user $group 0 solo |
86 | " \ | 84 | " "" "" |
87 | "" "" | ||
88 | SKIP= | 85 | SKIP= |
89 | 86 | ||
90 | |||
91 | # Was trying to create "/usr/bin", correct is "usr/bin". | 87 | # Was trying to create "/usr/bin", correct is "usr/bin". |
92 | rm -rf cpio.testdir | 88 | rm -rf cpio.testdir |
93 | optional FEATURE_CPIO_P | 89 | optional FEATURE_CPIO_P |
@@ -98,8 +94,24 @@ ls cpio.testdir" \ | |||
98 | 1 blocks | 94 | 1 blocks |
99 | 0 | 95 | 0 |
100 | usr | 96 | usr |
101 | " \ | 97 | " "" "" |
102 | "" "" | 98 | SKIP= |
99 | |||
100 | # chown on a link was affecting file, dropping its sgid bits | ||
101 | rm -rf cpio.testdir | ||
102 | optional FEATURE_CPIO_O | ||
103 | mkdir cpio.testdir | ||
104 | touch cpio.testdir/file | ||
105 | chmod 6755 cpio.testdir/file # set the suid/sgid bit | ||
106 | ln -sf file cpio.testdir/link | ||
107 | testing "cpio restores sgid bits" \ | ||
108 | "cd cpio.testdir && { echo file; echo link; } | cpio -ovHnewc >pack.cpio && rm ???? && cpio -idmvu <pack.cpio 2>/dev/null; | ||
109 | stat -c '%a %n' file" \ | ||
110 | "\ | ||
111 | file | ||
112 | link | ||
113 | 6755 file | ||
114 | " "" "" | ||
103 | SKIP= | 115 | SKIP= |
104 | 116 | ||
105 | 117 | ||