[LON-CAPA-cvs] cvs: loncom / lond /interface domainprefs.pm /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Sun Aug 1 15:28:11 EDT 2021
raeburn Sun Aug 1 19:28:11 2021 EDT
Modified files:
/loncom lond
/loncom/interface domainprefs.pm
/loncom/lonnet/perl lonnet.pm
Log:
- New arg ($encrypt) for &get_dom, &put_dom, &dump, and &put calls in
lonnet.pm, so request encrypted, and response (&get_dom and &dump)
also encrypted, unless requests will go to current server.
-------------- next part --------------
Index: loncom/lond
diff -u loncom/lond:1.567 loncom/lond:1.568
--- loncom/lond:1.567 Tue Jun 15 20:52:27 2021
+++ loncom/lond Sun Aug 1 19:28:10 2021
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.567 2021/06/15 20:52:27 raeburn Exp $
+# $Id: lond,v 1.568 2021/08/01 19:28:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -65,7 +65,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.567 $'; #' stupid emacs
+my $VERSION='$Revision: 1.568 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -239,6 +239,7 @@
du2 => {remote => 1, enroll => 1},
dump => {remote => 1, enroll => 1, domroles => 1},
edit => {institutiononly => 1}, #not used currently
+ edump => {remote => 1, enroll => 1, domroles => 1},
eget => {remote => 1, domroles => 1, enroll => 1}, #not used currently
egetdom => {remote => 1, domroles => 1, enroll => 1, },
ekey => {anywhere => 1},
@@ -3829,6 +3830,47 @@
}
®ister_handler("dump", \&dump_with_regexp, 0, 1, 0);
+#
+# Process the encrypted dump request. Original call should
+# be from lonnet::dump() with seventh arg ($encrypt) set to
+# 1, to ensure that both request and response are encrypted.
+#
+# Parameters:
+# $cmd - Command keyword of request (edump).
+# $tail - Tail of the command.
+# See &dump_with_regexp for more
+# information about this.
+# $client - File open on the client.
+# Returns:
+# 1 - Continue processing
+# 0 - server should exit.
+#
+
+sub encrypted_dump_with_regexp {
+ my ($cmd, $tail, $client) = @_;
+ my $res = LONCAPA::Lond::dump_with_regexp($tail, $clientversion);
+
+ if ($res =~ /^error:/) {
+ Failure($client, \$res, "$cmd:$tail");
+ } else {
+ if ($cipher) {
+ my $cmdlength=length($res);
+ $res.=" ";
+ my $encres='';
+ for (my $encidx=0;$encidx<=$cmdlength;$encidx+=8) {
+ $encres.= unpack("H16",
+ $cipher->encrypt(substr($res,
+ $encidx,
+ 8)));
+ }
+ &Reply( $client,"enc:$cmdlength:$encres\n","$cmd:$tail");
+ } else {
+ &Failure( $client, "error:no_key\n","$cmd:$tail");
+ }
+ }
+}
+®ister_handler("edump", \&encrypted_dump_with_regexp, 0, 1, 0);
+
# Store a set of key=value pairs associated with a versioned name.
#
# Parameters:
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.383 loncom/interface/domainprefs.pm:1.384
--- loncom/interface/domainprefs.pm:1.383 Fri May 28 01:26:02 2021
+++ loncom/interface/domainprefs.pm Sun Aug 1 19:28:10 2021
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.383 2021/05/28 01:26:02 raeburn Exp $
+# $Id: domainprefs.pm,v 1.384 2021/08/01 19:28:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -223,7 +223,7 @@
'ltitools','ssl','trust','lti','privacy','passwords',
'proctoring','wafproxy'],$dom);
my %encconfig =
- &Apache::lonnet::get_dom('encconfig',['ltitools','lti','proctoring'],$dom);
+ &Apache::lonnet::get_dom('encconfig',['ltitools','lti','proctoring'],$dom,undef,1);
if (ref($domconfig{'ltitools'}) eq 'HASH') {
if (ref($encconfig{'ltitools'}) eq 'HASH') {
foreach my $id (keys(%{$domconfig{'ltitools'}})) {
@@ -13527,7 +13527,7 @@
my %ltienchash = (
$action => { %encconfig }
);
- &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom);
+ &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
if (keys(%changes) > 0) {
my $cachetime = 24*60*60;
my %ltiall = %confhash;
@@ -14101,7 +14101,7 @@
my %proc_enchash = (
$action => { %encconfhash }
);
- &Apache::lonnet::put_dom('encconfig',\%proc_enchash,$dom);
+ &Apache::lonnet::put_dom('encconfig',\%proc_enchash,$dom,undef,1);
if (keys(%changes) > 0) {
my $cachetime = 24*60*60;
my %procall = %confhash;
@@ -14593,7 +14593,7 @@
my %ltienchash = (
$action => { %encconfig }
);
- &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom);
+ &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
if (keys(%changes) > 0) {
my $cachetime = 24*60*60;
my %ltiall = %confhash;
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1461 loncom/lonnet/perl/lonnet.pm:1.1462
--- loncom/lonnet/perl/lonnet.pm:1.1461 Mon Jul 19 15:48:27 2021
+++ loncom/lonnet/perl/lonnet.pm Sun Aug 1 19:28:11 2021
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1461 2021/07/19 15:48:27 raeburn Exp $
+# $Id: lonnet.pm,v 1.1462 2021/08/01 19:28:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -468,14 +468,15 @@
my $subcmd = $1;
if (($subcmd eq 'auth') || ($subcmd eq 'passwd') ||
($subcmd eq 'changeuserauth') || ($subcmd eq 'makeuser') ||
- ($subcmd eq 'putdom') || ($subcmd eq 'autoexportgrades')) {
+ ($subcmd eq 'putdom') || ($subcmd eq 'autoexportgrades') ||
+ ($subcmd eq 'put')) {
(undef,undef,my @rest) = split(/:/,$cmd);
if (($subcmd eq 'auth') || ($subcmd eq 'putdom')) {
splice(@rest,2,1,'Hidden');
} elsif ($subcmd eq 'passwd') {
splice(@rest,2,2,('Hidden','Hidden'));
} elsif (($subcmd eq 'changeuserauth') || ($subcmd eq 'makeuser') ||
- ($subcmd eq 'autoexportgrades')) {
+ ($subcmd eq 'autoexportgrades') || ($subcmd eq 'put')) {
splice(@rest,3,1,'Hidden');
}
$logged = join(':',('encrypt:'.$subcmd, at rest));
@@ -2146,7 +2147,7 @@
# ------------------------------------------ get items from domain db files
sub get_dom {
- my ($namespace,$storearr,$udom,$uhome)=@_;
+ my ($namespace,$storearr,$udom,$uhome,$encrypt)=@_;
return if ($udom eq 'public');
my $items='';
foreach my $item (@$storearr) {
@@ -2172,13 +2173,9 @@
my $rep;
if (grep { $_ eq $uhome } ¤t_machine_ids()) {
# domain information is hosted on this machine
- my $cmd = 'getdom';
- if ($namespace =~ /^enc/) {
- $cmd = 'egetdom';
- }
- $rep = &LONCAPA::Lond::get_dom("$cmd:$udom:$namespace:$items");
+ $rep = &LONCAPA::Lond::get_dom("getdom:$udom:$namespace:$items");
} else {
- if ($namespace =~ /^enc/) {
+ if ($encrypt) {
$rep=&reply("encrypt:egetdom:$udom:$namespace:$items",$uhome);
} else {
$rep=&reply("getdom:$udom:$namespace:$items",$uhome);
@@ -2206,7 +2203,7 @@
# -------------------------------------------- put items in domain db files
sub put_dom {
- my ($namespace,$storehash,$udom,$uhome)=@_;
+ my ($namespace,$storehash,$udom,$uhome,$encrypt)=@_;
if (!$udom) {
$udom=$env{'user.domain'};
if (defined(&domain($udom,'primary'))) {
@@ -2227,7 +2224,7 @@
$items.=&escape($item).'='.&freeze_escape($$storehash{$item}).'&';
}
$items=~s/\&$//;
- if ($namespace =~ /^enc/) {
+ if ($encrypt) {
return &reply("encrypt:putdom:$udom:$namespace:$items",$uhome);
} else {
return &reply("putdom:$udom:$namespace:$items",$uhome);
@@ -7117,7 +7114,7 @@
# see Lond::dump_with_regexp
# if $escapedkeys hash keys won't get unescaped.
sub dump {
- my ($namespace,$udomain,$uname,$regexp,$range,$escapedkeys)=@_;
+ my ($namespace,$udomain,$uname,$regexp,$range,$escapedkeys,$encrypt)=@_;
if (!$udomain) { $udomain=$env{'user.domain'}; }
if (!$uname) { $uname=$env{'user.name'}; }
my $uhome=&homeserver($uname,$udomain);
@@ -7133,7 +7130,12 @@
$uname, $namespace, $regexp, $range)), $perlvar{'lonVersion'});
return %{unserialize($reply, $escapedkeys)};
}
- my $rep=&reply("dump:$udomain:$uname:$namespace:$regexp:$range",$uhome);
+ my $rep;
+ if ($encrypt) {
+ $rep=&reply("encrypt:edump:$udomain:$uname:$namespace:$regexp:$range",$uhome);
+ } else {
+ $rep=&reply("dump:$udomain:$uname:$namespace:$regexp:$range",$uhome);
+ }
my @pairs=split(/\&/,$rep);
my %returnhash=();
if (!($rep =~ /^error/ )) {
@@ -7280,7 +7282,7 @@
# --------------------------------------------------------------- put interface
sub put {
- my ($namespace,$storehash,$udomain,$uname)=@_;
+ my ($namespace,$storehash,$udomain,$uname,$encrypt)=@_;
if (!$udomain) { $udomain=$env{'user.domain'}; }
if (!$uname) { $uname=$env{'user.name'}; }
my $uhome=&homeserver($uname,$udomain);
@@ -7289,7 +7291,11 @@
$items.=&escape($item).'='.&freeze_escape($$storehash{$item}).'&';
}
$items=~s/\&$//;
- return &reply("put:$udomain:$uname:$namespace:$items",$uhome);
+ if ($encrypt) {
+ return &reply("encrypt:put:$udomain:$uname:$namespace:$items",$uhome);
+ } else {
+ return &reply("put:$udomain:$uname:$namespace:$items",$uhome);
+ }
}
# ------------------------------------------------------------ newput interface
@@ -12192,7 +12198,7 @@
my %domconfig = &get_dom('configuration',[$name],$cdom);
if (ref($domconfig{$name}) eq 'HASH') {
%lti = %{$domconfig{$name}};
- my %encdomconfig = &get_dom('encconfig',[$name],$cdom);
+ my %encdomconfig = &get_dom('encconfig',[$name],$cdom,undef,1);
if (ref($encdomconfig{$name}) eq 'HASH') {
foreach my $id (keys(%lti)) {
if (ref($encdomconfig{$name}{$id}) eq 'HASH') {
More information about the LON-CAPA-cvs
mailing list