[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug#488024: cp preserves mode with --no-preserve=mode
From: |
Jim Meyering |
Subject: |
Re: Bug#488024: cp preserves mode with --no-preserve=mode |
Date: |
Sat, 28 Jun 2008 09:42:33 +0200 |
sergio <address@hidden> 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 <address@hidden>
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 <address@hidden>
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
- Re: Bug#488024: cp preserves mode with --no-preserve=mode,
Jim Meyering <=