I want to set up a 'file sharing' area on my server machine where two users can both easily read and write files. I want this to be an NFS mount on both users' machines so it's just an 'ordinary' directory as they see at and it can also be mounted as a VirtualBox shared drive.
Ideally I'd like the shared area to be owned by a third user, i.e. the two users reading and writing files are, say, 'fred' and 'bert' while the shared area is owned by 'shared'.
Is there any way to set up NFS so that if fred writes a file to the area owned by 'shared' it automatically becomes owned by shared and similarly for bert? I don't really want to end up with shared's files owned by all sorts of different users.
It would be fairly trivial to set up the shared area to have general write permissions for everyone but it would still be only too easy for either fred or bert to write files there that wouldn't then be writeable by the other users.
I guess I essentially want both fred and bert to become user shared when they do anything in shared's file system.
On Sun, Dec 13, 2009 at 10:48:07PM +0000, Chris G wrote:
I want to set up a 'file sharing' area on my server machine where two users can both easily read and write files. I want this to be an NFS mount on both users' machines so it's just an 'ordinary' directory as they see at and it can also be mounted as a VirtualBox shared drive.
Ideally I'd like the shared area to be owned by a third user, i.e. the two users reading and writing files are, say, 'fred' and 'bert' while the shared area is owned by 'shared'.
Is there any way to set up NFS so that if fred writes a file to the area owned by 'shared' it automatically becomes owned by shared and similarly for bert? I don't really want to end up with shared's files owned by all sorts of different users.
It would be fairly trivial to set up the shared area to have general write permissions for everyone but it would still be only too easy for either fred or bert to write files there that wouldn't then be writeable by the other users.
I guess I essentially want both fred and bert to become user shared when they do anything in shared's file system.
... and the answer can be found at the end of the 'exports (5)' man page:-
anonuid and anongid These options explicitly set the uid and gid of the anonymous account. This option is primarily useful for PC/NFS clients, where you might want all requests appear to be from one user. As an example, consider the export entry for /home/joe in the example section below, which maps all requests to uid 150 (which is supposedly that of user joe).
EXAMPLE /home/joe pc001(rw,all_squash,anonuid=150,anongid=100)
It's *exactly* what I want.