This will chmod a given directory and all its contents to the correct group-writeable permissions. Signed-off-by: Dan McGee <dan@archlinux.org> --- web/lib/aur.inc | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/web/lib/aur.inc b/web/lib/aur.inc index d0c2bc2..3bc3637 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -390,6 +390,33 @@ function rm_rf($dirname="") { return; } +# recursive chmod to set group write permissions +# +function chmod_group($path) { + if (!is_dir($path)) + return chmod($path, 0664); + + $d = dir($path); + while ($f = $d->read()) { + if ($f != '.' && $f != '..') { + $fullpath = $path.'/'.$f; + if (is_link($fullpath)) + continue; + elseif (!is_dir($fullpath)) + if (!chmod($fullpath, 0664)) + return FALSE; + elseif(!chmod_group($fullpath)) + return FALSE; + } + } + $d->close(); + + if(chmod($path, 0775)) + return TRUE; + else + return FALSE; +} + # obtain the uid given a Users.Username # function uid_from_username($username="") -- 1.6.0.3