forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_inst.cgi
executable file
·125 lines (115 loc) · 5.48 KB
/
check_inst.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/local/bin/perl
# check_inst.cgi
# check majordomo options and installation
require './majordomo-lib.pl';
use Fcntl ':mode';
%access = &get_module_acl();
$conf = &get_config();
eval { require "$config{'program_dir'}/majordomo_version.pl"; };
&ui_print_header(undef, $text{'check_title'}, "", undef, 1, 0, 0,
&mdom_help(),
undef, undef, &text('index_version', $majordomo_version));
$aliases_files = &get_aliases_file();
$email = &find_value("whoami", $conf); $email =~ s/\@.*$//g;
$owner = &find_value("whoami_owner", $conf); $owner =~ s/\@.*$//g;
# predefined values
local $cdiv='<div style="margin-left: 20%;">', $ediv='</div>';
local $ok="<div style=\"padding: .3em;\"><font color=\"green\">".&text('ok')."</font></div>";
local $fail="<div style=\"padding: .3em;\"><font color=\"red\">".&text('fail')."</font></div>";
local $possible="<div style=\"padding: .3em;\"><font color=\"orange\">".&text('check_possible')."</font></div>";
local $res=$ok, $tocheck, $sec;
# init / start table
local @tds;
push(@tds, "width=0", "width=30% nowrap", "width=60%", "");
print &ui_columns_start(["",&text('check_test'), &text('check_result'), &text('check_status')], 100, 0, \@tds);
# Check mailer / aliaes / config file
local $aliases=$aliases_files->[0], $mailer=$config{'aliases_file'};
$mailer="sendmail" if ($mailer eq '');
print &ui_checked_columns_row(["<b>Autodetect aliases file from mailer</b>", ucfirst($mailer), $res],
\@tds,undef, undef, 0,1);
$res=$ok;
$tocheck=$aliases;
if (!-r $tocheck) { $res=$fail; $tocheck = &text('index_esendmail', 'Sendmail alias file', $tocheck,
"$gconfig{'webprefix'}/config.cgi?$module_name"); }
print &ui_checked_columns_row(["<b>Aliases file used for majordomo</b>", $tocheck, $res],
\@tds,undef, undef, 0,1);
$res=$ok;
$tocheck=$config{'majordomo_cf'};
if (!-r $tocheck) { $res=$fail; $tocheck = &text('index_econfig', "<tt>$tocheck</tt>",
"$gconfig{'webprefix'}/config.cgi?$module_name"); }
print &ui_checked_columns_row(["<b>Majordomo configuration file</b>", $tocheck, $res],
\@tds,undef, undef, 0,1);
# config files exist?
if ( $res eq $ok) {
# Check program dir / version
$res=$ok;
local $progdir, $progdirok;
$tocheck= $progdir = $config{'program_dir'};
if (!-d $tocheck ) { $res=$fail; $tocheck = &text('index_eprograms', "<tt>$tocheck</tt>",
"$gconfig{'webprefix'}/config.cgi?$module_name"); }
print &ui_checked_columns_row(["<b>Majordomo programm dir</b>", $tocheck, $res],
\@tds,undef, undef, 0,1);
if ($res eq $ok) {
$progdirok=1;
$res=$ok;
$sec=$cdiv.&text('check_perm').":";
$tocheck=$config{'program_dir'};
if (((stat($tocheck)) [2] & S_IXOTH) != 0) { $res=$fail; $sec .= " ".&text('check_exec'); }
if (((stat($tocheck)) [2] & S_IROTH) != 0) { $res=$fail; $sec .= " ".&text('check_read'); }
if (((stat($tocheck)) [2] & S_IWOTH) != 0) { $res=$fail; $sec .= " ".&text('check_write'); }
print &ui_checked_columns_row(["", $sec.$ediv, $res] , \@tds,undef, undef, 0,1);
$res=$ok;
$tocheck=$majordomo_version;
if ($tocheck eq "" || $tocheck < 1.94 || $tocheck >= 2) { $res=$fail; $tocheck .= ": ".$text{'index_eversion'}; }
print &ui_checked_columns_row(["<b>".&text('index_version',"")."</b>", $tocheck, $res],
\@tds,undef, undef, 0,1);
}
# Check home / list / archive dir from majordomo.cf
$res=$ok;
local $home=&find_value("homedir", $conf);
$tocheck=$home;
if ($tocheck ne $progdir) { $res=$fail; $tocheck = &text('index_emdomdir',
'$homedir'." (should be ".$progdir."!)", $tocheck); }
print &ui_checked_columns_row(["<b>Majordomo script HOME dir</b>", $tocheck, $res],
\@tds,undef, undef, 0,1);
$res=$ok;
local $home=&find_value("homedir2", $conf);
$tocheck=$home;
if (! -d $tocheck) { $res=$fail; $tocheck = &text('index_emdomdir', '$homedir2', $home); }
print &ui_checked_columns_row(["<b>Majordomo list HOME2 dir</b>", $tocheck, $res],
\@tds,undef, undef, 0,1);
if ($res eq $ok) {
$res=$ok;
$sec=$cdiv.&text('check_perm').":";
$tocheck=$home;
if (((stat($tocheck)) [2] & S_IXOTH) != 0) { $res=$possible; $sec .= " ".&text('check_exec'); }
if (((stat($tocheck)) [2] & S_IROTH) != 0) { $res=$possible; $sec .= " ".&text('check_read'); }
if (((stat($tocheck)) [2] & S_IWOTH) != 0) { $res=$possible; $sec .= " ".&text('check_write'); }
print &ui_checked_columns_row(["", $sec.$ediv, $res] , \@tds,undef, undef, 0,1);
}
$res=$ok;
$tocheck = &perl_var_replace(&find_value("listdir", $conf), $conf);
if (!-d $tocheck) { $res=$fail; $tocheck = &text('index_emdomdir', '$listdir', $tocheck); }
print &ui_checked_columns_row(["<b>Majordomo LIST directory</b>", $tocheck, $res],
\@tds,undef, undef, 0,1);
$res=$ok;
$tocheck = &perl_var_replace(&find_value("filedir", $conf), $conf);
if (!-d $tocheck) { $res=$fail; $tocheck = &text('index_emdomdir', '$filedir', $tocheck); }
print &ui_checked_columns_row(["<b>Majordomo ARCHIVE directory</b>", $tocheck, $res],
\@tds,undef, undef, 0,1);
# run wrapper config-test
if ($progdirok == 1) {
local $cmd="$progdir/wrapper config-test";
local $realcmd="cd $progdir; echo n | $cmd 2>&1";
local $text=`$realcmd`;
$text =~ s/(^|\n)[\n\s]*/$1/g;
$text =~ s/Nothing bad found!.*/Nothing bad found!/s;
if ($? != 0) {$res=$fail;}
print &ui_checked_columns_row(["<b>Run Majormomo internal test</b>", $cmd, $res] ,
\@tds,undef, undef, 0,1);
print &ui_checked_columns_row(["", "<pre>${text}</pre>", ""],
\@tds,undef, undef, 0,1);
}
}
print &ui_columns_end();
&ui_print_footer("index.cgi", $text{'index'});