Results 1 to 7 of 7
Hi All,
I am a new bee facing problem with sudo -s option. I wanted to disble sudo -s option at all.
Ex: sudo ls
(should work)
where
sudo -s ...
- 01-19-2012 #1Just Joined!
- Join Date
- Jan 2012
- Posts
- 7
How to disable an option from command
Hi All,
I am a new bee facing problem with sudo -s option. I wanted to disble sudo -s option at all.
Ex: sudo ls
(should work)
where
sudo -s ls
(shouldnot work)
please help with your ideas.
- 01-19-2012 #2
Hi sasikantheda,
I am not sure it easy to disable an option for sudo. One way would be change the source code and than compile your own version of sudo. Another way would be to rename the sudo binary, replace it with a script that does nothing if executed with the option -s and else just passes everything on to the renamed binary. But both options seem rather ugly to me.
But why would you want to disable this option?
Regards,
DaanOS's I use: Debian testing, Debian stable, Ubuntu, Windows XP, Windows Vista
- 01-20-2012 #3Just Joined!
- Join Date
- Jan 2012
- Posts
- 7
Thank you Daan for sharing your ideas.
My problem is to limit the sudo user editing the visudo (/etc/sudoers).
This i have achieved by adding a line in /etc/sudoers as sudo user ALL = (ALL) , !/usr/sbin/visudo
But this can be by passed by using sudo -s (sudo user can now change the sudoers file).
so i thought to remove this option.
please help with your ideas.
- 01-20-2012 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,838
Well, as sudo -s means to run an interactive shell, how about listing that shell as a forbidden command, as well, in visudo? e.g.:
of course, this may break other things you want the sudo user to be able to do...just an idea. Daan's idea is good, too.Code:sudouser ALL = (ALL) !/usr/sbin/visudo sudouser ALL = (ALL) !/bin/bash
- 01-20-2012 #5Just Joined!
- Join Date
- Jan 2012
- Posts
- 7
Thank you atreyu for sharing your Idea
The code suudouser ALL = (ALL) !/bin/bash
solved by purpose.
Thanks a lot
- 01-20-2012 #6
This does not actually accomplish what you want.
Yes, it does not allow me to run sudo -s. But I could do:
If you are allowing a user to become root via sudo, they can do literally anything. If you do not want the user to be able to do absolutely anything, then they should not be able to sudo as root.Code:$ cp /bin/bash ~/my_bins/bash $ sudo ~/my_bins/bash # vi /etc/sudoers
The only actual way to prevent a user from editing the /etc/sudoers file is to ensure that they can never access an account that can write to the file.DISTRO=Arch
Registered Linux User #388732
- 01-20-2012 #7Linux Guru
- Join Date
- May 2011
- Posts
- 1,838
Yes, that's very true. There are other ways, too. I usually make the practice of having a list of sudo commands that a user can run versus a list of ones they can't.


Reply With Quote