mirror of
https://github.com/webmin/webmin.git
synced 2026-09-15 10:00:40 +01:00
Fix Postfix map updates failing when CIDR tables are configured
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
* Add DNF 4 and 5 package hold management to the Software Package Updates module
|
||||
* Add `return` based redirects with 301, 302, 303, 307 and 308 codes to the URL Re-Writing pages in the Nginx Webserver module [forum.virtualmin.com/t/137940](https://forum.virtualmin.com/t/137940)
|
||||
* Fix DNF update confirmations by previewing packages and dependencies that will be installed or updated
|
||||
* Fix Postfix map updates failing when CIDR tables are configured
|
||||
* Fix PostgreSQL initialization on EL systems to use SCRAM-SHA-256 authentication by default
|
||||
* Fix IPsec host key generation with modern Libreswan [#2132](https://github.com/webmin/webmin/issues/2132)
|
||||
* Fix journal since filter showing oldest entries on older systemd [forum.virtualmin.com/t/137876](https://forum.virtualmin.com/t/137876)
|
||||
|
||||
@@ -804,8 +804,10 @@ sub regenerate_any_table
|
||||
foreach my $map (@files)
|
||||
{
|
||||
next unless $map;
|
||||
# Text maps are read directly by Postfix and cannot be indexed.
|
||||
if (&file_map_type($map->[0]) &&
|
||||
$map->[0] ne 'regexp' && $map->[0] ne 'pcre') {
|
||||
$map->[0] ne 'regexp' && $map->[0] ne 'pcre' &&
|
||||
$map->[0] ne 'cidr') {
|
||||
my $out = &backquote_logged(
|
||||
$config{'postfix_lookup_table_command'}.
|
||||
" -c $config_dir".
|
||||
|
||||
@@ -118,6 +118,36 @@ is_deeply([ get_maps_types_files('') ], [],
|
||||
is_deeply([ get_maps_types_files('garbage-without-colon') ], [],
|
||||
'unparseable value yields no maps');
|
||||
|
||||
# --- map regeneration ----------------------------------------------------
|
||||
# Rebuild only indexed maps, preserving their configured types. Text and
|
||||
# external database maps must never be passed to postmap for indexing.
|
||||
{
|
||||
no warnings qw(redefine once);
|
||||
my @commands;
|
||||
my $maps = 'hash:/fixture/hash, lmdb:/fixture/lmdb, btree:/fixture/btree, '.
|
||||
'dbm:/fixture/dbm, regexp:/fixture/regexp, pcre:/fixture/pcre, '.
|
||||
'cidr:/fixture/cidr, mysql:/fixture/mysql';
|
||||
local *get_current_value = sub { return $maps; };
|
||||
local *get_real_value = sub { return $maps; };
|
||||
local *backquote_logged = sub { push(@commands, $_[0]); $? = 0; return ''; };
|
||||
local $config{'postfix_lookup_table_command'} = '/fixture/postmap';
|
||||
regenerate_transport_table();
|
||||
is(scalar(@commands), 4, 'only indexed maps are rebuilt');
|
||||
foreach my $type ('hash', 'lmdb', 'btree', 'dbm') {
|
||||
ok(scalar(grep { index($_, "$type:/fixture/$type") >= 0 } @commands),
|
||||
"$type map keeps its configured type");
|
||||
}
|
||||
@commands = ();
|
||||
$maps = 'cidr:/fixture/cidr';
|
||||
regenerate_transport_table();
|
||||
is_deeply(\@commands, [], 'CIDR-only configuration requires no index');
|
||||
local *backquote_logged = sub { $? = 256; return 'postmap failed'; };
|
||||
local *error = sub { die $_[0]; };
|
||||
$maps = 'hash:/fixture/hash';
|
||||
eval { regenerate_transport_table(); };
|
||||
like($@, qr/postmap failed/, 'indexing failures retain the Postfix error');
|
||||
}
|
||||
|
||||
# --- get_maps_files (path extraction) --------------------------------------
|
||||
is_deeply([ get_maps_files('hash:/etc/postfix/aliases,hash:/etc/aliases') ],
|
||||
[ '/etc/postfix/aliases', '/etc/aliases' ],
|
||||
|
||||
Reference in New Issue
Block a user