summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2026-01-04 15:30:25 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2026-01-04 21:30:27 +0000
commitdd7c30bd6b30a6ac3cf23b5460e8337f147b13a2 (patch)
tree369d73fa29c3c694026e5ab61b4d95630ba255e0 /perl-install
parentbe0ef82523ad8d642f12ff13e4a9e152f8fc15b7 (diff)
downloaddrakx-dd7c30bd6b30a6ac3cf23b5460e8337f147b13a2.tar
drakx-dd7c30bd6b30a6ac3cf23b5460e8337f147b13a2.tar.gz
drakx-dd7c30bd6b30a6ac3cf23b5460e8337f147b13a2.tar.bz2
drakx-dd7c30bd6b30a6ac3cf23b5460e8337f147b13a2.tar.xz
drakx-dd7c30bd6b30a6ac3cf23b5460e8337f147b13a2.zip
drakclock: fix config file read/write for chrony and ntpsec (mga#34664)
drakclock only supports selecting a server pool, not individual servers, so use the "pool" directive instead if the "server" directive. Rename the subroutines in timezone.pm for clarity. ntpsec overrides /etc/ntp.conf with settings found in /etc/ntp.d/, so we need to read/write /etc/ntp.d/use-pool. Both chrony and ntpsec support the iburst option, so we can write that unconditionally.
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/NEWS3
-rw-r--r--perl-install/install/any.pm2
-rwxr-xr-xperl-install/standalone/drakclock8
-rw-r--r--perl-install/timezone.pm38
4 files changed, 21 insertions, 30 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS
index 008c0f62b..5d63ecdf8 100644
--- a/perl-install/NEWS
+++ b/perl-install/NEWS
@@ -1,3 +1,6 @@
+- drakclock:
+ o fix config file read/write for chrony and ntpsec (mga#34664)
+ * use "pool" directive instead of "service"
- improve Congratulations message in last installer screen (mga#28209)
- make IceWM the last choice when automatically choosing the session for autologin
- fix inconsistent use of any::sessions()
diff --git a/perl-install/install/any.pm b/perl-install/install/any.pm
index 83b255efd..8772879ac 100644
--- a/perl-install/install/any.pm
+++ b/perl-install/install/any.pm
@@ -133,7 +133,7 @@ sub preConfigureTimezone {
$o->{timezone}{timezone} ||= timezone::bestTimezone($o->{locale}{country});
my $utc = every { !isFat_or_NTFS($_) } @{$o->{fstab}};
- my $ntp = timezone::ntp_server();
+ my $ntp = timezone::ntp_pool();
add2hash_($o->{timezone}, { UTC => $utc, ntp => $ntp });
#- Make the timezone available to urpm::mirrors.
diff --git a/perl-install/standalone/drakclock b/perl-install/standalone/drakclock
index ca8c69477..310701dbe 100755
--- a/perl-install/standalone/drakclock
+++ b/perl-install/standalone/drakclock
@@ -23,8 +23,8 @@ my $its_reset = 0;
$ugtk3::wm_icon = "/usr/share/mcc/themes/default/time-mdk.png";
-my $ntpd = $timezone::ntp . 'd';
-my $ntpfile = '/etc/' . $timezone::ntp . '.conf';
+my $ntpd = $timezone::ntpd;
+my $ntpfile = $timezone::ntp_conf;
my $my_win = ugtk3->new(N("Date, Clock & Time Zone Settings"));
@@ -117,7 +117,7 @@ $my_win->{window}->add(
err_dialog(N("Error"), N("Please enter a valid NTP server address."));
return;
}
- timezone::set_ntp_server($choosed_serv);
+ timezone::set_ntp_pool($choosed_serv);
system('systemctl', 'enable', "$ntpd.service");
system('systemctl', 'stop', "$ntpd.service");
#verify that we have a valid hostname (thx sam)
@@ -180,7 +180,7 @@ $time_box->set_direction('ltr');
my $servers = get_server();
$combo_ntpserver->set_popdown_strings(@$servers);
if (-e $ntpfile && is_ntp_daemon_running()) {
- $ntp = timezone::ntp_server();
+ $ntp = timezone::ntp_pool();
$ntp and ntp_widget_state(1);
my $fullntp = $ntp;
my $short_ntp = $ntp;
diff --git a/perl-install/timezone.pm b/perl-install/timezone.pm
index cfbaf98a1..1f4bbb419 100644
--- a/perl-install/timezone.pm
+++ b/perl-install/timezone.pm
@@ -26,44 +26,32 @@ sub read() {
{ timezone => $t{ZONE}, UTC => text2bool($t{UTC}) };
}
-our $ntp = "ntp";
-my $servername_config_suffix = "";
-unless (-f $::prefix . "/etc/" . $ntp . ".conf") {
- $ntp = "chrony";
- $servername_config_suffix = " iburst";
+our $ntpd = 'chronyd';
+our $ntp_conf = '/etc/chrony.conf';
+unless (-f "$::prefix$ntp_conf") {
+ $ntpd = 'ntpd';
+ $ntp_conf = '/etc/ntp.d/use-pool'
}
-sub ntp_server() {
- find { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($::prefix . "/etc/" . $ntp . ".conf");
+sub ntp_pool() {
+ find { $_ ne '' } map { (/^\s*pool\s+(\S*)/, $1) } cat_("$::prefix$ntp_conf");
}
-sub set_ntp_server {
- my ($server) = @_;
- my $f = $::prefix . "/etc/" . $ntp . ".conf";
+sub set_ntp_pool {
+ my ($pool) = @_;
+ my $f = "$::prefix$ntp_conf";
-f $f or return;
- my $pool_match = qr/\.pool\.ntp\.org$/;
- my @servers = $server =~ $pool_match ? (map { "$_.$server" } 0 .. 2) : $server;
-
- my $added = 0;
- substInFile {
- if (/^#?\s*server\s+(\S*)/ && $1 ne '127.127.1.0') {
- $_ = $added ? $_ =~ $pool_match ? undef : "#server $1\n" : join('', map { "server $_$servername_config_suffix\n" } @servers);
- $added = 1;
- }
- } $f;
- if ($ntp eq "ntp") {
- output_p("$::prefix/etc/ntp/step-tickers", join('', map { "$_\n" } @servers));
- }
+ substInFile { s/^#?\s*pool\s+.*/pool $pool iburst/ } $f if $pool;
require services;
- services::set_status($ntp . 'd', to_bool($server), $::isInstall);
+ services::set_status($ntpd, to_bool($pool), $::isInstall);
}
sub write {
my ($t) = @_;
- set_ntp_server($t->{ntp});
+ set_ntp_pool($t->{ntp});
my $tz_prefix = get_timezone_prefix(1);
eval { symlinkf($tz_prefix . '/' . $t->{timezone}, "$::prefix/etc/localtime") };