![]() |
|
|
|
|
|
Psudo root!
By Chandrashekhar Bhosle <cnb@freeos.com>
A common problem faced is allowing non root users to dial and establish a connection to the Internet. An easy and safe solution with sudo, assuming you use wvdial, is to put the following line in /etc/sudoers. (syntax explained later) ALL ALL=/usr/bin/wvdial This allows any user to run the program wvdial with root privileges when the user runs sudo as sudo wvdial Note: sudo issues a password prompt where the password to be entered is that of the user running sudo. How does sudo make handing out root privileges more secure? sudo is more secure than other options because of the following reasons.
WorkingSudo works in the following manner. When invoked, it matches the real and effective uid and gid of the target user and (by default) prompts them to authenticate themselves using their own password. On authentication, it sets a timestamp, which allows the user to run sudo within a time period of 5 minutes (configurable) without needing to authenticate themselves again. To run sudo, the user must be listed in the file /etc/sudoers. If the user isn't listed in /etc/sudoers and attempts to run sudo, an email is automatically sent by sudo to the superuser. The users should ideally do a "sudo -l" to see whether they are allowed to run any commands on the host to avoid ticking off their system administrator. Some other useful flags to sudo would be -h to show a help screen -b to run the program in the background -u to run a program as a user other than root (Usage: sudo -u foo) The /etc/sudoers fileThe /etc/sudoers file is where you set the users as well as the programs they are allowed to run using sudo. It must only be edited using visudo(8) and ideally with the -s flag, which does strict syntax checking (sudo will not run if the /etc/sudoers contains errors) and also locks the file against multiple access. visudo does not require vi. An alternate editor can be set using the $EDITOR or the $VISUAL environment variable. The syntax of the sudoers file is extensively documented in the sudoers(5) man page, but it is quite confusing in the beginning. The important thing to remember is that the sudoers file contains two types of statements.
Alias can be of four types
Let's create a sample /etc/sudoers file using visudo -s We've setup the following simple aliases # User alias specification # Cmnd alias specification Now we put in the User Specification entries. # User privilege specification Note: ALL in the above entries is a reserved sudo word which causes all matches to succeed. Let us dissect the first entry root ALL=(ALL) ALL This entry is in the form of User_Spec Host_Spec=(Runas_Spec) Cmnd_Spec The first word root is the user who will run the command. The first ALL allows the user to run the command on any host. The next (ALL) allows any user to run the command. And finally, the last ALL allows the user to run any command. Thus it implies let root run on any host, as any user, any command. The Runas_Spec can be dropped when the required privileges are those of root, as the Runas_Spec defaults to root. Thus in the second line we see, ALL ALL=/usr/bin/wvdial This allows ALL users to run on any host, as root, the command wvdial. Finally the last line, TRUSTED ALL=SHUTDOWN, KILL Allows the users defined in the TRUSTED alias run on any host the commands defined in the SHUTDOWN and KILL alias. This line would effectively expand to, Let cnb, mayank, sacs run on ALL hosts as root the commands /sbin/shutdown, /sbin/halt, /bin/kill, /usr/bin/killall. These examples are very rudimentary. One can create very powerful rules by using the sudo supported features of regular expressions and shell wildcards to build convenient and secure access control lists. All these are extensively documented in the sudoers(5) man page. Security Concernssudo does numerous security checks before executing the requested command. It removes certain environment variables and checks the path for command spoofing. Yet, there are ways in which sudo access can be exploited to gain unauthorized root privileges if not carefully used. For example, the following entry lets a person change Apache's configuration. user ALL=/bin/rvi /etc/httpd/conf/httpd.conf Using this seemingly innocuous entry a user could read in the /etc/shadow file, edit it and elevate himself to root privileges. This is possible even after we have used vi in the restricted mode because vi itself is running as root and can read and write any file using :r filename and :w filename. Be very careful when you let a person write to a file. Be very sure that system files cannot be altered using the allowed access. Allowing the replacement of (updating) executables and libraries is a strict non starter. Beware of the danger of trojan introduction. sudo is free software distributed under the BSD license and can be downloaded at here. The sudo website contains extensive documentation and pointers to various resources concerning sudo. So grab sudo and get rid of those dangerous setuid programs and shared root passwords.
Other articles by Chandrashekhar Bhosle
Current Rating: [ 8.41 / 10 ]
Number of Times Rated: [ 22 ]
|
|
|
© 1998-2004 FreeOS Technologies (I) Pvt. Ltd. All rights reserved.
[Privacy Policy]
![]() |