3

I have a script:

[postgres@LaHarch ~]$ cat mkrundir.sh 
#!/bin/bash
mkdir /run/postresql 

With attributes:

[postgres@LaHarch ~]$ ll mkrundir.sh 
-rwsr-sr-x 1 root root 74 Aug 26 18:53 mkrundir.sh

But when I run it I get:

[postgres@LaHarch ~]$ ./mkrundir.sh 
mkdir: cannot create directory '/run/postresql': Permission denied

Why SUID didn't help me? And what is best practice for such a task?

ilkkachu
  • 138,973
  • Setuid does not work on scripts, it is an intentional security setting. It is matter of taste, why is it so (in my opinion, it is meaningless paranoia, the solution would be not to disable setuid on all script, instead writing secure scripts). But it is so. You need to have other ways to run that script as root (my first suggestion would be: google for sudo). – peterh Aug 27 '19 at 08:28

0 Answers0