LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Mounting SMB shares as non-root (https://www.linuxquestions.org/questions/linux-software-2/mounting-smb-shares-as-non-root-423546/)

vxd 03-10-2006 11:36 AM

Mounting SMB shares as non-root
 
Running slackware 10.2 and I occasionally connect to a windows VPN and need access to shares. As root, I can enter the following and I have access as I would expect

Code:

smbmount //server/myfolder /mnt/share1 -o username=DOMAIN\\myname,password=mypass
If I do the same with my regular user, I get this error message:
Code:

cannot mount on /mnt/share1: Operation not permitted
smbmnt failed: 1

What am I doing wrong?

Thanks,
Tom

tomdkat 03-10-2006 12:15 PM

Nothing really. Usually, root access is required to mount anything. When you attach USB devices that get mounted automagically, some process with root authority is doing the mount on your behalf.

One thing you can try is use "sudo" to run the smbmount command. Not being able to run smbmount might seem like a pain in the a**, but from a security perspective not allowing regular users to mount devices is a good thing, at least IMO. :)

Peace...

vxd 03-10-2006 12:40 PM

Anything I could do in fstab to make this an easier process? Mounting 10 shares by typing all those isn't exactly "friendly". Note that I have no problem with my users having access (that is what I want).

Thanks,
Tom

tomdkat 03-10-2006 12:50 PM

Quote:

Originally Posted by vxd
Anything I could do in fstab to make this an easier process? Mounting 10 shares by typing all those isn't exactly "friendly". Note that I have no problem with my users having access (that is what I want).

Yep, you can do something like this:

Code:

//server/myfolder /mnt/share1 smbfs username=DOMAIN\\myname,password=mypass 0 0
The first zero is the 5th field in fstab:
Quote:

Originally Posted by fstab manpage
The fifth field, (fs_freq), is used for these filesystems by the
dump(8) command to determine which filesystems need to be dumped. If
the fifth field is not present, a value of zero is returned and dump
will assume that the filesystem does not need to be dumped.

The second 0 is the sixth field:
Quote:

Originally Posted by fstab manpage
The sixth field, (fs_passno), is used by the fsck(8) program to deter-
mine the order in which filesystem checks are done at reboot time. The
root filesystem should be specified with a fs_passno of 1, and other
filesystems should have a fs_passno of 2. Filesystems within a drive
will be checked sequentially, but filesystems on different drives will
be checked at the same time to utilize parallelism available in the
hardware. If the sixth field is not present or zero, a value of zero
is returned and fsck will assume that the filesystem does not need to
be checked.

See what that does. I've done this kind of thing in the past and it worked fine, except I don't think I specified the DOMAIN\\name in entry.

Peace...

vxd 03-10-2006 01:16 PM

Added this to fstab via root:

Code:

//server/myfolder /mnt/share1 smbfs username=DOMAIN\\myname,password=mypass 0 0
I logged out and logged in as my linux user. Then did a:

Code:

mount /mnt/share1
mount: only root can mount //server/myfolder on /mnt/share1

So it seems that I'm still required to be root. Willing to try anything at this point =/ Thanks for the help so far.

Tom

uselpa 03-10-2006 01:25 PM

You need to make `smbmnt` setuid root in order to have normal users do the mount.

vxd 03-10-2006 01:36 PM

Quote:

Originally Posted by uselpa
You need to make `smbmnt` setuid root in order to have normal users do the mount.

Not familiar with a command "setuid", but from what I read, the command "chmod u+s /usr/bin/smbmnt" does this. I did and I receive the same error. That command is correct right?

Tom

uselpa 03-10-2006 01:43 PM

From `man smbmnt`:
Quote:

smbmnt can be installed setuid root if you want normal users to be able to mount their SMB
shares.

A setuid smbmnt will only allow mounts on directories owned by the user, and that the user has write
permission on.
So I guess your user isn't the owner of the mount point?

tomdkat 03-10-2006 02:55 PM

Quote:

Originally Posted by uselpa
So I guess your user isn't the owner of the mount point?

Looks like each /mnt/shareX mount point will need to be owned by each user who will be mounting SMB shares.

When I setup fstab to mount SMB shares, I wanted it to be done at boot time and not on-demand.

As a test. make /mnt/share1 owned by your userid and see if you can mount it on-demand.

Peace...

uselpa 03-10-2006 03:22 PM

Quote:

Originally Posted by tomdkat
When I setup fstab to mount SMB shares, I wanted it to be done at boot time and not on-demand.

In that case, there's no problem because root will mount the shares. But that is not what the OP wanted.

Another way of mounting on demand without the problem you mention is using sudo.

tomdkat 03-10-2006 03:43 PM

Quote:

Originally Posted by uselpa
In that case, there's no problem because root will mount the shares. But that is not what the OP wanted.

Yep, I didn't figure out that he wanted his users to be able to do the mounts themselves, on-demand, until later on. :)

Quote:

Another way of mounting on demand without the problem you mention is using sudo.
Myabe put the sudo command in a script so the users type a command link "winmount [sharename]" and that share is mounted via sudo under the covers?

Additionally, if superuser access is required to mount the SMB share, I imagine there might be some permissions issues that would need to be worked out after the share is mounted. The user mounting the share might want read/write access to it.

Peace...

vxd 03-10-2006 07:47 PM

Quote:

Originally Posted by uselpa
From `man smbmnt`:


So I guess your user isn't the owner of the mount point?

Bingo! Totally forgot. Thanks a ton!

Tom


All times are GMT -5. The time now is 03:58 AM.