summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@iohq.net>2015-08-17 20:08:58 -0600
committerAaron Ball <nullspoon@iohq.net>2015-08-17 20:08:58 -0600
commit07e3d4cc011b131619e227a29174f19abb3a20e8 (patch)
tree01acfeb845a21f6291a37135e8cdaceadd50835d
parent0f6465b482bacf83180bcb45843292ac8c8ad900 (diff)
downloadterminus-07e3d4cc011b131619e227a29174f19abb3a20e8.tar.gz
terminus-07e3d4cc011b131619e227a29174f19abb3a20e8.tar.xz
Added sanity check for bios clock errors
When bios clock resets to 1979, terminus reads that, determines the threshold has not been exceeded (because it's a negative number since lastlogin obviously ahead of 1979), and writes the new lastlogin time, which is in 1979. If ntp then updates the clock, the user hasn't logged in in over 35 years, likely exceeding their set threshold. This puts in a sanity check to ensure the difference between lastlogin and now is a positive number. If the difference exceeds -1 day, terminus exits since the system clock is evidently unreliable.
-rw-r--r--src/main.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index fa89688..372e011 100644
--- a/src/main.c
+++ b/src/main.c
@@ -209,6 +209,15 @@ int main(int argc, char* argv[]) {
if((now - lastlogin) > threshold) {
printf("You're dead!\n");
exec_cmd(cmd);
+ } else if((lastlogin - now) > -86400) {
+ // Abort if last login is too far in the future.
+ // This should account for when
+ printf(
+ "Error: Last login appears to be over one day in the future.\n"
+ "This likely means something has gone wrong with the system clock.\n"
+ "Unable to determine current time. Aborting terminus check.\n"
+ );
+ return 2;
} else {
if(write_lastlogin(lastlogin_path) == 1) {
printf("Failure writing lastlogin\n");

Generated by cgit