I have a bash file that I want to run with owner permissions when executed by a group user. So I set the file permissions with:
sudo -u owner_user chmod 4750 bash_script
The file then has the permissions:
-rwsr-x---. 1 owner_user group 6559 Mar 15 09:52 bash_script
The file contains the line:
cp other_folder/source_file other_folder/destination_file
When I run the file as a user that is member of the group but different from the file owner owner_user
, I get the following error message:
cp: cannot create regular file ´other_folder/destination_file´: Permission denied
The permissions of the files are:
-rw-r--r--. 1 owner_user group 4331 Mar 13 11:51 other_folder/destination_file
-rw-r--r--. 1 owner_user group 4331 Mar 13 11:51 other_folder/source_file
When I run bash_script from owner_user
with the command
sudo -u owner_user ./bash_script
I do not get the cp error message above.
I would expect owner_user
's permissions on other_folder/destination_file
to be applied when bash_script
is run regardless of who executes it, since suid is set on bash_script
. This doesn't seem to be the case though. Anyone who knows why?