2009/4/3 <aurfalien@xxxxxxxxx>: > Hi all, > > For any one following this thread, here is how I worked around the > apache/php/chown limitation. > > script snippet (and if any one has a more elegant style, please share as I > am an amateur script kiddie). > > $path = "/homes".$username; > $chowncmd = "/usr/bin/sudo /bin/chown "; > mkdir($path); > chmod($path, 0775); > exec($chowncmd.$username. " ".$path); > > OK - you asked for style... ;) I personally think it's elegant to build such strings with sprintf() like.. $path = sprintf("/homes/%s", $username); or exec(sprintf("%s %s %s", $chowncmd, $username, $path)); That way you don't need added whitespace on vars like $chowncmd and you don't need the "ugly" . " " . "string" . "merging". btw. be sure that you always use http://php.net/manual/en/function.escapeshellcmd.php as well as http://php.net/manual/en/function.escapeshellarg.php when dealing with user inputs and system calls. byebye > I modified /etc/sudoers; > > #Defaults requiretty - I added the comment. > apache ALL = NOPASSWD: /bin/chown - added this line. > > - aurf > On Apr 2, 2009, at 6:58 PM, Michael A. Peters wrote: > >> Chris wrote: >>> >>> Shawn McKenzie wrote: >>>> >>>> Chris wrote: >>>>>> >>>>>> Wow, it does chown and chmod as well, thats friggen cool. >>>>> >>>>> chown will only work if the script is running as root which I doubt >>>>> your >>>>> drupal site will be. >>>>> >>>> >>>> Or if the script is running as a user/group that has write permissions >>>> to the dir/file that your trying to chown. >>> >>> chmod may allow that, but not chown. >> >> I believe it depends upon the operating system and version of the >> operating system. >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php