summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-01-29 05:52:40 +0000
committerErik Andersen <andersen@codepoet.org>2000-01-29 05:52:40 +0000
commit8e759aa31fa3f0dea6686cb7194398e68ff76696 (patch)
treebf85d9f769971c50e4c16ebeb4475a1e092c0fed /utility.c
parentd7a44c76fe22873893b995ab62ce4112fad99c66 (diff)
downloadbusybox-w32-8e759aa31fa3f0dea6686cb7194398e68ff76696.tar.gz
busybox-w32-8e759aa31fa3f0dea6686cb7194398e68ff76696.tar.bz2
busybox-w32-8e759aa31fa3f0dea6686cb7194398e68ff76696.zip
copy fixes to simplify link copying and always do the right thing.
ping could segfault because I'm an idiot, and tried to put a value in where I hadn't allocated storage. choke. -Erik
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/utility.c b/utility.c
index c10f9bb8a..191701bed 100644
--- a/utility.c
+++ b/utility.c
@@ -182,6 +182,11 @@ copyFile( const char *srcName, const char *destName,
182 perror(destName); 182 perror(destName);
183 return (FALSE); 183 return (FALSE);
184 } 184 }
185#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
186 if (setModes == TRUE) {
187 lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
188 }
189#endif
185 } else if (S_ISFIFO(srcStatBuf.st_mode)) { 190 } else if (S_ISFIFO(srcStatBuf.st_mode)) {
186 //fprintf(stderr, "copying fifo %s to %s\n", srcName, destName); 191 //fprintf(stderr, "copying fifo %s to %s\n", srcName, destName);
187 if (mkfifo(destName, 0644)) { 192 if (mkfifo(destName, 0644)) {
@@ -225,16 +230,9 @@ copyFile( const char *srcName, const char *destName,
225 } 230 }
226 231
227 if (setModes == TRUE) { 232 if (setModes == TRUE) {
228 if (! S_ISLNK(srcStatBuf.st_mode)) { 233 /* This is fine, since symlinks never get here */
229 chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid); 234 chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
230 /* Never chmod a symlink; it follows the link */ 235 chmod(destName, srcStatBuf.st_mode);
231 chmod(destName, srcStatBuf.st_mode);
232 }
233#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
234 else {
235 lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
236 }
237#endif
238 times.actime = srcStatBuf.st_atime; 236 times.actime = srcStatBuf.st_atime;
239 times.modtime = srcStatBuf.st_mtime; 237 times.modtime = srcStatBuf.st_mtime;
240 utime(destName, &times); 238 utime(destName, &times);