mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
2ac75bd812
commit
f12b11abc7
2 changed files with 47 additions and 17 deletions
|
@ -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="")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue