Hi, a recent thread on issues with gpg-agent lead me to take a look at how the gpg-agent socket is located in subversion. The current code was lacking support for $GNUPGHOME, which allows a user to relocate his gnupg configuration directory. As setting this environment variable would also cause S.gpg-agent to be created inside of $GNUPGHOME, we might fail to correctly locate the file in this case.
Attached patch fixes the problem. [[[ gpg_agent: search in $GNUPGHOME for gpg-agent socket The socket used to connect to the gpg-agent resides in the GnuPG home directory, which is by default located at "$HOME/.gnupg". But in fact, the home directory can be relocated by the user by setting the environment variable GNUPGHOME, in which case the gpg-agent socket will live at "$GNUPGHOME/S.gpg-agent". Subversion does only search the standard home directory, though, without evaluating $GNUPGHOME. Fix the issue by using the socket located at "$GNUPGHOME/S.gpg-agent" instead of using "$HOME/.gnupg" when the environment variable is set. * subversion/libsvn_subr/gpg_agent.c (find_running_gpg_agent): evaluate $GNUPGHOME ]]]
diff --git a/subversion/libsvn_subr/gpg_agent.c b/subversion/libsvn_subr/gpg_agent.c index 217e14a..35bdf8f 100644 --- a/subversion/libsvn_subr/gpg_agent.c +++ b/subversion/libsvn_subr/gpg_agent.c @@ -233,6 +233,7 @@ find_running_gpg_agent(int *new_sd, apr_pool_t *pool) { char *buffer; char *gpg_agent_info = NULL; + char *gpg_home = NULL; const char *socket_name = NULL; const char *request = NULL; const char *p = NULL; @@ -245,9 +246,11 @@ find_running_gpg_agent(int *new_sd, apr_pool_t *pool) * 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 */ + * socket path is actually in the the GnuPG home directory, + * i.e. either $GNUPGHOME/S.gpg-agent if $GNUPGHOME is defined + * or ~/.gnupg/S.gpg-agent otherwise */ gpg_agent_info = getenv("GPG_AGENT_INFO"); + gpg_home = getenv("GNUPGHOME"); if (gpg_agent_info != NULL) { apr_array_header_t *socket_details; @@ -259,6 +262,11 @@ find_running_gpg_agent(int *new_sd, apr_pool_t *pool) pool); socket_name = APR_ARRAY_IDX(socket_details, 0, const char *); } + else if (gpg_home != NULL) + { + socket_name = svn_dirent_join_many(pool, gpg_home, + "S.gpg-agent", SVN_VA_NULL); + } else { const char *homedir = svn_user_get_homedir(pool);
signature.asc
Description: PGP signature