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
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);
11 pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
12 diff -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
16 #undef HAVE_UT_UT_HOST
18 /* Define if your struct utmp uses ut_user and not ut_name */
19 -#undef HAVE_UTMAXTYPE
20 +#undef HAVE_UT_UT_USER
22 #define PF_ARGV_NONE 0
24 diff -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
28 #undef HAVE_UT_UT_HOST
30 /* Define if your struct utmp uses ut_user and not ut_name */
31 -#undef HAVE_UTMAXTYPE
32 +#undef HAVE_UT_UT_USER
34 #define PF_ARGV_NONE 0
36 diff -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
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 @@
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,
61 AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
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.])
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 @@
77 +dnl See what type of utmp exists
78 +AC_CHECK_HEADERS(utmpx.h, have_utmpx=1, have_utmpx=0)
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.])
94 + if test "$pr_cv_header_utx_syslen" = "yes"; then
95 + AC_DEFINE(HAVE_UTX_UT_SYSLEN, 1, [If struct utmpx has ut_syslen.])
99 dnl See if various LOG_ macros are defined
100 if test "$have_syslog_h" = "yes"; then
101 AC_DEFINE(HAVE_SYSLOG_H)
102 diff -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 @@
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__)
119 +#if defined(HAVE_UTMPX_H)
120 + char *wtmpx_file = NULL;
123 #if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
124 # define WTMPX_FILE _PATH_WTMPX
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");
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));
136 + if (fdx >= 0 || wtmpx_file != NULL)
138 +#if defined(__sparcv9) && !defined(__NetBSD__)
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.
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));
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);
167 - utx.ut_syslen = strlen(utx.ut_host)+1;
170 - utx.ut_tv.tv_sec = (time32_t)t;
172 - time(&utx.ut_tv.tv_sec);
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.
181 + if (fstat(fdx, &buf) == 0) {
182 + memset(&utx, 0, sizeof(utx));
185 - utx.ut_type = USER_PROCESS;
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;
195 + utx.ut_type = DEAD_PROCESS;
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));
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);
210 - pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
213 +#ifdef HAVE_UTX_UT_SYSLEN
214 + utx.ut_syslen = strlen(utx.ut_host)+1;
216 +#if defined(__NetBSD__)
217 + memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
218 + gettimeofday(&utx.ut_tv, NULL);
221 + utx.ut_tv.tv_sec = t;
224 -#else /* Non-SVR4 systems */
227 + memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
229 + memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
230 +#endif /* !PR_USE_IPV6 */
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);
237 + pr_log_debug(DEBUG0, "%s fstat(): %s", wtmpx_file, strerror(errno));
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));
250 if (fstat(fd, &buf) == 0) {
251 memset(&ut, 0, sizeof(ut));
252 -#ifdef HAVE_UTMAXTYPE
255 -# ifndef PR_USE_IPV6
256 - memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
258 - memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
259 -# endif /* !PR_USE_IPV6 */
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));
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();
275 + sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
277 ut.ut_type = USER_PROCESS;
280 ut.ut_type = DEAD_PROCESS;
281 -#else /* !HAVE_UTMAXTYPE */
283 + ut.ut_pid = getpid();
284 sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
286 - sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
287 -#endif /* HAVE_UTMAXTYPE */
289 + sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
290 #ifdef HAVE_UT_UT_HOST
292 sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
293 #endif /* HAVE_UT_UT_HOST */
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 */
302 + memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
304 + memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
305 +#endif /* !PR_USE_IPV6 */
307 if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
308 ftruncate(fd, buf.st_size);
311 pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
313 Only in proftpd-1.3.1rc2.wtmpx/src: log.c~