Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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...

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.