version 1.85, 2016/08/03 15:04:59
|
version 1.86, 2017/02/25 20:31:03
|
Line 83 sub get_static_config {
|
Line 83 sub get_static_config {
|
} |
} |
|
|
sub get_domain_config { |
sub get_domain_config { |
my ($dom,$isprimary,$url,$perlvarref) = @_; |
my ($dom,$primaryserver,$isprimary,$url,$perlvarref) = @_; |
my %confhash; |
my %confhash; |
if ($isprimary) { |
if ($isprimary) { |
if (ref($perlvarref) eq 'HASH') { |
if (ref($perlvarref) eq 'HASH') { |
Line 106 sub get_domain_config {
|
Line 106 sub get_domain_config {
|
} |
} |
} |
} |
} else { |
} else { |
if (open(PIPE,"wget --no-check-certificate '$url?domain=$dom&format=raw' |")) { |
if (open(PIPE,"wget --no-check-certificate '$url?primary=$primaryserver&format=raw' |")) { |
my $config = ''; |
my $config = ''; |
while (<PIPE>) { |
while (<PIPE>) { |
$config .= $_; |
$config .= $_; |
} |
} |
close(PIPE); |
close(PIPE); |
Line 227 if (-l "<TARGET />") {
|
Line 227 if (-l "<TARGET />") {
|
$currCluster = $1; |
$currCluster = $1; |
} |
} |
my %clustertypes = ( |
my %clustertypes = ( |
production => 'PRODUCTION', |
production => 'PRODUCTION', |
standalone => 'STAND-ALONE', |
standalone => 'STAND-ALONE', |
development => 'DEVELOPMENT', |
development => 'DEVELOPMENT', |
existing => 'RUNNING YOUR OWN CLUSTER', |
existing => 'RUNNING YOUR OWN CLUSTER', |
); |
); |
if (($currCluster) && (exists($clustertypes{$currCluster}))) { |
if (($currCluster) && (exists($clustertypes{$currCluster}))) { |
print(<<END); |
print(<<END); |
Line 455 END
|
Line 455 END
|
close(OUT); |
close(OUT); |
$lonDefDomain=$choice; |
$lonDefDomain=$choice; |
$flag=1; |
$flag=1; |
} elsif (length($choice)>35) { |
} elsif (length($choice)>35) { |
print "Name too long\n"; |
print "Name too long\n"; |
} elsif (length($choice)<2) { |
} elsif (length($choice)<2) { |
print "Name too short\n"; |
print "Name too short\n"; |
} elsif ($bad_domain_flag) { |
} elsif ($bad_domain_flag) { |
print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n"; |
print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n"; |
Line 542 END
|
Line 542 END
|
close(OUT); |
close(OUT); |
$lonHostID=$choice; |
$lonHostID=$choice; |
$flag=1; |
$flag=1; |
} elsif (length($choice)>45) { |
} elsif (length($choice)>45) { |
print "Name too long\n"; |
print "Name too long\n"; |
} elsif (length($choice)<4) { |
} elsif (length($choice)<4) { |
print "Name too short\n"; |
print "Name too short\n"; |
} elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) { |
} elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) { |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
Line 582 END
|
Line 582 END
|
print(<<END); |
print(<<END); |
ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$primaryLibServer]: |
ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$primaryLibServer]: |
END |
END |
} elsif (@libservers > 0) { |
} elsif (@libservers > 0) { |
print(<<END); |
print(<<END); |
ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$libservers[0]] |
ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$libservers[0]] |
END |
END |
Line 600 END
|
Line 600 END
|
print(OUT 'primaryLibServer'."\t".$choice."\n"); |
print(OUT 'primaryLibServer'."\t".$choice."\n"); |
close(OUT); |
close(OUT); |
$flag=1; |
$flag=1; |
} elsif (length($choice)>35) { |
} elsif (length($choice)>35) { |
print "Name too long\n"; |
print "Name too long\n"; |
} elsif (length($choice)<4) { |
} elsif (length($choice)<4) { |
print "Name too short\n"; |
print "Name too short\n"; |
} elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) { |
} elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) { |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
Line 958 END
|
Line 958 END
|
my $perlvarref = &get_static_config(); |
my $perlvarref = &get_static_config(); |
if (ref($perlvarref) eq 'HASH') { |
if (ref($perlvarref) eq 'HASH') { |
my ($certsdir,$privkey,$connectcsr,$replicatecsr); |
my ($certsdir,$privkey,$connectcsr,$replicatecsr); |
$certsdir = $perlvarref->{'lonCertificateDirectory'}; |
$certsdir = $perlvarref->{'lonCertificateDirectory'}; |
$privkey = $perlvarref->{'lonnetPrivateKey'}; |
$privkey = $perlvarref->{'lonnetPrivateKey'}; |
$connectcsr = $perlvarref->{'lonnetCertificate'}; |
$connectcsr = $perlvarref->{'lonnetCertificate'}; |
$connectcsr =~ s/\.pem$/.csr/; |
$connectcsr =~ s/\.pem$/.csr/; |
$replicatecsr = $perlvarref->{'lonnetHostnameCertificate'}; |
$replicatecsr = $perlvarref->{'lonnetHostnameCertificate'}; |
$replicatecsr =~ s/\.pem$/.csr/; |
$replicatecsr =~ s/\.pem$/.csr/; |
|
|
print(<<END); |
print(<<END); |
Line 1027 END
|
Line 1027 END
|
|
|
my $camail; |
my $camail; |
if ($lonCluster eq 'production' || $lonCluster eq 'development') { |
if ($lonCluster eq 'production' || $lonCluster eq 'development') { |
$camail = $perlvarref->{'SSLEmail'}; |
$camail = $perlvarref->l{'SSLEmail'}; |
} else { |
} else { |
$flag=0; |
$flag=0; |
# get Certificate Authority E-mail |
# get Certificate Authority E-mail |
Line 1282 my %perlvarstatic;
|
Line 1282 my %perlvarstatic;
|
} |
} |
} |
} |
# make list unique |
# make list unique |
@libservers = keys(%{{ map { $_ => 1 } (@libservers) }}); |
@libservers = keys(%{{ map { $_ => 1 } (@libservers) }}); |
close(IN); |
close(IN); |
if (@libservers == 1) { |
if (@libservers == 1) { |
$primaryLibServer = $libservers[0]; |
$primaryLibServer = $libservers[0]; |
Line 1333 if ($primaryLibServer eq $perlvar{'lonHo
|
Line 1333 if ($primaryLibServer eq $perlvar{'lonHo
|
} |
} |
$url = $primary_protocol.'://'.$primary_hostname.'/cgi-bin/listdomconfig.pl'; |
$url = $primary_protocol.'://'.$primary_hostname.'/cgi-bin/listdomconfig.pl'; |
} |
} |
my $domconf = &get_domain_config($perlvar{'lonDefDomain'},$isprimary,$url,\%perlvarstatic); |
my $domconf = &get_domain_config($perlvar{'lonDefDomain'},$primaryLibServer,$isprimary, |
|
$url,\%perlvarstatic); |
if (ref($domconf)) { |
if (ref($domconf)) { |
$gotdomconf = 1; |
$gotdomconf = 1; |
if (ref($domconf->{'contacts'}) eq 'HASH') { |
if (ref($domconf->{'contacts'}) eq 'HASH') { |
if (exists($domconf->{'contacts'}->{'adminemail'})) { |
if (exists($domconf->{'contacts'}->{'adminemail'})) { |
$adminmail = $domconf->{'contacts'}->{'adminemail'}; |
$adminmail = $domconf->{'contacts'}->{'adminemail'}; |
} |
} |
if (exists($domconf->{'contacts'}->{'supportemail'})) { |
if (exists($domconf->{'contacts'}->{'supportemail'})) { |
$supportmail = $domconf->{'contacts'}->{'supportemail'}; |
$supportmail = $domconf->{'contacts'}->{'supportemail'}; |
} |
} |
} |
} |
if (ref($domconf->{'ssl'}) eq 'HASH') { |
if (ref($domconf->{'ssl'}) eq 'HASH') { |
if (ref($domconf->{'ssl'}->{'connect'}) eq 'HASH') { |
foreach my $connect ('connto','connfrom') { |
my ($sslreq,$sslnoreq); |
if (ref($domconf->{'ssl'}->{$connect}) eq 'HASH') { |
my %contypes; |
my ($sslreq,$sslnoreq,$currsetting); |
foreach my $type ('dom','intdom','other') { |
my %contypes; |
my $key; |
foreach my $type ('dom','intdom','other') { |
if ($domconf->{'ssl'}->{'connect'}->{$type} eq 'req') { |
my $key; |
$key = 'yes'; |
if ($domconf->{'ssl'}->{'connect'}->{$type} eq 'req') { |
} else { |
$key = 'yes'; |
$key = 'no'; |
} else { |
|
$key = 'no'; |
|
} |
|
if ($type eq 'dom') { |
|
$contypes{$key} .= ' own domain,'; |
|
} elsif ($type eq 'intdom') { |
|
$contypes{$key} .= ' own institution,'; |
|
} elsif ($type eq 'other') { |
|
$contypes{$key} .= ' other domains,'; |
|
} |
} |
} |
if ($type eq 'dom') { |
foreach my $key (sort(keys(%contypes))) { |
$contypes{$key} .= ' own domain,'; |
$contypes{$key} =~ s/^\s//; |
} elsif ($type eq 'intdom') { |
$contypes{$key} =~ s/,$//; |
$contypes{$key} .= ' own institution,'; |
if ($key eq 'yes') { |
} elsif ($type eq 'other') { |
$currsetting .= ' Yes ('.$contypes{$key}.'),'; |
$contypes{$key} .= ' other domains,'; |
} elsif ($key eq 'no') { |
|
$currsetting .= ' No ('.$contypes{$key}.')'; |
|
} |
|
$currsetting =~ s/,$//; |
} |
} |
} |
if ($currsetting ne '') { |
foreach my $key (sort(keys(%contypes))) { |
$connectssl = $sslname{$connect}.' -- '.$currsetting.' | '; |
$contypes{$key} =~ s/^\s//; |
|
$contypes{$key} =~ s/,$//; |
|
if ($key eq 'yes') { |
|
$connectssl .= ' Yes ('.$contypes{$key}.'),'; |
|
} elsif ($key eq 'no') { |
|
$connectssl = ' No ('.$contypes{$key}.')'; |
|
} |
} |
$connectssl =~ s/,$//; |
|
} |
} |
} |
} |
|
$connectssl =~ s/\s\|\s$//; |
} |
} |
} |
} |
if ($connectssl) { |
if ($connectssl) { |
Line 1395 if ($supportmail) {
|
Line 1402 if ($supportmail) {
|
|
|
print "\nRetrieving status information for SSL key and certificates ...\n\n"; |
print "\nRetrieving status information for SSL key and certificates ...\n\n"; |
my ($lonhostcertstatus,$lonhostnamecertstatus,$lonkeystatus); |
my ($lonhostcertstatus,$lonhostnamecertstatus,$lonkeystatus); |
my $currcerts = &LONCAPA::SSL::print_certstatus({$perlvar{'lonHostID'} => 1,},'text','cgi'); |
my $currcerts = &LONCAPA::SSL::print_certstatus({$perlvar{'lonHostID'} => 1,},'text','cgi'); |
chomp($currcerts); |
chomp($currcerts); |
my %sslstatus; |
my %sslstatus; |
|
|
Line 1410 if ($currcerts eq "$perlvar{'lonHostID'}
|
Line 1417 if ($currcerts eq "$perlvar{'lonHostID'}
|
$lonhostnamecertstatus = 'unknown status'; |
$lonhostnamecertstatus = 'unknown status'; |
} else { |
} else { |
my %sslnames = ( |
my %sslnames = ( |
key => 'lonnetPrivateKey', |
key => 'lonnetPrivateKey', |
host => 'lonnetCertificate', |
host => 'lonnetCertificate', |
hostname => 'lonnetHostnameCertificate', |
hostname => 'lonnetHostnameCertificate', |
ca => 'lonnetCertificateAuthority', |
ca => 'lonnetCertificateAuthority', |
); |
); |
my %ssldesc = ( |
my %ssldesc = ( |
key => 'Private Key', |
key => 'Private Key', |
host => 'Connections Certificate', |
host => 'Connections Certificate', |
hostname => 'Replication Certificate', |
hostname => 'Replication Certificate', |
ca => 'LON-CAPA CA Certificate', |
ca => 'LON-CAPA CA Certificate', |
); |
); |
my ($lonhost,$info) = split(/\:/,$currcerts,2); |
my ($lonhost,$info) = split(/\:/,$currcerts,2); |
if ($lonhost eq $perlvar{'lonHostID'}) { |
if ($lonhost eq $perlvar{'lonHostID'}) { |
Line 1513 END
|
Line 1520 END
|
|
|
my @error; |
my @error; |
foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) { |
foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) { |
if (length($v)>35) { push(@error,"Name $v too long"); } |
if (length($v)>35) { push(@error,"Name $v too long"); } |
if (length($v)<2) { push(@error,"Name $v too short"); } |
if (length($v)<2) { push(@error,"Name $v too short"); } |
if ($v=~/capa/i) { |
if ($v=~/capa/i) { |
if ($v!~/^oucapa\d+$/ && |
if ($v!~/^oucapa\d+$/ && |
($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) { |
($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) { |
Line 1550 if (!defined($intdom)) {
|
Line 1557 if (!defined($intdom)) {
|
} |
} |
|
|
if (!defined($primaryLibServer)) { |
if (!defined($primaryLibServer)) { |
if (@libservers > 0) { |
if (@libservers > 0) { |
push(@error,"No primary library server ID designated. Choose from: ".join(',',sort(@libservers))); |
push(@error,"No primary library server ID designated. Choose from: ".join(',',sort(@libservers))); |
} else { |
} else { |
push(@error,"No library servers in this domain (including current server)"); |
push(@error,"No library servers in this domain (including current server)"); |
} |
} |
} else { |
} else { |
if (length($primaryLibServer)>35) { push(@error,"Primary Library Server ID: $primaryLibServer too long"); } |
if (length($primaryLibServer)>35) { push(@error,"Primary Library Server ID: $primaryLibServer too long"); } |
if (length($primaryLibServer)<2) { push(@error,"Primary Library Server ID: $primaryLibServer too short"); } |
if (length($primaryLibServer)<2) { push(@error,"Primary Library Server ID: $primaryLibServer too short"); } |
if ($primaryLibServer =~/capa/i) { |
if ($primaryLibServer =~/capa/i) { |
if ($primaryLibServer!~/^oucapa\d+$/ && |
if ($primaryLibServer!~/^oucapa\d+$/ && |
($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) { |
($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) { |
Line 1771 END
|
Line 1778 END
|
($securestatus,$securenum)=&securesetting(%perlvar); |
($securestatus,$securenum)=&securesetting(%perlvar); |
} |
} |
} elsif ($choice==15) { |
} elsif ($choice==15) { |
#$sslstatus{'key'}; |
if (($sslstatus{'key'} == 1) || ($sslstatus{'key'} == 2)) { |
print(<<END); |
print(<<END); |
15) Private Key for SSL: $lonkeystatus |
15) Private Key for SSL: $lonkeystatus |
|
|
POSSIBLE CHOICES: |
POSSIBLE CHOICES: |
Line 1781 POSSIBLE CHOICES:
|
Line 1788 POSSIBLE CHOICES:
|
3) make no change |
3) make no change |
ENTER NEW VALUE |
ENTER NEW VALUE |
END |
END |
|
} elsif ($sslstatus{'key'} == ) { |
my $choice2=<>; |
my $choice2=<>; |
chomp($choice2); |
chomp($choice2); |
} elsif ($choice==16) { |
} elsif ($choice==16) { |
|
if ($sslstatus{'key'} == 1) || ($sslstatus{'key'} == 2)) { |
#$sslstatus{'host'}; |
#$sslstatus{'host'}; |
print(<<END); |
print(<<END); |
16) SSL Certificate for LON-CAPA server connections: $lonhostcertstatus |
16) SSL Certificate for LON-CAPA server connections: $lonhostcertstatus |