From fdd29b3deda32edd576794de48110ce8e45e9451 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 7 Feb 2018 17:48:11 -0800 Subject: [PATCH] Add check for unregistered 'mailman' list https://www.virtualmin.com/node/55730 --- virtualmin-mailman-lib.pl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/virtualmin-mailman-lib.pl b/virtualmin-mailman-lib.pl index 20a2efc..244dabe 100755 --- a/virtualmin-mailman-lib.pl +++ b/virtualmin-mailman-lib.pl @@ -25,6 +25,7 @@ our $mailman_var = $config{'mailman_var'} || $mailman_dir; our $newlist_cmd = "$mailman_dir/bin/newlist"; our $rmlist_cmd = "$mailman_dir/bin/rmlist"; +our $list_lists_cmd = "$mailman_dir/bin/list_lists"; our $mailman_cmd = $config{'mailman_cmd'} || "$mailman_dir/bin/mailman"; if (!-x $mailman_cmd && $config{'alt_mailman_cmd'}) { # Hack needed to handle CentOS 4 @@ -84,6 +85,15 @@ sub list_lists return @rv; } +# list_real_lists() +# Returns a list of the names of actual lists that exist in the Mailman config +sub list_real_lists +{ +my $out = &backquote_command("$list_lists_cmd -b 2>/dev/null {'list'} eq 'mailman' } @lists; if ($mailman) { - # Already exists + # Already exists and is known to Virtualmin + return 0; + } +my @real = &list_real_lists(); +if (&indexof('mailman', @real) >= 0) { + # Already exists, although not registered in Virtualmin return 0; } &foreign_require("init", "init-lib.pl");