1 diff -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
7 /* Define if your struct utmp uses ut_user and not ut_name */
9 +#undef HAVE_UT_UT_USER
11 #define PF_ARGV_NONE 0
13 diff -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
17 #undef HAVE_UT_UT_HOST
19 /* Define if your struct utmp uses ut_user and not ut_name */
20 -#undef HAVE_UTMAXTYPE
21 +#undef HAVE_UT_UT_USER
23 #define PF_ARGV_NONE 0
25 diff -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
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 @@
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,
50 AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
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.])
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 @@
66 +dnl See what type of utmp exists
67 +AC_CHECK_HEADERS(utmpx.h, have_utmpx=1, have_utmpx=0)
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.])
83 + if test "$pr_cv_header_utx_syslen" = "yes"; then
84 + AC_DEFINE(HAVE_UTX_UT_SYSLEN, 1, [If struct utmpx has ut_syslen.])
88 dnl See if various LOG_ macros are defined
89 if test "$have_syslog_h" = "yes"; then
90 AC_DEFINE(HAVE_SYSLOG_H)
91 diff -ur proftpd-1.3.1rc2/src/log.c proftpd-1.3.1rc2.wtmpx/src/log.c
92 --- proftpd-1.3.1rc2/src/log.c 2006-12-11 20:53:43.000000000 +0100
93 +++ proftpd-1.3.1rc2.wtmpx/src/log.c 2007-08-20 14:52:13.000000000 +0200
98 -#if ((defined(SVR4) || defined(__SVR4)) || \
99 - (defined(__NetBSD__) && defined(HAVE_UTMPX_H))) && \
100 - !(defined(LINUX) || defined(__hpux) || defined (_AIX))
101 - /* This "auxilliary" utmp doesn't exist under linux. */
102 -#if defined(__sparcv9) && !defined(__NetBSD__)
108 +#if defined(HAVE_UTMPX_H)
109 + char *wtmpx_file = NULL;
112 #if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
113 # define WTMPX_FILE _PATH_WTMPX
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");
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));
125 + if (fdx >= 0 || wtmpx_file != NULL)
127 +#if defined(__sparcv9) && !defined(__NetBSD__)
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.
140 - if (fstat(fdx, &buf) == 0) {
141 - memset(&utx, 0, sizeof(utx));
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));
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));
151 - utx.ut_pid = getpid();
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);
156 - utx.ut_syslen = strlen(utx.ut_host)+1;
159 - utx.ut_tv.tv_sec = (time32_t)t;
161 - time(&utx.ut_tv.tv_sec);
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.
170 + if (fstat(fdx, &buf) == 0) {
171 + memset(&utx, 0, sizeof(utx));
174 - utx.ut_type = USER_PROCESS;
176 - utx.ut_type = DEAD_PROCESS;
177 -#ifdef HAVE_UT_UT_EXIT
178 - utx.ut_exit.e_termination = 0;
179 - utx.ut_exit.e_exit = 0;
180 + if (name && *name) {
181 + sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
182 + utx.ut_type = USER_PROCESS;
184 + utx.ut_type = DEAD_PROCESS;
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));
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 */
195 - if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
196 - ftruncate(fdx, buf.st_size);
199 - pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
202 +#ifdef HAVE_UTX_UT_SYSLEN
203 + utx.ut_syslen = strlen(utx.ut_host)+1;
205 +#if defined(__NetBSD__)
206 + memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
207 + gettimeofday(&utx.ut_tv, NULL);
210 + utx.ut_tv.tv_sec = t;
213 -#else /* Non-SVR4 systems */
216 + memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
218 + memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
219 +#endif /* !PR_USE_IPV6 */
222 - (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
223 + if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
224 + ftruncate(fdx, buf.st_size);
226 + pr_log_debug(DEBUG0, "%s fstat(): %s", wtmpx_file, strerror(errno));
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));
239 if (fstat(fd, &buf) == 0) {
240 memset(&ut, 0, sizeof(ut));
241 -#ifdef HAVE_UTMAXTYPE
244 -# ifndef PR_USE_IPV6
245 - memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
247 - memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
248 -# endif /* !PR_USE_IPV6 */
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));
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();
264 + sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
266 ut.ut_type = USER_PROCESS;
269 ut.ut_type = DEAD_PROCESS;
270 -#else /* !HAVE_UTMAXTYPE */
272 + ut.ut_pid = getpid();
273 sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
275 - sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
276 -#endif /* HAVE_UTMAXTYPE */
278 + sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
279 #ifdef HAVE_UT_UT_HOST
281 sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
282 #endif /* HAVE_UT_UT_HOST */
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 */
291 + memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
293 + memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
294 +#endif /* !PR_USE_IPV6 */
296 if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
297 ftruncate(fd, buf.st_size);
300 pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
302 Only in proftpd-1.3.1rc2.wtmpx/src: log.c~