unable to run script with owners privileges even after setuid bit is set and o+rx is provided
Hi, I have created a script with user Shyam and provided r-x to other and set the setuid bit for this file.
-rwsrwxr-x. 1 shyam shyam 53 Nov 26 14:43 shyam.sh
Script contains below :
echo Hello $USER
echo date
Hello $USER >> test.txt
shyam is able to run this but when yesh user runs the script 1st line gets executed but on 2nd line it says permission denied. Attaching a screenshot with some details. I am not sure what am I missing here in order to achieve -> yesh to successfully run the entire script. enter image description here
this has been asked and answered before, the gist being:
Linux ignores the setuid bit on all interpreted executables (i.e. executables starting with a #! line). The comp.unix.questions FAQ explains the security problems with setuid shell scripts. These problems are of two kinds: shebang-related and shell-related; I go into more details below.