iptables: bump to 1.4.19.1
[openwrt/openwrt.git] / package / network / utils / iptables / patches / 400-lenient-restore.patch
1 Index: iptables-1.4.18/iptables/ip6tables-restore.c
2 ===================================================================
3 --- iptables-1.4.18.orig/iptables/ip6tables-restore.c 2013-03-05 16:37:31.000000000 +0100
4 +++ iptables-1.4.18/iptables/ip6tables-restore.c 2013-03-05 16:42:57.475249794 +0100
5 @@ -14,6 +14,8 @@
6 #include <string.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 +#include <stdarg.h>
10 +#include <setjmp.h>
11 #include "ip6tables.h"
12 #include "xtables.h"
13 #include "libiptc/libip6tc.h"
14 @@ -25,6 +27,7 @@
15 #define DEBUGP(x, args...)
16 #endif
17
18 +static jmp_buf jmp;
19 static int binary = 0, counters = 0, verbose = 0, noflush = 0;
20
21 /* Keeping track of external matches and targets. */
22 @@ -35,6 +38,7 @@
23 {.name = "test", .has_arg = false, .val = 't'},
24 {.name = "help", .has_arg = false, .val = 'h'},
25 {.name = "noflush", .has_arg = false, .val = 'n'},
26 + {.name = "lenient", .has_arg = false, .val = 'l'},
27 {.name = "modprobe", .has_arg = true, .val = 'M'},
28 {.name = "table", .has_arg = true, .val = 'T'},
29 {NULL},
30 @@ -51,6 +55,7 @@
31 " [ --test ]\n"
32 " [ --help ]\n"
33 " [ --noflush ]\n"
34 + " [ --lenient ]\n"
35 " [ --modprobe=<command>]\n", name);
36
37 exit(1);
38 @@ -114,6 +119,17 @@
39 free(newargv[i]);
40 }
41
42 +static void catch_exit_error(enum xtables_exittype status, const char *msg, ...)
43 +{
44 + va_list args;
45 + fprintf(stderr, "line %d: ", line);
46 + va_start(args, msg);
47 + vfprintf(stderr, msg, args);
48 + va_end(args);
49 + fprintf(stderr, "\n");
50 + longjmp(jmp, status);
51 +}
52 +
53 static void add_param_to_argv(char *parsestart)
54 {
55 int quote_open = 0, escaped = 0, param_len = 0;
56 @@ -204,7 +220,7 @@
57 init_extensions6();
58 #endif
59
60 - while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) {
61 + while ((c = getopt_long(argc, argv, "bcvthnlM:T:", options, NULL)) != -1) {
62 switch (c) {
63 case 'b':
64 binary = 1;
65 @@ -225,6 +241,9 @@
66 case 'n':
67 noflush = 1;
68 break;
69 + case 'l':
70 + ip6tables_globals.exit_err = catch_exit_error;
71 + break;
72 case 'M':
73 xtables_modprobe_program = optarg;
74 break;
75 @@ -437,8 +456,11 @@
76 for (a = 0; a < newargc; a++)
77 DEBUGP("argv[%u]: %s\n", a, newargv[a]);
78
79 - ret = do_command6(newargc, newargv,
80 - &newargv[2], &handle);
81 + if (!setjmp(jmp))
82 + ret = do_command6(newargc, newargv,
83 + &newargv[2], &handle);
84 + else
85 + ret = 1;
86
87 free_argv();
88 fflush(stdout);
89 Index: iptables-1.4.18/iptables/iptables-restore.c
90 ===================================================================
91 --- iptables-1.4.18.orig/iptables/iptables-restore.c 2013-03-05 16:37:31.000000000 +0100
92 +++ iptables-1.4.18/iptables/iptables-restore.c 2013-03-05 16:44:56.303247355 +0100
93 @@ -11,6 +11,8 @@
94 #include <string.h>
95 #include <stdio.h>
96 #include <stdlib.h>
97 +#include <stdarg.h>
98 +#include <setjmp.h>
99 #include "iptables.h"
100 #include "xtables.h"
101 #include "libiptc/libiptc.h"
102 @@ -22,6 +24,7 @@
103 #define DEBUGP(x, args...)
104 #endif
105
106 +static jmp_buf jmp;
107 static int binary = 0, counters = 0, verbose = 0, noflush = 0;
108
109 /* Keeping track of external matches and targets. */
110 @@ -32,6 +35,7 @@
111 {.name = "test", .has_arg = false, .val = 't'},
112 {.name = "help", .has_arg = false, .val = 'h'},
113 {.name = "noflush", .has_arg = false, .val = 'n'},
114 + {.name = "lenient", .has_arg = false, .val = 'l'},
115 {.name = "modprobe", .has_arg = true, .val = 'M'},
116 {.name = "table", .has_arg = true, .val = 'T'},
117 {NULL},
118 @@ -50,6 +54,7 @@
119 " [ --test ]\n"
120 " [ --help ]\n"
121 " [ --noflush ]\n"
122 + " [ --lenient ]\n"
123 " [ --table=<TABLE> ]\n"
124 " [ --modprobe=<command>]\n", name);
125
126 @@ -113,6 +118,17 @@
127 free(newargv[i]);
128 }
129
130 +static void catch_exit_error(enum xtables_exittype status, const char *msg, ...)
131 +{
132 + va_list args;
133 + fprintf(stderr, "line %d: ", line);
134 + va_start(args, msg);
135 + vfprintf(stderr, msg, args);
136 + va_end(args);
137 + fprintf(stderr, "\n");
138 + longjmp(jmp, status);
139 +}
140 +
141 static void add_param_to_argv(char *parsestart)
142 {
143 int quote_open = 0, escaped = 0, param_len = 0;
144 @@ -204,7 +220,7 @@
145 init_extensions4();
146 #endif
147
148 - while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) {
149 + while ((c = getopt_long(argc, argv, "bcvthnlM:T:", options, NULL)) != -1) {
150 switch (c) {
151 case 'b':
152 binary = 1;
153 @@ -225,6 +241,9 @@
154 case 'n':
155 noflush = 1;
156 break;
157 + case 'l':
158 + iptables_globals.exit_err = catch_exit_error;
159 + break;
160 case 'M':
161 xtables_modprobe_program = optarg;
162 break;
163 @@ -437,8 +456,11 @@
164 for (a = 0; a < newargc; a++)
165 DEBUGP("argv[%u]: %s\n", a, newargv[a]);
166
167 - ret = do_command4(newargc, newargv,
168 - &newargv[2], &handle);
169 + if (!setjmp(jmp))
170 + ret = do_command4(newargc, newargv,
171 + &newargv[2], &handle);
172 + else
173 + ret = 1;
174
175 free_argv();
176 fflush(stdout);