Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 471610 - net-misc/openntpd: add systemd unit
Summary: net-misc/openntpd: add systemd unit
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo systemd Team
URL:
Whiteboard:
Keywords: NeedPatch
Depends on:
Blocks: install-systemd-unit
  Show dependency tree
 
Reported: 2013-05-28 17:25 UTC by Christoph Junghans (RETIRED)
Modified: 2013-08-25 22:02 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Junghans (RETIRED) gentoo-dev 2013-05-28 17:25:05 UTC
Do the files from Arch Linux look ok?
<https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/openntpd>

And what do we do about start_pre() from
<http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/openntpd/files/openntpd.init.d-3.9_p1-r4?revision=1.1&view=markup>

ExecStartPre?
Comment 1 Michael Hampicke 2013-06-02 19:25:21 UTC
I tried the unit from arch for openntpd. It works, with one exception. If I enable openntpd to be executed on boot, it fails with this error:

Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime returns frequency of 0.000000ppm
Jun 02 22:58:19 work ntpd[3717]: ntp engine ready
Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime returns frequency of 0.000000ppm
Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime adjusted frequency by -500.000000ppm
Jun 02 22:58:19 work ntpd[3618]: could not parse "pool.ntp.org": System error
Jun 02 22:58:34 work systemd[1]: Started OpenNTP Daemon.
Jun 02 23:03:19 work ntpd[3717]: 0 out of 1 peers valid
Jun 02 23:03:19 work ntpd[3717]: bad peer from pool pool.ntp.org (not resolved)

I guess that the network is not in a complete ready state - but I don't know how to debug this.

What about /etc/conf.d/ntpd? Should the unit file evaluate that file?
Comment 2 Christoph Junghans (RETIRED) gentoo-dev 2013-06-02 23:25:15 UTC
(In reply to Michael Hampicke from comment #1)
> I tried the unit from arch for openntpd. It works, with one exception. If I
> enable openntpd to be executed on boot, it fails with this error:
> 
> Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime returns frequency of 0.000000ppm
> Jun 02 22:58:19 work ntpd[3717]: ntp engine ready
> Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime returns frequency of 0.000000ppm
> Jun 02 22:58:19 work ntpd[3618]: ntp_adjtime adjusted frequency by
> -500.000000ppm
> Jun 02 22:58:19 work ntpd[3618]: could not parse "pool.ntp.org": System error
> Jun 02 22:58:34 work systemd[1]: Started OpenNTP Daemon.
> Jun 02 23:03:19 work ntpd[3717]: 0 out of 1 peers valid
> Jun 02 23:03:19 work ntpd[3717]: bad peer from pool pool.ntp.org (not
> resolved)
> 
> I guess that the network is not in a complete ready state - but I don't know
> how to debug this.
Seems like After=network.target is not enough, we need something like "have.connection".

> 
> What about /etc/conf.d/ntpd? Should the unit file evaluate that file?
We could use EnvironmentFile for that.
Comment 3 Mike Gilbert gentoo-dev 2013-06-02 23:36:44 UTC
I would guess that the network issue depends a lot on what network manager you are using and your specific network config.

Is there any way to get openntpd to retry a few times? That would be better than trying to detect when usable network connection is ready.
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-06-03 05:14:26 UTC
(In reply to Christoph Junghans from comment #0)
> Do the files from Arch Linux look ok?
> <https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/
> openntpd>

I don't know. For example, why is it using Type=forking instead of just passing '-d'?

> And what do we do about start_pre() from
> <http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/openntpd/
> files/openntpd.init.d-3.9_p1-r4?revision=1.1&view=markup>
> 
> ExecStartPre?

Drop it. Init scripts are not supposed to perform system modifications when starting a service.

(In reply to Christoph Junghans from comment #2)
> > I guess that the network is not in a complete ready state - but I don't know
> > how to debug this.
> Seems like After=network.target is not enough, we need something like
> "have.connection".

After=network-online.target

But not all network providers support that. And daemon which requires network to be fully functional at startup seems broken to me.

> > What about /etc/conf.d/ntpd? Should the unit file evaluate that file?
> We could use EnvironmentFile for that.

Drop it.
Comment 5 Christoph Junghans (RETIRED) gentoo-dev 2013-06-03 17:02:43 UTC
(In reply to Michał Górny from comment #4)
> (In reply to Christoph Junghans from comment #0)
> > Do the files from Arch Linux look ok?
> > <https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/
> > openntpd>
> 
> I don't know. For example, why is it using Type=forking instead of just
> passing '-d'?
ntpd is strange, -d means "Do not daemonize"

> > And what do we do about start_pre() from
> > <http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/openntpd/
> > files/openntpd.init.d-3.9_p1-r4?revision=1.1&view=markup>
> > 
> > ExecStartPre?
> 
> Drop it. Init scripts are not supposed to perform system modifications when
> starting a service.
ntpd runs in a chroot and if you ever change your timezone ${NTPD_HOME}/etc/localtime needs update, too.

> (In reply to Christoph Junghans from comment #2)
> > > I guess that the network is not in a complete ready state - but I don't know
> > > how to debug this.
> > Seems like After=network.target is not enough, we need something like
> > "have.connection".
> 
> After=network-online.target
> 
> But not all network providers support that. And daemon which requires
> network to be fully functional at startup seems broken to me.
I have never seen that error before, seems to be a problem with name resolution.
 
> > > What about /etc/conf.d/ntpd? Should the unit file evaluate that file?
> > We could use EnvironmentFile for that.
> Drop it.
The "-s" options (set time on start-up) comes in handy for some users, but I don't want to make it the default.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-06-03 17:06:54 UTC
(In reply to Christoph Junghans from comment #5)
> (In reply to Michał Górny from comment #4)
> > (In reply to Christoph Junghans from comment #0)
> > > Do the files from Arch Linux look ok?
> > > <https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/
> > > openntpd>
> > 
> > I don't know. For example, why is it using Type=forking instead of just
> > passing '-d'?
> ntpd is strange, -d means "Do not daemonize"

Which is intended. There's no point in programs randomly forking and systemd having to track those forks.

> > > And what do we do about start_pre() from
> > > <http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/openntpd/
> > > files/openntpd.init.d-3.9_p1-r4?revision=1.1&view=markup>
> > > 
> > > ExecStartPre?
> > 
> > Drop it. Init scripts are not supposed to perform system modifications when
> > starting a service.
> ntpd runs in a chroot and if you ever change your timezone
> ${NTPD_HOME}/etc/localtime needs update, too.

Then either:

1. you have to care about that yourself,

2. ntpd has to care about it.

Adding some random kind of middleware which performs some of program's tasks is not good for anyone.

> > (In reply to Christoph Junghans from comment #2)
> > > > I guess that the network is not in a complete ready state - but I don't know
> > > > how to debug this.
> > > Seems like After=network.target is not enough, we need something like
> > > "have.connection".
> > 
> > After=network-online.target
> > 
> > But not all network providers support that. And daemon which requires
> > network to be fully functional at startup seems broken to me.
> I have never seen that error before, seems to be a problem with name
> resolution.

Well, I don't know the program but it looks like it assumes that only hosts that are resolvable during startup are valid. That's a pretty poor assumption that needs to be fixed upstream.

> > > > What about /etc/conf.d/ntpd? Should the unit file evaluate that file?
> > > We could use EnvironmentFile for that.
> > Drop it.
> The "-s" options (set time on start-up) comes in handy for some users, but I
> don't want to make it the default.

Then provide a configuration file for it. Upstream, so people wouldn't need to check where a particular distro keeps it.
Comment 7 Mike Gilbert gentoo-dev 2013-06-03 17:51:30 UTC
(In reply to Michał Górny from comment #6)
> Which is intended. There's no point in programs randomly forking and systemd
> having to track those forks.

To me, it seems like it might be better in some situations to use forking mode. For example, if the parent waits for the child to initialize itself before exiting, this can tell systemd that the service is "ready" without having to implement sd_notify(3).

I'm not sure if that's the case with openntpd, but it is worth checking.
Comment 8 Michael Hampicke 2013-06-06 13:22:11 UTC
Hello there,

thx for t he hint with net manager. Ater I enabled NetworkManager.service the problem was gone. Before that, I only had dhcpcd.service enabled.
Comment 9 Pacho Ramos gentoo-dev 2013-08-20 09:21:54 UTC
(In reply to Michael Hampicke from comment #8)
> Hello there,
> 
> thx for t he hint with net manager. Ater I enabled NetworkManager.service
> the problem was gone. Before that, I only had dhcpcd.service enabled.

That is because NetworkManager is able to detect network being online or not. The problem is that I don't know how to handle the other issues :/ (the needing of ExecPre, the config issue...)
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-08-20 09:38:32 UTC
The start_pre() is something that the ebuild should ensure, not init.d. It's a mess.
Comment 11 Christoph Junghans (RETIRED) gentoo-dev 2013-08-20 14:29:24 UTC
(In reply to Michał Górny from comment #10)
> The start_pre() is something that the ebuild should ensure, not init.d. It's
> a mess.
Well, that isn't that easy as the timezone might change. I don't want to re-emerge openntpd whenever I travel to the other side of the US. If have to check, but
ln -s /etc/localtime "${NTPD_HOME}/etc/localtime"
might do the job.
Comment 12 Christoph Junghans (RETIRED) gentoo-dev 2013-08-20 15:55:13 UTC
How about?

$ cat ntpd.service
[Unit]
Description=OpenNTP Daemon
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/ntpd -s -d

[Install]
WantedBy=multi-user.target

Combined with the symlink that should be a good start.
Comment 13 Christoph Junghans (RETIRED) gentoo-dev 2013-08-25 22:02:14 UTC
+*openntpd-20080406-r3 (25 Aug 2013)
+
+  25 Aug 2013; Christoph Junghans <ottxor@gentoo.org>
+  +files/openntpd.conf.d-20080406-r3, +files/openntpd.init.d-20080406-r3,
+  +files/openntpd.service-20080406-r3, +openntpd-20080406-r3.ebuild,
+  -files/openntpd.init.d-20080406-r1, -files/openntpd.init.d-20080406-r2,
+  -openntpd-20080406-r2.ebuild:
+  added systemd unit files (bug #471610)
+