Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 232608 - net-fs/mount-cifs should have USE flags for setuid and for defining CIFS_ALLOW_USR_SUID
Summary: net-fs/mount-cifs should have USE flags for setuid and for defining CIFS_ALLO...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's SAMBA Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-21 23:15 UTC by Tanktalus
Modified: 2012-09-16 12:28 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Ugly fix to allow non-root mounting of CIFS shares when mount.cifs is SETUID root. (mount.cifs_enable_suid-set_user_mount.patch,280 bytes, patch)
2009-01-01 15:44 UTC, Johannes Truschnigg
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tanktalus 2008-07-21 23:15:43 UTC
The 3.0.28 ebuild does not set the setuid-bit for /usr/bin/{mount,umount}.cifs, nor is there an option to do so (so that I don't need to remember this again).

There should also be a USE flag for adding '-DCIFS_ALLOW_USR_SUID' to the build (as long as we're setting options).  Mind you, it could be argued that this would then warrant an ewarn block for how insecure this might be.

Finally, the symlinks that are created here should be relative to ${ROOT} or just to "../usr/bin/mount.cifs" instead of "/usr/bin/mount.cifs", like the other mount.* in /sbin.

I realise that the first option has been discussed before (bug 186383 and bug 210235).  However, I'm not sure why 210235 is closed - the requested feature is not upstream because upstream doesn't have an install function where setuid could be set.  Instead, it has to be the src_install function in the mount-cifs ebuild where we at the setuid bit to the files, and that is simply not happening now.  Something like:

use suid && fperms u+s /usr/bin/{mount,umount}.cifs

(untested) is about what we're looking for, at least for the first item.

Reproducible: Always

Actual Results:  
$ mount /mnt/mysambamountpoint
mount error 1 = Operation not permitted
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

Expected Results:  
$ mount /mnt/mysambamountpoint

[success]
Comment 1 Johannes Truschnigg 2009-01-01 15:44:36 UTC
Created attachment 177010 [details, diff]
Ugly fix to allow non-root mounting of CIFS shares when mount.cifs is SETUID root.

As of net-fs/mount-cifs-3.0.30, manually setting SUID on the resulting binary in /usr/bin does not make mounting with an UID!=0 work; check http://forums.gentoo.org/viewtopic-p-5355191.html#5355191 for details.

I tried to track down the problem, and it seems that mount.cifs improperly checks for permissions when called from a non-root account. Sadly, I do not have the time to investigate this to an extent that would enable me to provide a definite fix, but I managed to get it to work for me.
The attached patch details the approach I took - it's ugly, but it enables the functionality I need. I don't know if there's an impact on security, but I'd not be very surprised if there was, so please beware.
Comment 2 Klaas Decanniere 2009-03-11 18:34:46 UTC
(
> 
> I tried to track down the problem, and it seems that mount.cifs improperly
> checks for permissions when called from a non-root account. Sadly, I do not
> have the time to investigate this to an extent that would enable me to provide
> a definite fix, but I managed to get it to work for me.
> The attached patch details the approach I took - it's ugly, but it enables the
> functionality I need. I don't know if there's an impact on security, but I'd
> not be very surprised if there was, so please beware.

I haven't yet tried the patch, but I can mount a cifs filesystem as a normal user using the "suid,users" option.

However, I can't actually access the files below the mount point.

Permission is denied whatever I do.

Is reverting to a previous or later version a viable option?

the situation:

- the normal user owns the mount point, and the correct user name and group ID etc are specified in fstab
- mount, umount, mount.cifs is setuid root
- fstab entry is something like:
//host/share  /home/me/share \
cifs \
noauto,ro,username=remoteuser,uid=me,gid=mygroup,domain=WORKGROUP,suid,users 0 0

before and after the mount, ls -l shows that I own the mount point

After mounting permissions are drwxr-xr-x, which seems ok but does not allow me access
I also can't change that because the file system is ro. Mounting as rw still does not allow me to change it - I only get permission denied.




Comment 3 Klaas Decanniere 2009-03-11 18:39:14 UTC
(
> I haven't yet tried the patch, but I can mount a cifs filesystem as a normal
> user using the "suid,users" option.


That is net-fs/mount-cifs-3.0.30 on amd64, kernel 2.6.27-gentoo-r7, SMP, to be complete.
Comment 4 Nick Bowler 2009-04-27 17:56:59 UTC
A use flag to install mount.cifs / umount.cifs setuid would be very useful.  I currently have to manually chmod them every time the package is upgraded, and I'm usually reminded to do this by the complaints of my users: "damnit, you broke mount.cifs again!"
Comment 5 MageSlayer 2010-12-30 16:47:26 UTC
For those interested.
I added a patch for the latest samba to make suid work again.
It also enables any mounts user wishes to have instead of just listed in /etc/fstab. 
It is here - http://bugs.gentoo.org/show_bug.cgi?id=315445
Comment 6 Pacho Ramos gentoo-dev 2012-09-16 12:28:39 UTC
dropped