Bug 691425

Summary: In /etc/bashrc, set PROMPT_COMMAND only if not yet set
Product: Red Hat Enterprise Linux 6 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: 6.1CC: asersen, azelinka, pkovar, rbinkhor, sergio
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Bash provides the PROMPT_COMMAND environment variable containing a command that is called when a prompt is displayed. Prior to this update, the PROMPT_COMMAND variable set by a custom profile.d script was overwritten with the default value from the /etc/bashrc script file. With this update, the /etc/bashrc script file has been updated so that it now respects a user-defined PROMPT_COMMAND variable, and does not overwrite it.
Story Points: ---
Clone Of:
: 691430 (view as bug list) Environment:
Last Closed: 2011-08-18 06:44:30 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:    
Bug Blocks: 691430    

Description J.H.M. Dassen (Ray) 2011-03-28 14:34:05 UTC
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 2 Sergio Basto 2011-04-30 19:44:22 UTC
*** Bug 674108 has been marked as a duplicate of this bug. ***

Comment 8 Petr Kovar 2011-08-03 10:22:53 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Bash provides the PROMPT_COMMAND environment variable containing a command that is called when a prompt is displayed. Prior to this update, the PROMPT_COMMAND variable set by a custom profile.d script was overwritten with the default value from the /etc/bashrc script file. With this update, the /etc/bashrc script file has been updated so that it now respects a user-defined PROMPT_COMMAND variable, and does not overwrite it.

Comment 9 errata-xmlrpc 2011-08-18 06:44:30 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1171.html