Move My-Audit to PerlMail::Config.
[PerlMail.git] / perlmail-accept
index 08f6a2b..30e7833 100755 (executable)
@@ -27,13 +27,18 @@ INIT {
        }
 
 
+use File::Basename;
+BEGIN {
+       use lib $ENV{"PERLMAIL_BASEDIR"} || File::Basename::dirname($0);
+       use PerlMail::Config;
+       }
+
 use Mail::Audit qw(MAPS);
 require IO::Handle;
 use Carp qw(cluck confess);
 use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG);
 require POSIX; # for ceil
 use User::Utmp;
-require File::Basename;
 use Getopt::Long;
 require Mail::Address;
 require MIME::Words;
@@ -49,16 +54,6 @@ use URI::Escape 'uri_escape';
 require WWW::SMS;
 
 
-my $HOME="/home/lace";
-my $Mail="$HOME/Mail";
-my @ValidUsers=qw(root lace short kratochvil _local);
-my $IdleMax=10;
-my $MaxBodySMS=0x1000; # max bytes to pass to Lingua::EN::Squeeze
-my $SMSmailError='short+err@ucw.cz';
-my @SMSwebRcpt=qw(420 602 431329);
-my $SMSwebRcpt_username="lace2";
-my $SMScontact='<short@ucw.cz>';
-
 our($Message,$Audit,@AuditStored,$store_ignore,$store_ignorenewmail,$store_profile,$DoBell);
 our(%audit_profile,@sms_squeezes,@alternates_host,@dnsbl_whitelist);   # imported
 my %alternates_host;   # from @alternates_host
@@ -255,7 +250,7 @@ my($ignorenewmail,$smscount,%args)=@_;
        return map({
                        my $l=160;
                        if (!$ignorenewmail) {  # send by mail
-                               $l-=length("Z emailu $SMSmailError: ");
+                               $l-=length("Z emailu FIXME SMSmailError: ");
                                $l-=length(smsbuild($_,$smscount));
                                }
                        else {  # send by web
@@ -736,7 +731,6 @@ my($header,$map)=@_;
 
 # MAIN
 
-my $basedir=File::Basename::dirname($0);
 $Getopt::Long::ignorecase=0;
 die "GetOptions error" if !Getopt::Long::GetOptions(
                  "inetd"    ,sub { $opt_mode=\&inetd; },
@@ -746,21 +740,13 @@ die "GetOptions error" if !Getopt::Long::GetOptions(
                  "idle!"    ,\$opt_idle,
                  "idletest" ,sub { syslogging_restore(); print((defined($_=useridle()) ? $_ : "<undef>")."\n"); exit 0; },
                  "muttrc"   ,sub { syslogging_restore(); print scalar muttrc(); exit 0; },
-               "d|basedir=s",\&basedir,
                );
 # "Excessive arguments" checked in &inetd
 die "Missing mode" if !$opt_mode;
 
-my $filenameMyAudit="$basedir/My-Audit.pm";
-open AUDIT,$filenameMyAudit or die "open \"$filenameMyAudit\": $!";
-{
-       local $/=undef();
-       eval <AUDIT> or die "eval \"$filenameMyAudit\": $@";
-       audit_init();
-       %alternates_host=map((lc($_)=>1),@alternates_host);
-       %dnsbl_whitelist=map((   $_ =>1),@dnsbl_whitelist);
-       }
-close AUDIT or warn "close \"$filenameMyAudit\": $!";
+PerlMail::Config::audit_init();
+%alternates_host=map((lc($_)=>1),@alternates_host);
+%dnsbl_whitelist=map((   $_ =>1),@dnsbl_whitelist);
 
 &$opt_mode();
 die "NOTREACHED";