Hello Kurt, Bernhard,

On Thu, Jul 28, 2011 at 06:27:34PM +0200, Kurt Roeckx wrote:
> On Thu, Jul 28, 2011 at 04:25:16PM +0200, Michael Stapelberg wrote:
> > [...]
> > I created a systemd service file for ntp.
> > [...]
> [...]
> Also, the current file is missing alot of the configuarion options
> that are curruntly supported, like having an ntp.conf provided
> by dhcp.

I looked into implementing a 1:1 service file mapping for the init
script but ended up with something I (as a systemd user) would not want
to use myself. Simply overriding things via systemd native mechanisms
instead of via /etc/default or via init script logic is much more
preferred for a systemd user. Once realising this the only feature of
the init script I deemed worth preserving was the dhcp integration.
(which could be implemented via a
ConditionalPathExists=!/run/ntp.conf.dhcp and another unit with the
reverse logic).
I think it's much better to implement this logic natively in the daemon,
so please see attached patch. Please note that it's gotten basically no
testing at all, so review carefully.

Adding this patch and Stapelbergs original service file, there might
be some additional work to do still where I'd like to hear your
preferred choice:
 a/ Add a NEWS.Debian noting that /etc/default/ntp is only considered
   on sysvinit systems from now on.
 b/ Add ^^^^ + attempt a one-time automatic migration of settings on
   upgrade to a native systemd override file.
 c/ Like previous plus involve some kind of debconf prompting?

Personally I think a/ would be enough, but maybe b/ would be nice.
What do you think? I'll definitely consider implementing it if that
means we can make progress here.

> 
> We now pass the uid/gid of $RUNASUSER, not some (fixed) name and group.

Since I opted for the choice of treating /etc/default file as a
(sysv)init mechanism (only), this would by systemd users be handled
by systemctl edit and overriding the command line as preferred.

> [ snipped parts that where already confirmed are ok as is ]
>
> I will need more information about systemd than what you pointed
> to.

Since you wrote this a long time ago your need for additional info might
have changed by now, but just in case here are some useful resources:
 * See series linked from
   http://0pointer.net/blog/projects/socket-activated-containers.html
 * The official documentation (and examples section), specifically
   https://www.freedesktop.org/software/systemd/man/systemd.service.html
There are also numerous good talks available on youtube about systemd.
 
Happy to assist (when I can) if you have any specific questions.
Helpful expert advice otherwise available on pkg-systemd-maintainers list.

Regards,
Andreas Henriksson

>From b9ac0de43cbfdf7ab5a7ea08d0d5c8e347948535 Mon Sep 17 00:00:00 2001
From: Andreas Henriksson <andr...@fatal.se>
Date: Mon, 8 May 2017 21:22:31 +0200
Subject: [PATCH] default to /run/ntp.conf(.dhcp) if available
Status: O
Content-Length: 1057
Lines: 42

Detecting and using /run/ntp.conf.dhcp was previously implemented
in Debians (sysv)init script.
---
 ntpd/ntp_config.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c
index 428ab9f..3590044 100644
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -4512,6 +4512,20 @@ config_remotely(
 	save_and_apply_config_tree(FALSE);
 }
 
+#ifndef SYS_WINNT
+static const char *
+findconfig() {
+	/* prefer /run/ntpd.conf(.dhcp) if available. */
+	if (access("/run/ntp.conf", F_OK) == 0)
+		return "/run/ntp.conf";
+
+	if (access("/run/ntp.conf.dhcp", F_OK) == 0)
+		return "/run/ntp.conf.dhcp";
+
+	/* or simply use the default */
+	return CONFIG_FILE;
+}
+#endif
 
 /*
  * getconfig() - process startup configuration file e.g /etc/ntp.conf
@@ -4528,7 +4542,7 @@ getconfig(
 	atexit(free_all_config_trees);
 #endif
 #ifndef SYS_WINNT
-	config_file = CONFIG_FILE;
+	config_file = findconfig();
 #else
 	temp = CONFIG_FILE;
 	if (!ExpandEnvironmentStringsA(temp, config_file_storage,
-- 
2.11.0

Reply via email to