Score:1

Is there a way to audit who is changing the system time?

cn flag

I've got an openvpn client running which seems to be causing a problem on my system by changing the system time for my machine.

How do you prevent openvpn clients from changing the system clock?

Is there a way that I can isolate changes to the system time in Linux system logs (Ubuntu) to understand who is changing the system time, when they are changing it, and why?

example:

cat ./syslog | egrep -i '(date|time)'
ti7 avatar
cn flag
ti7
(migrated from SO) do you suspect an unknown user or a program you control?
ti7 avatar
cn flag
ti7
do you share the system with another operating system?
cn flag
It's not a shared system. Exclusivly Ubuntu. The issue is either NTP or timedatectl has a bug in it and it's updating the time to the wrong time or openvpn is executing a script which is also setting the time, even though I haven't found it yet in spite of my looking through all of the scripts openvpn executes. I need to know and understand which service to blame and then look at. Is it OpenVpn and I just missed it, or is it systemd-timedatectl?
cn flag
How about making a `date` script and place it before `/usr/bin/` in PATH and add logging to that script and let that call `/usr/bin/date`? (log the pid and related processes).
Score:0
sl flag

I know this isn't a full answer, but also too much for a comment - I hope it might still help you.

If you want to go all-in you need to check which clock actually changes as there are multiple and most of them are stacked delta on top of the other.

For example if you are now after the one that is controlled by clock_settime as used by e.g. the date command to set time you could consider tracing any invocation of that system call via ftrace.

But that might be a bit too much, most commonly "time changes on network change" is due to DHCP being allowed to push ntp server information to a system. If it now happens that your openvpn connection might run dhlient (uncommon but possible) or has set explicit option to push info through dhcp it might happen that you get a nameserver set that does cause your system to change time.

In general checking ntp configuration like timedatectl timesync-status and/or chronyc sources (if you have it installed over systemd-timesyncd) changes pre/post openvpn dial-in would be a great start. If it does the place I'd debug first, if it uses something like dhclient directly you can - for example - disable the ntp options in /etc/dhcp/dhclient.conf which will make the client not asking for those anymore.

The whole problem has too many "what if" and "it depends" to create a perfect answer. But maybe this gives you enough to add more detail to the question in the first place :-).

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.