tar: fix "hardlinks to symlinks chown" bug 1519.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
02365a6ef7
commit
e69ad87802
@ -96,7 +96,10 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
|||||||
file_header->name,
|
file_header->name,
|
||||||
file_header->link_target);
|
file_header->link_target);
|
||||||
}
|
}
|
||||||
} else {
|
/* Hardlinks have no separate mode/ownership, skip chown/chmod */
|
||||||
|
goto ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the filesystem entry */
|
/* Create the filesystem entry */
|
||||||
switch (file_header->mode & S_IFMT) {
|
switch (file_header->mode & S_IFMT) {
|
||||||
case S_IFREG: {
|
case S_IFREG: {
|
||||||
@ -148,7 +151,6 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
|||||||
default:
|
default:
|
||||||
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 (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) {
|
||||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||||
|
@ -61,6 +61,7 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
|
|||||||
|
|
||||||
#endif /* FEATURE_TAR_UNAME_GNAME */
|
#endif /* FEATURE_TAR_UNAME_GNAME */
|
||||||
|
|
||||||
|
/* NB: GNU tar shows "->" for symlinks and "link to" for hardlinks */
|
||||||
if (file_header->link_target) {
|
if (file_header->link_target) {
|
||||||
printf(" -> %s", file_header->link_target);
|
printf(" -> %s", file_header->link_target);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,35 @@ dr-xr-x--- input_dir
|
|||||||
" \
|
" \
|
||||||
"" ""
|
"" ""
|
||||||
|
|
||||||
|
testing "tar symlinks mode" '\
|
||||||
|
rm -rf input_* test.tar 2>/dev/null
|
||||||
|
>input_file
|
||||||
|
chmod 741 input_file
|
||||||
|
ln -s input_file input_soft
|
||||||
|
mkdir input_dir
|
||||||
|
chmod 550 input_dir
|
||||||
|
ln input_file input_dir
|
||||||
|
ln input_soft input_dir
|
||||||
|
tar cf test.tar input_*
|
||||||
|
tar tvf test.tar | sed "s/.*[0-9] input/input/"
|
||||||
|
tar xf test.tar 2>&1
|
||||||
|
echo Ok: $?
|
||||||
|
ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
|
||||||
|
' "\
|
||||||
|
input_dir/
|
||||||
|
input_dir/input_file
|
||||||
|
input_dir/input_soft -> input_file
|
||||||
|
input_file -> input_dir/input_file
|
||||||
|
input_soft -> input_dir/input_soft
|
||||||
|
Ok: 0
|
||||||
|
-rwxr----x input_dir/input_file
|
||||||
|
lrwxrwxrwx input_file
|
||||||
|
dr-xr-x--- input_dir
|
||||||
|
-rwxr----x input_file
|
||||||
|
lrwxrwxrwx input_file
|
||||||
|
" \
|
||||||
|
"" ""
|
||||||
|
|
||||||
optional FEATURE_TAR_LONG_OPTIONS
|
optional FEATURE_TAR_LONG_OPTIONS
|
||||||
testing "tar --overwrite" "\
|
testing "tar --overwrite" "\
|
||||||
rm -rf input_* test.tar 2>/dev/null
|
rm -rf input_* test.tar 2>/dev/null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user