[Xfce4-commits] <xfce-utils:master> fix gpg/ssh-agent startup for users with pam_ssh installed
Brian J. Tarricone
noreply at xfce.org
Thu Sep 24 00:24:01 CEST 2009
Updating branch refs/heads/master
to c67549e4b0648a95af9b1e5197cacdc452fea68b (commit)
from 1631634f2427fe1797cbff67b771f5d5badd275b (commit)
commit c67549e4b0648a95af9b1e5197cacdc452fea68b
Author: Brian J. Tarricone <brian at tarricone.org>
Date: Wed Sep 23 15:23:30 2009 -0700
fix gpg/ssh-agent startup for users with pam_ssh installed
this also fixes the case where ssh-agent just happens to be already
running. it's now a lot smarter about figuring out what to run, and to
make sure it cleans up after itself properly.
NEWS | 1 +
scripts/xinitrc.in.in | 55 ++++++++++++++++++++++++++++++++++++------------
2 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/NEWS b/NEWS
index 2606a2d..14b28f4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
4.7.0
=====
+- Add support for starting gpg-agent.
- Add ability to enable/disable or change the type of screensaver and
ssh-agent using xfconf.
diff --git a/scripts/xinitrc.in.in b/scripts/xinitrc.in.in
index e1a2167..fb3f6a3 100755
--- a/scripts/xinitrc.in.in
+++ b/scripts/xinitrc.in.in
@@ -140,29 +140,55 @@ fi
# launch gpg-agent or ssh-agent if enabled.
ssh_agent_enabled=`xfconf-query -c xfce4-session -p /startup/ssh-agent/enabled`
-if test -z "$SSH_AGENT_PID" -a "$ssh_agent_enabled" != "false"; then
+if test "$ssh_agent_enabled" != "false"; then
+ # if the user has pam_ssh installed, it will start ssh-agent for us, but
+ # of course won't start gpg-agent. so, if ssh-agent is already running,
+ # but we want gpg-agent (and that's not running yet) start gpg-agent
+ # without ssh support
+
ssh_agent_type=`xfconf-query -c xfce4-session -p /startup/ssh-agent/type`
+ if test -z "$ssh_agent_type"; then
+ if type gpg-agent >/dev/null 2>&1; then
+ ssh_agent_type=gpg-agent
+ else
+ ssh_agent_type=ssh-agent
+ fi
+ fi
+
+ # ignore stale ssh-agents
+ if test "$SSH_AGENT_PID"; then
+ if ! kill -0 $SSH_AGENT_PID; then
+ unset SSH_AGENT_PID
+ unset SSH_AUTH_SOCK
+ fi
+ fi
case "$ssh_agent_type" in
gpg-agent)
- eval `gpg-agent --daemon --enable-ssh-support`
- ssh_agent_kill_cmd="kill -INT $SSH_AGENT_PID"
+ if test -z "$SSH_AGENT_PID"; then
+ eval `gpg-agent --daemon --enable-ssh-support --write-env-file $XDG_CACHE_HOME/gpg-agent-info`
+ ssh_agent_kill_cmd="kill -INT $SSH_AGENT_PID; rm -f $XDG_CACHE_HOME/gpg-agent-info"
+ elif test -z "$GPG_AGENT_INFO"; then
+ echo "ssh-agent is already running; starting gpg-agent without ssh support"
+ eval `gpg-agent --daemon --write-env-file $XDG_CACHE_HOME/gpg-agent-info`
+ ssh_agent_kill_cmd="pkill -INT ^gpg-agent\$; rm -f $XDG_CACHE_HOME/gpg-agent-info"
+ else
+ echo "gpg-agent is already running"
+ fi
;;
ssh-agent)
- eval `ssh-agent -s`
- ssh_agent_kill_cmd="ssh-agent -k"
- ;;
-
- *)
- if type gpg-agent >/dev/null 2>&1; then
- eval `gpg-agent --daemon --enable-ssh-support`
- ssh_agent_kill_cmd="kill -INT $SSH_AGENT_PID"
- elif type ssh-agent >/dev/null 2>&1; then
+ if test -z "$SSH_AGENT_PID"; then
eval `ssh-agent -s`
ssh_agent_kill_cmd="ssh-agent -k"
+ else
+ echo "ssh-agent is already running"
fi
;;
+
+ *)
+ echo "Unrecognized agent type '$ssh_agent_type'" >&2
+ ;;
esac
fi
@@ -172,7 +198,8 @@ if type xfce4-session >/dev/null 2>&1; then
xfce4-session
if test "$ssh_agent_kill_cmd"; then
- $ssh_agent_kill_cmd
+ echo "running '$ssh_agent_kill_cmd'"
+ eval "$ssh_agent_kill_cmd"
fi
exit 0
@@ -261,7 +288,7 @@ EOF
esac
if test "$ssh_agent_kill_cmd"; then
- $ssh_agent_kill_cmd
+ eval "$ssh_agent_kill_cmd"
fi
xsetroot -bg white -fg red -solid black -cursor_name watch
More information about the Xfce4-commits
mailing list