Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit the timesyncd hook if not on systemd and not executable (#398) #403

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hooks/50-timesyncd.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
if [ ! -d /run/systemd/system ]; then
return
fi
if [ ! -x /lib/systemd/systemd-timesyncd ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@perkelix perkelix Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

return
fi

: ${timesyncd_conf_d:=/run/systemd/timesyncd.conf.d}
timesyncd_conf="${timesyncd_conf_d}/dhcpcd-$ifname.conf"
timesyncd_tmp_d="$state_dir/timesyncd"
Expand Down
Loading