1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

15 Commits

Author SHA1 Message Date
Andreas Schneider
4e9a58f376 lib:util: Initialize pid
Found by covscan

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-12-15 19:32:30 +00:00
Volker Lendecke
cf43f331be lib: Make pidfile_path_create() return the existing PID on conflict
Use F_GETLK to get the lock holder PID, this is more accurate than
reading the file contents: A conflicting process might not have
written its PID yet. Also, F_GETLK easily allows to do a retry if the
lock holder just died.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-16 17:09:32 +00:00
Volker Lendecke
723a4648dd lib: Avoid a memleak in pidfile_unlink()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-09 22:36:28 +00:00
Volker Lendecke
4b8dc75085 lib: Avoid ZERO_STRUCT in pidfile_pid()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-09 22:36:28 +00:00
Martin Schwenke
043334f2eb util: Fix signed/unsigned comparisons by casting
One case needs a variable declared, so it can be compared to -1 and
then cast to size_t for comparison.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jul  1 08:00:29 UTC 2019 on sn-devel-184
2019-07-01 08:00:29 +00:00
Martin Schwenke
c4771246b7 util: Add documentation for PID file handling
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Aug 17 19:45:32 CEST 2017 on sn-devel-144
2017-08-17 19:45:32 +02:00
Martin Schwenke
09b0398865 util: Reimplement pidfile_create() using pidfile_path_create()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2017-08-02 03:39:12 +02:00
Martin Schwenke
411b7c8753 util: New functions pidfile_path_create(), pidfile_fd_close()
Uses the core of CTDB's create_pidfile_context() for
pidfile_path_create(). pidfile_fd_close() is a subset of CTDB's
pidfile_context_destructor().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2017-08-02 03:39:11 +02:00
Martin Schwenke
d665b74dbb util: Clean up includes
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2017-08-02 03:39:11 +02:00
Martin Schwenke
8731f1cfab 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>
2017-08-02 03:39:11 +02:00
Volker Lendecke
1237b006d5 lib: Simplify pidfile.c
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Feb 26 18:28:31 CET 2015 on sn-devel-104
2015-02-26 18:28:31 +01:00
Volker Lendecke
bd6bc30693 Fix whitespace
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-02-26 15:58:05 +01:00
Andreas Schneider
ac434c4223 util: Don't use the pid ret value uninitialized.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2012-12-12 09:42:33 +01:00
Jeremy Allison
3e476e184d Add debugs to functions. Add pidfile_unlink(). 2012-07-19 16:08:16 -07:00
Jeremy Allison
2922fdaaf0 Move source4/smbd/pidfile into lib/util in preparation for making it in common. 2012-07-19 15:41:52 -07:00