bug-coreutils
[Top][All Lists]
Advanced

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

cp --no-preserve=mode is counter-intuitive


From: Dmitri Gribenko
Subject: cp --no-preserve=mode is counter-intuitive
Date: Sun, 19 Jul 2009 22:52:07 +0300

Hello,

Currently cp option --no-preserve=mode behavior is counter-intuitive.  What one
would expect is that --no-preserve=mode should set mode to (0666 & ~umask).
See below for a shell transcript (coreutils 7.4).

$ umask 0002
$ mkdir 1
$ cd 1
$ touch file1
$ ls -l
total 0
-rw-rw-r-- 1 grib grib 0 Jul 19 21:48 file1
$ touch ../file2
$ chmod 0644 ../file2
$ ls -l ../file2
-rw-r--r-- 1 grib grib 0 Jul 19 21:48 ../file2
$ cp ../file2 .
$ cp --no-preserve=all ../file2 ./file2-no-preserve-all
$ ls -l
total 0
-rw-rw-r-- 1 grib grib 0 Jul 19 21:48 file1
-rw-r--r-- 1 grib grib 0 Jul 19 21:50 file2
-rw-r--r-- 1 grib grib 0 Jul 19 21:50 file2-no-preserve-all

There is a usecase for behavior I'm requesting (but I can't think of a usecase
for current behavior).  For example, a shared directory on a multiuser computer
could set-group-id and owned by group users.  If appropriate umask value (0002)
is used, then all new files created in the shared directory would be owned by
group users and group-writable.  All new directories would be set-group-id.
But files copied (with cp) to the shared directory won't get such treatment.
It would be great if cp --no-preserve=mode set new file's mode like for plain
new files (e. g. created with touch).  Then cp --no-preserve=mode could be used
to copy files to the shared directory.

There is a couple of discussions on this topic, so I'm not alone in thinking
that current behavior makes little sense.

[1] http://lists.gnu.org/archive/html/bug-coreutils/2003-02/msg00033.html
[2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=488024
[3] https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/144024
[4] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=402332
[5] http://karapuz.habrahabr.ru/blog/64868/

Excuse me for linking [5], it is in Russian, but it describes the options to
create a shared directory on a Linux computer.  Because cp doesn't support
behavior I'm requesting, the authour had to conclude that the only working
solution is fam (monitoring new files and changing their permissions).

Best regards,
Dmitri Gribenko

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <address@hidden>*/




reply via email to

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