diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-04-20 12:06:19 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-04-20 12:07:34 +0200 |
commit | 2929619a2533b0d9970651391649f6e5651148a4 (patch) | |
tree | 90a495c26dd72ec8a3ae1b46f74b7e5aa13b41da | |
parent | 220c8044895ae567bb5010418a38200d7c94cc2b (diff) |
meta: accept uid/gid in numerical
You can use the user/group name or alternatively the uid/gid.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | src/meta.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -219,8 +219,12 @@ static struct error_record *uid_type_parse(const struct expr *sym, struct passwd *pw; pw = getpwnam(sym->identifier); - if (pw == NULL) - return error(&sym->location, "User does not exist"); + if (pw == NULL) { + /* Try harder, lookup based on UID */ + pw = getpwuid(atol(sym->identifier)); + if (pw == NULL) + return error(&sym->location, "User does not exist"); + } *res = constant_expr_alloc(&sym->location, sym->dtype, BYTEORDER_HOST_ENDIAN, @@ -260,8 +264,12 @@ static struct error_record *gid_type_parse(const struct expr *sym, struct group *gr; gr = getgrnam(sym->identifier); - if (gr == NULL) - return error(&sym->location, "Group does not exist"); + if (gr == NULL) { + /* Try harder, lookup based on GID */ + gr = getgrgid(atol(sym->identifier)); + if (gr == NULL) + return error(&sym->location, "Group does not exist"); + } *res = constant_expr_alloc(&sym->location, sym->dtype, BYTEORDER_HOST_ENDIAN, |