[PATCH] Fix datagram messaging after an upgrade or reconfig

Volker Lendecke Volker.Lendecke at SerNet.DE
Wed Oct 21 13:29:49 UTC 2015


Hi!

Review&push appreciated!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de

Besuchen Sie uns vom 10.-11.11.15 auf der ISSE!
Information Security Solutions Europe Conference
Hotel Palace Berlin, 20%-Rabattcode: "ISSE15SP"

Meet us at Information Security Conference ISSE!
November 10th - 11th 2015 in Hotel Palace Berlin
For 20% discount take voucher code:  "ISSE15SP"
-------------- next part --------------
From 0a5ef3a697295a821e24673b08e54037aa45af5d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 21 Oct 2015 15:15:51 +0200
Subject: [PATCH] messaging: Fix creating the dgm lockfile

There might be situations where the lock directory moves to a
location where a previous installation left the datagram sockets
(Yes, I just came across this). We can't really deal with it except
by just removing the socket without properly checking.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/messages_dgm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index 006e917..2ede3d9 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -88,6 +88,25 @@ static int messaging_dgm_lockfile_create(struct messaging_dgm_context *ctx,
 
 	lockfile_fd = open(lockfile_name.buf, O_NONBLOCK|O_CREAT|O_RDWR,
 			   0644);
+
+        if ((lockfile_fd == -1) &&
+	    ((errno == ENXIO) /* Linux */ ||
+	     (errno == EOPNOTSUPP) /* FreeBSD */)) {
+		/*
+                 * Huh -- a socket? This might be a stale socket from
+                 * an upgrade of Samba. Just unlink and retry, nobody
+                 * else is supposed to be here at this time.
+                 *
+                 * Yes, this is racy, but I don't see a way to deal
+                 * with this properly.
+                 */
+		unlink(lockfile_name.buf);
+
+		lockfile_fd = open(lockfile_name.buf,
+				   O_NONBLOCK|O_CREAT|O_WRONLY,
+				   0644);
+	}
+
 	if (lockfile_fd == -1) {
 		ret = errno;
 		DEBUG(1, ("%s: open failed: %s\n", __func__, strerror(errno)));
-- 
1.9.1



More information about the samba-technical mailing list