]> git.pld-linux.org Git - packages/proftpd.git/blame - proftpd-wtmp.patch
- thu shalt not mess with wtmp manually
[packages/proftpd.git] / proftpd-wtmp.patch
CommitLineData
728c4cc1
JR
1diff -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
3+++ proftpd-1.2.0rc2/src/log.c Wed Aug 9 16:57:44 2000
4@@ -529,21 +529,14 @@
5
6 int log_wtmp(char *line, char *name, char *host, p_in_addr_t *ip)
7 {
8- struct stat buf;
9 struct utmp ut;
10 int res = 0;
11- static int fd = -1;
12
13 #if defined(SVR4) || defined(__SVR4)
14-#if !(defined(LINUX) || defined(__hpux) || defined (_AIX))
15+#if !(defined(__hpux) || defined (_AIX))
16+#if (defined(LINUX) && defined(__GLIBC__))
17 /* This "auxilliary" utmp doesn't exist under linux. */
18 struct utmpx utx;
19- static int fdx = -1;
20-
21- if(fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY | O_APPEND, 0)) < 0) {
22- log_pri(LOG_WARNING,"wtmpx %s: %s",WTMPX_FILE,strerror(errno));
23- return -1;
24- }
25
26 /* Unfortunately, utmp string fields are terminated by '\0' if they are
27 * shorter than the size of the field, but if they are exactly the size of
28@@ -551,7 +544,6 @@
29 * Insane if you ask me. Unless there's massive uproar, I prefer to err on
30 * the side of caution and always null-terminate our strings.
31 */
32- if(fstat(fdx,&buf) == 0) {
33 memset(&utx,0,sizeof(utx));
34 sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
35 sstrncpy(utx.ut_id,"ftp",sizeof(utx.ut_user));
36@@ -566,22 +558,11 @@
37 utx.ut_type = DEAD_PROCESS;
38 utx.ut_exit.e_termination = 0;
39 utx.ut_exit.e_exit = 0;
40- if(write(fdx,(char*)&utx,sizeof(utx)) != sizeof(utx))
41- ftruncate(fdx, buf.st_size);
42- } else {
43- log_debug(DEBUG0,"%s fstat(): %s",WTMPX_FILE,strerror(errno));
44- res = -1;
45- }
46+ updwtmpx(_PATH_WTMP, &utx);
47
48 #endif
49 #endif /* SVR4 */
50
51- if(fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
52- log_pri(LOG_WARNING,"wtmp %s: %s",WTMP_FILE,strerror(errno));
53- return -1;
54- }
55-
56- if(fstat(fd,&buf) == 0) {
57 memset(&ut,0,sizeof(ut));
58 #ifdef HAVE_UTMAXTYPE
59 #ifdef LINUX
60@@ -612,12 +593,7 @@
61 #endif /* HAVE_UT_UT_HOST */
62
63 time(&ut.ut_time);
64- if(write(fd,(char*)&ut,sizeof(ut)) != sizeof(ut))
65- ftruncate(fd,buf.st_size);
66- } else {
67- log_debug(DEBUG0,"%s fstat(): %s",WTMP_FILE,strerror(errno));
68- res = -1;
69- }
70+ updwtmp(_PATH_WTMP, &utx);
71
72 return res;
73 }
This page took 0.063772 seconds and 4 git commands to generate.