Книга: Fedora™ Unleashed, 2008 edition
Understanding Set User ID and Set Group ID Permissions
Understanding Set User ID and Set Group ID Permissions
Another type of permission is "set user ID" (suid) and "set group ID" (sgid) permissions. These settings, when used in a program, enable any user running that program to have program owner or group owner permissions for that program. These settings enable the program to be run effectively by anyone, without requiring that each user's permissions be altered to include specific permissions for that program.
One commonly used program with suid permissions is the passwd
command:
$ ls -l /usr/bin/passwd
-rwsr-xr-x 1 root root 25604 2007-04-05 09:54 /usr/bin/passwd
This setting allows normal users to execute the command (as root) to make changes to a root-only accessible file, /etc/passwd
.
You also can assign similar permission using the chfn
command. This command allows users to update or change finger
information in /etc/passwd
. You accomplish this permission modification by using a leading 4
(or the mnemonic s) in front of the three octal values.
NOTE
Other files that might have suid or guid permissions include at
, rcp
, rlogin
, rsh
, chage
, chsh
, ssh
, crontab
, sudo
, sendmail
, ping
, mount
, and several UNIX-to-UNIX Copy (UUCP) utilities. Many programs (such as games) might also have this type of permission to access a sound device.
Files or programs that have suid or guid permissions can sometimes present security holes because they bypass normal permissions. This problem is especially compounded if the permission extends to an executable binary (a command) with an inherent security flaw because it could lead to any system user or intruder gaining root access. In past exploits, this typically happened when a user fed a vulnerable command with unexpected input (such as a long pathname or option); the command would bomb out, and the user would be presented a root prompt. Although Linux developers are constantly on the lookout for poor programming practices, new exploits are found all the time, and can crop up unexpectedly, especially in newer software packages that haven't had the benefit of peer developer review.
Savvy Linux system administrators keep the number of suid or guid files present on a system to a minimum. The find
command can be used to display all such files on your system:
# find / -type f -perm +6000 -exec ls -l {} ;
NOTE
The find
command is quite helpful and can be used for many purposes, such as before or during backup operations. See the section "Using Backup Software" in Chapter 13, "Backing Up."
Note that the programs do not necessarily have to be removed from your system. If your users really do not need to use the program, you can remove execute permission of the program for anyone. You have to decide, as the root operator, whether your users are allowed to, for example, mount and unmount CD-ROMs or other media on your system. Although Linux-based operating systems can be set up to accommodate ease of use and convenience, allowing programs such as mount
to be suid might not be the best security policy. Other candidates for suid permission change could include the chsh
, at
, and chage
commands.
- SET TERM больше не нужен в isql
- Разработка приложений баз данных InterBase на Borland Delphi
- Open Source Insight and Discussion
- Introduction to Microprocessors and Microcontrollers
- Chapter 6. Traversing of tables and chains
- Chapter 8. Saving and restoring large rule-sets
- Chapter 11. Iptables targets and jumps
- Chapter 5 Installing and Configuring VirtualCenter 2.0
- Chapter 15. Graphical User Interfaces for Iptables
- Chapter 16. Commercial products based on Linux, iptables and netfilter
- Appendix A. Detailed explanations of special commands
- Appendix B. Common problems and questions