Skip to content

Commit 96541d1

Browse files
author
Marius Burkard
committed
- Invalid XFS quota argument, fixes #4257
- Added missing shell escaping
1 parent 659b5a4 commit 96541d1

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

server/plugins-available/apache2_plugin.inc.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -879,30 +879,30 @@ function update($event_name, $data) {
879879
$blocks_soft = $data['new']['hd_quota'] * 1024;
880880
$blocks_hard = $blocks_soft + 1024;
881881
$mb_soft = $data['new']['hd_quota'];
882-
$mb_hard = $mb_soft + 1;
882+
$mb_hard = $mb_soft + 1;
883883
} else {
884884
$mb_soft = $mb_hard = $blocks_soft = $blocks_hard = 0;
885885
}
886-
887-
// get the primitive folder for document_root and the filesystem, will need it later.
888-
$df_output=explode(" ", exec("df -T " . escapeshellarg($data['new']['document_root']) . "|awk 'END{print \$2,\$NF}'"));
889-
$file_system = $df_output[0];
890-
$primitive_root = $df_output[1];
891886

892-
if($file_system == 'xfs') {
893-
exec("xfs_quota -x -c 'limit -u bsoft=$mb_soft" . 'm'. " bhard=$mb_hard" . 'm'. " $username' $primitive_root");
887+
// get the primitive folder for document_root and the filesystem, will need it later.
888+
$df_output=explode(" ", exec("df -T " . escapeshellarg($data['new']['document_root']) . "|awk 'END{print \$2,\$NF}'"));
889+
$file_system = $df_output[0];
890+
$primitive_root = $df_output[1];
894891

895-
// xfs only supports timers globally, not per user.
896-
exec("xfs_quota -x -c 'timer -bir -i 604800' $primitive_root");
892+
if($file_system == 'xfs') {
893+
exec("xfs_quota -x -c " . escapeshellarg("limit -u bsoft=$mb_soft" . 'm'. " bhard=$mb_hard" . 'm'. " " . $data['new']['system_group']) . " " . escapeshellarg($primitive_root));
897894

898-
unset($project_uid, $username_position, $xfs_projects);
899-
unset($primitive_root, $df_output, $mb_hard, $mb_soft);
900-
} else {
901-
if($app->system->is_installed('setquota')) {
902-
exec('setquota -u '. $username . ' ' . $blocks_soft . ' ' . $blocks_hard . ' 0 0 -a &> /dev/null');
903-
exec('setquota -T -u '.$username.' 604800 604800 -a &> /dev/null');
895+
// xfs only supports timers globally, not per user.
896+
exec("xfs_quota -x -c 'timer -bir -i 604800' " . escapeshellarg($primitive_root));
897+
898+
unset($project_uid, $username_position, $xfs_projects);
899+
unset($primitive_root, $df_output, $mb_hard, $mb_soft);
900+
} else {
901+
if($app->system->is_installed('setquota')) {
902+
exec('setquota -u '. $username . ' ' . $blocks_soft . ' ' . $blocks_hard . ' 0 0 -a &> /dev/null');
903+
exec('setquota -T -u '.$username.' 604800 604800 -a &> /dev/null');
904+
}
904905
}
905-
}
906906
}
907907

908908
if($this->action == 'insert' || $data["new"]["system_user"] != $data["old"]["system_user"]) {

server/plugins-available/nginx_plugin.inc.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -733,34 +733,34 @@ function update($event_name, $data) {
733733
} // end copy error docs
734734

735735
// Set the quota for the user, but only for vhosts, not vhostsubdomains or vhostalias
736-
if($username != '' && $app->system->is_user($username) && $data['new']['type'] == 'vhost') {
736+
if($username != '' && $app->system->is_user($username) && $data['new']['type'] == 'vhost') {
737737
if($data['new']['hd_quota'] > 0) {
738738
$blocks_soft = $data['new']['hd_quota'] * 1024;
739739
$blocks_hard = $blocks_soft + 1024;
740-
$mb_hard = $mb_soft + 1;
740+
$mb_hard = $mb_soft + 1;
741741
} else {
742742
$mb_soft = $mb_hard = $blocks_soft = $blocks_hard = 0;
743743
}
744-
745-
// get the primitive folder for document_root and the filesystem, will need it later.
746-
$df_output=explode(" ", exec("df -T $document_root|awk 'END{print \$2,\$NF}'"));
747-
$file_system = $df_output[0];
748-
$primitive_root = $df_output[1];
749744

750-
if($file_system == 'xfs') {
751-
exec("xfs_quota -x -c 'limit -u bsoft=$mb_soft" . 'm'. " bhard=$mb_hard" . 'm'. " $username' $primitive_root");
745+
// get the primitive folder for document_root and the filesystem, will need it later.
746+
$df_output=explode(" ", exec("df -T " . escapeshellarg($data['new']['document_root']) . "|awk 'END{print \$2,\$NF}'"));
747+
$file_system = $df_output[0];
748+
$primitive_root = $df_output[1];
752749

753-
// xfs only supports timers globally, not per user.
754-
exec("xfs_quota -x -c 'timer -bir -i 604800' $primitive_root");
750+
if($file_system == 'xfs') {
751+
exec("xfs_quota -x -c " . escapeshellarg("limit -u bsoft=$mb_soft" . 'm'. " bhard=$mb_hard" . 'm'. " " . $data['new']['system_group']) . " " . escapeshellarg($primitive_root));
755752

756-
unset($project_uid, $username_position, $xfs_projects);
757-
unset($primitive_root, $df_output, $mb_hard, $mb_soft);
758-
} else {
759-
if($app->system->is_installed('setquota')) {
760-
exec('setquota -u '. $username . ' ' . $blocks_soft . ' ' . $blocks_hard . ' 0 0 -a &> /dev/null');
761-
exec('setquota -T -u '.$username.' 604800 604800 -a &> /dev/null');
753+
// xfs only supports timers globally, not per user.
754+
exec("xfs_quota -x -c 'timer -bir -i 604800' " . escapeshellarg($primitive_root));
755+
756+
unset($project_uid, $username_position, $xfs_projects);
757+
unset($primitive_root, $df_output, $mb_hard, $mb_soft);
758+
} else {
759+
if($app->system->is_installed('setquota')) {
760+
exec('setquota -u '. $username . ' ' . $blocks_soft . ' ' . $blocks_hard . ' 0 0 -a &> /dev/null');
761+
exec('setquota -T -u '.$username.' 604800 604800 -a &> /dev/null');
762+
}
762763
}
763-
}
764764
}
765765

766766
if($this->action == 'insert' || $data["new"]["system_user"] != $data["old"]["system_user"]) {

0 commit comments

Comments
 (0)