1

I wanna run some script with root priviliges but by apache user. So I added SUID bit to script file but this doesn't work as I expected.

Script file owner is root.

rwsr-xr-x  1 root  root  2438 paź  8 12:10 script.sh

When I run this from bash as root everything works fine... but when I run this as apache user(it's launched by svn hook post-coomit script runing as apache) I'm getting some permission denied messages.

This is strange to me or I misundestood the mining of SUID bit. (users will get file owner’s permissions as well as owner UID and GID when executing a file/program/command.)

So what is the difference. Should I add proper line to /etc/sudoers that will enable runing that script as root...

B14D3
  • 5,110
  • 13
  • 58
  • 82

1 Answers1

2

In most enviroments, bash scripts (and most other) cannot be run as SUID (due to severe security issues*).

If you only need a couple of commands run as root, you can edit /etc/sudoers to allow the apache process to run just those specific commands as root.

*http://www.vidarholen.net/contents/blog/?p=30

mulaz
  • 10,472
  • 1
  • 30
  • 37