Completely ignore time stamp file if it is set to the epoch,

regardless of what gettimeofday() returns.
This commit is contained in:
Todd C. Miller
2013-02-21 10:05:16 -05:00
parent f336580bb1
commit 04b25a8bcd

View File

@@ -334,16 +334,17 @@ timestamp_status_internal(bool removing)
*/ */
if (status == TS_OLD && !removing) { if (status == TS_OLD && !removing) {
mtim_get(&sb, &mtime); mtim_get(&sb, &mtime);
if (timevalisset(&mtime)) {
/* Negative timeouts only expire manually (sudo -k). */ /* Negative timeouts only expire manually (sudo -k). */
if (def_timestamp_timeout < 0 && mtime.tv_sec != 0) if (def_timestamp_timeout < 0) {
status = TS_CURRENT; status = TS_CURRENT;
else { } else {
now = time(NULL); now = time(NULL);
if (def_timestamp_timeout && if (def_timestamp_timeout &&
now - mtime.tv_sec < 60 * def_timestamp_timeout) { now - mtime.tv_sec < 60 * def_timestamp_timeout) {
/* /*
* Check for bogus time on the stampfile. The clock may * Check for bogus time on the stampfile. The clock may
* have been set back or someone could be trying to spoof us. * have been set back or user could be trying to spoof us.
*/ */
if (mtime.tv_sec > now + 60 * def_timestamp_timeout * 2) { if (mtime.tv_sec > now + 60 * def_timestamp_timeout * 2) {
time_t tv_sec = (time_t)mtime.tv_sec; time_t tv_sec = (time_t)mtime.tv_sec;
@@ -355,7 +356,8 @@ timestamp_status_internal(bool removing)
else else
(void) rmdir(timestampdir); (void) rmdir(timestampdir);
status = TS_MISSING; status = TS_MISSING;
} else if (get_boottime(&boottime) && timevalcmp(&mtime, &boottime, <)) { } else if (get_boottime(&boottime) &&
timevalcmp(&mtime, &boottime, <)) {
status = TS_OLD; status = TS_OLD;
} else { } else {
status = TS_CURRENT; status = TS_CURRENT;
@@ -363,6 +365,7 @@ timestamp_status_internal(bool removing)
} }
} }
} }
}
done: done:
if (timestamp_uid != 0) if (timestamp_uid != 0)