3 # check postfix configuration
5 require './postfix-lib.pl';
9 $System=$in{'system'}||1;
10 $Package=$in{'package'}||1;
11 $Locking=$in{'locking'}||0;
12 $Tables=$in{'tables'}||0;
14 $Master=$in{'master'}||1;
15 $Permissions=$in{'permissions'}||0;
16 $Libraries=$in{'libraries'}||0;
18 $Defaultsinmain=$in{'defaultsinmain'}||1;
20 $access{'postfinger'} || &error($text{'postfinger_ecannot'});
21 &header($text{'postfinger_title'}, "");
23 print "<br><form action=postfinger.cgi>\n";
24 print "<input type=hidden name=go value=go>\n";
25 print "<table border>\n";
26 print "<tr $cb> <td><table>\n";
27 print "<tr $cb> <td><font color=0000FF size=4><b>Display Options:</b></font></td></tr>\n";
28 print "<tr $cb> <td><b>System</b></td> <td colspan=3>\n";
29 printf "<input type=radio name=system value=1 %s> %s\n",
30 $System eq 1 ? 'checked' : '', $text{'yes'};
31 printf "<input type=radio name=system value=no %s> %s\n",
32 $System eq 1 ? '' : 'checked', $text{'no'},
33 join(" ", $System),"</td> </tr>\n";
35 print "<tr $cb> <td><b>Package</b></td> <td colspan=3>\n";
36 printf "<input type=radio name=package value=1 %s> %s\n",
37 $Package eq 1 ? 'checked' : '', $text{'yes'};
38 printf "<input type=radio name=package value=no %s> %s\n",
39 $Package eq 1 ? '' : 'checked', $text{'no'},
40 join(" ", $Package),"</td> </tr>\n";
42 print "<tr $cb> <td><b>Main</b></td> <td colspan=3>\n";
43 printf "<input type=radio name=main value=1 %s> %s\n",
44 $Main eq 1 ? 'checked' : '', $text{'yes'};
45 printf "<input type=radio name=main value=no %s> %s\n",
46 $Main eq 1 ? '' : 'checked', $text{'no'},
47 join(" ", $Main),"</td> </tr>\n";
49 print "<tr $cb> <td><b>Defaults in Main</b></td> <td colspan=3>\n";
50 printf "<input type=radio name=defaultsinmain value=1 %s> %s\n",
51 $Defaultsinmain eq 1 ? 'checked' : '', $text{'yes'};
52 printf "<input type=radio name=defaultsinmain value=no %s> %s\n",
53 $Defaultsinmain eq 1 ? '' : 'checked', $text{'no'},
54 join(" ", $Defaultsinmain),"</td> </tr>\n";
56 print "<tr $cb> <td><b>Master</b></td> <td colspan=3>\n";
57 printf "<input type=radio name=master value=1 %s> %s\n",
58 $Master eq 1 ? 'checked' : '', $text{'yes'};
59 printf "<input type=radio name=master value=no %s> %s\n",
60 $Master eq 1 ? '' : 'checked', $text{'no'},
61 join(" ", $Master),"</td> </tr>\n";
63 print "<tr $cb> <td><b>Locking</b></td> <td colspan=3>\n";
64 printf "<input type=radio name=locking value=1 %s> %s\n",
65 $Locking eq 1 ? 'checked' : '', $text{'yes'};
66 printf "<input type=radio name=locking value=no %s> %s\n",
67 $Locking eq 1 ? '' : 'checked', $text{'no'},
68 join(" ", $Locking),"</td> </tr>\n";
70 print "<tr $cb> <td><b>Tables</b></td> <td colspan=3>\n";
71 printf "<input type=radio name=tables value=1 %s> %s\n",
72 $Tables eq 1 ? 'checked' : '', $text{'yes'};
73 printf "<input type=radio name=tables value=no %s> %s\n",
74 $Tables eq 1 ? '' : 'checked', $text{'no'},
75 join(" ", $Tables),"</td> </tr>\n";
77 print "<tr $cb> <td><b>Permissions</b></td> <td colspan=3>\n";
78 printf "<input type=radio name=permissions value=1 %s> %s\n",
79 $Permissions eq 1 ? 'checked' : '', $text{'yes'};
80 printf "<input type=radio name=permissions value=no %s> %s\n",
81 $Permissions eq 1 ? '' : 'checked', $text{'no'},
82 join(" ", $Permissions),"</td> </tr>\n";
84 print "<tr $cb> <td><b>Libraries</b></td> <td colspan=3>\n";
85 printf "<input type=radio name=libraries value=1 %s> %s\n",
86 $Libraries eq 1 ? 'checked' : '', $text{'yes'};
87 printf "<input type=radio name=libraries value=no %s> %s\n",
88 $Libraries eq 1 ? '' : 'checked', $text{'no'},
89 join(" ", $Libraries),"</td> </tr>\n";
91 print "<tr $cb> <td><b>Warn</b></td> <td colspan=3>\n";
92 printf "<input type=radio name=warn value=1 %s> %s\n",
93 $Warn eq 1 ? 'checked' : '', $text{'yes'};
94 printf "<input type=radio name=warn value=no %s> %s\n",
95 $Warn eq 1 ? '' : 'checked', $text{'no'},
96 join(" ", $Warn),"</td> </tr>\n";
97 print "<tr><td> </td></tr><tr><td><input type=submit value=\"$text{'postfinger_show'}\"></td></tr></form>\n";
99 print "</table></td> </tr></table>";
100 &footer("index.cgi", $text{'index_title'});
103 if (! -x $config{'postfix_config_command'} && ! -r $config{'postfix_config_file'} ) {
104 print "Can not find postconf";
107 # Verify that current configuration is valid
108 if ($config{'index_check'} && ($err = &check_postfix())) {
109 print "<p>",&text('check_error'),"<p>\n";
110 print "<pre>$err</pre>\n";
111 &footer("/", $text{'index'});
115 # print '<center><b>--System Parameters--</b></center>';
116 if (&has_command($config{'postfix_config_command'})) {
117 print "<h1 class='p'>Postfix Version: $postfix_version</h1>";
119 print "</table><br />";
120 print "<table border='0' cellpadding='3' width='600' align='center'>";
121 open(MAILQ, "/bin/hostname 2>/dev/null |");
122 while (my $hostname = <MAILQ>) { print "<tr><td class='e'>Hostname </td><td class='v'>$hostname</td></tr>"; }
124 open(MAILQ, "/bin/uname -a 2>/dev/null |");
125 while (my $uname = <MAILQ>) { print "<tr><td class='e'>System </td><td class='v'>$uname</td></tr>"; }
128 print "</table><br />";
131 if ($Locking eq 1 ) {
132 print '<h1 align="center">Mailbox locking methods</h1>';
133 print '<table border="0" cellpadding="0" width="600" align="center">';
134 open(MAILQ, "$config{'postfix_config_command'} -l 2>/dev/null |");
135 while (my $locking_methods = <MAILQ>) {
136 print "<tr><td class='v'><center><b>$locking_methods</b></center></td></tr>"; }
138 print "</table><br />";
142 print '<h1 align="center">Supported Lookup Tables</h1>';
143 print '<table border="0" cellpadding="0" width="600" align="center">';
144 # print '<center><b>--Supported Lookup tables--</b></center><br>';
145 open(MAILQ, "$config{'postfix_config_command'} -m 2>/dev/null |");
146 while (my $lookup_tables = <MAILQ>) {
147 print "<tr><td class='v'><center><b>$lookup_tables</b></center></td></tr>"; }
149 print "</table><br />";
152 if (($Main eq 1 || $Defaultsinmain eq 1 ) && ("x`find . -prune \( -perm 020 -o -perm 002 \) -print`" != "x")){
153 print "<center><b>Do not run this in a public- or group-writable directory</b></center><br>";
156 system ("rm postfinger.*.d postfinger.*.n");
157 # unlink "postfinger.*.d, postfinger.*.n";
158 `$config{'postfix_config_command'} -d | tr -s [:blank:] | sort > postfinger.$$.d`;
159 `$config{'postfix_config_command'} -n | tr -s [:blank:] | sort > postfinger.$$.n`;
162 print '<h1 align="center">main.cf</h1><br><h2 align="center">non-default parameters</h2>';
163 print '<table border="0" cellpadding="2" width="600" align="center">';
164 # print '<center><b>--main.cf non-default parameters--</b></center><br>';
165 open(MAILQ, "/usr/bin/comm -13 postfinger.$$.d postfinger.$$.n 2>/dev/null |");
166 while (my $postfinger = <MAILQ>) {
167 ($postf1,$postf2)=split(/=/,$postfinger,2);
168 print "<tr><td class='e'><b>$postf1</b></td>";
169 print "<td class='v'>$postf2</td></tr>"; }
171 print "</table><br />";
174 if ($Defaultsinmain eq 1 ) {
175 print '<h1 align="center">main.cf</h1><br><h2 align="center">parameters defined as per defaults</h2>';
176 print '<table border="0" cellpadding="2" width="600" align="center">';
177 # print '<center><b>--main.cf parameters defined as per defaults--</b></center><br>';
178 open(MAILQ, "/usr/bin/comm -12 postfinger.$$.d postfinger.$$.n 2>/dev/null |");
179 while (my $postfinger = <MAILQ>) {
180 ($postf1,$postf2)=split(/=/,$postfinger,2);
181 print "<tr><td class='e'><b>$postf1</b></td>";
182 print "<td class='v'>$postf2</td></tr>"; }
184 print "</table><br />";
186 unlink "postfinger.*.d, postfinger.*.n";
190 print '<h1 align="center">master.cf</h1><br>';
191 print '<table border="0" cellpadding="8" width="600" align="center">';
192 print "<tr><td class='e'><b>service</b></td><td class='v'><b>type</b></td>",
193 "<td class='v'><b>private</b></td><td class='v'><b>unpriv</b></td>",
194 "<td class='v'><b>chroot</b></td><td class='v'><b>wakeup</b></td>",
195 "<td class='v'><b>maxproc</b></td><td class='v'><b>command + args</b></td></tr>";
196 open(MAILQ, "/bin/cat `$config{'postfix_config_command'} -h config_directory`/master.cf 2>/dev/null |");
197 while (my $postfinger = <MAILQ>) {
198 ($postf1,$postf2,$postf3,$postf4,$postf5,$postf6,$postf7,$postf8)=split(/\s+/,$postfinger,8);
199 if ( grep(/\-\o/,$postfinger)){
200 print "<tr><td class='e'> </td><td class='v'> </td>",
201 "<td class='v'> </td><td class='v'> </td>",
202 "<td class='v'> </td><td class='v'> </td>",
203 "<td class='v'> </td><td class='v'>$postf2</td></tr>"
204 if ( !grep(/^#|^\[ \]*$/,$postfinger));
205 } elsif ( grep(/user=/,$postfinger)){
206 print "<tr><td class='e'> </td><td class='v'> </td>",
207 "<td class='v'> </td><td class='v'> </td>",
208 "<td class='v'> </td><td class='v'> </td>",
209 "<td class='v'> </td><td class='v'>$postf1</td></tr>"
210 if ( !grep(/^#|^\[ \]*$/,$postfinger));
212 print "<tr><td class='e'><b>$postf1</b></td><td class='v'><center>$postf2</center></td>",
213 "<td class='v'><center>$postf3</center></td><td class='v'><center>$postf4</center></td>",
214 "<td class='v'><center>$postf5</center></td><td class='v'><center>$postf6</center></td>",
215 "<td class='v'><center>$postf7</center></td><td class='v'>$postf8</td></tr>"
216 if ( !grep(/^#|^\[ \]*$/,$postfinger));
220 print "</table><br>";
223 if ($Permissions eq 1 ) {
224 print '<h1 align="center">Specific file and directory permissions</h1><br>';
225 print '<table border="0" cellpadding="0" width="600" align="center">';
226 print "<tr><td class='e'><b>Permission</b> Deep <b>Owner</b> <b>Group</b> Size Date <b>Directory/File</b> </td></tr>";
227 open(MAILQ, "/bin/ls -ld `$config{'postfix_config_command'} -h queue_directory`/maildrop 2>/dev/null |");
228 while (my $postfinger = <MAILQ>) {
229 print "<tr><td class='v'>$postfinger</td></tr>"
230 if ( !grep(/total|^#|^\[ \]*$/,$postfinger));
233 print "<tr><td> </td></tr>";
234 open(MAILQ, "/bin/ls -ld `$config{'postfix_config_command'} -h queue_directory`/public 2>/dev/null |");
235 while (my $postfinger = <MAILQ>) {
236 print "<tr><td class='v'>$postfinger</td></tr>"
237 if ( !grep(/total|^#|^\[ \]*$/,$postfinger));
240 print "<tr><td> </td></tr>";
241 if (! open(MAILQ, "/bin/ls -l `$config{'postfix_config_command'} -h queue_directory`/public 2>/dev/null |")) {
242 print '<center><b>WARNING: No access to $queue_directory/public<br>Try running postfinger as user root or postfix</b></center><br>';
244 while (my $postfinger = <MAILQ>) {
245 print "<tr><td class='v'>$postfinger</td></tr>"
246 if ( !grep(/total|^#|^\[ \]*$/,$postfinger));
249 print "<tr><td> </td></tr>";
251 open(MAILQ, "/bin/ls -ld `$config{'postfix_config_command'} -h queue_directory`/private 2>/dev/null |");
252 while (my $postfinger = <MAILQ>) {
253 print "<tr><td class='v'>$postfinger</td></tr>"
254 if ( !grep(/total|^#|^\[ \]*$/,$postfinger));
257 print "<tr><td> </td></tr>";
258 if (! open(MAILQ, "/bin/ls -l `$config{'postfix_config_command'} -h queue_directory`/private 2>/dev/null |")) {
259 print '<center><b>WARNING: No access to $queue_directory/private<br>Try running postfinger as user root or postfix</b></center><br>';
261 while (my $postfinger = <MAILQ>) {
262 print "<tr><td class='v'>$postfinger</td></tr>"
263 if ( !grep(/total|^#|^\[ \]*$/,$postfinger));
266 print "<tr><td> </td></tr>";
268 open(MAILQ, "/bin/ls -l `$config{'postfix_config_command'} -h command_directory`/postdrop 2>/dev/null |");
269 while (my $postfinger = <MAILQ>) {
270 print "<tr><td class='v'>$postfinger</td></tr>"
271 if ( !grep(/total|^#|^\[ \]*$/,$postfinger));
274 print "<tr><td> </td></tr>";
275 open(MAILQ, "/bin/ls -l `$config{'postfix_config_command'} -h command_directory`/postqueue 2>/dev/null |");
276 while (my $postfinger = <MAILQ>) {
277 print "<tr><td class='v'>$postfinger</td></tr>"
278 if ( !grep(/total|^#|^\[ \]*$/,$postfinger));
281 print "</table><br>";
283 if ($Libraries eq 1 ) {
284 print '<h1 align="center">Library dependencies</h1>';
285 print '<table border="0" cellpadding="0" width="600" align="center">';
286 if (! open(MAILQ, "/usr/bin/ldd `$config{'postfix_config_command'} -h daemon_directory`/smtpd 2>/dev/null |")) {
287 print '<center><b>WARNING: Can not find ldd. Check you have it installed and in your path</b></center><br>';
289 while (my $postfinger = <MAILQ>) {
290 ($postf1,$postf2)=split(/=/,$postfinger,2);
291 print "<tr><td class='e'><b>$postf1</b></td>";
292 print "<td class='v'>=$postf2</td></tr>";
295 print "</table><br>";
298 print "</td> </tr></table></td> </tr></table>";
299 &footer("index.cgi", $text{'index_title'});
303 print "<style type='text/css'><!--";
304 #print "body {background-color: #ffffff; color: #000000;}";
305 #print "body, td, th, h1, h2 {font-family: sans-serif;}";
306 print "pre {margin: 0px; font-family: monospace;}";
307 print "a:link {color: #000099; text-decoration: none;}";
308 print "a:hover {text-decoration: underline;}";
309 #print "table {border-collapse: collapse;}";
310 print ".center {text-align: center;}";
311 #print ".center table { margin-left: auto; margin-right: auto; text-align: left;}";
312 #print ".center th { text-align: center; !important }";
313 #print "td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}";
314 print "h1 {font-size: 150%;}";
315 print "h2 {font-size: 125%;}";
316 print ".p {text-align: left;}";
317 print ".e {background-color: #ccccff; font-weight: bold;}";
318 print ".h {background-color: #9999cc; font-weight: bold;}";
319 print ".v {background-color: #cccccc;}";
320 print "i {color: #666666;}";
321 #print "img {float: right; border: 0px;}";
322 print "hr {width: 600px; align: center; background-color: #cccccc; border: 0px; height: 1px;}";
323 print "//--></style>";
324 #print "<title>Postfinger</title></head>";
325 #print "<body><div class='center'>";
326 print "<table border='0' cellpadding='3' width='600' align='center'>";
327 print "<tr class='h'><td>";