GpgME: gpgme_op_import_result() for crap data

Andre Heinecke aheinecke at gnupg.org
Tue Jan 15 10:54:49 CET 2019


Hi,

On Saturday, January 12, 2019 4:52:11 PM CET Albrecht Dreß wrote:
> when I call gpg to import some crap data, a proper error message is
> returned, e.g.:
> 
> <snip>
> user at host:~$ gpg --import <<< 'some crap'
> gpg: no valid OpenPGP data found.
> gpg: Total number processed: 0
> </snip>

That is not an error but a status message. The difference is that the 
operation continues. E.g. if you provide two filenames and the second one 
contains valid data you will get the status message once but still something 
is imported.

> I would expect that imports is not NULL, and imports->result indicate the 
error (probably GPG_ERR_INV_DATA).

I agree that it is bad. In Kleopatra I just treat empty results like an error 
happened. But if you import two files and only one has an error Kleopatra also 
will not show it.
 
> Did I miss something here (i.e. I have to read the error information 
somewhere else), or is this information left out intentionally?

You could use the new diagnostic interface to show the status output of GnuPG 
to the user in case an empty import result occured. I explicitly wanted to 
have that interface for such reasons where diagnostic output that is printed 
to stderr by GnuPG would otherwise be lost.

Be aware though that you should not automatically parse the diagnostic output 
as it might change because it is by design human readable output and not 
machine output.

I've commited an example how to use it to the gpgme run-import test:

https://dev.gnupg.org/rMce327f994a2888b807b63cf202ddcecc3fb9c685


Best Regards,
Andre

-- 
GnuPG e.V., Rochusstr. 44, D-40479 Düsseldorf.  VR 11482 Düsseldorf
Vorstand: W.Koch, M.Gollowitzer, A.Heinecke.    Mail: board at gnupg.org
Finanzamt D-Altstadt, St-Nr: 103/5923/1779.   Tel: +49-2104-4938799
-------------- 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: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20190115/224da26d/attachment.sig>


More information about the Gnupg-devel mailing list