Commit bad3c6c3 bad3c6c3a982f65af0fe137d1e5b7a98d13bb9d5 by Sergey Poznyakoff

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.
1 parent 325c864e
......@@ -45,13 +45,4 @@ struct _mu_tls_stream
mu_stream_t transport[2];
};
struct _mu_tls_stream_s
{
struct _mu_stream stream;
enum _mu_tls_stream_state state;
gnutls_session session;
int tls_err;
mu_stream_t transport;
};
#endif
......
......@@ -45,7 +45,6 @@ MU_ERR_LOCK_EXT_KILLED _("External locker killed")
MU_ERR_NO_SUCH_USER _("No such user name")
MU_ERR_GETHOSTBYNAME _("DNS name resolution failed")
MU_ERR_BAD_RESUMPTION _("State busy must resume operation")
MU_ERR_MAILER_BAD_FROM _("Not a valid sender address")
MU_ERR_MAILER_BAD_TO _("Not a valid recipient address")
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")
MU_ERR_PERM_DIR_IWGRP _("File in group writable directory")
MU_ERR_PERM_DIR_IWOTH _("File in world writable directory")
MU_ERR_DISABLED _("Requested feature disabled in configuration")
......
......@@ -327,8 +327,6 @@ _mu_tls_io_stream_create (mu_stream_t *pstream,
sp->stream.close = _tls_io_close;
sp->stream.done = _tls_io_done;
sp->stream.ctl = _tls_io_ioctl;
/* FIXME:
sp->stream.error_string = _tls_error_string;*/
mu_stream_ref (transport);
sp->transport = transport;
......@@ -362,7 +360,8 @@ _tls_stream_push (gnutls_transport_ptr fd, const void *buf, size_t size)
rc = mu_stream_write (stream, buf, size, &size);
if (rc)
{
mu_error ("_tls_stream_push: %s", mu_strerror (rc)); /* FIXME */
mu_error ("_tls_stream_push: %s",
mu_stream_strerror (stream, rc)); /* FIXME */
return -1;
}
......@@ -379,7 +378,7 @@ _tls_server_open (mu_stream_t stream)
mu_transport_t transport[2];
if (!mu_tls_module_config.enable)
return MU_ERR_FAILURE; /* FIXME: another error code */
return MU_ERR_DISABLED;
if (!stream || sp->state != state_init)
return EINVAL;
......@@ -643,6 +642,17 @@ _tls_done (struct _mu_stream *stream)
mu_stream_destroy (&sp->transport[1]);
}
static const char *
_tls_error_string (struct _mu_stream *stream, int rc)
{
if (rc == EIO)
{
struct _mu_tls_stream *sp = (struct _mu_tls_stream *) stream;
return gnutls_strerror (sp->tls_err);
}
return mu_strerror (rc);
}
static int
_mu_tls_stream_create (mu_stream_t *pstream,
int (*openfn) (mu_stream_t stream),
......@@ -665,8 +675,7 @@ _mu_tls_stream_create (mu_stream_t *pstream,
sp->stream.done = _tls_done;
sp->stream.ctl = _tls_ioctl;
sp->stream.wait = _tls_wait;
/* FIXME:
sp->stream.error_string = _tls_error_string;*/
sp->stream.error_string = _tls_error_string;
mu_stream_set_buffer (strin, mu_buffer_none, 0);
mu_stream_set_buffer (strout, mu_buffer_none, 0);
......
......@@ -478,7 +478,7 @@ maildir_msg_init (struct _amd_data *amd, struct _amd_message *amm)
}
free (fname);
free (name);
return MU_ERR_BAD_RESUMPTION;
return EAGAIN;
}
static int
......