aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-04-30 17:32:43 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-04-30 17:32:43 +0000
commitc561cace091dd6316427878305b3668510b447a3 (patch)
treef050bb45b13ccde534cf98c988d733292969ebdb /libbb
parent8cc18e447869d5411c3779427ecc0633d778c202 (diff)
downloadbusybox-w32-c561cace091dd6316427878305b3668510b447a3.tar.gz
busybox-w32-c561cace091dd6316427878305b3668510b447a3.tar.bz2
busybox-w32-c561cace091dd6316427878305b3668510b447a3.zip
Fix user permissions of copied directories.
git-svn-id: svn://busybox.net/trunk/busybox@2491 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/copy_file.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index b2750ccf8..2d18b6087 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -64,6 +64,7 @@ int copy_file(const char *source, const char *dest, int flags)
64 if (S_ISDIR(source_stat.st_mode)) { 64 if (S_ISDIR(source_stat.st_mode)) {
65 DIR *dp; 65 DIR *dp;
66 struct dirent *d; 66 struct dirent *d;
67 mode_t saved_umask = 0;
67 68
68 if (!(flags & FILEUTILS_RECUR)) { 69 if (!(flags & FILEUTILS_RECUR)) {
69 error_msg("%s: omitting directory", source); 70 error_msg("%s: omitting directory", source);
@@ -77,7 +78,7 @@ int copy_file(const char *source, const char *dest, int flags)
77 return -1; 78 return -1;
78 } 79 }
79 } else { 80 } else {
80 mode_t mode, saved_umask; 81 mode_t mode;
81 saved_umask = umask(0); 82 saved_umask = umask(0);
82 83
83 mode = source_stat.st_mode; 84 mode = source_stat.st_mode;
@@ -122,6 +123,12 @@ int copy_file(const char *source, const char *dest, int flags)
122 perror_msg("unable to close directory `%s'", source); 123 perror_msg("unable to close directory `%s'", source);
123 status = -1; 124 status = -1;
124 } 125 }
126
127 if (!dest_exists &&
128 chmod(dest, source_stat.st_mode & ~saved_umask) < 0) {
129 perror_msg("unable to change permissions of `%s'", dest);
130 status = -1;
131 }
125 } else if (S_ISREG(source_stat.st_mode)) { 132 } else if (S_ISREG(source_stat.st_mode)) {
126 FILE *sfp, *dfp; 133 FILE *sfp, *dfp;
127 134