setuid bit疑問 - Linux

By Thomas
at 2019-02-05T20:37
at 2019-02-05T20:37
Table of Contents
我有兩個用戶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的運作方式
謝謝,新年快樂
--
Tags:
Linux
All Comments

By Bennie
at 2019-02-07T20:42
at 2019-02-07T20:42

By Margaret
at 2019-02-09T03:44
at 2019-02-09T03:44

By Sierra Rose
at 2019-02-13T20:09
at 2019-02-13T20:09

By Joe
at 2019-02-17T14:18
at 2019-02-17T14:18

By Oscar
at 2019-02-18T15:19
at 2019-02-18T15:19

By Andy
at 2019-02-20T05:09
at 2019-02-20T05:09

By Hedda
at 2019-02-25T04:47
at 2019-02-25T04:47
Related Posts
docker容器內的NIS該如何讓其他Host連到

By Tristan Cohan
at 2019-02-05T17:03
at 2019-02-05T17:03
最近網路上找到能正常玩惡靈古堡2重製版的方法

By Yedda
at 2019-01-31T12:18
at 2019-01-31T12:18
透過VPN登入ssh

By Isabella
at 2019-01-29T21:01
at 2019-01-29T21:01
docker容器內的NIS該如何讓其他Host連到

By Jack
at 2019-01-29T20:06
at 2019-01-29T20:06
檔案名稱後面有*及@

By Irma
at 2019-01-29T10:05
at 2019-01-29T10:05