--- loncom/lond 2001/05/28 13:13:58 1.48 +++ loncom/lond 2001/09/30 18:32:31 1.52 @@ -15,7 +15,8 @@ # 03/15 Scott Harrison # 03/24 Gerd Kortemeyer # 04/02 Scott Harrison -# 05/11,05/28 Gerd Kortemeyer +# 05/11,05/28,08/30 Gerd Kortemeyer +# 9/30 Scott Harrison # # based on "Perl Cookbook" ISBN 1-56592-243-3 # preforker - server who forks first @@ -32,6 +33,8 @@ use Crypt::IDEA; use LWP::UserAgent(); use GDBM_File; use Authen::Krb4; +use lib '/home/httpd/lib/perl/'; +use localauth; # grabs exception and records it to log before exiting sub catchexception { @@ -364,7 +367,8 @@ sub make_new_child { my $clientip=inet_ntoa($iaddr); my $clientrec=($hostid{$clientip} ne undef); &logthis( -"INFO: Connect from $clientip ($hostid{$clientip})"); +"INFO: Connection $i, $clientip ($hostid{$clientip})" + ); my $clientok; if ($clientrec) { my $remotereq=<$client>; @@ -468,14 +472,27 @@ sub make_new_child { (crypt($upass,$contentpwd) eq $contentpwd); } elsif ($howpwd eq 'unix') { $contentpwd=(getpwnam($uname))[1]; - $pwdcorrect= - (crypt($upass,$contentpwd) eq $contentpwd); + my $pwauth_path="/usr/local/sbin/pwauth"; + unless ($contentpwd eq 'x') { + $pwdcorrect= + (crypt($upass,$contentpwd) eq $contentpwd); + } + elsif (-e $pwauth_path) { + open PWAUTH, "|$pwauth_path" or + die "Cannot invoke authentication"; + print PWAUTH "$uname\n$upass\n"; + close PWAUTH; + $pwdcorrect=!$?; + } } elsif ($howpwd eq 'krb4') { $pwdcorrect=( Authen::Krb4::get_pw_in_tkt($uname,"", $contentpwd,'krbtgt',$contentpwd,1, $upass) == 0); - } + } elsif ($howpwd eq 'localauth') { + $pwdcorrect=&localauth::localauth($uname,$upass, + $contentpwd); + } if ($pwdcorrect) { print $client "authorized\n"; } else { @@ -562,8 +579,14 @@ sub make_new_child { { my $pf = IO::File->new(">$passfilename"); print $pf "internal:$ncpass\n"; - } + } print $client "ok\n"; + } elsif ($umode eq 'localauth') { + { + my $pf = IO::File->new(">$passfilename"); + print $pf "localauth:$npass\n"; + } + print $client "ok\n"; } elsif ($umode eq 'none') { { my $pf = IO::File->new(">$passfilename"); @@ -1100,6 +1123,13 @@ sub make_new_child { } if ($ulsout eq '') { $ulsout='empty'; } print $client "$ulsout\n"; +# ------------------------------------------------------------------ Hanging up + } elsif (($userinput =~ /^exit/) || + ($userinput =~ /^init/)) { + &logthis( + "Client $clientip ($hostid{$clientip}) hanging up: $userinput"); + print $client "bye\n"; + last; # ------------------------------------------------------------- unknown command } else { # unknown command