--- loncom/LondConnection.pm 2006/01/27 20:37:12 1.39 +++ loncom/LondConnection.pm 2006/09/15 20:49:24 1.43 @@ -1,7 +1,7 @@ # This module defines and implements a class that represents # a connection to a lond daemon. # -# $Id: LondConnection.pm,v 1.39 2006/01/27 20:37:12 albertel Exp $ +# $Id: LondConnection.pm,v 1.43 2006/09/15 20:49:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -297,8 +297,7 @@ sub new { return undef; } - } - else { + } else { # Remote peer: I'd like to do ssl, but if my host key or certificates # are not all installed, my only choice is insecure, if that's # allowed: @@ -333,7 +332,6 @@ sub new { # # Set socket to nonblocking I/O. # - my $socket = $self->{Socket}; my $flags = fcntl($socket, F_GETFL,0); if(!$flags) { $socket->close; @@ -738,7 +736,7 @@ sub InitiateTransaction { # Setup the trasaction # currently no version of lond supports inlining the sethost - if ($self->PeerVersion() <= 10000000) { + if ($self->PeerVersion() <= 321) { if ($server ne $self->{LoncapaHim}) { $self->{NextRequest} = $data; $self->{TransactionRequest} = "$sethost:$server\n"; @@ -747,6 +745,7 @@ sub InitiateTransaction { $self->{TransactionRequest} = $data; } } else { + $self->{LoncapaHim} = $server; $self->{TransactionRequest} = "$sethost:$server:$data"; } $self->{TransactionReply} = ""; @@ -1146,7 +1145,7 @@ this iterator returns a reference to an information read from the hosts configuration file. Array elements are used as follows: - [0] - LonCapa host name. + [0] - LonCapa host id. [1] - LonCapa domain name. [2] - Loncapa role (e.g. library or access). [3] - DNS name server hostname. @@ -1173,7 +1172,7 @@ sub GetHostIterator { # -my $confdir='/etc/httpd/conf/'; +my @confdirs=('/etc/httpd/conf/','/etc/apache2/'); # ------------------- Subroutine read_conf: read LON-CAPA server configuration. # This subroutine reads PerlSetVar values out of specified web server @@ -1181,25 +1180,33 @@ my $confdir='/etc/httpd/conf/'; sub read_conf { my (@conf_files)=@_; - my %perlvar; - foreach my $filename (@conf_files,'loncapa_apache.conf') - { - if($DebugLevel > 3) { - print STDERR ("Going to read $confdir.$filename\n"); - } - open(CONFIG,'<'.$confdir.$filename) or - die("Can't read $confdir$filename"); - while (my $configline=) - { - if ($configline =~ /^[^\#]*PerlSetVar/) - { - my ($unused,$varname,$varvalue)=split(/\s+/,$configline); + my (%perlvar,%configdirs); + foreach my $filename (@conf_files,'loncapa_apache.conf') { + my $configdir = ''; + $configdirs{$filename} = [@confdirs]; + while ($configdir eq '' && @{$configdirs{$filename}} > 0) { + my $testdir = shift(@{$configdirs{$filename}}); + if (-e $testdir.$filename) { + $configdir = $testdir; + } + } + if ($configdir eq '') { + die("Couldn't find a directory containing $filename"); + } + if($DebugLevel > 3) { + print STDERR ("Going to read $configdir.$filename\n"); + } + open(CONFIG,'<'.$configdir.$filename) or + die("Can't read $configdir$filename"); + while (my $configline=) { + if ($configline =~ /^[^\#]*PerlSetVar/) { + my ($unused,$varname,$varvalue)=split(/\s+/,$configline); chomp($varvalue); $perlvar{$varname}=$varvalue; - } - } + } + } close(CONFIG); - } + } if($DebugLevel > 3) { print STDERR "Dumping perlvar:\n"; foreach my $var (keys %perlvar) { @@ -1257,8 +1264,8 @@ sub read_hosts { # sub PeerVersion { my $self = shift; - my ($version) = ($self->{LondVersion} =~ /Revision 1\.(\d+)/); - return $self->{LondVersion}; + my ($version) = ($self->{LondVersion} =~ /Revision: 1\.(\d+)/); + return $version; } 1;