Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use new API for clearing language

  • Loading branch information...
commit f0bb980ebe42393a69427e79797209f2f8ec7b29 1 parent 539c9df
@jcameron jcameron authored
View
10 mount/linux-lib.pl
@@ -874,7 +874,9 @@ sub disk_space
if (&get_mounted($_[1], "*") < 0) { return (); }
if ($_[0] eq "proc" || $_[0] eq "swap" ||
$_[0] eq "auto" || $_[0] eq "autofs") { return (); }
-local $out = &backquote_command("LC_ALL='' LANG='' df -k ".quotemeta($_[1]), 1);
+&clean_language();
+local $out = &backquote_command("df -k ".quotemeta($_[1]), 1);
+&reset_environment();
if ($out =~ /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
return ($1, $2);
}
@@ -886,8 +888,10 @@ sub disk_space
sub inode_space
{
if (&get_mounted($_[1], "*") < 0) { return (); }
-if (&backquote_command("LC_ALL='' LANG='' df -i $_[1]", 1) =~
- /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
+&clean_language();
+local $out = &backquote_command("df -i $_[1]", 1);
+&reset_environment();
+if ($out =~ /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
return ($1, $2);
}
return ( );
View
4 net/linux-lib.pl
@@ -7,13 +7,15 @@ sub active_interfaces
{
local ($empty) = @_;
local(@rv, @lines, $l);
-&open_execute_command(IFC, "LC_ALL='' LANG='' ifconfig -a", 1, 1);
+&clean_language();
+&open_execute_command(IFC, "ifconfig -a", 1, 1);
while(<IFC>) {
s/\r|\n//g;
if (/^\S+/) { push(@lines, $_); }
else { $lines[$#lines] .= $_; }
}
close(IFC);
+&reset_environment();
my $ethtool = &has_command("ethtool");
foreach $l (@lines) {
local %ifc;
View
4 proc/proc-lib.pl
@@ -499,7 +499,9 @@ sub get_cpu_info
if (defined(&os_get_cpu_info)) {
return &os_get_cpu_info();
}
-local $out = `uptime 2>&1`;
+&clean_language();
+local $out = &backquote_command("uptime 2>&1");
+&reset_environment();
return $out =~ /average(s)?:\s+([0-9\.]+),?\s+([0-9\.]+),?\s+([0-9\.]+)/i ?
( $2, $3, $4 ) : ( );
}
View
4 samba/samba-lib.pl
@@ -222,7 +222,9 @@ sub list_locks
{
local($l, $started, @rv);
local $out;
-&execute_command("LANG=C $config{samba_status_program} -L", undef, \$out, undef);
+&clean_language();
+&execute_command("$config{samba_status_program} -L", undef, \$out, undef);
+&reset_environment();
foreach $l (split(/\n/, $out)) {
if ($l =~ /^----/) { $started = 1; }
if ($started && $l =~ /^(\d+)\s+(\d+)\s+(\S+)\s+(0x\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S.*)\s\s((Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s.*)/i) {
View
29 software/apt-lib.pl
@@ -140,8 +140,8 @@ sub update_system_available
# Use dump to get versions
&execute_command("$apt_get_command update");
-&open_execute_command(DUMP,
- "LANG='' LC_ALL='' apt-cache dump 2>/dev/null", 1, 1);
+&clean_language();
+&open_execute_command(DUMP, "apt-cache dump 2>/dev/null", 1, 1);
while(<DUMP>) {
if (/^\s*Package:\s*(\S+)/) {
$pkg = { 'name' => $1 };
@@ -160,6 +160,7 @@ sub update_system_available
}
}
close(DUMP);
+&reset_environment();
# Use search to get descriptions
foreach my $s (&update_system_search('.*')) {
@@ -178,7 +179,8 @@ sub update_system_available
sub update_system_search
{
local (@rv, $pkg);
-&open_execute_command(DUMP, "LANG='' LC_ALL='' $apt_search_command search ".
+&clean_language();
+&open_execute_command(DUMP, "$apt_search_command search ".
quotemeta($_[0])." 2>/dev/null", 1, 1);
while(<DUMP>) {
if (/^(\S+)\s*-\s*(.*)/) {
@@ -189,6 +191,7 @@ sub update_system_search
}
}
close(DUMP);
+&reset_environment();
return @rv;
}
@@ -201,22 +204,23 @@ sub update_system_updates
# Find held packages by dpkg
local %holds;
if ($config{'package_system'} eq 'debian') {
- &open_execute_command(HOLDS,
- "LANG='' LC_ALL='' dpkg --get-selections", 1, 1);
+ &clean_language();
+ &open_execute_command(HOLDS, "dpkg --get-selections", 1, 1);
while(<HOLDS>) {
if (/^(\S+)\s+hold/) {
$holds{$1}++;
}
}
close(HOLDS);
+ &reset_environment();
}
if (&has_command("apt-show-versions")) {
# This awesome command can give us all updates in one hit, and takes
# pinned versions and backports into account
local @rv;
- &open_execute_command(PKGS,
- "LANG='' LC_ALL='' apt-show-versions 2>/dev/null", 1, 1);
+ &clean_language();
+ &open_execute_command(PKGS, "apt-show-versions 2>/dev/null", 1, 1);
while(<PKGS>) {
if (/^(\S+)\/(\S+)\s+upgradeable\s+from\s+(\S+)\s+to\s+(\S+)/ &&
!$holds{$1}) {
@@ -230,6 +234,7 @@ sub update_system_updates
}
}
close(PKGS);
+ &reset_environment();
return @rv;
}
else {
@@ -258,8 +263,8 @@ sub update_system_updates
@somenames = @names;
@names = ( );
}
- &open_execute_command(PKGS,
- "LANG='' LC_ALL='' apt-cache showpkg ".
+ &clean_language();
+ &open_execute_command(PKGS, "apt-cache showpkg ".
join(" ", @somenames)." 2>/dev/null", 1, 1);
local $pkg = undef;
while(<PKGS>) {
@@ -287,6 +292,7 @@ sub update_system_updates
}
}
close(PKGS);
+ &reset_environment();
}
&set_pinned_versions(\@rv);
return @rv;
@@ -300,8 +306,8 @@ sub set_pinned_versions
{
local ($pkgs) = @_;
local %pkgmap = map { $_->{'name'}, $_ } @$pkgs;
-&open_execute_command(PKGS,
- "LANG='' LC_ALL='' apt-cache policy 2>/dev/null", 1, 1);
+&clean_language();
+&open_execute_command(PKGS, "apt-cache policy 2>/dev/null", 1, 1);
while(<PKGS>) {
s/\r|\n//g;
if (/\s+(\S+)\s+\-\>\s+(\S+)/) {
@@ -317,5 +323,6 @@ sub set_pinned_versions
}
}
close(PKGS);
+&reset_environment();
}
View
5 system-status/system-status-lib.pl
@@ -171,9 +171,10 @@ sub add_historic_collected_info
}
my $ifaces = join(" ", @ifaces);
foreach my $iname (@ifaces) {
+ &clean_language();
my $out = &backquote_command(
- "LC_ALL='' LANG='' ifconfig ".
- quotemeta($iname)." 2>/dev/null");
+ "ifconfig ".quotemeta($iname)." 2>/dev/null");
+ &reset_environment();
my $rx = $out =~ /RX\s+bytes:\s*(\d+)/i ? $1 : undef;
my $tx = $out =~ /TX\s+bytes:\s*(\d+)/i ? $1 : undef;
$rxtotal += $rx;
View
4 useradmin/linux-lib.pl
@@ -48,7 +48,8 @@ sub read_last_line
sub os_most_recent_logins
{
my %rv;
-open(LASTLOG, "LANG=C lastlog |");
+&clean_language();
+open(LASTLOG, "lastlog |");
while(<LASTLOG>) {
s/\r|\n//g;
if (/^(\S+)/) {
@@ -63,6 +64,7 @@ sub os_most_recent_logins
}
}
close(LASTLOG);
+&reset_environment();
return \%rv;
}
View
1  web-lib-funcs.pl
@@ -7093,6 +7093,7 @@ sub clean_language
{
%UNCLEAN_ENV = %ENV;
$ENV{'LANG'} = '';
+$ENV{'LANGUAGE'} = '';
$ENV{'LC_ALL'} = '';
$ENV{'LOCALE'} = '';
}
View
39 webmin/gnupg-lib.pl
@@ -22,7 +22,8 @@
sub list_keys
{
my (@rv, %kmap);
-open(GPG, "LC_ALL='' LANG='' $gpgpath --list-keys 2>/dev/null |");
+&clean_language();
+open(GPG, "$gpgpath --list-keys 2>/dev/null |");
while(<GPG>) {
if (/^pub\s+(\S+)\/(\S+)\s+(\S+)\s+(.*)\s+<(\S+)>/ ||
/^pub\s+(\S+)\/(\S+)\s+(\S+)\s+(.*)/) {
@@ -56,13 +57,14 @@ sub list_keys
}
}
close(GPG);
-open(GPG, "LC_ALL='' LANG='' $gpgpath --list-secret-keys 2>/dev/null |");
+open(GPG, "$gpgpath --list-secret-keys 2>/dev/null |");
while(<GPG>) {
if (/^sec\s+(\S+)\/(\S+)\s+(\S+)\s+(.*)/ && $kmap{$2}) {
$kmap{$2}->{'secret'}++;
}
}
close(GPG);
+&reset_environment();
return @rv;
}
@@ -86,13 +88,15 @@ sub key_fingerprint
{
my $fp;
local $_;
-open(GPG, "LC_ALL='' LANG='' $gpgpath --fingerprint \"$_[0]->{'name'}->[0]\" |");
+&clean_language();
+open(GPG, "$gpgpath --fingerprint \"$_[0]->{'name'}->[0]\" |");
while(<GPG>) {
if (/fingerprint\s+=\s+(.*)/) {
$fp = $1;
}
}
close(GPG);
+&reset_environment();
return $fp;
}
@@ -130,7 +134,8 @@ sub encrypt_data
my $ascii = $_[3] ? "--armor" : "";
my $comp = $config{'compress'} eq '' ? "" :
" --compress-algo $config{'compress'}";
-my $cmd = "LC_ALL='' LANG='' $gpgpath --output $dstfile $rcpt $ascii $comp --encrypt $srcfile";
+&clean_language();
+my $cmd = "$gpgpath --output $dstfile $rcpt $ascii $comp --encrypt $srcfile";
my ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
while(1) {
my $rv = &wait_for($fh, "anyway");
@@ -142,6 +147,7 @@ sub encrypt_data
}
}
close($fh);
+&reset_environment();
unlink($srcfile);
my $dst = &read_entire_file($dstfile);
unlink($dstfile);
@@ -162,7 +168,8 @@ sub decrypt_data
my $srcfile = &transname();
&write_entire_file($srcfile, $_[0]);
my $dstfile = &transname();
-my $cmd = "LC_ALL='' LANG='' $gpgpath --output $dstfile --decrypt $srcfile";
+&clean_language();
+my $cmd = "$gpgpath --output $dstfile --decrypt $srcfile";
my ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
my ($error, $seen_pass, $pass, $key, $keyid);
while(1) {
@@ -187,6 +194,7 @@ sub decrypt_data
}
}
close($fh);
+&reset_environment();
unlink($srcfile);
my $dst = &read_entire_file($dstfile);
unlink($dstfile);
@@ -227,8 +235,9 @@ sub sign_data
elsif ($_[3] == 2) {
$cmd = "$gpgpath --armor --output $dstfile --default-key $_[2]->{'key'} --detach-sig $srcfile";
}
-$cmd = "LC_ALL='' LANG='' $cmd";
+&clean_language();
my ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
+&reset_environment();
my ($error, $seen_pass);
my $pass = &get_passphrase($_[2]);
if (!defined($pass)) {
@@ -277,18 +286,20 @@ sub verify_data
my $cmd;
my $sigfile;
if (!$_[1]) {
- $cmd = "LC_ALL='' LANG='' $gpgpath --verify $datafile";
+ $cmd = "$gpgpath --verify $datafile";
}
else {
$sigfile = &transname();
&write_entire_file($sigfile, $_[1]);
- $cmd = "LC_ALL='' LANG='' $gpgpath --verify $sigfile $datafile";
+ $cmd = "$gpgpath --verify $sigfile $datafile";
}
#local ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
#&wait_for($fh);
#close($fh);
#local $out = $wait_for_input;
+&clean_language();
my $out = &backquote_command("$cmd 2>&1 </dev/null");
+&reset_environment();
unlink($datafile);
unlink($sigfile) if ($sigfile);
if ($out =~ /BAD signature from "(.*)"/i) {
@@ -336,7 +347,8 @@ sub write_entire_file
# Returns the trust level of a key
sub get_trust_level
{
-my $cmd = "LC_ALL='' LANG='' $gpgpath --edit-key \"$_[0]->{'name'}->[0]\"";
+&clean_language();
+my $cmd = "$gpgpath --edit-key \"$_[0]->{'name'}->[0]\"";
my ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
my $rv = &wait_for($fh, "trust:\\s+(.)", "command>");
my $tr;
@@ -349,6 +361,7 @@ sub get_trust_level
}
syswrite($fh, "quit\n", length("quit\n"));
close($fh);
+&reset_environment();
return $tr;
}
@@ -358,7 +371,8 @@ sub delete_key
{
my ($key) = @_;
if ($key->{'secret'}) {
- my $cmd = "LC_ALL='' LANG='' $gpgpath --delete-secret-key \"$key->{'name'}->[0]\"";
+ &clean_language();
+ my $cmd = "$gpgpath --delete-secret-key \"$key->{'name'}->[0]\"";
my ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
&wait_for($fh, "\\?");
syswrite($fh, "y\n");
@@ -366,13 +380,16 @@ sub delete_key
syswrite($fh, "y\n");
sleep(1);
close($fh);
+ &reset_environment();
}
-my $cmd = "LC_ALL='' LANG='' $gpgpath --delete-key \"$key->{'name'}->[0]\"";
+&clean_language();
+my $cmd = "$gpgpath --delete-key \"$key->{'name'}->[0]\"";
my ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", $cmd);
&wait_for($fh, "\\?");
syswrite($fh, "y\n");
sleep(1);
close($fh);
+&reset_environment();
}
# default_email_address()
Please sign in to comment.
Something went wrong with that request. Please try again.