summaryrefslogtreecommitdiffstats
path: root/tests/openpgp/fake-pinentry.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2016-04-14 09:08:50 +0200
committerWerner Koch <wk@gnupg.org>2016-04-14 09:37:45 +0200
commit94504b3d5af126abb591dedda1ca0f0970822f55 (patch)
treefd95167b3a3ab66010c2138135b6c492f7c9cd4b /tests/openpgp/fake-pinentry.c
parentagent: Implement new protection mode openpgp-s2k3-ocb-aes. (diff)
downloadgnupg2-94504b3d5af126abb591dedda1ca0f0970822f55.tar.xz
gnupg2-94504b3d5af126abb591dedda1ca0f0970822f55.zip
tests: Set fake-pinentry's stdout and stdin to _IOLBF.
* tests/openpgp/fake-pinentry.c (main): Call setvbuf. Show passphrase at startup. Increase buffer. -- Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tests/openpgp/fake-pinentry.c')
-rw-r--r--tests/openpgp/fake-pinentry.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/openpgp/fake-pinentry.c b/tests/openpgp/fake-pinentry.c
index c90637016..b8aa848b2 100644
--- a/tests/openpgp/fake-pinentry.c
+++ b/tests/openpgp/fake-pinentry.c
@@ -25,19 +25,36 @@
int
main (int argc, char **argv)
{
+ static char *passphrase;
+ char *p;
+
(void) argc, (void) argv;
+ setvbuf (stdin, NULL, _IOLBF, BUFSIZ);
+ setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
+
+ if (!passphrase)
+ {
+ passphrase = getenv ("PINENTRY_USER_DATA");
+ if (!passphrase)
+ passphrase = "";
+ for (p=passphrase; *p; p++)
+ if (*p == '\r' || *p == '\n')
+ *p = '.';
+ printf ("# Passphrase='%s'\n", passphrase);
+ }
+
printf ("OK - what's up?\n");
while (! feof (stdin))
{
- char buffer[128];
+ char buffer[1024];
if (fgets (buffer, sizeof buffer, stdin) == NULL)
break;
if (strncmp (buffer, "GETPIN", 6) == 0)
- printf ("D %s\nOK\n", getenv ("PINENTRY_USER_DATA") ?: "");
+ printf ("D %s\nOK\n", passphrase);
else if (strncmp (buffer, "BYE", 3) == 0)
{
printf ("OK\n");