--- loncom/lond 2002/03/03 19:49:00 1.74
+++ loncom/lond 2002/04/27 13:10:47 1.77
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.74 2002/03/03 19:49:00 harris41 Exp $
+# $Id: lond,v 1.77 2002/04/27 13:10:47 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -73,6 +73,8 @@ use Authen::Krb4;
use lib '/home/httpd/lib/perl/';
use localauth;
+my $DEBUG = 0; # Non zero to enable debug log entries.
+
my $status='';
my $lastlog='';
@@ -160,7 +162,7 @@ $server = IO::Socket::INET->new(LocalPor
# global variables
-$MAX_CLIENTS_PER_CHILD = 5; # number of clients each child should
+$MAX_CLIENTS_PER_CHILD = 50; # number of clients each child should
# process
%children = (); # keys are current child process IDs
$children = 0; # current number of children
@@ -235,6 +237,13 @@ sub logthis {
print $fh "$local ($$): $message\n";
}
+# ------------------------- Conditional log if $DEBUG true.
+sub Debug {
+ my $message = shift;
+ if($DEBUG) {
+ &logthis($message);
+ }
+}
# ------------------------------------------------------------------ Log status
sub logstatus {
@@ -301,10 +310,10 @@ sub reconlonc {
if (kill 0 => $loncpid) {
&logthis("lonc at pid $loncpid responding, sending USR1");
kill USR1 => $loncpid;
- sleep 1;
+ sleep 5;
if (-e "$peerfile") { return; }
&logthis("$peerfile still not there, give it another try");
- sleep 5;
+ sleep 10;
if (-e "$peerfile") { return; }
&logthis(
"WARNING: $peerfile still not there, giving up");
@@ -342,6 +351,7 @@ sub reply {
if ($answer eq 'con_lost') {
$answer=subreply("ping",$server);
if ($answer ne $server) {
+ &logthis("sub reply: answer != server");
&reconlonc("$perlvar{'lonSockDir'}/$server");
}
$answer=subreply($cmd,$server);
@@ -531,6 +541,7 @@ sub make_new_child {
}
if ($clientok) {
# ---------------- New known client connecting, could mean machine online again
+
&reconlonc("$perlvar{'lonSockDir'}/$hostid{$clientip}");
&logthis(
"Established connection: $hostid{$clientip}");
@@ -554,8 +565,9 @@ sub make_new_child {
}
$userinput=substr($userinput,0,$cmdlength);
$wasenc=1;
- }
}
+ }
+
# ------------------------------------------------------------- Normal commands
# ------------------------------------------------------------------------ ping
if ($userinput =~ /^ping/) {
@@ -734,14 +746,19 @@ sub make_new_child {
}
# -------------------------------------------------------------------- makeuser
} elsif ($userinput =~ /^makeuser/) {
+ Debug("Make user received");
my $oldumask=umask(0077);
if ($wasenc==1) {
my
($cmd,$udom,$uname,$umode,$npass)=split(/:/,$userinput);
+ &Debug("cmd =".$cmd." $udom =".$udom.
+ " uname=".$uname);
chomp($npass);
$npass=&unescape($npass);
my $proname=propath($udom,$uname);
my $passfilename="$proname/passwd";
+ &Debug("Password file created will be:".
+ $passfilename);
if (-e $passfilename) {
print $client "already_exists\n";
} elsif ($udom ne $perlvar{'lonDefDomain'}) {
@@ -770,7 +787,8 @@ sub make_new_child {
$salt=substr($salt,6,2);
my $ncpass=crypt($npass,$salt);
{
- my $pf = IO::File->new(">$passfilename");
+ &Debug("Creating internal auth");
+ my $pf = IO::File->new(">$passfilename");
print $pf "internal:$ncpass\n";
}
print $client "ok\n";
@@ -785,6 +803,8 @@ sub make_new_child {
my $execpath="$perlvar{'lonDaemons'}/".
"lcuseradd";
{
+ &Debug("Executing external: ".
+ $execpath);
my $se = IO::File->new("|$execpath");
print $se "$uname\n";
print $se "$npass\n";
@@ -813,10 +833,13 @@ sub make_new_child {
umask($oldumask);
# -------------------------------------------------------------- changeuserauth
} elsif ($userinput =~ /^changeuserauth/) {
- if ($wasenc==1) {
+ &Debug("Changing authorization");
+ if ($wasenc==1) {
my
($cmd,$udom,$uname,$umode,$npass)=split(/:/,$userinput);
chomp($npass);
+ &Debug("cmd = ".$cmd." domain= ".$udom.
+ "uname =".$uname." umode= ".$umode);
$npass=&unescape($npass);
my $proname=propath($udom,$uname);
my $passfilename="$proname/passwd";
@@ -1025,9 +1048,13 @@ sub make_new_child {
}
# -------------------------------------------------------------------- rolesput
} elsif ($userinput =~ /^rolesput/) {
+ &Debug("rolesput");
if ($wasenc==1) {
my ($cmd,$exedom,$exeuser,$udom,$uname,$what)
=split(/:/,$userinput);
+ &Debug("cmd = ".$cmd." exedom= ".$exedom.
+ "user = ".$exeuser." udom=".$udom.
+ "what = ".$what);
my $namespace='roles';
chomp($what);
my $proname=propath($udom,$uname);
@@ -1421,12 +1448,13 @@ sub make_new_child {
$client->close();
&logthis("WARNING: "
."Rejected client $clientip, closing connection");
- }
- &logthis("CRITICAL: "
- ."Disconnect from $clientip ($hostid{$clientip})");
+ }
+ }
+
# =============================================================================
- }
-
+
+ &logthis("CRITICAL: "
+ ."Disconnect from $clientip ($hostid{$clientip})");
# tidy up gracefully and finish
$server->close();