X-Git-Url: http://git.treefish.org/fex.git/blobdiff_plain/7fa382617fbaccc0ce522b2b3adbbee9db5ad227..20150729:/bin/fac diff --git a/bin/fac b/bin/fac index 0946704..b17d026 100755 --- a/bin/fac +++ b/bin/fac @@ -43,7 +43,7 @@ unless ($<) { umask 077; # import from fex.pp -our ($FEXHOME,$FHS,$hostname,$spooldir,$logdir,$akeydir,$docdir); +our ($FEXHOME,$FHS,$hostname,$spooldir,@logdir,$akeydir,$docdir); our ($durl,@durl,$mdomain,$admin,$mailmode); our ($autodelete,$keep_default,$keep_max,$recipient_quota,$sender_quota); our (@local_rdomains); @@ -198,7 +198,7 @@ if ($opt_M) { # show logfile if ($opt_w) { - $log = "$logdir/fexsrv.log"; + $log = $logdir[0]."/fexsrv.log"; warn "$0: polling $log\n\n"; exec "$FEXHOME/bin/logwatch",$log; die "$0: logwatch not found\n"; @@ -361,7 +361,7 @@ if ($opt_A) { open $fph,">$fph" or die "$0: cannot write to $fph - $!\n"; print {$fph} $_; close $fph; - system "cp $FEXLIB/fup.pl $vhd/lib/fup.pl"; + cpa("$FEXLIB/fup.pl","$vhd/lib"); foreach $i (qw'dop fex.pp fup.pl lf.pl reactivation.txt') { # symlink "$FEXLIB/$i","$vhd/lib/$i"; symlink "../../lib/$i","$vhd/lib/$i"; @@ -401,10 +401,10 @@ if ($opt_A) { } # show config -if ($opt_v) { +if ($opt_v and not @ARGV) { print "config from $FEXLIB/fex.ph :\n"; print " spooldir = $spooldir\n"; - print " logdir = $logdir\n"; + print " logdir = @logdir\n"; print " docdir = $docdir\n"; print " durl = @durl\n"; print " admin = $admin\n"; @@ -433,26 +433,27 @@ if ($opt_v) { # add user or show user config if ($opt_u) { + chdir $spooldir or die "$0: cannot chdir $spooldir = $!\n"; if ($opt_u = shift @ARGV) { $user = lc $opt_u; $user .= '@'.$mdomain if $mdomain and $user !~ /@/; $id = shift @ARGV; - $idf = "$spooldir/$user/@"; + $idf = "$user/@"; if (open $idf,$idf) { chomp($ido = <$idf>||''); close $idf; } unless ($id) { - die "$0: $user is not a FEX user\n" unless -f "$spooldir/$user/@"; + die "$0: $user is not a regular FEX user\n" unless -f "$user/@"; showuser($user,$ido); exit; } unless ($user =~ /\w@[\w.-]+\.[a-z]+$/) { die "$0: $user is not a valid email-address!\n"; } - unless (-d "$spooldir/$user") { - mkdir "$spooldir/$user",0755 - or die "$0: cannot mkdir $spooldir/$user - $!\n"; + unless (-d $user) { + mkdir $user,0755 + or die "$0: cannot mkdir $user - $!\n"; } open F,">$idf" or die "$0: cannot write $idf - $!\n"; print F $id,"\n"; @@ -460,7 +461,7 @@ if ($opt_u) { showuser($user,$id); } else { print "Users in $spooldir:\n"; - foreach $user (glob "$spooldir/*/@") { + foreach $user (glob "*/@") { $user =~ s:.*/(.+)/@:$1:; print "$user\n"; } @@ -533,7 +534,7 @@ if ($opt_q) { $user = lc $opt_q; $user .= '@'.$mdomain if $mdomain and $user !~ /@/; unless (-d "$spooldir/$user") { - die "$0: $user is not a regular FEX user\n"; + die "$0: $user is not a FEX user\n"; } quota($user,@ARGV); exit; @@ -637,7 +638,7 @@ usage(3); sub showuser { my $user = shift; my $id = shift; - my ($keep,$autodelete,$notification); + my ($keep,$autodelete,$notification,$login); $user .= '@'.$mdomain if $mdomain and $user !~ /@/; @@ -646,6 +647,14 @@ sub showuser { printf "%s/%s\n",$fup,b64("from=$user&id=$id"); # printf "%s/%s\n",$fup,b64("from=$user&to=$user&id=$id&submit=."); print "spool: $spooldir/$user/\n"; + if ($login_check and $login = readlink "$user/.login") { + my $lc = &$login_check($login); + if ($lc) { + print "login: $login\n"; + } else { + print "login: DELETED\n"; + } + } printf "fex yourself web default: %s\n", -e "$spooldir/$user/\@FEXYOURSELF" ? 'yes' : 'no'; printf "persistent: %s\n", @@ -712,7 +721,7 @@ sub fupstat { my ($log,$u,$d,$z); my $Z = 0; - if (-t) { $log = "$logdir/fup.log" } + if (-t) { $log = $logdir[0].'/fup.log' } else { $log = '>&=STDIN' } open $log,$log or die "$0: cannot open $log - $!\n"; @@ -749,7 +758,7 @@ sub fopstat { my ($log,$u,$d,$z); my (%user,%domain,%du); - if (-t) { $log = "$logdir/fop.log" } + if (-t) { $log = $logdir[0].'/fop.log' } else { $log = '>&=STDIN' } open $log,$log or die "$0: cannot open $log - $!\n"; @@ -789,11 +798,6 @@ sub cpa { } -sub mtime { - my @s = lstat shift; - return @s ? $s[9] : undef; -} - sub check_admin { my $admin_id = slurp("$spooldir/$admin/@") or @@ -882,10 +886,10 @@ $0 -L [filter] # list pending files in detail $0 -M # list pending files with TO/FROM/FILE $0 -M TO/FROM/FILE # resend notification email $0 -m "reason" # enter maintenance mode (reason "exit" to leave) -$0 -A alias:hostname # add new virtual server -$0 -V virtualhost ... # operations on virtualhost (alias or hostname) $0 -E # show usage examples EOD +# $0 -A alias:hostname # add new virtual server +# $0 -V virtualhost ... # operations on virtualhost (alias or hostname) if (-x "$FEXHOME/cgi-bin/fac") { print "See also web admin interface $proto://$hostname$port/fac\n"; }