]> git.pld-linux.org Git - packages/proftpd.git/blame - proftpd-wtmp.patch
- rediff
[packages/proftpd.git] / proftpd-wtmp.patch
CommitLineData
5c7e80b4
ER
1--- proftpd-1.3.1-wtmp/acconfig.h 2002-12-15 20:05:09.000000000 +0200
2+++ proftpd-1.3.1/acconfig.h 2008-01-09 00:43:47.043739566 +0200
082251a8
JR
3@@ -70,7 +70,7 @@
4 #undef HAVE_UT_UT_HOST
5
6 /* Define if your struct utmp uses ut_user and not ut_name */
7-#undef HAVE_UTMAXTYPE
8+#undef HAVE_UT_UT_USER
9
10 #define PF_ARGV_NONE 0
11 #define PF_ARGV_NEW 1
5c7e80b4
ER
12--- proftpd-1.3.1-wtmp/config.h.in 2008-01-09 00:43:32.506904225 +0200
13+++ proftpd-1.3.1/config.h.in 2008-01-09 00:43:47.043739566 +0200
14@@ -122,7 +122,7 @@
082251a8
JR
15 #undef HAVE_UT_UT_HOST
16
17 /* Define if your struct utmp uses ut_user and not ut_name */
18-#undef HAVE_UTMAXTYPE
19+#undef HAVE_UT_UT_USER
20
21 #define PF_ARGV_NONE 0
22 #define PF_ARGV_NEW 1
5c7e80b4
ER
23--- proftpd-1.3.1-wtmp/configure.in 2007-05-22 23:54:09.000000000 +0300
24+++ proftpd-1.3.1/configure.in 2008-01-09 00:43:47.043739566 +0200
25@@ -1063,7 +1063,7 @@
02396a1f
JR
26 AC_CHECK_HEADERS(sys/stat.h errno.h sys/socket.h sys/termios.h sys/termio.h)
27 AC_CHECK_HEADERS(sys/statvfs.h sys/un.h sys/vfs.h sys/select.h)
28 AC_CHECK_HEADERS(dirent.h ndir.h sys/ndir.h sys/dir.h vmsdir.h)
29-AC_CHECK_HEADERS(ucontext.h utime.h utmpx.h)
30+AC_CHECK_HEADERS(ucontext.h utime.h)
31 AC_CHECK_HEADERS(regex.h)
32 AC_CHECK_HEADER(syslog.h,have_syslog_h="yes",)
33 AC_CHECK_HEADERS(curses.h ncurses.h)
5c7e80b4 34@@ -1143,10 +1143,10 @@
12bef652 35
02396a1f
JR
36 if test $have_utmp; then
37 AC_CACHE_CHECK(whether your struct utmp has ut_user,
38- pr_cv_header_utmaxtype,
39+ pr_cv_header_ut_user,
40 AC_EGREP_HEADER([ *ut_user.*;],utmp.h,
41- pr_cv_header_utmaxtype="yes",
42- pr_cv_header_utmaxtype="no"))
43+ pr_cv_header_ut_user="yes",
44+ pr_cv_header_ut_user="no"))
45 AC_CACHE_CHECK(whether your struct utmp has ut_host,
46 pr_cv_header_ut_host,
47 AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
5c7e80b4 48@@ -1157,8 +1157,8 @@
02396a1f
JR
49 AC_EGREP_HEADER([ *ut_exit.*;],utmp.h,
50 pr_cv_header_ut_exit="yes",
51 pr_cv_header_ut_exit="no"))
52- if test "$pr_cv_header_utmaxtype" = "yes"; then
53- AC_DEFINE(HAVE_UTMAXTYPE, 1, [If struct utmp has ut_user.])
54+ if test "$pr_cv_header_ut_user" = "yes"; then
55+ AC_DEFINE(HAVE_UT_UT_USER, 1, [If struct utmp has ut_user.])
56 fi
57 if test "$pr_cv_header_ut_host" = "yes"; then
58 AC_DEFINE(HAVE_UT_UT_HOST, 1, [If struct utmp has ut_host.])
5c7e80b4 59@@ -1168,6 +1168,28 @@
02396a1f
JR
60 fi
61 fi
62
63+dnl See what type of utmp exists
64+AC_CHECK_HEADERS(utmpx.h, have_utmpx=1, have_utmpx=0)
65+
66+if test $have_utmpx; then
67+ AC_CACHE_CHECK(whether your struct utmpx has ut_exit,
68+ pr_cv_header_utx_exit,
69+ AC_EGREP_HEADER([ *ut_exit.*;],utmpx.h,
70+ pr_cv_header_utx_exit="yes",
71+ pr_cv_header_utx_exit="no"))
72+ AC_CACHE_CHECK(whether your struct utmpx has ut_syslen,
73+ pr_cv_header_utx_syslen,
74+ AC_EGREP_HEADER([ *ut_syslen.*;],utmpx.h,
75+ pr_cv_header_utx_syslen="yes",
76+ pr_cv_header_utx_syslen="no"))
77+ if test "$pr_cv_header_utx_exit" = "yes"; then
78+ AC_DEFINE(HAVE_UTX_UT_EXIT, 1, [If struct utmpx has ut_exit.])
79+ fi
80+ if test "$pr_cv_header_utx_syslen" = "yes"; then
81+ AC_DEFINE(HAVE_UTX_UT_SYSLEN, 1, [If struct utmpx has ut_syslen.])
82+ fi
83+fi
84+
85 dnl See if various LOG_ macros are defined
86 if test "$have_syslog_h" = "yes"; then
87 AC_DEFINE(HAVE_SYSLOG_H)
5c7e80b4
ER
88--- proftpd-1.3.1-wtmp/src/log.c 2007-09-11 03:49:44.000000000 +0300
89+++ proftpd-1.3.1/src/log.c 2008-01-09 00:43:47.043739566 +0200
52be463f 90@@ -59,119 +59,124 @@
728c4cc1 91 int res = 0;
02396a1f
JR
92 static int fd = -1;
93
7b7692b8
ER
94-#if ((defined(SVR4) || defined(__SVR4)) || \
95- (defined(__NetBSD__) && defined(HAVE_UTMPX_H))) && \
12bef652 96- !(defined(LINUX) || defined(__hpux) || defined (_AIX))
ff5ecb89 97- /* This "auxilliary" utmp doesn't exist under linux. */
4c33f075 98-#if defined(__sparcv9) && !defined(__NetBSD__)
8db28cde
PG
99- struct futmpx utx;
100- time_t t;
101-#else
ff5ecb89 102- struct utmpx utx;
8db28cde 103-#endif
02396a1f 104+#if defined(HAVE_UTMPX_H)
52be463f 105+ char *wtmpx_file = NULL;
ba9b13ed 106 static int fdx = -1;
618dd610
JR
107
108 #if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
109 # define WTMPX_FILE _PATH_WTMPX
110 #endif
52be463f
JR
111+ if (access(WTMPX_FILE, F_OK) == 0)
112+ wtmpx_file = strdup(WTMPX_FILE);
113+ else if (access(WTMPX_FILE"x", F_OK) == 0)
114+ wtmpx_file = strdup(WTMPX_FILE"x");
115
116- if (fdx < 0 &&
117- (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
118- pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
119- return -1;
120- }
ba9b13ed 121+ if (fdx >= 0 || wtmpx_file != NULL)
52be463f 122+ {
02396a1f
JR
123+#if defined(__sparcv9) && !defined(__NetBSD__)
124+ struct futmpx utx;
125+#else
126+ struct utmpx utx;
127+ time_t t;
128+#endif
02396a1f 129
02396a1f
JR
130- /* Unfortunately, utmp string fields are terminated by '\0' if they are
131- * shorter than the size of the field, but if they are exactly the size of
132- * the field they don't have to be terminated at all. Frankly, this sucks.
133- * Insane if you ask me. Unless there's massive uproar, I prefer to err on
134- * the side of caution and always null-terminate our strings.
135- */
850a3e73 136- if (fstat(fdx, &buf) == 0) {
137- memset(&utx, 0, sizeof(utx));
ba9b13ed
JR
138+ if (fdx < 0 && (fdx = open(wtmpx_file, O_WRONLY|O_APPEND, 0)) < 0) {
139+ pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", wtmpx_file, strerror(errno));
02396a1f
JR
140+ return -1;
141+ }
142
850a3e73 143- sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
144- sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
145- sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
146- sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
ff5ecb89 147- utx.ut_pid = getpid();
7b7692b8
ER
148-#if defined(__NetBSD__) && defined(HAVE_UTMPX_H)
149- memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
150- gettimeofday(&utx.ut_tv, NULL);
151-#else /* SVR4 */
152- utx.ut_syslen = strlen(utx.ut_host)+1;
153-# ifdef __sparcv9
8db28cde
PG
154- time(&t);
155- utx.ut_tv.tv_sec = (time32_t)t;
7b7692b8 156-# else
ff5ecb89 157- time(&utx.ut_tv.tv_sec);
7b7692b8
ER
158-# endif
159-#endif /* SVR4 */
02396a1f
JR
160+ /* Unfortunately, utmp string fields are terminated by '\0' if they are
161+ * shorter than the size of the field, but if they are exactly the size of
162+ * the field they don't have to be terminated at all. Frankly, this sucks.
163+ * Insane if you ask me. Unless there's massive uproar, I prefer to err on
164+ * the side of caution and always null-terminate our strings.
165+ */
166+ if (fstat(fdx, &buf) == 0) {
167+ memset(&utx, 0, sizeof(utx));
168
4c6dc458 169- if (*name)
ff5ecb89
JR
170- utx.ut_type = USER_PROCESS;
171- else
172- utx.ut_type = DEAD_PROCESS;
4c6dc458 173-#ifdef HAVE_UT_UT_EXIT
ff5ecb89
JR
174- utx.ut_exit.e_termination = 0;
175- utx.ut_exit.e_exit = 0;
02396a1f
JR
176+ if (name && *name) {
177+ sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
178+ utx.ut_type = USER_PROCESS;
179+ } else {
180+ utx.ut_type = DEAD_PROCESS;
181+ }
182+ utx.ut_pid = getpid();
183+ sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
184+ sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
185+ if (host && *host)
186+ sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
187+#ifdef HAVE_UTX_UT_EXIT
188+ utx.ut_exit.e_termination = 0;
189+ utx.ut_exit.e_exit = 0;
190 #endif /* HAVE_UT_UT_EXIT */
850a3e73 191- if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
5c7e80b4 192- (void) ftruncate(fdx, buf.st_size);
02396a1f 193
728c4cc1 194- } else {
850a3e73 195- pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
728c4cc1
JR
196- res = -1;
197- }
02396a1f
JR
198+#ifdef HAVE_UTX_UT_SYSLEN
199+ utx.ut_syslen = strlen(utx.ut_host)+1;
200+#endif
201+#if defined(__NetBSD__)
202+ memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
203+ gettimeofday(&utx.ut_tv, NULL);
204+#else
205+ time(&t);
7da49512 206+ utx.ut_tv.tv_sec = t;
02396a1f
JR
207+#endif
208
12bef652 209-#else /* Non-SVR4 systems */
02396a1f
JR
210+ if (ip)
211+#ifndef PR_USE_IPV6
212+ memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
213+#else
214+ memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
215+#endif /* !PR_USE_IPV6 */
216
850a3e73 217- if (fd < 0 &&
218- (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
02396a1f 219+ if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
ee1ec582 220+ (void )ftruncate(fdx, buf.st_size);
02396a1f 221+ } else {
ba9b13ed 222+ pr_log_debug(DEBUG0, "%s fstat(): %s", wtmpx_file, strerror(errno));
02396a1f
JR
223+ res = -1;
224+ }
225+
52be463f 226+ free(wtmpx_file);
02396a1f
JR
227+ return res;
228+ }
229+#else /* HAVE_UTMPX_H */
230+ if (fd < 0 && (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
231 pr_log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
232 return -1;
233 }
7b7692b8 234
02396a1f 235 if (fstat(fd, &buf) == 0) {
850a3e73 236 memset(&ut, 0, sizeof(ut));
02396a1f
JR
237-#ifdef HAVE_UTMAXTYPE
238-# ifdef LINUX
239- if (ip)
240-# ifndef PR_USE_IPV6
241- memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
242-# else
243- memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
244-# endif /* !PR_USE_IPV6 */
245-# else
246- sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
247-# ifdef HAVE_UT_UT_EXIT
248- ut.ut_exit.e_termination = 0;
249- ut.ut_exit.e_exit = 0;
250-# endif /* !HAVE_UT_UT_EXIT */
251-# endif /* !LINUX */
252- sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
253- if (name && *name)
254+ if (name && *name) {
255+#ifdef HAVE_UT_UT_USER
256 sstrncpy(ut.ut_user, name, sizeof(ut.ut_user));
257- ut.ut_pid = getpid();
258- if (name && *name)
259+#else
260+ sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
261+#endif
262 ut.ut_type = USER_PROCESS;
263- else
264+ } else {
265 ut.ut_type = DEAD_PROCESS;
266-#else /* !HAVE_UTMAXTYPE */
267+ }
268+ ut.ut_pid = getpid();
269 sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
270- if (name && *name)
271- sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
272-#endif /* HAVE_UTMAXTYPE */
273-
274+ sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
275 #ifdef HAVE_UT_UT_HOST
276 if (host && *host)
277 sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
728c4cc1 278 #endif /* HAVE_UT_UT_HOST */
02396a1f
JR
279-
280+#ifdef HAVE_UT_UT_EXIT
281+ ut.ut_exit.e_termination = 0;
282+ ut.ut_exit.e_exit = 0;
283+#endif /* !HAVE_UT_UT_EXIT */
12bef652 284 time(&ut.ut_time);
02396a1f
JR
285+ if (ip)
286+#ifndef PR_USE_IPV6
287+ memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
288+#else
289+ memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
290+#endif /* !PR_USE_IPV6 */
291+
292 if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
293 ftruncate(fd, buf.st_size);
850a3e73 294-
02396a1f
JR
295 } else {
296 pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
297 res = -1;
This page took 0.146692 seconds and 4 git commands to generate.