sudo + mount = the most retard thing ever

Posted: 2012-02-24 in Linux

My demand of mount is the follow, I run a java webservice which I can get a job with a network share.
I mount, copy files locally, process then push the vfs back up the network (ext4).
Easy? well should be but mount is my demise.

The list of problems so far was growing daily until i folded and forced the system admin to provide two shares (source and destination) already setup. My dynamic solution is dead, but the project lives.

Some of the problems so far:

Error: mount mounts using root root and the user cannot write to the directory without using sudo, even though they used to own the directory.
Reason: Cause of security mount is only a sudo command. Not sure why mount isn’t unrestricted in user home folder.
Solution: mount man page, look for the uid and gid settings and file/dir modes.
In my case i used:
mkdir SourceMnt
sudo -s mount -w -o file_mode=0666,dir_mode=0777,rw,gid=domain_users,uid=domain_users,uid=yourUsername,password=yourpassword //192.168.1.x/myShare SourceMnt

Error: mount 112 permission denied
Reason: Can’t call mount directly using ProcessBuilder
Solution: Make a pass through bash script “$1 $2 $3 $4 $5” call this and pass mount as second arguement (or anything) using ProcessBuilder in which case I pass the mount commands.

Error: ProcessBuilder  NullPointerException (ok this isn’t mount but cause by the above)
Reason: Can’t have arguements ending or starting with a space
Solution: for loop over the commands and call trim over each (are you serious java)

Error: mount not found in fstab, this is the worse it locks the computer
Reason: Calling mount to frequently
Solution: Don’t. So I went from fully dynamic solution too expecting the system admins to setup two base network folders, the caller passes the other half I no longer call mount (best compramise so far) 

 

For more reading I’d like to refer to post: http://kmandla.wordpress.com/2007/03/08/howto-mounting-without-sudo/

Which summizes my problems quiet well.

 

Mount sucks, you need to be sudo but then to use it i need to be sudo also. seriously wtf.. no user can use this unless they are sudo.. great! yippy!

Another nail in the Linux/java coffin for me.

Cheers,
Choco

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s