]>
Commit | Line | Data |
---|---|---|
728c4cc1 JR |
1 | diff -ur proftpd-1.2.0rc2.orig/src/log.c proftpd-1.2.0rc2/src/log.c |
2 | --- proftpd-1.2.0rc2.orig/src/log.c Wed Jul 26 13:03:17 2000 | |
d5bd2d19 JR |
3 | +++ proftpd-1.2.0rc2/src/log.c Wed Aug 9 17:14:50 2000 |
4 | @@ -31,6 +31,9 @@ | |
5 | * Also added a command line argument (-d,--debug) to alter the | |
6 | * debug level at runtime. See main.c. | |
7 | */ | |
4356f565 | 8 | +#ifdef __linux__ |
d5bd2d19 JR |
9 | +#define __USE_GNU |
10 | +#endif | |
11 | ||
12 | #include "conf.h" | |
13 | ||
14 | @@ -529,21 +532,11 @@ | |
728c4cc1 JR |
15 | |
16 | int log_wtmp(char *line, char *name, char *host, p_in_addr_t *ip) | |
17 | { | |
18 | - struct stat buf; | |
30911f7c | 19 | - struct utmp ut; |
728c4cc1 JR |
20 | int res = 0; |
21 | - static int fd = -1; | |
22 | ||
30911f7c | 23 | -#if defined(SVR4) || defined(__SVR4) |
728c4cc1 | 24 | -#if !(defined(LINUX) || defined(__hpux) || defined (_AIX)) |
30911f7c | 25 | +#ifdef HAVE_UTMPX_H |
728c4cc1 JR |
26 | /* This "auxilliary" utmp doesn't exist under linux. */ |
27 | struct utmpx utx; | |
28 | - static int fdx = -1; | |
29 | - | |
30 | - if(fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY | O_APPEND, 0)) < 0) { | |
31 | - log_pri(LOG_WARNING,"wtmpx %s: %s",WTMPX_FILE,strerror(errno)); | |
32 | - return -1; | |
33 | - } | |
34 | ||
35 | /* Unfortunately, utmp string fields are terminated by '\0' if they are | |
36 | * shorter than the size of the field, but if they are exactly the size of | |
d5bd2d19 | 37 | @@ -551,13 +544,11 @@ |
728c4cc1 JR |
38 | * Insane if you ask me. Unless there's massive uproar, I prefer to err on |
39 | * the side of caution and always null-terminate our strings. | |
40 | */ | |
41 | - if(fstat(fdx,&buf) == 0) { | |
42 | memset(&utx,0,sizeof(utx)); | |
43 | sstrncpy(utx.ut_user,name,sizeof(utx.ut_user)); | |
44 | sstrncpy(utx.ut_id,"ftp",sizeof(utx.ut_user)); | |
d5bd2d19 JR |
45 | sstrncpy(utx.ut_line,line,sizeof(utx.ut_line)); |
46 | sstrncpy(utx.ut_host,host,sizeof(utx.ut_host)); | |
47 | - utx.ut_syslen = strlen(utx.ut_host)+1; | |
48 | utx.ut_pid = getpid(); | |
49 | time(&utx.ut_tv.tv_sec); | |
50 | if(*name) | |
51 | @@ -566,22 +557,11 @@ | |
728c4cc1 JR |
52 | utx.ut_type = DEAD_PROCESS; |
53 | utx.ut_exit.e_termination = 0; | |
54 | utx.ut_exit.e_exit = 0; | |
55 | - if(write(fdx,(char*)&utx,sizeof(utx)) != sizeof(utx)) | |
56 | - ftruncate(fdx, buf.st_size); | |
57 | - } else { | |
58 | - log_debug(DEBUG0,"%s fstat(): %s",WTMPX_FILE,strerror(errno)); | |
59 | - res = -1; | |
60 | - } | |
d5bd2d19 | 61 | + updwtmpx(_PATH_WTMP, &utx); |
728c4cc1 | 62 | |
30911f7c JR |
63 | -#endif |
64 | -#endif /* SVR4 */ | |
65 | +#else | |
66 | + struct utmp ut; | |
728c4cc1 JR |
67 | |
68 | - if(fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) { | |
69 | - log_pri(LOG_WARNING,"wtmp %s: %s",WTMP_FILE,strerror(errno)); | |
70 | - return -1; | |
71 | - } | |
72 | - | |
73 | - if(fstat(fd,&buf) == 0) { | |
74 | memset(&ut,0,sizeof(ut)); | |
75 | #ifdef HAVE_UTMAXTYPE | |
76 | #ifdef LINUX | |
d5bd2d19 | 77 | @@ -612,12 +592,8 @@ |
728c4cc1 JR |
78 | #endif /* HAVE_UT_UT_HOST */ |
79 | ||
80 | time(&ut.ut_time); | |
81 | - if(write(fd,(char*)&ut,sizeof(ut)) != sizeof(ut)) | |
82 | - ftruncate(fd,buf.st_size); | |
83 | - } else { | |
84 | - log_debug(DEBUG0,"%s fstat(): %s",WTMP_FILE,strerror(errno)); | |
85 | - res = -1; | |
86 | - } | |
d5bd2d19 | 87 | + updwtmp(_PATH_WTMP, &ut); |
30911f7c | 88 | +#endif |
728c4cc1 JR |
89 | |
90 | return res; | |
91 | } |