From 03cc26dda4cb59207fea3dd4fd1fa4608746739c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Oct 2013 01:03:39 +0200 Subject: timedated: expose time and NTP sync flag via the bus This way, timedatectl can be run over the network and determine all properties correctly from the server rather than the client. --- src/shared/time-util.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/shared/time-util.c') diff --git a/src/shared/time-util.c b/src/shared/time-util.c index 860be61e8b..4b4cd7a270 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -21,6 +21,7 @@ #include #include +#include #include "util.h" #include "time-util.h" @@ -792,3 +793,15 @@ int parse_nsec(const char *t, nsec_t *nsec) { return 0; } + +bool ntp_synced(void) { + struct timex txc = {}; + + if (adjtimex(&txc) < 0) + return false; + + if (txc.status & STA_UNSYNC) + return false; + + return true; +} -- cgit v1.2.3-54-g00ecf