title: From PHP/Apache, exec() or system() program as root: "sudo: unable to open audit system: Permission denied"
body: <p>I have been spending half a day trying to figure this out, and I've done a lot of research.  I'm also familiar with many of the existing discussions on this topic, such as this one:
  <a href="https://stackoverflow.com/questions/1598231/how-to-run-php-exec-as-root">How to run PHP exec() as root?</a></p>
  
  <p>Unfortunately, none of the suggestions I've found seem to work for me.</p>
  
  <p>First of all, I am writing something to a spec, so I can't really avoid doing this.  Also, all machines will exist on a private network that is not connected to the internet.  While it's important to have SOME security, it's mostly necessary to prevent mistakes.  My objective is to configure some "thin servers".  Via a PHP script, I need to be able to change the network config (static or DHCP) and restart networking.</p>
  
  <p>The first thing I tried was to write a C program that is SUID root.  It reads, modifies, and writes a network config file.  If I run it as a regular user, it works just fine and can access and modify a file owned by root.  But if I run it from a PHP script, I get access errors.  It appears that Apache prevents SUID root somehow.</p>
  
  <p>Based on suggestions from other discussions, I tried the "sudo" method.  Temporarily, I added this to /etc/sudoers: 
  apache  ALL=(ALL)       NOPASSWD: ALL</p>
  
  <p>The error I get is this:
  sudo: unable to open audit system: Permission denied</p>
  
  <p>According to this page in Russian, this is happening because systems like RHEL (I'm using Fedora) default to requiretty for sudoers.  So I added this line to /etc/sudoers:
  Defaults    !requiretty</p>
  
  <p>I still get the same error.
  sudo: unable to open audit system: Permission denied</p>
  
  <p>I'm completely stymied here.  That is, unless I want to run Apache itself as root, something that would be more inconvenient than anything else.</p>
  
  <p>Can anyone make any suggestions here?  I realize what I'm trying to do is weird.  And I bet some of you will point me to some existing system for remotely configuring Fedora machines (and now that I think of it, I'm going to go look into that right now).</p>
  
  <p>BTW, I am running SELinux, because that is how Fedora 15 is configured by default.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:<br>
  I found this tutorial:<br>
  <a href="http://www.cyberciti.biz/faq/howto-disable-httpd-selinux-security-protection/" rel="nofollow noreferrer">http://www.cyberciti.biz/faq/howto-disable-httpd-selinux-security-protection/</a></p>
  
  <p>Unfortunately, when I run "setsebool httpd_disable_trans 1", I get the error:<br>
  Could not change active booleans: Invalid boolean</p>
  
  <p>I also tried directly editing "/etc/selinux/targeted/booleans", which didn't exist, and restarting apache, but that didn't work either.</p>