From 1ab5b88939ba53f592ba4aa7251cc91e032cd32a Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Wed, 21 Aug 2024 20:21:47 +0100 Subject: [PATCH] conf: do not check, write and delete PID file if set to '/' 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 | 17 ++++++++++++++++- doc/chrony.conf.adoc | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 858099f..a06423e 100644 --- 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) { diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc index 83de485..a5b49b1 100644 --- a/doc/chrony.conf.adoc +++ b/doc/chrony.conf.adoc @@ -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