GNU bug report logs - #9170
[PATCH] cp "restores" permissions it never set

Previous Next

Package: coreutils;

Reported by: Eric Lammerts <eric <at> lammerts.org>

Date: Mon, 25 Jul 2011 19:49:01 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eric Lammerts <eric <at> lammerts.org>
To: bug-coreutils <at> gnu.org
Subject: [PATCH] cp "restores" permissions it never set
Date: Mon, 25 Jul 2011 14:50:50 -0400 (EDT)
Hi,
I'm seeing the following strange behavior:

$ umask
0002
$ rm -rf /tmp/src /tmp/dst
$ mkdir -m775 /tmp/src /tmp/src/foo
$ mkdir -m700 /tmp/dst /tmp/dst/foo
$ ls -ld /tmp/dst/foo
drwx------ 2 eric eric 4096 Jul 25 13:40 /tmp/dst/foo
$ cp -r /tmp/src/. /tmp/dst/
$ ls -ld /tmp/dst/foo
drwx-w---- 2 eric eric 4096 Jul 25 13:40 /tmp/dst/foo

Patch below fixes this.

cheers,

Eric

diff --git a/src/copy.c b/src/copy.c
index 65566a0..b9c0ccf 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -2197,6 +2197,8 @@ copy_internal (char const *src_name, char const *dst_name,
           if (x->verbose)
             emit_verbose (src_name, dst_name, NULL);
         }
+      else
+        omitted_permissions = 0;

       /* Decide whether to copy the contents of the directory.  */
       if (x->one_file_system && device != 0 && device != src_sb.st_dev)




This bug report was last modified 13 years and 305 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.