Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have an encrypted disk image (sparsebundle) where all of my private documents are stored; I mount it to a custom mount point with:

mkdir -p /Users/gabriele/MyDocs
hdiutil attach /MyDocs.sparsebundle -mountpoint /Users/gabriele/MyDocs

Other users see the mounted disk image in the Finder window sidebar and maybe also on their Desktops (according to Finder preferences), but they cannot access the volume because of unsufficient privileges. In any case other users can eject the volume, and this is bad.

Is there a way to prevent other users from ejecting my volumes, or even seeing this volume if they don't have enough privileges to view its innards?

share|improve this question

1 Answer 1

To help make the mounted disk image less visible, you can run the SetFile command to make the volume's directory invisible. This will make the mounted disk image be less-obviously visible in the Finder sidebar for other users. Of course, this makes it less visible to you, too, but you can make an alias in the Finder to where the folder should be for you.

Run SetFile to make the mounted disk image image be invisible in the Finder:

SetFile -a V /Users/gabriele/MyDocs

Open the disk image location in the Finder:

open /Users/gabriele/MyDocs

Make an alias to make it easy for you to open the now-hidden MyDocs. Within the open Finder window, grab the folder icon in the top center where it says "MyDocs" and then drag that while holding down the Option+Command keys and release it on your Desktop, just not to /Users/gabriele, because you will need to rename the alias first, otherwise it will not let you copy it. So rename the dragged-off "MyDoc" to "MyDoc alias", then move it to /Users/gabriele or wherever you like. Now you should have the alias "MyDoc alias" to your hidden MyDoc directory, other users will not see it in the Finder sidebar.

Note: Xcode needs to be installed in order to use SetFile. Additionally, I had to relaunch the Finder on Lion for the mounted disk image to become invisible, try that if you can't get MyDoc to disappear.

Not sure how to prevent ejection, since anyone with access to Disk Utility, the mount command, etc. can see the path to it and un-mount it for you. However, making it invisible does lessen the need to make it un-ejectable, since it will not be in other users' faces in the Finder as an option to eject.

share|improve this answer
    
Thank you, I will give it a try and eventually get back… :) –  Gabriele May 4 '12 at 13:36
    
Ok, here I am after a test drive… if the directory is invisible it cannot be indexed nor searched by Spotlight: this is a huge drawback to me, because I have tons of documents in there. Furthermore, any unprivileged user to such Volume can still eject it, from the Finder if they toggle invisible files/directories to show up, or even from the command line prior easily identifying any mounted devices. There should be a way to prevent unmounting Volumes you don't have any access to, unless being root or listed among sudoers. Am I asking too much? :-) –  Gabriele May 5 '12 at 8:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.