]> git.pld-linux.org Git - packages/proftpd.git/blame - proftpd-wtmp.patch
- restore pre-1.3.3 /var/run/proftpd path
[packages/proftpd.git] / proftpd-wtmp.patch
CommitLineData
5c7e80b4
ER
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
082251a8
JR
3@@ -70,7 +70,7 @@
4 #undef HAVE_UT_UT_HOST
5
6 /* Define if your struct utmp uses ut_user and not ut_name */
7-#undef HAVE_UTMAXTYPE
8+#undef HAVE_UT_UT_USER
9
10 #define PF_ARGV_NONE 0
11 #define PF_ARGV_NEW 1
5c7e80b4
ER
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
14@@ -122,7 +122,7 @@
082251a8
JR
15 #undef HAVE_UT_UT_HOST
16
17 /* Define if your struct utmp uses ut_user and not ut_name */
18-#undef HAVE_UTMAXTYPE
19+#undef HAVE_UT_UT_USER
20
21 #define PF_ARGV_NONE 0
22 #define PF_ARGV_NEW 1
371db41d 23diff -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
02396a1f
JR
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)
371db41d 30-AC_CHECK_HEADERS(ucred.h ucontext.h utime.h utmpx.h)
02396a1f
JR
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)
371db41d 35@@ -1211,10 +1211,10 @@ AC_CHECK_HEADERS(utmp.h, have_utmp=1, ha
12bef652 36
02396a1f 37 if test $have_utmp; then
371db41d 38 AC_CACHE_CHECK(whether struct utmp has ut_user,
02396a1f 39- pr_cv_header_utmaxtype,
371db41d 40+ pr_cv_header_ut_user,
02396a1f
JR
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"))
371db41d 46 AC_CACHE_CHECK(whether struct utmp has ut_host,
02396a1f
JR
47 pr_cv_header_ut_host,
48 AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
371db41d 49@@ -1225,7 +1225,7 @@ if test $have_utmp; then
02396a1f
JR
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
02396a1f 54+ if test "$pr_cv_header_ut_user" = "yes"; then
371db41d 55 AC_DEFINE(HAVE_UTMAXTYPE, 1, [If struct utmp has ut_user.])
02396a1f
JR
56 fi
57 if test "$pr_cv_header_ut_host" = "yes"; then
371db41d 58@@ -1236,6 +1236,28 @@ if test $have_utmp; then
02396a1f
JR
59 fi
60 fi
61
62+dnl See what type of utmp exists
63+AC_CHECK_HEADERS(utmpx.h, have_utmpx=1, have_utmpx=0)
64+
65+if test $have_utmpx; then
66+ AC_CACHE_CHECK(whether your struct utmpx has ut_exit,
371db41d 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"))
02396a1f 71+ AC_CACHE_CHECK(whether your struct utmpx has ut_syslen,
371db41d 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"))
02396a1f
JR
76+ if test "$pr_cv_header_utx_exit" = "yes"; then
77+ AC_DEFINE(HAVE_UTX_UT_EXIT, 1, [If struct utmpx has ut_exit.])
78+ fi
79+ if test "$pr_cv_header_utx_syslen" = "yes"; then
80+ AC_DEFINE(HAVE_UTX_UT_SYSLEN, 1, [If struct utmpx has ut_syslen.])
81+ fi
82+fi
83+
84 dnl See if various LOG_ macros are defined
85 if test "$have_syslog_h" = "yes"; then
86 AC_DEFINE(HAVE_SYSLOG_H)
371db41d 87diff -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
91 struct utmp ut;
728c4cc1 92 int res = 0;
02396a1f 93 static int fd = -1;
371db41d 94+#if defined(HAVE_UTMPX_H)
95+ char *wtmpx_file = NULL;
96+ static int fdx = -1;
97+
98+#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
99+# define WTMPX_FILE _PATH_WTMPX
100+#endif
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");
02396a1f 105
7b7692b8
ER
106-#if ((defined(SVR4) || defined(__SVR4)) || \
107- (defined(__NetBSD__) && defined(HAVE_UTMPX_H))) && \
12bef652 108- !(defined(LINUX) || defined(__hpux) || defined (_AIX))
ff5ecb89 109- /* This "auxilliary" utmp doesn't exist under linux. */
371db41d 110+ if (fdx >= 0 || wtmpx_file != NULL)
111+ {
112 #if defined(__sparcv9) && !defined(__NetBSD__)
113 struct futmpx utx;
8db28cde 114- time_t t;
371db41d 115 #else
116 struct utmpx utx;
8db28cde 117-#endif
371db41d 118- static int fdx = -1;
119-
120-#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX)
121-# define WTMPX_FILE _PATH_WTMPX
122+ time_t t;
618dd610 123 #endif
52be463f
JR
124
125- if (fdx < 0 &&
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));
371db41d 128+ if (fdx < 0 && (fdx = open(wtmpx_file, O_WRONLY|O_APPEND, 0)) < 0) {
ba9b13ed 129+ pr_log_pri(PR_LOG_WARNING, "wtmpx %s: %s", wtmpx_file, strerror(errno));
371db41d 130 return -1;
131 }
02396a1f 132
371db41d 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.
136 */
137+
138 if (fstat(fdx, &buf) == 0) {
139 memset(&utx, 0, sizeof(utx));
140-
141+ if (name && *name) {
142 sstrncpy(utx.ut_user, name, sizeof(utx.ut_user));
850a3e73 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));
371db41d 146- utx.ut_pid = session.pid ? session.pid : getpid();
7b7692b8
ER
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);
150-#else /* SVR4 */
151- utx.ut_syslen = strlen(utx.ut_host)+1;
152-# ifdef __sparcv9
8db28cde
PG
153- time(&t);
154- utx.ut_tv.tv_sec = (time32_t)t;
7b7692b8 155-# else
ff5ecb89 156- time(&utx.ut_tv.tv_sec);
7b7692b8
ER
157-# endif
158-#endif /* SVR4 */
371db41d 159-
4c6dc458 160- if (*name)
371db41d 161 utx.ut_type = USER_PROCESS;
ff5ecb89 162- else
02396a1f 163+ } else {
371db41d 164 utx.ut_type = DEAD_PROCESS;
165-#ifdef HAVE_UT_UT_EXIT
02396a1f
JR
166+ }
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));
170+ if (host && *host)
171+ sstrncpy(utx.ut_host, host, sizeof(utx.ut_host));
172+#ifdef HAVE_UTX_UT_EXIT
371db41d 173 utx.ut_exit.e_termination = 0;
174 utx.ut_exit.e_exit = 0;
02396a1f 175 #endif /* HAVE_UT_UT_EXIT */
02396a1f
JR
176+#ifdef HAVE_UTX_UT_SYSLEN
177+ utx.ut_syslen = strlen(utx.ut_host)+1;
178+#endif
179+#if defined(__NetBSD__)
180+ memcpy(&utx.ut_ss, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_ss));
181+ gettimeofday(&utx.ut_tv, NULL);
182+#else
183+ time(&t);
7da49512 184+ utx.ut_tv.tv_sec = t;
02396a1f 185+#endif
02396a1f
JR
186+ if (ip)
187+#ifndef PR_USE_IPV6
188+ memcpy(&utx.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr));
189+#else
190+ memcpy(&utx.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(utx.ut_addr_v6));
191+#endif /* !PR_USE_IPV6 */
371db41d 192 if (write(fdx, (char *)&utx, sizeof(utx)) != sizeof(utx))
193- (void) ftruncate(fdx, buf.st_size);
194-
ee1ec582 195+ (void )ftruncate(fdx, buf.st_size);
371db41d 196 } else {
197- pr_log_debug(DEBUG0, "%s fstat(): %s", WTMPX_FILE, strerror(errno));
ba9b13ed 198+ pr_log_debug(DEBUG0, "%s fstat(): %s", wtmpx_file, strerror(errno));
371db41d 199 res = -1;
200 }
201-
202-#else /* Non-SVR4 systems */
203-
204- if (fd < 0 &&
205- (fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
52be463f 206+ free(wtmpx_file);
02396a1f
JR
207+ return res;
208+ }
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));
212 return -1;
213 }
7b7692b8 214
02396a1f 215 if (fstat(fd, &buf) == 0) {
850a3e73 216 memset(&ut, 0, sizeof(ut));
02396a1f
JR
217-#ifdef HAVE_UTMAXTYPE
218-# ifdef LINUX
219- if (ip)
220-# ifndef PR_USE_IPV6
221- memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
222-# else
223- memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
224-# endif /* !PR_USE_IPV6 */
225-# else
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));
233- if (name && *name)
234+ if (name && *name) {
235+#ifdef HAVE_UT_UT_USER
236 sstrncpy(ut.ut_user, name, sizeof(ut.ut_user));
371db41d 237- ut.ut_pid = session.pid ? session.pid : getpid();
02396a1f
JR
238- if (name && *name)
239+#else
371db41d 240+ sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
02396a1f
JR
241+#endif
242 ut.ut_type = USER_PROCESS;
243- else
244+ } else {
245 ut.ut_type = DEAD_PROCESS;
246-#else /* !HAVE_UTMAXTYPE */
247+ }
371db41d 248+ ut.ut_pid = session.pid ? session.pid : getpid();
02396a1f
JR
249 sstrncpy(ut.ut_line, line, sizeof(ut.ut_line));
250- if (name && *name)
251- sstrncpy(ut.ut_name, name, sizeof(ut.ut_name));
252-#endif /* HAVE_UTMAXTYPE */
02396a1f 253+ sstrncpy(ut.ut_id, "ftp", sizeof(ut.ut_id));
371db41d 254
02396a1f
JR
255 #ifdef HAVE_UT_UT_HOST
256 if (host && *host)
257 sstrncpy(ut.ut_host, host, sizeof(ut.ut_host));
728c4cc1 258 #endif /* HAVE_UT_UT_HOST */
371db41d 259
02396a1f
JR
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 */
371db41d 264+
265 ut.ut_time = time(NULL);
02396a1f
JR
266+ if (ip)
267+#ifndef PR_USE_IPV6
268+ memcpy(&ut.ut_addr, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr));
269+#else
270+ memcpy(&ut.ut_addr_v6, pr_netaddr_get_inaddr(ip), sizeof(ut.ut_addr_v6));
271+#endif /* !PR_USE_IPV6 */
272+
371db41d 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,
276 strerror(errno));
277 }
278 }
850a3e73 279-
02396a1f 280 } else {
371db41d 281 pr_log_debug(DEBUG0, "%s fstat(): %s", WTMP_FILE, strerror(errno));
02396a1f 282 res = -1;
This page took 0.11731 seconds and 4 git commands to generate.