aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-04-30 17:32:43 +0000
committerMatt Kraai <kraai@debian.org>2001-04-30 17:32:43 +0000
commit218aa370b487b630953fdf2f1e9be26aa232de8a (patch)
treef050bb45b13ccde534cf98c988d733292969ebdb
parent43ca13714b4dc720a617ce23f89eb860bfb62303 (diff)
downloadbusybox-w32-218aa370b487b630953fdf2f1e9be26aa232de8a.tar.gz
busybox-w32-218aa370b487b630953fdf2f1e9be26aa232de8a.tar.bz2
busybox-w32-218aa370b487b630953fdf2f1e9be26aa232de8a.zip
Fix user permissions of copied directories.
-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