]> TLD Linux GIT Repositories - packages/proftpd.git/blob - proftpd-wtmp.patch
- updated to 1.3.8b
[packages/proftpd.git] / proftpd-wtmp.patch
1 diff -ruNp proftpd-1.3.5.orig/src/wtmp.c proftpd-1.3.5/src/wtmp.c
2 --- proftpd-1.3.5.orig/src/wtmp.c       2013-12-09 20:16:15.000000000 +0100
3 +++ proftpd-1.3.5/src/wtmp.c    2015-04-03 11:47:21.710554599 +0200
4 @@ -136,11 +136,33 @@ int log_wtmp(const char *line, const cha
5    struct utmp ut;
6    static int fd = -1;
7  
8 +#if defined(HAVE_UTMPX_H)
9 +#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
10 +# define WTMPX_FILE _PATH_WTMPX
11 +#endif
12 +  static char *wtmp_file = NULL;
13 +  if (wtmp_file == NULL) {
14 +    if (access(WTMPX_FILE"x", F_OK) == 0)
15 +      wtmp_file = WTMPX_FILE"x";
16 +    else if (access(WTMPX_FILE, F_OK) == 0)
17 +      wtmp_file = WTMPX_FILE;
18 +    else if (access(WTMP_FILE"x", F_OK) == 0)
19 +      wtmp_file = WTMP_FILE"x";
20 +    else if (access(WTMP_FILE, F_OK) == 0)
21 +      wtmp_file = WTMP_FILE;
22 +    else {
23 +      pr_log_pri(PR_LOG_WARNING, "cannot find "WTMPX_FILE);
24 +      return -1;
25 +    }
26 +  }
27 +#else
28 +  static char *wtmp_file = WTMP_FILE;
29 +#endif
30    if (fd < 0 &&
31 -      (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
32 +      (fd = open(wtmp_file, O_WRONLY|O_APPEND, 0)) < 0) {
33      int xerrno = errno;
34  
35 -    pr_log_pri(PR_LOG_WARNING, "failed to open wtmp %s: %s", WTMP_FILE,
36 +    pr_log_pri(PR_LOG_WARNING, "failed to open wtmp %s: %s", wtmp_file,
37        strerror(xerrno));
38  
39      errno = xerrno;