]> git.pld-linux.org Git - packages/proftpd.git/blame - proftpd-wtmp.patch
- removed pam_access
[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
ff5ecb89
JR
3+++ proftpd-1.2.0rc2/src/log.c Sun Aug 20 01:07:51 2000
4@@ -530,93 +530,96 @@
728c4cc1
JR
5 int log_wtmp(char *line, char *name, char *host, p_in_addr_t *ip)
6 {
ff5ecb89 7 struct stat buf;
30911f7c 8- struct utmp ut;
728c4cc1
JR
9 int res = 0;
10- static int fd = -1;
ff5ecb89 11-
30911f7c 12-#if defined(SVR4) || defined(__SVR4)
728c4cc1 13-#if !(defined(LINUX) || defined(__hpux) || defined (_AIX))
ff5ecb89
JR
14- /* This "auxilliary" utmp doesn't exist under linux. */
15- struct utmpx utx;
16 static int fdx = -1;
17+ static int fd = -1;
18
728c4cc1
JR
19- if(fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY | O_APPEND, 0)) < 0) {
20- log_pri(LOG_WARNING,"wtmpx %s: %s",WTMPX_FILE,strerror(errno));
21- return -1;
22- }
ff5ecb89
JR
23-
24- /* Unfortunately, utmp string fields are terminated by '\0' if they are
25- * shorter than the size of the field, but if they are exactly the size of
26- * the field they don't have to be terminated at all. Frankly, this sucks.
27- * Insane if you ask me. Unless there's massive uproar, I prefer to err on
28- * the side of caution and always null-terminate our strings.
29- */
728c4cc1 30- if(fstat(fdx,&buf) == 0) {
ff5ecb89
JR
31- memset(&utx,0,sizeof(utx));
32- sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
33- sstrncpy(utx.ut_id,"ftp",sizeof(utx.ut_user));
34- sstrncpy(utx.ut_line,line,sizeof(utx.ut_line));
35- sstrncpy(utx.ut_host,host,sizeof(utx.ut_host));
d5bd2d19 36- utx.ut_syslen = strlen(utx.ut_host)+1;
ff5ecb89
JR
37- utx.ut_pid = getpid();
38- time(&utx.ut_tv.tv_sec);
39- if(*name)
40- utx.ut_type = USER_PROCESS;
41- else
42- utx.ut_type = DEAD_PROCESS;
43- utx.ut_exit.e_termination = 0;
44- utx.ut_exit.e_exit = 0;
728c4cc1
JR
45- if(write(fdx,(char*)&utx,sizeof(utx)) != sizeof(utx))
46- ftruncate(fdx, buf.st_size);
47- } else {
48- log_debug(DEBUG0,"%s fstat(): %s",WTMPX_FILE,strerror(errno));
49- res = -1;
50- }
ff5ecb89
JR
51+ if (fdx >= 0 || access(_PATH_WTMP"x", F_OK) == 0) {
52+ struct utmpx utx;
53
54+ if(fdx < 0 && (fdx = open(_PATH_WTMP"x", O_WRONLY | O_APPEND, 0)) < 0) {
55+ log_pri(LOG_WARNING,"wtmpx %s: %s",_PATH_WTMP"x",strerror(errno));
56+ return -1;
57+ }
58+
59+ /* Unfortunately, utmp string fields are terminated by '\0' if they are
60+ * shorter than the size of the field, but if they are exactly the size of
61+ * the field they don't have to be terminated at all. Frankly, this sucks.
62+ * Insane if you ask me. Unless there's massive uproar, I prefer to err on
63+ * the side of caution and always null-terminate our strings.
64+ */
65+ if(fstat(fdx,&buf) == 0) {
66+ memset(&utx,0,sizeof(utx));
67+ if(name && *name)
68+ sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
69+ sstrncpy(utx.ut_id,"ftp",sizeof(utx.ut_id));
70+ sstrncpy(utx.ut_line,line,sizeof(utx.ut_line));
71+ if(host && *host)
72+ sstrncpy(utx.ut_host,host,sizeof(utx.ut_host));
73+#ifndef LINUX
74+ utx.ut_syslen = strlen(utx.ut_host)+1;
75+ utx.ut_exit.e_termination = 0;
76+ utx.ut_exit.e_exit = 0;
7c4163b1 77 #endif
30911f7c 78-#endif /* SVR4 */
ff5ecb89
JR
79+ utx.ut_pid = getpid();
80+ time(&utx.ut_tv.tv_sec);
81+ if(name && *name)
82+ utx.ut_type = USER_PROCESS;
83+ else
84+ utx.ut_type = DEAD_PROCESS;
85+ if(ip)
86+ memcpy(&utx.ut_addr,ip,sizeof(utx.ut_addr));
87+ if(write(fdx,(char*)&utx,sizeof(utx)) != sizeof(utx))
88+ ftruncate(fdx, buf.st_size);
89+ } else {
90+ log_debug(DEBUG0,"%s fstat(): %s",_PATH_WTMP"x",strerror(errno));
91+ res = -1;
92+ }
93+ } else {
94+ struct utmp ut;
728c4cc1
JR
95
96- if(fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
97- log_pri(LOG_WARNING,"wtmp %s: %s",WTMP_FILE,strerror(errno));
98- return -1;
99- }
ff5ecb89
JR
100+ if(fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
101+ log_pri(LOG_WARNING,"wtmp %s: %s",WTMP_FILE,strerror(errno));
102+ return -1;
103+ }
104
728c4cc1 105- if(fstat(fd,&buf) == 0) {
ff5ecb89
JR
106- memset(&ut,0,sizeof(ut));
107+ if(fstat(fd,&buf) == 0) {
108+ memset(&ut,0,sizeof(ut));
728c4cc1
JR
109 #ifdef HAVE_UTMAXTYPE
110 #ifdef LINUX
ff5ecb89
JR
111- if(ip)
112- memcpy(&ut.ut_addr,ip,sizeof(ut.ut_addr));
113+ if(ip)
114+ memcpy(&ut.ut_addr,ip,sizeof(ut.ut_addr));
115 #else
116- sstrncpy(ut.ut_id,"ftp",sizeof(ut.ut_id));
117- ut.ut_exit.e_termination = 0;
118- ut.ut_exit.e_exit = 0;
119+ sstrncpy(ut.ut_id,"ftp",sizeof(ut.ut_id));
120+ ut.ut_exit.e_termination = 0;
121+ ut.ut_exit.e_exit = 0;
122 #endif
123- sstrncpy(ut.ut_line,line,sizeof(ut.ut_line));
124- if(name && *name)
125- sstrncpy(ut.ut_user,name,sizeof(ut.ut_user));
126- ut.ut_pid = getpid();
127- if(name && *name)
128- ut.ut_type = USER_PROCESS;
129- else
130- ut.ut_type = DEAD_PROCESS;
131+ sstrncpy(ut.ut_line,line,sizeof(ut.ut_line));
132+ if(name && *name)
133+ sstrncpy(ut.ut_user,name,sizeof(ut.ut_user));
134+ ut.ut_pid = getpid();
135+ if(name && *name)
136+ ut.ut_type = USER_PROCESS;
137+ else
138+ ut.ut_type = DEAD_PROCESS;
139 #else /* !HAVE_UTMAXTYPE */
140- sstrncpy(ut.ut_line,line,sizeof(ut.ut_line));
141- if(name && *name)
142- sstrncpy(ut.ut_name,name,sizeof(ut.ut_name));
143+ sstrncpy(ut.ut_line,line,sizeof(ut.ut_line));
144+ if(name && *name)
145+ sstrncpy(ut.ut_name,name,sizeof(ut.ut_name));
146 #endif /* HAVE_UTMAXTYPE */
147
148 #ifdef HAVE_UT_UT_HOST
149- if(host && *host)
150- sstrncpy(ut.ut_host,host,sizeof(ut.ut_host));
151+ if(host && *host)
152+ sstrncpy(ut.ut_host,host,sizeof(ut.ut_host));
728c4cc1
JR
153 #endif /* HAVE_UT_UT_HOST */
154
ff5ecb89 155- time(&ut.ut_time);
728c4cc1
JR
156- if(write(fd,(char*)&ut,sizeof(ut)) != sizeof(ut))
157- ftruncate(fd,buf.st_size);
158- } else {
159- log_debug(DEBUG0,"%s fstat(): %s",WTMP_FILE,strerror(errno));
160- res = -1;
ff5ecb89
JR
161+ time(&ut.ut_time);
162+ if(write(fd,(char*)&ut,sizeof(ut)) != sizeof(ut))
163+ ftruncate(fd,buf.st_size);
164+ } else {
165+ log_debug(DEBUG0,"%s fstat(): %s",WTMP_FILE,strerror(errno));
166+ res = -1;
167+ }
168 }
728c4cc1
JR
169
170 return res;
This page took 0.082911 seconds and 4 git commands to generate.