GNU bug report logs - #25589
Probably a bug in cp

Previous Next

Package: coreutils;

Reported by: Francesco Asnicar <francescoasnicar <at> gmail.com>

Date: Tue, 31 Jan 2017 16:30:02 UTC

Severity: normal

Tags: moreinfo

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Francesco Asnicar <francescoasnicar <at> gmail.com>, 25589 <at> debbugs.gnu.org
Cc: Francesco Beghini <guardian399 <at> gmail.com>
Subject: bug#25589: Probably a bug in cp
Date: Tue, 31 Jan 2017 19:53:37 +0100
On 01/31/2017 12:18 PM, Francesco Asnicar wrote:
> Dear all,
> I'm facing a problem with the cp command when using the -a (or
> --preserve=all) parameter.
> The problem is that the ownership of either files and folders is not
> preserved.
> I did several tests in which I tried to used different options, like
> --preserve=all instead of using -a, -p, and --preserve=ownership.
> I tried different version of cp present in different OS, for instance, the
> version 8.21 on a Ubuntu 14.04 and the version 8.26 on Arch (update as
> today).
> The result, regardless of the version and OS is always the same, the
> ownership is not preserved.
> 
> Many thanks,
> Francesco

You did not provide an example, but I guess that you are running cp(1)
as a regular user.  From the documentation [1]:

  ‘-p’
  ‘--preserve[=attribute_list]’
     ...
     ‘ownership’
        Preserve the owner and group. On most modern systems, only users
        with appropriate privileges may change the owner of a file, and
        ordinary users may preserve the group ownership of a file only
        if they happen to be a member of the desired group.

[1] http://www.gnu.org/software/coreutils/cp

So on a normal GNU/Linux system, you have to run the command as the root
user in order to successfully preserve the ownership.  Thus said, it's not
the cp(1) utility which is enforcing that rule, but the kernel (for a
good reason, of course).

Did you fall over this aspect?

Thanks & have a nice day,
Berny





This bug report was last modified 6 years and 207 days ago.

Previous Next


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