1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

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@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Oct 22 02:14:29 CEST 2015 on sn-devel-104
This commit is contained in:
Volker Lendecke 2015-10-21 15:15:51 +02:00 committed by Jeremy Allison
parent 3e705adcab
commit f1c49d7656

View File

@ -88,6 +88,26 @@ 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 == ENODEV) /* Linux kernel bug */ ||
(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)));