[aur-dev] [PATCH] Add new chmod_group function
From: Dan McGee <dan@archlinux.org> 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 b243cc4..c2cde52 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -392,6 +392,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
From: Dan McGee <dan@archlinux.org> Use the new chmod_group() function to do so. Signed-off-by: Dan McGee <dan@archlinux.org> --- NOTE: *completely* untested. I'll let you experienced AUR guys tell me this patch is completely crap. -Dan web/html/pkgsubmit.php | 34 +++++++++++++++++++++------------- 1 files changed, 21 insertions(+), 13 deletions(-) diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index abd6614..f79860d 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -48,16 +48,20 @@ if ($_COOKIE["AURSID"]): $error = __("Could not change directory to %s.", array($tempdir)); } else { - if ($_FILES['pfile']['name'] == "PKGBUILD") { - move_uploaded_file($_FILES['pfile']['tmp_name'], $tempdir . "/PKGBUILD"); - } else { - $tar = new Archive_Tar($_FILES['pfile']['tmp_name']); - $extract = $tar->extract(); - - if (!$extract) { - $error = __("Unknown file format for uploaded file."); - } - } + if ($_FILES['pfile']['name'] == "PKGBUILD") { + move_uploaded_file($_FILES['pfile']['tmp_name'], $tempdir . "/PKGBUILD"); + } else { + $tar = new Archive_Tar($_FILES['pfile']['tmp_name']); + $extract = $tar->extract(); + + if (!$extract) { + $error = __("Unknown file format for uploaded file."); + } + if (!chmod_group($tempdir)) { + $error = __("Could not chmod directory %s.", + array($tempdir)); + } + } } } } @@ -227,11 +231,15 @@ if ($_COOKIE["AURSID"]): if (!@mkdir(INCOMING_DIR . $pkg_name)) { $error = __( "Could not create directory %s." - , INCOMING_DIR . $pkg_name - ); + , INCOMING_DIR . $pkg_name); + } else { + if (!@chmod(INCOMING_DIR . $pkg_name, 0775)) { + $error = __( "Could not chmod directory %s." + , INCOMING_DIR . $pkg_name); + } } - rename($pkg_dir, INCOMING_DIR . $pkg_name . "/" . $pkg_name); + rename($pkg_dir, INCOMING_DIR . $pkg_name . "/" . $pkg_name); } else { $error = __( "You are not allowed to overwrite the %h%s%h package." , "<b>" -- 1.6.0.3
participants (1)
-
Dan McGee