You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/10/08 13:22:10 UTC
svn commit: r1005780 -
/subversion/branches/gpg-agent-password-store/subversion/libsvn_auth_gpg_agent/gpg_agent.c
Author: stylesen
Date: Fri Oct 8 11:22:10 2010
New Revision: 1005780
URL: http://svn.apache.org/viewvc?rev=1005780&view=rev
Log:
On the 'gpg-agent-password-store' branch:
More follow up based on philip's review.
* subversion/libsvn_auth_gpg_agent/gpg_agent.c
(): Formatting tweak - give two '\n' after each function definition
which was what I was doing all these days in code elsewhere in
subversion.
(password_get_gpg_agent): Get rid of many apr_pstrmemdup.
Suggested by: philip
Modified:
subversion/branches/gpg-agent-password-store/subversion/libsvn_auth_gpg_agent/gpg_agent.c
Modified: subversion/branches/gpg-agent-password-store/subversion/libsvn_auth_gpg_agent/gpg_agent.c
URL: http://svn.apache.org/viewvc/subversion/branches/gpg-agent-password-store/subversion/libsvn_auth_gpg_agent/gpg_agent.c?rev=1005780&r1=1005779&r2=1005780&view=diff
==============================================================================
--- subversion/branches/gpg-agent-password-store/subversion/libsvn_auth_gpg_agent/gpg_agent.c (original)
+++ subversion/branches/gpg-agent-password-store/subversion/libsvn_auth_gpg_agent/gpg_agent.c Fri Oct 8 11:22:10 2010
@@ -60,7 +60,6 @@ password_get_gpg_agent(const char **pass
{
int sd;
char *gpg_agent_info = NULL;
- char *value;
char *p = NULL;
char *ep = NULL;
char *buffer;
@@ -75,29 +74,16 @@ password_get_gpg_agent(const char **pass
const char *socket_name = NULL;
svn_checksum_t *digest = NULL;
- value = getenv("GPG_AGENT_INFO");
-
- if (value != NULL)
+ gpg_agent_info = getenv("GPG_AGENT_INFO");
+ if (gpg_agent_info != NULL)
{
- gpg_agent_info = apr_pstrmemdup(pool, value, strlen(value));
- socket_details = svn_cstring_split(gpg_agent_info, ":", TRUE, pool);
+ socket_details = svn_cstring_split(gpg_agent_info, ":", TRUE,
+ pool);
socket_name = APR_ARRAY_IDX(socket_details, 0, const char *);
}
else
return FALSE;
- value = getenv("GPG_TTY");
- if (value != NULL)
- tty_name = apr_pstrmemdup(pool, value, strlen(value));
- else
- return FALSE;
-
- value = getenv("TERM");
- if (value != NULL)
- tty_type = apr_pstrmemdup(pool, value, strlen(value));
- else
- return FALSE;
-
if (socket_name != NULL)
{
addr.sun_family = AF_UNIX;
@@ -126,21 +112,33 @@ password_get_gpg_agent(const char **pass
return FALSE;
/* Send TTY_NAME to the gpg-agent daemon. */
- request = apr_psprintf(pool, "OPTION ttyname=%s\n", tty_name);
- send(sd, request, strlen(request), 0);
- recvd = recv(sd, buffer, BUFFER_SIZE - 1, 0);
- buffer[recvd] = '\0';
+ tty_name = getenv("GPG_TTY");
+ if (tty_name != NULL)
+ {
+ request = apr_psprintf(pool, "OPTION ttyname=%s\n", tty_name);
+ send(sd, request, strlen(request), 0);
+ recvd = recv(sd, buffer, BUFFER_SIZE - 1, 0);
+ buffer[recvd] = '\0';
- if (strncmp(buffer, "OK", 2) != 0)
+ if (strncmp(buffer, "OK", 2) != 0)
+ return FALSE;
+ }
+ else
return FALSE;
/* Send TTY_TYPE to the gpg-agent daemon. */
- request = apr_psprintf(pool, "OPTION ttytype=%s\n", tty_type);
- send(sd, request, strlen(request), 0);
- recvd = recv(sd, buffer, BUFFER_SIZE - 1, 0);
- buffer[recvd] = '\0';
+ tty_type = getenv("TERM");
+ if (tty_type != NULL)
+ {
+ request = apr_psprintf(pool, "OPTION ttytype=%s\n", tty_type);
+ send(sd, request, strlen(request), 0);
+ recvd = recv(sd, buffer, BUFFER_SIZE - 1, 0);
+ buffer[recvd] = '\0';
- if (strncmp(buffer, "OK", 2) != 0)
+ if (strncmp(buffer, "OK", 2) != 0)
+ return FALSE;
+ }
+ else
return FALSE;
/* Create the CACHE_ID which will be generated based on REALMSTRING similar
@@ -173,12 +171,13 @@ password_get_gpg_agent(const char **pass
if (ep != NULL)
*ep = '\0';
- *password = apr_pstrmemdup(pool, p, recvd);
+ *password = p;
close(sd);
return TRUE;
}
+
/* Implementation of password_set_t that stores the password in
GPG Agent. */
static svn_boolean_t
@@ -230,6 +229,7 @@ simple_gpg_agent_save_creds(svn_boolean_
pool);
}
+
static const svn_auth_provider_t gpg_agent_simple_provider = {
SVN_AUTH_CRED_SIMPLE,
simple_gpg_agent_first_creds,
@@ -237,6 +237,7 @@ static const svn_auth_provider_t gpg_age
simple_gpg_agent_save_creds
};
+
/* Public API */
void
svn_auth_get_gpg_agent_simple_provider