I'm currently working on a web based network authorization system which relies on DHCP to separate known and unknown clients into two different subnets. The authorized subnet has full access to all network resources, while the non-authorized subnet only has access to a single web paged hosted on that subnet.

This PHP page uses a class that I wrote to manipulate both the DHCP lease file, and configuration file. When the end user visits this page, and agrees to the terms, their hardware address is resolved by comparing their IP address to the DHCP lease file. Finally, this information is used to write a new host declaration into the dhcp configuration file, thus allowing them into the authenticated subnet.

Everything described above works exactly as planned; however, my problem is applying these changes. I need a way for the user that owns the web server (in my case "www-data") to be able to restart dhcp.

The restart process is a simple shell script that kills the pid, and removes the file containing the pid, both of these task require elevated privileges that i do not want to give to the user "www-data."

As the restart script is well... a script, setting the suid bit does not work. To my knowledge, the only way to do what I have in mind is to compile an executable, make its owner "root", and then set the suid bit on it.

Unfortunately, I haven't the slightest idea on how make bash (or any other shell for that matter) execute a script from a C program. Any help on this subject would be very helpful. Thanks.