[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Sat Aug 3 19:36:10 EDT 2019


raeburn		Sat Aug  3 23:36:10 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - For 2.11
    Backport 1.1337, 1.1378
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1172.2.107 loncom/lonnet/perl/lonnet.pm:1.1172.2.108
--- loncom/lonnet/perl/lonnet.pm:1.1172.2.107	Thu Aug  1 19:13:26 2019
+++ loncom/lonnet/perl/lonnet.pm	Sat Aug  3 23:36:09 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1172.2.107 2019/08/01 19:13:26 raeburn Exp $
+# $Id: lonnet.pm,v 1.1172.2.108 2019/08/03 23:36:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -604,18 +604,39 @@
 sub check_for_valid_session {
     my ($r,$name,$userhashref,$domref) = @_;
     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
-    if ($name eq '') {
-        $name = 'lonID';
-    }
-    my $lonid=$cookies{$name};
-    return undef if (!$lonid);
-
-    my $handle=&LONCAPA::clean_handle($lonid->value);
-    my $lonidsdir;
+    my ($lonidsdir,$linkname,$pubname,$secure,$lonid);
     if ($name eq 'lonDAV') {
         $lonidsdir=$r->dir_config('lonDAVsessDir');
     } else {
         $lonidsdir=$r->dir_config('lonIDsDir');
+        if ($name eq '') {
+            $name = 'lonID';
+        }
+    }
+    if ($name eq 'lonID') {
+        $secure = 'lonSID';
+        $linkname = 'lonLinkID';
+        $pubname = 'lonPubID';
+        if (exists($cookies{$secure})) {
+            $lonid=$cookies{$secure};
+        } elsif (exists($cookies{$name})) {
+            $lonid=$cookies{$name};
+        } elsif ((exists($cookies{$linkname})) && ($ENV{'SERVER_PORT'} != 443)) {
+            $lonid=$cookies{$linkname};
+        } elsif (exists($cookies{$pubname})) {
+            $lonid=$cookies{$pubname};
+        }
+    } else {
+        $lonid=$cookies{$name};
+    }
+    return undef if (!$lonid);
+
+    my $handle=&LONCAPA::clean_handle($lonid->value);
+    if (-l "$lonidsdir/$handle.id") {
+        my $link = readlink("$lonidsdir/$handle.id");
+        if ((-e $link) && ($link =~ m{^\Q$lonidsdir\E/(.+)\.id$})) {
+            $handle = $1;
+        }
     }
     if (!-e "$lonidsdir/$handle.id") {
         if ((ref($domref)) && ($name eq 'lonID') &&




More information about the LON-CAPA-cvs mailing list