diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-05-13 15:39:30 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-05-13 15:39:30 +0000 |
commit | a17b3631fe866ba84f2be753e28b4ac5cac45341 (patch) | |
tree | 290ce540a96269c74ffc1a501dabc1789547e676 | |
parent | 95a349f427158f1e99bfd1d5534963d9cb55860d (diff) | |
download | busybox-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.c | 8 | ||||
-rw-r--r-- | tar.c | 8 |
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) | |||
382 | static int | 382 | static int |
383 | tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) | 383 | tarExtractDirectory(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 | ||
@@ -382,6 +382,7 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag) | |||
382 | static int | 382 | static int |
383 | tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) | 383 | tarExtractDirectory(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 | ||