SUID more explanation needed
by makupl from LinuxQuestions.org on (#4PX1S)
I'm trying to understand SUID functionality.
So what I try is to create script.sh which modifies let say file a.txt.
The script.sh is owned by specific user, let say test1 and group test1. Also file a.txt is same user and group. Now I do not allow to write for other users to file a.txt, however I set rws------ on script.sh (SUID is set)
File a.txt has permissions rwxr--r--. Now when I execute script.sh as user test2 I got permission error on a.txt.
I understood execution of script.sh is fired from user test2 but as it was run by user test1 who actually has write permisions to a.txt file.
Must be I understand it wrongly. I understood user test2 can't modify a.txt file directly but using script.sh may change accordingly if script.sh requires it.


So what I try is to create script.sh which modifies let say file a.txt.
The script.sh is owned by specific user, let say test1 and group test1. Also file a.txt is same user and group. Now I do not allow to write for other users to file a.txt, however I set rws------ on script.sh (SUID is set)
File a.txt has permissions rwxr--r--. Now when I execute script.sh as user test2 I got permission error on a.txt.
I understood execution of script.sh is fired from user test2 but as it was run by user test1 who actually has write permisions to a.txt file.
Must be I understand it wrongly. I understood user test2 can't modify a.txt file directly but using script.sh may change accordingly if script.sh requires it.