Debian Bug report logs - #488024
cp preserves mode with --no-preserve=mode

version graph

Package: coreutils; Maintainer for coreutils is Michael Stone <mstone@debian.org>; Source for coreutils is src:coreutils.

Reported by: sergio <mailbox@sergio.spb.ru>

Date: Wed, 25 Jun 2008 18:57:02 UTC

Severity: normal

Tags: wontfix

Found in version coreutils/6.10-3

Done: Benoît Knecht <benoit.knecht@fsfe.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#488024; Package coreutils. Full text and rfc822 format available.

Acknowledgement sent to sergio <mailbox@sergio.spb.ru>:
New Bug report received and forwarded. Copy sent to Michael Stone <mstone@debian.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: sergio <mailbox@sergio.spb.ru>
To: submit@bugs.debian.org
Subject: cp preserves mode with --no-preserve=mode
Date: Wed, 25 Jun 2008 22:56:18 +0400
Package: coreutils
Version: 6.10-3

% touch qwe
% chmod 640 qwe
% umask u=rwx,g=rx,o=rx
% ls -l qwe
-rw-r----- 1 sergio sergio 0 Июн 25 22:53 qwe
% cp --no-preserve=mode qwe asd
% ls -l asd
-rw-r----- 1 sergio sergio 0 Июн 25 22:54 asd

-- 
sergio




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#488024; Package coreutils. Full text and rfc822 format available.

Acknowledgement sent to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. Full text and rfc822 format available.

Message #10 received at 488024@bugs.debian.org (full text, mbox):

From: Jim Meyering <jim@meyering.net>
To: sergio <mailbox@sergio.spb.ru>
Cc: 488024@bugs.debian.org, bug-coreutils@gnu.org
Subject: Re: Bug#488024: cp preserves mode with --no-preserve=mode
Date: Sat, 28 Jun 2008 09:42:33 +0200
sergio <mailbox@sergio.spb.ru> wrote:
> Package: coreutils
> Version: 6.10-3
>
> % touch qwe
> % chmod 640 qwe
> % umask u=rwx,g=rx,o=rx
> % ls -l qwe
> -rw-r----- 1 sergio sergio 0 Июн 25 22:53 qwe
> % cp --no-preserve=mode qwe asd
> % ls -l asd
> -rw-r----- 1 sergio sergio 0 Июн 25 22:54 asd

Thank you for the report.
That is a bug even in the latest sources.

Here's the patch I expect to push once I've added a test:

From ad21be12ef4be4347f076ebcdfed6424c20cbe2e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Fri, 27 Jun 2008 22:09:14 +0200
Subject: [PATCH] cp: make --no-preserve=mode work properly

* src/copy.c (copy_internal): Handle --no-preserve=mode properly.
Reported by sergio <mailbox@sergio.spb.ru>
in http://bugs.debian.org/488024
* NEWS: FIXME
* new test: FIXME
---
 src/copy.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/copy.c b/src/copy.c
index 82c6978..6db59a6 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1819,14 +1819,18 @@ copy_internal (char const *src_name, char const *dst_name,
   else if (S_ISREG (src_mode)
 	   || (x->copy_as_regular && !S_ISLNK (src_mode)))
     {
-      copied_as_regular = true;
       /* POSIX says the permission bits of the source file must be
 	 used as the 3rd argument in the open call.  Historical
-	 practice passed all the source mode bits to 'open', but the extra
-	 bits were ignored, so it should be the same either way.  */
-      if (! copy_reg (src_name, dst_name, x, src_mode & S_IRWXUGO,
+	 practice passed all the source mode bits to 'open', but the
+	 extra bits were ignored, so it should be the same either way.
+	 With --no-preserve=mode, use only ~umask.  */
+      mode_t d_mode = (x->preserve_mode ? src_mode : ~cached_umask ());
+      if (! copy_reg (src_name, dst_name, x,
+		      d_mode & S_IRWXUGO,
 		      omitted_permissions, &new_dst, &src_sb))
 	goto un_backup;
+
+      copied_as_regular = true;
     }
   else if (S_ISFIFO (src_mode))
     {
--
1.5.6.1.91.gc2a16




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#488024; Package coreutils. Full text and rfc822 format available.

Acknowledgement sent to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. Full text and rfc822 format available.

Message #15 received at 488024@bugs.debian.org (full text, mbox):

From: Jim Meyering <jim@meyering.net>
To: sergio <mailbox@sergio.spb.ru>
Cc: 488024@bugs.debian.org, bug-coreutils@gnu.org
Subject: Re: Bug#488024: cp preserves mode with --no-preserve=mode
Date: Mon, 30 Jun 2008 22:55:09 +0200
Jim Meyering <jim@meyering.net> wrote:
> sergio <mailbox@sergio.spb.ru> wrote:
>> Package: coreutils
>> Version: 6.10-3
>>
>> % touch qwe
>> % chmod 640 qwe
>> % umask u=rwx,g=rx,o=rx
>> % ls -l qwe
>> -rw-r----- 1 sergio sergio 0 Июн 25 22:53 qwe
>> % cp --no-preserve=mode qwe asd
>> % ls -l asd
>> -rw-r----- 1 sergio sergio 0 Июн 25 22:54 asd
>
> Thank you for the report.
> That is a bug even in the latest sources.

Actually, now I'm convinced that is _not_ a bug, but rather the intended
behavior, since "cp --no-preserve=mode ..." is equivalent to "cp ...",
and cp's default behavior is to use the src permission bits (masked via
umask) as the destination permission bits.




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#488024; Package coreutils. Full text and rfc822 format available.

Acknowledgement sent to sergio <mailbox@sergio.spb.ru>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. Full text and rfc822 format available.

Message #20 received at 488024@bugs.debian.org (full text, mbox):

From: sergio <mailbox@sergio.spb.ru>
To: 488024@bugs.debian.org
Subject: Re: Bug#488024: cp preserves mode with --no-preserve=mode
Date: Tue, 01 Jul 2008 14:47:08 +0400
Jim Meyering wrote:

> Actually, now I'm convinced that is _not_ a bug, but rather the intended
> behavior, since "cp --no-preserve=mode ..." is equivalent to "cp ...",
> and cp's default behavior is to use the src permission bits (masked via
> umask) as the destination permission bits.

OK, and then what use case for cp --no-preserve=mode ?


-- 
sergio




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#488024; Package coreutils. Full text and rfc822 format available.

Acknowledgement sent to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. Full text and rfc822 format available.

Message #25 received at 488024@bugs.debian.org (full text, mbox):

From: Jim Meyering <jim@meyering.net>
To: sergio <mailbox@sergio.spb.ru>
Cc: 488024@bugs.debian.org
Subject: Re: Bug#488024: cp preserves mode with --no-preserve=mode
Date: Tue, 01 Jul 2008 21:53:05 +0200
sergio <mailbox@sergio.spb.ru> wrote:
> Jim Meyering wrote:
>
>> Actually, now I'm convinced that is _not_ a bug, but rather the intended
>> behavior, since "cp --no-preserve=mode ..." is equivalent to "cp ...",
>> and cp's default behavior is to use the src permission bits (masked via
>> umask) as the destination permission bits.
>
> OK, and then what use case for cp --no-preserve=mode ?

You may want to use it with -p, in order to preserve some
attributes, but not the "mode".




Added tag(s) wontfix. Request was from Benoît Knecht <benoit.knecht@fsfe.org> to control@bugs.debian.org. (Thu, 07 Jul 2011 07:51:03 GMT) Full text and rfc822 format available.

Reply sent to Benoît Knecht <benoit.knecht@fsfe.org>:
You have taken responsibility. (Thu, 07 Jul 2011 07:51:06 GMT) Full text and rfc822 format available.

Notification sent to sergio <mailbox@sergio.spb.ru>:
Bug acknowledged by developer. (Thu, 07 Jul 2011 07:51:07 GMT) Full text and rfc822 format available.

Message #32 received at 488024-done@bugs.debian.org (full text, mbox):

From: Benoît Knecht <benoit.knecht@fsfe.org>
To: 488024-done@bugs.debian.org
Cc: Michael Stone <mstone@debian.org>
Subject: Bug #488024: Not a bug (was: cp preserves mode with --no-preserve=mode)
Date: Thu, 7 Jul 2011 09:48:48 +0200
tag 488024 wontfix
thanks

As Jim explained, this behavior is not a bug:

Jim Meyering wrote:
> Actually, now I'm convinced that is _not_ a bug, but rather the
> intended behavior, since "cp --no-preserve=mode ..." is equivalent to
> "cp ...", and cp's default behavior is to use the src permission bits
> (masked via umask) as the destination permission bits.

Cheers,

-- 
Benoît Knecht




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Fri, 05 Aug 2011 07:33:31 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Apr 16 04:59:41 2014; Machine Name: beach.debian.org

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