Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Feb 2008 09:58:31 +0100
From:      Pietro Cerutti <gahr@gahr.ch>
To:        Jonathan McKeown <jonathan+freebsd-questions@hst.org.za>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: cp -p
Message-ID:  <47AC19B7.1040403@gahr.ch>
In-Reply-To: <200802081054.40808.jonathan%2Bfreebsd-questions@hst.org.za>
References:  <47AB48CF.1020804@gahr.ch> <47AB50FB.8020900@gahr.ch>	<6E924673-19E3-4CD2-9FE0-242E87FBE2D2@mac.com> <200802081054.40808.jonathan%2Bfreebsd-questions@hst.org.za>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig01C0FE66AEFD92CD93904E55
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Jonathan McKeown wrote:
> On Thursday 07 February 2008 20:07, Pietro Cerutti wrote:
>=20
>> HostServer exports via NFS /www, which belongs to user:www
>> (uid=3D1001, gid=3D80). The directory has the segid flag set:
>>
>> drwsr-xr-x  13 user www 512 Feb 7 00:58 www
>>
>> HostClient mounts the exported directory on /share/www. HostClient
>> doesn't know anything about gid 80.
>>
>> Now, on HostClient, user copies aFile to /share/www using the -p flag =
of
>> cp(1).
>>
>>> cp -p aFile /share/www/
>>> ls -l
>> -rw-------  1 user user  2981888 Feb  7 01:09 /www/aFile
>>
>> As shown, the setgid flag of /www hasn't worked.
>=20
> Hang on - you asked cp to preserve the user and group ownership of the =
file=20
> (cp -p). As far as I can see, it's done what you asked it to. I would r=
egard=20
> any other result as violating the Principle of Least Astonishment.

You are right. I thought that the setgid of the destination directory
had priority over the -p. If it's not the case, then this means that
mv(1) cannot be used across filesystems when one wants to ensure that
the setgid of the target directory does what it's supposed to do. From
man mv(1):

"As the rename(2) call does not work across file systems, mv uses cp(1)
and rm(1) to accomplish the move.  The effect is equivalent to:

           rm -f destination_path && \
           cp -pRP source_file destination && \
           rm -rf source_file
"

Note that mv invokes cp with the -p option. Is there any way to prevent
that?

> Jonathan


--=20
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp


--------------enig01C0FE66AEFD92CD93904E55
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (FreeBSD)

iEYEAREKAAYFAkesGbwACgkQwMJqmJVx946Z1gCfejL2QVfRjIPk2bfRqpmu79uc
JH4AoLJdORUyD1P8zYiQ00tif+7L/xhQ
=H68K
-----END PGP SIGNATURE-----

--------------enig01C0FE66AEFD92CD93904E55--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47AC19B7.1040403>