summaryrefslogtreecommitdiff
path: root/sysutils/busybox/files/patch-002
blob: 6aa761a5d461a447912e8056fd54e6d5cd0f37a9 (plain) (blame)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
diff -ubwr ./include/libbb.h ../../work.patched/busybox-1.13.4/include/libbb.h
--- ./include/libbb.h	2009-04-15 02:09:42.000000000 +0200
+++ ../../work.patched/busybox-1.13.4/include/libbb.h	2009-06-25 23:05:54.000000000 +0200
@@ -29,6 +29,10 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/socket.h>
+#if defined __FreeBSD__
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -86,7 +90,11 @@
 /* This is declared here rather than #including <libgen.h> in order to avoid
  * confusing the two versions of basename.  See the dirname/basename man page
  * for details. */
+#if !defined __FreeBSD__
+#endif
+#if !defined __FreeBSD__
 char *dirname(char *path);
+#endif
 /* Include our own copy of struct sysinfo to avoid binary compatibility
  * problems with Linux 2.4, which changed things.  Grumble, grumble. */
 struct sysinfo {
diff -ubwr ./include/platform.h ../../work.patched/busybox-1.13.4/include/platform.h
--- ./include/platform.h	2008-11-09 18:28:17.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/include/platform.h	2009-06-25 23:05:54.000000000 +0200
@@ -116,6 +116,14 @@
 # include <sex.h>
 # define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN)
 # define __BYTE_ORDER BYTE_ORDER
+#elif defined __FreeBSD__
+char *strchrnul(const char *s, int c);
+# include <sys/resource.h>	// rlimit
+# include <machine/endian.h>
+# define bswap_64 __bswap64
+# define bswap_32 __bswap32
+# define bswap_16 __bswap16
+# define __BIG_ENDIAN__ (_BYTE_ORDER == _BIG_ENDIAN)
 #elif !defined __APPLE__
 # include <byteswap.h>
 # include <endian.h>
@@ -164,7 +172,7 @@
 
 #ifndef __APPLE__
 # include <arpa/inet.h>
-# ifndef __socklen_t_defined
+# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
 typedef int socklen_t;
 # endif
 #else
@@ -173,7 +181,7 @@
 
 /* ---- Compiler dependent settings ------------------------- */
 
-#if (defined __digital__ && defined __unix__) || defined __APPLE__
+#if (defined __digital__ && defined __unix__) || defined __APPLE__ || defined __FreeBSD__
 # undef HAVE_MNTENT_H
 # undef HAVE_SYS_STATFS_H
 #else
diff -ubwr ./libbb/bb_askpass.c ../../work.patched/busybox-1.13.4/libbb/bb_askpass.c
--- ./libbb/bb_askpass.c	2008-11-09 18:28:09.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/bb_askpass.c	2009-06-25 23:05:54.000000000 +0200
@@ -35,6 +35,9 @@
 	tcgetattr(STDIN_FILENO, &oldtio);
 	tcflush(STDIN_FILENO, TCIFLUSH);
 	tio = oldtio;
+#if !defined IUCLC
+#define IUCLC 0
+#endif
 	tio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
 	tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP);
 	tcsetattr_stdin_TCSANOW(&tio);
diff -ubwr ./libbb/getpty.c ../../work.patched/busybox-1.13.4/libbb/getpty.c
--- ./libbb/getpty.c	2008-11-09 18:28:09.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/getpty.c	2009-06-25 23:09:02.000000000 +0200
@@ -19,7 +19,7 @@
 	if (p > 0) {
 		grantpt(p); /* chmod+chown corresponding slave pty */
 		unlockpt(p); /* (what does this do?) */
-#if 0 /* if ptsname_r is not available... */
+#if 1 /* if ptsname_r is not available... */
 		const char *name;
 		name = ptsname(p); /* find out the name of slave pty */
 		if (!name) {
diff -ubwr ./libbb/lineedit.c ../../work.patched/busybox-1.13.4/libbb/lineedit.c
--- ./libbb/lineedit.c	2008-11-29 07:48:56.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/lineedit.c	2009-06-25 23:05:54.000000000 +0200
@@ -78,6 +78,7 @@
 #if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
 static const char null_str[] ALIGN1 = "";
 #endif
+typedef void (*sighandler_t)(int signum);
 
 /* We try to minimize both static and stack usage. */
 struct lineedit_statics {
diff -ubwr ./libbb/login.c ../../work.patched/busybox-1.13.4/libbb/login.c
--- ./libbb/login.c	2008-11-09 18:28:09.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/login.c	2009-06-25 23:05:54.000000000 +0200
@@ -62,10 +62,12 @@
 			case 'm':
 				outbuf = uts.machine;
 				break;
+#if 0
 			case 'D':
 			case 'o':
 				outbuf = uts.domainname;
 				break;
+#endif
 			case 'd':
 				strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
 				break;
diff -ubwr ./libbb/makedev.c ../../work.patched/busybox-1.13.4/libbb/makedev.c
--- ./libbb/makedev.c	2008-11-09 18:28:09.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/makedev.c	2009-06-25 23:05:54.000000000 +0200
@@ -5,7 +5,7 @@
  *
  * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  */
-
+#if !defined __FreeBSD__
 /* We do not include libbb.h - #define makedev() is there! */
 #include "platform.h"
 #include <features.h>
@@ -22,3 +22,4 @@
 	return makedev(major, minor);
 }
 #endif
+#endif /* !__FreeBSD__ */
diff -ubwr ./libbb/match_fstype.c ../../work.patched/busybox-1.13.4/libbb/match_fstype.c
--- ./libbb/match_fstype.c	2008-11-09 18:28:09.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/match_fstype.c	2009-06-25 23:05:54.000000000 +0200
@@ -10,6 +10,7 @@
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
+#if !defined __FreeBSD__
 #include "libbb.h"
 
 int FAST_FUNC match_fstype(const struct mntent *mt, const char *fstype)
@@ -42,3 +43,4 @@
 
 	return -(no + 1);
 }
+#endif /* !__FreeBSD__ */
diff -ubwr ./libbb/safe_gethostname.c ../../work.patched/busybox-1.13.4/libbb/safe_gethostname.c
--- ./libbb/safe_gethostname.c	2008-11-09 18:28:09.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/safe_gethostname.c	2009-06-25 23:05:54.000000000 +0200
@@ -62,5 +62,5 @@
 	struct utsname uts;
 
 	uname(&uts);
-	return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));
+	return xstrndup("?", 2); // !uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));
 }
diff -ubwr ./libbb/xconnect.c ../../work.patched/busybox-1.13.4/libbb/xconnect.c
--- ./libbb/xconnect.c	2008-12-31 04:06:45.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/xconnect.c	2009-06-25 23:05:54.000000000 +0200
@@ -7,6 +7,7 @@
  */
 
 #include <netinet/in.h>
+#include <sys/socket.h>	// struct sockaddr
 #include <net/if.h>
 #include "libbb.h"
 
@@ -26,7 +27,7 @@
 	/* Actually, ifr_name is at offset 0, and in practice
 	 * just giving char[IFNAMSIZ] instead of struct ifreq works too.
 	 * But just in case it's not true on some obscure arch... */
-	r = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr));
+	r = -1; //setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr));
 	if (r)
 		bb_perror_msg("can't bind to interface %s", iface);
 	return r;
diff -ubwr ./libbb/xfuncs.c ../../work.patched/busybox-1.13.4/libbb/xfuncs.c
--- ./libbb/xfuncs.c	2008-11-09 18:28:09.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/xfuncs.c	2009-06-25 23:05:54.000000000 +0200
@@ -226,8 +226,9 @@
 	long size;
 
 	// If the ioctl works for this, return it.
-
+#if !defined __FreeBSD__
 	if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512;
+#endif
 
 	// FIXME: explain why lseek(SEEK_END) is not used here!
 
diff -ubwr ./libbb/xfuncs_printf.c ../../work.patched/busybox-1.13.4/libbb/xfuncs_printf.c
--- ./libbb/xfuncs_printf.c	2008-11-09 18:28:09.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libbb/xfuncs_printf.c	2009-06-25 23:05:54.000000000 +0200
@@ -294,8 +294,8 @@
 	return string_ptr;
 }
 
-#if 0 /* If we will ever meet a libc which hasn't [f]dprintf... */
-int FAST_FUNC fdprintf(int fd, const char *format, ...)
+#if 1 /* If we will ever meet a libc which hasn't [f]dprintf... */
+int FAST_FUNC dprintf(int fd, const char *format, ...)
 {
 	va_list p;
 	int r;
@@ -326,6 +326,32 @@
 	return r;
 }
 #endif
+char *strchrnul(const char *s, int c)
+{
+	char *r = strchr(s, c);
+	if (r == NULL)
+		r = (char *)s + strlen(s);
+	return r;
+}
+#if 0
+void *memrchr(const void *s, int c, size_t n)
+{
+	const char *p = s;
+	for (p += n - 1; p != s; p--)
+		if (*p == c) break;
+	return (*p == c ? p : NULL);
+}
+#endif
+
+size_t strnlen(const char *s, size_t maxlen)
+{
+	size_t i;
+	for (i = 0; i < maxlen; i++) {
+		if (s[i] == '\0')
+			break;
+	}
+	return i;
+}
 
 void FAST_FUNC xsetenv(const char *key, const char *value)
 {
diff -ubwr ./libpwdgrp/pwd_grp.c ../../work.patched/busybox-1.13.4/libpwdgrp/pwd_grp.c
--- ./libpwdgrp/pwd_grp.c	2008-11-09 18:28:19.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/libpwdgrp/pwd_grp.c	2009-06-25 23:05:54.000000000 +0200
@@ -19,7 +19,9 @@
  */
 
 #include "libbb.h"
+#if !defined __FreeBSD__
 #include <features.h>
+#endif
 #include <assert.h>
 
 #ifndef _PATH_SHADOW
diff -ubwr ./networking/nslookup.c ../../work.patched/busybox-1.13.4/networking/nslookup.c
--- ./networking/nslookup.c	2008-11-09 18:27:59.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/networking/nslookup.c	2009-06-25 23:05:54.000000000 +0200
@@ -11,6 +11,8 @@
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
+#include <netinet/in.h>
+#include <sys/socket.h>
 #include <resolv.h>
 #include "libbb.h"
 
diff -ubwr ./networking/telnetd.c ../../work.patched/busybox-1.13.4/networking/telnetd.c
--- ./networking/telnetd.c	2008-11-09 18:27:59.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/networking/telnetd.c	2009-06-25 23:05:54.000000000 +0200
@@ -254,7 +254,7 @@
 	 * cooked mode, and with XTABS CRMOD enabled (see tty(4)). */
 	tcgetattr(0, &termbuf);
 	termbuf.c_lflag |= ECHO; /* if we use readline we dont want this */
-	termbuf.c_oflag |= ONLCR | XTABS;
+	termbuf.c_oflag |= ONLCR | OXTABS;
 	termbuf.c_iflag |= ICRNL;
 	termbuf.c_iflag &= ~IXOFF;
 	/*termbuf.c_lflag &= ~ICANON;*/
diff -ubwr ./networking/traceroute.c ../../work.patched/busybox-1.13.4/networking/traceroute.c
--- ./networking/traceroute.c	2008-11-09 18:27:59.000000000 +0100
+++ ../../work.patched/busybox-1.13.4/networking/traceroute.c	2009-06-25 23:05:54.000000000 +0200
@@ -205,9 +205,10 @@
 //#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP
 
 
-#include <net/if.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
+#include <sys/socket.h>
+#include <net/if.h>
 #include <netinet/udp.h>
 #include <netinet/ip.h>
 #include <netinet/ip_icmp.h>
@@ -638,7 +639,7 @@
 		outicmp->icmp_seq = htons(seq);
 	else
 #endif
-		outudp->dest = htons(port + seq);
+		outudp->uh_dport = htons(port + seq);
 
 #if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
 	if (useicmp) {
@@ -660,11 +661,11 @@
 		ui->ui_src = oui->ui_src;
 		ui->ui_dst = oui->ui_dst;
 		ui->ui_pr = oui->ui_pr;
-		ui->ui_len = outudp->len;
-		outudp->check = 0;
-		outudp->check = in_cksum((uint16_t *)ui, packlen);
-		if (outudp->check == 0)
-			outudp->check = 0xffff;
+		ui->ui_len = outudp->uh_ulen;
+		outudp->uh_sum = 0;
+		outudp->uh_sum = in_cksum((uint16_t *)ui, packlen);
+		if (outudp->uh_sum == 0)
+			outudp->uh_sum = 0xffff;
 		*outip = tip;
 	}
 
@@ -792,8 +793,8 @@
 			/* XXX 8 is a magic number */
 			if (hlen + 12 <= cc &&
 			    hip->ip_p == IPPROTO_UDP &&
-			    up->source == htons(ident) &&
-			    up->dest == htons(port + seq))
+			    up->uh_sport == htons(ident) &&
+			    up->uh_dport == htons(port + seq))
 				return (type == ICMP_TIMXCEED ? -1 : code + 1);
 		}
 	}
@@ -1148,8 +1149,8 @@
 	{
 		outip->ip_p = IPPROTO_UDP;
 		outudp = (struct udphdr *)outp;
-		outudp->source = htons(ident);
-		outudp->len = htons((uint16_t)(packlen - (sizeof(*outip) + optlen)));
+		outudp->uh_sport = htons(ident);
+		outudp->uh_ulen = htons((uint16_t)(packlen - (sizeof(*outip) + optlen)));
 		outdata = (outdata_t *)(outudp + 1);
 	}