diff mbox

[09/32] package/systemd: add support for specifying NTP servers

Message ID 1456437341-19025-10-git-send-email-gabe@hashrabbit.co
State Changes Requested
Headers show

Commit Message

Gabe Evans Feb. 25, 2016, 9:55 p.m. UTC
Systemd warns against the use of using the default NTP servers:

configure: WARNING: *** Using Google NTP servers.
                        Do not ship OSes or devices with these default settings.
                        See DISTRO_PORTING for details!

DISTRO_PORTING notes that Google's NTP servers aren't actually
a publicly offered service like Google Public DNS and that they serve
non-standard time that can be up to .5s off.

To avoid unexpected behavior in out-of-the-box builds, ntp.org is used
as the default.

Signed-off-by: Gabe Evans <gabe@hashrabbit.co>
---
 package/systemd/Config.in  | 18 +++++++++++++++++-
 package/systemd/systemd.mk |  4 +++-
 2 files changed, 20 insertions(+), 2 deletions(-)

Comments

Thomas Petazzoni Feb. 29, 2016, 9:50 p.m. UTC | #1
Dear Gabe Evans,

On Thu, 25 Feb 2016 21:55:18 +0000, Gabe Evans wrote:

> +config BR2_PACKAGE_SYSTEMD_NTP_SERVERS
> +	string "default NTP servers"
> +	default "0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org"

Does this really needs to be a compile time definition? Can't this be
specified in some configuration file? If so, then I believe it would be
nicer.

Thanks!

Thomas
Gabe Evans March 2, 2016, 6:10 p.m. UTC | #2
Hi Thomas,

On Mon, Feb 29, 2016 at 1:50 PM Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:

> Dear Gabe Evans,
>
> On Thu, 25 Feb 2016 21:55:18 +0000, Gabe Evans wrote:
>
> > +config BR2_PACKAGE_SYSTEMD_NTP_SERVERS
> > +     string "default NTP servers"
> > +     default "0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
> 3.pool.ntp.org"
>
> Does this really needs to be a compile time definition? Can't this be
> specified in some configuration file? If so, then I believe it would be
> nicer.
>

I had another look and we should be able to override this in
/etc/systemd/timesyncd.conf. The configure flag just sets FallbackNTP= in
the default /usr/lib/systemd/timesyncd.conf. One of the reasons I chose to
add an option for it is because ntp.org has some restrictions regarding the
use of their servers and wants you to register as a vendor with them if you
plan to ship a product/appliance/distro. What does Buildroot currently use
for other NTP/SNTP packages?

Thanks,
Gabe


>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
>
diff mbox

Patch

diff --git a/package/systemd/Config.in b/package/systemd/Config.in
index 5d6759d..5d74383 100644
--- a/package/systemd/Config.in
+++ b/package/systemd/Config.in
@@ -107,6 +107,22 @@  config BR2_PACKAGE_SYSTEMD_TIMESYNCD
 
 	  http://www.freedesktop.org/software/systemd/man/systemd-timesyncd.html
 
+if BR2_PACKAGE_SYSTEMD_TIMESYNCD
+
+config BR2_PACKAGE_SYSTEMD_NTP_SERVERS
+	string "default NTP servers"
+	default "0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org"
+	help
+	  You may specify a space-separated list of default NTP servers for timesyncd
+	  to use.
+
+	  Anyone distributing an appliance, operating system, or some other kind of
+	  software using NTP can register their own vendor pool at ntp.org:
+
+	  http://www.pool.ntp.org/en/vendors.html
+
+endif # BR2_PACKAGE_SYSTEMD_TIMESYNCD
+
 config BR2_PACKAGE_SYSTEMD_COMPAT
 	bool "enable compatibility libraries"
 	help
@@ -134,4 +150,4 @@  config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
 	  When this feature is enabled, Systemd mounts smackfs and manages
 	  security labels for sockets.
 
-endif
+endif # BR2_PACKAGE_SYSTEMD
diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index 639b8a5..32bf41b 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -145,7 +145,9 @@  endef
 endif
 
 ifeq ($(BR2_PACKAGE_SYSTEMD_TIMESYNCD),y)
-SYSTEMD_CONF_OPTS += --enable-timesyncd
+SYSTEMD_CONF_OPTS += \
+	--enable-timesyncd \
+	--with-ntp-servers=$(BR2_PACKAGE_SYSTEMD_NTP_SERVERS)
 define SYSTEMD_INSTALL_SERVICE_TIMESYNC
 	mkdir -p $(TARGET_DIR)/etc/systemd/system/sysinit.target.wants
 	ln -sf ../../../../lib/systemd/system/systemd-timesyncd.service \