Project

General

Profile

Feature #8794 » system.inc.ntp-auth.23.01.patch

Adds support for $ntp_key in function system_ntp_configure() - LamaZ ., 03/03/2023 03:00 PM

View differences:

/etc/inc/system.inc 2023-02-20 20:05:49.538823000 -0500
$driftfile = "/var/db/ntpd.drift";
$statsdir = "/var/log/ntp";
$gps_device = '/dev/gps0';
$ntp_key = "1";
safe_mkdir($statsdir);
......
/* set NTP server authentication key */
if (config_get_path('ntpd/serverauth') == 'yes') {
$ntpkeyscfg = "1 " . strtoupper(config_get_path('ntpd/serverauthalgo')) . " " . base64_decode(config_get_path('ntpd/serverauthkey')) . "\n";
$ntp_key = "12345";
$ntpkeyscfg = $ntp_key . " " . strtoupper(config_get_path('ntpd/serverauthalgo')) . " " . base64_decode(config_get_path('ntpd/serverauthkey')) . "\n";
if (!@file_put_contents("{$g['varetc_path']}/ntp.keys", $ntpkeyscfg)) {
log_error(sprintf(gettext("Could not open %s/ntp.keys for writing"), g_get('varetc_path')));
return;
......
if (config_get_path('ntpd/serverauth') == 'yes') {
$ntpcfg .= "# Authentication settings \n";
$ntpcfg .= "keys /var/etc/ntp.keys \n";
$ntpcfg .= "trustedkey 1 \n";
$ntpcfg .= "requestkey 1 \n";
$ntpcfg .= "controlkey 1 \n";
$ntpcfg .= "trustedkey " . $ntp_key . " \n";
$ntpcfg .= "requestkey " . $ntp_key . " \n";
$ntpcfg .= "controlkey " . $ntp_key . " \n";
$ntpcfg .= "\n";
}
......
}
if (substr_count(config_get_path('ntpd/noselect'), $ts)) {
$ntpcfg .= ' noselect';
}
if (config_get_path('ntpd/serverauth') == 'yes') {
$ntpcfg .= " key " . $ntp_key . " ";
}
$ntpcfg .= "\n";
}
(3-3/8)