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);
}
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 ( );
{
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;
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 ) : ( );
}
{
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) {
# 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 };
}
}
close(DUMP);
+&reset_environment();
# Use search to get descriptions
foreach my $s (&update_system_search('.*')) {
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*(.*)/) {
}
}
close(DUMP);
+&reset_environment();
return @rv;
}
# 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}) {
}
}
close(PKGS);
+ &reset_environment();
return @rv;
}
else {
@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>) {
}
}
close(PKGS);
+ &reset_environment();
}
&set_pinned_versions(\@rv);
return @rv;
{
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+)/) {
}
}
close(PKGS);
+&reset_environment();
}
}
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;
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+)/) {
}
}
close(LASTLOG);
+&reset_environment();
return \%rv;
}
{
%UNCLEAN_ENV = %ENV;
$ENV{'LANG'} = '';
+$ENV{'LANGUAGE'} = '';
$ENV{'LC_ALL'} = '';
$ENV{'LOCALE'} = '';
}
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+(.*)/) {
}
}
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;
}
{
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;
}
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");
}
}
close($fh);
+&reset_environment();
unlink($srcfile);
my $dst = &read_entire_file($dstfile);
unlink($dstfile);
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) {
}
}
close($fh);
+&reset_environment();
unlink($srcfile);
my $dst = &read_entire_file($dstfile);
unlink($dstfile);
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)) {
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) {
# 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;
}
syswrite($fh, "quit\n", length("quit\n"));
close($fh);
+&reset_environment();
return $tr;
}
{
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");
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()