[LON-CAPA-cvs] cvs: loncom(version_2_11_X) / lond

raeburn raeburn at source.lon-capa.org
Thu Aug 1 14:17:03 EDT 2019


raeburn		Thu Aug  1 18:17:03 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom	lond 
  Log:
  - For 2.11
    Backport 1.551
  
  
Index: loncom/lond
diff -u loncom/lond:1.489.2.31 loncom/lond:1.489.2.32
--- loncom/lond:1.489.2.31	Fri Jul 26 20:19:35 2019
+++ loncom/lond	Thu Aug  1 18:17:02 2019
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.489.2.31 2019/07/26 20:19:35 raeburn Exp $
+# $Id: lond,v 1.489.2.32 2019/08/01 18:17:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -15,7 +15,6 @@
 #
 # LON-CAPA is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
@@ -64,7 +63,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.489.2.31 $'; #' stupid emacs
+my $VERSION='$Revision: 1.489.2.32 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -2021,7 +2020,7 @@
                 my ($remote,$hosted);
                 my $remotesession = &get_usersession_config($udom,'remotesession');
                 if (ref($remotesession) eq 'HASH') {
-                    $remote = $remotesession->{'remote'}
+                    $remote = $remotesession->{'remote'};
                 }
                 my $hostedsession = &get_usersession_config($clienthomedom,'hostedsession');
                 if (ref($hostedsession) eq 'HASH') {
@@ -3223,7 +3222,8 @@
 #
 #  Parameters:
 #     $cmd               - Command keyword of request (eget).
-#     $tail              - Tail of the command.  See GetProfileEntry#                          for more information about this.
+#     $tail              - Tail of the command.  See GetProfileEntry
+#                          for more information about this.
 #     $client            - File open on the client.
 #  Returns:
 #     1      - Continue processing
@@ -5114,6 +5114,58 @@
 &register_handler("tmpdel", \&tmp_del_handler, 0, 1, 0);
 
 #
+#  Process the delbalcookie command. This command deletes a balancer
+#  cookie in the lonBalancedir directory created by switchserver
+#
+# Parameters:
+#   $cmd      - Command that got us here.
+#   $cookie   - Cookie to be deleted.
+#   $client   - socket open on the client process.
+#
+# Returns:
+#   1     - Indicating processing should continue.
+# Side Effects:
+#   A cookie file is deleted from the lonBalancedir directory
+#   A reply is sent to the client.
+sub del_balcookie_handler {
+    my ($cmd, $cookie, $client) = @_;
+
+    my $userinput= "$cmd:$cookie";
+
+    chomp($cookie);
+    my $deleted = '';
+    if ($cookie =~ /^$LONCAPA::match_domain\_$LONCAPA::match_username\_[a-f0-9]{32}$/) {
+        my $execdir=$perlvar{'lonBalanceDir'};
+        if (-e "$execdir/$cookie.id") {
+            if (open(my $fh,'<',"$execdir/$cookie.id")) {
+                my $dodelete;
+                while (my $line = <$fh>) {
+                    chomp($line);
+                    if ($line eq $clientname) {
+                        $dodelete = 1;
+                        last;
+                    }
+                }
+                close($fh);
+                if ($dodelete) {
+                    if (unlink("$execdir/$cookie.id")) {
+                        $deleted = 1;
+                    }
+                }
+            }
+        }
+    }
+    if ($deleted) {
+        &Reply($client, "ok\n", $userinput);
+    } else {
+        &Failure( $client, "error: ".($!+0)."Unlinking cookie file Failed ".
+                  "while attempting delbalcookie\n", $userinput);
+    }
+    return 1;
+}
+&register_handler("delbalcookie", \&del_balcookie_handler, 0, 1, 0);
+
+#
 #   Processes the setannounce command.  This command
 #   creates a file named announce.txt in the top directory of
 #   the documentn root and sets its contents.  The announce.txt file is




More information about the LON-CAPA-cvs mailing list