if (S_ISDIR(source_stat.st_mode)) {
DIR *dp;
struct dirent *d;
+ mode_t saved_umask = 0;
if (!(flags & FILEUTILS_RECUR)) {
error_msg("%s: omitting directory", source);
return -1;
}
} else {
- mode_t mode, saved_umask;
+ mode_t mode;
saved_umask = umask(0);
mode = source_stat.st_mode;
perror_msg("unable to close directory `%s'", source);
status = -1;
}
+
+ if (!dest_exists &&
+ chmod(dest, source_stat.st_mode & ~saved_umask) < 0) {
+ perror_msg("unable to change permissions of `%s'", dest);
+ status = -1;
+ }
} else if (S_ISREG(source_stat.st_mode)) {
FILE *sfp, *dfp;