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