Exit the timesyncd hook if not on systemd and not executable (#398)#403
Exit the timesyncd hook if not on systemd and not executable (#398)#403rsmarples merged 1 commit intoNetworkConfiguration:masterfrom perkelix:patch-1
Conversation
Exit the timesyncd hook immediately if not running on a systemd host AND timesyncd is not executable.
| if [ ! -d /run/systemd/system ]; then | ||
| return | ||
| fi | ||
| if [ ! -x /lib/systemd/systemd-timesyncd ]; then |
There was a problem hiding this comment.
Would it be better to create a reload_timesyncd function where we make this check? That way if a user installs timesyncd it functions correctly from the get-go.
Not suggesting to make this change unless you agree, more of a question.
There was a problem hiding this comment.
This is copied verbatim from Debian's dhclient exit hook, and similar to many other Debian scripts. They all start by checking for the existence of systemd's run directory. This one also checks whether timesyncd has been made executable.
Anyhow, the key point here is that the timesynd hook ships by default on a distro where the user might have intentionally disabled timesyncd to use e.g. Crony with a fixed NTP server instead, or may even have intentionally removed systemd to revert to a more traditional sysv init. Without this double check right at the start of the hook, errors appear.
If you prefer putting these in a function, I don't have any objection, but doing what dhclient does (i.e. stick these as-is at the start of the script) would probably be the safest bet.
Exit the timesyncd hook immediately if not running on a systemd host AND timesyncd is not executable.