--- loncom/lond 2004/12/21 20:47:55 1.268
+++ loncom/lond 2005/02/08 17:58:42 1.278
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.268 2004/12/21 20:47:55 albertel Exp $
+# $Id: lond,v 1.278 2005/02/08 17:58:42 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -58,14 +58,13 @@ my $DEBUG = 0; # Non zero to ena
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.268 $'; #' stupid emacs
+my $VERSION='$Revision: 1.278 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
my $client;
my $clientip; # IP address of client.
-my $clientdns; # DNS name of client.
my $clientname; # LonCAPA name of client.
my $server;
@@ -178,7 +177,6 @@ sub ResetStatistics {
# $initcmd - The full text of the init command.
#
# Implicit inputs:
-# $clientdns - The DNS name of the remote client.
# $thisserver - Our DNS name.
#
# Returns:
@@ -187,10 +185,10 @@ sub ResetStatistics {
#
sub LocalConnection {
my ($Socket, $initcmd) = @_;
- Debug("Attempting local connection: $initcmd client: $clientdns me: $thisserver");
- if($clientdns ne $thisserver) {
+ Debug("Attempting local connection: $initcmd client: $clientip me: $thisserver");
+ if($clientip ne "127.0.0.1") {
&logthis(' LocalConnection rejecting non local: '
- ."$clientdns ne $thisserver ");
+ ."$clientip ne $thisserver ");
close $Socket;
return undef;
} else {
@@ -1312,8 +1310,10 @@ sub user_authorization_type {
my ($type,$otherinfo) = split(/:/,$result);
if($type =~ /^krb/) {
$type = $result;
- }
- &Reply( $replyfd, "$type:\n", $userinput);
+ } else {
+ $type .= ':';
+ }
+ &Reply( $replyfd, "$type\n", $userinput);
}
return 1;
@@ -1797,10 +1797,11 @@ sub change_authentication_handler {
# to take ownership of the construction space back to www:www
#
- if( ($oldauth =~ /^unix/) && ($umode eq "internal")) { # unix -> internal
+ if( (($oldauth =~ /^unix/) && ($umode eq "internal")) ||
+ (($oldauth =~ /^internal/) && ($umode eq "unix")) ) {
if(&is_author($udom, $uname)) {
&Debug(" Need to manage author permissions...");
- &manage_permissions("/$udom/_au", $udom, $uname, "internal:");
+ &manage_permissions("/$udom/_au", $udom, $uname, "$umode:");
}
}
@@ -3106,6 +3107,14 @@ sub reply_query_handler {
# $tail - Tail of the command. In this case consists of a colon
# separated list contaning the domain to apply this to and
# an ampersand separated list of keyword=value pairs.
+# Each value is a colon separated list that includes:
+# description, institutional code and course owner.
+# For backward compatibility with versions included
+# in LON-CAPA 1.1.X (and earlier) and 1.2.X, institutional
+# code and/or course owner are preserved from the existing
+# record when writing a new record in response to 1.1 or
+# 1.2 implementations of lonnet::flushcourselogs().
+#
# $client - Socket open on the client.
# Returns:
# 1 - indicating that processing should continue
@@ -3127,7 +3136,23 @@ sub put_course_id_handler {
my $hashref = &tie_domain_hash($udom, "nohist_courseids", &GDBM_WRCREAT());
if ($hashref) {
foreach my $pair (@pairs) {
- my ($key,$courseinfo) = split(/=/,$pair);
+ my ($key,$courseinfo) = split(/=/,$pair,2);
+ $courseinfo =~ s/=/:/g;
+
+ my @current_items = split(/:/,$hashref->{$key});
+ shift(@current_items); # remove description
+ pop(@current_items); # remove last access
+ my $numcurrent = scalar(@current_items);
+
+ my @new_items = split(/:/,$courseinfo);
+ my $numnew = scalar(@new_items);
+ if ($numcurrent > 0) {
+ if ($numnew == 1) { # flushcourselogs() from 1.1 or earlier
+ $courseinfo .= ':'.join(':',@current_items);
+ } elsif ($numnew == 2) { # flushcourselogs() from 1.2.X
+ $courseinfo .= ':'.$current_items[$numcurrent-1];
+ }
+ }
$hashref->{$key}=$courseinfo.':'.$now;
}
if (untie(%$hashref)) {
@@ -3166,6 +3191,15 @@ sub put_course_id_handler {
# description - regular expression that is used to filter
# the dump. Only keywords matching this regexp
# will be used.
+# institutional code - optional supplied code to filter
+# the dump. Only courses with an institutional code
+# that match the supplied code will be returned.
+# owner - optional supplied username of owner to filter
+# the dump. Only courses for which the course
+# owner matches the supplied username will be
+# returned. Implicit assumption that owner
+# is a user in the domain in which the
+# course database is defined.
# $client - The socket open on the client.
# Returns:
# 1 - Continue processing.
@@ -3199,13 +3233,9 @@ sub dump_course_id_handler {
if ($hashref) {
while (my ($key,$value) = each(%$hashref)) {
my ($descr,$lasttime,$inst_code,$owner);
- if ($value =~ m/^([^\:]*):([^\:]*):([^\:]*):(\d+)$/) {
- ($descr,$inst_code,$owner,$lasttime)=($1,$2,$3,$4);
- } elsif ($value =~ m/^([^\:]*):([^\:]*):(\d+)$/) {
- ($descr,$inst_code,$lasttime)=($1,$2,$3);
- } else {
- ($descr,$lasttime) = split(/\:/,$value);
- }
+ my @courseitems = split(/:/,$value);
+ $lasttime = pop(@courseitems);
+ ($descr,$inst_code,$owner)=@courseitems;
if ($lasttime<$since) { next; }
my $match = 1;
unless ($description eq '.') {
@@ -4249,12 +4279,18 @@ sub ReadHostTable {
my $myloncapaname = $perlvar{'lonHostID'};
Debug("My loncapa name is : $myloncapaname");
while (my $configline=) {
- if (!($configline =~ /^\s*\#/)) {
- my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
- chomp($ip); $ip=~s/\D+$//;
+ if ($configline !~ /^\s*\#/ && $configline !~ /^\s*$/ ) {
+ my ($id,$domain,$role,$name)=split(/:/,$configline);
+ $name=~s/\s//g;
+ my (undef,undef,undef,undef,$ip) = gethostbyname($name);
+ if (length($ip) ne 4) {
+ &logthis("Skipping host $id name $name no IP $ip found\n");
+ next;
+ }
+ $ip=inet_ntoa($ip);
$hostid{$ip}=$id; # LonCAPA name of host by IP.
$hostdom{$id}=$domain; # LonCAPA domain name of host.
- $hostip{$id}=$ip; # IP address of host.
+ $hostip{$id}=$ip; # IP address of host.
$hostdns{$name} = $id; # LonCAPA name of host by DNS.
if ($id eq $perlvar{'lonHostID'}) {
@@ -4435,7 +4471,7 @@ sub logstatus {
flock(LOG,LOCK_EX);
print LOG $$."\t".$clientname."\t".$currenthostid."\t"
.$status."\t".$lastlog."\t $keymode\n";
- flock(DB,LOCK_UN);
+ flock(LOG,LOCK_UN);
close(LOG);
}
&status("Finished logging");
@@ -4666,8 +4702,6 @@ sub make_new_child {
if (defined($iaddr)) {
$clientip = inet_ntoa($iaddr);
Debug("Connected with $clientip");
- $clientdns = gethostbyaddr($iaddr, AF_INET);
- Debug("Connected with $clientdns by name");
} else {
&logthis("Unable to determine clientip");
$clientip='Unavailable';
@@ -4707,18 +4741,23 @@ sub make_new_child {
ReadManagerTable; # May also be a manager!!
- my $clientrec=($hostid{$clientip} ne undef);
- my $ismanager=($managers{$clientip} ne undef);
+ my $outsideip=$clientip;
+ if ($clientip eq '127.0.0.1') {
+ $outsideip=$hostip{$perlvar{'lonHostID'}};
+ }
+
+ my $clientrec=($hostid{$outsideip} ne undef);
+ my $ismanager=($managers{$outsideip} ne undef);
$clientname = "[unknonwn]";
if($clientrec) { # Establish client type.
$ConnectionType = "client";
- $clientname = $hostid{$clientip};
+ $clientname = $hostid{$outsideip};
if($ismanager) {
$ConnectionType = "both";
}
} else {
$ConnectionType = "manager";
- $clientname = $managers{$clientip};
+ $clientname = $managers{$outsideip};
}
my $clientok;
@@ -5104,7 +5143,7 @@ sub validate_user {
my $krbserver = &Authen::Krb5::parse_name($krbservice);
my $credentials= &Authen::Krb5::cc_default();
$credentials->initialize($krbclient);
- my $krbreturn = &Authen::KRb5::get_in_tkt_with_password($krbclient,
+ my $krbreturn = &Authen::Krb5::get_in_tkt_with_password($krbclient,
$krbserver,
$password,
$credentials);