diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-17 02:43:14 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-17 02:43:14 +0200 |
commit | d57d62686dac254e83fbc18f851c773ec16013d8 (patch) | |
tree | 3e22476c6f2d74208568d5d56a629a81e11589ea | |
parent | 1166d7b1360285659aa7585e5c5bd4e1321aeeaf (diff) | |
download | busybox-w32-d57d62686dac254e83fbc18f851c773ec16013d8.tar.gz busybox-w32-d57d62686dac254e83fbc18f851c773ec16013d8.tar.bz2 busybox-w32-d57d62686dac254e83fbc18f851c773ec16013d8.zip |
tar: fix --numeric-owner, --no-same-owner, --no-same-permissions bits
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/ar.c | 2 | ||||
-rw-r--r-- | archival/cpio.c | 4 | ||||
-rw-r--r-- | archival/dpkg.c | 4 | ||||
-rw-r--r-- | archival/libunarchive/data_extract_all.c | 29 | ||||
-rw-r--r-- | archival/rpm.c | 4 | ||||
-rw-r--r-- | archival/tar.c | 36 | ||||
-rw-r--r-- | include/unarchive.h | 16 |
7 files changed, 50 insertions, 45 deletions
diff --git a/archival/ar.c b/archival/ar.c index dbff6775e..a1bcb1f9c 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -62,7 +62,7 @@ int ar_main(int argc, char **argv) | |||
62 | archive_handle->action_data = data_extract_all; | 62 | archive_handle->action_data = data_extract_all; |
63 | } | 63 | } |
64 | if (opt & AR_OPT_PRESERVE_DATE) { | 64 | if (opt & AR_OPT_PRESERVE_DATE) { |
65 | archive_handle->ah_flags |= ARCHIVE_PRESERVE_DATE; | 65 | archive_handle->ah_flags |= ARCHIVE_RESTORE_DATE; |
66 | } | 66 | } |
67 | if (opt & AR_OPT_VERBOSE) { | 67 | if (opt & AR_OPT_VERBOSE) { |
68 | archive_handle->action_header = header_verbose_list_ar; | 68 | archive_handle->action_header = header_verbose_list_ar; |
diff --git a/archival/cpio.c b/archival/cpio.c index 5b4135f66..bb578577d 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -387,7 +387,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
387 | archive_handle->action_data = data_extract_to_stdout; | 387 | archive_handle->action_data = data_extract_to_stdout; |
388 | } | 388 | } |
389 | if (opt & CPIO_OPT_UNCONDITIONAL) { | 389 | if (opt & CPIO_OPT_UNCONDITIONAL) { |
390 | archive_handle->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL; | 390 | archive_handle->ah_flags |= ARCHIVE_UNLINK_OLD; |
391 | archive_handle->ah_flags &= ~ARCHIVE_EXTRACT_NEWER; | 391 | archive_handle->ah_flags &= ~ARCHIVE_EXTRACT_NEWER; |
392 | } | 392 | } |
393 | if (opt & CPIO_OPT_VERBOSE) { | 393 | if (opt & CPIO_OPT_VERBOSE) { |
@@ -405,7 +405,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
405 | archive_handle->ah_flags |= ARCHIVE_CREATE_LEADING_DIRS; | 405 | archive_handle->ah_flags |= ARCHIVE_CREATE_LEADING_DIRS; |
406 | } | 406 | } |
407 | if (opt & CPIO_OPT_PRESERVE_MTIME) { | 407 | if (opt & CPIO_OPT_PRESERVE_MTIME) { |
408 | archive_handle->ah_flags |= ARCHIVE_PRESERVE_DATE; | 408 | archive_handle->ah_flags |= ARCHIVE_RESTORE_DATE; |
409 | } | 409 | } |
410 | 410 | ||
411 | while (*argv) { | 411 | while (*argv) { |
diff --git a/archival/dpkg.c b/archival/dpkg.c index 781f1bb03..a9334df87 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -1531,7 +1531,7 @@ static void unpack_package(deb_file_t *deb_file) | |||
1531 | archive_handle->sub_archive->filter = filter_accept_list; | 1531 | archive_handle->sub_archive->filter = filter_accept_list; |
1532 | archive_handle->sub_archive->action_data = data_extract_all_prefix; | 1532 | archive_handle->sub_archive->action_data = data_extract_all_prefix; |
1533 | archive_handle->sub_archive->buffer = info_prefix; | 1533 | archive_handle->sub_archive->buffer = info_prefix; |
1534 | archive_handle->sub_archive->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL; | 1534 | archive_handle->sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD; |
1535 | unpack_ar_archive(archive_handle); | 1535 | unpack_ar_archive(archive_handle); |
1536 | 1536 | ||
1537 | /* Run the preinst prior to extracting */ | 1537 | /* Run the preinst prior to extracting */ |
@@ -1542,7 +1542,7 @@ static void unpack_package(deb_file_t *deb_file) | |||
1542 | init_archive_deb_data(archive_handle); | 1542 | init_archive_deb_data(archive_handle); |
1543 | archive_handle->sub_archive->action_data = data_extract_all_prefix; | 1543 | archive_handle->sub_archive->action_data = data_extract_all_prefix; |
1544 | archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */ | 1544 | archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */ |
1545 | archive_handle->sub_archive->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL; | 1545 | archive_handle->sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD; |
1546 | unpack_ar_archive(archive_handle); | 1546 | unpack_ar_archive(archive_handle); |
1547 | 1547 | ||
1548 | /* Create the list file */ | 1548 | /* Create the list file */ |
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c index d79ef7cb9..3e4a77de8 100644 --- a/archival/libunarchive/data_extract_all.c +++ b/archival/libunarchive/data_extract_all.c | |||
@@ -18,14 +18,13 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
18 | free(name); | 18 | free(name); |
19 | } | 19 | } |
20 | 20 | ||
21 | /* Check if the file already exists */ | 21 | if (archive_handle->ah_flags & ARCHIVE_UNLINK_OLD) { |
22 | if (archive_handle->ah_flags & ARCHIVE_EXTRACT_UNCONDITIONAL) { | ||
23 | /* Remove the entry if it exists */ | 22 | /* Remove the entry if it exists */ |
24 | if ((!S_ISDIR(file_header->mode)) | 23 | if ((!S_ISDIR(file_header->mode)) |
25 | && (unlink(file_header->name) == -1) | 24 | && (unlink(file_header->name) == -1) |
26 | && (errno != ENOENT) | 25 | && (errno != ENOENT) |
27 | ) { | 26 | ) { |
28 | bb_perror_msg_and_die("cannot remove old file %s", | 27 | bb_perror_msg_and_die("can't remove old file %s", |
29 | file_header->name); | 28 | file_header->name); |
30 | } | 29 | } |
31 | } | 30 | } |
@@ -34,7 +33,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
34 | struct stat statbuf; | 33 | struct stat statbuf; |
35 | if (lstat(file_header->name, &statbuf) == -1) { | 34 | if (lstat(file_header->name, &statbuf) == -1) { |
36 | if (errno != ENOENT) { | 35 | if (errno != ENOENT) { |
37 | bb_perror_msg_and_die("cannot stat old file"); | 36 | bb_perror_msg_and_die("can't stat old file"); |
38 | } | 37 | } |
39 | } | 38 | } |
40 | else if (statbuf.st_mtime <= file_header->mtime) { | 39 | else if (statbuf.st_mtime <= file_header->mtime) { |
@@ -46,7 +45,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
46 | return; | 45 | return; |
47 | } | 46 | } |
48 | else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) { | 47 | else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) { |
49 | bb_perror_msg_and_die("cannot remove old file %s", | 48 | bb_perror_msg_and_die("can't remove old file %s", |
50 | file_header->name); | 49 | file_header->name); |
51 | } | 50 | } |
52 | } | 51 | } |
@@ -59,7 +58,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
59 | /* hard link */ | 58 | /* hard link */ |
60 | res = link(file_header->link_target, file_header->name); | 59 | res = link(file_header->link_target, file_header->name); |
61 | if ((res == -1) && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)) { | 60 | if ((res == -1) && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)) { |
62 | bb_perror_msg("cannot create %slink " | 61 | bb_perror_msg("can't create %slink " |
63 | "from %s to %s", "hard", | 62 | "from %s to %s", "hard", |
64 | file_header->name, | 63 | file_header->name, |
65 | file_header->link_target); | 64 | file_header->link_target); |
@@ -69,8 +68,10 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
69 | switch (file_header->mode & S_IFMT) { | 68 | switch (file_header->mode & S_IFMT) { |
70 | case S_IFREG: { | 69 | case S_IFREG: { |
71 | /* Regular file */ | 70 | /* Regular file */ |
72 | dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL, | 71 | dst_fd = xopen3(file_header->name, |
73 | file_header->mode); | 72 | O_WRONLY | O_CREAT | O_EXCL, |
73 | file_header->mode | ||
74 | ); | ||
74 | bb_copyfd_exact_size(archive_handle->src_fd, dst_fd, file_header->size); | 75 | bb_copyfd_exact_size(archive_handle->src_fd, dst_fd, file_header->size); |
75 | close(dst_fd); | 76 | close(dst_fd); |
76 | break; | 77 | break; |
@@ -82,7 +83,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
82 | && (errno != EEXIST) | 83 | && (errno != EEXIST) |
83 | && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET) | 84 | && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET) |
84 | ) { | 85 | ) { |
85 | bb_perror_msg("cannot make dir %s", file_header->name); | 86 | bb_perror_msg("can't make dir %s", file_header->name); |
86 | } | 87 | } |
87 | break; | 88 | break; |
88 | case S_IFLNK: | 89 | case S_IFLNK: |
@@ -91,7 +92,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
91 | if ((res == -1) | 92 | if ((res == -1) |
92 | && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET) | 93 | && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET) |
93 | ) { | 94 | ) { |
94 | bb_perror_msg("cannot create %slink " | 95 | bb_perror_msg("can't create %slink " |
95 | "from %s to %s", "sym", | 96 | "from %s to %s", "sym", |
96 | file_header->name, | 97 | file_header->name, |
97 | file_header->link_target); | 98 | file_header->link_target); |
@@ -105,7 +106,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
105 | if ((res == -1) | 106 | if ((res == -1) |
106 | && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET) | 107 | && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET) |
107 | ) { | 108 | ) { |
108 | bb_perror_msg("cannot create node %s", file_header->name); | 109 | bb_perror_msg("can't create node %s", file_header->name); |
109 | } | 110 | } |
110 | break; | 111 | break; |
111 | default: | 112 | default: |
@@ -113,7 +114,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
113 | } | 114 | } |
114 | } | 115 | } |
115 | 116 | ||
116 | if (!(archive_handle->ah_flags & ARCHIVE_NOPRESERVE_OWN)) { | 117 | if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) { |
117 | #if ENABLE_FEATURE_TAR_UNAME_GNAME | 118 | #if ENABLE_FEATURE_TAR_UNAME_GNAME |
118 | if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) { | 119 | if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) { |
119 | uid_t uid = file_header->uid; | 120 | uid_t uid = file_header->uid; |
@@ -136,11 +137,11 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
136 | /* uclibc has no lchmod, glibc is even stranger - | 137 | /* uclibc has no lchmod, glibc is even stranger - |
137 | * it has lchmod which seems to do nothing! | 138 | * it has lchmod which seems to do nothing! |
138 | * so we use chmod... */ | 139 | * so we use chmod... */ |
139 | if (!(archive_handle->ah_flags & ARCHIVE_NOPRESERVE_PERM)) { | 140 | if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) { |
140 | chmod(file_header->name, file_header->mode); | 141 | chmod(file_header->name, file_header->mode); |
141 | } | 142 | } |
142 | /* same for utime */ | 143 | /* same for utime */ |
143 | if (archive_handle->ah_flags & ARCHIVE_PRESERVE_DATE) { | 144 | if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) { |
144 | struct utimbuf t; | 145 | struct utimbuf t; |
145 | t.actime = t.modtime = file_header->mtime; | 146 | t.actime = t.modtime = file_header->mtime; |
146 | utime(file_header->name, &t); | 147 | utime(file_header->name, &t); |
diff --git a/archival/rpm.c b/archival/rpm.c index 569bcddf2..309b55a36 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -202,12 +202,12 @@ static void extract_cpio_gz(int fd) | |||
202 | archive_handle->seek = seek_by_read; | 202 | archive_handle->seek = seek_by_read; |
203 | //archive_handle->action_header = header_list; | 203 | //archive_handle->action_header = header_list; |
204 | archive_handle->action_data = data_extract_all; | 204 | archive_handle->action_data = data_extract_all; |
205 | archive_handle->ah_flags = ARCHIVE_PRESERVE_DATE | ARCHIVE_CREATE_LEADING_DIRS | 205 | archive_handle->ah_flags = ARCHIVE_RESTORE_DATE | ARCHIVE_CREATE_LEADING_DIRS |
206 | /* compat: overwrite existing files. | 206 | /* compat: overwrite existing files. |
207 | * try "rpm -i foo.src.rpm" few times in a row - | 207 | * try "rpm -i foo.src.rpm" few times in a row - |
208 | * standard rpm will not complain. | 208 | * standard rpm will not complain. |
209 | * (TODO? real rpm creates "file;1234" and then renames it) */ | 209 | * (TODO? real rpm creates "file;1234" and then renames it) */ |
210 | | ARCHIVE_EXTRACT_UNCONDITIONAL; | 210 | | ARCHIVE_UNLINK_OLD; |
211 | archive_handle->src_fd = fd; | 211 | archive_handle->src_fd = fd; |
212 | /*archive_handle->offset = 0; - init_handle() did it */ | 212 | /*archive_handle->offset = 0; - init_handle() did it */ |
213 | 213 | ||
diff --git a/archival/tar.c b/archival/tar.c index 9b7a42a18..bd8e5dc99 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -735,10 +735,10 @@ enum { | |||
735 | IF_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,) | 735 | IF_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,) |
736 | IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,) | 736 | IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,) |
737 | IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,) | 737 | IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,) |
738 | IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) | 738 | IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) /* 15th bit */ |
739 | OPTBIT_NOPRESERVE_OWN, | ||
740 | OPTBIT_NOPRESERVE_PERM, | ||
741 | OPTBIT_NUMERIC_OWNER, | 739 | OPTBIT_NUMERIC_OWNER, |
740 | OPTBIT_NOPRESERVE_OWNER, | ||
741 | OPTBIT_NOPRESERVE_PERM, | ||
742 | OPT_TEST = 1 << 0, // t | 742 | OPT_TEST = 1 << 0, // t |
743 | OPT_EXTRACT = 1 << 1, // x | 743 | OPT_EXTRACT = 1 << 1, // x |
744 | OPT_BASEDIR = 1 << 2, // C | 744 | OPT_BASEDIR = 1 << 2, // C |
@@ -755,9 +755,9 @@ enum { | |||
755 | OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X | 755 | OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X |
756 | OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z | 756 | OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z |
757 | OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z | 757 | OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z |
758 | OPT_NOPRESERVE_OWN = 1 << OPTBIT_NOPRESERVE_OWN , // no-same-owner | ||
759 | OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions | ||
760 | OPT_NUMERIC_OWNER = 1 << OPTBIT_NUMERIC_OWNER, | 758 | OPT_NUMERIC_OWNER = 1 << OPTBIT_NUMERIC_OWNER, |
759 | OPT_NOPRESERVE_OWNER = 1 << OPTBIT_NOPRESERVE_OWNER , // no-same-owner | ||
760 | OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions | ||
761 | }; | 761 | }; |
762 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS | 762 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS |
763 | static const char tar_longopts[] ALIGN1 = | 763 | static const char tar_longopts[] ALIGN1 = |
@@ -789,12 +789,15 @@ static const char tar_longopts[] ALIGN1 = | |||
789 | # if ENABLE_FEATURE_SEAMLESS_Z | 789 | # if ENABLE_FEATURE_SEAMLESS_Z |
790 | "compress\0" No_argument "Z" | 790 | "compress\0" No_argument "Z" |
791 | # endif | 791 | # endif |
792 | /* use numeric uid/gid from tar header, not textual */ | ||
792 | "numeric-owner\0" No_argument "\xfc" | 793 | "numeric-owner\0" No_argument "\xfc" |
794 | /* do not restore owner */ | ||
793 | "no-same-owner\0" No_argument "\xfd" | 795 | "no-same-owner\0" No_argument "\xfd" |
796 | /* do not restore mode */ | ||
794 | "no-same-permissions\0" No_argument "\xfe" | 797 | "no-same-permissions\0" No_argument "\xfe" |
795 | /* --exclude takes next bit position in option mask, */ | 798 | /* --exclude takes next bit position in option mask, */ |
796 | /* therefore we have to either put it _after_ --no-same-perm */ | 799 | /* therefore we have to either put it _after_ --no-same-perm */ |
797 | /* or add OPT[BIT]_EXCLUDE before OPT[BIT]_NOPRESERVE_OWN */ | 800 | /* or add OPT[BIT]_EXCLUDE before OPT[BIT]_NOPRESERVE_OWNER */ |
798 | # if ENABLE_FEATURE_TAR_FROM | 801 | # if ENABLE_FEATURE_TAR_FROM |
799 | "exclude\0" Required_argument "\xff" | 802 | "exclude\0" Required_argument "\xff" |
800 | # endif | 803 | # endif |
@@ -817,12 +820,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
817 | /* Initialise default values */ | 820 | /* Initialise default values */ |
818 | tar_handle = init_handle(); | 821 | tar_handle = init_handle(); |
819 | tar_handle->ah_flags = ARCHIVE_CREATE_LEADING_DIRS | 822 | tar_handle->ah_flags = ARCHIVE_CREATE_LEADING_DIRS |
820 | | ARCHIVE_PRESERVE_DATE | 823 | | ARCHIVE_RESTORE_DATE |
821 | | ARCHIVE_EXTRACT_UNCONDITIONAL; | 824 | | ARCHIVE_UNLINK_OLD; |
822 | 825 | ||
823 | /* Apparently only root's tar preserves perms (see bug 3844) */ | 826 | /* Apparently only root's tar preserves perms (see bug 3844) */ |
824 | if (getuid() != 0) | 827 | if (getuid() != 0) |
825 | tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM; | 828 | tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM; |
826 | 829 | ||
827 | /* Prepend '-' to the first argument if required */ | 830 | /* Prepend '-' to the first argument if required */ |
828 | opt_complementary = "--:" // first arg is options | 831 | opt_complementary = "--:" // first arg is options |
@@ -856,6 +859,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
856 | , &verboseFlag // combined count for -t and -v | 859 | , &verboseFlag // combined count for -t and -v |
857 | , &verboseFlag // combined count for -t and -v | 860 | , &verboseFlag // combined count for -t and -v |
858 | ); | 861 | ); |
862 | //bb_error_msg("opt:%08x", opt); | ||
859 | argv += optind; | 863 | argv += optind; |
860 | 864 | ||
861 | if (verboseFlag) tar_handle->action_header = header_verbose_list; | 865 | if (verboseFlag) tar_handle->action_header = header_verbose_list; |
@@ -868,17 +872,17 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
868 | tar_handle->action_data = data_extract_to_stdout; | 872 | tar_handle->action_data = data_extract_to_stdout; |
869 | 873 | ||
870 | if (opt & OPT_KEEP_OLD) | 874 | if (opt & OPT_KEEP_OLD) |
871 | tar_handle->ah_flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL; | 875 | tar_handle->ah_flags &= ~ARCHIVE_UNLINK_OLD; |
872 | |||
873 | if (opt & OPT_NOPRESERVE_OWN) | ||
874 | tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_OWN; | ||
875 | |||
876 | if (opt & OPT_NOPRESERVE_PERM) | ||
877 | tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM; | ||
878 | 876 | ||
879 | if (opt & OPT_NUMERIC_OWNER) | 877 | if (opt & OPT_NUMERIC_OWNER) |
880 | tar_handle->ah_flags |= ARCHIVE_NUMERIC_OWNER; | 878 | tar_handle->ah_flags |= ARCHIVE_NUMERIC_OWNER; |
881 | 879 | ||
880 | if (opt & OPT_NOPRESERVE_OWNER) | ||
881 | tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_OWNER; | ||
882 | |||
883 | if (opt & OPT_NOPRESERVE_PERM) | ||
884 | tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM; | ||
885 | |||
882 | if (opt & OPT_GZIP) | 886 | if (opt & OPT_GZIP) |
883 | get_header_ptr = get_header_tar_gz; | 887 | get_header_ptr = get_header_tar_gz; |
884 | 888 | ||
diff --git a/include/unarchive.h b/include/unarchive.h index d8cb2a081..26d79e1e9 100644 --- a/include/unarchive.h +++ b/include/unarchive.h | |||
@@ -4,14 +4,14 @@ | |||
4 | 4 | ||
5 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | 5 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN |
6 | 6 | ||
7 | #define ARCHIVE_PRESERVE_DATE 1 | 7 | #define ARCHIVE_RESTORE_DATE (1 << 0) |
8 | #define ARCHIVE_CREATE_LEADING_DIRS 2 | 8 | #define ARCHIVE_CREATE_LEADING_DIRS (1 << 1) |
9 | #define ARCHIVE_EXTRACT_UNCONDITIONAL 4 | 9 | #define ARCHIVE_UNLINK_OLD (1 << 2) |
10 | #define ARCHIVE_EXTRACT_QUIET 8 | 10 | #define ARCHIVE_EXTRACT_QUIET (1 << 3) |
11 | #define ARCHIVE_EXTRACT_NEWER 16 | 11 | #define ARCHIVE_EXTRACT_NEWER (1 << 4) |
12 | #define ARCHIVE_NOPRESERVE_OWN 32 | 12 | #define ARCHIVE_DONT_RESTORE_OWNER (1 << 5) |
13 | #define ARCHIVE_NOPRESERVE_PERM 64 | 13 | #define ARCHIVE_DONT_RESTORE_PERM (1 << 6) |
14 | #define ARCHIVE_NUMERIC_OWNER 128 | 14 | #define ARCHIVE_NUMERIC_OWNER (1 << 7) |
15 | 15 | ||
16 | typedef struct file_header_t { | 16 | typedef struct file_header_t { |
17 | char *name; | 17 | char *name; |