mirror of
https://github.com/sheumann/hush.git
synced 2025-01-04 22:34:37 +00:00
Fix user permissions of copied directories.
This commit is contained in:
parent
43ca13714b
commit
218aa370b4
@ -64,6 +64,7 @@ int copy_file(const char *source, const char *dest, int flags)
|
|||||||
if (S_ISDIR(source_stat.st_mode)) {
|
if (S_ISDIR(source_stat.st_mode)) {
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
|
mode_t saved_umask = 0;
|
||||||
|
|
||||||
if (!(flags & FILEUTILS_RECUR)) {
|
if (!(flags & FILEUTILS_RECUR)) {
|
||||||
error_msg("%s: omitting directory", source);
|
error_msg("%s: omitting directory", source);
|
||||||
@ -77,7 +78,7 @@ int copy_file(const char *source, const char *dest, int flags)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mode_t mode, saved_umask;
|
mode_t mode;
|
||||||
saved_umask = umask(0);
|
saved_umask = umask(0);
|
||||||
|
|
||||||
mode = source_stat.st_mode;
|
mode = source_stat.st_mode;
|
||||||
@ -122,6 +123,12 @@ int copy_file(const char *source, const char *dest, int flags)
|
|||||||
perror_msg("unable to close directory `%s'", source);
|
perror_msg("unable to close directory `%s'", source);
|
||||||
status = -1;
|
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)) {
|
} else if (S_ISREG(source_stat.st_mode)) {
|
||||||
FILE *sfp, *dfp;
|
FILE *sfp, *dfp;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user