]> granicus.if.org Git - sudo/commitdiff
Completely ignore time stamp file if it is set to the epoch, SUDO_1_8_6p7
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 25 Feb 2013 19:49:40 +0000 (14:49 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 25 Feb 2013 19:49:40 +0000 (14:49 -0500)
regardless of what gettimeofday() returns.

--HG--
branch : 1.8

plugins/sudoers/check.c

index e7134760e5bcf96f1bc3015ea44a58ef94fd74ef..e89f9b647d4ca043ee32c267e2b39f130c52c52b 100644 (file)
@@ -629,31 +629,34 @@ timestamp_status(char *timestampdir, char *timestampfile, char *user, int flags)
      */
     if (status == TS_OLD && !ISSET(flags, TS_REMOVE)) {
        mtim_get(&sb, &mtime);
-       /* Negative timeouts only expire manually (sudo -k). */
-       if (def_timestamp_timeout < 0 && mtime.tv_sec != 0)
-           status = TS_CURRENT;
-       else {
-           now = time(NULL);
-           if (def_timestamp_timeout &&
-               now - mtime.tv_sec < 60 * def_timestamp_timeout) {
-               /*
-                * Check for bogus time on the stampfile.  The clock may
-                * have been set back or someone could be trying to spoof us.
-                */
-               if (mtime.tv_sec > now + 60 * def_timestamp_timeout * 2) {
-                   time_t tv_sec = (time_t)mtime.tv_sec;
-                   log_error(0,
-                       _("timestamp too far in the future: %20.20s"),
-                       4 + ctime(&tv_sec));
-                   if (timestampfile)
-                       (void) unlink(timestampfile);
-                   else
-                       (void) rmdir(timestampdir);
-                   status = TS_MISSING;
-               } else if (get_boottime(&boottime) && timevalcmp(&mtime, &boottime, <)) {
-                   status = TS_OLD;
-               } else {
-                   status = TS_CURRENT;
+       if (timevalisset(&mtime)) {
+           /* Negative timeouts only expire manually (sudo -k). */
+           if (def_timestamp_timeout < 0) {
+               status = TS_CURRENT;
+           } else {
+               now = time(NULL);
+               if (def_timestamp_timeout &&
+                   now - mtime.tv_sec < 60 * def_timestamp_timeout) {
+                   /*
+                    * Check for bogus time on the stampfile.  The clock may
+                    * have been set back or user could be trying to spoof us.
+                    */
+                   if (mtime.tv_sec > now + 60 * def_timestamp_timeout * 2) {
+                       time_t tv_sec = (time_t)mtime.tv_sec;
+                       log_error(0,
+                           _("timestamp too far in the future: %20.20s"),
+                           4 + ctime(&tv_sec));
+                       if (timestampfile)
+                           (void) unlink(timestampfile);
+                       else
+                           (void) rmdir(timestampdir);
+                       status = TS_MISSING;
+                   } else if (get_boottime(&boottime) &&
+                       timevalcmp(&mtime, &boottime, <)) {
+                       status = TS_OLD;
+                   } else {
+                       status = TS_CURRENT;
+                   }
                }
            }
        }