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