From 5208fc6279f18b11bcc07a7fbfc54bf968a8fd19 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 18 Nov 2016 12:16:58 -0800 Subject: [PATCH] s3: lib: messaging: Solaris/Illumos sendmsg() is broken. Solaris/Illumos kernel should *NOT* be doing security checks on a connect()'ed unix domain socket at sendmsg() time, only at connect() time. Ensure we never queue messages on this platform. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12429 Signed-off-by: Jeremy Allison --- source3/lib/unix_msg/unix_msg.c | 20 ++++++++++++++++++++ source3/wscript | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/source3/lib/unix_msg/unix_msg.c b/source3/lib/unix_msg/unix_msg.c index bcfef28..720610e 100644 --- a/source3/lib/unix_msg/unix_msg.c +++ b/source3/lib/unix_msg/unix_msg.c @@ -660,6 +660,26 @@ static int unix_dgram_send(struct unix_dgram_ctx *ctx, unix_dgram_send_queue_free(q); return ret; } + +if defined(BROKEN_SENDMSG) + /* + * Never queue messages on broken platforms. + */ + { + int finished_job = -1; + do { + finished_job = -1; + ret = pthreadpool_finished_jobs(ctx->send_pool, + &finished_job, + 1); + if (ret <= 0) { + unix_dgram_send_queue_free(q); + return ret; + } + } while (q->sock != finished_job); + } +#endif + return 0; } diff --git a/source3/wscript b/source3/wscript index cd63f74..d50a264 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1482,6 +1482,14 @@ main() { conf.env['legacy_quota_libs'] = legacy_quota_libs # + # sendmsg() is broken on Solaris/Illumos. It checks permissions + # on a connected unix domain socket on every call, not only at + # connect time. See bug https://bugzilla.samba.org/show_bug.cgi?id=12429 + # + if (host_os.rfind('solaris') > -1): + conf.DEFINE('BROKEN_SENDMSG', '1') + + # # cluster support (CTDB) # if not Options.options.with_cluster_support: -- 2.8.0.rc3.226.g39d4020