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:
Created attachment 131364 [details] patch to test for socket before exporting it
Thanks!
%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.
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
I think there's a fault in your logic. How is GPG_AGENT_INFO getting set?
Ah, I understand now, I think, point is it will never recover properly, right?
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?
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.
Created attachment 148085 [details] debug agent startup
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..
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
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)
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.
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.
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.