summaryrefslogtreecommitdiffstats
path: root/common/simple-pwquery.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <mb@g10code.com>2005-07-04 06:55:48 +0200
committerMarcus Brinkmann <mb@g10code.com>2005-07-04 06:55:48 +0200
commit51a164e75270b7e3bdf36b3ffab023592df15fc9 (patch)
treec960eb136f6d30d516992d5e1517cbf65dae8417 /common/simple-pwquery.c
parent(data_sign): Removed empty statement. (diff)
downloadgnupg2-51a164e75270b7e3bdf36b3ffab023592df15fc9.tar.xz
gnupg2-51a164e75270b7e3bdf36b3ffab023592df15fc9.zip
2005-07-04 Marcus Brinkmann <marcus@g10code.de>
* simple-pwquery.h (simple_pwclear): New prototype. * simple-pwquery.c (simple_pwclear): New function.
Diffstat (limited to 'common/simple-pwquery.c')
-rw-r--r--common/simple-pwquery.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/common/simple-pwquery.c b/common/simple-pwquery.c
index de3689810..f156ca3f1 100644
--- a/common/simple-pwquery.c
+++ b/common/simple-pwquery.c
@@ -546,6 +546,28 @@ simple_pwquery (const char *cacheid,
}
+/* Ask the gpg-agent to clear the passphrase for the cache ID CACHEID. */
+int
+simple_pwclear (const char *cacheid)
+{
+ char line[500];
+ char *p;
+
+ /* We need not more than 50 characters for the command and the
+ terminating nul. */
+ if (strlen (cacheid) * 3 > sizeof (line) - 50)
+ return SPWQ_PROTOCOL_ERROR;
+
+ strcpy (line, "CLEAR_PASSPHRASE ");
+ p = line + 17;
+ p = copy_and_escape (p, cacheid);
+ *p++ = '\n';
+ *p++ = '\0';
+
+ return simple_query (line);
+}
+
+
/* Perform the simple query QUERY (which must be new-line and 0
terminated) and return the error code. */
int
@@ -576,7 +598,7 @@ simple_query (const char *query)
rc = SPWQ_PROTOCOL_ERROR;
goto leave;
}
-
+
if (response[0] == 'O' && response[1] == 'K')
/* OK, do nothing. */;
else if ((nread > 7 && !memcmp (response, "ERR 111", 7)