Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mounting windows on Linux for non-root user

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I have Samba set up and can mount a windows directory succesfully. I
have 2 basic problems I need some help with:

1) The mounted share is owned by root but the user that needs r/w
permission only gets r/o. As I understand it the owner of a mount is
determined by the user who mounts it. How do I mount the share and
specify the owner as other then root in fstab? Which brings me to #2.

2) The share, in typical windows fashion, contains spaces and other
not alphabetic characters. I cannot come up with the correct syntax in
/etc/fstab to mount this share. I can do it with the mount command
using quotes but not in fstab.

For reference here is the mount command that works:

mount -t smbfs "//dap001/SHARE (D)" /mnt/DAP001-D password=xxxxxxxx

Can someone help with these problems? TIA.
 
To #1, the folder or file on the linux box is owned by 'root' and has privleges for "root,the owner, and the owner's group".

Therefore, if you look at the folder/file with "ls -l" you'll see the privilegs shown as (example)

ls -l passwd
-rw-r--r-- 1 root root 1234 Dec 10 06:28 passwd

'root' user and 'root' group are the owners.
The system user 'root' has "-rw", user 'root' has '-r-' (Read), and group user has '-r-' also. Bad example, since root appears too many times.



Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
oops... small error above, and a better example...

'ls -l openvpn'
-rwxr-xr-x 1 daver daver 303 Sep 24 14:03 openvpn

In this listing, user 'daver' gets "rwx" (read, write, execute... ignorethe first bit), group 'daver' gets "r-x", the "world" gets 'r-x'...

So back to your point. If the Samba client comes in as user "awingnut" and that user is supposed to have read/write, then you need to set the privilege on file "file.txt" to be

-rw-rw---- 1 awingnut sambausers 303 Sep 24 14:03 file.txt

This would be done with "chmod 660 file.txt"

If you wanted to make the file executable for "awingnut" do 'chmod 760 file.txt'

If you wanted to allow the "sambausers" group to have privlieges, to 'chmod 764 file.txt'

all of this would leave the file
-rwxrw-r--

Sorry to ramble and leave a bad description above... ignore it.

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
Thanks for the reply but I don't think you are understanding my problem. What I need to know is how to mount it as someone other then 'root'? How did you get 'daver' as the owner? I can only get 'root'. It accepts 'password=' but no matter what I use for 'user=' it still mounts with 'root' as the owner.

mount -t smbfs -o "user=doesntmatter,password=xxxxxx" "//dap002/SHARE (D)" /mnt/DAP001-D

I can't 'chmod' because I get an "operation not permitted" error. However, that shouldn't matter if I can get the right owner after mounting.
 
Please re-explain which machines are involved and WHERE THE MOUNTs are relative to these machines.

Are you mounting a shared folder on another Windows box via linux samba? How are your clients trying to access this mounted share?

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
Thanks for the reply.

I have an XP machine (dap001) with a partition that is shared. The XP share name is 'SHARE (D)'. It allows full access with the appropriate R/W password.

There is a Linux user that needs R/W access to that XP share on the Linux box. So I issue the following command:

mount -t smbfs "//dap001/SHARE (D)" /mnt/DAP001-D password=xxxxx

This mounts the share but since I issue the command as 'root', 'root' is the owner and permissions are 755.

drwxr-xr-x root root ....

The user gets R/O access. According to what I understand, whatever user mounts the share on Linux, is supposed to become the owner.

drwxr-xr-x someuser somegroup ....

The above is what I need after the mount.

Unfortunately, when I do:

mount -t smbfs -o "user=someuser,password=xxxxx" "//dap001/SHARE (D)" /mnt/DAP001-D

I still get:

drwxr-xr-x root root ....
 
hi,

Correct me if i'm wrong. You wan't to mount a windows share on linux as user?
Firs of all i would suggest you rename your XP-share to a name without spaces like "D" or "data" after this make you fstab like:

//dap001/data /mnt/dap001 smbfs noauto,rw,users,username=<name_of_XP-User>,password=xxx 0 0

noauto: means no mount at boot
rw: self_explaining
users: users are permitted to mount
username and password(OPTIONAL if not set it will ask for) are the account information from your XP-User who has acces to the shares.

The only thing you need to look for is that the localuser(the one you mount with) must be owner of the mount point. Otherwise it will fail.


hope this helps
 
There's the rub. I cannot rename the share. I also cannot put the share name in fstab because fstab doesn't seem to like quotes as the mount command does.

Is my user screwed? I thought POSIX compliance fixed problems like this.
 
use "visudo" command (without space.)
It will do it
mention the normal user as sudoers. Now sudoer can also mount the another file system other than root. only just u have to mention who will be sudoer.
 
For #1, the options you need to use are uid= and gid= to specify what ownership would look like under linux, the fmask and dmask options are useful too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top