Implement error_string method in TLS streams.
* include/mailutils/sys/tls-stream.h (_mu_tls_stream_s): Remove. * libmailutils/diag/errors (MU_ERR_BAD_RESUMPTION): Remove. Use EAGAIN instead. (MU_ERR_DISABLED): New error code. * libmu_auth/tls.c (_tls_server_open): Return MU_ERR_DISABLED when needed. (_mu_tls_stream_create): Implement error_string method. * libproto/maildir/mbox.c (maildir_msg_init): Fix return value.
Showing
4 changed files
with
17 additions
and
17 deletions
... | @@ -45,13 +45,4 @@ struct _mu_tls_stream | ... | @@ -45,13 +45,4 @@ struct _mu_tls_stream |
45 | mu_stream_t transport[2]; | 45 | mu_stream_t transport[2]; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | struct _mu_tls_stream_s | ||
49 | { | ||
50 | struct _mu_stream stream; | ||
51 | enum _mu_tls_stream_state state; | ||
52 | gnutls_session session; | ||
53 | int tls_err; | ||
54 | mu_stream_t transport; | ||
55 | }; | ||
56 | |||
57 | #endif | 48 | #endif | ... | ... |
... | @@ -45,7 +45,6 @@ MU_ERR_LOCK_EXT_KILLED _("External locker killed") | ... | @@ -45,7 +45,6 @@ MU_ERR_LOCK_EXT_KILLED _("External locker killed") |
45 | MU_ERR_NO_SUCH_USER _("No such user name") | 45 | MU_ERR_NO_SUCH_USER _("No such user name") |
46 | 46 | ||
47 | MU_ERR_GETHOSTBYNAME _("DNS name resolution failed") | 47 | MU_ERR_GETHOSTBYNAME _("DNS name resolution failed") |
48 | MU_ERR_BAD_RESUMPTION _("State busy must resume operation") | ||
49 | MU_ERR_MAILER_BAD_FROM _("Not a valid sender address") | 48 | MU_ERR_MAILER_BAD_FROM _("Not a valid sender address") |
50 | MU_ERR_MAILER_BAD_TO _("Not a valid recipient address") | 49 | MU_ERR_MAILER_BAD_TO _("Not a valid recipient address") |
51 | MU_ERR_MAILER_NO_RCPT_TO _("No recipient addresses found") | 50 | MU_ERR_MAILER_NO_RCPT_TO _("No recipient addresses found") |
... | @@ -123,3 +122,4 @@ MU_ERR_PERM_LINKED_WRDIR _("Linked file in a writable directory") | ... | @@ -123,3 +122,4 @@ MU_ERR_PERM_LINKED_WRDIR _("Linked file in a writable directory") |
123 | MU_ERR_PERM_DIR_IWGRP _("File in group writable directory") | 122 | MU_ERR_PERM_DIR_IWGRP _("File in group writable directory") |
124 | MU_ERR_PERM_DIR_IWOTH _("File in world writable directory") | 123 | MU_ERR_PERM_DIR_IWOTH _("File in world writable directory") |
125 | 124 | ||
125 | MU_ERR_DISABLED _("Requested feature disabled in configuration") | ... | ... |
... | @@ -327,8 +327,6 @@ _mu_tls_io_stream_create (mu_stream_t *pstream, | ... | @@ -327,8 +327,6 @@ _mu_tls_io_stream_create (mu_stream_t *pstream, |
327 | sp->stream.close = _tls_io_close; | 327 | sp->stream.close = _tls_io_close; |
328 | sp->stream.done = _tls_io_done; | 328 | sp->stream.done = _tls_io_done; |
329 | sp->stream.ctl = _tls_io_ioctl; | 329 | sp->stream.ctl = _tls_io_ioctl; |
330 | /* FIXME: | ||
331 | sp->stream.error_string = _tls_error_string;*/ | ||
332 | 330 | ||
333 | mu_stream_ref (transport); | 331 | mu_stream_ref (transport); |
334 | sp->transport = transport; | 332 | sp->transport = transport; |
... | @@ -362,7 +360,8 @@ _tls_stream_push (gnutls_transport_ptr fd, const void *buf, size_t size) | ... | @@ -362,7 +360,8 @@ _tls_stream_push (gnutls_transport_ptr fd, const void *buf, size_t size) |
362 | rc = mu_stream_write (stream, buf, size, &size); | 360 | rc = mu_stream_write (stream, buf, size, &size); |
363 | if (rc) | 361 | if (rc) |
364 | { | 362 | { |
365 | mu_error ("_tls_stream_push: %s", mu_strerror (rc)); /* FIXME */ | 363 | mu_error ("_tls_stream_push: %s", |
364 | mu_stream_strerror (stream, rc)); /* FIXME */ | ||
366 | return -1; | 365 | return -1; |
367 | } | 366 | } |
368 | 367 | ||
... | @@ -379,7 +378,7 @@ _tls_server_open (mu_stream_t stream) | ... | @@ -379,7 +378,7 @@ _tls_server_open (mu_stream_t stream) |
379 | mu_transport_t transport[2]; | 378 | mu_transport_t transport[2]; |
380 | 379 | ||
381 | if (!mu_tls_module_config.enable) | 380 | if (!mu_tls_module_config.enable) |
382 | return MU_ERR_FAILURE; /* FIXME: another error code */ | 381 | return MU_ERR_DISABLED; |
383 | if (!stream || sp->state != state_init) | 382 | if (!stream || sp->state != state_init) |
384 | return EINVAL; | 383 | return EINVAL; |
385 | 384 | ||
... | @@ -643,6 +642,17 @@ _tls_done (struct _mu_stream *stream) | ... | @@ -643,6 +642,17 @@ _tls_done (struct _mu_stream *stream) |
643 | mu_stream_destroy (&sp->transport[1]); | 642 | mu_stream_destroy (&sp->transport[1]); |
644 | } | 643 | } |
645 | 644 | ||
645 | static const char * | ||
646 | _tls_error_string (struct _mu_stream *stream, int rc) | ||
647 | { | ||
648 | if (rc == EIO) | ||
649 | { | ||
650 | struct _mu_tls_stream *sp = (struct _mu_tls_stream *) stream; | ||
651 | return gnutls_strerror (sp->tls_err); | ||
652 | } | ||
653 | return mu_strerror (rc); | ||
654 | } | ||
655 | |||
646 | static int | 656 | static int |
647 | _mu_tls_stream_create (mu_stream_t *pstream, | 657 | _mu_tls_stream_create (mu_stream_t *pstream, |
648 | int (*openfn) (mu_stream_t stream), | 658 | int (*openfn) (mu_stream_t stream), |
... | @@ -665,8 +675,7 @@ _mu_tls_stream_create (mu_stream_t *pstream, | ... | @@ -665,8 +675,7 @@ _mu_tls_stream_create (mu_stream_t *pstream, |
665 | sp->stream.done = _tls_done; | 675 | sp->stream.done = _tls_done; |
666 | sp->stream.ctl = _tls_ioctl; | 676 | sp->stream.ctl = _tls_ioctl; |
667 | sp->stream.wait = _tls_wait; | 677 | sp->stream.wait = _tls_wait; |
668 | /* FIXME: | 678 | sp->stream.error_string = _tls_error_string; |
669 | sp->stream.error_string = _tls_error_string;*/ | ||
670 | 679 | ||
671 | mu_stream_set_buffer (strin, mu_buffer_none, 0); | 680 | mu_stream_set_buffer (strin, mu_buffer_none, 0); |
672 | mu_stream_set_buffer (strout, mu_buffer_none, 0); | 681 | mu_stream_set_buffer (strout, mu_buffer_none, 0); | ... | ... |
... | @@ -478,7 +478,7 @@ maildir_msg_init (struct _amd_data *amd, struct _amd_message *amm) | ... | @@ -478,7 +478,7 @@ maildir_msg_init (struct _amd_data *amd, struct _amd_message *amm) |
478 | } | 478 | } |
479 | free (fname); | 479 | free (fname); |
480 | free (name); | 480 | free (name); |
481 | return MU_ERR_BAD_RESUMPTION; | 481 | return EAGAIN; |
482 | } | 482 | } |
483 | 483 | ||
484 | static int | 484 | static int | ... | ... |
-
Please register or sign in to post a comment