diff options
Diffstat (limited to 'tests/gpgsm/t-support.h')
-rw-r--r-- | tests/gpgsm/t-support.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/gpgsm/t-support.h b/tests/gpgsm/t-support.h index 07f00c38..6dc14569 100644 --- a/tests/gpgsm/t-support.h +++ b/tests/gpgsm/t-support.h @@ -62,8 +62,20 @@ gpgme_error_t passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info, int last_was_bad, int fd) { - write (fd, "abc\n", 4); - return 0; + int res; + char *pass = "abc\n"; + int passlen = strlen (pass); + int off = 0; + + do + { + res = write (fd, &pass[off], passlen - off); + if (res > 0) + off += res; + } + while (res > 0 && off != passlen); + + return off == passlen ? 0 : gpgme_error_from_errno (errno); } |