Introduce qubes.SetDateTime service for time synchronization

It would be called by qvm-sync-clock instead of 'date' directly. This
gives a lot of flexibility - VM can control whether it want to sync time
this way. For now slight corrections (+-2sec) are ignored to not cause
problems by frequent time changes. But it can be easily extended to
refuse time sync when some other mechanism is used.
This commit is contained in:
Marek Marczykowski-Górecki 2014-09-30 03:29:58 +02:00
parent 4ee0de9fb8
commit 7339dd1ece
3 changed files with 13 additions and 0 deletions

View File

@ -167,6 +167,7 @@ install-common:
install -m 0644 qubes-rpc/qubes.{Backup,Restore} $(DESTDIR)/etc/qubes-rpc
install -m 0644 qubes-rpc/qubes.Select{File,Directory} $(DESTDIR)/etc/qubes-rpc
install -m 0644 qubes-rpc/qubes.GetImageRGBA $(DESTDIR)/etc/qubes-rpc
install -m 0644 qubes-rpc/qubes.SetDateTime $(DESTDIR)/etc/qubes-rpc
install -d $(DESTDIR)/usr/share/file-manager/actions
install -m 0644 qubes-rpc/*-gnome.desktop $(DESTDIR)/usr/share/file-manager/actions

View File

@ -0,0 +1,11 @@
#!/bin/sh
# it is in format of `date -u -Iseconds`, example: 2014-09-29T22:59:21+0000
# it comes from dom0, so is trusted
read timestamp
timediff=$(( `date -u +'+%Y%m%d%H%M%S'` - `date -u -d "$timestamp" +'+%Y%m%d%H%M%S'` ))
if [ $timediff -le 2 -a $timediff -ge -2 ]; then
# don't bother
exit 0
fi
date -u -s "$timestamp"

View File

@ -320,6 +320,7 @@ rm -f %{name}-%{version}
/etc/qubes-rpc/qubes.SelectFile
/etc/qubes-rpc/qubes.SelectDirectory
/etc/qubes-rpc/qubes.GetImageRGBA
/etc/qubes-rpc/qubes.SetDateTime
%config(noreplace) /etc/sudoers.d/qubes
%config(noreplace) /etc/sysconfig/iptables
%config(noreplace) /etc/sysconfig/ip6tables