Diff for /doc/loncapafiles/updatequery.piml between versions 1.85 and 1.86

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 (&lt;PIPE&gt;) {
                 $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  =&gt; 'PRODUCTION',
                        standalone  => 'STAND-ALONE',                         standalone  =&gt; 'STAND-ALONE',
                        development => 'DEVELOPMENT',                         development =&gt; 'DEVELOPMENT',
                        existing    => 'RUNNING YOUR OWN CLUSTER',                         existing    =&gt; 'RUNNING YOUR OWN CLUSTER',
                      );                       );
   if (($currCluster) && (exists($clustertypes{$currCluster}))) {    if (($currCluster) && (exists($clustertypes{$currCluster}))) {
       print(&lt;&lt;END);        print(&lt;&lt;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)&gt;35) {
     print "Name too long\n";      print "Name too long\n";
   } elsif (length($choice)<2) {    } elsif (length($choice)&lt;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)&gt;45) {
     print "Name too long\n";      print "Name too long\n";
   } elsif (length($choice)<4) {    } elsif (length($choice)&lt;4) {
     print "Name too short\n";      print "Name too short\n";
   } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {    } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');      open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
Line 582  END Line 582  END
         print(&lt;&lt;END);          print(&lt;&lt;END);
 ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$primaryLibServer]:  ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$primaryLibServer]:
 END  END
     } elsif (@libservers > 0) {      } elsif (@libservers &gt; 0) {
         print(&lt;&lt;END);          print(&lt;&lt;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)&gt;35) {
         print "Name too long\n";          print "Name too long\n";
     } elsif (length($choice)<4) {      } elsif (length($choice)&lt;4) {
         print "Name too short\n";          print "Name too short\n";
     } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {      } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
         open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');          open(OUT,'&gt;&gt;/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-&gt;{'lonCertificateDirectory'};
   $privkey = $perlvarref->{'lonnetPrivateKey'};      $privkey = $perlvarref-&gt;{'lonnetPrivateKey'};  
   $connectcsr = $perlvarref->{'lonnetCertificate'};    $connectcsr = $perlvarref-&gt;{'lonnetCertificate'};
   $connectcsr =~ s/\.pem$/.csr/;    $connectcsr =~ s/\.pem$/.csr/;
   $replicatecsr = $perlvarref->{'lonnetHostnameCertificate'};    $replicatecsr = $perlvarref-&gt;{'lonnetHostnameCertificate'};
   $replicatecsr =~ s/\.pem$/.csr/;    $replicatecsr =~ s/\.pem$/.csr/;
   
   print(&lt;&lt;END);    print(&lt;&lt;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-&gtl{'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 { $_ =&gt; 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-&gt;{'contacts'}) eq 'HASH') {
         if (exists($domconf->{'contacts'}->{'adminemail'})) {          if (exists($domconf-&gt;{'contacts'}-&gt;{'adminemail'})) {
             $adminmail = $domconf->{'contacts'}->{'adminemail'};              $adminmail = $domconf-&gt;{'contacts'}-&gt;{'adminemail'};
         }          }
         if (exists($domconf->{'contacts'}->{'supportemail'})) {          if (exists($domconf->{'contacts'}->{'supportemail'})) {
             $supportmail = $domconf->{'contacts'}->{'supportemail'};              $supportmail = $domconf-&gt;{'contacts'}-&gt;{'supportemail'};
         }          }
     }      }
     if (ref($domconf->{'ssl'}) eq 'HASH') {      if (ref($domconf-&gt;{'ssl'}) eq 'HASH') {
         if (ref($domconf->{'ssl'}->{'connect'}) eq 'HASH') {                 foreach my $connect ('connto','connfrom') { 
             my ($sslreq,$sslnoreq);              if (ref($domconf-&gt;{'ssl'}-&gt;{$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-&gt;{'ssl'}-&gt;{'connect'}-&gt;{$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'} =&gt; 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      =&gt; 'lonnetPrivateKey',
                       host     => 'lonnetCertificate',                        host     =&gt; 'lonnetCertificate',
                       hostname => 'lonnetHostnameCertificate',                        hostname =&gt; 'lonnetHostnameCertificate',
                       ca       => 'lonnetCertificateAuthority',                        ca       =&gt; 'lonnetCertificateAuthority',
                    );                     );
     my %ssldesc = (      my %ssldesc = (
                     key      => 'Private Key',                      key      =&gt; 'Private Key',
                     host     => 'Connections Certificate',                      host     =&gt; 'Connections Certificate',
                     hostname => 'Replication Certificate',                      hostname =&gt; 'Replication Certificate',
                     ca       => 'LON-CAPA CA Certificate',                      ca       =&gt; '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)&gt;35) { push(@error,"Name $v too long"); }
    if (length($v)<2) { push(@error,"Name $v too short"); }     if (length($v)&lt;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 &gt; 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)&gt;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)&lt;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(&lt;&lt;END);            print(&lt;&lt;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=&lt;&gt;;        my $choice2=&lt;&gt;;
       chomp($choice2);        chomp($choice2);
   } elsif ($choice==16) {    } elsif ($choice==16) {
         if ($sslstatus{'key'} == 1) || ($sslstatus{'key'} == 2)) {
       #$sslstatus{'host'};        #$sslstatus{'host'};
       print(&lt;&lt;END);        print(&lt;&lt;END);
 16) SSL Certificate for LON-CAPA server connections: $lonhostcertstatus  16) SSL Certificate for LON-CAPA server connections: $lonhostcertstatus

Removed from v.1.85  
changed lines
  Added in v.1.86


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