Automatic opening a USB disk on Sun Ray
By user12625760 on Mar 25, 2008
One of my users today had a bit of a hissy fit today when she plugged in her USB thumb drive into the Sun Ray and it did nothing. That is it did nothing visible. Behind the scenes the drive had been mounted somewhere but there was no realistic way she could know this.
So I need a way to get the file browser to open when the drive is inserted. A quick google finds " "USB Drive" daemon for Sun Ray sessions" which looks like the answer. The problem I have with this is that it polls to see if there is something mounted. Given my users never log out this would mean this running on average every second. Also the 5 second delay just does not take into account the attention span of a teenager.
There has to be a better way.
My solution is to use dtrace to see when the file system has been mounted and then run nautilus with that directory.
The great thing about Solaris 10 and later is that I can give the script just the privilege that allows it to run dtrace without handing out access to the world. Then of course you can then give that privilege away.
So I came up with this script. Save it. Mine is in /usr/local which in turn is a symbolic link to /tank/fs/local. Then add an entry to /etc/security/exec_attr, subsisting the correct absolute (ie one with no symbolic links in it) path in the line.
Basic Solaris User:solaris:cmd:::/tank/fs/local/bin/utmountd:privs=dtrace_kernel
This gives the script just enough privileges to allow it to work. It then drops the extra privilege so that when it runs nautilus it has no extra privileges.
Then you just have to arrange for users to run the script when they login using:
I have done this by creating a file called /etc/dt/config/Xsession.d/utmountd that contains these lines:
pfexec /usr/local/bin/utmountd & trap "kill $!" EXIT
I leave making this work for uses of CDE as an exercise for the reader.