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

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 07 February 2008 20:07, Pietro Cerutti wrote:

> HostServer exports via NFS /www, which belongs to user:www
> (uid=1001, gid=80). 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.

Hang on - you asked cp to preserve the user and group ownership of the file 
(cp -p). As far as I can see, it's done what you asked it to. I would regard 
any other result as violating the Principle of Least Astonishment.

and on Thursday 07 February 2008 20:48, Chuck Swiger wrote:
> On Feb 7, 2008, at 10:42 AM, Pietro Cerutti wrote:
> > From HostClient:
> >> ls -al /share/
> >
> > drwxr-sr-x  4 User   www           512 Feb  7 19:23 www
> >
> >> touch /share/www/foo
> >> ls -l /share/www/foo
> >
> > -rw-r-----  1 user  www  0 Feb  7 19:39 /share/www/foo
> >
> > (group id works)
>
> Right, this is the BSD setgid semantics one would expect.

Surely the BSD way is always to inherit group ownership from the directory? 
setgid is only used on SYSV systems to emulate the BSD semantics on a 
per-directory basis - or have I got this completely wrong?

Jonathan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802081054.40808.jonathan%2Bfreebsd-questions>