0

I created two file , one abc.sh and another myfile . The content of abc.sh is :

#!/bin/bash
echo "hi" >> myfile

The current permission and owner for both file is: abc.sh : rwsrw-r-x owner -> main(user) main(group)

myfile : -rw-rw-r-- owner -> main(user) main(group)

Note : the setuid bit is set on abc.sh file.

Now , if login as user user2 and run abc.sh file as user2 who is not owner and does not belong to group . I expect the script to be run successfully and content to be updated in myfile ,since the setuid is set and script will run as user main. also myfile has write permission for main user .

However , I still get permission denied error ? What is the reason for it ? please , correct me if I am mistaken.

  • 2
    Read [this](https://unix.stackexchange.com/a/2910/108618) and maybe [this](https://superuser.com/q/440363/432690). – Kamil Maciorowski Feb 15 '21 at 19:09
  • As said in the answers linked by @KamilMaciorowski, Linux ignores setuid bit on scripts. If you really need to run the script setuid, you must use a binary wrapper like the one presented in the second link. – raj Feb 15 '21 at 19:19
  • Please don't mind me closing your question as a duplicate of a newer question (and not the other way around). [There is no penalty upon your account](https://meta.stackexchange.com/q/10841/355310). Treat it as maintenance. – Kamil Maciorowski Mar 16 '23 at 06:21

0 Answers0