PDA

View Full Version : sudo button



Wiles
9th February 2007, 05:18 PM
how would I make a sudo button? I want to allow a user to start and stop samba but she doesn't know much about command line. so how can I make a button on the taskbar that will run the command "sudo service smb start" when creating a button like this, it doesn't ask for her password or anything...

ViRMiN
9th February 2007, 06:04 PM
Create a script containing the commands you want. Change the ownership to root:<specialgroup> where <specialgroup> is a new group you create. Give the user secondary group membership to <specialgroup>, and then set-up your sudoers file to allow the <specialgroup> to run the script. Use the "Defaults" options to prevent authentication for the one command and for just that group.

If you need more info, I can detail it more. This should get you going though!

ViRMiN
9th February 2007, 06:06 PM
Forgot! Filepermissions 750 on the script (rwxr-x---) to allow "root" to edit, and the <specialgroup> to execute it ;) Everyone-else has no access, not even to read what it's for!

ViRMiN
9th February 2007, 06:10 PM
Thinking about this, be careful where you put the script! You don't want the directory permissions set to allow someone to overwrite it with something less savoury, especially if it's going to be run as root :O

Duli
9th February 2007, 06:16 PM
Hey, great! This is something Iīve always wanted to do, but never took the time to study!

I would like to do the same thing, but my idea is to open nautilus with root powers. I guess the way you described should work for this case, also, right?!

Thanks a lot!
Duli

ViRMiN
9th February 2007, 06:32 PM
I'd only do something like that on your own machine, and only for yourself!. Once you've got a root nautilus up you can do whatever you like!

Duli
9th February 2007, 06:48 PM
I'd only do something like that on your own machine, and only for yourself!. Once you've got a root nautilus up you can do whatever you like!

Yep! Thatīs the idea! Just for me!! Although I can work with command line, I canīt deny sometimes itīs much faster to simply open nautilus as root and copy files, changer their names, edit them and so on...

Wiles
9th February 2007, 09:16 PM
ok, also seems that the usb drive also stopped automounting. will this method work to mount and unmount, or is it better to fix the automount function?

ViRMiN
9th February 2007, 09:25 PM
Best to fix it... remember it having something to do with HAL policies but, I've had a fair few vodka's and can't remember what the cause was! :D :D :D

Wiles
9th February 2007, 09:33 PM
how to find what's the cause of the problem of the automount not working?

ViRMiN
9th February 2007, 10:05 PM
I was simply reading the recent posts on here and stumbled across the fix... have a read of this thread:

http://forums.fedoraforum.org/forum/showthread.php?t=136676&highlight=usb+mount

Duli
16th February 2007, 04:23 AM
Create a script containing the commands you want. Change the ownership to root:<specialgroup> where <specialgroup> is a new group you create. Give the user secondary group membership to <specialgroup>, and then set-up your sudoers file to allow the <specialgroup> to run the script. Use the "Defaults" options to prevent authentication for the one command and for just that group.

If you need more info, I can detail it more. This should get you going though!

Hello, how do you set up the specialgroup to execute the script in the sudoers file? What the entry would be like?

I've tried but was not lucky.

Thanks a lot.
Duli

ViRMiN
16th February 2007, 07:55 PM
Easiest way is creating a group in the GUI (System -> Administration -> Users & Groups), create it with whatever name you want (max 8 chars), e.g. smbctrl

Then using the same GUI, open the users account and add them to the smbctrl group. You want to replace <specialgroup> with %smbctrl in the /etc/sudoers file. Here's an example of the sudoers config:

=== 8< === 8< === 8< ===

User_Alias SMBCTRL=%smbctrl

Cmnd_Alias SMB=/etc/init.d/smbd stop, /etc/init.d/smbd start

SMBCTRL ALL=NOPASSWD:SMB

Defaults:SMBCTRL !authentication
Defaults:SMBCTRL !timestamp_timeout

=== 8< === 8< === 8< ===

This should work; though I am typing from memory here! :)

Duli
17th February 2007, 04:21 AM
Easiest way is creating a group in the GUI (System -> Administration -> Users & Groups), create it with whatever name you want (max 8 chars), e.g. smbctrl

Then using the same GUI, open the users account and add them to the smbctrl group. You want to replace <specialgroup> with %smbctrl in the /etc/sudoers file. Here's an example of the sudoers config:

=== 8< === 8< === 8< ===

User_Alias SMBCTRL=%smbctrl

Cmnd_Alias SMB=/etc/init.d/smbd stop, /etc/init.d/smbd start

SMBCTRL ALL=NOPASSWD:SMB

Defaults:SMBCTRL !authentication
Defaults:SMBCTRL !timestamp_timeout

=== 8< === 8< === 8< ===

This should work; though I am typing from memory here! :)

Hello, thanks for the help. I'll try that. If i have any trouble, I'll sure scream for help!1 :)