Bug 196327 - gnupg2: gpg-agent not restarted after kde session crash/killed
gnupg2: gpg-agent not restarted after kde session crash/killed
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: gnupg2 (Show other bugs)
7
All Linux
medium Severity medium
: ---
: ---
Assigned To: Rex Dieter
Fedora Extras Quality Assurance
: Patch, Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-06-22 12:00 EDT by Robert Story
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version: 2.0.5-3.fc7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-08-13 13:07:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch to test for socket before exporting it (829 bytes, patch)
2006-06-22 12:00 EDT, Robert Story
no flags Details | Diff
debug agent startup (1.53 KB, application/x-sh)
2007-02-14 15:41 EST, Robert Story
no flags Details

  None (edit)
Description Robert Story 2006-06-22 12:00:36 EDT
Description of problem:
If a KDE session crashes or is killed, then
/etc/kde/shutdown/gpg-agent-shutdown.sh is not run, and $HOME/.gpg-agent-info is
not removed. On the next login, /etc/kde/env/gpg-agent-startup.sh will not start
gpg-agent if $HOME/.gpg-agent-info exists.

Version-Release number of selected component (if applicable):
gnupg2-1.9.20-3.fc5

How reproducible:
always

Steps to Reproduce:
1. log in KDE user
2. kill session & gpg-agent (or issue shutdown -r w/out loging out)
3. log in again
  
Actual results:
gpg-agent is not started, but GPG_AGENT_INFO is exported w/bad info

Expected results:
gpg-agent is started, correct GPG_AGENT_INFO is exported

Additional info:
Comment 1 Robert Story 2006-06-22 12:00:36 EDT
Created attachment 131364 [details]
patch to test for socket before exporting it
Comment 2 Rex Dieter 2006-06-22 12:15:00 EDT
Thanks!
Comment 3 Rex Dieter 2006-06-22 12:41:54 EDT
%changelog
* Thu Jun 22 2006 Rex Dieter <rexdieter[AT]users.sf.net> 1.9.21-3
- fix "gpg-agent not restarted after kde session crash/killed (#196327)

fixed build coming soon to a repo near you.
Comment 4 Robert Story 2007-02-14 12:23:37 EST
I had noticed that this doesn't appear to be working, so when it happened again
this morning, I took a little more time to look into it. The problem is the
initial test:

if [ -z "${GPG_AGENT_INFO}" -a -x "${GPG_AGENT}" ] ; then

So, if GPG_AGENT_INFO has been set, it won't test the validity of the socket. It
should always test the socket, so should be:

if [ -x "${GPG_AGENT}" ] ; then
Comment 5 Rex Dieter 2007-02-14 12:31:14 EST
I think there's a fault in your logic.  How is GPG_AGENT_INFO getting set?
Comment 6 Rex Dieter 2007-02-14 12:32:54 EST
Ah, I understand now, I think, point is it will never recover properly, right?
Comment 7 Rex Dieter 2007-02-14 12:36:42 EST
I'm confused again.

How could it happen that GPG_AGENT_INFO is set, but gpg-agent is not running? 
Or are you saying gpg-agent (possibly) crashed in the middle of a session
leaving a stale $GPG_AGENT_INFO behind?
Comment 8 Rex Dieter 2007-02-14 12:44:37 EST
OK, less confused again, I'm leaning toward liking your suggestion, since it
will test for validity on every run instead of assuming GPG_AGENT_INFO is always
correct.
Comment 9 Robert Story 2007-02-14 15:41:39 EST
Created attachment 148085 [details]
debug agent startup
Comment 10 Robert Story 2007-02-14 15:42:55 EST
Comment on attachment 148085 [details]
debug agent startup

Ok, I did a bit of poking around, and it has nothing to do with GPG_AGENT_INFO
already being set.. the problem is if gpg-agent is killed and the kde cleaup
doesn't run.. then there is a .gpg-agent-info file pointing to a socket with no
listener...  so we need to check if the PID in the .gpg-agent-info file is
active too.. either by using /proc or a ps command.

Attached is the debug version of the the setup script I used for testing, and
it seems to work for the case where both gpg-agent and kde are killed without a
chance to clean-up..
Comment 11 Robert Story 2007-06-07 11:53:47 EDT
Problem remains in Fedora 7. Here's the patch I'm currently using...

5c5
< if [ -z "${GPG_AGENT_INFO}" -a -x "${GPG_AGENT}" ] ; then
---
> if [ -x "${GPG_AGENT}" ] ; then
10,11c10,12
<     GPG_SOCKET=$(cat "${GPG_AGENT_INFO_FILE}" | cut -f1 -d:)
<     if ! test -S "${GPG_SOCKET}" -a -O "${GPG_SOCKET}" ; then
---
>     GPG_AGENT_PID=`cat ${GPG_AGENT_INFO_FILE} | cut -f2 -d:`
>     GPG_PID_NAME=`ps -p ${GPG_AGENT_PID} -o comm=`
>     if [ ! "x${GPG_PID_NAME}" = "xgpg-agent" ]; then
12a14,18
>     else
>        GPG_SOCKET=$(cat "${GPG_AGENT_INFO_FILE}" | cut -f1 -d:)
>        if ! test -S "${GPG_SOCKET}" -a -O "${GPG_SOCKET}" ; then
>          rm -f "${GPG_AGENT_INFO_FILE}" 2>&1 >/dev/null
>        fi
13a20
>     unset GPG_AGENT_PID GPG_SOCKET GPG_PID_NAME
Comment 12 Rex Dieter 2007-07-06 11:07:38 EDT
OK, I've stalled long enough to fix this properly.  Thanks for the patches and
patience.

%changelog
* Fri Jul 06 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 2.0.5-1
- gnupg-2.0.5
- gpg-agent not restarted after kde session crash/killed (#196327)
Comment 13 Fedora Update System 2007-07-09 11:45:15 EDT
gnupg2-2.0.5-2.fc7 has been pushed to the Fedora 7 testing repository.  If problems still persist, please make note of it in this bug report.
Comment 14 Fedora Update System 2007-07-16 12:55:25 EDT
gnupg2-2.0.5-3.fc7 has been pushed to the Fedora 7 testing repository.  If problems still persist, please make note of it in this bug report.
Comment 15 Fedora Update System 2007-08-13 13:07:24 EDT
gnupg2-2.0.5-3.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.