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

Merged
merged 1 commit into from
Dec 8, 2024

Conversation

perkelix
Copy link
Contributor

Exit the timesyncd hook immediately if not running on a systemd host AND timesyncd is not executable.

…Configuration#398)

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
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rsmarples are we merging this?

@rsmarples rsmarples merged commit 2568932 into NetworkConfiguration:master Dec 8, 2024
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants