summaryrefslogtreecommitdiff
path: root/src/shared/time-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-17 01:03:39 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-17 01:03:39 +0200
commit03cc26dda4cb59207fea3dd4fd1fa4608746739c (patch)
tree668d68fb3f7803ed5c7ce4a04e227bdbff030b0b /src/shared/time-util.c
parentaacf3b483b70b9a9ff16217f6376d143cbfe4636 (diff)
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.
Diffstat (limited to 'src/shared/time-util.c')
-rw-r--r--src/shared/time-util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index 860be61e8..4b4cd7a27 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -21,6 +21,7 @@
#include <time.h>
#include <string.h>
+#include <sys/timex.h>
#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;
+}