X-Git-Url: http://git.treefish.org/fex.git/blobdiff_plain/7fa382617fbaccc0ce522b2b3adbbee9db5ad227..20150729:/cgi-bin/fur?ds=inline diff --git a/cgi-bin/fur b/cgi-bin/fur index 3d91f55..2a75445 100755 --- a/cgi-bin/fur +++ b/cgi-bin/fur @@ -5,12 +5,9 @@ # Author: Ulli Horlacher # -use CGI qw(:standard); -use CGI::Carp qw(fatalsToBrowser); -use Fcntl qw(:flock :seek :mode); +BEGIN { ($ENV{PERLINIT}||'') =~ /(.+)/s and eval $1 } -$CGI::LIST_CONTEXT_WARN = 0; -$CGI::LIST_CONTEXT_WARN = 0; +use Fcntl qw(:flock :seek :mode); # import from fex.ph our (@local_hosts,@local_domains,@local_rhosts,@local_rdomains); @@ -18,7 +15,7 @@ our (@registration_hosts,@registration_domains); our ($usage_conditions); # import from fex.pp -our ($mdomain,$logdir,$spooldir,$fra,$hostname,$sendmail,$admin,$bcc); +our ($mdomain,@logdir,$spooldir,$fra,$hostname,$sendmail,$admin,$bcc); our $error = "F*EX user registration ERROR"; @@ -33,7 +30,7 @@ die "$0: no $FEXLIB\n" unless -d $FEXLIB; # load common code, local config: $HOME/lib/fex.ph require "$FEXLIB/fex.pp" or die "$0: cannot load $FEXLIB/fex.pp - $!\n"; -my $log = "$logdir/fur.log"; +my $log = 'fur.log'; my $head = "$ENV{SERVER_NAME} F*EX user registration"; chdir $spooldir or die "$spooldir - $!\n"; @@ -42,17 +39,26 @@ my $user = my $id = my $verify = ''; &check_maint; -unless (@local_domains or @local_rdomains) { +unless (@local_domains and @local_rdomains) { html_error($error, "No domains for registrations are defined.", "Contact $ENV{SERVER_ADMIN} for details." ); } +unless (@local_hosts and ipin($ENV{REMOTE_ADDR}||0,@local_hosts)) { + html_error($error, + "Registrations from your host ($ENV{REMOTE_ADDR}) are not allowed.", + "Contact $ENV{SERVER_ADMIN} for details." + ); +} + # look for CGI parameters -foreach my $v (param) { - my $vv = despace(param($v)); - debuglog("Param: $v=\"$vv\""); +our %PARAM; +&parse_parameters; +foreach my $v (keys %PARAM) { + my $vv = despace($PARAM{$v}); + # debuglog("Param: $v=\"$vv\""); $CASE = $v =~ /^user$/i ? $user = normalize_address($vv): $v =~ /^exuser$/i ? $exuser = normalize_address($vv): @@ -339,7 +345,7 @@ if ($verify eq 'no') { http_header("200 OK",'Content-Type: text/plain'); print "$ENV{PROTO}://$ENV{HTTP_HOST}/fup?from=$user&ID=$id\n"; furlog("direct: account $user created"); - if ($bcc and open my $mail,"|$sendmail '$bcc' 2>>$log") { + if ($bcc and open my $mail,"|$sendmail '$bcc' 2>>$logdir[0]/$log") { pq($mail,qq( 'From: fex' 'To: $bcc' @@ -395,14 +401,10 @@ sub furlog { $msg =~ s/\n/ /g; $msg =~ s/\s+$//; + $msg = sprintf "%s [%s_%s] %s %s\n", + isodate(time),$$,$ENV{REQUESTCOUNT},$fra,$msg; - if (open $log,'>>',$log) { - flock $log,LOCK_EX; - seek $log,0,SEEK_END; - printf {$log} "%s [%s_%s] %s %s\n", - isodate(time),$$,$ENV{REQUESTCOUNT},$fra,$msg; - close $log; - } + writelog($log,$msg); } sub normalize_address {