---
libutil/cp.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/libutil/cp.c b/libutil/cp.c
index c35d03e..e212a48 100644
--- a/libutil/cp.c
+++ b/libutil/cp.c
_AT_@ -134,9 +134,6 @@ cp(const char *s1, const char *s2, int depth)
return 0;
}
- /* preserve permissions by default */
- fchmod(f2, st.st_mode);
-
close(f1);
close(f2);
}
_AT_@ -150,12 +147,16 @@ cp(const char *s1, const char *s2, int depth)
cp_status = 1;
}
- /* owner */
+ /* owner and mode */
if (!S_ISLNK(st.st_mode)) {
if (chown(s2, st.st_uid, st.st_gid) < 0) {
weprintf("chown %s:", s2);
cp_status = 1;
- return 0;
+ st.st_mode &= ~(S_ISUID | S_ISGID);
+ }
+ if (chmod(s2, st.st_mode) < 0) {
+ weprintf("chmod %s:", s2);
+ cp_status = 1;
}
} else {
if (lchown(s2, st.st_uid, st.st_gid) < 0) {
--
2.11.0
Received on Mon Jan 02 2017 - 02:00:35 CET
This archive was generated by hypermail 2.3.0 : Mon Jan 02 2017 - 02:12:32 CET