ServDoc_exim - describe the exim daemon
$Id: ServDoc_0233exim,v 1.2 2004/02/19 07:17:48 uherbst Exp $
ServDoc_exim [-h|help] [-v|version] [--debug EXIM,intensity]
ServDoc_exim describe the exim daemon (if installed).
We describe it only if exim is running.
The debug feature for that module is named ``EXIM''.
Bas Couwenberg <sebastic@xs4all.nl>
#!/usr/bin/perl -w
#---------------------------------------------------------------------- # standard perl modules use strict; # print error about unknown variables ... use English; # long internal variable names; use FindBin; # In which directory is ServDoc itself ? # There has to be the module and the lib dir! use lib $FindBin::Bin. "/lib"; # Here are the ServDoc-perl-modules use File::Basename; # our own perl modules use ServDoc; #---------------------------------------------------------------------- my $options; $options->{Version} = '$Id: ServDoc_0233exim,v 1.2 2004/02/19 07:17:48 uherbst Exp $'; # We need the cmdline to call the modules with the same debug options. $options->{cmdline} = join " ", @ARGV; sub debug { ServDoc_debug( "EXIM", $options, shift, shift ); } $options = &process_cmdline($options); debug( 9, "ServDoc_exim is running" ); #---------------------------------------------------------------------- # Main # Here is your useful code. my $heading = "Net%+Services%+Exim%+"; # Check for running exim my @exim = ps_grep ("exim|inetd"); exit 0 if ($#exim < 0); my $fullcmd = find_path('exim'); if (!defined($fullcmd)) { debug(8,"We can't find the exim executable"); exit 0; } # Exim version and more my $versionstring = do_cmd("$fullcmd -bV"); report_string ($heading . "Version","exim -bV","", $versionstring); # Running from inetd or standalone? my $inet_config_file = "/etc/inetd.conf"; my $standalone = 1; my $inetd_exim = ''; if(-f $inet_config_file) { if(-r $inet_config_file) { open(F, $inet_config_file); while(<F>) { if(/^smtp.*exim/) { $standalone = 0; $inetd_exim = $_; } } close F; } } if($standalone == 1) { report_string ($heading . "Standalone or inetd","Standalone","", ""); } else { report_string ($heading . "Standalone or inetd","inetd","inetd.conf", "$inetd_exim"); } # Exim config file my $eximconf = "/etc/exim/exim.conf"; foreach(@exim) { if(/exim.*?\-C (.*?) /) { $eximconf = $1; } } my $conffile = readfile($eximconf); report_string ($heading . "Config file%+exim.conf","$eximconf","", $conffile); # Aliases file my $aliases = "/etc/aliases"; # Default location if(-r $eximconf) { # Read through the exim config and locate # the (user defined) aliases file my $seen = 0; open(F, $eximconf); while(<F>) { chomp; if(/^system_aliases/ || $seen) { debug(3,"Seen aliases\n") if($seen != 1); $seen = 1; if(/^\s*file\s*=\s*(.*)\s*$/) { $aliases = $1; $seen = 0; } } } close F; } # Strip whitespace file filename if any if($aliases =~ s/\s+//g) {} if($aliases =~ /\$domain\s*$/) { # Aliases file foreach localdomain # Default configuration would be "file = /etc/aliases/$domain", # but another directory could be possible (my $dir) = $aliases =~ m!^(.*?/)\$domain!; if(-r $dir) { opendir(DIR, $dir); foreach my $file (readdir DIR) { # Skip current and parent dir if($file !~ /^.{1,2}$/) { $file = $dir.$file; my $conffile = readfile($file); report_string ($heading . "Aliases file%+$file","","", $conffile); } } closedir DIR; } else { debug(8,"Cannot read aliases directory"); } } else { # Just one aliases file (might also be something other than /etc/aliases # Multiple domain could also be configured in a single aliases file my $conffile = readfile($aliases); report_string ($heading . "Aliases file%+$aliases","","", $conffile); } # Email-addresses file my $email_addresses = "/etc/email-addresses"; if(-r $email_addresses) { # Only used in the Rewriting section of exim.conf # Can be user defined, but is then almost impossible # to extract from exim.conf ( at least for me ;-) ) my $conffile = readfile($email_addresses); report_string ($heading . "Email-Addresses file%+$email_addresses","","", $conffile); } else { debug(8,"Cannot read email-addresses file"); } exit 0;