2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-11 20:16:25 +00:00
Commit Graph

25 Commits

Author SHA1 Message Date
Daniel Hilst a6212e8384 fix(xcat-core): makentp and the NTP selector disagree on when chrony is usable
xCAT::NTP::Backend->available reported chrony as available on chronyd alone, while makentp
configured chrony only where systemctl was present too. On a host with chronyd and no systemctl
the selector returned chrony with no downgrade, makentp fell through to the ntpd path, and the
admin saw either a silent switch or "Please make sure ntpd is installed".

available now requires chronyd and systemctl for chrony, so the selector answers on the same
terms makentp acts on, and makentp branches on the name alone. choose therefore downgrades to
ntpd, or reports install, in the case it used to pass over. A commands argument injects the
command probe, in the same shape as the existing available argument.

ntp_backend_selection.t covers both commands. Six of its assertions fail without this change.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-03 14:40:31 -03:00
Daniel Hilst 124e2782db fix(makentp): make the backend call site testable
The NTP backend selector was well covered and nothing connected it to makentp:
copying the base makentp.pm over the head one left the whole unit suite
byte-identical, so the branches that consume choose()'s answer -- abort on a
selector error, warn on a downgrade, abort when neither daemon is installed --
and the --backend argument handed to setupntp were covered by nothing.

They were unreachable from a test because they sat inside process_request,
which needs a management node. Move the decisions into ntp_backend_action() and
setupntp_command(), which take their inputs and return an answer; the caller
keeps send_msg and runcmd. No behaviour changes -- the same messages are sent
on the same conditions, and the same command is built.

Verified by mutation rather than by reading: dropping the install abort reds 3
of 15, the downgrade note 1, the --backend argument 2, the server-list split 1,
and the selector-error abort 2.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-01 18:57:21 -03:00
Daniel Hilst a13a74f4c2 fix(xcat-core): let site.ntpbackend reach the nodes, not just the management node
makentp picks the NTP daemon through xCAT::NTP::Backend, but then runs setupntp -- on the
management node and, through updatenode -P, on every service node -- and setupntp decided for
itself with `check_executes chronyd || USE_NTPD=yes`. A cluster with site.ntpbackend=ntpd and
chronyd present therefore configured ntpd on the MN and chrony everywhere else. The selector was
one code path only on the side that does not write the config.

setupntp now takes --backend chrony|ntpd, and makentp passes what it chose on both call sites.
The service-node dispatch passes the cluster's intent rather than this host's availability: a
service node may have a different daemon installed, and the requested backend is a preference --
a node without chronyd still falls back to ntpd and logs that it did, rather than failing.
--use-ntpd keeps working.

Two results of choose() were computed and never read. A downgrade is now reported, so an admin
who asked for one daemon and got the other is told. install=1 -- neither daemon present -- is an
error naming the daemon that is missing, instead of falling through to the ntpd branch and
reporting "Please make sure ntpd is installed" even when chrony was the preferred choice.

Six cases cover the selection: the backend honoured in both directions, the probe still used when
none is given, and the fallback when the requested daemon is absent. Removing the --backend case
fails one; ignoring the preference fails two.

Also worth stating plainly, since the PR reads as a management-node fix: setupntp stops and
disables systemd-timesyncd wherever it runs, nodes included. It has to -- timesyncd disciplines
the clock against the daemon being configured -- but a node that was relying on it loses it.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-01 18:57:21 -03:00
Daniel Hilst 067eda810e fix(xcat-core): configure a server-capable NTP daemon on Ubuntu MNs
Add xCAT::NTP::Backend, a selector for the NTP daemon xCAT configures, in the same
spirit as xCAT::DHCP::Backend. It honours site.ntpbackend, defaults per distro family
(EL7+/SLES15+ chrony, older ntpd, Ubuntu/Debian chrony), and downgrades to whichever
of chrony/ntpd is actually installed rather than installing a second daemon. makentp
selects through it instead of probing /usr/sbin/chronyd directly, so the choice is one
unit-tested code path.

Guarantee the daemon at install time: the xcat metapackage now Depends on
"chrony | ntp" and the xCAT rpm Requires "(chrony or ntp)". Both sit beside the
existing service dependencies the metapackage already declares -- isc-dhcp-server|kea,
apache2, nfs-kernel-server -- because an MN that cannot serve time cannot serve its
compute nodes, and Ubuntu's default systemd-timesyncd is a client only.

Stop requiring hwclock in setupntp. It only persists the already-stepped system clock
to the RTC, and Ubuntu 24.04 moved it to util-linux-extra, absent on minimal images --
so a fatal check_exec_or_exit aborted the entire NTP setup, including the clock step
that does not use it. Use it when present, log and continue when not, and pull
util-linux-extra through Recommends and the diskless pkglist so it usually is.

Disable systemd-timesyncd there too. It ships as part of systemd rather than a
time-daemon package, so nothing displaces it, and it keeps disciplining the clock
against the daemon being configured.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-01 18:57:18 -03:00
Vinícius Ferrão bd260c9feb fix: harden makentp generated ntp.conf
The ntpd config generated by makentp had no access restrictions,
explicitly disabled authentication, and was vulnerable to CVE-2013-5211
amplification attacks.

Add restrict lines to block unauthorized access, add iburst for faster
initial sync, replace "disable auth" with "disable monitor". Security
hardening applies to all platforms including AIX (xntpd supports the
same restrict directives).

The chrony path (EL8+) is unaffected — it delegates to setupntp.

Fixes #2435
2026-04-26 16:19:32 -03:00
Markus Hilger 2643c1edd6 Remove useless executable bit 2024-05-07 16:19:25 +02:00
GONG Jie ca3251aaf1 Let makentp fall back to use ntpd when systemctl is not available. 2019-04-22 17:37:21 +08:00
Casandra Qiu 85894795c6 Change options Verbose to verbose 2018-08-21 15:18:12 -04:00
GONG Jie 5aea21eff3 Remove trailing spaces in file xCAT-server/lib/xcat/plugins/makentp.pm 2017-12-31 23:59:59 +00:00
GONG Jie 1d00ec9ea8 Remove some blank lines in makentp.pm 2018-07-19 13:27:14 +08:00
GONG Jie d227e2738a Tweak makentp for chronyd 2018-07-19 13:27:08 +08:00
Casandra Qiu 3586bea59b modify the message 2017-01-18 15:45:57 -05:00
Casandra Qiu 179f8211e3 change drift file to /var/lib/ntp/drift/ntp.drift 2017-01-03 14:50:00 -05:00
Casandra Qiu f08b804e74 modifed 2016-12-16 16:44:21 -05:00
Casandra Qiu 921213ea9e File /etc/sysconfig/ntpd doesn't exists in the SLES 2016-12-16 16:09:56 -05:00
immarvin 46daf64a93 fix issue [DEV] 'makentp -a' always return 1 #2282 2016-12-07 01:58:29 -05:00
Casandra Qiu c619538333 Handle invalid options for makentp command 2016-11-02 16:55:05 -04:00
Mark Gurevich 0a3fbd8d51 perltidy all perl files 2016-07-20 11:40:27 -04:00
Casandra Qiu 39cf499532 bugs#4720 makentp should supports synch MN's hwclock 2015-07-09 10:49:45 -04:00
Casandra Qiu f0b3125e0b Bug #4721 makentp -a didn't work on sles11.3 2015-07-02 14:28:19 -04:00
linggao ed8c829e66 ntp setup to handle sles12 2015-06-19 13:09:41 -04:00
linggao 5902b4808c more code for makentp 2015-06-17 22:13:08 -04:00
linggao 552e733075 added more code for ntp 2015-06-17 16:57:43 -04:00
linggao 3f32f3998f more on makentp 2015-06-12 15:39:59 -04:00
linggao 0ea24f1db9 added new command makentp to setup ntp servers on mn and sn. 2015-06-11 12:17:01 -04:00