diff options
author | erik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-01-29 05:52:40 +0000 |
---|---|---|
committer | erik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-01-29 05:52:40 +0000 |
commit | 78b8594add37cb36dabc7b78fb071a3621707117 (patch) | |
tree | bf85d9f769971c50e4c16ebeb4475a1e092c0fed /utility.c | |
parent | f944869377f715439b35080cf68137457a964714 (diff) | |
download | busybox-w32-78b8594add37cb36dabc7b78fb071a3621707117.tar.gz busybox-w32-78b8594add37cb36dabc7b78fb071a3621707117.tar.bz2 busybox-w32-78b8594add37cb36dabc7b78fb071a3621707117.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
git-svn-id: svn://busybox.net/trunk/busybox@346 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to '')
-rw-r--r-- | utility.c | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -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, ×); | 238 | utime(destName, ×); |