mirror of
https://github.com/webmin/webmin.git
synced 2026-10-29 06:31:04 +00:00
This PR fixes package installation pages stopping after "Re-fetching available packages .." on RPM systems, before the System Status refresh, reboot check, and return link appeared. The regression was introduced by https://github.com/webmin/webmin/commit/658f930, which wrapped RPM queries in `clean_environment` while the Package Updates installer had already cleaned the environment. The inner clean overwrote the only saved environment, leaving `WEBMIN_CONFIG` unset and causing the System Status library to fail after the page headers had been sent. Nested `clean_environment` calls now save separate snapshots, allowing each `reset_environment` call to restore the matching environment exactly while preserving Virtualmin's API script runner behavior.
43 lines
1.0 KiB
Perl
43 lines
1.0 KiB
Perl
#!/usr/bin/perl
|
|
# Tests nested environment cleanup and exact restoration.
|
|
|
|
use strict;
|
|
use warnings;
|
|
use Test::More;
|
|
use File::Basename qw(dirname);
|
|
use File::Spec;
|
|
|
|
my $root = File::Spec->rel2abs(File::Spec->catfile(dirname(__FILE__), '..'));
|
|
require File::Spec->catfile($root, 'web-lib-funcs.pl');
|
|
|
|
my %original = (
|
|
'PATH' => '/bin:/usr/bin',
|
|
'LANG' => 'de_DE.UTF-8',
|
|
'WEBMIN_CONFIG' => '/etc/webmin',
|
|
'HTTP_ACCEPT' => 'text/html',
|
|
);
|
|
|
|
{
|
|
local %ENV = %original;
|
|
no warnings 'once';
|
|
local @main::clean_environment_stack;
|
|
local %main::UNCLEAN_ENV;
|
|
|
|
main::clean_environment();
|
|
$ENV{'WEBMIN_CONFIG'} = '/nested/etc/webmin';
|
|
main::clean_environment();
|
|
main::clean_language();
|
|
main::reset_environment();
|
|
|
|
is($ENV{'WEBMIN_CONFIG'}, '/nested/etc/webmin',
|
|
'nested reset restores the outer cleaned environment');
|
|
ok(!exists($ENV{'HTTP_ACCEPT'}),
|
|
'nested reset does not restore the original request environment');
|
|
|
|
main::reset_environment();
|
|
is_deeply({ %ENV }, \%original,
|
|
'outer reset restores the original environment exactly');
|
|
}
|
|
|
|
done_testing();
|