Commit 706c32c9 authored by Arturo Borrero Gonzalez's avatar Arturo Borrero Gonzalez
Browse files

Update upstream source from tag 'upstream/1.6.2'

Update to upstream version '1.6.2'
with Debian dir 709e57568379856beca5301ab2678ceffca94a99
parents a82b926a 5beab31f
...@@ -34,9 +34,9 @@ struct xtables_globals iptables_xml_globals = { ...@@ -34,9 +34,9 @@ struct xtables_globals iptables_xml_globals = {
static void print_usage(const char *name, const char *version) static void print_usage(const char *name, const char *version)
__attribute__ ((noreturn)); __attribute__ ((noreturn));
static int verbose = 0; static int verbose;
/* Whether to combine actions of sequential rules with identical conditions */ /* Whether to combine actions of sequential rules with identical conditions */
static int combine = 0; static int combine;
/* Keeping track of external matches and targets. */ /* Keeping track of external matches and targets. */
static struct option options[] = { static struct option options[] = {
{"verbose", 0, NULL, 'v'}, {"verbose", 0, NULL, 'v'},
...@@ -73,10 +73,10 @@ parse_counters(char *string, struct xt_counters *ctr) ...@@ -73,10 +73,10 @@ parse_counters(char *string, struct xt_counters *ctr)
/* global new argv and argc */ /* global new argv and argc */
static char *newargv[255]; static char *newargv[255];
static unsigned int newargc = 0; static unsigned int newargc;
static char *oldargv[255]; static char *oldargv[255];
static unsigned int oldargc = 0; static unsigned int oldargc;
/* arg meta data, were they quoted, frinstance */ /* arg meta data, were they quoted, frinstance */
static int newargvattr[255]; static int newargvattr[255];
...@@ -96,7 +96,7 @@ struct chain { ...@@ -96,7 +96,7 @@ struct chain {
#define maxChains 10240 /* max chains per table */ #define maxChains 10240 /* max chains per table */
static struct chain chains[maxChains]; static struct chain chains[maxChains];
static int nextChain = 0; static int nextChain;
/* funCtion adding one argument to newargv, updating newargc /* funCtion adding one argument to newargv, updating newargc
* returns true if argument added, false otherwise */ * returns true if argument added, false otherwise */
...@@ -426,12 +426,9 @@ do_rule_part(char *leveltag1, char *leveltag2, int part, int argc, ...@@ -426,12 +426,9 @@ do_rule_part(char *leveltag1, char *leveltag2, int part, int argc,
else else
printf("%s%s", spacer, argv[arg]); printf("%s%s", spacer, argv[arg]);
spacer = " "; spacer = " ";
} else if (!argvattr[arg] && isTarget(argv[arg]) } else if (!argvattr[arg] && isTarget(argv[arg]) &&
&& existsChain(argv[arg + 1]) (arg + 1 < argc) &&
&& (2 + arg >= argc)) { existsChain(argv[arg + 1])) {
if (!((1 + arg) < argc))
// no args to -j, -m or -g, ignore & finish loop
break;
CLOSE_LEVEL(2); CLOSE_LEVEL(2);
if (level1) if (level1)
printf("%s", leveli1); printf("%s", leveli1);
...@@ -819,9 +816,11 @@ iptables_xml_main(int argc, char *argv[]) ...@@ -819,9 +816,11 @@ iptables_xml_main(int argc, char *argv[])
*(param_buffer + param_len) = '\0'; *(param_buffer + param_len) = '\0';
/* check if table name specified */ /* check if table name specified */
if (!strncmp(param_buffer, "-t", 3) if ((param_buffer[0] == '-' &&
|| !strncmp(param_buffer, param_buffer[1] != '-' &&
"--table", 8)) { strchr(param_buffer, 't')) ||
(!strncmp(param_buffer, "--t", 3) &&
!strncmp(param_buffer, "--table", strlen(param_buffer)))) {
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Line %u seems to have a " "Line %u seems to have a "
"-t table option.\n", "-t table option.\n",
......
...@@ -1114,9 +1114,8 @@ void print_rule4(const struct ipt_entry *e, ...@@ -1114,9 +1114,8 @@ void print_rule4(const struct ipt_entry *e,
e->ip.invflags & IPT_INV_FRAG ? " !" : ""); e->ip.invflags & IPT_INV_FRAG ? " !" : "");
/* Print matchinfo part */ /* Print matchinfo part */
if (e->target_offset) { if (e->target_offset)
IPT_MATCH_ITERATE(e, print_match_save, &e->ip); IPT_MATCH_ITERATE(e, print_match_save, &e->ip);
}
/* print counters for iptables -R */ /* print counters for iptables -R */
if (counters < 0) if (counters < 0)
...@@ -1393,8 +1392,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1393,8 +1392,7 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_DELETE, CMD_NONE, add_command(&command, CMD_DELETE, CMD_NONE,
cs.invert); cs.invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv)) {
&& argv[optind][0] != '!') {
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
command = CMD_DELETE_NUM; command = CMD_DELETE_NUM;
} }
...@@ -1404,8 +1402,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1404,8 +1402,7 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_REPLACE, CMD_NONE, add_command(&command, CMD_REPLACE, CMD_NONE,
cs.invert); cs.invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1417,8 +1414,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1417,8 +1414,7 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_INSERT, CMD_NONE, add_command(&command, CMD_INSERT, CMD_NONE,
cs.invert); cs.invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
else rulenum = 1; else rulenum = 1;
break; break;
...@@ -1427,11 +1423,9 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1427,11 +1423,9 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_LIST, add_command(&command, CMD_LIST,
CMD_ZERO | CMD_ZERO_NUM, cs.invert); CMD_ZERO | CMD_ZERO_NUM, cs.invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
break; break;
...@@ -1439,11 +1433,9 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1439,11 +1433,9 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_LIST_RULES, add_command(&command, CMD_LIST_RULES,
CMD_ZERO|CMD_ZERO_NUM, cs.invert); CMD_ZERO|CMD_ZERO_NUM, cs.invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
break; break;
...@@ -1451,8 +1443,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1451,8 +1443,7 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_FLUSH, CMD_NONE, add_command(&command, CMD_FLUSH, CMD_NONE,
cs.invert); cs.invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
break; break;
...@@ -1460,11 +1451,9 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1460,11 +1451,9 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_ZERO, CMD_LIST|CMD_LIST_RULES, add_command(&command, CMD_ZERO, CMD_LIST|CMD_LIST_RULES,
cs.invert); cs.invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv)) {
&& argv[optind][0] != '!') {
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
command = CMD_ZERO_NUM; command = CMD_ZERO_NUM;
} }
...@@ -1481,8 +1470,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1481,8 +1470,7 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_DELETE_CHAIN, CMD_NONE, add_command(&command, CMD_DELETE_CHAIN, CMD_NONE,
cs.invert); cs.invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
break; break;
...@@ -1490,8 +1478,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1490,8 +1478,7 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_RENAME_CHAIN, CMD_NONE, add_command(&command, CMD_RENAME_CHAIN, CMD_NONE,
cs.invert); cs.invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
newname = argv[optind++]; newname = argv[optind++];
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1504,8 +1491,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1504,8 +1491,7 @@ int do_command4(int argc, char *argv[], char **table,
add_command(&command, CMD_SET_POLICY, CMD_NONE, add_command(&command, CMD_SET_POLICY, CMD_NONE,
cs.invert); cs.invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
policy = argv[optind++]; policy = argv[optind++];
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1613,16 +1599,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1613,16 +1599,7 @@ int do_command4(int argc, char *argv[], char **table,
"You cannot use `-w' from " "You cannot use `-w' from "
"iptables-restore"); "iptables-restore");
} }
wait = -1; wait = parse_wait_time(argc, argv);
if (optarg) {
if (sscanf(optarg, "%i", &wait) != 1)
xtables_error(PARAMETER_PROBLEM,
"wait seconds not numeric");
} else if (optind < argc && argv[optind][0] != '-'
&& argv[optind][0] != '!')
if (sscanf(argv[optind++], "%i", &wait) != 1)
xtables_error(PARAMETER_PROBLEM,
"wait seconds not numeric");
break; break;
case 'W': case 'W':
...@@ -1631,14 +1608,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1631,14 +1608,7 @@ int do_command4(int argc, char *argv[], char **table,
"You cannot use `-W' from " "You cannot use `-W' from "
"iptables-restore"); "iptables-restore");
} }
if (optarg) parse_wait_interval(argc, argv, &wait_interval);
parse_wait_interval(optarg, &wait_interval);
else if (optind < argc &&
argv[optind][0] != '-' &&
argv[optind][0] != '!')
parse_wait_interval(argv[optind++],
&wait_interval);
wait_interval_set = true; wait_interval_set = true;
break; break;
...@@ -1688,8 +1658,7 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1688,8 +1658,7 @@ int do_command4(int argc, char *argv[], char **table,
bcnt = strchr(pcnt + 1, ','); bcnt = strchr(pcnt + 1, ',');
if (bcnt) if (bcnt)
bcnt++; bcnt++;
if (!bcnt && optind < argc && argv[optind][0] != '-' if (!bcnt && xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
bcnt = argv[optind++]; bcnt = argv[optind++];
if (!bcnt) if (!bcnt)
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1796,15 +1765,8 @@ int do_command4(int argc, char *argv[], char **table, ...@@ -1796,15 +1765,8 @@ int do_command4(int argc, char *argv[], char **table,
generic_opt_check(command, cs.options); generic_opt_check(command, cs.options);
/* Attempt to acquire the xtables lock */ /* Attempt to acquire the xtables lock */
if (!restore && !xtables_lock(wait, &wait_interval)) { if (!restore)
fprintf(stderr, "Another app is currently holding the xtables lock. "); xtables_lock_or_exit(wait, &wait_interval);
if (wait == 0)
fprintf(stderr, "Perhaps you want to use the -w option?\n");
else
fprintf(stderr, "Stopped waiting after %ds.\n", wait);
xtables_free_opts(1);
exit(RESOURCE_PROBLEM);
}
/* only allocate handle if we weren't called with a handle */ /* only allocate handle if we weren't called with a handle */
if (!*handle) if (!*handle)
......
...@@ -320,6 +320,8 @@ static void nft_ipv4_print_firewall(struct nftnl_rule *r, unsigned int num, ...@@ -320,6 +320,8 @@ static void nft_ipv4_print_firewall(struct nftnl_rule *r, unsigned int num,
if (!(format & FMT_NONEWLINE)) if (!(format & FMT_NONEWLINE))
fputc('\n', stdout); fputc('\n', stdout);
xtables_rule_matches_free(&cs.matches);
} }
static void save_ipv4_addr(char letter, const struct in_addr *addr, static void save_ipv4_addr(char letter, const struct in_addr *addr,
...@@ -488,7 +490,7 @@ static int nft_ipv4_xlate(const void *data, struct xt_xlate *xl) ...@@ -488,7 +490,7 @@ static int nft_ipv4_xlate(const void *data, struct xt_xlate *xl)
return ret; return ret;
/* Always add counters per rule, as in iptables */ /* Always add counters per rule, as in iptables */
xt_xlate_add(xl, "counter "); xt_xlate_add(xl, "counter");
ret = xlate_action(cs, !!(cs->fw.ip.flags & IPT_F_GOTO), xl); ret = xlate_action(cs, !!(cs->fw.ip.flags & IPT_F_GOTO), xl);
comment = xt_xlate_get_comment(xl); comment = xt_xlate_get_comment(xl);
......
...@@ -251,6 +251,8 @@ static void nft_ipv6_print_firewall(struct nftnl_rule *r, unsigned int num, ...@@ -251,6 +251,8 @@ static void nft_ipv6_print_firewall(struct nftnl_rule *r, unsigned int num,
if (!(format & FMT_NONEWLINE)) if (!(format & FMT_NONEWLINE))
fputc('\n', stdout); fputc('\n', stdout);
xtables_rule_matches_free(&cs.matches);
} }
static void save_ipv6_addr(char letter, const struct in6_addr *addr, static void save_ipv6_addr(char letter, const struct in6_addr *addr,
...@@ -437,7 +439,7 @@ static int nft_ipv6_xlate(const void *data, struct xt_xlate *xl) ...@@ -437,7 +439,7 @@ static int nft_ipv6_xlate(const void *data, struct xt_xlate *xl)
return ret; return ret;
/* Always add counters per rule, as in iptables */ /* Always add counters per rule, as in iptables */
xt_xlate_add(xl, "counter "); xt_xlate_add(xl, "counter");
ret = xlate_action(cs, !!(cs->fw6.ipv6.flags & IP6T_F_GOTO), xl); ret = xlate_action(cs, !!(cs->fw6.ipv6.flags & IP6T_F_GOTO), xl);
comment = xt_xlate_get_comment(xl); comment = xt_xlate_get_comment(xl);
......
...@@ -147,7 +147,8 @@ static void mnl_nftnl_batch_reset(void) ...@@ -147,7 +147,8 @@ static void mnl_nftnl_batch_reset(void)
list_for_each_entry_safe(batch_page, next, &batch_page_list, head) { list_for_each_entry_safe(batch_page, next, &batch_page_list, head) {
list_del(&batch_page->head); list_del(&batch_page->head);
free(batch_page->batch); free(mnl_nlmsg_batch_head(batch_page->batch));
mnl_nlmsg_batch_stop(batch_page->batch);
free(batch_page); free(batch_page);
batch_num_pages--; batch_num_pages--;
} }
...@@ -1454,13 +1455,18 @@ int nft_chain_user_add(struct nft_handle *h, const char *chain, const char *tabl ...@@ -1454,13 +1455,18 @@ int nft_chain_user_add(struct nft_handle *h, const char *chain, const char *tabl
return ret == 0 ? 1 : 0; return ret == 0 ? 1 : 0;
} }
/* From linux/netlink.h */
#ifndef NLM_F_NONREC
#define NLM_F_NONREC 0x100 /* Do not delete recursively */
#endif
static int __nft_chain_del(struct nft_handle *h, struct nftnl_chain *c) static int __nft_chain_del(struct nft_handle *h, struct nftnl_chain *c)
{ {
char buf[MNL_SOCKET_BUFFER_SIZE]; char buf[MNL_SOCKET_BUFFER_SIZE];
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
nlh = nftnl_chain_nlmsg_build_hdr(buf, NFT_MSG_DELCHAIN, h->family, nlh = nftnl_chain_nlmsg_build_hdr(buf, NFT_MSG_DELCHAIN, h->family,
NLM_F_ACK, h->seq); NLM_F_NONREC | NLM_F_ACK, h->seq);
nftnl_chain_nlmsg_build_payload(nlh, c); nftnl_chain_nlmsg_build_payload(nlh, c);
return mnl_talk(h, nlh, NULL, NULL); return mnl_talk(h, nlh, NULL, NULL);
...@@ -2348,7 +2354,8 @@ static int nft_action(struct nft_handle *h, int action) ...@@ -2348,7 +2354,8 @@ static int nft_action(struct nft_handle *h, int action)
break; break;
case NFT_COMPAT_CHAIN_USER_DEL: case NFT_COMPAT_CHAIN_USER_DEL:
nft_compat_chain_batch_add(h, NFT_MSG_DELCHAIN, nft_compat_chain_batch_add(h, NFT_MSG_DELCHAIN,
0, seq++, n->chain); NLM_F_NONREC, seq++,
n->chain);
break; break;
case NFT_COMPAT_CHAIN_UPDATE: case NFT_COMPAT_CHAIN_UPDATE:
nft_compat_chain_batch_add(h, NFT_MSG_NEWCHAIN, nft_compat_chain_batch_add(h, NFT_MSG_NEWCHAIN,
...@@ -2536,8 +2543,8 @@ static void xtables_config_perror(uint32_t flags, const char *fmt, ...) ...@@ -2536,8 +2543,8 @@ static void xtables_config_perror(uint32_t flags, const char *fmt, ...)
int nft_xtables_config_load(struct nft_handle *h, const char *filename, int nft_xtables_config_load(struct nft_handle *h, const char *filename,
uint32_t flags) uint32_t flags)
{ {
struct nftnl_table_list *table_list = nftnl_table_list_alloc(); struct nftnl_table_list *table_list = NULL;
struct nftnl_chain_list *chain_list = nftnl_chain_list_alloc(); struct nftnl_chain_list *chain_list = NULL;
struct nftnl_table_list_iter *titer = NULL; struct nftnl_table_list_iter *titer = NULL;
struct nftnl_chain_list_iter *citer = NULL; struct nftnl_chain_list_iter *citer = NULL;
struct nftnl_table *table; struct nftnl_table *table;
...@@ -2548,6 +2555,9 @@ int nft_xtables_config_load(struct nft_handle *h, const char *filename, ...@@ -2548,6 +2555,9 @@ int nft_xtables_config_load(struct nft_handle *h, const char *filename,
if (h->restore) if (h->restore)
return 0; return 0;
table_list = nftnl_table_list_alloc();
chain_list = nftnl_chain_list_alloc();
if (xtables_config_parse(filename, table_list, chain_list) < 0) { if (xtables_config_parse(filename, table_list, chain_list) < 0) {
if (errno == ENOENT) { if (errno == ENOENT) {
xtables_config_perror(flags, xtables_config_perror(flags,
......
#include <config.h>
#include <getopt.h> #include <getopt.h>
#include <errno.h>
#include <libgen.h> #include <libgen.h>
#include <netdb.h> #include <netdb.h>
#include <stdbool.h> #include <stdbool.h>
...@@ -16,9 +18,6 @@ ...@@ -16,9 +18,6 @@
#include <math.h> #include <math.h>
#include "xshared.h" #include "xshared.h"
#define XT_LOCK_NAME "/run/xtables.lock"
#define BASE_MICROSECONDS 100000
/* /*
* Print out any special helps. A user might like to be able to add a --help * Print out any special helps. A user might like to be able to add a --help
* to the commandline, and see expected results. So we call help for all * to the commandline, and see expected results. So we call help for all
...@@ -247,51 +246,106 @@ void xs_init_match(struct xtables_match *match) ...@@ -247,51 +246,106 @@ void xs_init_match(struct xtables_match *match)
match->init(match->m); match->init(match->m);
} }
bool xtables_lock(int wait, struct timeval *wait_interval) static int xtables_lock(int wait, struct timeval *wait_interval)
{ {
struct timeval time_left, wait_time, waited_time; struct timeval time_left, wait_time;
int fd, i = 0; int fd, i = 0;
time_left.tv_sec = wait; time_left.tv_sec = wait;
time_left.tv_usec = 0; time_left.tv_usec = 0;
waited_time.tv_sec = 0;
waited_time.tv_usec = 0;
fd = open(XT_LOCK_NAME, O_CREAT, 0600); fd = open(XT_LOCK_NAME, O_CREAT, 0600);
if (fd < 0) if (fd < 0) {
return true; fprintf(stderr, "Fatal: can't open lock file %s: %s\n",
XT_LOCK_NAME, strerror(errno));
return XT_LOCK_FAILED;
}
if (wait == -1) {
if (flock(fd, LOCK_EX) == 0)
return fd;
fprintf(stderr, "Can't lock %s: %s\n", XT_LOCK_NAME,
strerror(errno));
return XT_LOCK_BUSY;
}
while (1) { while (1) {
if (flock(fd, LOCK_EX | LOCK_NB) == 0) if (flock(fd, LOCK_EX | LOCK_NB) == 0)
return true; return fd;
else if (timercmp(&time_left, wait_interval, <))
return XT_LOCK_BUSY;
if (++i % 10 == 0) { if (++i % 10 == 0) {
if (wait != -1) fprintf(stderr, "Another app is currently holding the xtables lock; "
fprintf(stderr, "Another app is currently holding the xtables lock; " "still %lds %ldus time ahead to have a chance to grab the lock...\n",
"still %lds %ldus time ahead to have a chance to grab the lock...\n", time_left.tv_sec, time_left.tv_usec);
time_left.tv_sec, time_left.tv_usec);
else
fprintf(stderr, "Another app is currently holding the xtables lock; "
"waiting for it to exit...\n");
} }
wait_time = *wait_interval; wait_time = *wait_interval;
select(0, NULL, NULL, NULL, &wait_time); select(0, NULL, NULL, NULL, &wait_time);
if (wait == -1)
continue;
timeradd(&waited_time, wait_interval, &waited_time);
timersub(&time_left, wait_interval, &time_left); timersub(&time_left, wait_interval, &time_left);
if (!timerisset(&time_left))
return false;
} }
} }
void parse_wait_interval(const char *str, struct timeval *wait_interval) void xtables_unlock(int lock)
{
if (lock >= 0)
close(lock);
}
int xtables_lock_or_exit(int wait, struct timeval *wait_interval)
{ {
int lock = xtables_lock(wait, wait_interval);
if (lock == XT_LOCK_FAILED) {
xtables_free_opts(1);
exit(RESOURCE_PROBLEM);
}
if (lock == XT_LOCK_BUSY) {
fprintf(stderr, "Another app is currently holding the xtables lock. ");
if (wait == 0)
fprintf(stderr, "Perhaps you want to use the -w option?\n");
else
fprintf(stderr, "Stopped waiting after %ds.\n", wait);
xtables_free_opts(1);
exit(RESOURCE_PROBLEM);
}
return lock;
}
int parse_wait_time(int argc, char *argv[])
{
int wait = -1;
if (optarg) {
if (sscanf(optarg, "%i", &wait) != 1)
xtables_error(PARAMETER_PROBLEM,
"wait seconds not numeric");
} else if (xs_has_arg(argc, argv))
if (sscanf(argv[optind++], "%i", &wait) != 1)
xtables_error(PARAMETER_PROBLEM,
"wait seconds not numeric");
return wait;
}
void parse_wait_interval(int argc, char *argv[], struct timeval *wait_interval)
{
const char *arg;
unsigned int usec; unsigned int usec;
int ret; int ret;
ret = sscanf(str, "%u", &usec); if (optarg)
arg = optarg;
else if (xs_has_arg(argc, argv))
arg = argv[optind++];
else
xtables_error(PARAMETER_PROBLEM, "wait interval value required");
ret = sscanf(arg, "%u", &usec);
if (ret == 1) { if (ret == 1) {
if (usec > 999999) if (usec > 999999)
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -304,3 +358,10 @@ void parse_wait_interval(const char *str, struct timeval *wait_interval) ...@@ -304,3 +358,10 @@ void parse_wait_interval(const char *str, struct timeval *wait_interval)
} }
xtables_error(PARAMETER_PROBLEM, "wait interval not numeric"); xtables_error(PARAMETER_PROBLEM, "wait interval not numeric");
} }
inline bool xs_has_arg(int argc, char *argv[])
{
return optind < argc &&
argv[optind][0] != '-' &&
argv[optind][0] != '!';
}
...@@ -86,9 +86,31 @@ extern struct xtables_match *load_proto(struct iptables_command_state *); ...@@ -86,9 +86,31 @@ extern struct xtables_match *load_proto(struct iptables_command_state *);
extern int subcmd_main(int, char **, const struct subcommand *); extern int subcmd_main(int, char **, const struct subcommand *);
extern void xs_init_target(struct xtables_target *); extern void xs_init_target(struct xtables_target *);
extern void xs_init_match(struct xtables_match *); extern void xs_init_match(struct xtables_match *);
bool xtables_lock(int wait, struct timeval *wait_interval);
void parse_wait_interval(const char *str, struct timeval *wait_interval); /**
* Values for the iptables lock.
*
* A value >= 0 indicates the lock filedescriptor. Other values are:
*
* XT_LOCK_FAILED : The lock could not be acquired.
*
* XT_LOCK_BUSY : The lock was held by another process. xtables_lock only
* returns this value when |wait| == false. If |wait| == true, xtables_lock
* will not return unless the lock has been acquired.
*
* XT_LOCK_NOT_ACQUIRED : We have not yet attempted to acquire the lock.
*/
enum {
XT_LOCK_BUSY = -1,
XT_LOCK_FAILED = -2,
XT_LOCK_NOT_ACQUIRED = -3,
};
extern void xtables_unlock(int lock);
extern int xtables_lock_or_exit(int wait, struct timeval *tv);
int parse_wait_time(int argc, char *argv[]);
void parse_wait_interval(int argc, char *argv[], struct timeval *wait_interval);
bool xs_has_arg(int argc, char *argv[]);
extern const struct xtables_afinfo *afinfo; extern const struct xtables_afinfo *afinfo;
......
...@@ -150,7 +150,7 @@ static struct option original_opts[] = { ...@@ -150,7 +150,7 @@ static struct option original_opts[] = {
int RUNTIME_NF_ARP_NUMHOOKS = 3; int RUNTIME_NF_ARP_NUMHOOKS = 3;
static struct option *opts = original_opts; static struct option *opts = original_opts;
static unsigned int global_option_offset = 0; static unsigned int global_option_offset;
extern void xtables_exit_error(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3))); extern void xtables_exit_error(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3)));
struct xtables_globals arptables_globals = { struct xtables_globals arptables_globals = {
...@@ -984,8 +984,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -984,8 +984,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_DELETE, CMD_NONE, add_command(&command, CMD_DELETE, CMD_NONE,
invert); invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv)) {
&& argv[optind][0] != '!') {
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
command = CMD_DELETE_NUM; command = CMD_DELETE_NUM;
} }
...@@ -995,8 +994,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -995,8 +994,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_REPLACE, CMD_NONE, add_command(&command, CMD_REPLACE, CMD_NONE,
invert); invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1008,8 +1006,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -1008,8 +1006,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_INSERT, CMD_NONE, add_command(&command, CMD_INSERT, CMD_NONE,
invert); invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
rulenum = parse_rulenumber(argv[optind++]); rulenum = parse_rulenumber(argv[optind++]);
else rulenum = 1; else rulenum = 1;
break; break;
...@@ -1018,8 +1015,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -1018,8 +1015,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_LIST, CMD_ZERO, add_command(&command, CMD_LIST, CMD_ZERO,
invert); invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
break; break;
...@@ -1027,8 +1023,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -1027,8 +1023,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_FLUSH, CMD_NONE, add_command(&command, CMD_FLUSH, CMD_NONE,
invert); invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
break; break;
...@@ -1036,8 +1031,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -1036,8 +1031,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_ZERO, CMD_LIST, add_command(&command, CMD_ZERO, CMD_LIST,
invert); invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
break; break;
...@@ -1059,8 +1053,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -1059,8 +1053,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_DELETE_CHAIN, CMD_NONE, add_command(&command, CMD_DELETE_CHAIN, CMD_NONE,
invert); invert);
if (optarg) chain = optarg; if (optarg) chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
chain = argv[optind++]; chain = argv[optind++];
break; break;
...@@ -1068,8 +1061,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -1068,8 +1061,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_RENAME_CHAIN, CMD_NONE, add_command(&command, CMD_RENAME_CHAIN, CMD_NONE,
invert); invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
newname = argv[optind++]; newname = argv[optind++];
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1082,8 +1074,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -1082,8 +1074,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
add_command(&command, CMD_SET_POLICY, CMD_NONE, add_command(&command, CMD_SET_POLICY, CMD_NONE,
invert); invert);
chain = optarg; chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
policy = argv[optind++]; policy = argv[optind++];
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1286,8 +1277,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table) ...@@ -1286,8 +1277,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table)
set_option(&options, OPT_COUNTERS, &cs.fw.arp.invflags, set_option(&options, OPT_COUNTERS, &cs.fw.arp.invflags,
invert); invert);
pcnt = optarg; pcnt = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
bcnt = argv[optind++]; bcnt = argv[optind++];
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define DEBUGP(x, args...) #define DEBUGP(x, args...)
#endif #endif
static int counters = 0, verbose = 0, noflush = 0; static int counters, verbose, noflush;
/* Keeping track of external matches and targets. */ /* Keeping track of external matches and targets. */
static const struct option options[] = { static const struct option options[] = {
...@@ -40,8 +40,6 @@ static const struct option options[] = { ...@@ -40,8 +40,6 @@ static const struct option options[] = {
{NULL}, {NULL},
}; };
static void print_usage(const char *name, const char *version) __attribute__((noreturn));
#define prog_name xtables_globals.program_name #define prog_name xtables_globals.program_name
static void print_usage(const char *name, const char *version) static void print_usage(const char *name, const char *version)
...@@ -56,8 +54,6 @@ static void print_usage(const char *name, const char *version) ...@@ -56,8 +54,6 @@ static void print_usage(const char *name, const char *version)
" [ --modprobe=<command> ]\n" " [ --modprobe=<command> ]\n"
" [ --ipv4 ]\n" " [ --ipv4 ]\n"
" [ --ipv6 ]\n", name); " [ --ipv6 ]\n", name);
exit(1);
} }
static int parse_counters(char *string, struct xt_counters *ctr) static int parse_counters(char *string, struct xt_counters *ctr)
...@@ -140,8 +136,11 @@ static void add_param_to_argv(char *parsestart) ...@@ -140,8 +136,11 @@ static void add_param_to_argv(char *parsestart)
param_buffer[param_len] = '\0'; param_buffer[param_len] = '\0';
/* check if table name specified */ /* check if table name specified */
if (!strncmp(param_buffer, "-t", 2) if ((param_buffer[0] == '-' &&
|| !strncmp(param_buffer, "--table", 8)) { param_buffer[1] != '-' &&
strchr(param_buffer, 't')) ||
(!strncmp(param_buffer, "--t", 3) &&
!strncmp(param_buffer, "--table", strlen(param_buffer)))) {
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"The -t option (seen in line %u) cannot be " "The -t option (seen in line %u) cannot be "
"used in xtables-restore.\n", line); "used in xtables-restore.\n", line);
...@@ -181,8 +180,10 @@ static void chain_delete(struct nftnl_chain_list *clist, const char *curtable, ...@@ -181,8 +180,10 @@ static void chain_delete(struct nftnl_chain_list *clist, const char *curtable,
/* This chain has been found, delete from list. Later /* This chain has been found, delete from list. Later
* on, unvisited chains will be purged out. * on, unvisited chains will be purged out.
*/ */
if (chain_obj != NULL) if (chain_obj != NULL) {
nftnl_chain_list_del(chain_obj); nftnl_chain_list_del(chain_obj);
nftnl_chain_free(chain_obj);
}
} }
struct nft_xt_restore_cb restore_cb = { struct nft_xt_restore_cb restore_cb = {
...@@ -434,6 +435,9 @@ void xtables_restore_parse(struct nft_handle *h, ...@@ -434,6 +435,9 @@ void xtables_restore_parse(struct nft_handle *h,
xt_params->program_name, line + 1); xt_params->program_name, line + 1);
exit(1); exit(1);
} }
if (chain_list)
nftnl_chain_list_free(chain_list);
} }
static int static int
...@@ -486,7 +490,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[]) ...@@ -486,7 +490,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
case 'h': case 'h':
print_usage("xtables-restore", print_usage("xtables-restore",
IPTABLES_VERSION); IPTABLES_VERSION);
break; exit(0);
case 'n': case 'n':
noflush = 1; noflush = 1;
break; break;
...@@ -503,6 +507,10 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[]) ...@@ -503,6 +507,10 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
h.family = AF_INET6; h.family = AF_INET6;
xtables_set_nfproto(AF_INET6); xtables_set_nfproto(AF_INET6);
break; break;
default:
fprintf(stderr,
"Try `xtables-restore -h' for more information.\n");
exit(1);
} }
} }
...@@ -522,6 +530,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[]) ...@@ -522,6 +530,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
xtables_restore_parse(&h, &p, &restore_cb, argc, argv); xtables_restore_parse(&h, &p, &restore_cb, argc, argv);
nft_fini(&h);
fclose(p.in); fclose(p.in);
return 0; return 0;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h>
#include "libiptc/libiptc.h" #include "libiptc/libiptc.h"
#include "iptables.h" #include "iptables.h"
#include "xtables-multi.h" #include "xtables-multi.h"
...@@ -32,6 +33,7 @@ static const struct option options[] = { ...@@ -32,6 +33,7 @@ static const struct option options[] = {
{.name = "dump", .has_arg = false, .val = 'd'}, {.name = "dump", .has_arg = false, .val = 'd'},
{.name = "table", .has_arg = true, .val = 't'}, {.name = "table", .has_arg = true, .val = 't'},
{.name = "modprobe", .has_arg = true, .val = 'M'}, {.name = "modprobe", .has_arg = true, .val = 'M'},
{.name = "file", .has_arg = true, .val = 'f'},
{.name = "ipv4", .has_arg = false, .val = '4'}, {.name = "ipv4", .has_arg = false, .val = '4'},
{.name = "ipv6", .has_arg = false, .val = '6'}, {.name = "ipv6", .has_arg = false, .val = '6'},
{NULL}, {NULL},
...@@ -82,7 +84,8 @@ xtables_save_main(int family, const char *progname, int argc, char *argv[]) ...@@ -82,7 +84,8 @@ xtables_save_main(int family, const char *progname, int argc, char *argv[])
struct nft_handle h = { struct nft_handle h = {
.family = family, .family = family,
}; };
int c; FILE *file = NULL;
int ret, c;
xtables_globals.program_name = progname; xtables_globals.program_name = progname;
c = xtables_init_all(&xtables_globals, family); c = xtables_init_all(&xtables_globals, family);
...@@ -104,7 +107,7 @@ xtables_save_main(int family, const char *progname, int argc, char *argv[]) ...@@ -104,7 +107,7 @@ xtables_save_main(int family, const char *progname, int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
while ((c = getopt_long(argc, argv, "bcdt:M:46", options, NULL)) != -1) { while ((c = getopt_long(argc, argv, "bcdt:M:f:46", options, NULL)) != -1) {
switch (c) { switch (c) {
case 'b': case 'b':
fprintf(stderr, "-b/--binary option is not implemented\n"); fprintf(stderr, "-b/--binary option is not implemented\n");
...@@ -120,6 +123,21 @@ xtables_save_main(int family, const char *progname, int argc, char *argv[]) ...@@ -120,6 +123,21 @@ xtables_save_main(int family, const char *progname, int argc, char *argv[])
case 'M': case 'M':
xtables_modprobe_program = optarg; xtables_modprobe_program = optarg;
break; break;
case 'f':
file = fopen(optarg, "w");
if (file == NULL) {
fprintf(stderr, "Failed to open file, error: %s\n",
strerror(errno));
exit(1);
}
ret = dup2(fileno(file), STDOUT_FILENO);
if (ret == -1) {
fprintf(stderr, "Failed to redirect stdout, error: %s\n",
strerror(errno));
exit(1);
}
fclose(file);
break;
case 'd': case 'd':
dump = true; dump = true;
break; break;
...@@ -130,6 +148,10 @@ xtables_save_main(int family, const char *progname, int argc, char *argv[]) ...@@ -130,6 +148,10 @@ xtables_save_main(int family, const char *progname, int argc, char *argv[])
h.family = AF_INET6; h.family = AF_INET6;
xtables_set_nfproto(AF_INET6); xtables_set_nfproto(AF_INET6);
break; break;
default:
fprintf(stderr,
"Look at manual page `xtables-save.8' for more information.\n");
exit(1);
} }
} }
......
...@@ -85,9 +85,8 @@ xtables_main(int family, const char *progname, int argc, char *argv[]) ...@@ -85,9 +85,8 @@ xtables_main(int family, const char *progname, int argc, char *argv[])
fprintf(stderr, "iptables: %s.\n", fprintf(stderr, "iptables: %s.\n",
nft_strerror(errno)); nft_strerror(errno));
} }
if (errno == EAGAIN) { if (errno == EAGAIN)
exit(RESOURCE_PROBLEM); exit(RESOURCE_PROBLEM);
}
} }
exit(!ret); exit(!ret);
......
...@@ -60,12 +60,13 @@ int xlate_action(const struct iptables_command_state *cs, bool goto_set, ...@@ -60,12 +60,13 @@ int xlate_action(const struct iptables_command_state *cs, bool goto_set,
if (cs->target != NULL) { if (cs->target != NULL) {
/* Standard target? */ /* Standard target? */
if (strcmp(cs->jumpto, XTC_LABEL_ACCEPT) == 0) if (strcmp(cs->jumpto, XTC_LABEL_ACCEPT) == 0)
xt_xlate_add(xl, "accept"); xt_xlate_add(xl, " accept");
else if (strcmp(cs->jumpto, XTC_LABEL_DROP) == 0) else if (strcmp(cs->jumpto, XTC_LABEL_DROP) == 0)
xt_xlate_add(xl, "drop"); xt_xlate_add(xl, " drop");
else if (strcmp(cs->jumpto, XTC_LABEL_RETURN) == 0) else if (strcmp(cs->jumpto, XTC_LABEL_RETURN) == 0)
xt_xlate_add(xl, "return"); xt_xlate_add(xl, " return");
else if (cs->target->xlate) { else if (cs->target->xlate) {
xt_xlate_add(xl, " ");
struct xt_xlate_tg_params params = { struct xt_xlate_tg_params params = {
.ip = (const void *)&cs->fw, .ip = (const void *)&cs->fw,
.target = cs->target->t, .target = cs->target->t,
...@@ -79,9 +80,9 @@ int xlate_action(const struct iptables_command_state *cs, bool goto_set, ...@@ -79,9 +80,9 @@ int xlate_action(const struct iptables_command_state *cs, bool goto_set,
} else if (strlen(cs->jumpto) > 0) { } else if (strlen(cs->jumpto) > 0) {
/* Not standard, then it's a go / jump to chain */ /* Not standard, then it's a go / jump to chain */
if (goto_set) if (goto_set)
xt_xlate_add(xl, "goto %s", cs->jumpto); xt_xlate_add(xl, " goto %s", cs->jumpto);
else else
xt_xlate_add(xl, "jump %s", cs->jumpto); xt_xlate_add(xl, " jump %s", cs->jumpto);
} }
return ret; return ret;
...@@ -195,6 +196,8 @@ static int xlate(struct nft_handle *h, struct nft_xt_cmd_parse *p, ...@@ -195,6 +196,8 @@ static int xlate(struct nft_handle *h, struct nft_xt_cmd_parse *p,
} }
break; break;
} }
if (!cs->restore && i < args->s.naddrs - 1)
printf("nft ");
} }
return ret; return ret;
...@@ -234,9 +237,8 @@ static int do_command_xlate(struct nft_handle *h, int argc, char *argv[], ...@@ -234,9 +237,8 @@ static int do_command_xlate(struct nft_handle *h, int argc, char *argv[],
switch (p.command) { switch (p.command) {
case CMD_APPEND: case CMD_APPEND:
ret = 1; ret = 1;
if (!xlate(h, &p, &cs, &args, true, nft_rule_xlate_add)) { if (!xlate(h, &p, &cs, &args, true, nft_rule_xlate_add))
print_ipt_cmd(argc, argv); print_ipt_cmd(argc, argv);
}
break; break;
case CMD_DELETE: case CMD_DELETE:
break; break;
...@@ -248,9 +250,8 @@ static int do_command_xlate(struct nft_handle *h, int argc, char *argv[], ...@@ -248,9 +250,8 @@ static int do_command_xlate(struct nft_handle *h, int argc, char *argv[],
break; break;
case CMD_INSERT: case CMD_INSERT:
ret = 1; ret = 1;
if (!xlate(h, &p, &cs, &args, false, nft_rule_xlate_add)) { if (!xlate(h, &p, &cs, &args, false, nft_rule_xlate_add))
print_ipt_cmd(argc, argv); print_ipt_cmd(argc, argv);
}
break; break;
case CMD_FLUSH: case CMD_FLUSH:
if (p.chain) { if (p.chain) {
...@@ -356,6 +357,8 @@ static int xlate_chain_set(struct nft_handle *h, const char *table, ...@@ -356,6 +357,8 @@ static int xlate_chain_set(struct nft_handle *h, const char *table,
if (strcmp(table, "nat") == 0) if (strcmp(table, "nat") == 0)
type = "nat"; type = "nat";
else if (strcmp(table, "mangle") == 0 && strcmp(chain, "OUTPUT") == 0)
type = "route";
printf("add chain %s %s %s { type %s ", printf("add chain %s %s %s { type %s ",
family2str[h->family], table, chain, type); family2str[h->family], table, chain, type);
...@@ -379,6 +382,14 @@ static int xlate_chain_set(struct nft_handle *h, const char *table, ...@@ -379,6 +382,14 @@ static int xlate_chain_set(struct nft_handle *h, const char *table,
return 1; return 1;
} }
static int dummy_compat_rev(const char *name, uint8_t rev, int opt)
{
/* Avoid querying the kernel - it's not needed when just translating
* rules and not even possible when running as unprivileged user.
*/
return 1;
}
static struct nft_xt_restore_cb cb_xlate = { static struct nft_xt_restore_cb cb_xlate = {
.table_new = xlate_table_new, .table_new = xlate_table_new,
.chain_set = xlate_chain_set, .chain_set = xlate_chain_set,
...@@ -398,6 +409,7 @@ static int xtables_xlate_main(int family, const char *progname, int argc, ...@@ -398,6 +409,7 @@ static int xtables_xlate_main(int family, const char *progname, int argc,
}; };
xtables_globals.program_name = progname; xtables_globals.program_name = progname;
xtables_globals.compat_rev = dummy_compat_rev;
ret = xtables_init_all(&xtables_globals, family); ret = xtables_init_all(&xtables_globals, family);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "%s/%s Failed to initialize xtables\n", fprintf(stderr, "%s/%s Failed to initialize xtables\n",
...@@ -440,6 +452,7 @@ static int xtables_restore_xlate_main(int family, const char *progname, ...@@ -440,6 +452,7 @@ static int xtables_restore_xlate_main(int family, const char *progname,
int c; int c;
xtables_globals.program_name = progname; xtables_globals.program_name = progname;
xtables_globals.compat_rev = dummy_compat_rev;
ret = xtables_init_all(&xtables_globals, family); ret = xtables_init_all(&xtables_globals, family);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "%s/%s Failed to initialize xtables\n", fprintf(stderr, "%s/%s Failed to initialize xtables\n",
......
...@@ -744,8 +744,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -744,8 +744,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
add_command(&p->command, CMD_DELETE, CMD_NONE, add_command(&p->command, CMD_DELETE, CMD_NONE,
cs->invert); cs->invert);
p->chain = optarg; p->chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv)) {
&& argv[optind][0] != '!') {
p->rulenum = parse_rulenumber(argv[optind++]); p->rulenum = parse_rulenumber(argv[optind++]);
p->command = CMD_DELETE_NUM; p->command = CMD_DELETE_NUM;
} }
...@@ -755,8 +754,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -755,8 +754,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
add_command(&p->command, CMD_REPLACE, CMD_NONE, add_command(&p->command, CMD_REPLACE, CMD_NONE,
cs->invert); cs->invert);
p->chain = optarg; p->chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->rulenum = parse_rulenumber(argv[optind++]); p->rulenum = parse_rulenumber(argv[optind++]);
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -768,8 +766,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -768,8 +766,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
add_command(&p->command, CMD_INSERT, CMD_NONE, add_command(&p->command, CMD_INSERT, CMD_NONE,
cs->invert); cs->invert);
p->chain = optarg; p->chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->rulenum = parse_rulenumber(argv[optind++]); p->rulenum = parse_rulenumber(argv[optind++]);
else else
p->rulenum = 1; p->rulenum = 1;
...@@ -780,11 +777,9 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -780,11 +777,9 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
CMD_ZERO | CMD_ZERO_NUM, cs->invert); CMD_ZERO | CMD_ZERO_NUM, cs->invert);
if (optarg) if (optarg)
p->chain = optarg; p->chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->chain = argv[optind++]; p->chain = argv[optind++];
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->rulenum = parse_rulenumber(argv[optind++]); p->rulenum = parse_rulenumber(argv[optind++]);
break; break;
...@@ -793,11 +788,9 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -793,11 +788,9 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
CMD_ZERO|CMD_ZERO_NUM, cs->invert); CMD_ZERO|CMD_ZERO_NUM, cs->invert);
if (optarg) if (optarg)
p->chain = optarg; p->chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->chain = argv[optind++]; p->chain = argv[optind++];
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->rulenum = parse_rulenumber(argv[optind++]); p->rulenum = parse_rulenumber(argv[optind++]);
break; break;
...@@ -806,8 +799,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -806,8 +799,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
cs->invert); cs->invert);
if (optarg) if (optarg)
p->chain = optarg; p->chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->chain = argv[optind++]; p->chain = argv[optind++];
break; break;
...@@ -816,11 +808,9 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -816,11 +808,9 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
CMD_LIST|CMD_LIST_RULES, cs->invert); CMD_LIST|CMD_LIST_RULES, cs->invert);
if (optarg) if (optarg)
p->chain = optarg; p->chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->chain = argv[optind++]; p->chain = argv[optind++];
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv)) {
&& argv[optind][0] != '!') {
p->rulenum = parse_rulenumber(argv[optind++]); p->rulenum = parse_rulenumber(argv[optind++]);
p->command = CMD_ZERO_NUM; p->command = CMD_ZERO_NUM;
} }
...@@ -845,8 +835,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -845,8 +835,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
cs->invert); cs->invert);
if (optarg) if (optarg)
p->chain = optarg; p->chain = optarg;
else if (optind < argc && argv[optind][0] != '-' else if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->chain = argv[optind++]; p->chain = argv[optind++];
break; break;
...@@ -854,8 +843,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -854,8 +843,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
add_command(&p->command, CMD_RENAME_CHAIN, CMD_NONE, add_command(&p->command, CMD_RENAME_CHAIN, CMD_NONE,
cs->invert); cs->invert);
p->chain = optarg; p->chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->newname = argv[optind++]; p->newname = argv[optind++];
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -868,8 +856,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -868,8 +856,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
add_command(&p->command, CMD_SET_POLICY, CMD_NONE, add_command(&p->command, CMD_SET_POLICY, CMD_NONE,
cs->invert); cs->invert);
p->chain = optarg; p->chain = optarg;
if (optind < argc && argv[optind][0] != '-' if (xs_has_arg(argc, argv))
&& argv[optind][0] != '!')
p->policy = argv[optind++]; p->policy = argv[optind++];
else else
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1014,15 +1001,8 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -1014,15 +1001,8 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
"You cannot use `-w' from " "You cannot use `-w' from "
"iptables-restore"); "iptables-restore");
} }
if (optarg) {
if (sscanf(optarg, "%i", &wait) != 1) wait = parse_wait_time(argc, argv);
xtables_error(PARAMETER_PROBLEM,
"wait seconds not numeric");
} else if (optind < argc && argv[optind][0] != '-'
&& argv[optind][0] != '!')
if (sscanf(argv[optind++], "%i", &wait) != 1)
xtables_error(PARAMETER_PROBLEM,
"wait seconds not numeric");
break; break;
case 'W': case 'W':
...@@ -1031,14 +1011,8 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -1031,14 +1011,8 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
"You cannot use `-W' from " "You cannot use `-W' from "
"iptables-restore"); "iptables-restore");
} }
if (optarg)
parse_wait_interval(optarg, &wait_interval);
else if (optind < argc &&
argv[optind][0] != '-' &&
argv[optind][0] != '!')
parse_wait_interval(argv[optind++],
&wait_interval);
parse_wait_interval(argc, argv, &wait_interval);
wait_interval_set = true; wait_interval_set = true;
break; break;
...@@ -1058,9 +1032,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[], ...@@ -1058,9 +1032,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
args->bcnt = strchr(args->pcnt + 1, ','); args->bcnt = strchr(args->pcnt + 1, ',');
if (args->bcnt) if (args->bcnt)
args->bcnt++; args->bcnt++;
if (!args->bcnt && optind < argc && if (!args->bcnt && xs_has_arg(argc, argv))
argv[optind][0] != '-' &&
argv[optind][0] != '!')
args->bcnt = argv[optind++]; args->bcnt = argv[optind++];
if (!args->bcnt) if (!args->bcnt)
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
...@@ -1309,6 +1281,8 @@ int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table, ...@@ -1309,6 +1281,8 @@ int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table,
*table = p.table; *table = p.table;
xtables_rule_matches_free(&cs.matches); xtables_rule_matches_free(&cs.matches);
if (cs.target)
free(cs.target->t);
if (h->family == AF_INET) { if (h->family == AF_INET) {
free(args.s.addr.v4); free(args.s.addr.v4);
......
# Makefile.in generated by automake 1.14.1 from Makefile.am. # Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc. # Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
...@@ -18,7 +18,17 @@ ...@@ -18,7 +18,17 @@
VPATH = @srcdir@ VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \ am__make_running_with_option = \
case $${target_option-} in \ case $${target_option-} in \
?) ;; \ ?) ;; \
...@@ -81,8 +91,6 @@ POST_UNINSTALL = : ...@@ -81,8 +91,6 @@ POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
subdir = libipq subdir = libipq
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(srcdir)/libipq.pc.in $(top_srcdir)/build-aux/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
...@@ -90,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \ ...@@ -90,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = libipq.pc CONFIG_CLEAN_FILES = libipq.pc
...@@ -195,6 +204,8 @@ am__define_uniq_tagged_files = \ ...@@ -195,6 +204,8 @@ am__define_uniq_tagged_files = \
done | $(am__uniquify_input)` done | $(am__uniquify_input)`
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libipq.pc.in \
$(top_srcdir)/build-aux/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
pkgdatadir = @pkgdatadir@ pkgdatadir = @pkgdatadir@
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
...@@ -239,6 +250,7 @@ LIBTOOL = @LIBTOOL@ ...@@ -239,6 +250,7 @@ LIBTOOL = @LIBTOOL@
LIPO = @LIPO@ LIPO = @LIPO@
LN_S = @LN_S@ LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@ LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@ MKDIR_P = @MKDIR_P@
...@@ -336,6 +348,7 @@ program_transform_name = @program_transform_name@ ...@@ -336,6 +348,7 @@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
regular_CFLAGS = @regular_CFLAGS@ regular_CFLAGS = @regular_CFLAGS@
regular_CPPFLAGS = @regular_CPPFLAGS@ regular_CPPFLAGS = @regular_CPPFLAGS@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
...@@ -371,7 +384,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) ...@@ -371,7 +384,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libipq/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libipq/Makefile'; \
$(am__cd) $(top_srcdir) && \ $(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu libipq/Makefile $(AUTOMAKE) --gnu libipq/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \
*config.status*) \ *config.status*) \
...@@ -740,6 +752,8 @@ uninstall-man: uninstall-man3 ...@@ -740,6 +752,8 @@ uninstall-man: uninstall-man3
tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \ tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
uninstall-man uninstall-man3 uninstall-pkgconfigDATA uninstall-man uninstall-man3 uninstall-pkgconfigDATA
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded. # Otherwise a system limit (for SysV at least) may be exceeded.
......
# Makefile.in generated by automake 1.14.1 from Makefile.am. # Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc. # Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
...@@ -18,7 +18,17 @@ ...@@ -18,7 +18,17 @@
VPATH = @srcdir@ VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \ am__make_running_with_option = \
case $${target_option-} in \ case $${target_option-} in \
?) ;; \ ?) ;; \
...@@ -81,9 +91,6 @@ POST_UNINSTALL = : ...@@ -81,9 +91,6 @@ POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
subdir = libiptc subdir = libiptc
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(srcdir)/libiptc.pc.in $(srcdir)/libip4tc.pc.in \
$(srcdir)/libip6tc.pc.in $(top_srcdir)/build-aux/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
...@@ -91,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \ ...@@ -91,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = libiptc.pc libip4tc.pc libip6tc.pc CONFIG_CLEAN_FILES = libiptc.pc libip4tc.pc libip6tc.pc
...@@ -209,6 +217,9 @@ am__define_uniq_tagged_files = \ ...@@ -209,6 +217,9 @@ am__define_uniq_tagged_files = \
done | $(am__uniquify_input)` done | $(am__uniquify_input)`
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libip4tc.pc.in \
$(srcdir)/libip6tc.pc.in $(srcdir)/libiptc.pc.in \
$(top_srcdir)/build-aux/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
pkgdatadir = @pkgdatadir@ pkgdatadir = @pkgdatadir@
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
...@@ -253,6 +264,7 @@ LIBTOOL = @LIBTOOL@ ...@@ -253,6 +264,7 @@ LIBTOOL = @LIBTOOL@
LIPO = @LIPO@ LIPO = @LIPO@
LN_S = @LN_S@ LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@ LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@ MKDIR_P = @MKDIR_P@
...@@ -350,6 +362,7 @@ program_transform_name = @program_transform_name@ ...@@ -350,6 +362,7 @@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
regular_CFLAGS = @regular_CFLAGS@ regular_CFLAGS = @regular_CFLAGS@
regular_CPPFLAGS = @regular_CPPFLAGS@ regular_CPPFLAGS = @regular_CPPFLAGS@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
...@@ -386,7 +399,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) ...@@ -386,7 +399,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libiptc/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libiptc/Makefile'; \
$(am__cd) $(top_srcdir) && \ $(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu libiptc/Makefile $(AUTOMAKE) --gnu libiptc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \
*config.status*) \ *config.status*) \
...@@ -719,6 +731,8 @@ uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgconfigDATA ...@@ -719,6 +731,8 @@ uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgconfigDATA
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-libLTLIBRARIES uninstall-pkgconfigDATA uninstall-libLTLIBRARIES uninstall-pkgconfigDATA
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded. # Otherwise a system limit (for SysV at least) may be exceeded.
......
...@@ -1686,7 +1686,8 @@ iptcc_standard_map(struct rule_head *r, int verdict) ...@@ -1686,7 +1686,8 @@ iptcc_standard_map(struct rule_head *r, int verdict)
static int static int
iptcc_map_target(struct xtc_handle *const handle, iptcc_map_target(struct xtc_handle *const handle,
struct rule_head *r) struct rule_head *r,
bool dry_run)
{ {
STRUCT_ENTRY *e = r->entry; STRUCT_ENTRY *e = r->entry;
STRUCT_ENTRY_TARGET *t = GET_TARGET(e); STRUCT_ENTRY_TARGET *t = GET_TARGET(e);
...@@ -1731,7 +1732,8 @@ iptcc_map_target(struct xtc_handle *const handle, ...@@ -1731,7 +1732,8 @@ iptcc_map_target(struct xtc_handle *const handle,
0, 0,
FUNCTION_MAXNAMELEN - 1 - strlen(t->u.user.name)); FUNCTION_MAXNAMELEN - 1 - strlen(t->u.user.name));
r->type = IPTCC_R_MODULE; r->type = IPTCC_R_MODULE;
set_changed(handle); if (!dry_run)
set_changed(handle);
return 1; return 1;
} }
...@@ -1781,7 +1783,7 @@ TC_INSERT_ENTRY(const IPT_CHAINLABEL chain, ...@@ -1781,7 +1783,7 @@ TC_INSERT_ENTRY(const IPT_CHAINLABEL chain,
memcpy(r->entry, e, e->next_offset); memcpy(r->entry, e, e->next_offset);
r->counter_map.maptype = COUNTER_MAP_SET; r->counter_map.maptype = COUNTER_MAP_SET;
if (!iptcc_map_target(handle, r)) { if (!iptcc_map_target(handle, r, false)) {
free(r); free(r);
return 0; return 0;
} }
...@@ -1831,7 +1833,7 @@ TC_REPLACE_ENTRY(const IPT_CHAINLABEL chain, ...@@ -1831,7 +1833,7 @@ TC_REPLACE_ENTRY(const IPT_CHAINLABEL chain,
memcpy(r->entry, e, e->next_offset); memcpy(r->entry, e, e->next_offset);
r->counter_map.maptype = COUNTER_MAP_SET; r->counter_map.maptype = COUNTER_MAP_SET;
if (!iptcc_map_target(handle, r)) { if (!iptcc_map_target(handle, r, false)) {
free(r); free(r);
return 0; return 0;
} }
...@@ -1870,7 +1872,7 @@ TC_APPEND_ENTRY(const IPT_CHAINLABEL chain, ...@@ -1870,7 +1872,7 @@ TC_APPEND_ENTRY(const IPT_CHAINLABEL chain,
memcpy(r->entry, e, e->next_offset); memcpy(r->entry, e, e->next_offset);
r->counter_map.maptype = COUNTER_MAP_SET; r->counter_map.maptype = COUNTER_MAP_SET;
if (!iptcc_map_target(handle, r)) { if (!iptcc_map_target(handle, r, false)) {
DEBUGP("unable to map target of rule for chain `%s'\n", chain); DEBUGP("unable to map target of rule for chain `%s'\n", chain);
free(r); free(r);
return 0; return 0;
...@@ -1976,7 +1978,7 @@ static int delete_entry(const IPT_CHAINLABEL chain, const STRUCT_ENTRY *origfw, ...@@ -1976,7 +1978,7 @@ static int delete_entry(const IPT_CHAINLABEL chain, const STRUCT_ENTRY *origfw,
memcpy(r->entry, origfw, origfw->next_offset); memcpy(r->entry, origfw, origfw->next_offset);
r->counter_map.maptype = COUNTER_MAP_NOMAP; r->counter_map.maptype = COUNTER_MAP_NOMAP;
if (!iptcc_map_target(handle, r)) { if (!iptcc_map_target(handle, r, dry_run)) {
DEBUGP("unable to map target of rule for chain `%s'\n", chain); DEBUGP("unable to map target of rule for chain `%s'\n", chain);
free(r); free(r);
return 0; return 0;
......
# Makefile.in generated by automake 1.14.1 from Makefile.am. # Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc. # Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
...@@ -17,7 +17,17 @@ ...@@ -17,7 +17,17 @@
# -*- Makefile -*- # -*- Makefile -*-
VPATH = @srcdir@ VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \ am__make_running_with_option = \
case $${target_option-} in \ case $${target_option-} in \
?) ;; \ ?) ;; \
...@@ -84,8 +94,6 @@ host_triplet = @host@ ...@@ -84,8 +94,6 @@ host_triplet = @host@
@ENABLE_STATIC_TRUE@am__append_1 = -lm ${libnetfilter_conntrack_LIBS} @ENABLE_STATIC_TRUE@am__append_1 = -lm ${libnetfilter_conntrack_LIBS}
@ENABLE_SHARED_TRUE@am__append_2 = -ldl @ENABLE_SHARED_TRUE@am__append_2 = -ldl
subdir = libxtables subdir = libxtables
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/build-aux/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
...@@ -93,6 +101,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \ ...@@ -93,6 +101,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
...@@ -200,6 +209,8 @@ am__define_uniq_tagged_files = \ ...@@ -200,6 +209,8 @@ am__define_uniq_tagged_files = \
done | $(am__uniquify_input)` done | $(am__uniquify_input)`
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/build-aux/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
pkgdatadir = @pkgdatadir@ pkgdatadir = @pkgdatadir@
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
...@@ -244,6 +255,7 @@ LIBTOOL = @LIBTOOL@ ...@@ -244,6 +255,7 @@ LIBTOOL = @LIBTOOL@
LIPO = @LIPO@ LIPO = @LIPO@
LN_S = @LN_S@ LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@ LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@ MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@ MKDIR_P = @MKDIR_P@
...@@ -341,6 +353,7 @@ program_transform_name = @program_transform_name@ ...@@ -341,6 +353,7 @@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
regular_CFLAGS = @regular_CFLAGS@ regular_CFLAGS = @regular_CFLAGS@
regular_CPPFLAGS = @regular_CPPFLAGS@ regular_CPPFLAGS = @regular_CPPFLAGS@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
...@@ -374,7 +387,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) ...@@ -374,7 +387,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libxtables/Makefile'; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libxtables/Makefile'; \
$(am__cd) $(top_srcdir) && \ $(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu libxtables/Makefile $(AUTOMAKE) --gnu libxtables/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \ @case '$?' in \
*config.status*) \ *config.status*) \
...@@ -687,6 +699,8 @@ uninstall-am: uninstall-libLTLIBRARIES ...@@ -687,6 +699,8 @@ uninstall-am: uninstall-libLTLIBRARIES
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded. # Otherwise a system limit (for SysV at least) may be exceeded.
......
...@@ -538,15 +538,15 @@ void xtables_parse_interface(const char *arg, char *vianame, ...@@ -538,15 +538,15 @@ void xtables_parse_interface(const char *arg, char *vianame,
} else { } else {
/* Include nul-terminator in match */ /* Include nul-terminator in match */
memset(mask, 0xFF, vialen + 1); memset(mask, 0xFF, vialen + 1);
for (i = 0; vianame[i]; i++) { }
if (vianame[i] == '/' ||
vianame[i] == ' ') { /* Display warning on invalid characters */
fprintf(stderr, for (i = 0; vianame[i]; i++) {
"Warning: weird character in interface" if (vianame[i] == '/' || vianame[i] == ' ') {
" `%s' ('/' and ' ' are not allowed by the kernel).\n", fprintf(stderr, "Warning: weird character in interface"
vianame); " `%s' ('/' and ' ' are not allowed by the kernel).\n",
break; vianame);
} break;
} }
} }
} }
...@@ -1367,26 +1367,22 @@ static struct in_addr *host_to_ipaddr(const char *name, unsigned int *naddr) ...@@ -1367,26 +1367,22 @@ static struct in_addr *host_to_ipaddr(const char *name, unsigned int *naddr)
unsigned int i; unsigned int i;
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_RAW; hints.ai_socktype = SOCK_RAW;
*naddr = 0; *naddr = 0;
if ((err = getaddrinfo(name, NULL, &hints, &res)) != 0) { err = getaddrinfo(name, NULL, &hints, &res);
if (err != 0)
return NULL; return NULL;
} else { for (p = res; p != NULL; p = p->ai_next)
for (p = res; p != NULL; p = p->ai_next) ++*naddr;
++*naddr; addr = xtables_calloc(*naddr, sizeof(struct in_addr));
addr = xtables_calloc(*naddr, sizeof(struct in_addr)); for (i = 0, p = res; p != NULL; p = p->ai_next)
for (i = 0, p = res; p != NULL; p = p->ai_next) memcpy(&addr[i++],
memcpy(&addr[i++], &((const struct sockaddr_in *)p->ai_addr)->sin_addr,
&((const struct sockaddr_in *)p->ai_addr)->sin_addr, sizeof(struct in_addr));
sizeof(struct in_addr)); freeaddrinfo(res);
freeaddrinfo(res); return addr;
return addr;
}
return NULL;
} }
static struct in_addr * static struct in_addr *
...@@ -1657,28 +1653,24 @@ host_to_ip6addr(const char *name, unsigned int *naddr) ...@@ -1657,28 +1653,24 @@ host_to_ip6addr(const char *name, unsigned int *naddr)
unsigned int i; unsigned int i;
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_INET6; hints.ai_family = AF_INET6;
hints.ai_socktype = SOCK_RAW; hints.ai_socktype = SOCK_RAW;
*naddr = 0; *naddr = 0;
if ((err = getaddrinfo(name, NULL, &hints, &res)) != 0) { err = getaddrinfo(name, NULL, &hints, &res);
if (err != 0)
return NULL; return NULL;
} else { /* Find length of address chain */
/* Find length of address chain */ for (p = res; p != NULL; p = p->ai_next)
for (p = res; p != NULL; p = p->ai_next) ++*naddr;
++*naddr; /* Copy each element of the address chain */
/* Copy each element of the address chain */ addr = xtables_calloc(*naddr, sizeof(struct in6_addr));
addr = xtables_calloc(*naddr, sizeof(struct in6_addr)); for (i = 0, p = res; p != NULL; p = p->ai_next)
for (i = 0, p = res; p != NULL; p = p->ai_next) memcpy(&addr[i++],
memcpy(&addr[i++], &((const struct sockaddr_in6 *)p->ai_addr)->sin6_addr,
&((const struct sockaddr_in6 *)p->ai_addr)->sin6_addr, sizeof(struct in6_addr));
sizeof(struct in6_addr)); freeaddrinfo(res);
freeaddrinfo(res); return addr;
return addr;
}
return NULL;
} }
static struct in6_addr *network_to_ip6addr(const char *name) static struct in6_addr *network_to_ip6addr(const char *name)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
# Helper functions for option handling. -*- Autoconf -*- # Helper functions for option handling. -*- Autoconf -*-
# #
# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
# Inc. # Foundation, Inc.
# Written by Gary V. Vaughan, 2004 # Written by Gary V. Vaughan, 2004
# #
# This file is free software; the Free Software Foundation gives # This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without # unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved. # modifications, as long as this notice is preserved.
# serial 7 ltoptions.m4 # serial 8 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define. # This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
...@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION], ...@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option `$2'])])[]dnl [m4_warning([Unknown $1 option '$2'])])[]dnl
]) ])
...@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[ ...@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
dnl dnl
dnl If no reference was made to various pairs of opposing options, then dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither dnl we run the default mode handler for the pair. For example, if neither
dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
dnl archives by default: dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL]) [_LT_ENABLE_FAST_INSTALL])
_LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
[_LT_WITH_AIX_SONAME([aix])])
]) ])
])# _LT_SET_OPTIONS ])# _LT_SET_OPTIONS
...@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN], ...@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen]) [_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete], AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you [$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `dlopen' option into LT_INIT's first parameter.]) put the 'dlopen' option into LT_INIT's first parameter.])
]) ])
dnl aclocal-1.4 backwards compatibility: dnl aclocal-1.4 backwards compatibility:
...@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL], ...@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
_LT_SET_OPTION([LT_INIT], [win32-dll]) _LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete], AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you [$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `win32-dll' option into LT_INIT's first parameter.]) put the 'win32-dll' option into LT_INIT's first parameter.])
]) ])
dnl aclocal-1.4 backwards compatibility: dnl aclocal-1.4 backwards compatibility:
...@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) ...@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT]) # _LT_ENABLE_SHARED([DEFAULT])
# ---------------------------- # ----------------------------
# implement the --enable-shared flag, and supports the `shared' and # implement the --enable-shared flag, and supports the 'shared' and
# `disable-shared' LT_INIT options. # 'disable-shared' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_SHARED], m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared], AC_ARG_ENABLE([shared],
...@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared], ...@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
*) *)
enable_shared=no enable_shared=no
# Look at the argument we got. We use all the common list separators. # Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do for pkg in $enableval; do
IFS="$lt_save_ifs" IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then if test "X$pkg" = "X$p"; then
enable_shared=yes enable_shared=yes
fi fi
done done
IFS="$lt_save_ifs" IFS=$lt_save_ifs
;; ;;
esac], esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT) [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
...@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], []) ...@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT]) # _LT_ENABLE_STATIC([DEFAULT])
# ---------------------------- # ----------------------------
# implement the --enable-static flag, and support the `static' and # implement the --enable-static flag, and support the 'static' and
# `disable-static' LT_INIT options. # 'disable-static' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_STATIC], m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static], AC_ARG_ENABLE([static],
...@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static], ...@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
*) *)
enable_static=no enable_static=no
# Look at the argument we got. We use all the common list separators. # Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do for pkg in $enableval; do
IFS="$lt_save_ifs" IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then if test "X$pkg" = "X$p"; then
enable_static=yes enable_static=yes
fi fi
done done
IFS="$lt_save_ifs" IFS=$lt_save_ifs
;; ;;
esac], esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT) [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
...@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], []) ...@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT]) # _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ---------------------------------- # ----------------------------------
# implement the --enable-fast-install flag, and support the `fast-install' # implement the --enable-fast-install flag, and support the 'fast-install'
# and `disable-fast-install' LT_INIT options. # and 'disable-fast-install' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_FAST_INSTALL], m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install], AC_ARG_ENABLE([fast-install],
...@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install], ...@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
*) *)
enable_fast_install=no enable_fast_install=no
# Look at the argument we got. We use all the common list separators. # Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do for pkg in $enableval; do
IFS="$lt_save_ifs" IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then if test "X$pkg" = "X$p"; then
enable_fast_install=yes enable_fast_install=yes
fi fi
done done
IFS="$lt_save_ifs" IFS=$lt_save_ifs
;; ;;
esac], esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
...@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL], ...@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete], AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put [$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `fast-install' option into LT_INIT's first parameter.]) the 'fast-install' option into LT_INIT's first parameter.])
]) ])
AU_DEFUN([AC_DISABLE_FAST_INSTALL], AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete], AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put [$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `disable-fast-install' option into LT_INIT's first parameter.]) the 'disable-fast-install' option into LT_INIT's first parameter.])
]) ])
dnl aclocal-1.4 backwards compatibility: dnl aclocal-1.4 backwards compatibility:
...@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) ...@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_AIX_SONAME([DEFAULT])
# ----------------------------------
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
m4_define([_LT_WITH_AIX_SONAME],
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
shared_archive_member_spec=
case $host,$enable_shared in
power*-*-aix[[5-9]]*,yes)
AC_MSG_CHECKING([which variant of shared library versioning to provide])
AC_ARG_WITH([aix-soname],
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
with_aix_soname=$lt_cv_with_aix_soname])
AC_MSG_RESULT([$with_aix_soname])
if test aix != "$with_aix_soname"; then
# For the AIX way of multilib, we name the shared archive member
# based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
# and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
# Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
# the AIX toolchain works better with OBJECT_MODE set (default 32).
if test 64 = "${OBJECT_MODE-32}"; then
shared_archive_member_spec=shr_64
else
shared_archive_member_spec=shr
fi
fi
;;
*)
with_aix_soname=aix
;;
esac
_LT_DECL([], [shared_archive_member_spec], [0],
[Shared archive member basename, for filename based shared library versioning on AIX])dnl
])# _LT_WITH_AIX_SONAME
LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
# _LT_WITH_PIC([MODE]) # _LT_WITH_PIC([MODE])
# -------------------- # --------------------
# implement the --with-pic flag, and support the `pic-only' and `no-pic' # implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options. # LT_INIT options.
# MODE is either `yes' or `no'. If omitted, it defaults to `both'. # MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC], m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic], [AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
...@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC], ...@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
*) *)
pic_mode=default pic_mode=default
# Look at the argument we got. We use all the common list separators. # Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do for lt_pkg in $withval; do
IFS="$lt_save_ifs" IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes pic_mode=yes
fi fi
done done
IFS="$lt_save_ifs" IFS=$lt_save_ifs
;; ;;
esac], esac],
[pic_mode=default]) [pic_mode=m4_default([$1], [default])])
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC ])# _LT_WITH_PIC
...@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE], ...@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only]) [_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete], AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you [$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `pic-only' option into LT_INIT's first parameter.]) put the 'pic-only' option into LT_INIT's first parameter.])
]) ])
dnl aclocal-1.4 backwards compatibility: dnl aclocal-1.4 backwards compatibility:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment