I spent a weekend trying to get a client machine to automount a volume from the server via samba. I need three users on the client to be able to access (read/write) files on the server. I want to preserve the information about the file creator, so each user has his/her own login credentials for the server, — I don’t want to have just one user login for everyone. I need the volume to be mounted three times, each time for a different user with different login credentials. I need the mount point to well-defined — your traditional “connect to server” in Finder does not work to well, it uses
/Volumes as the mount location and then names each new volume mount sequentially, e.g.,
One solution that looked promising is to automount the volume into each of the users home directory under the user’s server login credentials. That volume would look like another folder with all files owned by the user. I looked over the
autofs guide and created a direct map file that looked like this:
/Users/user1/Media -fstype=smbfs,soft ://user1:email@example.com/Media /Users/user2/Media -fstype=smbfs,soft ://user2:firstname.lastname@example.org/Media /Users/user3/Media -fstype=smbfs,soft ://user3:email@example.com/Media
It looked like it was supposed to work. And it worked. For two users. For the third one, the mounted directory assumed root ownership and was unaccessible. I relaunched automount a few times and suddenly all three users can access their respective Media folders. I rebooted the client machine, now users 2 and 3 can see, mount, and use the folders, but user1 could not. I spent most of the day trying to figure out why the mounting was so unstable. Finally, I gave up on this approach.
My current solution, the one that seems to work reliably, is to create an indirect map for every user into a hidden folder somewhere on the startup disk
sudo mkdir /UsersVolumes sudo chflags hidden /UsersVolumes
add this to
/UsersVolumes my_indirect_map -nosuid
/etc/my_indirect_map looks like
user1 \ /Media -fstype=smbfs,soft ://user1:firstname.lastname@example.org/Media user2 \ /Media -fstype=smbfs,soft ://user2:email@example.com/Media user3 \ /Media -fstype=smbfs,soft ://user3:firstname.lastname@example.org/Media
I also put a soft link in every user’s home folder to the appropriate
cd /Users/user1 ln -s /UserVolumes/user1/Media chmod -h 0700 Media
The last line should ensure that only
user1 will be able to access the link and trigger the mount.