Skip to content

Commit 2dd4648

Browse files
committed
overlay coreos-base/misc-files: Add net-misc/ntp customizations
These are following things: - adding notrap to restrict option in ntp.conf - setting Flatcar-specific NTP servers in ntp.conf - setting Restart=always for ntpd.service - setting up environment for sntp and ntpdate
1 parent 980c627 commit 2dd4648

File tree

4 files changed

+110
-6
lines changed

4 files changed

+110
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Service]
2+
Environment="SERVER=0.flatcar.pool.ntp.org 1.flatcar.pool.ntp.org 2.flatcar.pool.ntp.org 3.flatcar.pool.ntp.org"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# NOTES:
2+
# DHCP clients can append or replace NTP configuration files.
3+
# You should consult your DHCP client documentation about its
4+
# default behaviour and how to change it.
5+
6+
# Name of the servers ntpd should sync with
7+
# Please respect the access policy as stated by the responsible person.
8+
#server ntp.example.tld iburst
9+
10+
# Common pool for random people
11+
#server pool.ntp.org
12+
13+
# Pools for Flatcar users
14+
server 0.flatcar.pool.ntp.org
15+
server 1.flatcar.pool.ntp.org
16+
server 2.flatcar.pool.ntp.org
17+
server 3.flatcar.pool.ntp.org
18+
19+
##
20+
# A list of available servers can be found here:
21+
# http://www.pool.ntp.org/
22+
# http://www.pool.ntp.org/#use
23+
# A good way to get servers for your machine is:
24+
# netselect -s 3 pool.ntp.org
25+
##
26+
27+
# you should not need to modify the following paths
28+
driftfile /var/lib/ntp/ntp.drift
29+
30+
#server ntplocal.example.com prefer
31+
#server timeserver.example.org
32+
33+
# Warning: Using default NTP settings will leave your NTP
34+
# server accessible to all hosts on the Internet.
35+
36+
# If you want to deny all machines (including your own)
37+
# from accessing the NTP server, uncomment:
38+
#restrict default ignore
39+
40+
41+
# Default configuration:
42+
# - Allow only time queries, at a limited rate, sending KoD when in excess.
43+
# - Allow all local queries (IPv4, IPv6)
44+
# From commit da515112395ea7ce0da7cba7103de65d53fc93c9:
45+
#
46+
# net-misc/ntp: add notrap to default restrict config
47+
#
48+
# It's a common security hardening option and doesn't seem likely to
49+
# affect any actual usage.
50+
restrict default nomodify nopeer noquery notrap limited kod
51+
restrict 127.0.0.1
52+
restrict [::1]
53+
54+
55+
# To allow machines within your network to synchronize
56+
# their clocks with your server, but ensure they are
57+
# not allowed to configure the server or used as peers
58+
# to synchronize against, uncomment this line.
59+
#
60+
#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Service]
2+
# From commit 5e5abb4d7ea48a9238b9baa22941fda6a6bbda8c:
3+
#
4+
# ntpd: always restart, required to handle large time jumps.
5+
#
6+
# Some VM platforms suspend machines by simply stopping them instead of
7+
# gracefully suspending them like real hardware would. This means that
8+
# when the system is resumed the kernel's time will be completely wrong
9+
# and it doesn't have a way to fix it. Additionally ntp will abort if the
10+
# clock offset is greater than 1000 seconds (conveniently without logging
11+
# any error messages). We can tune that in ntp.conf but ntpd has so many
12+
# knobs related to how it skews the clock and other update strategies that
13+
# the easiest option is to just restart.
14+
Restart=always

sdk_container/src/third_party/coreos-overlay/coreos-base/misc-files/misc-files-0-r2.ebuild renamed to sdk_container/src/third_party/coreos-overlay/coreos-base/misc-files/misc-files-0-r3.ebuild

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ HOMEPAGE='https://www.flatcar.org/'
1212
LICENSE='Apache-2.0'
1313
SLOT='0'
1414
KEYWORDS='amd64 arm64'
15-
IUSE="openssh"
15+
IUSE="openssh ntp"
1616

1717
# No source directory.
1818
S="${WORKDIR}"
@@ -31,6 +31,7 @@ DEPEND="
3131
RDEPEND="
3232
${DEPEND}
3333
>=app-shells/bash-5.2_p15-r2
34+
ntp? ( >=net-misc/ntp-4.2.8_p17 )
3435
"
3536

3637
declare -A CORE_BASH_SYMLINKS
@@ -57,6 +58,24 @@ src_compile() {
5758
LC_ALL=C sort "${config_tmp}" >"${config}"
5859
}
5960

61+
misc_files_install_dropin() {
62+
local unit conf
63+
unit=${1}; shift
64+
conf=${1}; shift
65+
66+
[[ -n ${unit} ]] || die "No unit specified"
67+
[[ -n ${conf} ]] || die "No conf file specified"
68+
[[ ${conf} = *.conf ]] || die "Conf file must have .conf suffix"
69+
70+
local override_dir
71+
override_dir="$(systemd_get_systemunitdir)/${unit}.d"
72+
(
73+
insopts -m 0644
74+
insinto "${override_dir}"
75+
doins "${conf}"
76+
)
77+
}
78+
6079
src_install() {
6180
# Use absolute paths to be clear about what locations are used. The
6281
# dosym below will make relative paths out of them.
@@ -85,6 +104,11 @@ src_install() {
85104
['/usr/share/ssh/sshd_config']='/usr/share/flatcar/etc/ssh/sshd_config.d/50-flatcar-sshd.conf'
86105
)
87106
fi
107+
if use ntp; then
108+
compat_symlinks+=(
109+
['/usr/share/ntp/ntp.conf']='/usr/share/flatcar/etc/ntp.conf'
110+
)
111+
fi
88112

89113
local link target
90114
for link in "${!compat_symlinks[@]}"; do
@@ -133,16 +157,20 @@ src_install() {
133157

134158
# Install our socket drop-in file that disables the rate
135159
# limiting on the sshd socket.
136-
local override_dir
137-
override_dir="$(systemd_get_systemunitdir)/sshd.socket.d"
138-
dodir "${override_dir}"
139-
insinto "${override_dir}"
140-
doins "${FILESDIR}/no-trigger-limit-burst.conf"
160+
misc_files_install_dropin sshd.socket "${FILESDIR}/no-trigger-limit-burst.conf"
141161

142162
# Enable some sockets that aren't enabled by their own ebuilds.
143163
systemd_enable_service sockets.target sshd.socket
144164
fi
145165

166+
if use ntp; then
167+
insinto /etc
168+
doins "${FILESDIR}/ntp.conf"
169+
misc_files_install_dropin ntpd.service "${FILESDIR}/ntpd-always-restart.conf"
170+
misc_files_install_dropin ntpdate.service "${FILESDIR}/ntp-environment.conf"
171+
misc_files_install_dropin sntp.service "${FILESDIR}/ntp-environment.conf"
172+
fi
173+
146174
# Create a symlink for Kubernetes to redirect writes from /usr/libexec/... to /var/kubernetes/...
147175
# (The below keepdir will result in a tmpfiles entry in base_image_var.conf)
148176
keepdir /var/kubernetes/kubelet-plugins/volume/exec

0 commit comments

Comments
 (0)