]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
conf: do not check, write and delete PID file if set to '/'
authorLuca Boccassi <bluca@debian.org>
Wed, 21 Aug 2024 19:21:47 +0000 (20:21 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 22 Aug 2024 12:24:49 +0000 (14:24 +0200)
If the pid file path is specified as '/', skip handling it,
as it is not only unnecessary but complicates managing the
service. A systemd unit can manage the program without any
need for this functionality, and it makes process tracking
simpler and more robust.
The implementation matches the bindcmdaddress directive.

conf.c
doc/chrony.conf.adoc

diff --git a/conf.c b/conf.c
index 858099fcde938f8f01d4e8788a3ef06269ac91d2..a06423e4f7d6782713a4f1b82efac753f6458689 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -78,6 +78,7 @@ static void parse_makestep(char *);
 static void parse_maxchange(char *);
 static void parse_ntsserver(char *, ARR_Instance files);
 static void parse_ntstrustedcerts(char *);
+static void parse_pidfile(char *line);
 static void parse_ratelimit(char *line, int *enabled, int *interval,
                             int *burst, int *leak, int *kod);
 static void parse_refclock(char *);
@@ -703,7 +704,7 @@ CNF_ParseLine(const char *filename, int number, char *line)
   } else if (!strcasecmp(command, "peer")) {
     parse_source(p, command, 1);
   } else if (!strcasecmp(command, "pidfile")) {
-    parse_string(p, &pidfile);
+    parse_pidfile(p);
   } else if (!strcasecmp(command, "pool")) {
     parse_source(p, command, 1);
   } else if (!strcasecmp(command, "port")) {
@@ -1529,6 +1530,20 @@ parse_hwtimestamp(char *line)
 
 /* ================================================== */
 
+static void
+parse_pidfile(char *line)
+{
+  parse_string(line, &pidfile);
+
+  /* / disables the PID file handling */
+  if (strcmp(pidfile, "/") == 0) {
+    Free(pidfile);
+    pidfile = NULL;
+  }
+}
+
+/* ================================================== */
+
 static const char *
 get_basename(const char *path)
 {
index 83de48527ae633c9023cf572e6d98051bdd88469..a5b49b13c4d9f57c94faf2377446ecf4aeef95a0 100644 (file)
@@ -2781,6 +2781,8 @@ e.g.:
 ----
 pidfile /run/chronyd.pid
 ----
++
+Setting this directive to _/_ disables writing and checking of the PID file.
 
 [[ptpport]]*ptpport* _port_::
 The *ptpport* directive enables *chronyd* to send and receive NTP messages