1 --- proftpd-1.3.1-wtmp/acconfig.h 2002-12-15 20:05:09.000000000 +0200
2 +++ proftpd-1.3.1/acconfig.h 2008-01-09 00:43:47.043739566 +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.1-wtmp/config.h.in 2008-01-09 00:43:32.506904225 +0200
13 +++ proftpd-1.3.1/config.h.in 2008-01-09 00:43:47.043739566 +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 --- proftpd-1.3.1-wtmp/configure.in 2007-05-22 23:54:09.000000000 +0300
24 +++ proftpd-1.3.1/configure.in 2008-01-09 00:43:47.043739566 +0200
26 AC_CHECK_HEADERS(sys/stat.h errno.h sys/socket.h sys/termios.h sys/termio.h)
27 AC_CHECK_HEADERS(sys/statvfs.h sys/un.h sys/vfs.h sys/select.h)
28 AC_CHECK_HEADERS(dirent.h ndir.h sys/ndir.h sys/dir.h vmsdir.h)
29 -AC_CHECK_HEADERS(ucontext.h utime.h utmpx.h)
30 +AC_CHECK_HEADERS(ucontext.h utime.h)
31 AC_CHECK_HEADERS(regex.h)
32 AC_CHECK_HEADER(syslog.h,have_syslog_h="yes",)
33 AC_CHECK_HEADERS(curses.h ncurses.h)
34 @@ -1143,10 +1143,10 @@
36 if test $have_utmp; then
37 AC_CACHE_CHECK(whether your struct utmp has ut_user,
38 - pr_cv_header_utmaxtype,
39 + pr_cv_header_ut_user,
40 AC_EGREP_HEADER([ *ut_user.*;],utmp.h,
41 - pr_cv_header_utmaxtype="yes",
42 - pr_cv_header_utmaxtype="no"))
43 + pr_cv_header_ut_user="yes",
44 + pr_cv_header_ut_user="no"))
45 AC_CACHE_CHECK(whether your struct utmp has ut_host,
47 AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
49 AC_EGREP_HEADER([ *ut_exit.*;],utmp.h,
50 pr_cv_header_ut_exit="yes",
51 pr_cv_header_ut_exit="no"))
52 - if test "$pr_cv_header_utmaxtype" = "yes"; then
53 - AC_DEFINE(HAVE_UTMAXTYPE, 1, [If struct utmp has ut_user.])
54 + if test "$pr_cv_header_ut_user" = "yes"; then
55 + AC_DEFINE(HAVE_UT_UT_USER, 1, [If struct utmp has ut_user.])
57 if test "$pr_cv_header_ut_host" = "yes"; then
58 AC_DEFINE(HAVE_UT_UT_HOST, 1, [If struct utmp has ut_host.])
59 @@ -1168,6 +1168,28 @@
63 +dnl See what type of utmp exists
64 +AC_CHECK_HEADERS(utmpx.h, have_utmpx=1, have_utmpx=0)
66 +if test $have_utmpx; then
67 + AC_CACHE_CHECK(whether your struct utmpx has ut_exit,
68 + pr_cv_header_utx_exit,
69 + AC_EGREP_HEADER([ *ut_exit.*;],utmpx.h,
70 + pr_cv_header_utx_exit="yes",
71 + pr_cv_header_utx_exit="no"))
72 + AC_CACHE_CHECK(whether your struct utmpx has ut_syslen,
73 + pr_cv_header_utx_syslen,
74 + AC_EGREP_HEADER([ *ut_syslen.*;],utmpx.h,
75 + pr_cv_header_utx_syslen="yes",
76 + pr_cv_header_utx_syslen="no"))
77 + if test "$pr_cv_header_utx_exit" = "yes"; then
78 + AC_DEFINE(HAVE_UTX_UT_EXIT, 1, [If struct utmpx has ut_exit.])
80 + if test "$pr_cv_header_utx_syslen" = "yes"; then
81 + AC_DEFINE(HAVE_UTX_UT_SYSLEN, 1, [If struct utmpx has ut_syslen.])
85 dnl See if various LOG_ macros are defined
86 if test "$have_syslog_h" = "yes"; then
87 AC_DEFINE(HAVE_SYSLOG_H)
88 --- proftpd-1.3.1-wtmp/src/log.c 2007-09-11 03:49:44.000000000 +0300
89 +++ proftpd-1.3.1/src/log.c 2008-01-09 00:43:47.043739566 +0200
94 -#if ((defined(SVR4) || defined(__SVR4)) || \
95 - (defined(__NetBSD__) && defined(HAVE_UTMPX_H))) && \
96 - !(defined(LINUX) || defined(__hpux) || defined (_AIX))
97 - /* This "auxilliary" utmp doesn't exist under linux. */
98 -#if defined(__sparcv9) && !defined(__NetBSD__)
104 +#if defined(HAVE_UTMPX_H)
105 + char *wtmpx_file = NULL;
108 #if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
109 # define WTMPX_FILE _PATH_WTMPX
111 + if (access(WTMPX_FILE, F_OK) == 0)
112 + wtmpx_file = strdup(WTMPX_FILE);
113 + else if (access(WTMPX_FILE"x", F_OK) == 0)
114 + wtmpx_file = strdup(WTMPX_FILE"x");
117 - (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
118 - pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
121 + if (fdx >= 0 || wtmpx_file != NULL)
123 +#if defined(__sparcv9) && !defined(__NetBSD__)
130 - /* Unfortunately, utmp string fields are terminated by '\0' if they are
131 - * shorter than the size of the field, but if they are exactly the size of
132 - * the field they don't have to be terminated at all. Frankly, this sucks.
133 - * Insane if you ask me. Unless there's massive uproar, I prefer to err on
134 - * the side of caution and always null-terminate our strings.
136 - if (fstat(fdx, &buf) == 0) {
137 - memset(&utx, 0, sizeof(utx));
138 + if (fdx < 0 && (fdx = open(wtmpx_file, O_WRONLY|O_APPEND, 0)) < 0) {
139 + pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", wtmpx_file, strerror(errno));
143 - sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
144 - sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
145 - sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
146 - sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
147 - utx.ut_pid = getpid();
148 -#if defined(__NetBSD__) && defined(HAVE_UTMPX_H)
149 - memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
150 - gettimeofday(&utx.ut_tv, NULL);
152 - utx.ut_syslen = strlen(utx.ut_host)+1;
155 - utx.ut_tv.tv_sec = (time32_t)t;
157 - time(&utx.ut_tv.tv_sec);
160 + /* Unfortunately, utmp string fields are terminated by '\0' if they are
161 + * shorter than the size of the field, but if they are exactly the size of
162 + * the field they don't have to be terminated at all. Frankly, this sucks.
163 + * Insane if you ask me. Unless there's massive uproar, I prefer to err on
164 + * the side of caution and always null-terminate our strings.
166 + if (fstat(fdx, &buf) == 0) {
167 + memset(&utx, 0, sizeof(utx));
170 - utx.ut_type = USER_PROCESS;
172 - utx.ut_type = DEAD_PROCESS;
173 -#ifdef HAVE_UT_UT_EXIT
174 - utx.ut_exit.e_termination = 0;
175 - utx.ut_exit.e_exit = 0;
176 + if (name && *name) {
177 + sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
178 + utx.ut_type = USER_PROCESS;
180 + utx.ut_type = DEAD_PROCESS;
182 + utx.ut_pid = getpid();
183 + sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
184 + sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
186 + sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
187 +#ifdef HAVE_UTX_UT_EXIT
188 + utx.ut_exit.e_termination = 0;
189 + utx.ut_exit.e_exit = 0;
190 #endif /* HAVE_UT_UT_EXIT */
191 - if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
192 - (void) ftruncate(fdx, buf.st_size);
195 - pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
198 +#ifdef HAVE_UTX_UT_SYSLEN
199 + utx.ut_syslen = strlen(utx.ut_host)+1;
201 +#if defined(__NetBSD__)
202 + memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
203 + gettimeofday(&utx.ut_tv, NULL);
206 + utx.ut_tv.tv_sec = t;
209 -#else /* Non-SVR4 systems */
212 + memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
214 + memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
215 +#endif /* !PR_USE_IPV6 */
218 - (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
219 + if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
220 + (void )ftruncate(fdx, buf.st_size);
222 + pr_log_debug(DEBUG0, "%s fstat(): %s", wtmpx_file, strerror(errno));
229 +#else /* HAVE_UTMPX_H */
230 + if (fd < 0 && (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
231 pr_log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
235 if (fstat(fd, &buf) == 0) {
236 memset(&ut, 0, sizeof(ut));
237 -#ifdef HAVE_UTMAXTYPE
240 -# ifndef PR_USE_IPV6
241 - memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
243 - memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
244 -# endif /* !PR_USE_IPV6 */
246 - sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
247 -# ifdef HAVE_UT_UT_EXIT
248 - ut.ut_exit.e_termination = 0;
249 - ut.ut_exit.e_exit = 0;
250 -# endif /* !HAVE_UT_UT_EXIT */
251 -# endif /* !LINUX */
252 - sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
254 + if (name && *name) {
255 +#ifdef HAVE_UT_UT_USER
256 sstrncpy(ut.ut_user, name, sizeof(ut.ut_user));
257 - ut.ut_pid = getpid();
260 + sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
262 ut.ut_type = USER_PROCESS;
265 ut.ut_type = DEAD_PROCESS;
266 -#else /* !HAVE_UTMAXTYPE */
268 + ut.ut_pid = getpid();
269 sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
271 - sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
272 -#endif /* HAVE_UTMAXTYPE */
274 + sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
275 #ifdef HAVE_UT_UT_HOST
277 sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
278 #endif /* HAVE_UT_UT_HOST */
280 +#ifdef HAVE_UT_UT_EXIT
281 + ut.ut_exit.e_termination = 0;
282 + ut.ut_exit.e_exit = 0;
283 +#endif /* !HAVE_UT_UT_EXIT */
287 + memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
289 + memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
290 +#endif /* !PR_USE_IPV6 */
292 if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut))
293 ftruncate(fd, buf.st_size);
296 pr_log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));