Diff for /loncom/lond between versions 1.68.2.1 and 1.73

version 1.68.2.1, 2002/02/06 14:18:09 version 1.73, 2002/02/25 20:43:15
Line 48 Line 48
 # 12/22 Gerd Kortemeyer  # 12/22 Gerd Kortemeyer
 # YEAR=2002  # YEAR=2002
 # 01/20/02,02/05 Gerd Kortemeyer  # 01/20/02,02/05 Gerd Kortemeyer
   # 02/05 Guy Albertelli
   # 02/07 Scott Harrison
   # 02/12 Gerd Kortemeyer
   # 02/19 Matthew Hall
   # 02/25 Gerd Kortemeyer
 ###  ###
   
 # based on "Perl Cookbook" ISBN 1-56592-243-3  # based on "Perl Cookbook" ISBN 1-56592-243-3
Line 136  open (CONFIG,"$perlvar{'lonTabDir'}/host Line 141  open (CONFIG,"$perlvar{'lonTabDir'}/host
   
 while ($configline=<CONFIG>) {  while ($configline=<CONFIG>) {
     my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);      my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
     chomp($ip);      chomp($ip); $ip=~s/\D+$//;
     $hostid{$ip}=$id;      $hostid{$ip}=$id;
     if ($id eq $perlvar{'lonHostID'}) { $thisserver=$name; }      if ($id eq $perlvar{'lonHostID'}) { $thisserver=$name; }
     $PREFORK++;      $PREFORK++;
Line 534  sub make_new_child { Line 539  sub make_new_child {
               while (my $userinput=<$client>) {                while (my $userinput=<$client>) {
                 chomp($userinput);                  chomp($userinput);
                 &status('Processing '.$hostid{$clientip}.': '.$userinput);                  &status('Processing '.$hostid{$clientip}.': '.$userinput);
                 &logthis('Processing '.$hostid{$clientip}.': '.$userinput);  
                 my $wasenc=0;                  my $wasenc=0;
                 alarm(120);                  alarm(120);
 # ------------------------------------------------------------ See if encrypted  # ------------------------------------------------------------ See if encrypted
Line 551  sub make_new_child { Line 555  sub make_new_child {
     $userinput=substr($userinput,0,$cmdlength);      $userinput=substr($userinput,0,$cmdlength);
                     $wasenc=1;                      $wasenc=1;
   }    }
   &logthis('Decrypted '.$hostid{$clientip}.': '.$userinput);   }
       }  
   
 # ------------------------------------------------------------- Normal commands  # ------------------------------------------------------------- Normal commands
 # ------------------------------------------------------------------------ ping  # ------------------------------------------------------------------------ ping
    if ($userinput =~ /^ping/) {     if ($userinput =~ /^ping/) {
Line 640  sub make_new_child { Line 642  sub make_new_child {
   $pwdcorrect=!$?;    $pwdcorrect=!$?;
       }        }
                           } elsif ($howpwd eq 'krb4') {                            } elsif ($howpwd eq 'krb4') {
                                $null=pack("C",0);
        unless ($upass=~/$null/) {
                               $pwdcorrect=(                                $pwdcorrect=(
                                  Authen::Krb4::get_pw_in_tkt($uname,"",                                   Authen::Krb4::get_pw_in_tkt($uname,"",
                                         $contentpwd,'krbtgt',$contentpwd,1,                                          $contentpwd,'krbtgt',$contentpwd,1,
      $upass) == 0);       $upass) == 0);
        } else { $pwdcorrect=0; }
                           } elsif ($howpwd eq 'localauth') {                            } elsif ($howpwd eq 'localauth') {
     $pwdcorrect=&localauth::localauth($uname,$upass,      $pwdcorrect=&localauth::localauth($uname,$upass,
       $contentpwd);        $contentpwd);
Line 667  sub make_new_child { Line 672  sub make_new_child {
                        chomp($npass);                         chomp($npass);
                        $upass=&unescape($upass);                         $upass=&unescape($upass);
                        $npass=&unescape($npass);                         $npass=&unescape($npass);
                        my $proname=propath($udom,$uname);         &logthis("Trying to change password for $uname");
          my $proname=propath($udom,$uname);
                        my $passfilename="$proname/passwd";                         my $passfilename="$proname/passwd";
                        if (-e $passfilename) {                         if (-e $passfilename) {
    my $realpasswd;     my $realpasswd;
Line 682  sub make_new_child { Line 688  sub make_new_child {
      my $ncpass=crypt($npass,$salt);       my $ncpass=crypt($npass,$salt);
                              { my $pf = IO::File->new(">$passfilename");                               { my $pf = IO::File->new(">$passfilename");
           print $pf "internal:$ncpass\n"; }                         print $pf "internal:$ncpass\n"; }             
        &logthis("Result of password change for $uname: pwchange_success");
                              print $client "ok\n";                               print $client "ok\n";
                            } else {                             } else {
                              print $client "non_authorized\n";                               print $client "non_authorized\n";
                            }                             }
                           } else {                            } elsif ($howpwd eq 'unix') {
         # Unix means we have to access /etc/password
         # one way or another.
         # First: Make sure the current password is
         #        correct
         $contentpwd=(getpwnam($uname))[1];
         my $pwdcorrect = "0";
         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=!$?;
         }
        if ($pwdcorrect) {
    my $execdir=$perlvar{'lonDaemons'};
    my $pf = IO::File->new("|$execdir/lcpasswd");
    print $pf "$uname\n$npass\n$npass\n";
    close $pf;
    my $result = ($?>0 ? 'pwchange_failure' 
          : 'ok');
    &logthis("Result of password change for $uname: $result");
    print $client "$result\n";
        } else {
    print $client "non_authorized\n";
        }
     } else {
                             print $client "auth_mode_error\n";                              print $client "auth_mode_error\n";
                           }                              }  
        } else {         } else {
Line 1377  sub make_new_child { Line 1414  sub make_new_child {
 # -------------------------------------------------------------------- complete  # -------------------------------------------------------------------- complete
    alarm(0);     alarm(0);
                    &status('Listening to '.$hostid{$clientip});                     &status('Listening to '.$hostid{$clientip});
                    &logthis('Completed '.$userinput.' Listening to '.$hostid{$clientip});  
        }         }
 # --------------------------------------------- client unknown or fishy, refuse  # --------------------------------------------- client unknown or fishy, refuse
             } else {              } else {
Line 1393  sub make_new_child { Line 1429  sub make_new_child {
           
         # tidy up gracefully and finish          # tidy up gracefully and finish
           
         $client->close();  
         $server->close();          $server->close();
   
         # this exit is VERY important, otherwise the child will become          # this exit is VERY important, otherwise the child will become
Line 1448  Server/Process Line 1483  Server/Process
   
   
   
   
   
   
   
   

Removed from v.1.68.2.1  
changed lines
  Added in v.1.73


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>