Bug 463913

Summary: keychain shouldn't overwrite and/or unset variables that are used by other tools
Product: [Fedora] Fedora Reporter: Mathieu Chouquet-Stringer <mathieu-acct>
Component: keychainAssignee: Alexander Dalloz <alex>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: medium    
Version: 10CC: alex, dqarras, ville.skytta
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 2.6.8-4.fc10 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-03-05 16:30:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mathieu Chouquet-Stringer 2008-09-25 11:14:46 UTC
Description of problem:
I use zsh and for quite some time, I have been having issues with an internal zsh facility that lets you print the hostname (namely print -P "%M).
On some of my F9 hosts it would work and on some others it wouldn't.

After investigating, it appears keychain in /etc/profile.d/keychain.sh not only overwrites HOST but it also unset it before it exits.

Issue is HOST is defined by the shell (document under "PARAMETERS SET BY THE SHELL" section in the manpage) so it expects it to be present.

If HOST isn't defined, print -P "%M" doesn't work:
%echo $HOST

%print -P "%m %M"

%HOST=foobar
%print -P "%m %M"
foobar foobar


Version-Release number of selected component (if applicable):
keychain-2.6.8-3.fc9.noarch

How reproducible:
Always if you have keychain enable (aka ~/.keychainrc).

Steps to Reproduce:
1. use zsh as your shell
2. have ~/.keychainrc
3. open a new session, HOST is undefined
  
Actual results:
keychain.sh overwrites HOST even though it's already set, then it unset it.

Expected results:
I guess it shouldn't replace the value of HOST if it's already there and above all it shouldn't delete it.

This is what I propose:

--- /etc/profile.d/keychain.sh.orig     2008-04-06 18:09:07.000000000 +0200
+++ /etc/profile.d/keychain.sh  2008-09-25 13:13:12.000000000 +0200
@@ -24,13 +24,13 @@
        keychain $KCHOPTS $SSHKEYS $GPGKEYS
     fi
 
-    HOST=`uname -n`
+    [ -n "$HOST" ] || HOST=`uname -n`
     [ -f $HOME/.keychain/$HOST-sh ] && \
        . $HOME/.keychain/$HOST-sh
     [ -f $HOME/.keychain/$HOST-sh-gpg ] && \
        . $HOME/.keychain/$HOST-sh-gpg
 
-    unset KCHOPTS SSHKEYS GPGKEYS HOST
+    unset KCHOPTS SSHKEYS GPGKEYS
 
     KEYCHAIN_DONE=1
 fi

Comment 1 Mathieu Chouquet-Stringer 2008-11-02 21:22:26 UTC
Anybody home?????

Comment 2 Alexander Dalloz 2008-11-05 13:32:39 UTC
Hello,
thank your for this report. I will care for this issue and prepare a new rpm once I have access to my build system.

Comment 3 Mathieu Chouquet-Stringer 2008-11-30 14:45:19 UTC
Same issue in F10...

Comment 4 Daniel Qarras 2008-12-22 22:22:06 UTC
I also noticed this with zsh, my prompt definition that has worked since the previous millennium is now broken :/

Comment 5 Mathieu Chouquet-Stringer 2009-02-07 15:51:47 UTC
Seriously, I reported this bug 4.5 months ago and *NOTHING* has been done while the fix is only a 2 liner...

Common...

Comment 6 Ville Skyttä 2009-02-16 18:22:16 UTC
https://admin.fedoraproject.org/updates/keychain-2.6.8-4.fc10 has been submitted for testing.

Please test and be sure to click the "works for me" or "does not work" radio buttons when submitting comments.  Updates for other affected distros will follow later if this works for people unless the package maintainer beats me to it.

Comment 7 Fedora Update System 2009-03-05 16:30:29 UTC
keychain-2.6.8-4.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.