title: GetFACL/SetFACL from PHP
body: <p>I need to manage directory permissions via <a href="https://wiki.archlinux.org/index.php/Access_Control_Lists" rel="nofollow">ACL</a> on a linux box from PHP where we have setup a Windows share and mounted it on the local linux box. I'm looking for a way to get and set permissions for the directory within a PHP class that I can then use to interface with the frontend. I found some work by <a href="http://blog.subutux.be/2010/02/03/acl-viewer-in-php/" rel="nofollow">subutux back in 2010</a> - but not sure about the execution:</p>
  
  <pre><code>function getfacl($f){
    //inital parsing
    $facl = shell_exec("getfacl $f");
    $facl_ = explode("\n",$facl);
    //print_r($facl_);
    foreach ($facl_ as $line){
      // Getting creator
      if (!preg_match("/^# file.*/",$line) &amp;&amp; preg_match("/^#.*/",$line)){
      $facl_rule = explode(": ",$line);
      //print_r($facl_rule);
        if ($facl_rule[0] == "# owner"){
        $facl_output['owner'] = $facl_rule[1];
        } else if ($facl_rule[0] = "# group"){
        $facl_output['group'] = $facl_rule[1];
        }
    }
    return $facl_output;
  }
  </code></pre>
  
  <p>So, I have a two questions:</p>
  
  <ol>
  <li>Does the above get the job done for GetFACL and how would I go about running a SetFACL command?</li>
  <li>Are there any other known libraries for working with linux ACL from PHP?</li>
  </ol>