From 94504b3d5af126abb591dedda1ca0f0970822f55 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 14 Apr 2016 09:08:50 +0200 Subject: 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 --- tests/openpgp/fake-pinentry.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'tests/openpgp/fake-pinentry.c') 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"); -- cgit v1.2.3