Running shell scripts as root in php?
<p>I am trying to write a php script to add users to an LDAP. To this end I have a shell script, aptly titled "addldapuser.sh", that will take in user/screenname/password combinations and add them to the LDAP. This script works properly. We would like users to be able to enter their information on a web form, which will then invoke said script and add the user to the LDAP properly. The addldapuser script currently needs to be run as root, and while I am aware of the security concerns, they can be dealt with later. I have tried everything I can think of or find, gave everything every permission I could think of, gave everything I could root, mucked around with Apache for awhile, and now I am out of ideas.</p>

<pre><code>$scrName = $_POST['screenname'];
$usrName = $_POST['username'];
$pass = $_POST['password'];

if (isset($_POST['submit']))
{
    $out =  nl2br(shell_exec("sudo /EasyLDAP/old_scripts/addldapuser.sh " . $usrName . " " . $scrName . " " . $pass));

}
</code></pre>

<p>Once again, I know this is just a terrible, terrible idea that is guaranteed to end in hackers destroying us all forever, but my boss wants me to at least make it function this way.</p>

<p>I do know that we should at least sanitize the input, and that will be taken care of in due time.</p>
