} else
timespec_store(&ts, (usec_t) utc);
+ /* refuse the request when the time is before systemd build date time*/
+ if (ts.tv_sec < TIME_EPOCH)
+ return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Requested to set the clock to time before build time, refusing.");
+
r = bus_verify_polkit_async_full(
m,
"org.freedesktop.timedate1.set-time",
systemctl disable --now systemd-timesyncd.service
timedatectl set-timezone Europe/Berlin
-timedatectl set-time 1980-10-15
+
+# A future timestamp needs to be used, otherwise 'timedatectl set-time' fails
+# if a timestamp older than the TIME_EPOCH is specified.
+current_time=$(date)
+
+future_time=$(date -d "$current_time + 1 year" +"%Y-%m-%d %H:%M:%S")
+
+timedatectl set-time "$future_time"
systemd-run --on-timezone-change touch /tmp/timezone-changed
systemd-run --on-clock-change touch /tmp/clock-changed
while test ! -f /tmp/timezone-changed ; do sleep .5 ; done
-timedatectl set-time 2018-1-1
+future_time=$(date -d "$current_time + 1 year + 1 month" +"%Y-%m-%d %H:%M:%S")
+
+timedatectl set-time "$future_time"
while test ! -f /tmp/clock-changed ; do sleep .5 ; done