let's say there are to users A and B, belong to different group. and bot of them are not root
first, as user A.
1) touch a.txt; echo "hello word" > a.txt
2)chmod 600
3) touch b
4) echo "cat a.txt" > b
5) chmod 4755 b
and then switch to user B, my assumption is user B can successfully run the binary and get the greeting "hello word", but when I actually run the binary as User B, I got "permission denied". so why?
Linux does not implement the handling of the S_ISUID
bit of script files; instead, the mode bits of the interpreter (shell) are used.
The concept of setuid
files means that if you have the setuid bit
turned on on a file, anybody executing that command (file) will inherit the permissions of the owner of the file.
$ chmod 4755 b --verbose
mode of `b' changed to 4755 (rwsr-xr-x)
I suspect user A and B belong to seperate groups, so you need to do setgid
also. This can be done by adding 2, for both setuid and setgid add to get 6.
$ chmod 6755 b --verbose
mode of `b' changed to 6755 (rwsr-sr-x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.