From: Todd C. Miller Date: Thu, 9 Jul 2015 16:10:34 +0000 (-0600) Subject: Sprinkle debugging for boottime. X-Git-Tag: SUDO_1_8_14^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b73d96804bf187f4a3ebe7c799a917770286f500;p=sudo Sprinkle debugging for boottime. --- diff --git a/plugins/sudoers/boottime.c b/plugins/sudoers/boottime.c index 72a7330bf..21a72a9b5 100644 --- a/plugins/sudoers/boottime.c +++ b/plugins/sudoers/boottime.c @@ -32,6 +32,7 @@ #ifdef HAVE_STRINGS_H # include #endif /* HAVE_STRINGS_H */ +#include #include #ifdef TIME_WITH_SYS_TIME # include @@ -77,7 +78,12 @@ get_boottime(struct timespec *ts) ts->tv_sec = (time_t)llval; ts->tv_nsec = 0; found = true; + sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO, + "found btime in /proc/stat: %lld", llval); break; + } else { + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, + "invalid btime in /proc/stat: %s", line); } } } @@ -102,10 +108,14 @@ get_boottime(struct timespec *ts) mib[1] = KERN_BOOTTIME; size = sizeof(tv); if (sysctl(mib, 2, &tv, &size, NULL, 0) != -1) { + sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO, + "KERN_BOOTTIME: %lld, %ld", (long long)tv.tv_sec, (long)tv.tv_usec); TIMEVAL_TO_TIMESPEC(&tv, ts); debug_return_bool(true); } + sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO, + "KERN_BOOTTIME: %s", strerror(errno)); debug_return_bool(false); } @@ -120,8 +130,12 @@ get_boottime(struct timespec *ts) memset(&key, 0, sizeof(key)); key.ut_type = BOOT_TIME; setutxent(); - if ((ut = getutxid(&key)) != NULL) + if ((ut = getutxid(&key)) != NULL) { + sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO, + "BOOT_TIME: %lld, %ld", (long long)ut->ut_tv.tv_sec, + (long)ut->ut_tv.tv_usec); TIMEVAL_TO_TIMESPEC(&ut->ut_tv, ts); + } endutxent(); debug_return_bool(ut != NULL); } @@ -138,6 +152,8 @@ get_boottime(struct timespec *ts) key.ut_type = BOOT_TIME; setutent(); if ((ut = getutid(&key)) != NULL) { + sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO, + "BOOT_TIME: %lld", (long long)ut->ut_time); ts->tv_sec = ut->ut_time; ts->tv_nsec = 0; }