diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-01-27 19:50:47 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-01-27 19:50:47 +0000 |
commit | ce5b466bcce4edbd8a57ed3fa91911936bd11927 (patch) | |
tree | b49f4bb9a7eecc77307c014f8eafa1d60218da20 | |
parent | ccc7488615f0079032d8b017f57e6bf6a994cf84 (diff) | |
download | busybox-w32-ce5b466bcce4edbd8a57ed3fa91911936bd11927.tar.gz busybox-w32-ce5b466bcce4edbd8a57ed3fa91911936bd11927.tar.bz2 busybox-w32-ce5b466bcce4edbd8a57ed3fa91911936bd11927.zip |
copyFile could call chmod on a symlink, changing the perms
of the pointed to file. Minor fix to tar for directory handling.
-Erik
-rw-r--r-- | Changelog | 8 | ||||
-rw-r--r-- | archival/tar.c | 1 | ||||
-rw-r--r-- | tar.c | 1 | ||||
-rw-r--r-- | utility.c | 26 |
4 files changed, 21 insertions, 15 deletions
@@ -25,7 +25,8 @@ | |||
25 | contributed Friedrich Vedder <fwv@myrtle.lahn.de> | 25 | contributed Friedrich Vedder <fwv@myrtle.lahn.de> |
26 | * Cosmetic fix to busybox.c (Don't print a comma at the | 26 | * Cosmetic fix to busybox.c (Don't print a comma at the |
27 | end of line if there are no more application names). | 27 | end of line if there are no more application names). |
28 | * Fixed a stupid bug in "head" option handling ("head -n" would segfault). | 28 | * Fixed a stupid bug in "head" option handling ("head -n" |
29 | would segfault). | ||
29 | * Moved commonly used functions "xmalloc()" and "exit()" | 30 | * Moved commonly used functions "xmalloc()" and "exit()" |
30 | to utility.c (with proper #ifdef's). | 31 | to utility.c (with proper #ifdef's). |
31 | * Created a tiny tail implementation, removing -c, -q, -v, and making | 32 | * Created a tiny tail implementation, removing -c, -q, -v, and making |
@@ -37,7 +38,10 @@ | |||
37 | * Fixed mount and umount. Previously they could leak loop device | 38 | * Fixed mount and umount. Previously they could leak loop device |
38 | allocations, causing the system to quickly run out. Fix for umount | 39 | allocations, causing the system to quickly run out. Fix for umount |
39 | by Ben Collins <bcollins@debian.org>, and mount was fixed by me. | 40 | by Ben Collins <bcollins@debian.org>, and mount was fixed by me. |
40 | * ls formatting on 8 char user names fixed by Randolph Chung <tausq@debian.org>. | 41 | * ls formatting on eight charactor user names fixed by |
42 | Randolph Chung <tausq@debian.org>. | ||
43 | * cp could, when copying symlinks, change permissions of the | ||
44 | files pointed to by the symlinks. | ||
41 | 45 | ||
42 | 46 | ||
43 | -Erik Andersen | 47 | -Erik Andersen |
diff --git a/archival/tar.c b/archival/tar.c index aedb36a23..0fa09ffd8 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -596,6 +596,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) | |||
596 | chmod(outName, mode); | 596 | chmod(outName, mode); |
597 | return; | 597 | return; |
598 | } | 598 | } |
599 | return; | ||
599 | } | 600 | } |
600 | 601 | ||
601 | /* | 602 | /* |
@@ -596,6 +596,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) | |||
596 | chmod(outName, mode); | 596 | chmod(outName, mode); |
597 | return; | 597 | return; |
598 | } | 598 | } |
599 | return; | ||
599 | } | 600 | } |
600 | 601 | ||
601 | /* | 602 | /* |
@@ -131,6 +131,7 @@ copyFile( const char *srcName, const char *destName, | |||
131 | struct stat dstStatBuf; | 131 | struct stat dstStatBuf; |
132 | struct utimbuf times; | 132 | struct utimbuf times; |
133 | 133 | ||
134 | /* Grab the source file's stats */ | ||
134 | if (followLinks == FALSE) | 135 | if (followLinks == FALSE) |
135 | result = stat(srcName, &srcStatBuf); | 136 | result = stat(srcName, &srcStatBuf); |
136 | else | 137 | else |
@@ -140,6 +141,7 @@ copyFile( const char *srcName, const char *destName, | |||
140 | return FALSE; | 141 | return FALSE; |
141 | } | 142 | } |
142 | 143 | ||
144 | /* Grab the dest file's stats */ | ||
143 | if (followLinks == FALSE) | 145 | if (followLinks == FALSE) |
144 | result = stat(destName, &dstStatBuf); | 146 | result = stat(destName, &dstStatBuf); |
145 | else | 147 | else |
@@ -223,18 +225,18 @@ copyFile( const char *srcName, const char *destName, | |||
223 | } | 225 | } |
224 | 226 | ||
225 | if (setModes == TRUE) { | 227 | if (setModes == TRUE) { |
226 | //fprintf(stderr, "Setting permissions for %s\n", destName); | 228 | if (! S_ISLNK(srcStatBuf.st_mode)) { |
227 | chmod(destName, srcStatBuf.st_mode); | 229 | chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid); |
230 | /* Never chmod a symlink; it follows the link */ | ||
231 | chmod(destName, srcStatBuf.st_mode); | ||
232 | } | ||
228 | #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) | 233 | #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) |
229 | if (followLinks == FALSE) | 234 | else { |
230 | lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid); | 235 | lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid); |
231 | else | 236 | } |
232 | #endif | 237 | #endif |
233 | chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid); | ||
234 | |||
235 | times.actime = srcStatBuf.st_atime; | 238 | times.actime = srcStatBuf.st_atime; |
236 | times.modtime = srcStatBuf.st_mtime; | 239 | times.modtime = srcStatBuf.st_mtime; |
237 | |||
238 | utime(destName, ×); | 240 | utime(destName, ×); |
239 | } | 241 | } |
240 | 242 | ||
@@ -414,6 +416,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir | |||
414 | status = lstat(fileName, &statbuf); | 416 | status = lstat(fileName, &statbuf); |
415 | 417 | ||
416 | if (status < 0) { | 418 | if (status < 0) { |
419 | fprintf(stderr, "status=%d followLinks=%d TRUE=%d\n", status, followLinks, TRUE); | ||
417 | perror(fileName); | 420 | perror(fileName); |
418 | return (FALSE); | 421 | return (FALSE); |
419 | } | 422 | } |
@@ -515,14 +518,11 @@ extern int createPath (const char *name, int mode) | |||
515 | cp = strchr (cp + 1, '/'); | 518 | cp = strchr (cp + 1, '/'); |
516 | *cpOld = '\0'; | 519 | *cpOld = '\0'; |
517 | retVal = mkdir (buf, cp ? 0777 : mode); | 520 | retVal = mkdir (buf, cp ? 0777 : mode); |
518 | *cpOld = '/'; | 521 | if (retVal != 0 && errno != EEXIST) { |
519 | } | 522 | perror( buf); |
520 | /* Return the result from the final directory, as that | ||
521 | * is the one that counts */ | ||
522 | if( retVal!=0) { | ||
523 | if ( errno!=EEXIST) { | ||
524 | return( FALSE); | 523 | return( FALSE); |
525 | } | 524 | } |
525 | *cpOld = '/'; | ||
526 | } | 526 | } |
527 | return( TRUE); | 527 | return( TRUE); |
528 | } | 528 | } |