File Permission with setuid enabled(rws).
File Owner: vaisakh
vaisakh@computer:~/me$ ls -l
total 4
-rwsr-xr-x 1 vaisakh vaisakh 60 May 3 17:05 vaisakh.sh
Switch to an another user var23
vaisakh@computer:~/me$ su var23
Password:
Rechecking the permission
var23@computer:/home/vaisakh/me$ ls -l
total 4
-rwsr-xr-x 1 vaisakh vaisakh 60 May 3 17:05 vaisakh.sh
Executable for var23 too
var23@computer:/home/vaisakh/me$ ./vaisakh.sh
Its vaisakh
total 4
-rwsr-xr-x 1 vaisakh vaisakh 60 May 3 17:05 vaisakh.sh
Checking the write permission.
Note: Only the vaisakh(owner) have write permission.
But since the s(setuid) is enabled, file will execute with owner(vaisakh)'s permission(rws).
( Means it will allow the 'var23' to write to the file )
var23@computer:/home/vaisakh/me$ vim vaisakh.sh
After the var23 edit the file, checking the file permission again.
var23@computer:/home/vaisakh/me$ ls -l
total 4
-rwxr-xr-x 1 var23 var23 67 May 3 17:09 vaisakh.sh
var23@computer:/home/vaisakh/me$
File content vaisakh.sh.
var23@computer:~/var23/Prometheus/me1$ cat vaisakh.sh
#!/bin/sh
echo "Its vaisakh"
ls -l
var23@computer:~/var23/Prometheus/me1$
Question:
- Couldn't understand why the ownership changes from vaisakh -> var23(permission too rws -> rwx) ?
- What is the minimum permission need by a file, to make use of setuid( let non-owner users to inherit owner permission )? Read-Execute(r_x) !
Does the setuid is only applicable for execute flag ?
Eg:- If the the actual file permission is 4711, non-owner user can't read it. Why its not elevating the owner permission 4711 and allow others to read the content.