Package: freebsd-utils / 10.1~svn273304-1

pf_regex_c.diff Patch series | download
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
#!/bin/bash

# You can execute this patch in order to generate a patched directory

for d in b/src/contrib/pf ; do \
	for f in $(find $d -type f -name \*.c -or -name \*.y -or -name \*.h | grep -v "/\.svn/") ; do \
		sed -i $f \
			-e 's/defined\( \|\t\)*(\( \|\t\)*__FreeBSD__\( \|\t\)*)/1/g' \
			-e 's/#\( \|\t\)*ifdef\( \|\t\)*__FreeBSD__/#if 1/g' \
			-e 's/#\( \|\t\)*ifndef\( \|\t\)*__FreeBSD__/#if 0/g' \
		; done \
	; done

exit 0

Index: freebsd-utils-jessie/src/contrib/pf/authpf/authpf.c
===================================================================
--- freebsd-utils-jessie.orig/src/contrib/pf/authpf/authpf.c
+++ freebsd-utils-jessie/src/contrib/pf/authpf/authpf.c
@@ -33,7 +33,7 @@ __FBSDID("$FreeBSD: stable/10/contrib/pf
 
 #include <err.h>
 #include <errno.h>
-#ifdef __FreeBSD__
+#if 1
 #include <inttypes.h>
 #endif
 #include <login_cap.h>
@@ -74,7 +74,7 @@ struct timeval	Tstart, Tend;	/* start an
 
 volatile sig_atomic_t	want_death;
 static void		need_death(int signo);
-#ifdef __FreeBSD__
+#if 1
 static __dead2 void	do_death(int);
 #else
 static __dead void	do_death(int);
@@ -155,7 +155,7 @@ main(void)
 	else
 		shell = pw->pw_shell;
 
-#ifndef __FreeBSD__
+#if 0
 	login_close(lc);
 #endif
 
@@ -163,7 +163,7 @@ main(void)
 	    strcmp(shell, PATH_AUTHPF_SHELL_NOIP)) {
 		syslog(LOG_ERR, "wrong shell for user %s, uid %u",
 		    pw->pw_name, pw->pw_uid);
-#ifdef __FreeBSD__
+#if 1
 	login_close(lc);
 #else
 		if (shell != pw->pw_shell)
@@ -172,7 +172,7 @@ main(void)
 		goto die;
 	}
 
-#ifdef __FreeBSD__
+#if 1
 	login_close(lc);
 #else
 	if (shell != pw->pw_shell)
@@ -932,7 +932,7 @@ need_death(int signo __unused)
 /*
  * function that removes our stuff when we go away.
  */
-#ifdef __FreeBSD__
+#if 1
 static __dead2 void
 #else
 static __dead void
Index: freebsd-utils-jessie/src/contrib/pf/ftp-proxy/ftp-proxy.c
===================================================================
--- freebsd-utils-jessie.orig/src/contrib/pf/ftp-proxy/ftp-proxy.c
+++ freebsd-utils-jessie/src/contrib/pf/ftp-proxy/ftp-proxy.c
@@ -585,7 +585,7 @@ logmsg(int pri, const char *message, ...
 
 		/* We don't care about truncation. */
 		vsnprintf(buf, sizeof buf, message, ap);
-#ifdef __FreeBSD__
+#if 1
 		strvis(visbuf, buf, VIS_CSTYLE | VIS_NL);
 #else
 		strnvis(visbuf, buf, sizeof visbuf, VIS_CSTYLE | VIS_NL);
Index: freebsd-utils-jessie/src/contrib/pf/libevent/kqueue.c
===================================================================
--- freebsd-utils-jessie.orig/src/contrib/pf/libevent/kqueue.c
+++ freebsd-utils-jessie/src/contrib/pf/libevent/kqueue.c
@@ -48,7 +48,7 @@
 #include <inttypes.h>
 #endif
 
-#if defined(HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
+#if defined(HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !1
 #define INTPTR(x)	(intptr_t)x
 #else
 #define INTPTR(x)	x
Index: freebsd-utils-jessie/src/contrib/pf/pflogd/pflogd.c
===================================================================
--- freebsd-utils-jessie.orig/src/contrib/pf/pflogd/pflogd.c
+++ freebsd-utils-jessie/src/contrib/pf/pflogd/pflogd.c
@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD: stable/10/contrib/pf
 #include <errno.h>
 #include <stdarg.h>
 #include <fcntl.h>
-#ifdef __FreeBSD__
+#if 1
 #include <ifaddrs.h>
 #include "pidfile.h"
 #else
@@ -161,7 +161,7 @@ logmsg(int pri, const char *message, ...
 	va_end(ap);
 }
 
-#ifdef __FreeBSD__
+#if 1
 __dead2 void
 #else
 __dead void
@@ -215,7 +215,7 @@ set_pcap_filter(void)
 int
 if_exists(char *ifname)
 {
-#ifdef __FreeBSD__
+#if 1
 	struct ifaddrs *ifdata, *mb;
 	int exists = 0;
 
@@ -406,7 +406,7 @@ int
 scan_dump(FILE *fp, off_t size)
 {
 	struct pcap_file_header hdr;
-#ifdef __FreeBSD__
+#if 1
 	struct pcap_sf_pkthdr ph;
 #else
 	struct pcap_pkthdr ph;
@@ -479,7 +479,7 @@ void
 dump_packet_nobuf(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 {
 	FILE *f = (FILE *)user;
-#ifdef __FreeBSD__
+#if 1
 	struct pcap_sf_pkthdr sh;
 #endif
 
@@ -488,7 +488,7 @@ dump_packet_nobuf(u_char *user, const st
 		return;
 	}
 
-#ifdef __FreeBSD__
+#if 1
 	sh.ts.tv_sec = (bpf_int32)h->ts.tv_sec;
 	sh.ts.tv_usec = (bpf_int32)h->ts.tv_usec;
 	sh.caplen = h->caplen;
@@ -501,7 +501,7 @@ dump_packet_nobuf(u_char *user, const st
 		off_t pos = ftello(f);
 
 		/* try to undo header to prevent corruption */
-#ifdef __FreeBSD__
+#if 1
 		if (pos < sizeof(sh) ||
 		    ftruncate(fileno(f), pos - sizeof(sh))) {
 #else
@@ -576,7 +576,7 @@ void
 dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 {
 	FILE *f = (FILE *)user;
-#ifdef __FreeBSD__
+#if 1
 	struct pcap_sf_pkthdr sh;
 	size_t len = sizeof(sh) + h->caplen;
 #else
@@ -609,7 +609,7 @@ dump_packet(u_char *user, const struct p
 	}
 
  append:       
-#ifdef __FreeBSD__
+#if 1
 	sh.ts.tv_sec = (bpf_int32)h->ts.tv_sec;
 	sh.ts.tv_usec = (bpf_int32)h->ts.tv_usec;
 	sh.caplen = h->caplen;
Index: freebsd-utils-jessie/src/contrib/pf/pflogd/pidfile.c
===================================================================
--- freebsd-utils-jessie.orig/src/contrib/pf/pflogd/pidfile.c
+++ freebsd-utils-jessie/src/contrib/pf/pflogd/pidfile.c
@@ -41,7 +41,7 @@ static const char rcsid[] = "$OpenBSD: p
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#ifdef __FreeBSD__
+#if 1
 #include "pidfile.h"
 #else
 #include <util.h>
Index: freebsd-utils-jessie/src/contrib/pf/pflogd/privsep.c
===================================================================
--- freebsd-utils-jessie.orig/src/contrib/pf/pflogd/privsep.c
+++ freebsd-utils-jessie/src/contrib/pf/pflogd/privsep.c
@@ -73,7 +73,7 @@ priv_init(void)
 	int snaplen, ret, olderrno;
 	struct passwd *pw;
 
-#ifdef __FreeBSD__
+#if 1
 	for (i = 1; i < NSIG; i++)
 #else
 	for (i = 1; i < _NSIG; i++)
Index: freebsd-utils-jessie/src/contrib/pf/tftp-proxy/filter.c
===================================================================
--- freebsd-utils-jessie.orig/src/contrib/pf/tftp-proxy/filter.c
+++ freebsd-utils-jessie/src/contrib/pf/tftp-proxy/filter.c
@@ -298,7 +298,7 @@ prepare_rule(u_int32_t id, int rs_num, s
 		pfr.rule.quick = 1;
 		pfr.rule.log = rule_log;
 		pfr.rule.keep_state = 1;
-#ifdef __FreeBSD__
+#if 1
 		pfr.rule.flags = (proto == IPPROTO_TCP ? TH_SYN : 0);
 		pfr.rule.flagset = (proto == IPPROTO_TCP ?
 		    (TH_SYN|TH_ACK|TH_FIN|TH_RST) : 0);
Index: freebsd-utils-jessie/src/sbin/pfctl/parse.y
===================================================================
--- freebsd-utils-jessie.orig/src/sbin/pfctl/parse.y
+++ freebsd-utils-jessie/src/sbin/pfctl/parse.y
@@ -33,7 +33,7 @@ __FBSDID("$FreeBSD: stable/10/sbin/pfctl
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
-#ifdef __FreeBSD__
+#if 1
 #include <sys/sysctl.h>
 #endif
 #include <net/if.h>
@@ -2217,7 +2217,7 @@ pfrule		: action dir logquick interface
 				}
 				free($9.queues.pqname);
 			}
-#ifdef __FreeBSD__
+#if 1
 			r.divert.port = $9.divert.port;
 #else
 			if ((r.divert.port = $9.divert.port)) {
@@ -2362,7 +2362,7 @@ filter_opt	: USER uids {
 			filter_opts.rtableid = $2;
 		}
 		| DIVERTTO portplain {
-#ifdef __FreeBSD__
+#if 1
 			filter_opts.divert.port = $2.a;
 			if (!filter_opts.divert.port) {
 				yyerror("invalid divert port: %u", ntohs($2.a));
@@ -2371,7 +2371,7 @@ filter_opt	: USER uids {
 #endif
 		}
 		| DIVERTTO STRING PORT portplain {
-#ifndef __FreeBSD__
+#if 0
 			if ((filter_opts.divert.addr = host($2)) == NULL) {
 				yyerror("could not parse divert address: %s",
 				    $2);
@@ -2389,7 +2389,7 @@ filter_opt	: USER uids {
 			}
 		}
 		| DIVERTREPLY {
-#ifdef __FreeBSD__
+#if 1
 			yyerror("divert-reply has no meaning in FreeBSD pf(4)");
 			YYERROR;
 #else
@@ -2855,7 +2855,7 @@ host		: STRING			{
 			char	*buf;
 
 			/* ie. for 10/8 parsing */
-#ifdef __FreeBSD__
+#if 1
 			if (asprintf(&buf, "%lld/%lld", (long long)$1, (long long)$3) == -1)
 #else
 			if (asprintf(&buf, "%lld/%lld", $1, $3) == -1)
@@ -6020,7 +6020,7 @@ pfctl_load_anchors(int dev, struct pfctl
 int
 rt_tableid_max(void)
 {
-#ifdef __FreeBSD__
+#if 1
 	int fibs;
 	size_t l = sizeof(fibs);
 
Index: freebsd-utils-jessie/src/sbin/pfctl/pfctl.c
===================================================================
--- freebsd-utils-jessie.orig/src/sbin/pfctl/pfctl.c
+++ freebsd-utils-jessie/src/sbin/pfctl/pfctl.c
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD: stable/10/sbin/pfctl
 #include <sys/socket.h>
 #include <sys/stat.h>
 
-#ifdef __FreeBSD__
+#if 1
 #include <sys/endian.h>
 #endif
 
@@ -251,7 +251,7 @@ pfctl_enable(int dev, int opts)
 	if (ioctl(dev, DIOCSTART)) {
 		if (errno == EEXIST)
 			errx(1, "pf already enabled");
-#ifdef __FreeBSD__
+#if 1
 		else if (errno == ESRCH)
 			errx(1, "pfil registeration failed");
 #endif
@@ -2186,7 +2186,7 @@ main(int argc, char *argv[])
 		/* turn off options */
 		opts &= ~ (PF_OPT_DISABLE | PF_OPT_ENABLE);
 		clearopt = showopt = debugopt = NULL;
-#if defined(__FreeBSD__) && !defined(ENABLE_ALTQ)
+#if 1 && !defined(ENABLE_ALTQ)
 		altqsupport = 0;
 #else
 		altqsupport = 1;
Index: freebsd-utils-jessie/src/sbin/pfctl/pfctl.h
===================================================================
--- freebsd-utils-jessie.orig/src/sbin/pfctl/pfctl.h
+++ freebsd-utils-jessie/src/sbin/pfctl/pfctl.h
@@ -86,7 +86,7 @@ void	 warn_namespace_collision(const cha
 int	 pfctl_show_ifaces(const char *, int);
 FILE	*pfctl_fopen(const char *, const char *);
 
-#ifdef __FreeBSD__
+#if 1
 extern int altqsupport;
 extern int dummynetsupport;
 #define	HTONL(x)		(x) = htonl((__uint32_t)(x))
Index: freebsd-utils-jessie/src/sbin/pfctl/pfctl_altq.c
===================================================================
--- freebsd-utils-jessie.orig/src/sbin/pfctl/pfctl_altq.c
+++ freebsd-utils-jessie/src/sbin/pfctl/pfctl_altq.c
@@ -77,7 +77,7 @@ static int		 gsc_add_seg(struct gen_sc *
 			     double);
 static double		 sc_x2y(struct service_curve *, double);
 
-#ifdef __FreeBSD__
+#if 1
 u_int32_t	getifspeed(int, char *);
 #else
 u_int32_t	 getifspeed(char *);
@@ -153,7 +153,7 @@ print_altq(const struct pf_altq *a, unsi
 		return;
 	}
 
-#ifdef __FreeBSD__
+#if 1
 	if (a->local_flags & PFALTQ_FLAG_IF_REMOVED)
 		printf("INACTIVE ");
 #endif
@@ -193,7 +193,7 @@ print_queue(const struct pf_altq *a, uns
 {
 	unsigned int	i;
 
-#ifdef __FreeBSD__
+#if 1
 	if (a->local_flags & PFALTQ_FLAG_IF_REMOVED)
 		printf("INACTIVE ");
 #endif
@@ -239,7 +239,7 @@ eval_pfaltq(struct pfctl *pf, struct pf_
 	if (bw->bw_absolute > 0)
 		pa->ifbandwidth = bw->bw_absolute;
 	else
-#ifdef __FreeBSD__
+#if 1
 		if ((rate = getifspeed(pf->dev, pa->ifname)) == 0) {
 #else
 		if ((rate = getifspeed(pa->ifname)) == 0) {
@@ -1095,7 +1095,7 @@ rate2str(double rate)
 	return (buf);
 }
 
-#ifdef __FreeBSD__
+#if 1
 /*
  * XXX
  * FreeBSD does not have SIOCGIFDATA.
@@ -1150,7 +1150,7 @@ getifmtu(char *ifname)
 	    sizeof(ifr.ifr_name))
 		errx(1, "getifmtu: strlcpy");
 	if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) == -1)
-#ifdef __FreeBSD__
+#if 1
 		ifr.ifr_mtu = 1500;
 #else
 		err(1, "SIOCGIFMTU");
Index: freebsd-utils-jessie/src/sbin/pfctl/pfctl_optimize.c
===================================================================
--- freebsd-utils-jessie.orig/src/sbin/pfctl/pfctl_optimize.c
+++ freebsd-utils-jessie/src/sbin/pfctl/pfctl_optimize.c
@@ -862,7 +862,7 @@ block_feedback(struct pfctl *pf, struct
 				break;
 			}
 		}
-#ifdef __FreeBSD__
+#if 1
 		if (por2 == NULL)
 #else
 		if (por2 == TAILQ_END(&block->sb_rules))
Index: freebsd-utils-jessie/src/sbin/pfctl/pfctl_parser.c
===================================================================
--- freebsd-utils-jessie.orig/src/sbin/pfctl/pfctl_parser.c
+++ freebsd-utils-jessie/src/sbin/pfctl/pfctl_parser.c
@@ -580,7 +580,7 @@ print_status(struct pf_status *s, int op
 		    s->src_nodes, "");
 		for (i = 0; i < SCNT_MAX; i++) {
 			printf("  %-25s %14lld ", pf_scounters[i],
-#ifdef __FreeBSD__
+#if 1
 				    (long long)s->scounters[i]);
 #else
 				    s->scounters[i]);
@@ -606,7 +606,7 @@ print_status(struct pf_status *s, int op
 		printf("Limit Counters\n");
 		for (i = 0; i < LCNT_MAX; i++) {
 			printf("  %-25s %14lld ", pf_lcounters[i],
-#ifdef __FreeBSD__
+#if 1
 				    (unsigned long long)s->lcounters[i]);
 #else
 				    s->lcounters[i]);
@@ -655,7 +655,7 @@ print_src_node(struct pf_src_node *sn, i
 			    sn->expire, min, sec);
 		}
 		printf(", %llu pkts, %llu bytes",
-#ifdef __FreeBSD__
+#if 1
 		    (unsigned long long)(sn->packets[0] + sn->packets[1]),
 		    (unsigned long long)(sn->bytes[0] + sn->bytes[1]));
 #else
@@ -1013,7 +1013,7 @@ print_rule(struct pf_rule *r, const char
 	if (r->rtableid != -1)
 		printf(" rtable %u", r->rtableid);
 	if (r->divert.port) {
-#ifdef __FreeBSD__
+#if 1
 		printf(" divert-to %u", ntohs(r->divert.port));
 #else
 		if (PF_AZERO(&r->divert.addr, r->af)) {
Index: freebsd-utils-jessie/src/sbin/pfctl/pfctl_qstats.c
===================================================================
--- freebsd-utils-jessie.orig/src/sbin/pfctl/pfctl_qstats.c
+++ freebsd-utils-jessie/src/sbin/pfctl/pfctl_qstats.c
@@ -89,7 +89,7 @@ pfctl_show_altq(int dev, const char *ifa
 	struct pf_altq_node	*root = NULL, *node;
 	int			 nodes, dotitle = (opts & PF_OPT_SHOWALL);
 
-#ifdef __FreeBSD__
+#if 1
 	if (!altqsupport)
 		return (-1);
 #endif
@@ -118,7 +118,7 @@ pfctl_show_altq(int dev, const char *ifa
 		for (node = root; node != NULL; node = node->next) {
 			if (iface != NULL && strcmp(node->altq.ifname, iface))
 				continue;
-#ifdef __FreeBSD__
+#if 1
 			if (node->altq.local_flags & PFALTQ_FLAG_IF_REMOVED)
 				continue;
 #endif
@@ -161,7 +161,7 @@ pfctl_update_qstats(int dev, struct pf_a
 			warn("DIOCGETALTQ");
 			return (-1);
 		}
-#ifdef __FreeBSD__
+#if 1
 		if (pa.altq.qid > 0 &&
 		    !(pa.altq.local_flags & PFALTQ_FLAG_IF_REMOVED)) {
 #else
@@ -184,7 +184,7 @@ pfctl_update_qstats(int dev, struct pf_a
 				pfctl_insert_altq_node(root, pa.altq, qstats);
 			}
 		}
-#ifdef __FreeBSD__
+#if 1
 		else if (pa.altq.local_flags & PFALTQ_FLAG_IF_REMOVED) {
 			memset(&qstats.data, 0, sizeof(qstats.data));
 			if ((node = pfctl_find_altq_node(*root, pa.altq.qname,
@@ -303,7 +303,7 @@ pfctl_print_altq_nodestat(int dev, const
 	if (a->altq.qid == 0)
 		return;
 
-#ifdef __FreeBSD__
+#if 1
 	if (a->altq.local_flags & PFALTQ_FLAG_IF_REMOVED)
 		return;
 #endif