#include #include #include #include #include #include #include #define LLOG "/var/log/wtmp" int main ( int argc, char *argv[] ) { struct utmp ut; int lfd; lfd = open(LLOG, O_RDONLY); if ( lfd == -1 ) { printf("Could not open log file %s\n", LLOG); return EXIT_FAILURE; } while ( read(lfd, &ut, sizeof(ut)) == sizeof(ut) ) { printf("user: %s from %s\n", ut.ut_user, ut.ut_host); } return 0; }