aboutsummaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorerik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-01-27 19:50:47 +0000
committererik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-01-27 19:50:47 +0000
commit2f1e4cb06b9e262ec8d28b2082f9186daf56ac5b (patch)
treeb49f4bb9a7eecc77307c014f8eafa1d60218da20 /utility.c
parent1a0c0d1f16ed677c80d6a3183955d04f59c5862f (diff)
downloadbusybox-w32-2f1e4cb06b9e262ec8d28b2082f9186daf56ac5b.tar.gz
busybox-w32-2f1e4cb06b9e262ec8d28b2082f9186daf56ac5b.tar.bz2
busybox-w32-2f1e4cb06b9e262ec8d28b2082f9186daf56ac5b.zip
copyFile could call chmod on a symlink, changing the perms
of the pointed to file. Minor fix to tar for directory handling. -Erik git-svn-id: svn://busybox.net/trunk/busybox@344 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to '')
-rw-r--r--utility.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/utility.c b/utility.c
index 5ff03d7a0..69637c475 100644
--- a/utility.c
+++ b/utility.c
@@ -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, &times); 240 utime(destName, &times);
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}