make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / compiled-tools / utmp.c
blob4bfc400391023c4fe49bfceb3958931a5821e8fc
2 #include <utmp.h>
3 #include <stdio.h>
4 #include <err.h>
5 #include <errno.h>
6 #include <string.h>
7 #include <paths.h>
9 int main(int argc, char **argv)
11 struct utmp *utmpptr;
13 #ifdef DEBUG
14 printf("EMPTY=%u RUN_LVL=%u BOOT_TIME=%u NEW_TIME=%u OLD_TIME=%u INIT_PROCESS=%u LOGIN_PROCESS=%u USER_PROCESS=%u DEAD_PROCESS=%u ACCOUNTING=%u\n", EMPTY, RUN_LVL, BOOT_TIME, NEW_TIME, OLD_TIME, INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, DEAD_PROCESS, ACCOUNTING);
15 #endif
17 if(argc > 1)
19 if(strcmp(argv[1], "--help")==0)
21 printf("Usage: utmp [<FILE>]\nDisplay bare UTMP database line-by-line.\nDefault FILE is "_PATH_UTMP".\n");
22 return(0);
25 if(utmpname(argv[1]) != 0)
27 err(errno || -1, "%s: could not set utmp name", argv[1]);
31 while((utmpptr = getutent()))
33 #ifdef DEBUG
34 printf("utmp type=%u pid=%u line=%s id=%s user=%s host=%s\n",utmpptr->ut_type,utmpptr->ut_pid,utmpptr->ut_line,utmpptr->ut_id,utmpptr->ut_user,utmpptr->ut_host);
35 #endif
36 if(utmpptr->ut_type == USER_PROCESS)
38 printf("%u\t%s\t%s\t%s\n", utmpptr->ut_pid, utmpptr->ut_line, utmpptr->ut_user, utmpptr->ut_host);
41 endutent();
43 return(0);