Cancel operation does not return error code

Ingo Klöcker kloecker at
Thu Mar 10 22:15:50 CET 2022

On Donnerstag, 10. März 2022 14:30:29 CET Schultschik, Sven via Gnupg-users 
> if your using gpgme with interactive password entry on the command line and
> the user cancels the operation, shouldn't there be an error returned?
> Following code
> err = gpgme_op_encrypt(ctx, NULL, GPGME_ENCRYPT_SYMMETRIC, in, out);
> fprintf(stdout, "DEBUG ERROR Code = \%d \%s \%s\n" , gpgme_err_code(err),
> gpgme_strsource(err) , gpgme_strerror(err));
> If user cancel on the passwort screen, the following error code is returned
> ERROR Code = 0 Unspecified source Success

When I run t-encrypt-sym (in gpgme/tests/gpg) and cancel the passphrase dialog 
provided by pinentry-qt, then t-encrypt-sym prints
../../../../src/gpgme/tests/gpg/t-encrypt-sym.c:67: GPGME: Operation cancelled

When I force usage of pinentry-tty and cancel the passphrase entry with 
Ctrl+D, then I get the same result:
$ ./t-encrypt-sym 
Enter passphrase

../../../../src/gpgme/tests/gpg/t-encrypt-sym.c:67: GPGME: Operation cancelled

So, in general, gpgme_op_encrypt seems to return the correct error code. What 
I'm wondering is how do you cancel "interactive password entry on the command 
line" resp. how do you do "interactive password entry on the command line"?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the Gnupg-users mailing list