You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2014/06/04 19:25:57 UTC
svn commit: r1600368 - /subversion/trunk/subversion/libsvn_subr/gpg_agent.c
Author: breser
Date: Wed Jun 4 17:25:57 2014
New Revision: 1600368
URL: http://svn.apache.org/r1600368
Log:
Support connection to gpg-agent's that are using the standard socket location.
This is now the default behavior of gpg-agent (though many distributions
change that at build time). This means that GPG_AGENT_INFO is not required
if the gpg-agent's socket is in the standard location. The gpg-agent man page
describes how a client should determine the socket to connect to.
Some distributions of GPG rely on this and avoid setting GPG_AGENT_INFO
altogether, making our implementation require extra setup that GPG itself
doesn't. For example the GPGTools distribution of GPG on the Mac.
* subversion/libsvn_subr/gpg_agent.c
(find_running_gpg_agent): If there is no GPG_AGENT_INFO environment variable
try the standard location. Add some documentation of the GPG_AGENT_INFO
environment variable format to make it easier to understand what the code
is doing.
Modified:
subversion/trunk/subversion/libsvn_subr/gpg_agent.c
Modified: subversion/trunk/subversion/libsvn_subr/gpg_agent.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/gpg_agent.c?rev=1600368&r1=1600367&r2=1600368&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/gpg_agent.c (original)
+++ subversion/trunk/subversion/libsvn_subr/gpg_agent.c Wed Jun 4 17:25:57 2014
@@ -72,6 +72,8 @@
#include "svn_cmdline.h"
#include "svn_checksum.h"
#include "svn_string.h"
+#include "svn_user.h"
+#include "svn_dirent_uri.h"
#include "auth.h"
#include "private/svn_auth_private.h"
@@ -185,17 +187,30 @@ find_running_gpg_agent(int *new_sd, apr_
*new_sd = -1;
+ /* This implements the method of finding the socket as described in
+ * the gpg-agent man page under the --use-standard-socket option.
+ * The manage page misleadingly says the standard socket is
+ * "named 'S.gpg-agent' located in the home directory." The standard
+ * socket path is actually in the .gnupg directory in the home directory,
+ * i.e. ~/.gnupg/S.gpg-agent */
gpg_agent_info = getenv("GPG_AGENT_INFO");
if (gpg_agent_info != NULL)
{
apr_array_header_t *socket_details;
+ /* For reference GPG_AGENT_INFO consists of 3 : separated fields.
+ * The path to the socket, the pid of the gpg-agent process and
+ * finally the version of the protocol the agent talks. */
socket_details = svn_cstring_split(gpg_agent_info, ":", TRUE,
pool);
socket_name = APR_ARRAY_IDX(socket_details, 0, const char *);
}
else
- return SVN_NO_ERROR;
+ {
+ const char *homedir = svn_user_get_homedir(pool);
+ socket_name = svn_dirent_join_many(pool, homedir, ".gnupg",
+ "S.gpg-agent", SVN_VA_NULL);
+ }
if (socket_name != NULL)
{