update chrony to 4.1
This commit is contained in:
parent
74f1210e73
commit
f49118ad01
@ -1,207 +0,0 @@
|
||||
From f00fed20092b6a42283f29c6ee1f58244d74b545 Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Thu, 6 Aug 2020 09:31:11 +0200
|
||||
Subject: [PATCH] main: create new file when writing pidfile
|
||||
|
||||
When writing the pidfile, open the file with the O_CREAT|O_EXCL flags
|
||||
to avoid following a symlink and writing the PID to an unexpected file,
|
||||
when chronyd still has the root privileges.
|
||||
|
||||
The Linux open(2) man page warns about O_EXCL not working as expected on
|
||||
NFS versions before 3 and Linux versions before 2.6. Saving pidfiles on
|
||||
a distributed filesystem like NFS is not generally expected, but if
|
||||
there is a reason to do that, these old kernel and NFS versions are not
|
||||
considered to be supported for saving files by chronyd.
|
||||
|
||||
This is a minimal backport specific to this issue of the following
|
||||
commits:
|
||||
- commit 2fc8edacb810 ("use PATH_MAX")
|
||||
- commit f4c6a00b2a11 ("logging: call exit() in LOG_Message()")
|
||||
- commit 7a4c396bba8f ("util: add functions for common file operations")
|
||||
- commit e18903a6b563 ("switch to new util file functions")
|
||||
|
||||
Reported-by: Matthias Gerstner <mgerstner@suse.de>
|
||||
---
|
||||
logging.c | 1 +
|
||||
main.c | 10 ++-----
|
||||
sysincl.h | 1 +
|
||||
util.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
util.h | 11 ++++++++
|
||||
5 files changed, 111 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/logging.c b/logging.c
|
||||
index d2296e0..fd7f900 100644
|
||||
--- a/logging.c
|
||||
+++ b/logging.c
|
||||
@@ -171,6 +171,7 @@ void LOG_Message(LOG_Severity severity,
|
||||
system_log = 0;
|
||||
log_message(1, severity, buf);
|
||||
}
|
||||
+ exit(1);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
diff --git a/main.c b/main.c
|
||||
index 6ccf32e..8edb2e1 100644
|
||||
--- a/main.c
|
||||
+++ b/main.c
|
||||
@@ -281,13 +281,9 @@ write_pidfile(void)
|
||||
if (!pidfile[0])
|
||||
return;
|
||||
|
||||
- out = fopen(pidfile, "w");
|
||||
- if (!out) {
|
||||
- LOG_FATAL("Could not open %s : %s", pidfile, strerror(errno));
|
||||
- } else {
|
||||
- fprintf(out, "%d\n", (int)getpid());
|
||||
- fclose(out);
|
||||
- }
|
||||
+ out = UTI_OpenFile(NULL, pidfile, NULL, 'W', 0644);
|
||||
+ fprintf(out, "%d\n", (int)getpid());
|
||||
+ fclose(out);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
diff --git a/sysincl.h b/sysincl.h
|
||||
index 296c5e6..873a3bd 100644
|
||||
--- a/sysincl.h
|
||||
+++ b/sysincl.h
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <glob.h>
|
||||
#include <grp.h>
|
||||
#include <inttypes.h>
|
||||
+#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <netinet/in.h>
|
||||
#include <pwd.h>
|
||||
diff --git a/util.c b/util.c
|
||||
index e7e3442..83b3b20 100644
|
||||
--- a/util.c
|
||||
+++ b/util.c
|
||||
@@ -1179,6 +1179,101 @@ UTI_CheckDirPermissions(const char *path, mode_t perm, uid_t uid, gid_t gid)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
+static int
|
||||
+join_path(const char *basedir, const char *name, const char *suffix,
|
||||
+ char *buffer, size_t length, LOG_Severity severity)
|
||||
+{
|
||||
+ const char *sep;
|
||||
+
|
||||
+ if (!basedir) {
|
||||
+ basedir = "";
|
||||
+ sep = "";
|
||||
+ } else {
|
||||
+ sep = "/";
|
||||
+ }
|
||||
+
|
||||
+ if (!suffix)
|
||||
+ suffix = "";
|
||||
+
|
||||
+ if (snprintf(buffer, length, "%s%s%s%s", basedir, sep, name, suffix) >= length) {
|
||||
+ LOG(severity, "File path %s%s%s%s too long", basedir, sep, name, suffix);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+/* ================================================== */
|
||||
+
|
||||
+FILE *
|
||||
+UTI_OpenFile(const char *basedir, const char *name, const char *suffix,
|
||||
+ char mode, mode_t perm)
|
||||
+{
|
||||
+ const char *file_mode;
|
||||
+ char path[PATH_MAX];
|
||||
+ LOG_Severity severity;
|
||||
+ int fd, flags;
|
||||
+ FILE *file;
|
||||
+
|
||||
+ severity = mode >= 'A' && mode <= 'Z' ? LOGS_FATAL : LOGS_ERR;
|
||||
+
|
||||
+ if (!join_path(basedir, name, suffix, path, sizeof (path), severity))
|
||||
+ return NULL;
|
||||
+
|
||||
+ switch (mode) {
|
||||
+ case 'r':
|
||||
+ case 'R':
|
||||
+ flags = O_RDONLY;
|
||||
+ file_mode = "r";
|
||||
+ if (severity != LOGS_FATAL)
|
||||
+ severity = LOGS_DEBUG;
|
||||
+ break;
|
||||
+ case 'w':
|
||||
+ case 'W':
|
||||
+ flags = O_WRONLY | O_CREAT | O_EXCL;
|
||||
+ file_mode = "w";
|
||||
+ break;
|
||||
+ case 'a':
|
||||
+ case 'A':
|
||||
+ flags = O_WRONLY | O_CREAT | O_APPEND;
|
||||
+ file_mode = "a";
|
||||
+ break;
|
||||
+ default:
|
||||
+ assert(0);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+try_again:
|
||||
+ fd = open(path, flags, perm);
|
||||
+ if (fd < 0) {
|
||||
+ if (errno == EEXIST) {
|
||||
+ if (unlink(path) < 0) {
|
||||
+ LOG(severity, "Could not remove %s : %s", path, strerror(errno));
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ DEBUG_LOG("Removed %s", path);
|
||||
+ goto try_again;
|
||||
+ }
|
||||
+ LOG(severity, "Could not open %s : %s", path, strerror(errno));
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ UTI_FdSetCloexec(fd);
|
||||
+
|
||||
+ file = fdopen(fd, file_mode);
|
||||
+ if (!file) {
|
||||
+ LOG(severity, "Could not open %s : %s", path, strerror(errno));
|
||||
+ close(fd);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ DEBUG_LOG("Opened %s fd=%d mode=%c", path, fd, mode);
|
||||
+
|
||||
+ return file;
|
||||
+}
|
||||
+
|
||||
+/* ================================================== */
|
||||
+
|
||||
void
|
||||
UTI_DropRoot(uid_t uid, gid_t gid)
|
||||
{
|
||||
diff --git a/util.h b/util.h
|
||||
index e3d6767..a2481cc 100644
|
||||
--- a/util.h
|
||||
+++ b/util.h
|
||||
@@ -176,6 +176,17 @@ extern int UTI_CreateDirAndParents(const char *path, mode_t mode, uid_t uid, gid
|
||||
permissions and its uid/gid must match the specified values. */
|
||||
extern int UTI_CheckDirPermissions(const char *path, mode_t perm, uid_t uid, gid_t gid);
|
||||
|
||||
+/* Open a file. The full path of the file is constructed from the basedir
|
||||
+ (may be NULL), '/' (if basedir is not NULL), name, and suffix (may be NULL).
|
||||
+ Created files have specified permissions (umasked). Returns NULL on error.
|
||||
+ The following modes are supported (if the mode is an uppercase character,
|
||||
+ errors are fatal):
|
||||
+ r/R - open an existing file for reading
|
||||
+ w/W - open a new file for writing (remove existing file)
|
||||
+ a/A - open an existing file for appending (create if does not exist) */
|
||||
+extern FILE *UTI_OpenFile(const char *basedir, const char *name, const char *suffix,
|
||||
+ char mode, mode_t perm);
|
||||
+
|
||||
/* Set process user/group IDs and drop supplementary groups */
|
||||
extern void UTI_DropRoot(uid_t uid, gid_t gid);
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
Binary file not shown.
BIN
chrony-4.1.tar.gz
Normal file
BIN
chrony-4.1.tar.gz
Normal file
Binary file not shown.
@ -1,8 +0,0 @@
|
||||
[Unit]
|
||||
Description=DNS SRV lookup of %I for chrony
|
||||
After=chronyd.service network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/libexec/chrony-helper update-dnssrv-servers %I
|
||||
@ -1,9 +0,0 @@
|
||||
[Unit]
|
||||
Description=Periodic DNS SRV lookup of %I for chrony
|
||||
|
||||
[Timer]
|
||||
OnActiveSec=0
|
||||
OnUnitInactiveSec=1h
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
43
chrony-nm-dispatcher-dhcp.patch
Normal file
43
chrony-nm-dispatcher-dhcp.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From: Robert Fairley <rfairley@redhat.com>
|
||||
Date: Wed, 17 Jun 2020 10:14:19 -0400
|
||||
Subject: [PATCH] examples/nm-dispatcher.dhcp: use sysconfig
|
||||
|
||||
Use the PEERNTP and NTPSERVERARGS environment variables from
|
||||
/etc/sysconfig/network{-scripts}.
|
||||
|
||||
Co-Authored-By: Christian Glombek <cglombek@redhat.com>
|
||||
|
||||
diff --git a/examples/chrony.nm-dispatcher.dhcp b/examples/chrony.nm-dispatcher.dhcp
|
||||
index 6ea4c37..a6ad35a 100644
|
||||
--- a/examples/chrony.nm-dispatcher.dhcp
|
||||
+++ b/examples/chrony.nm-dispatcher.dhcp
|
||||
@@ -6,16 +6,24 @@
|
||||
|
||||
chronyc=/usr/bin/chronyc
|
||||
default_server_options=iburst
|
||||
-server_dir=/var/run/chrony-dhcp
|
||||
+server_dir=/run/chrony-dhcp
|
||||
|
||||
dhcp_server_file=$server_dir/$interface.sources
|
||||
# DHCP4_NTP_SERVERS is passed from DHCP options by NetworkManager.
|
||||
nm_dhcp_servers=$DHCP4_NTP_SERVERS
|
||||
|
||||
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
|
||||
+[ -f /etc/sysconfig/network-scripts/ifcfg-"${interface}" ] && \
|
||||
+ . /etc/sysconfig/network-scripts/ifcfg-"${interface}"
|
||||
+
|
||||
add_servers_from_dhcp() {
|
||||
rm -f "$dhcp_server_file"
|
||||
+
|
||||
+ # Don't add NTP servers if PEERNTP=no specified; return early.
|
||||
+ [ "$PEERNTP" = "no" ] && return
|
||||
+
|
||||
for server in $nm_dhcp_servers; do
|
||||
- echo "server $server $default_server_options" >> "$dhcp_server_file"
|
||||
+ echo "server $server ${NTPSERVERARGS:-$default_server_options}" >> "$dhcp_server_file"
|
||||
done
|
||||
$chronyc reload sources > /dev/null 2>&1 || :
|
||||
}
|
||||
--
|
||||
2.29.2
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
commit 62d6aed6a64b887c9e3b7f03d9e0db1deaa2696a
|
||||
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Tue Jun 18 15:41:50 2019 +0200
|
||||
|
||||
test: update processing of packet log
|
||||
|
||||
Two new fields have been added to the packet log, which broke some
|
||||
of the simulation tests.
|
||||
|
||||
diff --git a/test/simulation/test.common b/test/simulation/test.common
|
||||
index 951a794b..8ed6ad9e 100644
|
||||
--- a/test/simulation/test.common
|
||||
+++ b/test/simulation/test.common
|
||||
@@ -391,9 +391,9 @@ check_packet_port() {
|
||||
for i in $(seq 1 $(get_chronyd_nodes)); do
|
||||
test_message 3 0 "node $i:"
|
||||
|
||||
- grep -E -q " $port [0-9]+\$" tmp/log.packets && \
|
||||
+ grep -E -q "^([0-9e.+-]+ ){5}$port " tmp/log.packets && \
|
||||
! grep -E "^[0-9e.+-]+ $i " tmp/log.packets | \
|
||||
- grep -E -q -v " $port [0-9]+\$" && \
|
||||
+ grep -E -q -v "^([0-9e.+-]+ ){5}$port " && \
|
||||
test_ok || test_bad
|
||||
[ $? -eq 0 ] || ret=1
|
||||
done
|
||||
@ -1,11 +0,0 @@
|
||||
diff -Nur chrony-3.5.bck/examples/chronyd.service chrony-3.5/examples/chronyd.service
|
||||
--- chrony-3.5.bck/examples/chronyd.service 2020-06-23 15:41:07.789042822 +0800
|
||||
+++ chrony-3.5/examples/chronyd.service 2020-06-23 15:42:09.489819150 +0800
|
||||
@@ -10,6 +10,7 @@
|
||||
PIDFile=/run/chrony/chronyd.pid
|
||||
EnvironmentFile=-/etc/sysconfig/chronyd
|
||||
ExecStart=/usr/sbin/chronyd $OPTIONS
|
||||
+ExecStartPost=/usr/libexec/chrony-helper update-daemon
|
||||
PrivateTmp=yes
|
||||
ProtectHome=yes
|
||||
ProtectSystem=full
|
||||
@ -1,20 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
SERVERFILE=$SAVEDIR/chrony.servers.$interface
|
||||
CHRONY_SOURCEDIR=/run/chrony-dhcp
|
||||
SERVERFILE=$CHRONY_SOURCEDIR/$interface.sources
|
||||
|
||||
chrony_config() {
|
||||
rm -f $SERVERFILE
|
||||
# Disable modifications if called from a NM dispatcher script
|
||||
[ -n "$NM_DISPATCHER_ACTION" ] && return 0
|
||||
|
||||
rm -f "$SERVERFILE"
|
||||
if [ "$PEERNTP" != "no" ]; then
|
||||
mkdir -p $CHRONY_SOURCEDIR
|
||||
for server in $new_ntp_servers; do
|
||||
echo "$server ${NTPSERVERARGS:-iburst}" >> $SERVERFILE
|
||||
echo "server $server ${NTPSERVERARGS:-iburst}" >> "$SERVERFILE"
|
||||
done
|
||||
/usr/libexec/chrony-helper update-daemon || :
|
||||
/usr/bin/chronyc reload sources > /dev/null 2>&1 || :
|
||||
fi
|
||||
}
|
||||
|
||||
chrony_restore() {
|
||||
if [ -f $SERVERFILE ]; then
|
||||
rm -f $SERVERFILE
|
||||
/usr/libexec/chrony-helper update-daemon || :
|
||||
[ -n "$NM_DISPATCHER_ACTION" ] && return 0
|
||||
|
||||
if [ -f "$SERVERFILE" ]; then
|
||||
rm -f "$SERVERFILE"
|
||||
/usr/bin/chronyc reload sources > /dev/null 2>&1 || :
|
||||
fi
|
||||
}
|
||||
|
||||
252
chrony.helper
252
chrony.helper
@ -1,252 +0,0 @@
|
||||
#!/bin/bash
|
||||
# This script configures running chronyd to use NTP servers obtained from
|
||||
# DHCP and _ntp._udp DNS SRV records. Files with servers from DHCP are managed
|
||||
# externally (e.g. by a dhclient script). Files with servers from DNS SRV
|
||||
# records are updated here using the dig utility. The script can also list
|
||||
# and set static sources in the chronyd configuration file.
|
||||
|
||||
chronyc=/usr/bin/chronyc
|
||||
chrony_conf=/etc/chrony.conf
|
||||
chrony_service=chronyd.service
|
||||
helper_dir=/var/run/chrony-helper
|
||||
added_servers_file=$helper_dir/added_servers
|
||||
|
||||
network_sysconfig_file=/etc/sysconfig/network
|
||||
dhclient_servers_files=/var/lib/dhclient/chrony.servers.*
|
||||
dnssrv_servers_files=$helper_dir/dnssrv@*
|
||||
dnssrv_timer_prefix=chrony-dnssrv@
|
||||
|
||||
. $network_sysconfig_file &> /dev/null
|
||||
|
||||
chrony_command() {
|
||||
$chronyc -a -n -m "$1"
|
||||
}
|
||||
|
||||
is_running() {
|
||||
chrony_command "tracking" &> /dev/null
|
||||
}
|
||||
|
||||
get_servers_files() {
|
||||
[ "$PEERNTP" != "no" ] && echo "$dhclient_servers_files"
|
||||
echo "$dnssrv_servers_files"
|
||||
}
|
||||
|
||||
is_update_needed() {
|
||||
for file in $(get_servers_files) $added_servers_file; do
|
||||
[ -e "$file" ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
update_daemon() {
|
||||
local all_servers_with_args all_servers added_servers
|
||||
|
||||
if ! is_running; then
|
||||
rm -f $added_servers_file
|
||||
return 0
|
||||
fi
|
||||
|
||||
all_servers_with_args=$(cat $(get_servers_files) 2> /dev/null)
|
||||
|
||||
all_servers=$(
|
||||
echo "$all_servers_with_args" |
|
||||
while read server serverargs; do
|
||||
echo "$server"
|
||||
done | sort -u)
|
||||
added_servers=$( (
|
||||
cat $added_servers_file 2> /dev/null
|
||||
echo "$all_servers_with_args" |
|
||||
while read server serverargs; do
|
||||
[ -z "$server" ] && continue
|
||||
chrony_command "add server $server $serverargs" &> /dev/null &&
|
||||
echo "$server"
|
||||
done) | sort -u)
|
||||
|
||||
comm -23 <(echo -n "$added_servers") <(echo -n "$all_servers") |
|
||||
while read server; do
|
||||
chrony_command "delete $server" &> /dev/null
|
||||
done
|
||||
|
||||
added_servers=$(comm -12 <(echo -n "$added_servers") <(echo -n "$all_servers"))
|
||||
|
||||
[ -n "$added_servers" ] && echo "$added_servers" > $added_servers_file ||
|
||||
rm -f $added_servers_file
|
||||
}
|
||||
|
||||
get_dnssrv_servers() {
|
||||
local name=$1 output
|
||||
|
||||
if ! command -v dig &> /dev/null; then
|
||||
echo "Missing dig (DNS lookup utility)" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
output=$(dig "$name" srv +short +ndots=2 +search 2> /dev/null)
|
||||
[ $? -ne 0 ] && return 0
|
||||
|
||||
echo "$output" | while read prio weight port target; do
|
||||
server=${target%.}
|
||||
[ -z "$server" ] && continue
|
||||
echo "$server port $port ${NTPSERVERARGS:-iburst}"
|
||||
done
|
||||
}
|
||||
|
||||
check_dnssrv_name() {
|
||||
local name=$1
|
||||
|
||||
if [ -z "$name" ]; then
|
||||
echo "No DNS SRV name specified" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "${name:0:9}" != _ntp._udp ]; then
|
||||
echo "DNS SRV name $name doesn't start with _ntp._udp" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
update_dnssrv_servers() {
|
||||
local name=$1
|
||||
local srv_file=$helper_dir/dnssrv@$name servers
|
||||
|
||||
check_dnssrv_name "$name" || return 1
|
||||
|
||||
servers=$(get_dnssrv_servers "$name")
|
||||
[ -n "$servers" ] && echo "$servers" > "$srv_file" || rm -f "$srv_file"
|
||||
}
|
||||
|
||||
set_dnssrv_timer() {
|
||||
local state=$1 name=$2
|
||||
local srv_file=$helper_dir/dnssrv@$name servers
|
||||
local timer=$dnssrv_timer_prefix$(systemd-escape "$name").timer
|
||||
|
||||
check_dnssrv_name "$name" || return 1
|
||||
|
||||
if [ "$state" = enable ]; then
|
||||
systemctl enable "$timer"
|
||||
systemctl start "$timer"
|
||||
elif [ "$state" = disable ]; then
|
||||
systemctl stop "$timer"
|
||||
systemctl disable "$timer"
|
||||
rm -f "$srv_file"
|
||||
fi
|
||||
}
|
||||
|
||||
list_dnssrv_timers() {
|
||||
systemctl --all --full -t timer list-units | grep "^$dnssrv_timer_prefix" | \
|
||||
sed "s|^$dnssrv_timer_prefix\(.*\)\.timer.*|\1|" |
|
||||
while read -r name; do
|
||||
systemd-escape --unescape "$name"
|
||||
done
|
||||
}
|
||||
|
||||
prepare_helper_dir() {
|
||||
mkdir -p $helper_dir
|
||||
exec 100> $helper_dir/lock
|
||||
if ! flock -w 20 100; then
|
||||
echo "Failed to lock $helper_dir" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_source_line() {
|
||||
local pattern="^[ \t]*(server|pool|peer|refclock)[ \t]+[^ \t]+"
|
||||
[[ "$1" =~ $pattern ]]
|
||||
}
|
||||
|
||||
list_static_sources() {
|
||||
while read line; do
|
||||
is_source_line "$line" && echo "$line" || :
|
||||
done < $chrony_conf
|
||||
}
|
||||
|
||||
set_static_sources() {
|
||||
local new_config tmp_conf
|
||||
|
||||
new_config=$(
|
||||
sources=$(
|
||||
while read line; do
|
||||
is_source_line "$line" && echo "$line"
|
||||
done)
|
||||
|
||||
while read line; do
|
||||
if ! is_source_line "$line"; then
|
||||
echo "$line"
|
||||
continue
|
||||
fi
|
||||
|
||||
tmp_sources=$(
|
||||
local removed=0
|
||||
|
||||
echo "$sources" | while read line2; do
|
||||
[ "$removed" -ne 0 -o "$line" != "$line2" ] && \
|
||||
echo "$line2" || removed=1
|
||||
done)
|
||||
|
||||
[ "$sources" == "$tmp_sources" ] && continue
|
||||
sources=$tmp_sources
|
||||
echo "$line"
|
||||
done < $chrony_conf
|
||||
|
||||
echo "$sources"
|
||||
)
|
||||
|
||||
tmp_conf=${chrony_conf}.tmp
|
||||
|
||||
cp -a $chrony_conf $tmp_conf &&
|
||||
echo "$new_config" > $tmp_conf &&
|
||||
mv $tmp_conf $chrony_conf || return 1
|
||||
|
||||
systemctl try-restart $chrony_service
|
||||
}
|
||||
|
||||
print_help() {
|
||||
echo "Usage: $0 COMMAND"
|
||||
echo
|
||||
echo "Commands:"
|
||||
echo " update-daemon"
|
||||
echo " update-dnssrv-servers NAME"
|
||||
echo " enable-dnssrv NAME"
|
||||
echo " disable-dnssrv NAME"
|
||||
echo " list-dnssrv"
|
||||
echo " list-static-sources"
|
||||
echo " set-static-sources < sources.list"
|
||||
echo " is-running"
|
||||
echo " command CHRONYC-COMMAND"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
update-daemon|add-dhclient-servers|remove-dhclient-servers)
|
||||
is_update_needed || exit 0
|
||||
prepare_helper_dir && update_daemon
|
||||
;;
|
||||
update-dnssrv-servers)
|
||||
prepare_helper_dir && update_dnssrv_servers "$2" && update_daemon
|
||||
;;
|
||||
enable-dnssrv)
|
||||
set_dnssrv_timer enable "$2"
|
||||
;;
|
||||
disable-dnssrv)
|
||||
set_dnssrv_timer disable "$2" && prepare_helper_dir && update_daemon
|
||||
;;
|
||||
list-dnssrv)
|
||||
list_dnssrv_timers
|
||||
;;
|
||||
list-static-sources)
|
||||
list_static_sources
|
||||
;;
|
||||
set-static-sources)
|
||||
set_static_sources
|
||||
;;
|
||||
is-running)
|
||||
is_running
|
||||
;;
|
||||
command|forced-command)
|
||||
chrony_command "$2"
|
||||
;;
|
||||
*)
|
||||
print_help
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit $?
|
||||
41
chrony.spec
41
chrony.spec
@ -1,22 +1,17 @@
|
||||
%global clknetsim_ver 79ffe4
|
||||
%global clknetsim_ver f89702
|
||||
|
||||
Name: chrony
|
||||
Version: 3.5
|
||||
Release: 3
|
||||
Version: 4.1
|
||||
Release: 1
|
||||
Summary: An NTP client/server
|
||||
License: GPLv2
|
||||
URL: https://chrony.tuxfamily.org
|
||||
Source0: https://download.tuxfamily.org/chrony/chrony-%{version}%{?prerelease}.tar.gz
|
||||
Source1: chrony.dhclient
|
||||
Source2: chrony.helper
|
||||
Source3: chrony-dnssrv@.service
|
||||
Source4: chrony-dnssrv@.timer
|
||||
|
||||
Source6: https://github.com/mlichvar/clknetsim/archive/%{clknetsim_ver}/clknetsim-%{clknetsim_ver}.tar.gz
|
||||
|
||||
Patch0: chrony-service-helper.patch
|
||||
Patch1: chrony-packettest.patch
|
||||
Patch2: 0001-main-create-new-file-when-writing-pidfile.patch
|
||||
Patch1: chrony-nm-dispatcher-dhcp.patch
|
||||
BuildRequires: gcc gcc-c++ bison systemd libcap-devel libedit-devel nettle-devel pps-tools-devel libseccomp-devel
|
||||
|
||||
Requires: shadow-utils systemd timedatex
|
||||
@ -33,9 +28,7 @@ service to other computers in the network.
|
||||
%prep
|
||||
|
||||
%setup -q -n %{name}-%{version} -a 6
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
mv clknetsim-%{clknetsim_ver}* test/simulation/clknetsim
|
||||
|
||||
%build
|
||||
@ -53,7 +46,8 @@ install -m 644 -p examples/chrony.conf.example2 $RPM_BUILD_ROOT%{_sysconfdir}/ch
|
||||
install -m 640 -p examples/chrony.keys.example $RPM_BUILD_ROOT%{_sysconfdir}/chrony.keys
|
||||
|
||||
install -d $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d
|
||||
install -m 755 -p examples/chrony.nm-dispatcher $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony
|
||||
install -m 755 -p examples/chrony.nm-dispatcher.onoffline $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony-onoffline
|
||||
install -m 755 -p examples/chrony.nm-dispatcher.dhcp $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony-dhcp
|
||||
|
||||
install -d $RPM_BUILD_ROOT%{_sysconfdir}/dhcp/dhclient.d
|
||||
install -m 755 -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/dhcp/dhclient.d/chrony.sh
|
||||
@ -66,13 +60,10 @@ OPTIONS=""
|
||||
EOF
|
||||
|
||||
install -d $RPM_BUILD_ROOT%{_libexecdir}
|
||||
install -m 755 -p %{SOURCE2} $RPM_BUILD_ROOT%{_libexecdir}/chrony-helper
|
||||
|
||||
install -d $RPM_BUILD_ROOT%{_unitdir}
|
||||
install -m 644 -p examples/chrony-wait.service $RPM_BUILD_ROOT%{_unitdir}/chrony-wait.service
|
||||
install -m 644 -p examples/chronyd.service $RPM_BUILD_ROOT%{_unitdir}/chronyd.service
|
||||
install -m 644 -p %{SOURCE3} $RPM_BUILD_ROOT%{_unitdir}/chrony-dnssrv@.service
|
||||
install -m 644 -p %{SOURCE4} $RPM_BUILD_ROOT%{_unitdir}/chrony-dnssrv@.timer
|
||||
|
||||
|
||||
install -d $RPM_BUILD_ROOT%{_prefix}/lib/systemd/ntp-units.d
|
||||
@ -100,6 +91,16 @@ fi
|
||||
%systemd_preun chronyd.service chrony-wait.service
|
||||
|
||||
%post
|
||||
# migrate from chrony-helper to sourcedir directive
|
||||
if test -a %{_libexecdir}/chrony-helper; then
|
||||
grep -qi 'sourcedir /run/chrony-dhcp$' %{_sysconfdir}/chrony.conf 2> /dev/null || \
|
||||
echo -e '\n# Use NTP servers from DHCP.\nsourcedir /run/chrony-dhcp' >> \
|
||||
%{_sysconfdir}/chrony.conf
|
||||
mkdir -p /run/chrony-dhcp
|
||||
for f in %{_localstatedir}/lib/dhclient/chrony.servers.*; do
|
||||
sed 's|.*|server &|' < $f > /run/chrony-dhcp/"${f##*servers.}.sources"
|
||||
done 2> /dev/null
|
||||
fi
|
||||
%systemd_post chronyd.service chrony-wait.service
|
||||
|
||||
|
||||
@ -114,15 +115,13 @@ fi
|
||||
%config(noreplace) %verify(not md5 size mtime) %attr(640,root,chrony) %{_sysconfdir}/chrony.keys
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/chrony
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/chronyd
|
||||
%{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony
|
||||
%{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony*
|
||||
%{_sysconfdir}/dhcp/dhclient.d/chrony.sh
|
||||
|
||||
%{_bindir}/chronyc
|
||||
%{_sbindir}/chronyd
|
||||
%{_libexecdir}/chrony-helper
|
||||
%{_prefix}/lib/systemd/ntp-units.d/*.list
|
||||
%{_unitdir}/chrony*.service
|
||||
%{_unitdir}/chrony*.timer
|
||||
|
||||
%dir %attr(-,chrony,chrony) %{_localstatedir}/lib/chrony
|
||||
%ghost %attr(-,chrony,chrony) %{_localstatedir}/lib/chrony/drift
|
||||
@ -136,6 +135,12 @@ fi
|
||||
%{_mandir}/man[158]/%{name}*.[158]*
|
||||
|
||||
%changelog
|
||||
* Fri Jul 09 2021 gaihuiying <gaihuiying1@huawei.com> - 4.1-1
|
||||
- Type:requirement
|
||||
- Id:NA
|
||||
- SUG:NA
|
||||
- DESC:update chrony to 4.1
|
||||
|
||||
* Tue Dec 15 2020 xihaochen <xihaochen@huawei.com> - 3.5-3
|
||||
- Type:requirement
|
||||
- Id:NA
|
||||
|
||||
Binary file not shown.
BIN
clknetsim-f89702.tar.gz
Normal file
BIN
clknetsim-f89702.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user