bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cp -x fails to preserve mount point permissions


From: Andrew Church
Subject: cp -x fails to preserve mount point permissions
Date: Sat, 03 Mar 2007 06:30:32 JST

To whom it may concern:

     There seems to be a bug in cp of coreutils 6.7 which causes the
permissions of mount point directories to not get preserved properly
when using the -x/--one-file-system option.  For example:

# mkdir /foo /foo/bar
# mount /dev/sdb1 /foo/bar
# ls -l /foo
total 4
drwxrwxrwt   3 root     root         4096 Mar  3 06:09 bar
# mkdir /quux
# cp -ax /foo /quux/
# ls -l /quux/foo
total 4
drwx-----T   2 root     root         4096 Mar  3 06:36 bar

     While the code in copy_internal() is sufficiently complex that I
haven't investigated it thoroughly, the following check at line 1597 of
copy.c seems suspicious:
      if (x->one_file_system && device != 0 && device != src_sb.st_dev)
        return true;
This is immediately after the directory is created, so there is no
opportunity to set any permission bits which may have been masked out by
the umask.

     The following patch may or may not be correct, but it seems to
solve the problem for my case.

----------------
diff -urN ../coreutils-6.7-orig/src/copy.c src/copy.c
--- ../coreutils-6.7-orig/src/copy.c    2006-12-07 16:01:16 +0900
+++ src/copy.c  2007-03-03 06:41:14 +0900
@@ -1595,7 +1595,8 @@
 
       /* Are we crossing a file system boundary?  */
       if (x->one_file_system && device != 0 && device != src_sb.st_dev)
-       return true;
+       delayed_ok = true;
+      else
 
       /* Copy the contents of the directory.  */
 
----------------

  --Andrew Church
    address@hidden
    http://achurch.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]