AW: Cancel operation does not return error code
Schultschik, Sven
sven.schultschik at siemens.com
Fri Mar 11 10:29:41 CET 2022
The method gpgme_op_encrypt provides the interactive possibility itself.
If you don't set a passphrase with gpgme_set_passphrase_cb before calling gpgme_op_encrypt, it asks itself for a passphrase.
See screenshot.
There are more issues with this interactive view.
1. Cancel does not send an error
2. If you wait for the timeout of the passphrase form, it returns Error 0 Success as well
3. Ctrl+C does not cancel the gpgme passphrase entry. See screenshot 2
Ctrl+C I tried to fix by catching the ctrl+c signal an cancel gpgme itself
void signal_callback_handler(int signum)
{
gpgme_error_t err = gpgme_cancel(_ctx);
_ctx = gpgme_wait(_ctx, &err, false);
}
signal(SIGINT, signal_callback_handler);
regards
Sven
-----Ursprüngliche Nachricht-----
Von: Gnupg-users <gnupg-users-bounces at gnupg.org> Im Auftrag von Ingo Klöcker
Gesendet: Donnerstag, 10. März 2022 22:16
An: gnupg-users at gnupg.org
Betreff: Re: Cancel operation does not return error code
On Donnerstag, 10. März 2022 14:30:29 CET Schultschik, Sven via Gnupg-users
wrote:
> 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
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"?
Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctrl-c.png
Type: image/png
Size: 15046 bytes
Desc: ctrl-c.png
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20220311/fd2f6fa2/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2022-03-11 09_54_07-Clipboard.png
Type: image/png
Size: 6866 bytes
Desc: 2022-03-11 09_54_07-Clipboard.png
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20220311/fd2f6fa2/attachment-0003.png>
More information about the Gnupg-users
mailing list