I recently ran into problems with generating TOTP 2-factor codes on my laptop. The fact that some of the codes would work and some wouldn't suggested a problem with time keeping on my laptop.
This was surprising since I've been running NTP for a
many years and have therefore never had to think about time synchronization.
After realizing that ntpd had stopped working on my machine for some reason,
I found that systemd
provides an easier way to keep time synchronized.
The new systemd time synchronization daemon
On a machine running systemd, there is no need to run the full-fledged
ntpd daemon anymore. The built-in systemd-timesyncd can do the basic
time synchronization job just fine.
However, I noticed that the daemon wasn't actually running:
$ systemctl status systemd-timesyncd.service 
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: inactive (dead)
Condition: start condition failed at Thu 2017-08-03 21:48:13 PDT; 1 day 20h ago
     Docs: man:systemd-timesyncd.service(8)
referring instead to a mysterious "failed condition". Attempting to restart the service did provide more details though:
$ systemctl restart systemd-timesyncd.service 
$ systemctl status systemd-timesyncd.service 
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: inactive (dead)
Condition: start condition failed at Sat 2017-08-05 18:19:12 PDT; 1s ago
           └─ ConditionFileIsExecutable=!/usr/sbin/ntpd was not met
     Docs: man:systemd-timesyncd.service(8)
The above check for the presence of /usr/sbin/ntpd points to a conflict
between ntpd and systemd-timesyncd. The solution of course is to remove
the former before enabling the latter:
apt purge ntp
Enabling time synchronization with NTP
Once the ntp package has been removed, it is time to enable NTP support in
timesyncd.
Start by choosing the NTP server pool nearest
you and put it in /etc/systemd/timesyncd.conf.d/local.conf. For example, mine reads
like this:
[Time]
NTP=time.cloudflare.com
before restarting the daemon:
systemctl restart systemd-timesyncd.service 
That may not be enough on your machine though. To check whether or not the time has been synchronized with NTP servers, run the following:
$ timedatectl
...
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no
If NTP is not enabled, then you can enable it by running this command:
timedatectl set-ntp true
Once that's done, everything should be in place and time should be kept correctly:
$ timedatectl
...
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
I recently ran into problems trying to package the latest version of my planetfilter tool.
This is how I was able to temporarily work-around bugs in my tools and still produce a package that can be built reproducibly from source and that contains a verifiable upstream signature.
pristine-tar being is unable to reproduce a tarball
After importing the
latest upstream tarball
using gbp import-orig, I tried to build the package but ran into this
pristine-tar error:
$ gbp buildpackage
gbp:error: Pristine-tar couldn't checkout "planetfilter_0.7.4.orig.tar.gz": xdelta3: target window checksum mismatch: XD3_INVALID_INPUT
xdelta3: normally this indicates that the source file is incorrect
xdelta3: please verify the source file with sha1sum or equivalent
xdelta3 decode failed! at /usr/share/perl5/Pristine/Tar/DeltaTools.pm line 56.
pristine-tar: command failed: pristine-gz --no-verbose --no-debug --no-keep gengz /tmp/user/1000/pristine-tar.mgnaMjnwlk/wrapper /tmp/user/1000/pristine-tar.EV5aXIPWfn/planetfilter_0.7.4.orig.tar.gz.tmp
pristine-tar: failed to generate tarball
So I decided to throw away what I had, re-import the tarball and try again.
This time, I got a different pristine-tar error:
$ gbp buildpackage
gbp:error: Pristine-tar couldn't checkout "planetfilter_0.7.4.orig.tar.gz": xdelta3: target window checksum mismatch: XD3_INVALID_INPUT
xdelta3: normally this indicates that the source file is incorrect
xdelta3: please verify the source file with sha1sum or equivalent
xdelta3 decode failed! at /usr/share/perl5/Pristine/Tar/DeltaTools.pm line 56.
pristine-tar: command failed: pristine-gz --no-verbose --no-debug --no-keep gengz /tmp/user/1000/pristine-tar.mgnaMjnwlk/wrapper /tmp/user/1000/pristine-tar.EV5aXIPWfn/planetfilter_0.7.4.orig.tar.gz.tmp
pristine-tar: failed to generate tarball
I filed bug 871938 for this.
As a work-around, I simply symlinked the upstream tarball I already had
and then built the package using the tarball directly instead of the
upstream git branch:
ln -s ~/deve/remote/planetfilter/dist/planetfilter-0.7.4.tar.gz ../planetfilter_0.7.4.orig.tar.gz
gbp buildpackage --git-tarball-dir=..
Given that only the upstream and master branches are signed, the
.delta file
on the
pristine-tar branch
could be fixed at any time in the future by committing a new .delta file
once pristine-tar gets fixed. This therefore seems like a reasonable
work-around.
git-buildpackage doesn't import the upstream tarball signature
The second problem I ran into was a missing upstream signature after
building the package with
git-buildpackage:
$ lintian -i planetfilter_0.7.4-1_amd64.changes
E: planetfilter changes: orig-tarball-missing-upstream-signature planetfilter_0.7.4.orig.tar.gz
N: 
N:    The packaging includes an upstream signing key but the corresponding
N:    .asc signature for one or more source tarballs are not included in your
N:    .changes file.
N:    
N:    Severity: important, Certainty: certain
N:    
N:    Check: changes-file, Type: changes
N: 
This problem (and the lintian error I suspect) is fairly new and hasn't been solved yet.
So until gbp import-orig gets proper support for upstream signatures, my
work-around was to copy the upstream signature in the export-dir output
directory (which I set in ~/.gbp.conf) so that it can be picked up by the
final stages of gbp buildpackage:
ln -s ~/deve/remote/planetfilter/dist/planetfilter-0.7.4.tar.gz.asc ../build-area/planetfilter_0.7.4.orig.tar.gz.asc
If there's a better way to do this, please feel free to leave a comment (authentication not required)!