Bug 1165793

Summary: 'bash --debugger' should complain if bashdb is not installed, or else be turned off entirely
Product: Red Hat Enterprise Linux 7 Reporter: Eric Blake <eblake>
Component: bashAssignee: Ondrej Oprala <ooprala>
Status: CLOSED ERRATA QA Contact: Martin Kyral <mkyral>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: eblake, isenfeld, ovasik
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: bash-4.2.46-19.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1260568 (view as bug list) Environment:
Last Closed: 2015-11-19 04:39:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1260568    

Description Eric Blake 2014-11-19 17:46:21 UTC
Description of problem:
bash can be configured to support a --debugger option that effectively sources a hard-coded debugger script (often /usr/bin/bashdb).  RHEL does not ship bashdb (but Fedora does, and so it is feasible that EPEL might someday do likewise), but DOES configure bash to turn on the --debugger option.

If we have no intention of supporting a debugger, it might be nice to configure bash so that it rejects --debugger instead of silently ignoring it.  On the other hand, if we plan on allowing users to install their own debugger script, it would be nice if 'bash --debugger' could print an error message instead of silently behaving as if --debugger had not been specified, when the debugger script is not located.

Upstream bash currently uses the same mechanism for loading the debugger script as it does for other startup files, such as ~/.profile (look for maybe_execute_file):
http://git.savannah.gnu.org/gitweb/?p=bash.git;a=blob;f=shell.c;h=bbc8a66cc2ebb27162da8b36e87ff3d2e90e5bef;hb=ca6a2ba40c709c2b45a56e49d21d0dfc66e21974#l1385

But I have a potential downstream solution that would work in spite of the upstream code: what if we use the alternatives system.  Thus, the 'bash' package is in charge of installing a low-priority alternative that gets symlinked to /usr/bin/bashdb, and which blindly issues an error message along the lines of 'bash: debug script /usr/bin/bashdb not installed'.  Any other package, such as 'bashdb', that intends to provide a debugger would also use the alternatives system to install a higher-priority variant of the symlink.  The default install therefore behaves sanely without requiring bashdb, and the alternatives framework means that installing bashdb (whether from RHEL or third-party) then makes 'bash --debugger' magically start working.

Version-Release number of selected component (if applicable):
bash-4.1.2-29.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. echo 'echo hello' > foo
2. bash --debugger foo
3.

Actual results:
hello

Expected results:
either start an instance of a bash debugger, or error out stating that the debugger is not installed

Additional info:

Comment 2 Yaakov Selkowitz 2014-11-19 17:52:16 UTC
Does bashdb set some bash property or environment variable that could be checked in start_debugger(), the absence of which could then trigger an error message?

Comment 3 Ondrej Oprala 2014-11-20 10:06:17 UTC
I like the idea, and I agree we shouldn't just silently go along with executing the script when there's no debugger. However, I don't think we'll really benefit from it unless we try to get bashdb into EPEL as a parallel effort. This way, we'll have a neat system ready for some unspecified point in the future when someone might decide to bundle it, probably unaware of our effort with the alternatives system.

Comment 4 Eric Blake 2014-11-20 15:35:56 UTC
Does that mean we need to clone this to Fedora first, to get the alternatives system working there in both bash and bashdb?

Comment 5 Eric Blake 2014-11-22 02:35:43 UTC
See also this upstream message where I asked if bash should quit silently ignoring --debugger when the configured file does not exist.

https://lists.gnu.org/archive/html/bug-bash/2014-11/msg00137.html

Comment 6 Ondrej Oprala 2014-11-24 10:43:36 UTC
I'm glad that Chet agrees with this. I'm not sure about "fedora first", but it might be for the better. We'd test and get it working in fedora and hopefully wouldn't have to do more for future RHELs.

Comment 18 errata-xmlrpc 2015-11-19 04:39:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2144.html