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