assuan_read_from_server() and return value
Ben Kibbey
bjk at luxsci.net
Sat Dec 15 18:32:00 CET 2007
On Wed, Dec 12, 2007 at 03:47:18PM +0100, Marcus Brinkmann wrote:
> > After the inquire callback is finished, assuan_transact() sends END to
> > terminate the inquire then calls _assuan_read_from_server() again.
>
> Are you sure? That's not my reading of the code:
>
> assuan-client.c::assuan_transact()
> [...]
>
> if (!inquire_cb)
> {
> assuan_write_line (ctx, "END"); /* get out of inquire mode */
> _assuan_read_from_server (ctx, &okay, &off); /* dummy read */
> rc = _assuan_error (ASSUAN_No_Inquire_Callback);
> }
> else
> {
> rc = inquire_cb (inquire_cb_arg, line);
> if (!rc)
> rc = assuan_send_data (ctx, NULL, 0); /* flush and send END */
> if (!rc)
> goto again;
> }
I do have an inquire callback set. I was referring to the END sent from
assuan_send_data(). Then _assuan_read_from_server() is called to get the
error code (if any) of the inquire (with my patch applied).
> > Without the patch, _assuan_read_from_server()
> > returns the value returned from _assuan_read_line() (zero). I use
> > GPG_ERR codes on the server. Pinentry uses ASSUAN_ errors and there is
> > no way to tell if the error is an GPG_ERR_ or an ASSUAN_ error.
>
> Not quite correct. We have a heuristic to differentiate: Values that
> have the high bits set indicate a gpg error with a source set. All
> our servers set a gpg error source. On the other hand, low values
> indicate an assuan based error code. This is not failure proof, but
> covers current and expected usage. By the way: It is currently
> undefined how assuan error codes can be extended by user defined error
> codes. In gpg-error, there are reserved values for that.
Breaks when GPG_ERR_SOURCE_UNKNOWN is used, and this is the default.
>
> > So I
> > guess pinentry has to migrate to use GPG_ERR_ codes, which may break
> > clients, or I have to wait until libassuan removes ASSUAN_ codes
> > completely forcing libassuan users to use GPG_ERR_ codes, which seems
> > unlikely to happen any time soon?
>
> We can map assuan error codes to gpg error codes (see the function
> _assuan_error in mkerrors).
Has the error source problem above.
I have rewritten my app to handle pinentry specially, although it will
break when pinentry uses gpg-error codes. But I still need the patch
applied in order to get any inquire error code from the server.
--
Benjamin J. Kibbey bjk at luxsci.net/jabber/freenode
3019 F5FC AA33 5BC7 BE9F 09D2 393E DBD2 40D5 FA7E
More information about the Gnupg-devel
mailing list