1 --- ./src/log.c.org Sun Oct 21 21:11:04 2001
2 +++ ./src/log.c Sun Oct 21 21:20:07 2001
6 int log_wtmp(char *line, const char *name, const char *host, p_in_addr_t *ip) {
12 -#if (defined(SVR4) || defined(__SVR4)) && \
13 - !(defined(LINUX) || defined(__hpux) || defined (_AIX))
14 - /* This "auxilliary" utmp doesn't exist under linux. */
21 - static int fdx = -1;
22 + static int washere = 0;
24 - if (fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
25 - log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
29 + utmpname(_PATH_WTMP);
34 /* Unfortunately, utmp string fields are terminated by '\0' if they are
35 * shorter than the size of the field, but if they are exactly the size of
37 * Insane if you ask me. Unless there's massive uproar, I prefer to err on
38 * the side of caution and always null-terminate our strings.
40 - if (fstat(fdx,&buf) == 0) {
41 - memset(&utx,0,sizeof(utx));
42 - sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
43 - sstrncpy(utx.ut_id, "ftp",sizeof(utx.ut_user));
44 - sstrncpy(utx.ut_line,line,sizeof(utx.ut_line));
45 - sstrncpy(utx.ut_host,host,sizeof(utx.ut_host));
46 - utx.ut_syslen = strlen(utx.ut_host)+1;
47 - utx.ut_pid = getpid();
50 - utx.ut_tv.tv_sec = (time32_t)t;
52 - time(&utx.ut_tv.tv_sec);
55 - utx.ut_type = USER_PROCESS;
57 - utx.ut_type = DEAD_PROCESS;
58 -#ifdef HAVE_UT_UT_EXIT
59 - utx.ut_exit.e_termination = 0;
60 - utx.ut_exit.e_exit = 0;
61 -#endif /* HAVE_UT_UT_EXIT */
62 - if (write(fdx, (char *)&utx,sizeof(utx)) != sizeof(utx))
63 - ftruncate(fdx, buf.st_size);
65 - log_debug(DEBUG0, "%s fstat(): %s",WTMPX_FILE,strerror(errno));
69 -#else /* Non-SVR4 systems */
71 - if (fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
72 - log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
76 - if (fstat(fd,&buf) == 0) {
77 memset(&ut,0,sizeof(ut));
81 #endif /* HAVE_UT_UT_HOST */
84 - if (write(fd, (char *)&ut,sizeof(ut)) != sizeof(ut))
85 - ftruncate(fd,buf.st_size);
87 - log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
93 + while ((getutent())) ;