我有兩個用戶tenghaooo和user1
首先用戶tenghaooo在自家目錄新創一個文字檔file
並將其權限改為640
-rw-r----- 1 tenghaooo tenghaooo 9 Feb 5 19:45 file
然後再編譯一個C檔 test.c,源碼如下
#include <stdlib.h>
int main(void) {
system("/bin/cat file");
return 0;
}
編譯後的a.out改其權限為4755
-rwsr-xr-x 1 tenghaooo tenghaooo 8304 Feb 5 20:04 a.out
最後切換用戶成user1,到tenghaooo家目錄裡執行a.out
結果無法成功看見file內容
/bin/cat: file: Permission denied
我以為由於a.out setuid bit的緣故,當user1執行a.out時,權限會變成tenghaooo
進而能夠看見file內容
但似乎不是如此
希望各位大大解說一下setuid bit的運作方式
謝謝,新年快樂
--
All Comments