aboutsummaryrefslogtreecommitdiff
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-8e759aa31fa3f0dea6686cb7194398e68ff76696.tar.gz
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,
perror(destName);
return (FALSE);
}
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
+ if (setModes == TRUE) {
+ lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
+ }
+#endif
} else if (S_ISFIFO(srcStatBuf.st_mode)) {
//fprintf(stderr, "copying fifo %s to %s\n", srcName, destName);
if (mkfifo(destName, 0644)) {
@@ -225,16 +230,9 @@ copyFile( const char *srcName, const char *destName,
}
if (setModes == TRUE) {
- if (! S_ISLNK(srcStatBuf.st_mode)) {
- chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
- /* Never chmod a symlink; it follows the link */
- chmod(destName, srcStatBuf.st_mode);
- }
-#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
- else {
- lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
- }
-#endif
+ /* This is fine, since symlinks never get here */
+ chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid);
+ chmod(destName, srcStatBuf.st_mode);
times.actime = srcStatBuf.st_atime;
times.modtime = srcStatBuf.st_mtime;
utime(destName, &times);