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:46:55.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 - static int fdx = -1;
109 +#if defined(HAVE_UTMPX_H)
110 + 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 (wtmpx_file != NULL)
127 +#if defined(__sparcv9) && !defined(__NetBSD__)
133 + static int fdx = -1;
135 - /* Unfortunately, utmp string fields are terminated by '\0' if they are
136 - * shorter than the size of the field, but if they are exactly the size of
137 - * the field they don't have to be terminated at all. Frankly, this sucks.
138 - * Insane if you ask me. Unless there's massive uproar, I prefer to err on
139 - * the side of caution and always null-terminate our strings.
141 - if (fstat(fdx, &buf) == 0) {
142 - memset(&utx, 0, sizeof(utx));
143 + if (fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
144 + pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
148 - sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
149 - sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
150 - sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
151 - sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
152 - utx.ut_pid = getpid();
153 -#if defined(__NetBSD__) && defined(HAVE_UTMPX_H)
154 - memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
155 - gettimeofday(&utx.ut_tv, NULL);
157 - utx.ut_syslen = strlen(utx.ut_host)+1;
160 - utx.ut_tv.tv_sec = (time32_t)t;
162 - time(&utx.ut_tv.tv_sec);
165 + /* Unfortunately, utmp string fields are terminated by '\0' if they are
166 + * shorter than the size of the field, but if they are exactly the size of
167 + * the field they don't have to be terminated at all. Frankly, this sucks.
168 + * Insane if you ask me. Unless there's massive uproar, I prefer to err on
169 + * the side of caution and always null-terminate our strings.
171 + if (fstat(fdx, &buf) == 0) {
172 + memset(&utx, 0, sizeof(utx));
175 - utx.ut_type = USER_PROCESS;
177 - utx.ut_type = DEAD_PROCESS;
178 -#ifdef HAVE_UT_UT_EXIT
179 - utx.ut_exit.e_termination = 0;
180 - utx.ut_exit.e_exit = 0;
181 + if (name && *name) {
182 + sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
183 + utx.ut_type = USER_PROCESS;
185 + utx.ut_type = DEAD_PROCESS;
187 + utx.ut_pid = getpid();
188 + sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
189 + sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
191 + sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
192 +#ifdef HAVE_UTX_UT_EXIT
193 + utx.ut_exit.e_termination = 0;
194 + utx.ut_exit.e_exit = 0;
195 #endif /* HAVE_UT_UT_EXIT */
196 - if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
197 - ftruncate(fdx, buf.st_size);
200 - pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
203 +#ifdef HAVE_UTX_UT_SYSLEN
204 + utx.ut_syslen = strlen(utx.ut_host)+1;
206 +#if defined(__NetBSD__)
207 + memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
208 + gettimeofday(&utx.ut_tv, NULL);
211 + utx.ut_tv.tv_sec = t;
214 -#else /* Non-SVR4 systems */
217 + memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
219 + memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
220 +#endif /* !PR_USE_IPV6 */
223 - (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
224 + if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
225 + ftruncate(fdx, buf.st_size);
227 + pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
234 +#else /* HAVE_UTMPX_H */
235 + if (fd < 0 && (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
236 pr_log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
240 if (fstat(fd, &buf) == 0) {
241 memset(&ut, 0, sizeof(ut));
242 -#ifdef HAVE_UTMAXTYPE
245 -# ifndef PR_USE_IPV6
246 - memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
248 - memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
249 -# endif /* !PR_USE_IPV6 */
251 - sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
252 -# ifdef HAVE_UT_UT_EXIT
253 - ut.ut_exit.e_termination = 0;
254 - ut.ut_exit.e_exit = 0;
255 -# endif /* !HAVE_UT_UT_EXIT */
256 -# endif /* !LINUX */
257 - sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
259 + if (name && *name) {
260 +#ifdef HAVE_UT_UT_USER
261 sstrncpy(ut.ut_user, name, sizeof(ut.ut_user));
262 - ut.ut_pid = getpid();
265 + sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
267 ut.ut_type = USER_PROCESS;
270 ut.ut_type = DEAD_PROCESS;
271 -#else /* !HAVE_UTMAXTYPE */
273 + ut.ut_pid = getpid();
274 sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
276 - sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
277 -#endif /* HAVE_UTMAXTYPE */
279 + sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
280 #ifdef HAVE_UT_UT_HOST
282 sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
283 #endif /* HAVE_UT_UT_HOST */
285 +#ifdef HAVE_UT_UT_EXIT
286 + ut.ut_exit.e_termination = 0;
287 + ut.ut_exit.e_exit = 0;
288 +#endif /* !HAVE_UT_UT_EXIT */
292 + memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
294 + memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
295 +#endif /* !PR_USE_IPV6 */
297 if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
298 ftruncate(fd, buf.st_size);
301 pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
303 Only in proftpd-1.3.1rc2.wtmpx/src: log.c~