Sergey Poznyakoff <[email protected]> ha escrit: > I will provide a better alternative in the short run.
Here it goes attached. Please give it a try and let me know if it works for you. Regards, Sergey
>From 9f9d7b0b7cdb586b34ff08bfa7c752d05088a720 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff <[email protected]> Date: Fri, 23 Mar 2012 16:52:33 +0200 Subject: [PATCH] Fix semantics of MU_IOCTL_SUBSTREAM. This also fixes e75e9123, which broke TLS support in daemons. * include/mailutils/stream.h (MU_IOCTL_TOPSTREAM): New ioctl. * imap4d/imap4d.c (set_strerr_flt) (clr_strerr_flt): Use MU_IOCTL_TOPSTREAM. * pop3d/pop3d.c: Likewise. * libmailutils/stream/fltstream.c (filter_ctl): Handle both MU_IOCTL_SUBSTREAM and MU_IOCTL_TOPSTREAM. * libmailutils/stream/iostream.c (_iostream_ctl): Likewise. * libmailutils/stream/logstream.c (_log_ctl): Likewise. * libmailutils/stream/xscript-stream.c (_xscript_ctl): Likewise. --- imap4d/imap4d.c | 10 +++++----- include/mailutils/stream.h | 4 ++++ libmailutils/stream/fltstream.c | 10 +++++++++- libmailutils/stream/iostream.c | 1 + libmailutils/stream/logstream.c | 8 ++++++++ libmailutils/stream/xscript-stream.c | 7 +++++++ pop3d/pop3d.c | 10 +++++----- 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c index 03af348..98957c5 100644 --- a/imap4d/imap4d.c +++ b/imap4d/imap4d.c @@ -415,7 +415,7 @@ set_strerr_flt () mu_stream_t flt, trans[2]; int rc; - rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET, trans); + rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_GET, trans); if (rc == 0) { char sessidstr[10]; @@ -432,7 +432,7 @@ set_strerr_flt () mu_stream_set_buffer (flt, mu_buffer_line, 0); trans[0] = flt; trans[1] = NULL; - rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_SUBSTREAM, + rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_SET, trans); mu_stream_unref (trans[0]); if (rc) @@ -456,16 +456,16 @@ clr_strerr_flt () mu_stream_t flt, trans[2]; int rc; - rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET, trans); + rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_GET, trans); if (rc == 0) { flt = trans[0]; - rc = mu_stream_ioctl (flt, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET, trans); + rc = mu_stream_ioctl (flt, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_GET, trans); if (rc == 0) { mu_stream_unref (trans[0]); - rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_SUBSTREAM, + rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_SET, trans); if (rc == 0) mu_stream_unref (flt); diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h index b0bdc4f..bbf9ec3 100644 --- a/include/mailutils/stream.h +++ b/include/mailutils/stream.h @@ -73,6 +73,10 @@ enum mu_buffer_type #define MU_IOCTL_FD 9 /* File descriptor manipulation */ #define MU_IOCTL_SYSLOGSTREAM 10 /* Syslog stream (see below) */ #define MU_IOCTL_FILTER 11 /* Filter streams (see below) */ +#define MU_IOCTL_TOPSTREAM 12 /* Same as MU_IOCTL_SUBSTREAM, but + always returns the topmost substream + */ /* Opcodes common for various families */ #define MU_IOCTL_OP_GET 0 diff --git a/libmailutils/stream/fltstream.c b/libmailutils/stream/fltstream.c index 8b26d27..9a8e4b5 100644 --- a/libmailutils/stream/fltstream.c +++ b/libmailutils/stream/fltstream.c @@ -398,7 +398,8 @@ static int filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr) { struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream; - + int status; + switch (code) { case MU_IOCTL_FILTER: @@ -423,6 +424,13 @@ filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr) break; case MU_IOCTL_SUBSTREAM: + if (fs->transport && + ((status = mu_stream_ioctl (fs->transport, code, opcode, ptr)) == 0 + || status != ENOSYS)) + return status; + /* fall through */ + + case MU_IOCTL_TOPSTREAM: if (!ptr) return EINVAL; else diff --git a/libmailutils/stream/iostream.c b/libmailutils/stream/iostream.c index 753cdc0..4eb0a80 100644 --- a/libmailutils/stream/iostream.c +++ b/libmailutils/stream/iostream.c @@ -159,6 +159,7 @@ _iostream_ctl (struct _mu_stream *str, int code, int opcode, void *arg) break; case MU_IOCTL_SUBSTREAM: + case MU_IOCTL_TOPSTREAM: if (!arg) return EINVAL; else diff --git a/libmailutils/stream/logstream.c b/libmailutils/stream/logstream.c index 3bcc684..81b9f65 100644 --- a/libmailutils/stream/logstream.c +++ b/libmailutils/stream/logstream.c @@ -281,6 +281,7 @@ static int _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg) { struct _mu_log_stream *sp = (struct _mu_log_stream *)str; + int status; switch (code) { @@ -310,6 +311,13 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg) break; case MU_IOCTL_SUBSTREAM: + if (sp->transport && + ((status = mu_stream_ioctl (sp->transport, code, opcode, arg)) == 0 || + status != ENOSYS)) + return status; + /* fall through */ + + case MU_IOCTL_TOPSTREAM: if (!arg) return EINVAL; else diff --git a/libmailutils/stream/xscript-stream.c b/libmailutils/stream/xscript-stream.c index 281eae4..9eb19ef 100644 --- a/libmailutils/stream/xscript-stream.c +++ b/libmailutils/stream/xscript-stream.c @@ -288,6 +288,13 @@ _xscript_ctl (struct _mu_stream *str, int code, int opcode, void *arg) break; case MU_IOCTL_SUBSTREAM: + if (sp->transport && + ((status = mu_stream_ioctl (sp->transport, code, opcode, arg)) == 0 || + status != ENOSYS)) + return status; + /* fall through */ + + case MU_IOCTL_TOPSTREAM: if (!arg) return EINVAL; switch (opcode) diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c index 223db35..efe4155 100644 --- a/pop3d/pop3d.c +++ b/pop3d/pop3d.c @@ -372,7 +372,7 @@ set_strerr_flt () mu_stream_t flt, trans[2]; int rc; - rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET, trans); + rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_GET, trans); if (rc == 0) { char sessidstr[10]; @@ -389,7 +389,7 @@ set_strerr_flt () mu_stream_set_buffer (flt, mu_buffer_line, 0); trans[0] = flt; trans[1] = NULL; - rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_SUBSTREAM, + rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_SET, trans); mu_stream_unref (trans[0]); if (rc) @@ -413,16 +413,16 @@ clr_strerr_flt () mu_stream_t flt, trans[2]; int rc; - rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET, trans); + rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_GET, trans); if (rc == 0) { flt = trans[0]; - rc = mu_stream_ioctl (flt, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET, trans); + rc = mu_stream_ioctl (flt, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_GET, trans); if (rc == 0) { mu_stream_unref (trans[0]); - rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_SUBSTREAM, + rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TOPSTREAM, MU_IOCTL_OP_SET, trans); if (rc == 0) mu_stream_unref (flt); -- 1.7.3.2
_______________________________________________ Bug-mailutils mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-mailutils
