blob: e9cc0ff8985f9f2422936e527d2e768013324e55 [file] [log] [blame]
Max Kellermann5b76f682008-01-29 13:42:48 +00001/* Code to restore the iptables state, from file by ip6tables-save.
András Kis-Szabó2f523792001-02-27 09:59:48 +00002 * Author: Andras Kis-Szabo <kisza@sch.bme.hu>
3 *
4 * based on iptables-restore
5 * Authors:
Max Kellermann5b76f682008-01-29 13:42:48 +00006 * Harald Welte <laforge@gnumonks.org>
7 * Rusty Russell <rusty@linuxcare.com.au>
András Kis-Szabó0c4188f2002-08-14 11:40:41 +00008 * This code is distributed under the terms of GNU GPL v2
András Kis-Szabó2f523792001-02-27 09:59:48 +00009 *
Martin Josefsson357d59d2004-12-27 19:49:28 +000010 * $Id$
András Kis-Szabó2f523792001-02-27 09:59:48 +000011 */
12
13#include <getopt.h>
14#include <sys/errno.h>
15#include <string.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include "ip6tables.h"
Yasuyuki KOZAKAI0b82e8e2007-07-24 05:47:40 +000019#include "xtables.h"
András Kis-Szabó2f523792001-02-27 09:59:48 +000020#include "libiptc/libip6tc.h"
Jan Engelhardt33690a12008-02-11 00:54:00 +010021#include "ip6tables-multi.h"
András Kis-Szabó2f523792001-02-27 09:59:48 +000022
23#ifdef DEBUG
24#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
25#else
Max Kellermann5b76f682008-01-29 13:42:48 +000026#define DEBUGP(x, args...)
András Kis-Szabó2f523792001-02-27 09:59:48 +000027#endif
28
András Kis-Szabó2f523792001-02-27 09:59:48 +000029static int binary = 0, counters = 0, verbose = 0, noflush = 0;
30
31/* Keeping track of external matches and targets. */
32static struct option options[] = {
33 { "binary", 0, 0, 'b' },
34 { "counters", 0, 0, 'c' },
Martin Josefssonec789712004-01-31 19:28:13 +000035 { "verbose", 0, 0, 'v' },
Martin Josefsson4e5e29a2004-02-02 19:59:17 +000036 { "test", 0, 0, 't' },
András Kis-Szabó2f523792001-02-27 09:59:48 +000037 { "help", 0, 0, 'h' },
38 { "noflush", 0, 0, 'n'},
Harald Welte58918652001-06-16 18:25:25 +000039 { "modprobe", 1, 0, 'M'},
András Kis-Szabó2f523792001-02-27 09:59:48 +000040 { 0 }
41};
42
43static void print_usage(const char *name, const char *version) __attribute__((noreturn));
44
45static void print_usage(const char *name, const char *version)
46{
Martin Josefsson60044392004-02-02 20:12:33 +000047 fprintf(stderr, "Usage: %s [-b] [-c] [-v] [-t] [-h]\n"
András Kis-Szabó2f523792001-02-27 09:59:48 +000048 " [ --binary ]\n"
49 " [ --counters ]\n"
50 " [ --verbose ]\n"
Martin Josefsson4e5e29a2004-02-02 19:59:17 +000051 " [ --test ]\n"
András Kis-Szabó2f523792001-02-27 09:59:48 +000052 " [ --help ]\n"
Harald Welte58918652001-06-16 18:25:25 +000053 " [ --noflush ]\n"
Max Kellermann5b76f682008-01-29 13:42:48 +000054 " [ --modprobe=<command>]\n", name);
55
András Kis-Szabó2f523792001-02-27 09:59:48 +000056 exit(1);
57}
58
Jan Engelhardt33690a12008-02-11 00:54:00 +010059static ip6tc_handle_t create_handle(const char *tablename,
60 const char *modprobe)
András Kis-Szabó2f523792001-02-27 09:59:48 +000061{
62 ip6tc_handle_t handle;
63
64 handle = ip6tc_init(tablename);
Harald Welte58918652001-06-16 18:25:25 +000065
66 if (!handle) {
András Kis-Szabó97fd91a2002-03-03 09:44:31 +000067 /* try to insmod the module if iptc_init failed */
Yasuyuki KOZAKAI0d502bc2007-07-24 05:52:07 +000068 load_xtables_ko(modprobe, 0);
András Kis-Szabó97fd91a2002-03-03 09:44:31 +000069 handle = ip6tc_init(tablename);
Harald Welte58918652001-06-16 18:25:25 +000070 }
71
András Kis-Szabó2f523792001-02-27 09:59:48 +000072 if (!handle) {
Patrick McHardy5b098ac2007-02-14 13:59:12 +000073 exit_error(PARAMETER_PROBLEM, "%s: unable to initialize "
András Kis-Szabó2f523792001-02-27 09:59:48 +000074 "table '%s'\n", program_name, tablename);
75 exit(1);
76 }
77 return handle;
78}
79
Lutz Jaenickee78c69c2006-12-09 13:06:04 +000080static int parse_counters(char *string, struct ip6t_counters *ctr)
András Kis-Szabó2f523792001-02-27 09:59:48 +000081{
Patrick McHardy875441e2007-10-17 08:48:58 +000082 unsigned long long pcnt, bcnt;
83 int ret;
Patrick McHardy31f51c62007-10-16 08:49:31 +000084
Patrick McHardy875441e2007-10-17 08:48:58 +000085 ret = sscanf(string, "[%llu:%llu]",
86 (unsigned long long *)&pcnt,
87 (unsigned long long *)&bcnt);
88 ctr->pcnt = pcnt;
89 ctr->bcnt = bcnt;
90 return ret == 2;
András Kis-Szabó2f523792001-02-27 09:59:48 +000091}
92
Harald Welte885c6eb2001-10-04 08:30:46 +000093/* global new argv and argc */
94static char *newargv[255];
95static int newargc;
96
Max Kellermann5b76f682008-01-29 13:42:48 +000097/* function adding one argument to newargv, updating newargc
András Kis-Szabó97fd91a2002-03-03 09:44:31 +000098 * returns true if argument added, false otherwise */
Harald Welte885c6eb2001-10-04 08:30:46 +000099static int add_argv(char *what) {
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000100 DEBUGP("add_argv: %s\n", what);
101 if (what && ((newargc + 1) < sizeof(newargv)/sizeof(char *))) {
102 newargv[newargc] = strdup(what);
103 newargc++;
104 return 1;
Max Kellermann5b76f682008-01-29 13:42:48 +0000105 } else
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000106 return 0;
Harald Welte885c6eb2001-10-04 08:30:46 +0000107}
108
109static void free_argv(void) {
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000110 int i;
Harald Welte885c6eb2001-10-04 08:30:46 +0000111
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000112 for (i = 0; i < newargc; i++)
113 free(newargv[i]);
Harald Welte885c6eb2001-10-04 08:30:46 +0000114}
115
Hann-Huei Chiou4bc48332007-10-23 14:22:34 +0000116#ifdef IPTABLES_MULTI
117int ip6tables_restore_main(int argc, char *argv[])
118#else
András Kis-Szabó2f523792001-02-27 09:59:48 +0000119int main(int argc, char *argv[])
Hann-Huei Chiou4bc48332007-10-23 14:22:34 +0000120#endif
András Kis-Szabó2f523792001-02-27 09:59:48 +0000121{
Martin Josefsson841e4ae2003-05-02 15:30:11 +0000122 ip6tc_handle_t handle = NULL;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000123 char buffer[10240];
András Kis-Szabó2f523792001-02-27 09:59:48 +0000124 int c;
125 char curtable[IP6T_TABLE_MAXNAMELEN + 1];
András Kis-Szabó2f523792001-02-27 09:59:48 +0000126 FILE *in;
Harald Welte58918652001-06-16 18:25:25 +0000127 const char *modprobe = 0;
Martin Josefsson4e5e29a2004-02-02 19:59:17 +0000128 int in_table = 0, testing = 0;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000129
130 program_name = "ip6tables-restore";
Harald Welte80fe35d2002-05-29 13:08:15 +0000131 program_version = IPTABLES_VERSION;
Harald Weltea8658ca2003-03-05 07:46:15 +0000132 line = 0;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000133
Martin Josefsson357d59d2004-12-27 19:49:28 +0000134 lib_dir = getenv("IP6TABLES_LIB_DIR");
135 if (!lib_dir)
136 lib_dir = IP6T_LIB_DIR;
137
Harald Welte3efb6ea2001-08-06 18:50:21 +0000138#ifdef NO_SHARED_LIBS
139 init_extensions();
140#endif
141
Martin Josefsson4e5e29a2004-02-02 19:59:17 +0000142 while ((c = getopt_long(argc, argv, "bcvthnM:", options, NULL)) != -1) {
András Kis-Szabó2f523792001-02-27 09:59:48 +0000143 switch (c) {
144 case 'b':
145 binary = 1;
146 break;
147 case 'c':
148 counters = 1;
149 break;
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000150 case 'v':
151 verbose = 1;
152 break;
Martin Josefsson4e5e29a2004-02-02 19:59:17 +0000153 case 't':
154 testing = 1;
155 break;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000156 case 'h':
157 print_usage("ip6tables-restore",
Harald Welte80fe35d2002-05-29 13:08:15 +0000158 IPTABLES_VERSION);
András Kis-Szabó2f523792001-02-27 09:59:48 +0000159 break;
160 case 'n':
161 noflush = 1;
162 break;
Harald Welte58918652001-06-16 18:25:25 +0000163 case 'M':
164 modprobe = optarg;
165 break;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000166 }
167 }
Max Kellermann5b76f682008-01-29 13:42:48 +0000168
András Kis-Szabó2f523792001-02-27 09:59:48 +0000169 if (optind == argc - 1) {
170 in = fopen(argv[optind], "r");
171 if (!in) {
Pavel Rusnak972af092007-05-10 15:00:39 +0000172 fprintf(stderr, "Can't open %s: %s\n", argv[optind],
András Kis-Szabó2f523792001-02-27 09:59:48 +0000173 strerror(errno));
174 exit(1);
175 }
176 }
177 else if (optind < argc) {
Pavel Rusnak972af092007-05-10 15:00:39 +0000178 fprintf(stderr, "Unknown arguments found on commandline\n");
András Kis-Szabó2f523792001-02-27 09:59:48 +0000179 exit(1);
180 }
181 else in = stdin;
Max Kellermann5b76f682008-01-29 13:42:48 +0000182
András Kis-Szabó2f523792001-02-27 09:59:48 +0000183 /* Grab standard input. */
184 while (fgets(buffer, sizeof(buffer), in)) {
Martin Josefssoncc536282004-02-02 20:14:56 +0000185 int ret = 0;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000186
187 line++;
Martin Josefsson5065afa2004-01-31 19:33:47 +0000188 if (buffer[0] == '\n')
189 continue;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000190 else if (buffer[0] == '#') {
Martin Josefsson3673dcb2004-01-31 19:41:49 +0000191 if (verbose)
192 fputs(buffer, stdout);
András Kis-Szabó2f523792001-02-27 09:59:48 +0000193 continue;
Harald Weltea8658ca2003-03-05 07:46:15 +0000194 } else if ((strcmp(buffer, "COMMIT\n") == 0) && (in_table)) {
Martin Josefsson4e5e29a2004-02-02 19:59:17 +0000195 if (!testing) {
196 DEBUGP("Calling commit\n");
197 ret = ip6tc_commit(&handle);
198 } else {
199 DEBUGP("Not calling commit, testing\n");
200 ret = 1;
201 }
Harald Weltea8658ca2003-03-05 07:46:15 +0000202 in_table = 0;
203 } else if ((buffer[0] == '*') && (!in_table)) {
András Kis-Szabó2f523792001-02-27 09:59:48 +0000204 /* New table */
205 char *table;
206
207 table = strtok(buffer+1, " \t\n");
208 DEBUGP("line %u, table '%s'\n", line, table);
209 if (!table) {
Max Kellermann5b76f682008-01-29 13:42:48 +0000210 exit_error(PARAMETER_PROBLEM,
András Kis-Szabó2f523792001-02-27 09:59:48 +0000211 "%s: line %u table name invalid\n",
212 program_name, line);
213 exit(1);
214 }
215 strncpy(curtable, table, IP6T_TABLE_MAXNAMELEN);
Karsten Desler073df8f2004-01-31 15:33:55 +0000216 curtable[IP6T_TABLE_MAXNAMELEN] = '\0';
András Kis-Szabó2f523792001-02-27 09:59:48 +0000217
Martin Josefsson841e4ae2003-05-02 15:30:11 +0000218 if (handle)
219 ip6tc_free(&handle);
220
Harald Welte58918652001-06-16 18:25:25 +0000221 handle = create_handle(table, modprobe);
András Kis-Szabó2f523792001-02-27 09:59:48 +0000222 if (noflush == 0) {
223 DEBUGP("Cleaning all chains of table '%s'\n",
224 table);
Max Kellermann5b76f682008-01-29 13:42:48 +0000225 for_each_chain(flush_entries, verbose, 1,
András Kis-Szabó2f523792001-02-27 09:59:48 +0000226 &handle);
Max Kellermann5b76f682008-01-29 13:42:48 +0000227
András Kis-Szabó2f523792001-02-27 09:59:48 +0000228 DEBUGP("Deleting all user-defined chains "
229 "of table '%s'\n", table);
Max Kellermann5b76f682008-01-29 13:42:48 +0000230 for_each_chain(delete_chain, verbose, 0,
András Kis-Szabó2f523792001-02-27 09:59:48 +0000231 &handle) ;
232 }
233
234 ret = 1;
Harald Weltea8658ca2003-03-05 07:46:15 +0000235 in_table = 1;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000236
Harald Weltea8658ca2003-03-05 07:46:15 +0000237 } else if ((buffer[0] == ':') && (in_table)) {
András Kis-Szabó2f523792001-02-27 09:59:48 +0000238 /* New chain. */
239 char *policy, *chain;
240
241 chain = strtok(buffer+1, " \t\n");
242 DEBUGP("line %u, chain '%s'\n", line, chain);
243 if (!chain) {
244 exit_error(PARAMETER_PROBLEM,
245 "%s: line %u chain name invalid\n",
246 program_name, line);
247 exit(1);
248 }
András Kis-Szabó2f523792001-02-27 09:59:48 +0000249
Harald Weltedf1c71c2004-08-30 16:00:32 +0000250 if (ip6tc_builtin(chain, handle) <= 0) {
Charlie Brady595e4932005-06-12 15:54:15 +0000251 if (noflush && ip6tc_is_chain(chain, handle)) {
252 DEBUGP("Flushing existing user defined chain '%s'\n", chain);
253 if (!ip6tc_flush_entries(chain, &handle))
254 exit_error(PARAMETER_PROBLEM,
255 "error flushing chain "
256 "'%s':%s\n", chain,
257 strerror(errno));
258 } else {
259 DEBUGP("Creating new chain '%s'\n", chain);
260 if (!ip6tc_create_chain(chain, &handle))
261 exit_error(PARAMETER_PROBLEM,
262 "error creating chain "
263 "'%s':%s\n", chain,
264 strerror(errno));
265 }
Harald Welte885c6eb2001-10-04 08:30:46 +0000266 }
András Kis-Szabó2f523792001-02-27 09:59:48 +0000267
268 policy = strtok(NULL, " \t\n");
269 DEBUGP("line %u, policy '%s'\n", line, policy);
270 if (!policy) {
271 exit_error(PARAMETER_PROBLEM,
272 "%s: line %u policy invalid\n",
273 program_name, line);
274 exit(1);
275 }
276
277 if (strcmp(policy, "-") != 0) {
278 struct ip6t_counters count;
279
280 if (counters) {
281 char *ctrs;
282 ctrs = strtok(NULL, " \t\n");
283
Harald Welte6f38a302006-02-09 14:35:38 +0000284 if (!ctrs || !parse_counters(ctrs, &count))
285 exit_error(PARAMETER_PROBLEM,
286 "invalid policy counters "
287 "for chain '%s'\n", chain);
András Kis-Szabó2f523792001-02-27 09:59:48 +0000288
289 } else {
Max Kellermann5b76f682008-01-29 13:42:48 +0000290 memset(&count, 0,
András Kis-Szabó2f523792001-02-27 09:59:48 +0000291 sizeof(struct ip6t_counters));
292 }
293
294 DEBUGP("Setting policy of chain %s to %s\n",
295 chain, policy);
296
297 if (!ip6tc_set_policy(chain, policy, &count,
298 &handle))
299 exit_error(OTHER_PROBLEM,
300 "Can't set policy `%s'"
301 " on `%s' line %u: %s\n",
302 chain, policy, line,
303 ip6tc_strerror(errno));
304 }
305
306 ret = 1;
307
Harald Weltea8658ca2003-03-05 07:46:15 +0000308 } else if (in_table) {
Harald Welte885c6eb2001-10-04 08:30:46 +0000309 int a;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000310 char *ptr = buffer;
311 char *pcnt = NULL;
312 char *bcnt = NULL;
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000313 char *parsestart;
Harald Welte885c6eb2001-10-04 08:30:46 +0000314
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000315 /* the parser */
Max Kellermann3bf54df2008-01-29 13:45:29 +0000316 char *curchar;
317 int quote_open, escaped;
318 size_t param_len;
Harald Welte885c6eb2001-10-04 08:30:46 +0000319
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000320 /* reset the newargv */
321 newargc = 0;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000322
323 if (buffer[0] == '[') {
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000324 /* we have counters in our input */
András Kis-Szabó2f523792001-02-27 09:59:48 +0000325 ptr = strchr(buffer, ']');
326 if (!ptr)
327 exit_error(PARAMETER_PROBLEM,
328 "Bad line %u: need ]\n",
329 line);
Harald Welte885c6eb2001-10-04 08:30:46 +0000330
András Kis-Szabó2f523792001-02-27 09:59:48 +0000331 pcnt = strtok(buffer+1, ":");
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000332 if (!pcnt)
333 exit_error(PARAMETER_PROBLEM,
334 "Bad line %u: need :\n",
335 line);
Harald Welte885c6eb2001-10-04 08:30:46 +0000336
András Kis-Szabó2f523792001-02-27 09:59:48 +0000337 bcnt = strtok(NULL, "]");
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000338 if (!bcnt)
339 exit_error(PARAMETER_PROBLEM,
340 "Bad line %u: need ]\n",
341 line);
András Kis-Szabó2f523792001-02-27 09:59:48 +0000342
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000343 /* start command parsing after counter */
344 parsestart = ptr + 1;
345 } else {
346 /* start command parsing at start of line */
347 parsestart = buffer;
András Kis-Szabó2f523792001-02-27 09:59:48 +0000348 }
András Kis-Szabó2f523792001-02-27 09:59:48 +0000349
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000350 add_argv(argv[0]);
351 add_argv("-t");
352 add_argv((char *) &curtable);
Max Kellermann5b76f682008-01-29 13:42:48 +0000353
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000354 if (counters && pcnt && bcnt) {
355 add_argv("--set-counters");
356 add_argv((char *) pcnt);
357 add_argv((char *) bcnt);
358 }
András Kis-Szabó2f523792001-02-27 09:59:48 +0000359
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000360 /* After fighting with strtok enough, here's now
361 * a 'real' parser. According to Rusty I'm now no
362 * longer a real hacker, but I can live with that */
András Kis-Szabó2f523792001-02-27 09:59:48 +0000363
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000364 quote_open = 0;
Max Kellermann3bf54df2008-01-29 13:45:29 +0000365 escaped = 0;
366 param_len = 0;
Max Kellermann5b76f682008-01-29 13:42:48 +0000367
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000368 for (curchar = parsestart; *curchar; curchar++) {
Max Kellermann3bf54df2008-01-29 13:45:29 +0000369 char param_buffer[1024];
370
Max Kellermann3bf54df2008-01-29 13:45:29 +0000371 if (quote_open) {
Max Kellermannfe05c762008-01-29 13:46:01 +0000372 if (escaped) {
373 param_buffer[param_len++] = *curchar;
374 escaped = 0;
375 continue;
376 } else if (*curchar == '\\') {
Max Kellermann3bf54df2008-01-29 13:45:29 +0000377 escaped = 1;
378 continue;
379 } else if (*curchar == '"') {
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000380 quote_open = 0;
381 *curchar = ' ';
382 } else {
Max Kellermann3bf54df2008-01-29 13:45:29 +0000383 param_buffer[param_len++] = *curchar;
384 continue;
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000385 }
Max Kellermann3bf54df2008-01-29 13:45:29 +0000386 } else {
387 if (*curchar == '"') {
388 quote_open = 1;
389 continue;
390 }
391 }
392
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000393 if (*curchar == ' '
394 || *curchar == '\t'
395 || * curchar == '\n') {
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000396 if (!param_len) {
397 /* two spaces? */
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000398 continue;
399 }
Max Kellermann3bf54df2008-01-29 13:45:29 +0000400
401 param_buffer[param_len] = '\0';
Harald Weltebb41f882001-10-21 14:11:54 +0000402
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000403 /* check if table name specified */
Harald Welte48a6f902001-10-22 15:16:21 +0000404 if (!strncmp(param_buffer, "-t", 3)
405 || !strncmp(param_buffer, "--table", 8)) {
Max Kellermann5b76f682008-01-29 13:42:48 +0000406 exit_error(PARAMETER_PROBLEM,
Harald Weltebb41f882001-10-21 14:11:54 +0000407 "Line %u seems to have a "
408 "-t table option.\n", line);
409 exit(1);
410 }
411
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000412 add_argv(param_buffer);
Max Kellermann3bf54df2008-01-29 13:45:29 +0000413 param_len = 0;
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000414 } else {
Max Kellermann3bf54df2008-01-29 13:45:29 +0000415 /* regular character, copy to buffer */
416 param_buffer[param_len++] = *curchar;
417
418 if (param_len >= sizeof(param_buffer))
419 exit_error(PARAMETER_PROBLEM,
420 "Parameter too long!");
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000421 }
422 }
Harald Welte885c6eb2001-10-04 08:30:46 +0000423
424 DEBUGP("calling do_command6(%u, argv, &%s, handle):\n",
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000425 newargc, curtable);
Harald Welte885c6eb2001-10-04 08:30:46 +0000426
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000427 for (a = 0; a < newargc; a++)
András Kis-Szabó2f523792001-02-27 09:59:48 +0000428 DEBUGP("argv[%u]: %s\n", a, newargv[a]);
429
Max Kellermann5b76f682008-01-29 13:42:48 +0000430 ret = do_command6(newargc, newargv,
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000431 &newargv[2], &handle);
Harald Welte885c6eb2001-10-04 08:30:46 +0000432
András Kis-Szabó97fd91a2002-03-03 09:44:31 +0000433 free_argv();
András Kis-Szabó2f523792001-02-27 09:59:48 +0000434 }
435 if (!ret) {
436 fprintf(stderr, "%s: line %u failed\n",
437 program_name, line);
438 exit(1);
439 }
440 }
Martin Josefssone0dc5812004-02-02 19:58:36 +0000441 if (in_table) {
442 fprintf(stderr, "%s: COMMIT expected at line %u\n",
443 program_name, line + 1);
444 exit(1);
445 }
András Kis-Szabó2f523792001-02-27 09:59:48 +0000446
447 return 0;
448}