data_extract_all: do not chmod symlink. Closes 2053
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
0cc25945d8
commit
d86b4c3907
@ -152,35 +152,32 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
|||||||
bb_error_msg_and_die("unrecognized file type");
|
bb_error_msg_and_die("unrecognized file type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) {
|
if (!S_ISLNK(file_header->mode)) {
|
||||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) {
|
||||||
if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) {
|
|
||||||
uid_t uid = file_header->uid;
|
uid_t uid = file_header->uid;
|
||||||
gid_t gid = file_header->gid;
|
gid_t gid = file_header->gid;
|
||||||
|
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||||
if (file_header->tar__uname) {
|
if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) {
|
||||||
|
if (file_header->tar__uname) {
|
||||||
//TODO: cache last name/id pair?
|
//TODO: cache last name/id pair?
|
||||||
struct passwd *pwd = getpwnam(file_header->tar__uname);
|
struct passwd *pwd = getpwnam(file_header->tar__uname);
|
||||||
if (pwd) uid = pwd->pw_uid;
|
if (pwd) uid = pwd->pw_uid;
|
||||||
}
|
}
|
||||||
if (file_header->tar__gname) {
|
if (file_header->tar__gname) {
|
||||||
struct group *grp = getgrnam(file_header->tar__gname);
|
struct group *grp = getgrnam(file_header->tar__gname);
|
||||||
if (grp) gid = grp->gr_gid;
|
if (grp) gid = grp->gr_gid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* GNU tar 1.15.1 uses chown, not lchown */
|
/* GNU tar 1.15.1 uses chown, not lchown */
|
||||||
chown(file_header->name, uid, gid);
|
chown(file_header->name, uid, gid);
|
||||||
} else
|
}
|
||||||
#endif
|
|
||||||
chown(file_header->name, file_header->uid, file_header->gid);
|
|
||||||
}
|
|
||||||
if (!S_ISLNK(file_header->mode)) {
|
|
||||||
/* uclibc has no lchmod, glibc is even stranger -
|
/* uclibc has no lchmod, glibc is even stranger -
|
||||||
* it has lchmod which seems to do nothing!
|
* it has lchmod which seems to do nothing!
|
||||||
* so we use chmod... */
|
* so we use chmod... */
|
||||||
if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) {
|
if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) {
|
||||||
chmod(file_header->name, file_header->mode);
|
chmod(file_header->name, file_header->mode);
|
||||||
}
|
}
|
||||||
/* same for utime */
|
|
||||||
if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) {
|
if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) {
|
||||||
struct timeval t[2];
|
struct timeval t[2];
|
||||||
|
|
||||||
|
@ -40,8 +40,7 @@ ls -ln cpio.testdir | $FILTER_LS" \
|
|||||||
0
|
0
|
||||||
-rw-r--r-- 2 $user $group 0 x
|
-rw-r--r-- 2 $user $group 0 x
|
||||||
-rw-r--r-- 2 $user $group 0 y
|
-rw-r--r-- 2 $user $group 0 y
|
||||||
" \
|
" "" ""
|
||||||
"" ""
|
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
|
|
||||||
@ -56,8 +55,7 @@ cpio.testdir/x
|
|||||||
cpio.testdir/y
|
cpio.testdir/y
|
||||||
1 blocks
|
1 blocks
|
||||||
0
|
0
|
||||||
" \
|
" "" ""
|
||||||
"" ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -83,11 +81,9 @@ ls -ln cpio.testdir2/cpio.testdir | $FILTER_LS" \
|
|||||||
-rw-r--r-- 2 $user $group 2 nonempty
|
-rw-r--r-- 2 $user $group 2 nonempty
|
||||||
-rw-r--r-- 2 $user $group 2 nonempty1
|
-rw-r--r-- 2 $user $group 2 nonempty1
|
||||||
-rw-r--r-- 1 $user $group 0 solo
|
-rw-r--r-- 1 $user $group 0 solo
|
||||||
" \
|
" "" ""
|
||||||
"" ""
|
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
|
|
||||||
# Was trying to create "/usr/bin", correct is "usr/bin".
|
# Was trying to create "/usr/bin", correct is "usr/bin".
|
||||||
rm -rf cpio.testdir
|
rm -rf cpio.testdir
|
||||||
optional FEATURE_CPIO_P
|
optional FEATURE_CPIO_P
|
||||||
@ -98,8 +94,24 @@ ls cpio.testdir" \
|
|||||||
1 blocks
|
1 blocks
|
||||||
0
|
0
|
||||||
usr
|
usr
|
||||||
" \
|
" "" ""
|
||||||
"" ""
|
SKIP=
|
||||||
|
|
||||||
|
# chown on a link was affecting file, dropping its sgid bits
|
||||||
|
rm -rf cpio.testdir
|
||||||
|
optional FEATURE_CPIO_O
|
||||||
|
mkdir cpio.testdir
|
||||||
|
touch cpio.testdir/file
|
||||||
|
chmod 6755 cpio.testdir/file # set the suid/sgid bit
|
||||||
|
ln -sf file cpio.testdir/link
|
||||||
|
testing "cpio restores sgid bits" \
|
||||||
|
"cd cpio.testdir && { echo file; echo link; } | cpio -ovHnewc >pack.cpio && rm ???? && cpio -idmvu <pack.cpio 2>/dev/null;
|
||||||
|
stat -c '%a %n' file" \
|
||||||
|
"\
|
||||||
|
file
|
||||||
|
link
|
||||||
|
6755 file
|
||||||
|
" "" ""
|
||||||
SKIP=
|
SKIP=
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user