DVG-4646431_password_after_reboot.patch   [plain text]


diff -uNr ../sudo-1.6.8p12.orig/check.c ./check.c
--- ../sudo-1.6.8p12.orig/check.c	2005-03-24 17:55:31.000000000 -0800
+++ ./check.c	2006-12-04 17:26:40.000000000 -0800
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/stat.h>
+#include <sys/sysctl.h>
 #ifndef __TANDEM
 # include <sys/file.h>
 #endif
@@ -513,6 +514,8 @@
 		    else
 			(void) rmdir(timestampdir);
 		    status = TS_MISSING;
+		} else if (sb.st_mtime < timeofboot()) {
+		    status = TS_OLD;
 		} else
 		    status = TS_CURRENT;
 	    }
@@ -560,3 +563,25 @@
     if (timestampfile)
 	free(timestampfile);
 }
+
+/*
+ * Check the boottime.
+ */
+int
+timeofboot()
+{
+	struct timeval	boottime;
+	time_t timeofboot = 0;
+	int mib[2];
+	size_t size;
+	
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_BOOTTIME;
+	size = sizeof(boottime);
+	
+	if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) {
+		timeofboot = boottime.tv_sec;
+	}
+	
+	return timeofboot;
+}