aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-05-13 15:39:30 +0000
committerEric Andersen <andersen@codepoet.org>2001-05-13 15:39:30 +0000
commita17b3631fe866ba84f2be753e28b4ac5cac45341 (patch)
tree290ce540a96269c74ffc1a501dabc1789547e676
parent95a349f427158f1e99bfd1d5534963d9cb55860d (diff)
downloadbusybox-w32-a17b3631fe866ba84f2be753e28b4ac5cac45341.tar.gz
busybox-w32-a17b3631fe866ba84f2be753e28b4ac5cac45341.tar.bz2
busybox-w32-a17b3631fe866ba84f2be753e28b4ac5cac45341.zip
Do not ever change permissions on existing directories, only
on directories we created while extracting a tarball. Fix based on bug report and patch from Konstantin Boldyshev <konst@linuxassembly.org> -Erik
-rw-r--r--archival/tar.c8
-rw-r--r--tar.c8
2 files changed, 12 insertions, 4 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 135bfd186..6af16f4bd 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -382,6 +382,7 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
382static int 382static int
383tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) 383tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
384{ 384{
385 int result;
385 386
386 if (extractFlag==FALSE || tostdoutFlag==TRUE) 387 if (extractFlag==FALSE || tostdoutFlag==TRUE)
387 return( TRUE); 388 return( TRUE);
@@ -393,12 +394,15 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
393 /* make the final component, just in case it was 394 /* make the final component, just in case it was
394 * omitted by create_path() (which will skip the 395 * omitted by create_path() (which will skip the
395 * directory if it doesn't have a terminating '/') */ 396 * directory if it doesn't have a terminating '/') */
396 if (mkdir(header->name, header->mode) < 0 && errno != EEXIST) { 397 result = mkdir(header->name, header->mode);
398 /* Don't fix permissions on pre-existing directories */
399 if (result == 0) {
400 fixUpPermissions(header);
401 } else if (result < 0 && errno != EEXIST) {
397 perror_msg("%s", header->name); 402 perror_msg("%s", header->name);
398 return FALSE; 403 return FALSE;
399 } 404 }
400 405
401 fixUpPermissions(header);
402 return( TRUE); 406 return( TRUE);
403} 407}
404 408
diff --git a/tar.c b/tar.c
index 135bfd186..6af16f4bd 100644
--- a/tar.c
+++ b/tar.c
@@ -382,6 +382,7 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
382static int 382static int
383tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) 383tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
384{ 384{
385 int result;
385 386
386 if (extractFlag==FALSE || tostdoutFlag==TRUE) 387 if (extractFlag==FALSE || tostdoutFlag==TRUE)
387 return( TRUE); 388 return( TRUE);
@@ -393,12 +394,15 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
393 /* make the final component, just in case it was 394 /* make the final component, just in case it was
394 * omitted by create_path() (which will skip the 395 * omitted by create_path() (which will skip the
395 * directory if it doesn't have a terminating '/') */ 396 * directory if it doesn't have a terminating '/') */
396 if (mkdir(header->name, header->mode) < 0 && errno != EEXIST) { 397 result = mkdir(header->name, header->mode);
398 /* Don't fix permissions on pre-existing directories */
399 if (result == 0) {
400 fixUpPermissions(header);
401 } else if (result < 0 && errno != EEXIST) {
397 perror_msg("%s", header->name); 402 perror_msg("%s", header->name);
398 return FALSE; 403 return FALSE;
399 } 404 }
400 405
401 fixUpPermissions(header);
402 return( TRUE); 406 return( TRUE);
403} 407}
404 408