util: pidfile_pid() should not unlink PID file
authorMartin Schwenke <martin@meltin.net>
Mon, 31 Jul 2017 01:37:21 +0000 (11:37 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 2 Aug 2017 01:39:11 +0000 (03:39 +0200)
commit8731f1cfab5e8cd2550237b589b5767a93935381
tree5e8ac2593cacff52b8424651fbb2dfbba1d45844
parenta70ab5f02026d5610558d529c599f2cda904d742
util: pidfile_pid() should not unlink PID file

This causes a race.  If 2 callers to pidfile_create() both a find a
stale PID file using pidfile_pid().  The 1st may then return to
pidfile_create() and create a new PID file, which can then be unlinked
by the 2nd caller.

Consequently, PID file creation can not depend on creating the file,
so drop O_EXCL from the call to open().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
lib/util/pidfile.c