From cbdc2506efbd5a83642ad50a957f0b51b9eedfc6 Mon Sep 17 00:00:00 2001 From: Changlei Li Date: Wed, 24 Sep 2025 18:43:22 +0800 Subject: [PATCH] CA-417641 Update ntp-dhcp server file path xsconsole can set ntp to Use DHCP NTP Servers or Use Default NTP Servers, Provide NTP Servers Manually. This is so-called dhcp default and manual mode. When switching from other modes to DHCP, the DHCP-provided NTP servers should be added to the Chrony sources. Conversely, they should be removed when switching away from DHCP. In XS9, the ntp-dhcp server path is outdated as the chrony version update, comparing to XS8. xs8-chrony: version 3.2, the server file with dhclient is /var/lib/dhclient/chrony.servers.$interface xs9-chrony: version 4.6.1, the server file with dhclient is /run/chrony-dhcp/$interface.sources So the path should be updated. Signed-off-by: Changlei Li --- XSConsoleData.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/XSConsoleData.py b/XSConsoleData.py index da03a40..a65e48a 100644 --- a/XSConsoleData.py +++ b/XSConsoleData.py @@ -602,8 +602,8 @@ def AddDHCPNTP(self): for interface in interfaces: ntpServer = self.GetDHCPNTPServer(interface) - with open("/var/lib/dhclient/chrony.servers.%s" % interface, "w") as chronyFile: - chronyFile.write("%s iburst prefer\n" % ntpServer) + with open("/run/chrony-dhcp/%s.sources" % interface, "w") as chronyFile: + chronyFile.write("server %s iburst prefer\n" % ntpServer) # Ensure chrony is enabled self.EnableService("chronyd") @@ -655,7 +655,7 @@ def RemoveDHCPNTP(self): newPermissions = oldPermissions & ~(stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) os.chmod("/etc/dhcp/dhclient.d/chrony.sh", newPermissions) - getstatusoutput("rm -f /var/lib/dhclient/chrony.servers.*") + getstatusoutput("rm -f /run/chrony-dhcp/*.sources") def SetTimeManually(self, date): # Double-check authentication