]> TLD Linux GIT Repositories - packages/proftpd.git/blobdiff - proftpd-wtmp.patch
- merged changes from PLD
[packages/proftpd.git] / proftpd-wtmp.patch
diff --git a/proftpd-wtmp.patch b/proftpd-wtmp.patch
new file mode 100644 (file)
index 0000000..fb84cbd
--- /dev/null
@@ -0,0 +1,39 @@
+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;
+   static int fd = -1;
++#if defined(HAVE_UTMPX_H)
++#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
++# define WTMPX_FILE _PATH_WTMPX
++#endif
++  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;
+-    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));
+     errno = xerrno;