1 --- proftpd-1.3.1rc2.utmpx/acconfig.h~ 2002-12-15 19:05:09.000000000 +0100
2 +++ proftpd-1.3.1rc2.utmpx/acconfig.h 2007-08-20 14:13:20.000000000 +0200
6 /* Define if your struct utmp uses ut_user and not ut_name */
8 +#undef HAVE_UT_UT_USER
10 #define PF_ARGV_NONE 0
12 --- proftpd-1.3.1rc2.utmpx/config.h.in~ 2007-08-20 13:25:55.000000000 +0200
13 +++ proftpd-1.3.1rc2.utmpx/config.h.in 2007-08-20 14:14:03.000000000 +0200
15 #undef HAVE_UT_UT_HOST
17 /* Define if your struct utmp uses ut_user and not ut_name */
18 -#undef HAVE_UTMAXTYPE
19 +#undef HAVE_UT_UT_USER
21 #define PF_ARGV_NONE 0
23 diff -ur proftpd-1.3.1rc2/configure.in proftpd-1.3.1rc2.utmpx/configure.in
24 --- proftpd-1.3.1rc2/configure.in 2007-08-20 14:07:40.000000000 +0200
25 +++ proftpd-1.3.1rc2.utmpx/configure.in 2007-08-20 14:07:28.000000000 +0200
27 AC_CHECK_HEADERS(sys/stat.h errno.h sys/socket.h sys/termios.h sys/termio.h)
28 AC_CHECK_HEADERS(sys/statvfs.h sys/un.h sys/vfs.h sys/select.h)
29 AC_CHECK_HEADERS(dirent.h ndir.h sys/ndir.h sys/dir.h vmsdir.h)
30 -AC_CHECK_HEADERS(ucontext.h utime.h utmpx.h)
31 +AC_CHECK_HEADERS(ucontext.h utime.h)
32 AC_CHECK_HEADERS(regex.h)
33 AC_CHECK_HEADER(syslog.h,have_syslog_h="yes",)
34 AC_CHECK_HEADERS(curses.h ncurses.h)
35 @@ -1119,10 +1119,10 @@
37 if test $have_utmp; then
38 AC_CACHE_CHECK(whether your struct utmp has ut_user,
39 - pr_cv_header_utmaxtype,
40 + pr_cv_header_ut_user,
41 AC_EGREP_HEADER([ *ut_user.*;],utmp.h,
42 - pr_cv_header_utmaxtype="yes",
43 - pr_cv_header_utmaxtype="no"))
44 + pr_cv_header_ut_user="yes",
45 + pr_cv_header_ut_user="no"))
46 AC_CACHE_CHECK(whether your struct utmp has ut_host,
48 AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
50 AC_EGREP_HEADER([ *ut_exit.*;],utmp.h,
51 pr_cv_header_ut_exit="yes",
52 pr_cv_header_ut_exit="no"))
53 - if test "$pr_cv_header_utmaxtype" = "yes"; then
54 - AC_DEFINE(HAVE_UTMAXTYPE, 1, [If struct utmp has ut_user.])
55 + if test "$pr_cv_header_ut_user" = "yes"; then
56 + AC_DEFINE(HAVE_UT_UT_USER, 1, [If struct utmp has ut_user.])
58 if test "$pr_cv_header_ut_host" = "yes"; then
59 AC_DEFINE(HAVE_UT_UT_HOST, 1, [If struct utmp has ut_host.])
60 @@ -1144,6 +1144,28 @@
64 +dnl See what type of utmp exists
65 +AC_CHECK_HEADERS(utmpx.h, have_utmpx=1, have_utmpx=0)
67 +if test $have_utmpx; then
68 + AC_CACHE_CHECK(whether your struct utmpx has ut_exit,
69 + pr_cv_header_utx_exit,
70 + AC_EGREP_HEADER([ *ut_exit.*;],utmpx.h,
71 + pr_cv_header_utx_exit="yes",
72 + pr_cv_header_utx_exit="no"))
73 + AC_CACHE_CHECK(whether your struct utmpx has ut_syslen,
74 + pr_cv_header_utx_syslen,
75 + AC_EGREP_HEADER([ *ut_syslen.*;],utmpx.h,
76 + pr_cv_header_utx_syslen="yes",
77 + pr_cv_header_utx_syslen="no"))
78 + if test "$pr_cv_header_utx_exit" = "yes"; then
79 + AC_DEFINE(HAVE_UTX_UT_EXIT, 1, [If struct utmpx has ut_exit.])
81 + if test "$pr_cv_header_utx_syslen" = "yes"; then
82 + AC_DEFINE(HAVE_UTX_UT_SYSLEN, 1, [If struct utmpx has ut_syslen.])
86 dnl See if various LOG_ macros are defined
87 if test "$have_syslog_h" = "yes"; then
88 AC_DEFINE(HAVE_SYSLOG_H)
89 diff -ur proftpd-1.3.1rc2/src/log.c proftpd-1.3.1rc2.utmpx/src/log.c
90 --- proftpd-1.3.1rc2/src/log.c 2006-12-11 20:53:43.000000000 +0100
91 +++ proftpd-1.3.1rc2.utmpx/src/log.c 2007-08-20 14:07:30.000000000 +0200
96 -#if ((defined(SVR4) || defined(__SVR4)) || \
97 - (defined(__NetBSD__) && defined(HAVE_UTMPX_H))) && \
98 - !(defined(LINUX) || defined(__hpux) || defined (_AIX))
99 - /* This "auxilliary" utmp doesn't exist under linux. */
100 -#if defined(__sparcv9) && !defined(__NetBSD__)
106 - static int fdx = -1;
107 +#if defined(HAVE_UTMPX_H)
109 #if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
110 # define WTMPX_FILE _PATH_WTMPX
112 + if (access(WTMPX_FILE, F_OK) == 0) {
113 +#if defined(__sparcv9) && !defined(__NetBSD__)
119 + static int fdx = -1;
122 - (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
123 - pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
127 - /* Unfortunately, utmp string fields are terminated by '\0' if they are
128 - * shorter than the size of the field, but if they are exactly the size of
129 - * the field they don't have to be terminated at all. Frankly, this sucks.
130 - * Insane if you ask me. Unless there's massive uproar, I prefer to err on
131 - * the side of caution and always null-terminate our strings.
133 - if (fstat(fdx, &buf) == 0) {
134 - memset(&utx, 0, sizeof(utx));
135 + if (fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
136 + pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
140 - sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
141 - sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
142 - sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
143 - sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
144 - utx.ut_pid = getpid();
145 -#if defined(__NetBSD__) && defined(HAVE_UTMPX_H)
146 - memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
147 - gettimeofday(&utx.ut_tv, NULL);
149 - utx.ut_syslen = strlen(utx.ut_host)+1;
152 - utx.ut_tv.tv_sec = (time32_t)t;
154 - time(&utx.ut_tv.tv_sec);
157 + /* Unfortunately, utmp string fields are terminated by '\0' if they are
158 + * shorter than the size of the field, but if they are exactly the size of
159 + * the field they don't have to be terminated at all. Frankly, this sucks.
160 + * Insane if you ask me. Unless there's massive uproar, I prefer to err on
161 + * the side of caution and always null-terminate our strings.
163 + if (fstat(fdx, &buf) == 0) {
164 + memset(&utx, 0, sizeof(utx));
167 - utx.ut_type = USER_PROCESS;
169 - utx.ut_type = DEAD_PROCESS;
170 -#ifdef HAVE_UT_UT_EXIT
171 - utx.ut_exit.e_termination = 0;
172 - utx.ut_exit.e_exit = 0;
173 + if (name && *name) {
174 + sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
175 + utx.ut_type = USER_PROCESS;
177 + utx.ut_type = DEAD_PROCESS;
179 + utx.ut_pid = getpid();
180 + sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
181 + sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
183 + sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
184 +#ifdef HAVE_UTX_UT_EXIT
185 + utx.ut_exit.e_termination = 0;
186 + utx.ut_exit.e_exit = 0;
187 #endif /* HAVE_UT_UT_EXIT */
188 - if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
189 - ftruncate(fdx, buf.st_size);
192 - pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
195 +#ifdef HAVE_UTX_UT_SYSLEN
196 + utx.ut_syslen = strlen(utx.ut_host)+1;
198 +#if defined(__NetBSD__)
199 + memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
200 + gettimeofday(&utx.ut_tv, NULL);
203 + utx.ut_tv.tv_sec = t;
206 -#else /* Non-SVR4 systems */
209 + memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
211 + memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
212 +#endif /* !PR_USE_IPV6 */
215 - (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
216 + if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
217 + ftruncate(fdx, buf.st_size);
219 + pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
225 +#else /* HAVE_UTMPX_H */
226 + if (fd < 0 && (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
227 pr_log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
231 if (fstat(fd, &buf) == 0) {
232 memset(&ut, 0, sizeof(ut));
233 -#ifdef HAVE_UTMAXTYPE
236 -# ifndef PR_USE_IPV6
237 - memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
239 - memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
240 -# endif /* !PR_USE_IPV6 */
242 - sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
243 -# ifdef HAVE_UT_UT_EXIT
244 - ut.ut_exit.e_termination = 0;
245 - ut.ut_exit.e_exit = 0;
246 -# endif /* !HAVE_UT_UT_EXIT */
247 -# endif /* !LINUX */
248 - sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
250 + if (name && *name) {
251 +#ifdef HAVE_UT_UT_USER
252 sstrncpy(ut.ut_user, name, sizeof(ut.ut_user));
253 - ut.ut_pid = getpid();
256 + sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
258 ut.ut_type = USER_PROCESS;
261 ut.ut_type = DEAD_PROCESS;
262 -#else /* !HAVE_UTMAXTYPE */
264 + ut.ut_pid = getpid();
265 sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
267 - sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
268 -#endif /* HAVE_UTMAXTYPE */
270 + sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
271 #ifdef HAVE_UT_UT_HOST
273 sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
274 #endif /* HAVE_UT_UT_HOST */
276 +#ifdef HAVE_UT_UT_EXIT
277 + ut.ut_exit.e_termination = 0;
278 + ut.ut_exit.e_exit = 0;
279 +#endif /* !HAVE_UT_UT_EXIT */
283 + memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
285 + memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
286 +#endif /* !PR_USE_IPV6 */
288 if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
289 ftruncate(fd, buf.st_size);
292 pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));