Fix to use quotemeta to prevent shell injection in Quota module
This commit is contained in:
+20
-12
@@ -66,9 +66,11 @@ if ($_[1]%2 == 1) {
|
||||
&open_tempfile(QUOTAFILE, ">$qf", 0, 1);
|
||||
&close_tempfile(QUOTAFILE);
|
||||
&set_ownership_permissions(undef, undef, 0600, $qf);
|
||||
&system_logged("$config{'quotacheck_command'} $_[0]");
|
||||
&system_logged("$config{'quotacheck_command'} ".
|
||||
quotemeta($_[0]));
|
||||
}
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
if ($_[1] > 1) {
|
||||
@@ -78,9 +80,11 @@ if ($_[1] > 1) {
|
||||
&open_tempfile(QUOTAFILE, ">$qf", 0, 1);
|
||||
&close_tempfile(QUOTAFILE);
|
||||
&set_ownership_permissions(undef, undef, 0600, $qf);
|
||||
&system_logged("$config{'quotacheck_command'} $_[0]");
|
||||
&system_logged("$config{'quotacheck_command'} ".
|
||||
quotemeta($_[0]));
|
||||
}
|
||||
$out = &backquote_logged("$config{'group_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'group_quotaon_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
return undef;
|
||||
@@ -93,11 +97,13 @@ sub quotaoff
|
||||
return if (&is_readonly_mode());
|
||||
local($out);
|
||||
if ($_[1]%2 == 1) {
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
if ($_[1] > 1) {
|
||||
$out = &backquote_logged("$config{'group_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'group_quotaoff_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
return undef;
|
||||
@@ -191,7 +197,8 @@ return $n;
|
||||
sub filesystem_users
|
||||
{
|
||||
local($rep, @rep, $n, $what);
|
||||
$rep = `$config{'user_repquota_command'} $_[0] 2>&1`;
|
||||
$rep = &backquote_command("$config{'user_repquota_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
@rep = split(/\n/, $rep);
|
||||
@rep = grep { !/^root\s/ } @rep[3..$#rep];
|
||||
@@ -219,7 +226,8 @@ return $n;
|
||||
sub filesystem_groups
|
||||
{
|
||||
local($rep, @rep, $n, $what);
|
||||
$rep = `$config{'group_repquota_command'} $_[0] 2>&1`;
|
||||
$rep = &backquote_command("$config{'group_repquota_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
@rep = split(/\n/, $rep);
|
||||
@rep = @rep[3..$#rep];
|
||||
@@ -268,7 +276,8 @@ return $rv;
|
||||
# Runs quotacheck on some filesystem
|
||||
sub quotacheck
|
||||
{
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} ".quotemeta($_[0]).
|
||||
" 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -311,7 +320,7 @@ sub get_user_grace
|
||||
{
|
||||
local(@rv, %mtab, @m);
|
||||
$ENV{'EDITOR'} = $ENV{'VISUAL'} = "cat";
|
||||
open(GRACE, "$config{'user_grace_command'} $_[0] |");
|
||||
open(GRACE, "$config{'user_grace_command'} ".quotemeta($_[0])." |");
|
||||
while(<GRACE>) {
|
||||
if (/^(\S+): block grace period: (\d+) (\S+), file grace period: (\d+) (\S+)/ && $1 eq $_[0]) {
|
||||
@rv = ($2, $name_to_unit{$3}, $4, $name_to_unit{$5});
|
||||
@@ -328,7 +337,7 @@ sub get_group_grace
|
||||
{
|
||||
local(@rv, %mtab, @m);
|
||||
$ENV{'EDITOR'} = $ENV{'VISUAL'} = "cat";
|
||||
open(GRACE, "$config{'group_grace_command'} $_[0] |");
|
||||
open(GRACE, "$config{'group_grace_command'} ".quotemeta($_[0])." |");
|
||||
while(<GRACE>) {
|
||||
if (/^(\S+): block grace period: (\d+) (\S+), file grace period: (\d+) (\S+)/ && $1 eq $_[0]) {
|
||||
@rv = ($2, $name_to_unit{$3}, $4, $name_to_unit{$5});
|
||||
@@ -385,4 +394,3 @@ foreach $k (keys %name_to_unit) {
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
+9
-5
@@ -19,7 +19,7 @@ return 1;
|
||||
sub free_space
|
||||
{
|
||||
local($out);
|
||||
$out = `df -t $_[0]`;
|
||||
$out = &backquote_command("df -t ".quotemeta($_[0]));
|
||||
$out =~ /(\d+) blocks\s+(\d+) files\n.*\s+(\d+) blocks\s+(\d+) files/;
|
||||
return ($3, $1, $4, $2);
|
||||
}
|
||||
@@ -52,7 +52,8 @@ return $_[0]->[3] =~ /,quota/ || $_[0]->[3] =~ /^quota/ ? 1 : 0;
|
||||
sub filesystem_users
|
||||
{
|
||||
local($rep, @rep, $n, $newfmt);
|
||||
$rep = `$config{'user_repquota_command'} $_[0] 2>&1`;
|
||||
$rep = &backquote_command("$config{'user_repquota_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
@rep = split(/\n/, $rep); @rep = @rep[3..$#rep];
|
||||
`uname -r` =~ /(\d+)\.(\d+)/;
|
||||
@@ -99,7 +100,8 @@ if (!(-r $qf)) {
|
||||
&close_tempfile(QUOTAFILE);
|
||||
&set_ownership_permissions(undef, undef, 0600, $qf);
|
||||
}
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -110,7 +112,8 @@ sub quotaoff
|
||||
{
|
||||
return if (&is_readonly_mode());
|
||||
local($out);
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -119,7 +122,8 @@ return undef;
|
||||
# Runs quotacheck on some filesystem
|
||||
sub quotacheck
|
||||
{
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} ".quotemeta($_[0]).
|
||||
" 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
|
||||
+8
-4
@@ -25,7 +25,8 @@ return 1;
|
||||
sub free_space
|
||||
{
|
||||
local(@out, @rv);
|
||||
`df -i '$_[0]'` =~ /Mounted\n\S+\s+\S+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/;
|
||||
&backquote_command("df -i ".quotemeta($_[0])) =~
|
||||
/Mounted\n\S+\s+\S+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/;
|
||||
return ($1, $3, $5+$6, $6);
|
||||
}
|
||||
|
||||
@@ -113,7 +114,8 @@ return $n;
|
||||
sub filesystem_users
|
||||
{
|
||||
local($rep, @rep, $n = 0, $r);
|
||||
$rep = `$config{'user_repquota_command'} $_[0] 2>&1`;
|
||||
$rep = &backquote_command("$config{'user_repquota_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
@rep = split(/\n/, $rep);
|
||||
foreach $r (@rep) {
|
||||
@@ -150,7 +152,8 @@ return $rv;
|
||||
# Runs quotacheck on some filesystem
|
||||
sub quotacheck
|
||||
{
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} ".quotemeta($_[0]).
|
||||
" 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -181,7 +184,8 @@ sub get_user_grace
|
||||
{
|
||||
local(@rv, %mtab, @m);
|
||||
$ENV{'EDITOR'} = $ENV{'VISUAL'} = "cat";
|
||||
open(GRACE, "$config{'user_grace_command'} $_[0] 2>/dev/null |");
|
||||
open(GRACE, "$config{'user_grace_command'} ".quotemeta($_[0]).
|
||||
" 2>/dev/null |");
|
||||
while(<GRACE>) {
|
||||
if (/^fs\s+(\S+)\s+kbytes\s+time\s+limit\s+=\s+(\S+)\s+(\S+),\s+files\s+time\s+limit\s+=\s+(\S+)\s+(\S+)/) {
|
||||
@rv = ($2, $name_to_unit{$3}, $4, $name_to_unit{$5});
|
||||
|
||||
+26
-21
@@ -50,7 +50,7 @@ sub free_space
|
||||
{
|
||||
local(@out, @rv);
|
||||
&clean_language();
|
||||
$out = &backquote_command("df -k $_[0]");
|
||||
$out = &backquote_command("df -k ".quotemeta($_[0]));
|
||||
$out =~ /Mounted on\n\S+\s+(\d+)\s+\d+\s+(\d+)/;
|
||||
if ($_[1]) {
|
||||
push(@rv, int($1*1024/$_[1]), int($2*1024/$_[1]));
|
||||
@@ -58,7 +58,7 @@ if ($_[1]) {
|
||||
else {
|
||||
push(@rv, $1, $2);
|
||||
}
|
||||
$out = &backquote_command("df -i $_[0]");
|
||||
$out = &backquote_command("df -i ".quotemeta($_[0]));
|
||||
$out =~ /Mounted on\n\S+\s+(\d+)\s+\d+\s+(\d+)/;
|
||||
push(@rv, $1, $2);
|
||||
&reset_environment();
|
||||
@@ -140,7 +140,7 @@ if ($_[0]->[4]%2 == 1) {
|
||||
# Fall back to testing by running quotaon
|
||||
&clean_language();
|
||||
$out = &backquote_command(
|
||||
"$config{'user_quotaon_command'} $dir 2>&1");
|
||||
"$config{'user_quotaon_command'} ".quotemeta($dir)." 2>&1");
|
||||
&reset_environment();
|
||||
if ($out =~ /Device or resource busy/i) {
|
||||
# already on..
|
||||
@@ -153,7 +153,7 @@ if ($_[0]->[4]%2 == 1) {
|
||||
else {
|
||||
# was off.. need to turn on again
|
||||
&execute_command(
|
||||
"$config{'user_quotaoff_command'} $dir 2>&1");
|
||||
"$config{'user_quotaoff_command'} ".quotemeta($dir)." 2>&1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ if ($_[0]->[4] > 1) {
|
||||
# Fall back to testing by running quotaon
|
||||
&clean_language();
|
||||
$out = &backquote_command(
|
||||
"$config{'group_quotaon_command'} $dir 2>&1");
|
||||
"$config{'group_quotaon_command'} ".quotemeta($dir)." 2>&1");
|
||||
&reset_environment();
|
||||
if ($out =~ /Device or resource busy/i) {
|
||||
# already on..
|
||||
@@ -186,7 +186,7 @@ if ($_[0]->[4] > 1) {
|
||||
else {
|
||||
# was off.. need to turn on again
|
||||
&execute_command(
|
||||
"$config{'group_quotaoff_command'} $dir 2>&1");
|
||||
"$config{'group_quotaoff_command'} ".quotemeta($dir)." 2>&1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ sub supports_status
|
||||
if (!defined($supports_status_cache{$_[0],$_[1]})) {
|
||||
&clean_language();
|
||||
local $stout = &backquote_command(
|
||||
"$config{$_[1].'_quotaon_command'} -p $_[0] 2>&1");
|
||||
"$config{$_[1].'_quotaon_command'} -p ".quotemeta($_[0])." 2>&1");
|
||||
&reset_environment();
|
||||
$supports_status_cache{$_[0],$_[1]} =
|
||||
$stout =~ /is\s+(on|off|enabled|disabled)/ ? $stout : 0;
|
||||
@@ -296,7 +296,7 @@ if ($_[1]%2 == 1) {
|
||||
&close_tempfile(QUOTAFILE);
|
||||
&set_ownership_permissions(undef, undef, 0600,
|
||||
"$_[0]/quota.user");
|
||||
&system_logged("convertquota -u $_[0] 2>&1");
|
||||
&system_logged("convertquota -u ".quotemeta($_[0])." 2>&1");
|
||||
$ok = 1 if (!$?);
|
||||
&unlink_file("$_[0]/quota.user");
|
||||
}
|
||||
@@ -315,7 +315,8 @@ if ($_[1]%2 == 1) {
|
||||
&run_quotacheck($_[0], "-u -f -m -c -F $fmt");
|
||||
}
|
||||
}
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged(
|
||||
"$config{'user_quotaon_command'} ".quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
if ($_[1] > 1) {
|
||||
@@ -330,7 +331,7 @@ if ($_[1] > 1) {
|
||||
&close_tempfile(QUOTAFILE);
|
||||
&set_ownership_permissions(undef, undef, 0600,
|
||||
"$_[0]/quota.group");
|
||||
&system_logged("convertquota -g $_[0] 2>&1");
|
||||
&system_logged("convertquota -g ".quotemeta($_[0])." 2>&1");
|
||||
$ok = 1 if (!$?);
|
||||
&unlink_file("$_[0]/quota.group");
|
||||
}
|
||||
@@ -349,7 +350,8 @@ if ($_[1] > 1) {
|
||||
&run_quotacheck($_[0], "-g -f -m -c -F $fmt");
|
||||
}
|
||||
}
|
||||
$out = &backquote_logged("$config{'group_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged(
|
||||
"$config{'group_quotaon_command'} ".quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
return undef;
|
||||
@@ -364,8 +366,8 @@ Runs the quotacheck command on some filesystem, and returns 1 on success or
|
||||
sub run_quotacheck
|
||||
{
|
||||
&clean_language();
|
||||
local $out =&backquote_logged(
|
||||
"$config{'quotacheck_command'} $_[1] $_[0] 2>&1");
|
||||
local $out = &backquote_logged(
|
||||
"$config{'quotacheck_command'} $_[1] ".quotemeta($_[0])." 2>&1");
|
||||
&reset_environment();
|
||||
return $? || $out =~ /cannot guess|cannot remount|cannot find|please stop/i ? 0 : 1;
|
||||
}
|
||||
@@ -381,11 +383,13 @@ sub quotaoff
|
||||
return if (&is_readonly_mode());
|
||||
local($out);
|
||||
if ($_[1]%2 == 1) {
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged(
|
||||
"$config{'user_quotaoff_command'} ".quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
if ($_[1] > 1) {
|
||||
$out = &backquote_logged("$config{'group_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged(
|
||||
"$config{'group_quotaoff_command'} ".quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
return undef;
|
||||
@@ -591,7 +595,7 @@ sub parse_repquota_output
|
||||
local ($cmd, $what, $mode, $dir) = @_;
|
||||
local($rep, @rep, $n, $u, @uinfo);
|
||||
%$what = ( );
|
||||
$rep = &backquote_command("$cmd $dir 2>&1");
|
||||
$rep = &backquote_command("$cmd ".quotemeta($dir)." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
local $st = &supports_status($dir, $mode);
|
||||
if (!$st) {
|
||||
@@ -660,7 +664,7 @@ sub parse_xfs_report_output
|
||||
{
|
||||
my ($cmd, $what, $mode, $fs) = @_;
|
||||
%$what = ( );
|
||||
my $rep = &backquote_command("$cmd $fs 2>&1");
|
||||
my $rep = &backquote_command("$cmd ".quotemeta($fs)." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
my @rep = split(/\r?\n/, $rep);
|
||||
my $nn = 0;
|
||||
@@ -754,13 +758,15 @@ if ($_[1] == 0 || $_[1] == 2) {
|
||||
local $cmd = $config{'quotacheck_command'};
|
||||
$cmd =~ s/\s+-[ug]//g;
|
||||
local $flag = $_[1] == 1 ? "-u" : $_[1] == 2 ? "-g" : "-u -g";
|
||||
$out = &backquote_logged("$cmd $flag $_[0] 2>&1");
|
||||
$out = &backquote_logged("$cmd $flag ".quotemeta($_[0])." 2>&1");
|
||||
if ($?) {
|
||||
# Try with the -f and -m options
|
||||
$out = &backquote_logged("$cmd $flag -f -m $_[0] 2>&1");
|
||||
$out = &backquote_logged(
|
||||
"$cmd $flag -f -m ".quotemeta($_[0])." 2>&1");
|
||||
if ($?) {
|
||||
# Try with the -F option
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} $flag -F $_[0] 2>&1");
|
||||
$out = &backquote_logged(
|
||||
"$config{'quotacheck_command'} $flag -F ".quotemeta($_[0])." 2>&1");
|
||||
}
|
||||
return $out if ($?);
|
||||
}
|
||||
@@ -1055,4 +1061,3 @@ return !&is_xfs_fs($fs);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
+22
-12
@@ -27,7 +27,8 @@ sub free_space
|
||||
{
|
||||
local(@out, @rv);
|
||||
$ENV{'BLOCKSIZE'} = 1024;
|
||||
`df -i $_[0]` =~ /Mounted on\n\S+\s+(\d+)\s+\d+\s+(\d+)\s+\S+\s+(\d+)\s+(\d+)/;
|
||||
&backquote_command("df -i ".quotemeta($_[0])) =~
|
||||
/Mounted on\n\S+\s+(\d+)\s+\d+\s+(\d+)\s+\S+\s+(\d+)\s+(\d+)/;
|
||||
return ($1, $2, $3+$4, $4);
|
||||
}
|
||||
|
||||
@@ -74,9 +75,11 @@ if ($_[1]%2 == 1) {
|
||||
$qf = "$_[0]/.quota.user";
|
||||
if (!&big_enough($qf)) {
|
||||
&unlink_file($qf);
|
||||
&system_logged("$config{'quotacheck_command'} $_[0]");
|
||||
&system_logged("$config{'quotacheck_command'} ".
|
||||
quotemeta($_[0]));
|
||||
}
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
if ($_[1] > 1) {
|
||||
@@ -87,9 +90,11 @@ if ($_[1] > 1) {
|
||||
$qf = "$_[0]/quota.group";
|
||||
if (!&big_enough($qf)) {
|
||||
&unlink_file($qf);
|
||||
&system_logged("$config{'quotacheck_command'} $_[0]");
|
||||
&system_logged("$config{'quotacheck_command'} ".
|
||||
quotemeta($_[0]));
|
||||
}
|
||||
$out = &backquote_logged("$config{'group_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'group_quotaon_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
}
|
||||
return undef;
|
||||
@@ -109,12 +114,14 @@ sub quotaoff
|
||||
return if (&is_readonly_mode());
|
||||
local($out);
|
||||
if ($_[1]%2 == 1) {
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
&unlink_file("$_[0]/.quota.ops.user");
|
||||
}
|
||||
if ($_[1] > 1) {
|
||||
$out = &backquote_logged("$config{'group_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'group_quotaoff_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
&unlink_file("$_[0]/.quota.ops.group");
|
||||
}
|
||||
@@ -177,7 +184,8 @@ return $n;
|
||||
sub filesystem_users
|
||||
{
|
||||
local($rep, @rep, $n, $what);
|
||||
$rep = `$config{'user_repquota_command'} $_[0] 2>&1`;
|
||||
$rep = &backquote_command("$config{'user_repquota_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
@rep = split(/\n/, $rep);
|
||||
@rep = grep { !/^root\s/ } @rep[3..$#rep];
|
||||
@@ -201,7 +209,8 @@ return $n;
|
||||
sub filesystem_groups
|
||||
{
|
||||
local($rep, @rep, $n, $what);
|
||||
$rep = `$config{'group_repquota_command'} $_[0] 2>&1`;
|
||||
$rep = &backquote_command("$config{'group_repquota_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
@rep = split(/\n/, $rep);
|
||||
@rep = @rep[3..$#rep];
|
||||
@@ -240,7 +249,8 @@ return $rv;
|
||||
# Runs quotacheck on some filesystem
|
||||
sub quotacheck
|
||||
{
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} ".quotemeta($_[0]).
|
||||
" 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -283,7 +293,7 @@ sub get_user_grace
|
||||
{
|
||||
local(@rv, %mtab, @m);
|
||||
$ENV{'EDITOR'} = $ENV{'VISUAL'} = "cat";
|
||||
open(GRACE, "$config{'user_grace_command'} $_[0] |");
|
||||
open(GRACE, "$config{'user_grace_command'} ".quotemeta($_[0])." |");
|
||||
while(<GRACE>) {
|
||||
if (/^(\S+): block grace period: (\d+) (\S+), file grace period: (\d+) (\S+)/ && $1 eq $_[0]) {
|
||||
@rv = ($2, $name_to_unit{$3}, $4, $name_to_unit{$5});
|
||||
@@ -300,7 +310,7 @@ sub get_group_grace
|
||||
{
|
||||
local(@rv, %mtab, @m);
|
||||
$ENV{'EDITOR'} = $ENV{'VISUAL'} = "cat";
|
||||
open(GRACE, "$config{'group_grace_command'} $_[0] |");
|
||||
open(GRACE, "$config{'group_grace_command'} ".quotemeta($_[0])." |");
|
||||
while(<GRACE>) {
|
||||
if (/^(\S+): block grace period: (\d+) (\S+), file grace period: (\d+) (\S+)/ && $1 eq $_[0]) {
|
||||
@rv = ($2, $name_to_unit{$3}, $4, $name_to_unit{$5});
|
||||
|
||||
+11
-7
@@ -19,7 +19,7 @@ return 1;
|
||||
sub free_space
|
||||
{
|
||||
local($out);
|
||||
$out = `df -t $_[0]`;
|
||||
$out = &backquote_command("df -t ".quotemeta($_[0]));
|
||||
$out =~ /(\d+) blocks\s+(\d+) files\n.*\s+(\d+) blocks\s+(\d+) files/;
|
||||
return ($3, $1, $4, $2);
|
||||
}
|
||||
@@ -52,7 +52,8 @@ return $_[0]->[3] =~ /,quota/ || $_[0]->[3] =~ /^quota/ ? 1 : 0;
|
||||
sub filesystem_users
|
||||
{
|
||||
local($rep, @rep, $n, %hasu, @hasu, $u);
|
||||
$rep = `$config{'user_repquota_command'} $_[0] 2>&1`;
|
||||
$rep = &backquote_command("$config{'user_repquota_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
setpwent();
|
||||
while(@uinfo = getpwent()) {
|
||||
@@ -121,7 +122,8 @@ if (!(-r $qf)) {
|
||||
&close_tempfile(QUOTAFILE);
|
||||
&set_ownership_permissions(undef, undef, 0600, $qf);
|
||||
}
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -132,7 +134,8 @@ sub quotaoff
|
||||
{
|
||||
return if (&is_readonly_mode());
|
||||
local($out);
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -141,7 +144,8 @@ return undef;
|
||||
# Runs quotacheck on some filesystem
|
||||
sub quotacheck
|
||||
{
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} ".quotemeta($_[0]).
|
||||
" 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -268,8 +272,8 @@ return 1024;
|
||||
sub fs_block_size
|
||||
{
|
||||
if ($_[2] eq "ufs") {
|
||||
local $kout = `df -k $_[0]`;
|
||||
local $bout = `df -t $_[0]`;
|
||||
local $kout = &backquote_command("df -k ".quotemeta($_[0]));
|
||||
local $bout = &backquote_command("df -t ".quotemeta($_[0]));
|
||||
if ($kout =~ /\n\Q$_[1]\E\s+(\d+)/) {
|
||||
local $ks = $1;
|
||||
if ($bout =~ /total\s*:\s*(\d+)\s+blocks/) {
|
||||
|
||||
@@ -19,7 +19,7 @@ return 1;
|
||||
sub free_space
|
||||
{
|
||||
local($out);
|
||||
$out = `df -t $_[0]`;
|
||||
$out = &backquote_command("df -t ".quotemeta($_[0]));
|
||||
$out =~ /(\d+) blocks\s+(\d+) files\n.*\s+(\d+) blocks\s+(\d+) files/;
|
||||
return ($3, $1, $4, $2);
|
||||
}
|
||||
@@ -52,7 +52,8 @@ return $_[0]->[3] =~ /,quota/ || $_[0]->[3] =~ /^quota/ ? 1 : 0;
|
||||
sub filesystem_users
|
||||
{
|
||||
local($rep, @rep, $n, %hasu, $u);
|
||||
$rep = &backquote_logged("$config{'user_repquota_command'} $_[0] 2>&1");
|
||||
$rep = &backquote_command("$config{'user_repquota_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return -1; }
|
||||
setpwent();
|
||||
while(@uinfo = getpwent()) {
|
||||
@@ -113,7 +114,8 @@ if (!(-r $qf)) {
|
||||
&close_tempfile(QUOTAFILE);
|
||||
&set_ownership_permissions(undef, undef, 0600, $qf);
|
||||
}
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaon_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -124,7 +126,8 @@ sub quotaoff
|
||||
{
|
||||
return if (&is_readonly_mode());
|
||||
local($out);
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'user_quotaoff_command'} ".
|
||||
quotemeta($_[0])." 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
@@ -133,7 +136,8 @@ return undef;
|
||||
# Runs quotacheck on some filesystem
|
||||
sub quotacheck
|
||||
{
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} $_[0] 2>&1");
|
||||
$out = &backquote_logged("$config{'quotacheck_command'} ".quotemeta($_[0]).
|
||||
" 2>&1");
|
||||
if ($?) { return $out; }
|
||||
return undef;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user