1 --- proftpd-1.2.0rc2/src/log.c~ Sat Feb 3 18:19:05 2001
2 +++ proftpd-1.2.0rc2/src/log.c Sat Feb 3 18:21:08 2001
5 int log_wtmp(char *line, char *name, char *host, struct sockaddr_storage *ip)
12 -#if (defined(SVR4) || defined(__SVR4)) && \
13 - !(defined(LINUX) || defined(__hpux) || defined (_AIX))
14 - /* This "auxilliary" utmp doesn't exist under linux. */
16 - static int fdx = -1;
18 - if(fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY | O_APPEND, 0)) < 0) {
19 - log_pri(LOG_WARNING,"wtmpx %s: %s",WTMPX_FILE,strerror(errno));
22 + static int washere = 0;
25 + utmpname(_PATH_WTMP);
29 /* Unfortunately, utmp string fields are terminated by '\0' if they are
30 * shorter than the size of the field, but if they are exactly the size of
31 * the field they don't have to be terminated at all. Frankly, this sucks.
32 * Insane if you ask me. Unless there's massive uproar, I prefer to err on
33 * the side of caution and always null-terminate our strings.
35 - if(fstat(fdx,&buf) == 0) {
36 - memset(&utx,0,sizeof(utx));
37 - sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
38 - sstrncpy(utx.ut_id,"ftp",sizeof(utx.ut_user));
39 - sstrncpy(utx.ut_line,line,sizeof(utx.ut_line));
40 - sstrncpy(utx.ut_host,host,sizeof(utx.ut_host));
41 - utx.ut_syslen = strlen(utx.ut_host)+1;
42 - utx.ut_pid = getpid();
43 - time(&utx.ut_tv.tv_sec);
45 - utx.ut_type = USER_PROCESS;
47 - utx.ut_type = DEAD_PROCESS;
48 - utx.ut_exit.e_termination = 0;
49 - utx.ut_exit.e_exit = 0;
50 - if(write(fdx,(char*)&utx,sizeof(utx)) != sizeof(utx))
51 - ftruncate(fdx, buf.st_size);
53 - log_debug(DEBUG0,"%s fstat(): %s",WTMPX_FILE,strerror(errno));
57 -#else /* Non-SVR4 systems */
59 - if(fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
60 - log_pri(LOG_WARNING,"wtmp %s: %s",WTMP_FILE,strerror(errno));
64 - if(fstat(fd,&buf) == 0) {
65 - memset(&ut,0,sizeof(ut));
66 + memset(&ut,0,sizeof(ut));
71 #endif /* HAVE_UT_UT_HOST */
74 - if(write(fd,(char*)&ut,sizeof(ut)) != sizeof(ut))
75 - ftruncate(fd,buf.st_size);
77 - log_debug(DEBUG0,"%s fstat(): %s",WTMP_FILE,strerror(errno));
83 + while ((getutent())) ;