======Set Uid(suid)======
* 針對Binary檔案
* 檔案須有x的權限
* 設定setuid此檔案情況下,不是此檔案的擁有者而且有x權限,就可暫時取得擁有者的權限。
* 典型Linux案例/usr/bin/passwd一般使用者也可用passwd修改密碼,存取於/etc下(shadow)的檔案
#ls -l /usr/bin/passwd;ls -l shadow
-rwsr-xr-x. 1 root root 25304 Aug 22 2010 /usr/bin/passwd
---------- 1 root root 1348 Mar 29 10:51 shadow
現在就仿照passwd概念,套用到cat;看shadow檔案內容
#cp -p /bin/cat /home/andy/
#chmod 4711 /home/andy/cat
#ls -l /home/andy/cat
-rws--x--x 1 root root 48808 Mar 30 10:13 /home/andy/cat
#su - andy
$cd /etc
$/home/andy/cat shadow
======Set Gid(gid)======
* 針對Binary檔案
* 檔案須有x的權限
* 設定setgid此檔案情況下,不是此檔案的擁有者而且有x權限,就可暫時取得擁有者的權限。
* 也可針對目錄,其作用為目錄下的檔案或子目錄會繼承該目錄的群組權限。
* 典型Linux案例/usr/bin/locateSet Gid針對檔案概念和上一項的set uid是一樣的
#ls -l {/usr/bin/locate,/var/lib/mlocate/mlocate.db}
-rwx--s--x 1 root slocate 28184 Sep 4 2009 /usr/bin/locate
-rw-r----- 1 root slocate 3219420 Mar 30 04:02 /var/lib/mlocate/mlocate.db
另外還有針對目錄,目錄底下的檔案或子目錄會繼承群組擁有者
#mkdir /testD/
#chmod 777 /testD/
#chmod g+s /testD/
#cd /testD/
#su joe
jpe$touch joeF;exit
#su tea
tea$touch teaF;exit
#ls -l
-rw-rw-r-- 1 joe andy 0 Mar 30 18:54 joeF
-rw-rw-r-- 1 tea andy 0 Mar 30 18:54 teaFile
是不是都是繼承andy群組
======SBIT======
* 稱為黏著位元
* 針對目錄且也必須有x權限
* 設定好sbit情況下,此目錄允許任何使用建立檔案,但不管權限為何,都不允許刪除別人的檔案(除了root以外)。
* 典型Linux案例 /tmp目錄#cd /tmp
#touch rootFile;chmod 777 rootFile
#su andy
$echo "hello">rootFile
$cat rootFile
Hello
$ls -l rootFile
$-rwxrwxrwx 1 root root 6 Mar 30 18:34 rootFile
$rm -f rootFile
rm: cannot remove `rootFile': Operation not permitted