mount fails when run as sudo

nkalister
Valued Contributor

Hi list, I feel like a complete idiot that I have to ask about this, but that's the reality of this Friday afternoon! :)
I'm working on a script to automatically backup Sophos Safeguard's kernel and authentication information after a machine has been encrypted. I've got a network share setup with guest access, and the script works when run as the user. However, when casper runs it as root, the mount command for the network share fails with an authentication failed message. I've also tried specifying a user and password in the mount command that are valid, and it still fails when run as root. Anyone know if this is an OS X bug or ?
The mount command is just your garden variety:
mount -t smbfs //Guest at ussccitdemac/Sophos /Volumes/Sophos

nick
--
Nick Kalister
Desktop Engineering
Hitachi Data Systems
Office: 408.970.4316

750 Central Expressway
Building 32 : M/S 3240
Santa Clara, CA 95050

11 REPLIES 11

tlarkin
Honored Contributor

You running Lion? I read that root fails to mount network shares in Lion. so that may or may not be applicable to your situation. I had issues with some of the mount commands myself a few years back and did an Apple Script instead, but my script had to mount a file share then launch an application that had to connect to that file share, here is the example code:

tell application "Finder"

mount volume "smb://user:password@myserver.com/sharepoint"

delay 10 repeat 25 times if (exists "sharepoint") then do shell script "open -a myapp" exit repeat

end if delay 2 end repeat end tell

tlarkin
Honored Contributor

It was on the Mac Enterprise list either this week or last week

nkalister
Valued Contributor

Yep, lion. 10.7.2
Any links to what you were reading about this? I googled, but did not see anything related.
nick
--
Nick Kalister
Desktop Engineering
Hitachi Data Systems
Office: 408.970.4316

750 Central Expressway
Building 32 : M/S 3240
Santa Clara, CA 95050

nkalister
Valued Contributor

Found the discussion. The only workaround right now is to use the –i switch to prompt for a password. Needless to say, that's not going to help for a script run from a casper policy. I'm going to try this as an applescript for now, but I'm wondering- is there anyway to have casper execute a script NOT as root?
nick
--
Nick Kalister
Desktop Engineering
Hitachi Data Systems
Office: 408.970.4316

750 Central Expressway
Building 32 : M/S 3240
Santa Clara, CA 95050

tlarkin
Honored Contributor

I feature requested this about a month ago to have a policy run as the
currently logged in user. I suggest you deploy this as a launch daemon
or a launch agent.

-Tom

bentoms
Release Candidate Programs Tester

It was on the Mac Enterprise list.

Regards,

Ben.

tomt
Valued Contributor

Here's a link to the archive of the thread.

http://lists.psu.edu/cgi-bin/wa?A2=ind1110&L=macenterprise&T=0&F=&S=&P=241791

------------------------------
Tom Tubbiola
Special Technical Services (STS Team)
Ttubbiola at oakley.com
949.900.7705

sean
Valued Contributor

You can run a command as anyone you like from root:

su [username] -c [command]

For what it's worth, we run executable mount maps from a yp server using nfs, which is all automatic. This all works with Lion as expected (in terminal). There is a bug with Finder at the moment, but it is workable. If you think this is something you could or would want to implement then I can provide more details, but I'm going to guess that like most users on here you live in a windows environment, although potentially still possible!

Sean

tlarkin
Honored Contributor

Apple scripts you can save as apps and add to a user's start up items.

-Tom

bentoms
Release Candidate Programs Tester

+1

Regards,

Ben.

nkalister
Valued Contributor

yeah, did this in applescript, saved as an app.