summaryrefslogtreecommitdiff
path: root/src/copy.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-10-06 04:57:40 +0000
committerJim Meyering <jim@meyering.net>1997-10-06 04:57:40 +0000
commitfe12b6711354443b38c583936ac1546a13423414 (patch)
treee3ca1bd53eb71ca0a494a3dc5e5d969f461013ad /src/copy.c
parent22a4f828dbc66cf3aea8649da41409ab4e1abdf0 (diff)
downloadcoreutils-fe12b6711354443b38c583936ac1546a13423414.tar.xz
(copy_internal): Use require_preserve.
Diffstat (limited to 'src/copy.c')
-rw-r--r--src/copy.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/copy.c b/src/copy.c
index fd6191f52..93f4aaa05 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -687,6 +687,14 @@ copy_internal (const char *src_path, const char *dst_path,
goto un_backup;
}
+ /* POSIX says that `cp -p' must restore the following:
+ - permission bits
+ - setuid, setgid bits
+ - owner and group
+ If it fails to restore any of those, we may give a warning but
+ the destination must not be removed.
+ FIXME: implement the above. */
+
/* Adjust the times (and if possible, ownership) for the copy.
chown turns off set[ug]id bits for non-root,
so do the chmod last. */
@@ -701,13 +709,13 @@ copy_internal (const char *src_path, const char *dst_path,
if (utime (dst_path, &utb))
{
error (0, errno, _("preserving times for %s"), dst_path);
- return 1;
+ return x->require_preserve;
}
if (DO_CHOWN (chown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, _("preserving ownership for %s"), dst_path);
- return 1;
+ return x->require_preserve;
}
}
@@ -717,7 +725,7 @@ copy_internal (const char *src_path, const char *dst_path,
if (chmod (dst_path, src_mode & x->umask_kill))
{
error (0, errno, _("preserving permissions for %s"), dst_path);
- return 1;
+ return x->require_preserve;
}
}
else if (fix_mode)
@@ -749,6 +757,8 @@ valid_options (const struct cp_options *co)
/* FIXME: make sure xstat and dereference are consistent. */
assert (co->xstat);
+ assert (co->require_preserve == 0 || co->require_preserve == 1);
+
assert (co->sparse_mode != SPARSE_UNUSED);
return 1;
}