assuan_read_from_server() and return value
Marcus Brinkmann
marcus.brinkmann at ruhr-uni-bochum.de
Tue Jan 8 18:46:37 CET 2008
At Sat, 5 Jan 2008 14:01:03 -0500,
Ben Kibbey <bjk at luxsci.net> wrote:
>
> On Mon, Dec 17, 2007 at 05:10:37PM +0100, Marcus Brinkmann wrote:
> > Ah, so now we are talking about the _assuan_read_from_server at the
> > "again:" label in _assuan_transact?
> >
> > In this case, the ERR should set OKAY to 0 and OFF to the offset of
> > the error code, and then assuan_transact should execute:
> >
> > if (!okay)
> > {
> > rc = atoi (line);
> > if (rc > 0 && rc < 100)
> > rc = _assuan_error (ASSUAN_Server_Fault);
> > else if (rc > 0 && rc <= 405)
> > rc = _assuan_error (rc);
> > }
> >
> > Thereby returning the error code as it should. Why is that code not
> > working for you?
>
> Didn't see this code. Sorry. This works as it should.
>
> If there is no error source set (which pinentry doesn't do)
> _assuan_error() will return the unmasked error code, and for the
> application (which uses gpg-error), it is impossible to determine if the
> error is an ASSUAN_ or GPG_ERR error code. So the problem (in my case)
> is with pinentry not setting an error source.
Alrighty! The problem is that _assuan_error is designed to be used
for error codes within the application, not to interpret error codes
from peers. The above code is thus "clearly wrong" (but see below),
as it should inspect rc for an error source.
However, unfortunately, there is no sane operation we can do if the
peers "mismatch", ie if one uses gpg-error and the other doesn't.
There is no lossless mapping from one to the other (in both
directions). Even if there was such a mapping, the application would
need to know about its details for user-defined error codes. This is
a mess!
So, the right thing to do is to just use gpg-error everywhere. I will
adjust pinentry accordingly. And in the future, we might even decide
to remove the ol' Assuan error stuff. It was useful for transition,
but I think once all components of gnupg are moved to use gpg-error,
it has outlived its purpose.
I know that you have been saying this all along, but I was focusing
first on the code and inquire stuff, because that was more difficult
to deal with. Solving the pinentry error code problem is easy.
Thanks,
Marcus
More information about the Gnupg-devel
mailing list