summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLoui Chang <louipc.ist@gmail.com>2008-11-10 04:35:00 +0100
committerLoui Chang <louipc.ist@gmail.com>2008-11-13 21:19:26 +0100
commitf12b11abc70b03fa75faf211a6311acb1cc1b32d (patch)
tree7c43e9a46d0a560d1bd6f550c105b8179543fc05 /web/lib
parent2ac75bd81278a6a51d3eef56e9088c198a887a6d (diff)
downloadaur-f12b11abc70b03fa75faf211a6311acb1cc1b32d.tar.gz
aur-f12b11abc70b03fa75faf211a6311acb1cc1b32d.tar.xz
Give group writable permissions to uploaded files.
Add a new function chown_group to recursively change permissions. Tweak some of the coding style. Replace some of the redundant string concatenation with a variable. Thanks to Dan McGee for chmod_group. Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/aur.inc28
1 files changed, 28 insertions, 0 deletions
diff --git a/web/lib/aur.inc b/web/lib/aur.inc
index a126bb94..d08ff0ca 100644
--- a/web/lib/aur.inc
+++ b/web/lib/aur.inc
@@ -381,6 +381,34 @@ 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="")