]> granicus.if.org Git - sudo/commitdiff
Completely ignore time stamp file if it is set to the epoch,
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 21 Feb 2013 15:05:16 +0000 (10:05 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 21 Feb 2013 15:05:16 +0000 (10:05 -0500)
regardless of what gettimeofday() returns.

plugins/sudoers/timestamp.c

index a21d3bc1f04ebaae634e3b48ce0ab0d4c3dc06ca..f884e614df90b2c9af38e38e7a5f14741cf01bb7 100644 (file)
@@ -334,31 +334,34 @@ timestamp_status_internal(bool removing)
      */
     if (status == TS_OLD && !removing) {
        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,
-                       N_("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,
+                           N_("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;
+                   }
                }
            }
        }