I modified some sample Go daemon code to execute timedatectl and wasn’t able to reproduce the error at first. I tried using a full path for the executable /usr/bin/timedatectl and just using the name of the binary.
My code used the status, set-ntp, set-timezone, and set-time functions. One thing I did discover is that if you use the set-time operation, it fails due to a quoting problem in the timedatectl wrapper script. You have a pass the time as a quoted string like this:
sudo timedatectl set-time "2012-10-30 18:17:16"
…and the quotes get dropped in the wrapper script which if the command isn’t “set-timezone”, just does:
$TIMEDATECTL $@
I’ll file a bug for this.
When running my daemon snap, I did see some apparmor errors for timedatectl, but I never saw any for timedatectl.real until I modified the snap to declare plugs for timezone-control, time-control, and timeserver-control. At this point, I started seeing apparmor errors for the various libraries that timedatectl.real actually uses, however I still didn’t see the ptrace error or the /proc/1/environ error. It wasn’t until I actually connected the plugs for the three time interfaces that these errors were logged.
So, to trigger these errors:
- Ensure the snap declares plugs for time*-control
- Ensure that the snap app that uses timedatectl is a simple daemon
- Ensure that the snap daemon calls timedatectl set-ntp true
- Ensure that all the time* plugs are connected