project-lakitu: update chronyd to v4.1

Upgrade chronyd from v3.1 to v4.1
Remove unnecessary change:
  * Enable chronyd by default
  * Create tmpfiles
since upstream already fixed the issue
  * Use default group/user ntp instead of chrony

BUG=b/176257054
TEST=presbumit
RELEASE_NOTE=update chronyd to v4.1

Change-Id: I51ce7fbfea984c482858457b1f6ac109b22d59c4
Reviewed-on: https://cos-review.googlesource.com/c/cos/overlays/board-overlays/+/19590
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
Reviewed-by: Roy Yang <royyang@google.com>
diff --git a/project-lakitu/net-misc/chrony-config/files/default-chrony.conf b/project-lakitu/net-misc/chrony-config/files/default-chrony.conf
index bca0f5c..e423c2d 100644
--- a/project-lakitu/net-misc/chrony-config/files/default-chrony.conf
+++ b/project-lakitu/net-misc/chrony-config/files/default-chrony.conf
@@ -23,5 +23,5 @@
 # Enable kernel synchronization of the real-time clock (RTC).
 rtcsync
 
-# Switch to user chrony from root
-user chrony
+# Switch to user ntp from root
+user ntp
diff --git a/project-lakitu/net-misc/chrony-config/files/platform_aws-chrony.conf b/project-lakitu/net-misc/chrony-config/files/platform_aws-chrony.conf
index 72f812b..ebe44b4 100644
--- a/project-lakitu/net-misc/chrony-config/files/platform_aws-chrony.conf
+++ b/project-lakitu/net-misc/chrony-config/files/platform_aws-chrony.conf
@@ -23,5 +23,5 @@
 # Enable kernel synchronization of the real-time clock (RTC).
 rtcsync
 
-# Switch to user chrony from root
-user chrony
+# Switch to user ntp from root
+user ntp
diff --git a/project-lakitu/net-misc/chrony-config/files/platform_azure-chrony.conf b/project-lakitu/net-misc/chrony-config/files/platform_azure-chrony.conf
index bca0f5c..e423c2d 100644
--- a/project-lakitu/net-misc/chrony-config/files/platform_azure-chrony.conf
+++ b/project-lakitu/net-misc/chrony-config/files/platform_azure-chrony.conf
@@ -23,5 +23,5 @@
 # Enable kernel synchronization of the real-time clock (RTC).
 rtcsync
 
-# Switch to user chrony from root
-user chrony
+# Switch to user ntp from root
+user ntp
diff --git a/project-lakitu/net-misc/chrony-config/files/platform_gcp-chrony.conf b/project-lakitu/net-misc/chrony-config/files/platform_gcp-chrony.conf
index 6eb39d5..b4d96b8 100644
--- a/project-lakitu/net-misc/chrony-config/files/platform_gcp-chrony.conf
+++ b/project-lakitu/net-misc/chrony-config/files/platform_gcp-chrony.conf
@@ -23,5 +23,5 @@
 # Enable kernel synchronization of the real-time clock (RTC).
 rtcsync
 
-# Switch to user chrony from root
-user chrony
+# Switch to user ntp from root
+user ntp
diff --git a/project-lakitu/net-misc/chrony-config/files/platform_vsphere-chrony.conf b/project-lakitu/net-misc/chrony-config/files/platform_vsphere-chrony.conf
index d9720cf..ad9612a 100644
--- a/project-lakitu/net-misc/chrony-config/files/platform_vsphere-chrony.conf
+++ b/project-lakitu/net-misc/chrony-config/files/platform_vsphere-chrony.conf
@@ -23,5 +23,5 @@
 # Enable kernel synchronization of the real-time clock (RTC).
 rtcsync
 
-# Switch to user chrony from root
-user chrony
+# Switch to user ntp from root
+user ntp
diff --git a/project-lakitu/net-misc/chrony/Manifest b/project-lakitu/net-misc/chrony/Manifest
index 88d0f53..ee8a90b 100644
--- a/project-lakitu/net-misc/chrony/Manifest
+++ b/project-lakitu/net-misc/chrony/Manifest
@@ -1 +1,2 @@
-DIST chrony-3.1.tar.gz 424109 BLAKE2B eb6bc13905a05eab15b00919577cceb4c8c881b4881fbd0e19d966dca86ed6973c31618b1ae56b59cad989144bf59a0206328d50d9eb436fdb058684e74a1661 SHA512 4ba3a75c3634050bb63ba9ee80d9be7a295f44ce4d195a050e4be4738bd7dd807fe37f2289d7ead4a75272bd5ebadbd03c233c67f859e9b68871fca5a6671427
+DIST chrony-4.1.tar.gz 564648 BLAKE2B f9c4b44c521ee592c109b8a3d500b9cb3ea4fbf0d7dce9d8754498ad41ce2ac87c913cf72a38557ce5f28208672163b21b067307f723fd91cc91d71f69e739ef SHA512 5e283d6a56e6852606c681a7c29c5786b102d584178cbd7033ebbc95a8e95533605631363b850a3087cca438a5878db7a317f120aab2fd856487d02fccfbcb1f
+DIST chrony-4.1.tar.gz.asc 833 BLAKE2B 6d800ae436523f61cd713cdd12cf0246db53e732554433d5ef6cf1a437296ee9d0da3b2e9e72d1ccb0e3a6b1ee1227e5d1626bf031b0491670ee0712e17c57ff SHA512 82faf9171d782c18224d2d44b340994b0ddab141e88cc803dea83d0ffbb6468bc51e8b11c8dd9bd327220cae04f7d789b58ab23141a2bdf038ce628f9adeb57a
diff --git a/project-lakitu/net-misc/chrony/chrony-3.1-r8.ebuild b/project-lakitu/net-misc/chrony/chrony-3.1-r8.ebuild
deleted file mode 120000
index ea97899..0000000
--- a/project-lakitu/net-misc/chrony/chrony-3.1-r8.ebuild
+++ /dev/null
@@ -1 +0,0 @@
-chrony-3.1.ebuild
\ No newline at end of file
diff --git a/project-lakitu/net-misc/chrony/chrony-3.1.ebuild b/project-lakitu/net-misc/chrony/chrony-3.1.ebuild
deleted file mode 100644
index c24d118..0000000
--- a/project-lakitu/net-misc/chrony/chrony-3.1.ebuild
+++ /dev/null
@@ -1,129 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-
-inherit eutils systemd toolchain-funcs
-
-DESCRIPTION="NTP client and server programs"
-HOMEPAGE="http://chrony.tuxfamily.org/"
-SRC_URI="http://download.tuxfamily.org/${PN}/${P/_/-}.tar.gz"
-LICENSE="GPL-2"
-SLOT="0"
-
-KEYWORDS="*"
-IUSE="caps +cmdmon html ipv6 libedit +ntp +phc pps readline +refclock +rtc selinux +adns"
-REQUIRED_USE="
-	?? ( libedit readline )
-"
-
-CDEPEND="
-	caps? ( sys-libs/libcap )
-	libedit? ( dev-libs/libedit )
-	readline? ( >=sys-libs/readline-4.1-r4:= )
-"
-DEPEND="
-	${CDEPEND}
-	html? ( dev-ruby/asciidoctor )
-	pps? ( net-misc/pps-tools )
-"
-RDEPEND="
-	${CDEPEND}
-	selinux? ( sec-policy/selinux-chronyd )
-	acct-group/chrony
-	acct-user/chrony
-"
-
-RESTRICT=test
-
-S="${WORKDIR}/${P/_/-}"
-
-src_prepare() {
-	sed -i \
-		-e 's:/etc/chrony\.:/etc/chrony/chrony.:g' \
-		-e 's:/var/run:/run:g' \
-		conf.c doc/*.man.in examples/* || die
-
-	default
-}
-
-src_configure() {
-	tc-export CC
-
-	local CHRONY_EDITLINE
-	# ./configure legend:
-	# --disable-readline : disable line editing entirely
-	# --without-readline : do not use sys-libs/readline (enabled by default)
-	# --without-editline : do not use dev-libs/libedit (enabled by default)
-	if ! use readline && ! use libedit; then
-		CHRONY_EDITLINE='--disable-readline'
-	else
-		CHRONY_EDITLINE+=" $(usex readline '' --without-readline)"
-		CHRONY_EDITLINE+=" $(usex libedit '' --without-editline)"
-	fi
-
-	# not an autotools generated script
-	local CHRONY_CONFIGURE="
-	./configure \
-		$(usex caps '' --disable-linuxcaps) \
-		$(usex cmdmon '' --disable-cmdmon) \
-		$(usex ipv6 '' --disable-ipv6) \
-		$(usex ntp '' --disable-ntp) \
-		$(usex phc '' --disable-phc) \
-		$(usex pps '' --disable-pps) \
-		$(usex rtc '' --disable-rtc) \
-		$(usex refclock '' --disable-refclock) \
-		$(usex adns '' --disable-asyncdns) \
-		${CHRONY_EDITLINE} \
-		${EXTRA_ECONF} \
-		--docdir=/usr/share/doc/${PF} \
-		--chronysockdir=/run/chrony \
-		--mandir=/usr/share/man \
-		--prefix=/usr \
-		--sysconfdir=/etc/chrony \
-		--disable-sechash \
-		--without-nss \
-		--without-tomcrypt
-	"
-
-	# print the ./configure call to aid in future debugging
-	einfo ${CHRONY_CONFIGURE}
-	bash ${CHRONY_CONFIGURE} || die
-}
-
-src_compile() {
-	emake all docs $(usex html '' 'ADOC=true')
-}
-
-src_install() {
-	default
-
-	newinitd "${FILESDIR}"/chronyd.init-r1 chronyd
-	newconfd "${FILESDIR}"/chronyd.conf chronyd
-
-	# Remove the configuration here when update.
-	# Leave each board to do their own configuration.
-	#insinto /etc/${PN}
-	#newins examples/chrony.conf.example1 chrony.conf
-
-	docinto examples
-	dodoc examples/*.example*
-
-	if use html; then
-		docinto html
-		dodoc doc/*.html
-	fi
-	# Those empty directories are not carried to image in ChromeOS.
-	keepdir /var/{lib,log}/chrony
-
-	# tmpfiles stuff to make sure var/lib/chrony installed.
-	insinto /usr/lib/tmpfiles.d
-	newins "${FILESDIR}/tmpfiles.d" "chrony.conf"
-
-	insinto /etc/logrotate.d
-	newins "${FILESDIR}"/chrony-2.4-r1.logrotate chrony
-
-	systemd_newunit "${FILESDIR}"/chronyd.service-r2 chronyd.service
-	systemd_enable_ntpunit 50-chrony chronyd.service
-	systemd_enable_service multi-user.target chronyd.service
-}
diff --git a/project-lakitu/net-misc/chrony/chrony-4.1-r1.ebuild b/project-lakitu/net-misc/chrony/chrony-4.1-r1.ebuild
new file mode 120000
index 0000000..bed8bc5
--- /dev/null
+++ b/project-lakitu/net-misc/chrony/chrony-4.1-r1.ebuild
@@ -0,0 +1 @@
+chrony-4.1.ebuild
\ No newline at end of file
diff --git a/project-lakitu/net-misc/chrony/chrony-4.1.ebuild b/project-lakitu/net-misc/chrony/chrony-4.1.ebuild
new file mode 100644
index 0000000..3e00b6c
--- /dev/null
+++ b/project-lakitu/net-misc/chrony/chrony-4.1.ebuild
@@ -0,0 +1,259 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit systemd tmpfiles toolchain-funcs
+
+DESCRIPTION="NTP client and server programs"
+HOMEPAGE="https://chrony.tuxfamily.org/ https://git.tuxfamily.org/chrony/chrony.git"
+
+if [[ ${PV} == "9999" ]] ; then
+	EGIT_REPO_URI="https://git.tuxfamily.org/chrony/chrony.git"
+	inherit git-r3
+else
+	VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/mlichvar.asc
+	inherit verify-sig
+
+	SRC_URI="https://download.tuxfamily.org/${PN}/${P/_/-}.tar.gz"
+	SRC_URI+=" verify-sig? ( https://download.tuxfamily.org/chrony/${P/_/-}-tar-gz-asc.txt -> ${P/_/-}.tar.gz.asc )"
+
+	if [[ ${PV} != *_pre* ]] ; then
+		KEYWORDS="*"
+	fi
+fi
+
+S="${WORKDIR}/${P/_/-}"
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="+caps +cmdmon debug html ipv6 libedit libtomcrypt +nettle nss +ntp +nts +phc pps +refclock +rtc samba +seccomp +sechash selinux"
+# nettle > nss > libtomcrypt in configure
+REQUIRED_USE="
+	sechash? ( || ( nettle nss libtomcrypt ) )
+	nettle? ( !nss )
+	nss? ( !nettle )
+	libtomcrypt? ( !nettle !nss )
+	!sechash? ( !nss )
+	!sechash? ( !nts? ( !nettle ) )
+"
+
+DEPEND="
+	caps? (
+		acct-group/ntp
+		acct-user/ntp
+		sys-libs/libcap
+	)
+	libedit? ( dev-libs/libedit )
+	!libedit? ( sys-libs/readline:= )
+	nettle? ( dev-libs/nettle:= )
+	nss? ( dev-libs/nss:= )
+	nts? ( net-libs/gnutls:= )
+	pps? ( net-misc/pps-tools )
+	seccomp? ( sys-libs/libseccomp )
+"
+RDEPEND="
+	${DEPEND}
+	selinux? ( sec-policy/selinux-chronyd )
+"
+BDEPEND="
+	html? ( dev-ruby/asciidoctor )
+	nts? ( virtual/pkgconfig )
+	sechash? (
+		nettle? ( virtual/pkgconfig )
+		nss? ( virtual/pkgconfig )
+	)
+"
+
+if [[ ${PV} == "9999" ]] ; then
+	# Needed for doc generation in 9999
+	REQUIRED_USE+=" html"
+	BDEPEND+=" virtual/w3m"
+else
+	BDEPEND+=" verify-sig? ( >=app-crypt/openpgp-keys-mlichvar-20210513 )"
+fi
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-3.5-pool-vendor-gentoo.patch
+	"${FILESDIR}"/${PN}-4.1-systemd-gentoo.patch
+)
+
+src_prepare() {
+	default
+
+	sed -i \
+		-e 's:/etc/chrony\.conf:/etc/chrony/chrony.conf:g' \
+		doc/* examples/* || die
+
+	cp "${FILESDIR}"/chronyd.conf-r3 "${T}"/chronyd.conf || die
+}
+
+src_configure() {
+	if ! use caps ; then
+		sed -i \
+			-e 's/ -u ntp//' \
+			"${T}"/chronyd.conf examples/chronyd.service || die
+	fi
+
+	if ! use seccomp ; then
+		sed -i \
+			-e 's/ -F 2//' \
+			"${T}"/chronyd.conf examples/chronyd.service || die
+	fi
+
+	tc-export CC PKG_CONFIG
+
+	# Update from time to time with output from "date +%s"
+	# on a system that is time-synced.
+	export SOURCE_DATE_EPOCH=1607976314
+
+	# Not an autotools generated script
+	local myconf=(
+		$(use_enable seccomp scfilter)
+
+		$(usex caps '' '--disable-linuxcaps')
+		$(usex cmdmon '' '--disable-cmdmon')
+		$(usex debug '--enable-debug' '')
+		$(usex ipv6 '' '--disable-ipv6')
+		$(usex libedit '' '--without-editline')
+		$(usex libtomcrypt '' '--without-tomcrypt')
+		$(usex nettle '' '--without-nettle')
+		$(usex nss '' '--without-nss')
+		$(usex ntp '' '--disable-ntp')
+		$(usex nts '' '--disable-nts')
+		$(usex nts '' '--without-gnutls')
+		$(usex phc '' '--disable-phc')
+		$(usex pps '' '--disable-pps')
+		$(usex refclock '' '--disable-refclock')
+		$(usex rtc '' '--disable-rtc')
+		$(usex samba '--enable-ntp-signd' '')
+		$(usex sechash '' '--disable-sechash')
+
+		--chronysockdir="${EPREFIX}/run/chrony"
+		--docdir="${EPREFIX}/usr/share/doc/${PF}"
+		--mandir="${EPREFIX}/usr/share/man"
+		--prefix="${EPREFIX}/usr"
+		--sysconfdir="${EPREFIX}/etc/chrony"
+		--with-hwclockfile="${EPREFIX}/etc/adjtime"
+		--with-pidfile="${EPREFIX}/run/chrony/chronyd.pid"
+
+		${EXTRA_ECONF}
+	)
+
+	# Print the ./configure call
+	echo sh ./configure "${myconf[@]}" >&2
+	sh ./configure "${myconf[@]}" || die
+}
+
+src_compile() {
+	if [[ ${PV} == "9999" ]] ; then
+		# Uses w3m
+		emake -C doc man txt
+	fi
+
+	emake all docs $(usex html '' 'ADOC=true')
+}
+
+src_install() {
+	default
+
+	newinitd "${FILESDIR}"/chronyd.init-r2 chronyd
+	newconfd "${T}"/chronyd.conf chronyd
+
+
+	# lakitu: Remove the configuration from the original.
+	# insinto /etc/${PN}
+	# newins examples/chrony.conf.example1 chrony.conf
+
+	docinto examples
+	dodoc examples/*.example*
+
+	newtmpfiles - chronyd.conf <<<"d /run/chrony 0750 $(usex caps 'ntp ntp' 'root root')"
+
+	if use html ; then
+		docinto html
+		dodoc doc/*.html
+	fi
+
+	# lakitu: Those empty directories are not carried to image in ChromeOS.
+	keepdir /var/{lib,log}/chrony
+
+	# tmpfiles stuff to make sure var/lib/chrony installed.
+	insinto /usr/lib/tmpfiles.d
+	newins "${FILESDIR}/tmpfiles.d" "chrony.conf"
+
+	if use caps ; then
+		# Prepare a directory for the chrony.drift file (a la ntpsec)
+		# Ensures the environment is sane on new installs
+		# bug #711058
+		fowners ntp:ntp /var/{lib,log}/chrony
+		fperms 770 /var/lib/chrony
+	fi
+
+	insinto /etc/logrotate.d
+	newins "${FILESDIR}"/chrony-2.4-r1.logrotate chrony
+
+	systemd_dounit examples/chronyd.service
+	systemd_dounit examples/chrony-wait.service
+	systemd_enable_ntpunit 50-chrony chronyd.service
+}
+
+pkg_preinst() {
+	HAD_CAPS=0
+	HAD_SECCOMP=0
+	HAD_PRE_NEW_SECCOMP_LEVEL=0
+
+	# See https://dev.gentoo.org/~zmedico/portage/doc/portage.html#package-ebuild-phases-after-2.1.5
+	# in "Ebuild Phases" for an explanation of why we need to save the variable beforehand
+	if has_version 'net-misc/chrony[caps]' ; then
+		HAD_CAPS=1
+	fi
+
+	if has_version 'net-misc/chrony[seccomp]' ; then
+		HAD_SECCOMP=1
+	fi
+
+	if has_version '>=net-misc/chrony-4.1[seccomp]' ; then
+		# This version introduced a new filter level: -F 2
+		# It's a limited set of seccomp filters designed to be 'bare minimum'
+		HAD_PRE_NEW_SECCOMP_LEVEL=1
+	fi
+}
+
+pkg_postinst() {
+	tmpfiles_process chronyd.conf
+
+	if [[ -n "${REPLACING_VERSIONS}" ]] ; then
+		if use caps && ! [[ ${HAD_CAPS} -eq 1 ]] ; then
+			# bug #719876
+			ewarn "Please adjust permissions on ${EROOT}/var/{lib,log}/chrony to be owned by ntp:ntp"
+			ewarn "e.g. chown -R ntp:ntp ${EROOT}/var/{lib,log}/chrony"
+			ewarn "This is necessary for chrony to drop privileges"
+		elif ! use caps && [[ ${HAD_CAPS} -eq 0 ]] ; then
+			ewarn "Please adjust permissions on ${EROOT}/var/{lib,log}/chrony to be owned by root:root"
+		fi
+	fi
+
+	# See bug #783915 for general discussion on enabling seccomp filtering
+	# by default.
+	local show_seccomp_enable_msg=0
+
+	# Was seccomp disabled before and now enabled?
+	if [[ ${HAD_SECCOMP} -eq 0 ]] && use seccomp ; then
+		show_seccomp_enable_msg=1
+	fi
+
+	# Are we coming from an old version without the new 'minimal' filter?
+	# (-F 2)
+	if [[ ${HAD_PRE_NEW_SECCOMP_LEVEL} -eq 0 ]] ; then
+		show_seccomp_enable_msg=1
+	fi
+
+	if [[ ${show_seccomp_enable_msg} -eq 1 ]] ; then
+		elog "To enable seccomp in a stricter mode, please modify:"
+		elog "- /etc/conf.d/chronyd for OpenRC"
+		elog "- systemctl edit chronyd for systemd"
+		elog "By default, we now use -F 2 which is a baseline/minimal filter."
+		elog "to use -F 1 or -F -1 instead of -F 2 (see man chronyd)"
+	fi
+}
diff --git a/project-lakitu/net-misc/chrony/files/chrony-3.5-pool-vendor-gentoo.patch b/project-lakitu/net-misc/chrony/files/chrony-3.5-pool-vendor-gentoo.patch
new file mode 100644
index 0000000..817a410
--- /dev/null
+++ b/project-lakitu/net-misc/chrony/files/chrony-3.5-pool-vendor-gentoo.patch
@@ -0,0 +1,16 @@
+- Use the Gentoo pool
+- Use the server directive instead of the pool directive so we get four time
+  sources and not twelve.
+
+--- a/examples/chrony.conf.example1
++++ b/examples/chrony.conf.example1
+@@ -1,5 +1,8 @@
+ # Use public NTP servers from the pool.ntp.org project.
+-pool pool.ntp.org iburst
++server 0.gentoo.pool.ntp.org iburst
++server 1.gentoo.pool.ntp.org iburst
++server 2.gentoo.pool.ntp.org iburst
++server 3.gentoo.pool.ntp.org iburst
+ 
+ # Record the rate at which the system clock gains/losses time.
+ driftfile /var/lib/chrony/drift
diff --git a/project-lakitu/net-misc/chrony/files/chrony-3.5-r3-systemd-gentoo.patch b/project-lakitu/net-misc/chrony/files/chrony-3.5-r3-systemd-gentoo.patch
new file mode 100644
index 0000000..a3a2962
--- /dev/null
+++ b/project-lakitu/net-misc/chrony/files/chrony-3.5-r3-systemd-gentoo.patch
@@ -0,0 +1,12 @@
+--- a/examples/chronyd.service
++++ b/examples/chronyd.service
+@@ -8,8 +8,7 @@
+ [Service]
+ Type=forking
+ PIDFile=/run/chrony/chronyd.pid
+-EnvironmentFile=-/etc/sysconfig/chronyd
+-ExecStart=/usr/sbin/chronyd $OPTIONS
++ExecStart=/usr/sbin/chronyd -u ntp -F 0
+ PrivateTmp=yes
+ ProtectHome=yes
+ ProtectSystem=full
diff --git a/project-lakitu/net-misc/chrony/files/chrony-4.1-systemd-gentoo.patch b/project-lakitu/net-misc/chrony/files/chrony-4.1-systemd-gentoo.patch
new file mode 100644
index 0000000..ff3b320
--- /dev/null
+++ b/project-lakitu/net-misc/chrony/files/chrony-4.1-systemd-gentoo.patch
@@ -0,0 +1,12 @@
+--- a/examples/chronyd.service
++++ b/examples/chronyd.service
+@@ -8,8 +8,7 @@
+ [Service]
+ Type=forking
+ PIDFile=/run/chrony/chronyd.pid
+-EnvironmentFile=-/etc/sysconfig/chronyd
+-ExecStart=/usr/sbin/chronyd $OPTIONS
++ExecStart=/usr/sbin/chronyd -u ntp -F 2
+ PrivateTmp=yes
+ ProtectHome=yes
+ ProtectSystem=full
diff --git a/project-lakitu/net-misc/chrony/files/chronyd.conf b/project-lakitu/net-misc/chrony/files/chronyd.conf-r3
similarity index 94%
rename from project-lakitu/net-misc/chrony/files/chronyd.conf
rename to project-lakitu/net-misc/chrony/files/chronyd.conf-r3
index fc43a95..25a4758 100644
--- a/project-lakitu/net-misc/chrony/files/chronyd.conf
+++ b/project-lakitu/net-misc/chrony/files/chronyd.conf-r3
@@ -9,4 +9,4 @@
 # The combination of "-s -r" allows chronyd to perform long term averaging of
 # the gain or loss rate across system reboots and shutdowns.
 
-ARGS=""
+ARGS=" -u ntp -F 2"
diff --git a/project-lakitu/net-misc/chrony/files/chronyd.init-r1 b/project-lakitu/net-misc/chrony/files/chronyd.init-r2
similarity index 93%
rename from project-lakitu/net-misc/chrony/files/chronyd.init-r1
rename to project-lakitu/net-misc/chrony/files/chronyd.init-r2
index a76e253..4892a57 100644
--- a/project-lakitu/net-misc/chrony/files/chronyd.init-r1
+++ b/project-lakitu/net-misc/chrony/files/chronyd.init-r2
@@ -1,5 +1,5 @@
 #!/sbin/openrc-run
-# Copyright 1999-2013 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 depend() {
@@ -27,6 +27,7 @@
 		# option. I'm going to leave it here anyway, since you never
 		# know if it might be handy
 		PIDFILE=`awk '/^ *pidfile/{print $2}' "${CFGFILE}"`
+		[ -z "${PIDFILE}" ] && PIDFILE=/run/chrony/chronyd.pid
 	fi
 	return 0
 }
diff --git a/project-lakitu/net-misc/chrony/metadata.xml b/project-lakitu/net-misc/chrony/metadata.xml
index 4349fba..e43d787 100644
--- a/project-lakitu/net-misc/chrony/metadata.xml
+++ b/project-lakitu/net-misc/chrony/metadata.xml
@@ -1,33 +1,43 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
 <pkgmetadata>
-<maintainer type="person">
-	<email>jer@gentoo.org</email>
-</maintainer>
-<longdescription>
-Chrony is a pair of programs (chronyd and chronyc) which are used to maintain
-the accuracy of the system clock on a computer. chronyd has been specifically
-written to work well for systems which have only an intermittent (e.g. dial-up)
-connection to the network where the NTP servers are. It still works well
-in a "permanently connected" mode.
-</longdescription>
-<longdescription lang="ja">
-Chrony はコンピュータのシステム・クロックの精度を保つために使われるプログラムの
-ペア(chronyd と chronyc)です。chronyd は NTP サーバがあるネットワークと断続的な
-接続(e.g. dial-up)しか持たないシステムで機能するよう書かれています。ですが永続的
-な接続でも機能します。
-</longdescription>
-<use>
-<flag name="adns">Support for asynchronous DNS</flag>
-<flag name="cmdmon">Support for command and monitoring</flag>
-<flag name="html">Install HTML documentation</flag>
-<flag name="ntp">Support for the Network Time Protocol (NTP)</flag>
-<flag name="phc">Support for the PTP (Precision Time Protocol) Hardware Clock (PHC) interface</flag>
-<flag name="pps">Support for the Linux Pulse Per Second (PPS) interface</flag>
-<flag name="refclock">Support for reference clocks</flag>
-<flag name="rtc">Support for the Linux Real Time Clock interface</flag>
-</use>
-<upstream>
-<remote-id type="cpe">cpe:/a:chrony_project:chrony</remote-id>
-</upstream>
+	<maintainer type="person">
+		<email>sam@gentoo.org</email>
+		<name>Sam James</name>
+	</maintainer>
+	<maintainer type="project">
+		<email>base-system@gentoo.org</email>
+		<name>Gentoo Base System</name>
+	</maintainer>
+	<longdescription>
+		Chrony is a pair of programs (chronyd and chronyc) which are used to maintain
+		the accuracy of the system clock on a computer. chronyd has been specifically
+		written to work well for systems which have only an intermittent (e.g. dial-up)
+		connection to the network where the NTP servers are. It still works well
+		in a "permanently connected" mode.
+	</longdescription>
+	<longdescription lang="ja">
+		Chrony はコンピュータのシステム・クロックの精度を保つために使われるプログラムの
+		ペア(chronyd と chronyc)です。chronyd は NTP サーバがあるネットワークと断続的な
+		接続(e.g. dial-up)しか持たないシステムで機能するよう書かれています。ですが永続的
+		な接続でも機能します。
+	</longdescription>
+	<use>
+		<flag name="cmdmon">Support for command and monitoring</flag>
+		<flag name="debug">Get DEBUG_LOG output from chronyd when passing -dd parameter</flag>
+		<flag name="html">Install HTML documentation</flag>
+		<flag name="nettle">Use <pkg>dev-libs/nettle</pkg> for hash functions or nts</flag>
+		<flag name="nss">Use <pkg>dev-libs/nss</pkg> for hash functions</flag>
+		<flag name="ntp">Support for the Network Time Protocol (NTP)</flag>
+		<flag name="nts">Support for Network Time Security (NTS). Uses <pkg>net-libs/gnutls</pkg></flag>
+		<flag name="phc">Support for the PTP (Precision Time Protocol) Hardware Clock (PHC) interface</flag>
+		<flag name="pps">Support for the Linux Pulse Per Second (PPS) interface</flag>
+		<flag name="refclock">Support for reference clocks</flag>
+		<flag name="rtc">Support for the Linux Real Time Clock interface</flag>
+		<flag name="sechash">Enable support for hashes other than MD5</flag>
+		<flag name="libtomcrypt">Support different hashes via <pkg>dev-libs/libtomcrypt</pkg></flag>
+	</use>
+	<upstream>
+		<remote-id type="cpe">cpe:/a:chrony_project:chrony</remote-id>
+	</upstream>
 </pkgmetadata>