Why scripts not run as root when setuid used on scripts?

If I have a file that has owner and group set to root, and setuid:

sudo chown 0:0 /var/www/file.sh
sudo chmod 4777 /var/www/file.sh

What could possibly be keeping apache (www-data) from running the file as root? I can verify that everything works as I want it to if I add www-data as a sudoer, but that’s the stupid thing to do.

I am simply working on a web interface for LAN where I use PHP to run a shell script. PHP is using the exec function. Again, everything works if I add www-data as a sudoer.

Help me understand!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.