[LON-CAPA-cvs] cvs: doc /loncapafiles bash_config_check.piml

raeburn raeburn at source.lon-capa.org
Mon Jul 15 12:24:24 EDT 2024


raeburn		Mon Jul 15 16:24:24 2024 EDT

  Modified files:              
    /doc/loncapafiles	bash_config_check.piml 
  Log:
  - Test for bracketed-paste in bash environment for www user checks config
    for the specific application (R), if default is set to "on".
  
  
Index: doc/loncapafiles/bash_config_check.piml
diff -u doc/loncapafiles/bash_config_check.piml:1.3 doc/loncapafiles/bash_config_check.piml:1.4
--- doc/loncapafiles/bash_config_check.piml:1.3	Wed Jul 10 17:39:58 2024
+++ doc/loncapafiles/bash_config_check.piml	Mon Jul 15 16:24:23 2024
@@ -2,7 +2,7 @@
 	"http://lpml.sourceforge.net/DTD/piml.dtd">
 <!-- bash_config_check.piml -->
 
-<!-- $Id: bash_config_check.piml,v 1.3 2024/07/10 17:39:58 raeburn Exp $ -->
+<!-- $Id: bash_config_check.piml,v 1.4 2024/07/15 16:24:23 raeburn Exp $ -->
 
 <!--
 
@@ -37,24 +37,76 @@
 
 use strict;
 
-my $bracketed_warning;
+my ($bracketed_warning,$run_modify_config);
 if (open(PIPE,"/bin/su -s /bin/bash -c 'bind -V 2>&1' www |grep enable-bracketed-paste |")) {
     my $info = <PIPE>;
     chomp($info);
     my ($bracketed) = ($info =~ /^\Qenable-bracketed-paste\E\s+is\s+set\s+to\s+\W(on|off)\W$/);
     close(PIPE);
     if ($bracketed eq 'on') {
-        $bracketed_warning = 1;
+        my $bash_www_cnf = '/home/www/.inputrc';
+        if (!-e $bash_www_cnf) {
+            $bracketed_warning = 1;
+        } elsif (open(my $fh,'<',$bash_www_cnf)) {
+            my (%bracketed_paste_on,%bracketed_paste_off,$condition);
+            $condition = '';
+            while (my $line=<$fh>) {
+                chomp($line);
+                if ($line =~ /^\$if\s+(\w+)\s*$/) {
+                    if ($1 eq 'R') {
+                        $condition = 'r';
+                    } elsif ($1 eq 'maxima') {
+                        $condition = 'maxima';
+                    } else {
+                        $condition = 'other';
+                    }
+                } elsif ($line =~ /^\$endif\s*$/) {
+                    $condition = '';
+                }
+                if ($line =~ /^\s*set\s+enable\-bracketed\-paste\s+(off|on)\s*$/) {
+                    if ($1 eq 'off') {
+                        if ($condition ne '') {
+                            $bracketed_paste_off{$condition} = 1;
+                        } else {
+                            $bracketed_paste_off{all} = 1;
+                        }
+                    } else {
+                        if ($condition ne '') {
+                            $bracketed_paste_on{$condition} = 1;
+                        } else {
+                            $bracketed_paste_on{all} = 1;
+                        }
+                    }
+                }
+            }
+            close($fh);
+            if ($bracketed_paste_on{r} || !exists($bracketed_paste_off{r})) {
+                $run_modify_config = 1;
+            }
+        } else {
+            print "Unable to check if bracketed paste is set to off for www user's shell for R application (lonr).\n";
+        }
     }
 } else {
-    print "Unable to check if bracketed paste is set to off for www user's shell\n"; 
+    print "Unable to check if bracketed paste is set to off for www user's shell for R application (lonr).\n";
 }
 
 if ($bracketed_warning) {
-    print <<"END";
+    print <<'END';
 **** ERROR: Problems which include calls to R statistics engine will not work.
-You need to create a file: /home/www/.inputrc containing the following line:
-set enable-bracketed-paste to off
+You need to create a file: /home/www/.inputrc containing the following lines:
+$if R
+    set enable-bracketed-paste off
+$endif
+END
+} elsif ($run_modify_config) {
+    print <<'END';
+**** ERROR: Problems which include calls to R statistics engine will not work.
+Run /home/httpd/perl/modify_config_files.pl as root so the file /home/www/.inputrc
+will contain the following:
+$if R
+    set enable-bracketed-paste off
+$endif
 END
 }
 




More information about the LON-CAPA-cvs mailing list