[LON-CAPA-cvs] cvs: loncom /build Makefile /debugging_tools modify_config_files.pl doc/loncapafiles bash_config_check.piml

raeburn raeburn at source.lon-capa.org
Mon Jul 8 19:46:06 EDT 2024


raeburn		Mon Jul  8 23:46:06 2024 EDT

  Added files:                 
    /doc/loncapafiles	bash_config_check.piml 

  Modified files:              
    /loncom/build	Makefile 
    /loncom/debugging_tools	modify_config_files.pl 
  Log:
  - Red Hat "bug" 2079078. For bash with readline library 8.1 or newer need to
    disable default bracketed paste mode, with line added to /home/www/.inputrc
    so R commands sent to lonr daemon can be processed.
  
  
Index: loncom/build/Makefile
diff -u loncom/build/Makefile:1.224 loncom/build/Makefile:1.225
--- loncom/build/Makefile:1.224	Sat Jul  6 01:42:55 2024
+++ loncom/build/Makefile	Mon Jul  8 23:46:06 2024
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 
-# $Id: Makefile,v 1.224 2024/07/06 01:42:55 raeburn Exp $
+# $Id: Makefile,v 1.225 2024/07/08 23:46:06 raeburn Exp $
 
 # TYPICAL USAGE of this Makefile is primarily for two targets:
 # "make build" and "make install".
@@ -149,6 +149,7 @@
 	@echo "chkconfig: test runlevels of httpd and loncontrol."
 	@echo "rpmcheck: test to see if rpms known to confict are installed."
 	@echo "wrap_setuid: put a C wrapper around setuid scripts."
+	@echo "bash_config_check: test if enable-bracketed-paste set to on." 
         @echo "latex_fixup: regenerate ls-R database for the latex base."
 	@echo "picins_check: check for picins.sty, retrieve and rebuild"
 	@echo "             filename databases used by LaTeX"
@@ -549,6 +550,11 @@
 	cat $(SOURCE)/doc/loncapafiles/removenolongerused.piml | \
 	perl piml_parse.pl  $(CATEGORY) $(DIST) "$(TARGET)" $(QUERYLAUNCH)
 
+bash_config_check:
+	cat $(SOURCE)/doc/loncapafiles/bash_config_check.piml | \
+	perl piml_parse.pl  $(CATEGORY) $(DIST) "$(TARGET)" $(LAUNCH) | \
+	tee -a WARNINGS
+
 postinstall:
 	make postaboutVERSION
 	make webserverconf
@@ -572,6 +578,7 @@
 	make picins_check
 	make mimetex_version_check
 	make verify_domconfiguser
+	make bash_config_check 
 	make latex_fmtutil
 	make lcmathcomplex
 	sed -i "s/\x08\x08*/.../g" WARNINGS
Index: loncom/debugging_tools/modify_config_files.pl
diff -u loncom/debugging_tools/modify_config_files.pl:1.24 loncom/debugging_tools/modify_config_files.pl:1.25
--- loncom/debugging_tools/modify_config_files.pl:1.24	Fri Jun 28 12:46:47 2024
+++ loncom/debugging_tools/modify_config_files.pl	Mon Jul  8 23:46:06 2024
@@ -2,7 +2,7 @@
 #
 # The LearningOnline Network
 #
-# $Id: modify_config_files.pl,v 1.24 2024/06/28 12:46:47 raeburn Exp $
+# $Id: modify_config_files.pl,v 1.25 2024/07/08 23:46:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,6 +49,10 @@
 /etc/sysconfig/rhn/sources (for RHEL4), or /etc/yum.repos.d/loncapa.repo
 (for Fedora >= 21; Oracle Linux; AlmaLinux; RockyLinux; CentOS/RHEL >= 8).
 
+The script also modifies /home/www/.inputrc on Linux distros which have 
+readline 8.1 or newer, i.e., CentOS/Scientific Linux/RHEL >= 9,
+Ubuntu >= 22, Debian >= 12, and Fedora >= 34.
+
 =head1 DESCRIPTION
 
 This script will modify /etc/my.cnf, /etc/mysql/my.cnf, 
@@ -56,7 +60,8 @@
 /etc/mysql/mariadb.conf.d/50-server.cnf,
 and /etc/yum.conf, /etc/yum.repos.d/loncapa.repo,
 /etc/apt/sources.list, /etc/apt/sources.list.d/loncapa.list or 
-/etc/sysconfig/rhn/sources to ensure certain parameters are set properly.
+/etc/sysconfig/rhn/sources and /home/www/.inputrc to ensure 
+certain parameters are set properly.
 
 The LON-CAPA yum repositories are added to /etc/yum.conf, 
 /etc/yum.repos.d/loncapa.repo, or /etc/sysconfig/rhn/sources
@@ -359,6 +364,68 @@
                key     =>'password=',
                value   =>$loncapa_config->{'lonSqlAccess'}},]);
 
+my $needs_inputrc_check;
+if ($dist  =~ /^debian(\d+)$/) {
+    if ($1 >= 12) {
+        $needs_inputrc_check = 1;
+    }
+} elsif ($dist =~ /^ubuntu(\d+)$/) {
+    if ($1 >= 22) {
+        $needs_inputrc_check = 1;
+    }
+} elsif ($dist =~ /^(?:redhat|oracle|alma|rocky|centos-stream)(\d+)$/) {
+    if ($1 >= 9) {
+        $needs_inputrc_check = 1;
+    }
+} elsif ($dist =~ /^fedora(\d+)$/) {
+    if ($1 >= 34) {
+        $needs_inputrc_check = 1;
+    }
+}
+
+if ($needs_inputrc_check) {
+    my $bash_www_cnf = '/home/www/.inputrc';
+    if (!-e $bash_www_cnf) {
+        system("touch $bash_www_cnf");
+        if (open(my $fh,'>',$bash_www_cnf)) {
+            print $fh "set enable-bracketed-paste off\n";
+            close($fh);
+        } else {
+            warn "**** Error: could not open $bash_www_cnf to add 'set enable-bracketed-paste to off'";
+        }
+    } else {
+        my ($bracketed_paste_on,$bracketed_paste_off, at preserve);
+        if (open(my $fh,'<',$bash_www_cnf)) {
+            while (my $line=<$fh>) {
+                chomp($line);
+                if ($line =~ /^\s*set\s+enable\-bracketed\-paste\s+(off|on)\s*$/) {
+                    if ($1 eq 'off') {
+                        $bracketed_paste_off = 1;
+                    } else {
+                        $bracketed_paste_on = 1;
+                    }
+                } else {
+                    push(@preserve,$line);
+                }
+            }
+            close($fh);
+        }
+        if ($bracketed_paste_on || !$bracketed_paste_off) {
+            if (open(my $fh,'>',$bash_www_cnf)) {
+                print $fh "set enable-bracketed-paste off\n";
+                if (@preserve) {
+                    foreach my $entry (@preserve) {
+                        print $fh "$entry\n";
+                    }
+                }
+                close($fh);
+            } else {
+                warn "**** Error: could not open $bash_www_cnf to add 'set enable-bracketed-paste to off'";
+            }
+        }
+    }
+}
+
 my $exitvalue = 0;
 
 if ($mysql_global_status) { $exitvalue = 1; }

Index: doc/loncapafiles/bash_config_check.piml
+++ doc/loncapafiles/bash_config_check.piml
<!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN" 
	"http://lpml.sourceforge.net/DTD/piml.dtd">
<!-- bash_config_check.piml -->

<!-- $Id: bash_config_check.piml,v 1.1 2024/07/08 23:46:05 raeburn Exp $ -->

<!--

This file is part of the LearningOnline Network with CAPA (LON-CAPA).

LON-CAPA is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

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.

You should have received a copy of the GNU General Public License
along with LON-CAPA; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

/home/httpd/html/adm/gpl.txt

http://www.lon-capa.org/

-->

<piml>
<targetroot>/</targetroot>
<files>
<file>
<target dist="default">/home/httpd/perl</target>
<perlscript mode="fg" dist="fedora34 fedora35 fedora36 fedora37 fedora38 fedora39 fedora40 debian12 ubuntu22 ubuntu24 centos9-stream rhes9 oracle9 rocky9 alma9">

use strict;

my $bracketed_warning;
if (open(PIPE,"/bin/su -s /bin/bash -c 'bind -V' www 2>&1 |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;
    }
} else {
    print "Unable to check if bracketed paste is set to off for www user's shell\n"; 
}

if ($bracketed_warning) {
    print <<"END";
**** ERROR: Problems will include calls to R statistics engine will not work.
You need to create a file: /home/www/.inputrc containing th efollowing line:
set enable-bracketed-paste to off
END
}

</perlscript>
</file>
</files>
</piml>




More information about the LON-CAPA-cvs mailing list