[csw-devel] SF.net SVN: opencsw:[623] catalog_signatures/bin/signing_daemon

bdwalton at users.sourceforge.net bdwalton at users.sourceforge.net
Tue Jul 24 04:32:12 CEST 2012


Revision: 623
          http://opencsw.svn.sourceforge.net/opencsw/?rev=623&view=rev
Author:   bdwalton
Date:     2012-07-24 02:32:12 +0000 (Tue, 24 Jul 2012)
Log Message:
-----------
Avoid starting multiple gpg agent processes

Be a bit smarter about when/how we start a new gpg agent process.
We used to nuke the env file and force a new agent into being.  Now,
we re-use an existing agent.

Signed-off-by: Ben Walton <bwalton at opencsw.org>

Modified Paths:
--------------
    catalog_signatures/bin/signing_daemon

Modified: catalog_signatures/bin/signing_daemon
===================================================================
--- catalog_signatures/bin/signing_daemon	2012-07-24 00:45:45 UTC (rev 622)
+++ catalog_signatures/bin/signing_daemon	2012-07-24 02:32:12 UTC (rev 623)
@@ -10,10 +10,26 @@
 APP_ETC="${APP_HOME}etc"
 source "${APP_ETC}/signing_daemon.conf"
 
-rm -f ${APP_GPG_ENV}
+_gpg_live=
+if [ -f ${APP_GPG_ENV} ]; then
+    _gpg_pid=$(cat ${APP_GPG_ENV} | awk -F: '{print $2}')
+    _gpg_live=$(ps -ef | awk "\$2 == ${_gpg_pid} {print}")
 
-# we run gpg-agent separately instead of having it fork/exec screen so
-# that when screen is detached, gpg-agent continues to run...
-eval $(gpg-agent --log-file "${APP_LOGDIR}/gpg-agent.log" --daemon --homedir "${APP_GPG}" --write-env-file "${APP_GPG_ENV}")
+    if [ -z "${_gpg_live}" ]; then
+	echo "Cleaning up old gpg agent cruft."
+	rm "${APP_GPG_ENV}"
+    fi
+fi
 
+if [ -z "${_gpg_live}" ]; then
+    # we run gpg-agent separately instead of having it fork/exec
+    # screen so that when screen is detached, gpg-agent continues to
+    # run...
+    eval $(gpg-agent --log-file "${APP_LOGDIR}/gpg-agent.log" --daemon --homedir "${APP_GPG}" --write-env-file "${APP_GPG_ENV}")
+else
+    echo "We think a gpg agent is running, so we're attempting to re-use it."
+    source "${APP_GPG_ENV}"
+    export GPG_AGENT_INFO
+fi
+
 exec screen -c "${APP_ETC}/screenrc" -p 0

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list