Operating System - HP-UX
1851668 Members
3767 Online
104061 Solutions
New Discussion

Re: Adding a line to Sudo

 
SOLVED
Go to solution
Nancy_32
Occasional Contributor

Adding a line to Sudo

I created the users accounts. Now I need to let them mount and umount cdrom with sudo. What sould be the line to be use in this case. My device path is /dev/dsk/c1t2t0. Directory to mount it should be /SD_CDROM.

Thank you.
Nancy L.
6 REPLIES 6
Sundar_7
Honored Contributor
Solution

Re: Adding a line to Sudo

# vi /etc/sudoers
Cmnd_Alias MOUNT_UNMOUNT=/usr/sbin/mount,/usr/sbin/umount

user1 ALL=MOUNT_UNMOUNT
user2 ALL=MOUNT_UNMOUNT
#
Learn What to do ,How to do and more importantly When to do ?
Jeff_Traigle
Honored Contributor

Re: Adding a line to Sudo

I would do it more like this. I don't think you really want users being able to mount and unmount anything they want to try. :) And having the User_Alias makes administering the sudoers file a little tidier.


User_Alias MOUNT_USERS=user1,user2

Cmnd_Alias MOUNT_CMNDS=/usr/sbin/mount /dev/dsk/c1t2t0 /SD_CDROM,/usr/sbin/umount /SD_CDROM

MOUNT_USERS ALL=MOUNT_CMNDS
--
Jeff Traigle
Michael Tully
Honored Contributor

Re: Adding a line to Sudo

Depending on your version of sudo, as to where the file is and the right tool to edit 'sudoders'
Try:

# /opt/sudo/sbin/visudo

# /usr/local/sbin/visudo

Don't edit the file directly. Jeff's options are a very good guide.
Anyone for a Mutiny ?
Nancy_32
Occasional Contributor

Re: Adding a line to Sudo

Now, that I have added the suggested lines, the error is:

user: error in /etc/sudoers, line 18; TTY=pts/1 ; PWD= /home/user; USER=root

I am login as the user and the path I enter is: sudo /dev/dsk/c1t2d0 /home/user/SD_CDROM


The account was done with "users" as the primary group and the group account has the root permissions same as the lp, shutdown, etc......

See if you give me any suggestions.....
Jeff Schussele
Honored Contributor

Re: Adding a line to Sudo

Hi Nancy,

You must enter the command exactly as it is in the sudoers file. If there are multiple entries the command must match one of them.

EX:

sudo /usr/sbin/mount /dev/dsk/c1t2t0 /SD_CDROM

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Nancy_32
Occasional Contributor

Re: Adding a line to Sudo

Guys,

I thank you for your help. I was totally sucessful with all your help. Also, another option I added to the user was the following:

Script file called - /etc/mountcd
#!/bin/sh
sudo /usr/sbin/mount /dev/dsk/c1t2d0 /CDROM

and
file - /etc/umountcd

#!/bin/sh
sudo /usr/sbin/umount /CDROM

Changed permissions to /etc/mountcd and /etc/umountcd
chmod +X /etc/mountcd
chmod +X /etc/umountcd

It worked fine both ways.

Thanks,
Nancy L.