The "set user id"-bit (or setuid-bit) is a potentially dangerous permission type. Wrong usage of setuid can result in unauthorized access to your system.
When a setuid bit is set to an executable, the script will be executed as if it was executed by the owner of the file. So for example this script has a setuid bit set:
$ ls -l myscript.sh
-rwsr-xr-x 1 root wheel 200 Nov 5 10:47 myscript.shImagine that this script contains the command "reboot"; in that case anybody would be able to reboot the machine.
Very easy:
# chmod 4755 myscript.sh# chmod u+s myscript.shHere is a small demonstration, first showing that a user can't write to /etc/passwd.
$ echo "foo bar" >> /etc/passwd
-bash: /etc/passwd: Permission denied# chmod u+s /bin/echo$ echo "foo bar" >> /etc/passwd
$See the dangerous situation we have just created? Undo it by executing # chmod u-s /bin/echo.
# find / -perm -4000| About | Consultancy | Articles | Contact |
|
|
|
|
|
| References | Red Hat Certified Architect | By Robert de Bock | Robert de Bock |
| Curriculum Vitae | By Fred Clausen | +31 6 14 39 58 72 | |
| By Nelson Manning | robert@meinit.nl |