I have a file owned by "root" and script owned by "non-root" user. I'm trying to change permission of "root" owned file using "non-root" script and getting below error:
$ cat root_file
echo "HELLO WORLD"
$ cat non_root_script
chmod 777 root_file.txt
$ ./non_root_script
chmod: changing permissions of 'abc.txt': Operation not permitted
I tried adding capabilities to the non_root_script but I'm still getting same error.
$ sudo setcap CAP_FOWNER+ep non_root_script
$ ./non_root_script
chmod: changing permissions of 'abc.txt': Operation not permitted
Are there any other capabilities that I need to provide, if so please suggest. Also I don't want to use "sudo chmod".