LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   sudo: umount works, mount not works (https://www.linuxquestions.org/questions/slackware-14/sudo-umount-works-mount-not-works-818762/)

sasser 07-08-2010 03:29 PM

sudo: umount works, mount not works
 
Hello,

I've got a problem in doing sudo working for mounting things (e.g. usb pen or optic discs). Details:

The OS: Slackware 13.0

The response to sudo -l command:
Code:

User user1 may run the following commands on this host:
    (root) /sbin/shutdown -h now, /sbin/shutdown -r now
    (root) /usr/bin/less /var/log/syslog
    (root) /sbin/mount /dev/sda?, /sbin/umount /dev/sda?
    (root) /sbin/mount /dev/hdc, /sbin/umount /dev/hdc

The first two (shutdown and reading the syslog) works as sudo, but the problem appears when I try to mount an usb memstick or an cd/dvd disc. In my case, sda (sda1) is the memstick in /dev, which I can mount as root using su, mount /dev/sda1 /media/usb.

When I try to mount it using sudo mount /dev/sda1 /media/usb, doesn't work, I get the response:
Code:

Sorry, user user1 is not allowed to execute '/bin/mount /dev/sda1 /media/usb' as root on HOST1.
Firstly, I don't understand why the OS thinks user1 wants to execute /bin/mount when in sudoers is /sbin/mount.

If I use the full path sudo /sbin/mount /dev/sda1 /media/usb, still doesn't work:
Code:

Sorry, user user1 is not allowed to execute '/sbin/mount /dev/sda1 /media/usb' as root on HOST1.
Here user1 is not allowed to execute /sbin/mount as root, why? According to sudo -l should have this privilege.

But after I mount the /dev/sda1 using su, I can umount it using sudo umount /dev/sda1

What's wrong? Why the umount works and mount doesn't?

Thanks.

titopoquito 07-08-2010 03:51 PM

Quote:

Originally Posted by sasser (Post 4027664)
Hello,

I've got a problem in doing sudo working for mounting things (e.g. usb pen or optic discs). Details:

The OS: Slackware 13.0

The response to sudo -l command:
Code:

User user1 may run the following commands on this host:
    (root) /sbin/shutdown -h now, /sbin/shutdown -r now
    (root) /usr/bin/less /var/log/syslog
    (root) /sbin/mount /dev/sda?, /sbin/umount /dev/sda?
    (root) /sbin/mount /dev/hdc, /sbin/umount /dev/hdc

The first two (shutdown and reading the syslog) works as sudo, but the problem appears when I try to mount an usb memstick or an cd/dvd disc. In my case, sda (sda1) is the memstick in /dev, which I can mount as root using su, mount /dev/sda1 /media/usb.

When I try to mount it using sudo mount /dev/sda1 /media/usb, doesn't work, I get the response:
Code:

Sorry, user user1 is not allowed to execute '/bin/mount /dev/sda1 /media/usb' as root on HOST1.
Firstly, I don't understand why the OS thinks user1 wants to execute /bin/mount when in sudoers is /sbin/mount.

If I use the full path sudo /sbin/mount /dev/sda1 /media/usb, still doesn't work:
Code:

Sorry, user user1 is not allowed to execute '/sbin/mount /dev/sda1 /media/usb' as root on HOST1.
Here user1 is not allowed to execute /sbin/mount as root, why? According to sudo -l should have this privilege.

But after I mount the /dev/sda1 using su, I can umount it using sudo umount /dev/sda1

What's wrong? Why the umount works and mount doesn't?

Thanks.

As far as I know you have to type the commands exactly as they are used on the command line, in your example you are missing the last part, the mount point! Guess it will work if you try in your sudoers file "/sbin/mount /dev/sda1 /media/usb" instead or use wildcards like "/sbin/mount /dev/sda1 *".

DonnieP 07-08-2010 05:42 PM

Quote:

Firstly, I don't understand why the OS thinks user1 wants to execute /bin/mount when in sudoers is /sbin/mount.
Because /sbin is not in user1's path; you need to add it.

sasser 07-09-2010 03:01 AM

Quote:

Originally Posted by titopoquito (Post 4027676)
As far as I know you have to type the commands exactly as they are used on the command line, in your example you are missing the last part, the mount point! Guess it will work if you try in your sudoers file "/sbin/mount /dev/sda1 /media/usb" instead or use wildcards like "/sbin/mount /dev/sda1 *".

Yes, it worked, thanks.

Now I understand why the umount had worked and mount didn't in my initial setup.


All times are GMT -5. The time now is 06:39 PM.