mirror of
https://github.com/webmin/webmin.git
synced 2026-05-04 22:30:33 +01:00
Add new function to force use of english, use it in quota module
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -122,8 +122,10 @@ if ($_[0]->[4]%2 == 1) {
|
||||
}
|
||||
else {
|
||||
# Fall back to testing by running quotaon
|
||||
&clean_language();
|
||||
$out = &backquote_command(
|
||||
"$config{'user_quotaon_command'} $dir 2>&1");
|
||||
&reset_environment();
|
||||
if ($out =~ /Device or resource busy/i) {
|
||||
# already on..
|
||||
$rv += 1;
|
||||
@@ -152,8 +154,10 @@ if ($_[0]->[4] > 1) {
|
||||
}
|
||||
else {
|
||||
# Fall back to testing by running quotaon
|
||||
&clean_language();
|
||||
$out = &backquote_command(
|
||||
"$config{'group_quotaon_command'} $dir 2>&1");
|
||||
&reset_environment();
|
||||
if ($out =~ /Device or resource busy/i) {
|
||||
# already on..
|
||||
$rv += 2;
|
||||
@@ -181,8 +185,10 @@ Internal function to check if the quotaon -p flag is supported.
|
||||
sub supports_status
|
||||
{
|
||||
if (!defined($supports_status_cache{$_[0],$_[1]})) {
|
||||
&clean_language();
|
||||
local $stout = &backquote_command(
|
||||
"$config{$_[1].'_quotaon_command'} -p $_[0] 2>&1");
|
||||
&reset_environment();
|
||||
$supports_status_cache{$_[0],$_[1]} =
|
||||
$stout =~ /is\s+(on|off|enabled|disabled)/ ? $stout : 0;
|
||||
}
|
||||
@@ -295,8 +301,10 @@ Runs the quotacheck command on some filesytem, and returns 1 on success or
|
||||
=cut
|
||||
sub run_quotacheck
|
||||
{
|
||||
&clean_language();
|
||||
local $out =&backquote_logged(
|
||||
"$config{'quotacheck_command'} $_[1] $_[0] 2>&1");
|
||||
&reset_environment();
|
||||
return $? || $out =~ /cannot guess|cannot remount|cannot find|please stop/i ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -7082,6 +7082,21 @@ if (%UNCLEAN_ENV) {
|
||||
}
|
||||
}
|
||||
|
||||
=head2 clean_language
|
||||
|
||||
Sets all language and locale-related environment variables to US english, to
|
||||
ensure that commands run output in the expected language. Can be reverted by
|
||||
reset_environment.
|
||||
|
||||
=cut
|
||||
sub clean_language
|
||||
{
|
||||
%UNCLEAN_ENV = %ENV;
|
||||
$ENV{'LANG'} = '';
|
||||
$ENV{'LC_ALL'} = '';
|
||||
$ENV{'LOCALE'} = '';
|
||||
}
|
||||
|
||||
=head2 progress_callback
|
||||
|
||||
Never called directly, but useful for passing to &http_download to print
|
||||
|
||||
Reference in New Issue
Block a user