[aur-dev] [PATCH] Add new chmod_group function
Dan McGee
dpmcgee at gmail.com
Fri Oct 24 17:07:10 EDT 2008
From: Dan McGee <dan at archlinux.org>
This will chmod a given directory and all its contents to the correct
group-writeable permissions.
Signed-off-by: Dan McGee <dan at 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
More information about the aur-dev
mailing list