summaryrefslogtreecommitdiff
path: root/net/wu-ftpd/patches/patch-ai
blob: cb2df8826eef3c0a838bf9aea6bc15b71467aa00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
$NetBSD: patch-ai,v 1.11 2012/04/08 04:43:51 dholland Exp $

- support netbsd-6 libquota
- avoid build failure on netbsd 5.99 proplib quotas
- support dragonfly quotas
- support 4.4BSD quotas
- don't declare own errno
- prune remote hostnames longer than UT_HOSTSIZE from utmp.h
- use va_list correctly
- use snprintf

--- src/ftpd.c.orig	2012-04-08 04:32:17.000000000 +0000
+++ src/ftpd.c
@@ -75,6 +75,7 @@
 #include <grp.h>
 #endif
 #include <sys/stat.h>
+#include <utmp.h>
 
 #define VA_LOCAL_DECL	va_list ap;
 #define VA_START(f)	va_start(ap, f)
@@ -82,12 +83,29 @@
 
 #include "proto.h"
 
+#ifdef HAVE_QUOTA_H
+#define HAVE_NETBSD_LIBQUOTA
+#include <quota.h>
+#endif
+
 #ifdef HAVE_UFS_QUOTA_H
 #include <ufs/quota.h>
 #endif
+
+#if defined(__DragonFly__) && __DragonFly_version >= 160000
+#define dqblk ufs_dqblk
+#endif
+
 #ifdef HAVE_SYS_FS_UFS_QUOTA_H
 #include <sys/fs/ufs_quota.h>
 #endif
+#ifdef HAVE_UFS_UFS_QUOTA_H
+#include <ufs/ufs/quota.h>
+#ifdef UFS_QUOTA_ENTRY_NAMES
+/* netbsd 5.99 proplib quota interface (march 2011-january 2012) - punt */
+#undef QUOTA
+#endif
+#endif
 
 #ifdef HAVE_SYS_SYSLOG_H
 #include <sys/syslog.h>
@@ -214,7 +232,6 @@ int Send(FILE *sockfp, char *format,...)
 
 /* File containing login names NOT to be used on this machine. Commonly used
  * to disallow uucp. */
-extern int errno;
 extern int pidfd;
 
 extern char *ctime(const time_t *);
@@ -254,8 +271,10 @@ extern int virtual_ftpaccess;
 #endif
 
 #ifdef QUOTA
+#ifndef HAVE_NETBSD_LIBQUOTA
 extern struct dqblk quota;
 #endif
+#endif
 
 int data;
 jmp_buf errcatch;
@@ -2370,7 +2389,8 @@ void end_login(void)
     (void) seteuid((uid_t) 0);
     if (logged_in)
 	if (wtmp_logging)
-	    wu_logwtmp(ttyline, pw->pw_name, remotehost, 0);
+	    wu_logwtmp(ttyline, pw->pw_name, strlen(remotehost) > UT_HOSTSIZE
+		       ? remoteaddr : remotehost, 0);
     pw = NULL;
 #ifdef AFS_AUTH
     ktc_ForgetAllTokens();
@@ -2869,14 +2889,18 @@ void pass(char *passwd)
 #ifdef DEBUG
 	syslog(LOG_DEBUG, "about to call wtmp");
 #endif
-	wu_logwtmp(ttyline, pw->pw_name, remotehost, 1);
+	wu_logwtmp(ttyline, pw->pw_name, strlen(remotehost) > UT_HOSTSIZE
+		       ? remoteaddr : remotehost, 1);
     }
     logged_in = 1;
 
     expand_id();
 
 #ifdef QUOTA
+#ifndef HAVE_NETBSD_LIBQUOTA
+    /* the code for the libquota case clears the quotas for us on failure */
     memset(&quota, 0, sizeof(quota));
+#endif
     get_quota(pw->pw_dir, pw->pw_uid);
 #endif
 
@@ -5459,7 +5483,9 @@ void reply(int n, char *fmt,...)
 		*p = '\0';
 
 	    /* send a line...(note that this overrides dolreplies!) */
+	    VA_START(fmt);
 	    vreply(USE_REPLY_LONG | USE_REPLY_NOTFMT, n, ptr, ap);
+	    VA_END; /* *NEVER* send a 0 as an ap, some machines use a *struct* for a va_list! */
 
 	    if (p)
 		ptr = p + 1;	/* set to the next line... (\0 is handled in the while) */
@@ -6083,6 +6109,8 @@ void dologout(int status)
 	(void) seteuid((uid_t) 0);
 	if (wtmp_logging)
 	    wu_logwtmp(ttyline, pw->pw_name, remotehost, 0);
+	    wu_logwtmp(ttyline, pw->pw_name, strlen(remotehost) > UT_HOSTSIZE
+		       ? remoteaddr : remotehost, 0);
     }
     if (logging)
 	syslog(LOG_INFO, "FTP session closed");
@@ -7378,7 +7406,7 @@ int SockPrintf(FILE *sockfp, char *forma
     char buf[32768];
 
     va_start(ap, format);
-    vsprintf(buf, format, ap);
+    vsnprintf(buf, sizeof(buf), format, ap);
     va_end(ap);
     return SockWrite(buf, 1, strlen(buf), sockfp);
 }