Supouse I have a directory /opt/expe
and I want any user to create .txt files on it. I want any user to type something like this:
$ whoami
user1
$ export $file_name=my_txt_file
$ /opt/expe/create_file.sh
$ ls -cal /opt/expe
total 12
drwxr-xr-x 2 root root 4096 Jul 29 19:27 .
drwxr-xr-x 6 root root 4096 Jul 29 19:14 ..
-rwsr-sr-t 1 root root 65 Jul 29 19:29 create_file.sh
-rw-r--r-- 1 user1 root 0 Jul 29 19:27 my_txt_file.txt
I try this with a sudoer
$ whoami
user_sudoer
$ cat /opt/expe/create_file.sh
touch /opt/expe/$file_name.txt
chown $USER /opt/expe/$file_name.txt
$ chmod a+x /opt/expe/create_file.sh
$ chmod a+t /opt/expe/create_file.sh
$ chmod a+s /opt/expe/create_file.sh
$ chmod a+X /opt/expe/create_file.sh
Then with non-root user I obtained:
$ whoami
user1
$ export $file_name=my_txt_file
$ /opt/expe/create_file.sh
touch: cannot touch '/opt/expe/prueba_txt.txt': Permission denied
Can I do something like this. I want something like postgres SECURITY DEFINER
concept.
group
?chmod 775 /opt/expe
orchmod 777 /opt/expe
. Why should I learn about "postgres SECURITY DEFINER concept"? What parts of it do you need?