Results 1 to 9 of 9

Thread: Allow user to perform one root comand without password request

  1. #1

    Default Allow user to perform one root comand without password request

    Hi,

    Opensuse 13.2, fully updated, KDE 4

    I sometimes have to mount a distant network drive.
    This I do with
    Code:
     mount -t cifs "//<network address>/partition" /mnt/mountpoint -o guest,rw,iocharset=utf8,file_mode=0777,dir_mode=0777
    I do that by becoming root (with su -) and then typing in that command, and giving the root password.

    For several reasons without importance here, it is not practical to include the equivalent line
    in /etc/fstab to have this automounted at startup.

    I would like normal users to be able to perform this command as well, without the need to type in
    the root password, nor their own password.

    Is that possible?

    I naively included the following line in the /etc/sudoers file, hoping that this would allow that:

    Code:
     username ALL= NOPASSWD: /sbin/mount, /usr/sbin/mount.fuse, /bin/mount, /sbin/mount.ntfs (and all other /sbin/mount.xxx)
    (I'm aware that this would give user "username" the power to use the mount command for all mount operations
    and not only the one described above).

    But I still get
    Code:
     mount: only root can use "--options" option
    as a result.

    Any help would be appreciated.

    Thanks in advance

    Lenwolf

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,153

    Default Re: Allow user to perform one root comand without password request

    Quote Originally Posted by lenwolf View Post

    For several reasons without importance here, it is not practical to include the equivalent line
    in /etc/fstab to have this automounted at startup.
    I do of course not know your "several reasons". But when you add the option noauto to the /etc/fstab entry, the system will not try to mount it at boot. So when your only reason is that it should not be mounted at boot (what you call "automounted"). that reason is nil.

    This will considarably shorten what you have to type when you want to mount it. E.g.:
    Code:
    mount /mnt/mountpoint
    will be sufficient.
    Henk van Velden

  3. #3

    Default Re: Allow user to perform one root comand without password request

    Hi Henk, Thank you very much for that piece of advice. However, that doesn't solve my problem, or does it? Would a normal user be able to issue the mount command without being prompted for any password? Thanks. Lenwolf

  4. #4
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,004

    Default Re: Allow user to perform one root comand without password request

    You're running the command without sudo, that's the problem.

    Sudoers file does not magically allow commands to be run arbitrarily, you need to run it with sudo your_cool_commands
    .: miuku #suse @ irc.freenode.net
    :: miuku@opensuse.org

    .: h​ttps://download.opensuse.org/repositories/home:/Miuku/

  5. #5

    Default Re: Allow user to perform one root comand without password request

    Quote Originally Posted by Miuku View Post
    You're running the command without sudo, that's the problem.

    Sudoers file does not magically allow commands to be run arbitrarily, you need to run it with sudo your_cool_commands
    Hi,
    this is one of those instances where you sit in front of your computer, read the answer you just got and hit your head on the table asking how could I not see that?
    Well, I couldn't...
    Thanks, your reply does the trick!

    Lenwolf

  6. #6
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,153

    Default Re: Allow user to perform one root comand without password request

    Quote Originally Posted by lenwolf View Post
    Hi Henk, Thank you very much for that piece of advice. However, that doesn't solve my problem, or does it? Would a normal user be able to issue the mount command without being prompted for any password? Thanks. Lenwolf
    Well, first step is to minimize the command and then of course sudo, properly configured, is able to let users use commands running "as root" with the root password, the user's password or no password.
    Henk van Velden

  7. #7

    Default Re: Allow user to perform one root comand without password request

    Quote Originally Posted by hcvv View Post
    Well, first step is to minimize the command and then of course sudo, properly configured, is able to let users use commands running "as root" with the root password, the user's password or no password.
    Yes, thank you!

    Lenwolf

  8. #8

    Default Re: Allow user to perform one root comand without password request

    Quote Originally Posted by lenwolf View Post
    Hi Henk, Thank you very much for that piece of advice. However, that doesn't solve my problem, or does it? Would a normal user be able to issue the mount command without being prompted for any password?
    Try adding the "user" mount option, then a plain user should be able to mount it without gaining root privileges.

    I don't know whether that works with Samba shares though, it doesn't with NTFS-3g e.g.

  9. #9
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Allow user to perform one root comand without password request

    On 2015-04-22 13:06, lenwolf wrote:
    >
    > Hi Henk, Thank you very much for that piece of advice. However, that
    > doesn't solve my problem, or does it? Would a normal user be able to
    > issue the mount command without being prompted for any password?


    Yes, you can mount something that is listed in fstab if it includes the
    option "user", as plain user without giving any password or having to
    use sudo.

    --
    Cheers / Saludos,

    Carlos E. R.

    (from 13.1 x86_64 "Bottle" (Minas Tirith))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •