How to reliably keep network share connected for a specific user using automount?
Solution 1:
Assuming you do NOT want to enable the "root" user login feature and loosen up file and directory permissions enough to potentially open up your system to a significant security attack vector (and I am assuming exactly that...), as of today, Feb 7, 2017, there is no way to accomplish what you describe :(
At least not for AFP / SMB / CIFS shares (those are the only three I have tested, you may have other luck with NFS volumes but I don't run those on my network so can't confirm).
There appears to be two potential root causes. One is that sometime around Yosemite, there was some modification to the difference between using direct vs. indirect automounting functionality that caused intermittent failures when an auto mounted share was accessed by more than one user.
As of Sierra, this functionality is completely broken since the owner of the special /Volumes directory was made to be the "root" user and that user will take over ownership automatically if another user is granted ownership of any folders or files in that directory at some point. Bugs have been filed, feel free to comment and share your outrage.
In the comment section over on this blog post discussing several examples of using automount (and a few of its limitations) user "Mark" provides a complete analysis of this issue with respect to sharing auto mounted folders across multiple users.
TL;DR - it was broken somewhere around 10.10 and despite being discussed across many forums Apple has not yet acknowledged the bug or committed to a fix.
I think there is something going on with 10.11 that breaks the procedure > for mounting AFP shares into user directories. I am trying to mount afp://user:[email protected]/Music to /Users/me/Test
auto_master has the line: /- auto_afp -nosuid
auto_afp has the line: /Users/me/Test -fstype=afp afp://serveuser:[email protected]/Music
The server mounts beautifully, but clicking on the server icon in /Users/me gives the error “The folder “Test” can’t be opened because you don’t have permission to see its contents.”
After working the problem through, I see that this is a permissions problem. The mount point has the owner and group and permissions: drwx——@ 1 root wheel 364 31 Dec 10:01 Test (Actually, it’s interesting — if I empty out my auto_afp file and reboot, this returns to a regular directory with owner/group/permissions drwx——+ 18 me staff 612 31 Dec 10:01 Test)
So the problem here is that autofs is mounting the share with root privilege, and my user cannot actually use the share. From my reading on the web, this appears to be a relatively new problem — perhaps El Capitan related?
For comparison, when I do the following (as a user, not as a system user or using ‘sudo’): Create a new folder from the finder at /Users/me called ‘Test3′ then from the terminal enter: mount -o nosuid -t afp afp://serveuser:[email protected]/Music /Users/me/Test3
then the server mounts beautifully (albeit with the finder name “Music”, which I would prefer to change), and has the following user/group/permissions: drwx——@ 1 me staff 364 31 Dec 10:21 Test3 and I am able to see and manipulate the contents.
So in summary, the problem is: How can I get autofs to mount a network AFP share and map it into a user directory so that the user can access it and manipulate its contents? Historically, I think this is exactly how autofs is supposed to work, but it seems that the ownership of the mapped folder by ‘root wheel’ prevents it now from being of any real use.
One more matter, while I’m at it: I have fallen back to the simple goal outlined above, but my longer-term goal is to map an external music folder to EACH user. auto_afp should look like this:
/Users/me/Test -fstype=afp afp://serveuser:[email protected]/Music /Users/her/Test -fstype=afp afp://serveuser:[email protected]/Music /Users/him/Test -fstype=afp afp://serveuser:[email protected]/Music
I know that I can make this mount in each users’ login items, but that’s not actually good enough to achieve my long-term needs. Long term, I need this folder mounted at boot by autofs to make it available for cloud backup.
User "Ben" commented, confirming this analysis and echoing that at least as of the time he shared his comment, there was no fix:
Using an indirect map doesn’t help either. This functionality seems to be fundamentally broken in OSX going back to at least Yosemite… I’ve dug through 3 years worth of posts of people having this same issue and as far as I can tell, there’s simply no way to share a mount point across users… what an huge, infuriating, unbelievable fail.
Thanks apple!
NOTE : I do not recommend this for any network so will not provide detailed instructions on how to do so here, but one other user on that same comment board indicated that enabling the root user login and using that to access his system would allow this to work as expected:
One option is to enable root, and logon as root. Once you do that it all starts working. Crap option, I know, but my use case is a media server on an isolated network. Only option until I can see until apple gets it head out of its arse.
This is strongly discouraged by everyone, Apple, Security Experts, etc so I do think it is a viable path around this problem. We will have to wait until Apple releases a fix.