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 diff -burNp proftpd-1.3.2.orig/configure.in proftpd-1.3.2-dud/configure.in
24 --- proftpd-1.3.2.orig/configure.in 2008-11-19 04:51:38.000000000 +0100
25 +++ proftpd-1.3.2-dud/configure.in 2009-02-09 12:03:19.465085522 +0100
26 @@ -1131,7 +1131,7 @@ AC_CHECK_HEADERS(netinet/tcp.h arpa/inet
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(ucred.h 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 @@ -1211,10 +1211,10 @@ AC_CHECK_HEADERS(utmp.h, have_utmp=1, ha
37 if test $have_utmp; then
38 AC_CACHE_CHECK(whether 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 struct utmp has ut_host,
48 AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
49 @@ -1225,7 +1225,7 @@ if test $have_utmp; then
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 + if test "$pr_cv_header_ut_user" = "yes"; then
55 AC_DEFINE(HAVE_UTMAXTYPE, 1, [If struct utmp has ut_user.])
57 if test "$pr_cv_header_ut_host" = "yes"; then
58 @@ -1236,6 +1236,28 @@ if test $have_utmp; then
62 +dnl See what type of utmp exists
63 +AC_CHECK_HEADERS(utmpx.h, have_utmpx=1, have_utmpx=0)
65 +if test $have_utmpx; then
66 + AC_CACHE_CHECK(whether your struct utmpx has ut_exit,
67 + pr_cv_header_utx_exit,
68 + AC_EGREP_HEADER([ *ut_exit.*;],utmpx.h,
69 + pr_cv_header_utx_exit="yes",
70 + pr_cv_header_utx_exit="no"))
71 + AC_CACHE_CHECK(whether your struct utmpx has ut_syslen,
72 + pr_cv_header_utx_syslen,
73 + AC_EGREP_HEADER([ *ut_syslen.*;],utmpx.h,
74 + pr_cv_header_utx_syslen="yes",
75 + pr_cv_header_utx_syslen="no"))
76 + if test "$pr_cv_header_utx_exit" = "yes"; then
77 + AC_DEFINE(HAVE_UTX_UT_EXIT, 1, [If struct utmpx has ut_exit.])
79 + if test "$pr_cv_header_utx_syslen" = "yes"; then
80 + AC_DEFINE(HAVE_UTX_UT_SYSLEN, 1, [If struct utmpx has ut_syslen.])
84 dnl See if various LOG_ macros are defined
85 if test "$have_syslog_h" = "yes"; then
86 AC_DEFINE(HAVE_SYSLOG_H)
87 diff -burNp proftpd-1.3.2.orig/src/log.c proftpd-1.3.2-dud/src/log.c
88 --- proftpd-1.3.2.orig/src/log.c 2008-12-17 00:43:55.000000000 +0100
89 +++ proftpd-1.3.2-dud/src/log.c 2009-02-09 14:24:34.271689801 +0100
90 @@ -58,26 +58,29 @@ int log_wtmp(char *line, const char *nam
94 +#if defined(HAVE_UTMPX_H)
95 + char *wtmpx_file = NULL;
96 + static int fdx = -1;
98 +#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
99 +# define WTMPX_FILE _PATH_WTMPX
101 + if (access(WTMPX_FILE, F_OK) == 0)
102 + wtmpx_file = strdup(WTMPX_FILE);
103 + else if (access(WTMPX_FILE"x", F_OK) == 0)
104 + wtmpx_file = strdup(WTMPX_FILE"x");
106 -#if ((defined(SVR4) || defined(__SVR4)) || \
107 - (defined(__NetBSD__) && defined(HAVE_UTMPX_H))) && \
108 - !(defined(LINUX) || defined(__hpux) || defined (_AIX))
109 - /* This "auxilliary" utmp doesn't exist under linux. */
110 + if (fdx >= 0 || wtmpx_file != NULL)
112 #if defined(__sparcv9) && !defined(__NetBSD__)
118 - static int fdx = -1;
120 -#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
121 -# define WTMPX_FILE _PATH_WTMPX
126 - (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
127 - pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
128 + if (fdx < 0 && (fdx = open(wtmpx_file, O_WRONLY|O_APPEND, 0)) < 0) {
129 + pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", wtmpx_file, strerror(errno));
133 @@ -87,95 +90,95 @@ int log_wtmp(char *line, const char *nam
134 * Insane if you ask me. Unless there's massive uproar, I prefer to err on
135 * the side of caution and always null-terminate our strings.
138 if (fstat(fdx, &buf) == 0) {
139 memset(&utx, 0, sizeof(utx));
141 + if (name && *name) {
142 sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
143 - sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
144 - sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
145 - sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
146 - utx.ut_pid = session.pid ? session.pid : getpid();
147 -#if defined(__NetBSD__) && defined(HAVE_UTMPX_H)
148 - memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
149 - gettimeofday(&utx.ut_tv, NULL);
151 - utx.ut_syslen = strlen(utx.ut_host)+1;
154 - utx.ut_tv.tv_sec = (time32_t)t;
156 - time(&utx.ut_tv.tv_sec);
161 utx.ut_type = USER_PROCESS;
164 utx.ut_type = DEAD_PROCESS;
165 -#ifdef HAVE_UT_UT_EXIT
167 + utx.ut_pid = getpid();
168 + sstrncpy(utx.ut_line, line, sizeof(utx.ut_line));
169 + sstrncpy(utx.ut_id, "ftp", sizeof(utx.ut_user));
171 + sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
172 +#ifdef HAVE_UTX_UT_EXIT
173 utx.ut_exit.e_termination = 0;
174 utx.ut_exit.e_exit = 0;
175 #endif /* HAVE_UT_UT_EXIT */
176 +#ifdef HAVE_UTX_UT_SYSLEN
177 + utx.ut_syslen = strlen(utx.ut_host)+1;
179 +#if defined(__NetBSD__)
180 + memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
181 + gettimeofday(&utx.ut_tv, NULL);
184 + utx.ut_tv.tv_sec = t;
188 + memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
190 + memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
191 +#endif /* !PR_USE_IPV6 */
192 if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
193 - (void) ftruncate(fdx, buf.st_size);
195 + (void )ftruncate(fdx, buf.st_size);
197 - pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
198 + pr_log_debug(DEBUG0, "%s fstat(): %s", wtmpx_file, strerror(errno));
202 -#else /* Non-SVR4 systems */
205 - (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
209 +#else /* HAVE_UTMPX_H */
210 + if (fd < 0 && (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
211 pr_log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
215 if (fstat(fd, &buf) == 0) {
216 memset(&ut, 0, sizeof(ut));
217 -#ifdef HAVE_UTMAXTYPE
220 -# ifndef PR_USE_IPV6
221 - memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
223 - memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
224 -# endif /* !PR_USE_IPV6 */
226 - sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
227 -# ifdef HAVE_UT_UT_EXIT
228 - ut.ut_exit.e_termination = 0;
229 - ut.ut_exit.e_exit = 0;
230 -# endif /* !HAVE_UT_UT_EXIT */
231 -# endif /* !LINUX */
232 - sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
234 + if (name && *name) {
235 +#ifdef HAVE_UT_UT_USER
236 sstrncpy(ut.ut_user, name, sizeof(ut.ut_user));
237 - ut.ut_pid = session.pid ? session.pid : getpid();
240 + sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
242 ut.ut_type = USER_PROCESS;
245 ut.ut_type = DEAD_PROCESS;
246 -#else /* !HAVE_UTMAXTYPE */
248 + ut.ut_pid = session.pid ? session.pid : getpid();
249 sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
251 - sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
252 -#endif /* HAVE_UTMAXTYPE */
253 + sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
255 #ifdef HAVE_UT_UT_HOST
257 sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
258 #endif /* HAVE_UT_UT_HOST */
260 +#ifdef HAVE_UT_UT_EXIT
261 + ut.ut_exit.e_termination = 0;
262 + ut.ut_exit.e_exit = 0;
263 +#endif /* !HAVE_UT_UT_EXIT */
265 ut.ut_time = time(NULL);
268 + memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
270 + memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
271 +#endif /* !PR_USE_IPV6 */
273 if (write(fd, (char *)&ut, sizeof(ut)) != sizeof(ut)) {
274 if (ftruncate(fd, buf.st_size) < 0) {
275 pr_log_debug(DEBUG0, "error truncating '%s': %s", WTMP_FILE,
281 pr_log_debug(DEBUG0, "%s fstat(): %s", WTMP_FILE, strerror(errno));