modification du script fixperms.sh pour modfier les ACL par fichiers, afin de les modifier après upload par le panel
This commit is contained in:
parent
ad874e6232
commit
0bba178de7
|
@ -509,7 +509,7 @@ class m_bro {
|
||||||
* @returns the path where the file resides or false if upload failed
|
* @returns the path where the file resides or false if upload failed
|
||||||
*/
|
*/
|
||||||
function UploadFile($R) {
|
function UploadFile($R) {
|
||||||
global $_FILES,$err;
|
global $_FILES,$err,$cuid;
|
||||||
$absolute=$this->convertabsolute($R,0);
|
$absolute=$this->convertabsolute($R,0);
|
||||||
if (!$absolute) {
|
if (!$absolute) {
|
||||||
$err->raise("bro",1);
|
$err->raise("bro",1);
|
||||||
|
@ -521,7 +521,8 @@ class m_bro {
|
||||||
@touch($absolute."/".$_FILES['userfile']['name']);
|
@touch($absolute."/".$_FILES['userfile']['name']);
|
||||||
}
|
}
|
||||||
if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute."/".$_FILES['userfile']['name'])) {
|
if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute."/".$_FILES['userfile']['name'])) {
|
||||||
return $absolute."/".$_FILES['userfile']['name'];
|
exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -f ".$absolute."/".$_FILES['userfile']['name']);
|
||||||
|
return $absolute."/".$_FILES['userfile']['name'];
|
||||||
} else {
|
} else {
|
||||||
$err->raise("bro",3);
|
$err->raise("bro",3);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
alterncpanel ALL = NOPASSWD : /usr/bin/quota, /usr/sbin/setquota
|
alterncpanel ALL = NOPASSWD : /usr/bin/quota, /usr/sbin/setquota, /usr/lib/alternc/fixperms.sh
|
||||||
vmail ALL = NOPASSWD : /usr/lib/dovecot/deliver
|
vmail ALL = NOPASSWD : /usr/lib/dovecot/deliver
|
||||||
|
|
|
@ -31,18 +31,33 @@
|
||||||
#Default Query : fixperms for all account
|
#Default Query : fixperms for all account
|
||||||
query="SELECT uid,login FROM membres"
|
query="SELECT uid,login FROM membres"
|
||||||
sub_dir=""
|
sub_dir=""
|
||||||
|
file=""
|
||||||
#Two optionals argument
|
#Two optionals argument
|
||||||
# -l string : a specific login to fix
|
# -l string : a specific login to fix
|
||||||
# -u interger : a specifi uid to fix
|
# -u interger : a specific uid to fix
|
||||||
while getopts "l:u:d:" optname
|
# -f interger : a specific file to fix according to a given uid
|
||||||
|
|
||||||
|
while getopts "l:u:f:d:" optname
|
||||||
do
|
do
|
||||||
case "$optname" in
|
case "$optname" in
|
||||||
"l")
|
"l")
|
||||||
query="SELECT uid,login FROM membres WHERE login LIKE '$OPTARG'"
|
if [[ "$OPTARG" =~ ^[a-zA-Z0-9_]+$ ]] ; then
|
||||||
|
query="SELECT uid,login FROM membres WHERE login LIKE '$OPTARG'"
|
||||||
|
else
|
||||||
|
echo "Bad login provided"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"u")
|
"u")
|
||||||
query="SELECT uid,login FROM membres WHERE uid LIKE '$OPTARG'"
|
if [[ "$OPTARG" =~ ^[0-9]+$ ]] ; then
|
||||||
|
query="SELECT uid,login FROM membres WHERE uid LIKE '$OPTARG'"
|
||||||
|
else
|
||||||
|
echo "Bad uid provided"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"f")
|
||||||
|
file="$OPTARG"
|
||||||
;;
|
;;
|
||||||
"d")
|
"d")
|
||||||
sub_dir="$OPTARG"
|
sub_dir="$OPTARG"
|
||||||
|
@ -97,12 +112,31 @@ doone() {
|
||||||
# Delete existings ACL
|
# Delete existings ACL
|
||||||
# Set the defaults acl on all the files
|
# Set the defaults acl on all the files
|
||||||
setfacl -b -k -m d:g:alterncpanel:rwx -m d:u:$GID:rw- -m d:g:$GID:rw- \
|
setfacl -b -k -m d:g:alterncpanel:rwx -m d:u:$GID:rw- -m d:g:$GID:rw- \
|
||||||
-m g:alterncpanel:rwx -m u:$GID:rw- -m g:$GID:rw- \
|
-Rm g:alterncpanel:rwx -m u:$GID:rw- -m g:$GID:rw- \
|
||||||
-R "$REP"
|
"$REP"
|
||||||
|
|
||||||
read GID LOGIN
|
read GID LOGIN
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |doone
|
fixefile(){
|
||||||
|
read GID LOGIN
|
||||||
|
/usr/bin/setfacl -bk $file
|
||||||
|
echo "gid: $GID"
|
||||||
|
echo "file: $file"
|
||||||
|
chown $GID:$GID $file
|
||||||
|
chmod 0770 $file
|
||||||
|
/usr/bin/setfacl -m u:$GID:rw- -m g:$GID:rw- -m g:alterncpanel:rw- -m u:$GID:rw- -m g:$GID:rw- $file
|
||||||
|
echo file ownership and ACLs changed
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $file != "" ]]; then
|
||||||
|
if [ -e $file ]; then
|
||||||
|
mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |fixefile
|
||||||
|
else
|
||||||
|
echo "file not found"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |doone
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue