/* * Print all the NEW_TIME entries in UTMP/WTMP, to see if there was a time change */ #include #include #include struct utmp *utmp_line; struct utmp utmp_to_search; int main(int argc, char** argv) { utmpname(_PATH_WTMP); //or _PATH_UTMP if you want it. setutent(); //see man utmp and man setutent utmp_to_search.ut_type = NEW_TIME; utmp_line = getutid(&utmp_to_search); if (utmp_line != NULL){ printf("The user that changed the time was: %s", utmp_line->ut_user); }else{ printf("There was no time change\n"); } endutent(); //closes the utmp/wtmp file return(EXIT_SUCCESS); }