aboutsummaryrefslogtreecommitdiffstats
path: root/src/mv.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2007-12-01 10:09:57 +0100
committerJim Meyering <meyering@redhat.com>2007-12-01 10:09:57 +0100
commitb64119bc54791809b9fc3a225761b1c913fe66bc (patch)
tree15566919c6c92780e8677a300cef940668fe2bad /src/mv.c
parentAvoid a spurious test failure when build directory is set-GID. (diff)
downloadcoreutils-b64119bc54791809b9fc3a225761b1c913fe66bc.tar.gz
coreutils-b64119bc54791809b9fc3a225761b1c913fe66bc.zip
Fix a security race with "cp -p A B" when B already exists.
* src/copy.h (struct cp_options): New member owner_privileges. * src/copy.c (USE_ACL): Define to 0 if not defined, for convenience. (owner_failure_ok): New function. (set_owner): Avoid a security-related race by doing an extra chmod first if it looks like there might be trouble right after a chown. Accept a source struct stat rather than a uid and gid, and accept a boolean NEW_DST and destination struct stat. All callers changed. * src/copy.h (cp_options_default): New function, replacing the old chown_privileges. * src/copy.c (cp_options_default): Likewise. * src/cp.c (cp_option_init): Use it. * src/install.c (cp_option_init): Likewise. * src/mv.c (cp_option_init): Likewise.
Diffstat (limited to 'src/mv.c')
-rw-r--r--src/mv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mv.c b/src/mv.c
index 3b1ba8e9e..44f5bfc51 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -123,6 +123,7 @@ cp_option_init (struct cp_options *x)
{
bool selinux_enabled = (0 < is_selinux_enabled ());
+ cp_options_default (x);
x->copy_as_regular = false; /* FIXME: maybe make this an option */
x->dereference = DEREF_NEVER;
x->unlink_dest_before_opening = false;
@@ -130,7 +131,6 @@ cp_option_init (struct cp_options *x)
x->hard_link = false;
x->interactive = I_UNSPECIFIED;
x->move_mode = true;
- x->chown_privileges = chown_privileges ();
x->one_file_system = false;
x->preserve_ownership = true;
x->preserve_links = true;