-diff -ur proftpd-1.2.0rc2.orig/src/log.c proftpd-1.2.0rc2/src/log.c
---- proftpd-1.2.0rc2.orig/src/log.c Wed Jul 26 13:03:17 2000
-+++ proftpd-1.2.0rc2/src/log.c Wed Aug 9 17:01:45 2000
-@@ -529,21 +529,14 @@
-
- int log_wtmp(char *line, char *name, char *host, p_in_addr_t *ip)
- {
-- struct stat buf;
+diff -ruNp proftpd-1.3.5.orig/src/wtmp.c proftpd-1.3.5/src/wtmp.c
+--- proftpd-1.3.5.orig/src/wtmp.c 2013-12-09 20:16:15.000000000 +0100
++++ proftpd-1.3.5/src/wtmp.c 2015-04-03 11:47:21.710554599 +0200
+@@ -136,11 +136,33 @@ int log_wtmp(const char *line, const cha
struct utmp ut;
- int res = 0;
-- static int fd = -1;
-
- #if defined(SVR4) || defined(__SVR4)
--#if !(defined(LINUX) || defined(__hpux) || defined (_AIX))
-+#if !(defined(__hpux) || defined (_AIX))
-+#if (defined(LINUX) && defined(__GLIBC__))
- /* This "auxilliary" utmp doesn't exist under linux. */
- struct utmpx utx;
-- static int fdx = -1;
--
-- if(fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY | O_APPEND, 0)) < 0) {
-- log_pri(LOG_WARNING,"wtmpx %s: %s",WTMPX_FILE,strerror(errno));
-- return -1;
-- }
-
- /* Unfortunately, utmp string fields are terminated by '\0' if they are
- * shorter than the size of the field, but if they are exactly the size of
-@@ -551,7 +544,6 @@
- * Insane if you ask me. Unless there's massive uproar, I prefer to err on
- * the side of caution and always null-terminate our strings.
- */
-- if(fstat(fdx,&buf) == 0) {
- memset(&utx,0,sizeof(utx));
- sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
- sstrncpy(utx.ut_id,"ftp",sizeof(utx.ut_user));
-@@ -566,22 +558,12 @@
- utx.ut_type = DEAD_PROCESS;
- utx.ut_exit.e_termination = 0;
- utx.ut_exit.e_exit = 0;
-- if(write(fdx,(char*)&utx,sizeof(utx)) != sizeof(utx))
-- ftruncate(fdx, buf.st_size);
-- } else {
-- log_debug(DEBUG0,"%s fstat(): %s",WTMPX_FILE,strerror(errno));
-- res = -1;
-- }
-+ updwtmpx(_PATH_WTMP, &utx);
+ static int fd = -1;
- #endif
++#if defined(HAVE_UTMPX_H)
++#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
++# define WTMPX_FILE _PATH_WTMPX
+#endif
- #endif /* SVR4 */
-
-- if(fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
-- log_pri(LOG_WARNING,"wtmp %s: %s",WTMP_FILE,strerror(errno));
-- return -1;
-- }
--
-- if(fstat(fd,&buf) == 0) {
- memset(&ut,0,sizeof(ut));
- #ifdef HAVE_UTMAXTYPE
- #ifdef LINUX
-@@ -612,12 +594,7 @@
- #endif /* HAVE_UT_UT_HOST */
++ static char *wtmp_file = NULL;
++ if (wtmp_file == NULL) {
++ if (access(WTMPX_FILE"x", F_OK) == 0)
++ wtmp_file = WTMPX_FILE"x";
++ else if (access(WTMPX_FILE, F_OK) == 0)
++ wtmp_file = WTMPX_FILE;
++ else if (access(WTMP_FILE"x", F_OK) == 0)
++ wtmp_file = WTMP_FILE"x";
++ else if (access(WTMP_FILE, F_OK) == 0)
++ wtmp_file = WTMP_FILE;
++ else {
++ pr_log_pri(PR_LOG_WARNING, "cannot find "WTMPX_FILE);
++ return -1;
++ }
++ }
++#else
++ static char *wtmp_file = WTMP_FILE;
++#endif
+ if (fd < 0 &&
+- (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
++ (fd = open(wtmp_file, O_WRONLY|O_APPEND, 0)) < 0) {
+ int xerrno = errno;
- time(&ut.ut_time);
-- if(write(fd,(char*)&ut,sizeof(ut)) != sizeof(ut))
-- ftruncate(fd,buf.st_size);
-- } else {
-- log_debug(DEBUG0,"%s fstat(): %s",WTMP_FILE,strerror(errno));
-- res = -1;
-- }
-+ updwtmp(_PATH_WTMP, &ut);
+- pr_log_pri(PR_LOG_WARNING, "failed to open wtmp %s: %s", WTMP_FILE,
++ pr_log_pri(PR_LOG_WARNING, "failed to open wtmp %s: %s", wtmp_file,
+ strerror(xerrno));
- return res;
- }
+ errno = xerrno;