LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-25-2008, 12:07 AM   #1
Ghodmode
LQ Newbie
 
Registered: Feb 2007
Location: New Zealand
Distribution: Kubuntu
Posts: 11

Rep: Reputation: 0
Question SMB/CIFS mount: "only root can do that"


Does anyone know how to mount SMB shares as a normal user?

I want to mount a SMB share from a Windows XP box on my Linux (Kubuntu) box with an unprivileged user and without adding the mount point to fstab.

Here are the two commands I've tried:
Code:
mount -t cifs -o username=king,password=kong //xp/C\$ /home/ghodmode/xp/C\$
mount -t smbfs -o username=king,password=kong //xp/C\$ /home/ghodmode/xp/C\$
When I try this, I get the message mount: only root can do that. It works if I run the command with sudo.

I can use Smb4K to accomplish this task without providing my root or sudo password. When I look at the mount points while a share is mounted using Smb4K, I can see that the share is mounted as cifs, but I can't tell how it did it.

All of the related commands have the setuid bit set:
Code:
ghodmode@home:~$ ls -l /bin/mount /sbin/mount.smb /usr/bin/smbmount /sbin/mount.cifs
-rwsr-xr-x 1 root root  80568 2007-10-03 17:48 /bin/mount
-rwsr-xr-x 1 root root  22628 2007-12-18 20:28 /sbin/mount.cifs
lrwxrwxrwx 1 root root     17 2008-02-04 11:08 /sbin/mount.smb -> /usr/bin/smbmount
-rwsr-xr-x 1 root root 906292 2007-12-18 20:28 /usr/bin/smbmount
Thank you,
Ghodmode
 
Old 03-25-2008, 01:32 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Well, all the 'mount' programs are setuid - and this sets effective ID, but they always check caller uid. Smb4K is probably installed setuid and it switches to root real UID before calling mount. 'sudo strace -s 1024 -f -o log -x smb4k ...' may help - look for execve calls in log, you will see how it calls mount; *uid calls will show you what happens with UID. If you want to be able to mount Samba with even less root actions involved, you can try fusesmb. It uses "File system in Userspace" interface, and the only thing requiring root (and it is done by a setuid program you already have , fusermount) is connecting the purely userspace, unprivileged program processing Samba (and possibly exposed to protocol implementation exploits) to file system interface.
 
Old 03-27-2008, 05:23 PM   #3
pwalden
Member
 
Registered: Jun 2003
Location: Washington
Distribution: Raspbian, Ubuntu, Chrome/Crouton
Posts: 374

Rep: Reputation: 50
I use mount.cifs to mount ntfs drives whilst logged is as myself. I noticed you only have the suid bit set for user (root). Here is my ll:

Code:
[root@walden4 ~]# ll /sbin/mount*
-rwsr-sr-x 1 root root 23628 2007-12-10 08:19 /sbin/mount.cifs
-rwsr-xr-x 1 root root 55460 2007-09-17 12:15 /sbin/mount.nfs
Try chmod a+s /sbin/mount.cifs
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cifs "mount error 13 = Permission denied" CIFS SUCKS humbletech99 Linux - Networking 45 04-06-2020 05:31 AM
Cifs "mount error 5 = Input/output error" but smbfs works! humbletech99 Linux - Networking 36 12-18-2019 02:59 AM
difference between "service smb restart" and "/etc/rc.d/init.d/smb" powah Linux - Software 1 01-17-2007 05:17 PM
Cifs "mount error 11 = Resource temporarily unavailable" humbletech99 Linux - Networking 1 09-26-2006 12:04 PM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration