cp -p

Pietro Cerutti gahr at gahr.ch
Thu Feb 7 18:07:20 UTC 2008


Hi list,

here's the situation:

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.

Now in man cp, I can read the following:

"If the source file has its set-user-ID bit on and the user ID cannot be
preserved, the set-user-ID bit is not preserved in the copy's
permissions.  If the source file has its set-group-ID bit on and the
group ID cannot be preserved, the set-group-ID bit is not preserved in
the copy's permissions. If the source file has both its set-user-ID and
set-group-ID bits on, and either the user ID or group ID cannot be
preserved, neither the set-user-ID nor set-group-ID bits are preserved
in the copy's permissions."

I cannot find anywhere information such as "If the /*destination*/ file
directory has its set-group-ID bit on and the group-ID cannot be
preserved, the set-group-ID bit is not preserved in the copy's permissions."

Assuming that this is the correct and expected behavior, why is it like
this?

Thank you,


-- 
Pietro Cerutti

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080207/8384be3e/signature.pgp


More information about the freebsd-questions mailing list