summaryrefslogtreecommitdiffstats
path: root/src/meta.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-08-15 13:14:18 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-08-18 03:14:08 +0200
commit788c986343bc24bd0272e8aa409121ffe51f1ef3 (patch)
tree42cf0210e9fce93e0a5a951f0012e891fa750b05 /src/meta.c
parentddb1f1f8cdca2e0f70254a5adcc0291907503a36 (diff)
src: quote user-defined strings when used from rule selectors
The following selectors display strings using quotes: * meta iifname * meta oifname * meta ibriport * meta obriport However, the following do not: * meta oif * meta iif * meta skuid * meta skgid * meta iifgroup * meta oifgroup * meta rtclassid * ct label Given they refer to user-defined values, neither keywords nor internal built-in known values, let's quote the output of this. This patch modifies symbolic_constant_print() so we can signal this to indicate if the string needs to be quoted. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/meta.c')
-rw-r--r--src/meta.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/meta.c b/src/meta.c
index 9dd91de3..94263f90 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -47,7 +47,7 @@ static void __exit realm_table_exit(void)
static void realm_type_print(const struct expr *expr)
{
- return symbolic_constant_print(realm_tbl, expr);
+ return symbolic_constant_print(realm_tbl, expr, true);
}
static struct error_record *realm_type_parse(const struct expr *sym,
@@ -144,7 +144,7 @@ static void ifindex_type_print(const struct expr *expr)
ifindex = mpz_get_uint32(expr->value);
if (nft_if_indextoname(ifindex, name))
- printf("%s", name);
+ printf("\"%s\"", name);
else
printf("%d", ifindex);
}
@@ -208,7 +208,7 @@ static void uid_type_print(const struct expr *expr)
pw = getpwuid(uid);
if (pw != NULL)
- printf("%s", pw->pw_name);
+ printf("\"%s\"", pw->pw_name);
else
printf("%d", uid);
return;
@@ -260,7 +260,7 @@ static void gid_type_print(const struct expr *expr)
gr = getgrgid(gid);
if (gr != NULL)
- printf("%s", gr->gr_name);
+ printf("\"%s\"", gr->gr_name);
else
printf("%u", gid);
return;
@@ -314,7 +314,7 @@ static const struct symbol_table pkttype_type_tbl = {
static void pkttype_type_print(const struct expr *expr)
{
- return symbolic_constant_print(&pkttype_type_tbl, expr);
+ return symbolic_constant_print(&pkttype_type_tbl, expr, false);
}
static const struct datatype pkttype_type = {
@@ -341,7 +341,7 @@ static void __exit devgroup_table_exit(void)
static void devgroup_type_print(const struct expr *expr)
{
- return symbolic_constant_print(devgroup_tbl, expr);
+ return symbolic_constant_print(devgroup_tbl, expr, true);
}
static struct error_record *devgroup_type_parse(const struct expr *sym,