aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-17 02:43:14 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-17 02:43:14 +0200
commitd57d62686dac254e83fbc18f851c773ec16013d8 (patch)
tree3e22476c6f2d74208568d5d56a629a81e11589ea /archival/libunarchive
parent1166d7b1360285659aa7585e5c5bd4e1321aeeaf (diff)
downloadbusybox-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>
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/data_extract_all.c29
1 files changed, 15 insertions, 14 deletions
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);