Skip to content

Commit d9ea2a7

Browse files
committed
strict/warn
1 parent ca4264a commit d9ea2a7

16 files changed

+366
-289
lines changed

add.cgi

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/local/bin/perl
22
# Add a new mailing list, and record it
3+
use strict;
4+
use warnings;
5+
our (%access, %text, %in);
6+
our $remote_user;
37

48
require './virtualmin-mailman-lib.pl';
59
&ReadParse();
@@ -11,22 +15,22 @@ $in{'list'} =~ /^[a-z0-9\.\-\_]+$/i || &error($text{'add_ename'});
1115
if ($in{'list'} ne 'mailman') {
1216
$in{'dom'} =~ /^[a-z0-9\.\-]+$/i || &error($text{'add_edom'});
1317
}
14-
@lists = &list_lists();
15-
($clash) = grep { $_->{'list'} eq $in{'list'} } @lists;
18+
my @lists = &list_lists();
19+
my ($clash) = grep { $_->{'list'} eq $in{'list'} } @lists;
1620
$clash && &error($text{'add_eclash'});
1721
$in{'email_def'} || $in{'email'} =~ /^\S+\@\S+$/ || &error($text{'add_eemail'});
1822
$in{'pass_def'} || $in{'pass'} =~ /\S/ || &error($text{'add_epass'});
1923

2024
# Check limit on lists
21-
@alllists = &list_lists();
25+
my @alllists = &list_lists();
2226
@lists = grep { &can_edit_list($_) } @alllists;
2327
if ($access{'max'} && @lists >= $access{'max'}) {
2428
&error($text{'index_max'});
2529
}
2630

2731
if ($in{'list'} eq 'mailman') {
2832
# The special 'mailman' list has no domain
29-
$err = &create_list($in{'list'}, $in{'dom'},
33+
my $err = &create_list($in{'list'}, $in{'dom'},
3034
"Mailman administration list",
3135
undef, $in{'email'}, $in{'pass'});
3236
&error($err) if ($err);
@@ -36,30 +40,31 @@ if ($in{'list'} eq 'mailman') {
3640
if (&init::action_status("mailman")) {
3741
&init::enable_at_boot("mailman");
3842
&init::stop_action("mailman");
39-
($ok, $err) = &init::start_action("mailman");
40-
&error(&text('add_einit', "<pre>".&html_escape($out)."</pre>"))
43+
my ($ok, $err) = &init::start_action("mailman");
44+
&error(&text('add_einit', "<pre>".&html_escape($err)."</pre>"))
4145
if (!$ok);
4246
}
4347
}
4448
else {
4549
# Get the Virtualmin domain
46-
$vdom = &virtual_server::get_domain_by("dom", $in{'dom'});
50+
my $vdom = &virtual_server::get_domain_by("dom", $in{'dom'});
51+
my $parentdom;
4752
$vdom || &error($text{'add_evdom'});
4853
if ($vdom->{'parent'}) {
4954
$parentdom = &virtual_server::get_domain($vdom->{'parent'});
5055
}
5156

5257
# Check for a clash on aliases or users
53-
@aliases = &virtual_server::list_virtusers();
54-
@clash = grep {
58+
my @aliases = &virtual_server::list_virtusers();
59+
my @clash = grep {
5560
$_->{'from'} eq $in{'list'}.'@'.$vdom->{'dom'} ||
5661
$_->{'from'} =~ /^\Q$in{'list'}\E\-.*\@\Q$vdom->{'dom'}\E/
5762
} @aliases;
5863
if (@clash) {
5964
&error(&text('add_ealiases',
6065
join(" ", map { $_->{'from'} } @clash)));
6166
}
62-
@users = &virtual_server::list_domain_users($vdom);
67+
my @users = &virtual_server::list_domain_users($vdom);
6368
@clash = grep {
6469
$_->{'email'} eq $in{'list'}.'@'.$vdom->{'dom'} ||
6570
$_->{'email'} =~ /^\Q$in{'list'}\E\-.*\@\Q$vdom->{'dom'}\E/
@@ -70,10 +75,10 @@ else {
7075
}
7176

7277
# Create the list
73-
$pass = $in{'pass_def'} && $parentdom ? $parentdom->{'pass'} :
78+
my $pass = $in{'pass_def'} && $parentdom ? $parentdom->{'pass'} :
7479
$in{'pass_def'} ? $vdom->{'pass'} : $in{'pass'};
7580
$pass || &error(&text('add_epass2', $vdom->{'dom'}));
76-
$err = &create_list($in{'list'}, $in{'dom'}, $in{'desc'}, $in{'lang'},
81+
my $err = &create_list($in{'list'}, $in{'dom'}, $in{'desc'}, $in{'lang'},
7782
$in{'email_def'} && $vdom->{'emailto'} ? $vdom->{'emailto'}:
7883
$in{'email_def'} ? "$remote_user\@$in{'dom'}" :
7984
$in{'email'},
@@ -82,4 +87,3 @@ else {
8287
}
8388

8489
&redirect("index.cgi?show=$in{'show'}");
85-

add_member.cgi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
#!/usr/local/bin/perl
22
# Add one list member
3+
use strict;
4+
use warnings;
5+
our (%text, %in);
36

47
require './virtualmin-mailman-lib.pl';
58
&ReadParse();
69
&error_setup($text{'addmem_err'});
7-
@lists = &list_lists();
8-
($list) = grep { $_->{'list'} eq $in{'list'} } @lists;
10+
my @lists = &list_lists();
11+
my ($list) = grep { $_->{'list'} eq $in{'list'} } @lists;
912
&can_edit_list($list) || &error($text{'mems_ecannot'});
1013

1114
# Validate and store inputs
1215
$in{'email'} =~ /^\S+$/ || &error($text{'addmem_eemail'});
13-
$mem = { 'email' => $in{'email'},
16+
my $mem = { 'email' => $in{'email'},
1417
'digest' => $in{'digest'},
1518
'welcome' => $in{'welcome'},
1619
'admin' => $in{'admin'} };
17-
$err = &add_member($mem, $list);
20+
my $err = &add_member($mem, $list);
1821
&error($err) if ($err);
1922
&redirect("list_mems.cgi?list=$in{'list'}&show=$in{'show'}");
20-

admin.cgi

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/usr/local/bin/perl
22
# Run a mailman CGI program, and display output with Webmin header
3+
use strict;
4+
use warnings;
5+
our (%text, %config);
6+
our $module_name;
7+
our $mailman_dir;
8+
our $doneheaders; # XXX I'm not sure about this one.
39

410
require './virtualmin-mailman-lib.pl';
11+
my $lname;
512
if ($ENV{'PATH_INFO'} =~ /^\/([^\/]+)(.*)/) {
613
$lname = $1;
714
}
@@ -12,20 +19,21 @@ elsif ($ENV{'PATH_INFO'} eq '' || $ENV{'PATH_INFO'} eq '/') {
1219
else {
1320
&error($text{'edit_eurl'});
1421
}
15-
$prog = $ENV{'SCRIPT_NAME'};
22+
my $prog = $ENV{'SCRIPT_NAME'};
1623
$prog =~ s/^.*\///;
1724
$prog =~ s/\.cgi$//;
1825

19-
@lists = &list_lists();
26+
my @lists = &list_lists();
27+
my $d;
2028
if ($lname) {
2129
# Get the list, and from it the domain
22-
($list) = grep { $_->{'list'} eq $lname } @lists;
30+
my ($list) = grep { $_->{'list'} eq $lname } @lists;
2331
&can_edit_list($list) || &error($text{'edit_ecannot'});
2432
$d = &virtual_server::get_domain_by("dom", $list->{'dom'});
2533
}
2634
else {
2735
# Get the domain from the URL
28-
$dname = $ENV{'HTTP_HOST'};
36+
my $dname = $ENV{'HTTP_HOST'};
2937
$dname =~ s/:\d+$//;
3038
$d = &virtual_server::get_domain_by("dom", $dname);
3139
if (!$d) {
@@ -35,10 +43,11 @@ else {
3543
$dname || &error(&text('edit_edname', &html_escape($dname)));
3644
}
3745

38-
$cgiuser = &get_mailman_apache_user($d);
46+
my $cgiuser = &get_mailman_apache_user($d);
47+
my ($prot, $httphost);
3948
if ($config{'rewriteurl'}) {
4049
# Custom URL for Mailman, perhaps if behind proxy
41-
($httphost, $httpport, $httppage, $httpssl) =
50+
my ($httphost, $httpport, $httppage, $httpssl) =
4251
&parse_http_url($config{'rewriteurl'});
4352
$httphost .= ":".$httpport if ($httpport != ($httpssl ? 443 : 80));
4453
$prot = $httpssl ? "https" : "http";
@@ -54,27 +63,29 @@ else {
5463
}
5564

5665
# Work out possible hostnames for URLs
57-
@realhosts = ( &get_system_hostname(),
66+
my @realhosts = ( &get_system_hostname(),
5867
$httphost,
5968
(map { $_->{'dom'} } grep { $_->{$module_name} }
6069
&virtual_server::list_domains()) );
6170

6271
# Read posted data
63-
$temp = &transname();
64-
open(TEMP, ">$temp");
72+
my $temp = &transname();
73+
open(my $TEMP, ">", "$temp");
74+
my $qs;
6575
if (defined(&read_fully)) {
66-
&read_fully(STDIN, \$qs, $ENV{'CONTENT_LENGTH'});
76+
&read_fully($STDIN, \$qs, $ENV{'CONTENT_LENGTH'});
6777
}
6878
else {
6979
read(STDIN, $qs, $ENV{'CONTENT_LENGTH'});
7080
}
71-
print TEMP $qs;
72-
close(TEMP);
81+
print $TEMP $qs;
82+
close($TEMP);
7383

7484
# Run the real command, and fix up output
75-
$cmd = &command_as_user($cgiuser, 0, "$mailman_dir/cgi-bin/$prog");
76-
$textarea = 0;
77-
open(CGI, "$cmd <$temp |");
85+
my $cmd = &command_as_user($cgiuser, 0, "$mailman_dir/cgi-bin/$prog");
86+
my $textarea = 0;
87+
my ($headers, $body);
88+
open(my $CGI, "<", "$cmd <$temp |");
7889
while(<CGI>) {
7990
# Check if we are in a textarea
8091
if (/<textarea/i) { $textarea = 1; }
@@ -86,7 +97,7 @@ while(<CGI>) {
8697
s/\/(cgi-bin\/)?mailman\/([^\/ "']+)\.cgi/\/$module_name\/$2.cgi/g || s/\/(cgi-bin\/)?mailman\/([^\/ "']+)([\/ "'])/\/$module_name\/$2.cgi$3/g;
8798
}
8899
if (!/pipermail/) {
89-
foreach $realhost (@realhosts) {
100+
foreach my $realhost (@realhosts) {
90101
s/(http|https):\/\/$realhost\//$prot:\/\/$httphost\//g && last;
91102
}
92103
s/(http|https):\/\/(lists\.)?$d->{'dom'}\//$prot:\/\/$httphost\//g;
@@ -109,6 +120,7 @@ while(<CGI>) {
109120
close(CGI);
110121

111122
print $headers;
123+
my $title;
112124
if ($body =~ /<title>([^>]*)<\/title>/i) {
113125
$title = $1;
114126
}
@@ -117,5 +129,3 @@ $body =~ s/<\/body[^>]*>[\000-\377]*//i;
117129
&ui_print_header(undef, $title, "");
118130
print $body;
119131
&ui_print_footer("", $text{'index_return'});
120-
121-

cgi_args.pl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use strict;
2+
use warnings;
3+
our $module_name;
14

25
do 'virtualmin-mailman-lib.pl';
36

delete.cgi

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/usr/local/bin/perl
22
# Remove one mailing list
3+
use strict;
4+
use warnings;
5+
our (%text, %in, %config);
36

47
require './virtualmin-mailman-lib.pl';
58
&ReadParse();
69
&error_setup($text{'delete_err'});
710

8-
@lists = &list_lists();
9-
($listname) = grep { $_ ne "confirm" && $_ ne "show" } keys %in;
11+
my @lists = &list_lists();
12+
my ($listname) = grep { $_ ne "confirm" && $_ ne "show" } keys %in;
1013

1114
if ($listname =~ /^mems_(\S+)$/) {
1215
# Actually editing members .. redirect
@@ -17,8 +20,8 @@ elsif ($listname =~ /^man_(\S+)$/) {
1720
# Actually managing list .. redirect
1821
if ($config{'manage_url'}) {
1922
# Custom URL
20-
($list) = grep { $_->{'list'} eq $1 } @lists;
21-
$d = &virtual_server::get_domain_by("dom", $list->{'dom'});
23+
my ($list) = grep { $_->{'list'} eq $1 } @lists;
24+
my $d = &virtual_server::get_domain_by("dom", $list->{'dom'});
2225
&redirect(&virtual_server::substitute_domain_template(
2326
$config{'manage_url'}, $d));
2427
}
@@ -36,9 +39,9 @@ elsif ($listname =~ /^reset_(\S+)$/) {
3639

3740
# Get the list
3841
$listname eq "mailman" && &error($text{'delete_emailman'});
39-
($list) = grep { $_->{'list'} eq $listname } @lists;
42+
my ($list) = grep { $_->{'list'} eq $listname } @lists;
4043
&can_edit_list($list) || &error($text{'delete_ecannot'});
41-
$d = &virtual_server::get_domain_by("dom", $list->{'dom'});
44+
my $d = &virtual_server::get_domain_by("dom", $list->{'dom'});
4245
$d || &error($text{'delete_edon'});
4346

4447
if (!$in{'confirm'}) {
@@ -53,9 +56,8 @@ if (!$in{'confirm'}) {
5356
}
5457
else {
5558
# Do it
56-
$err = &delete_list($listname, $list->{'dom'});
59+
my $err = &delete_list($listname, $list->{'dom'});
5760
&error($err) if ($err);
5861

5962
&redirect("");
6063
}
61-

delete_member.cgi

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
#!/usr/local/bin/perl
22
# Delete one list member
3+
use strict;
4+
use warnings;
5+
our (%text, %in);
36

47
require './virtualmin-mailman-lib.pl';
58
&ReadParse();
69
&error_setup($text{'deletemem_err'});
7-
@lists = &list_lists();
8-
($list) = grep { $_->{'list'} eq $in{'list'} } @lists;
10+
my @lists = &list_lists();
11+
my ($list) = grep { $_->{'list'} eq $in{'list'} } @lists;
912
&can_edit_list($list) || &error($text{'mems_ecannot'});
1013

11-
@mems = &list_members($list);
12-
($email) = grep { $_ ne "list" && $_ ne "show" } (keys %in);
13-
($mem) = grep { $_->{'email'} eq $email } @mems;
14+
my @mems = &list_members($list);
15+
my ($email) = grep { $_ ne "list" && $_ ne "show" } (keys %in);
16+
my ($mem) = grep { $_->{'email'} eq $email } @mems;
1417
$mem || &error($text{'deletemem_emem'});
1518

16-
$err = &remove_member($mem, $list);
19+
my $err = &remove_member($mem, $list);
1720
&error($err) if ($err);
1821
&redirect("list_mems.cgi?list=$in{'list'}&show=$in{'show'}");

export_mems.cgi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/usr/local/bin/perl
22
# Output text list of members
3+
use strict;
4+
use warnings;
5+
our (%text, %in);
36

47
require './virtualmin-mailman-lib.pl';
58
&ReadParse();
6-
@lists = &list_lists();
7-
($list) = grep { $_->{'list'} eq $in{'list'} } @lists;
9+
my @lists = &list_lists();
10+
my ($list) = grep { $_->{'list'} eq $in{'list'} } @lists;
811
&can_edit_list($list) || &error($text{'mems_ecannot'});
912

1013
print "Content-type: text/plain\n\n";
11-
foreach $m (&list_members($list)) {
14+
foreach my $m (&list_members($list)) {
1215
print $m->{'email'},"\n";
1316
}
14-

fixurls.cgi

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#!/usr/local/bin/perl
22
# Fix Webmin redirect URLs on a list of domains
3+
use strict;
4+
use warnings;
5+
our (%text, %in);
6+
our $module_name;
37

48
require './virtualmin-mailman-lib.pl';
59
&ReadParse();
610

711
# Get all the domains
8-
@doms = ( );
9-
foreach $id (split(/\0/, $in{'d'})) {
10-
$d = &virtual_server::get_domain($id);
12+
my @doms = ( );
13+
foreach my $id (split(/\0/, $in{'d'})) {
14+
my $d = &virtual_server::get_domain($id);
1115
if ($d && &virtual_server::can_edit_domain($d) && $d->{$module_name}) {
1216
push(@doms, $d);
1317
}
@@ -16,11 +20,11 @@ foreach $id (split(/\0/, $in{'d'})) {
1620
# Fix them, showing progress
1721
&ui_print_header(undef, $text{'fixurls_title'}, "");
1822

19-
foreach $d (@doms) {
23+
foreach my $d (@doms) {
2024
print &text('fixurls_fixing', $d->{'dom'},
2125
&get_mailman_webmin_url($d)),"<br>\n";
2226
&virtual_server::obtain_lock_web($d);
23-
$err = &fix_webmin_mailman_urls($d);
27+
my $err = &fix_webmin_mailman_urls($d);
2428
if ($err) {
2529
print &text('fixurls_failed', $err),"<p>\n";
2630
}
@@ -34,4 +38,3 @@ foreach $d (@doms) {
3438
&webmin_log("fixurls");
3539

3640
&ui_print_footer("", $text{'index_return'});
37-

0 commit comments

Comments
 (0)