Bug 691430

Summary: In /etc/bashrc, set PROMPT_COMMAND only if not yet set
Product: Red Hat Enterprise Linux 5 Reporter: J.H.M. Dassen (Ray) <rdassen>
Component: setupAssignee: Ondrej Vasik <ovasik>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 5.6CC: asersen, azelinka, dsulliva, jmarko, rbinkhor
Target Milestone: rcKeywords: EasyFix, Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 691425 Environment:
Last Closed: 2012-02-21 05:39:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 691425    
Bug Blocks: 554476, 726492    

Description J.H.M. Dassen (Ray) 2011-03-28 14:43:09 UTC
+++ This bug was initially created as a clone of Bug #691425 +++

2. What is the nature and description of the request?

Make a change to the default /etc/bashrc file so that if PROMPT_COMMAND has not
already been set, then to set it.

[ -z "${PROMPT_COMMAND}" ] && PROMPT_COMMAND=
'echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}";
echo -ne "\007"' 

3. Why does the customer need this? (List the business requirements here).

Customer wants the bash .history contents to be a more reliable audit of user
activities. Multiple articles found via google recommend setting env variable
PROMPT_COMMAND to contain 'history -a' so that multiple simultaneous shells
will share (and write immediately) the most recent commands executed to the
history file; refer to (among others):

http://linuxcommando.blogspot.com/2007/11/keeping-command-history-across-multiple.html 

The problem with these are:
1. The file /etc/sysconfig/bash-prompt-xterm is run by bash at each prompt as a
new executable (in a new shell) so doesn't work for setting the current shell's
history (or any other environment variables).
2. The files in /etc/profile.d/*.sh are read by /etc/profile before the
/etc/bashrc file is read by the default ~/.bashrc (taken from
/usr/skel/.bashrc). All changes to PROMPT_COMMAND are over-written by
/etc/bashrc. 

4. How would the customer like to achieve this? (List the functional
requirements here)

An update to bash so that /etc/bashrc only modifies the PROMPT_COMMAND if not
already set in the previous /etc/profile.d/*.sh or
/etc/sysconfig/bash_prompt_xterm files.  Make available in a minor update
release.

5. For each functional requirement listed in question 4, specify how Red Hat
and the customer can test to confirm the requirement is successfully
implemented.

Customer is able to test the latest Z-stream release for RHEL5 and RHEL6
package that has the /etc/bashrc changes and confirms that their history
setting is saved properly.

6. Is there already an existing RFE upstream or in Red Hat bugzilla?

no

7. How quickly does this need resolved? (desired target release)

RHEL5.8, RHEL6.2.

8. Does this request meet the RHEL Inclusion criteria (please review)

yes. 

9. List the affected packages.

setup

10. Would the customer be able to assist in testing this functionality if
implemented?

Yes

Comment 11 errata-xmlrpc 2012-02-21 05:39:18 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.

http://rhn.redhat.com/errata/RHBA-2012-0198.html