summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/json.c4
-rw-r--r--src/main.c11
-rw-r--r--src/meta.c4
3 files changed, 14 insertions, 5 deletions
diff --git a/src/json.c b/src/json.c
index 5c96bcd0..e90445fc 100644
--- a/src/json.c
+++ b/src/json.c
@@ -1021,7 +1021,7 @@ json_t *uid_type_json(const struct expr *expr, struct output_ctx *octx)
{
uint32_t uid = mpz_get_uint32(expr->value);
- if (octx->numeric < NFT_NUMERIC_ALL) {
+ if (nft_output_guid(octx)) {
struct passwd *pw = getpwuid(uid);
if (pw)
@@ -1034,7 +1034,7 @@ json_t *gid_type_json(const struct expr *expr, struct output_ctx *octx)
{
uint32_t gid = mpz_get_uint32(expr->value);
- if (octx->numeric < NFT_NUMERIC_ALL) {
+ if (nft_output_guid(octx)) {
struct group *gr = getgrgid(gid);
if (gr)
diff --git a/src/main.c b/src/main.c
index 6e1e4186..0c8fa1e9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -39,10 +39,11 @@ enum opt_vals {
OPT_DEBUG = 'd',
OPT_HANDLE_OUTPUT = 'a',
OPT_ECHO = 'e',
+ OPT_GUID = 'u',
OPT_INVALID = '?',
};
-#define OPTSTRING "hvcf:iI:jvnsNaeS"
+#define OPTSTRING "hvcf:iI:jvnsNaeSu"
static const struct option options[] = {
{
@@ -105,6 +106,10 @@ static const struct option options[] = {
.val = OPT_JSON,
},
{
+ .name = "guid",
+ .val = OPT_GUID,
+ },
+ {
.name = NULL
}
};
@@ -127,6 +132,7 @@ static void show_help(const char *name)
" Specify twice to also show Internet services (port numbers) numerically.\n"
" Specify three times to also show protocols, user IDs, and group IDs numerically.\n"
" -s, --stateless Omit stateful information of ruleset.\n"
+" -u, --guid Print UID/GID as defined in /etc/passwd and /etc/group.\n"
" -N Translate IP addresses to names.\n"
" -S, --service Translate ports to service names as described in /etc/services.\n"
" -a, --handle Output rule handle.\n"
@@ -276,6 +282,9 @@ int main(int argc, char * const *argv)
output_flags |= NFT_CTX_OUTPUT_JSON;
#endif
break;
+ case OPT_GUID:
+ output_flags |= NFT_CTX_OUTPUT_GUID;
+ break;
case OPT_INVALID:
exit(EXIT_FAILURE);
}
diff --git a/src/meta.c b/src/meta.c
index 3677561b..c8a7b13b 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -207,7 +207,7 @@ static void uid_type_print(const struct expr *expr, struct output_ctx *octx)
{
struct passwd *pw;
- if (octx->numeric < NFT_NUMERIC_ALL) {
+ if (nft_output_guid(octx)) {
uint32_t uid = mpz_get_uint32(expr->value);
pw = getpwuid(uid);
@@ -260,7 +260,7 @@ static void gid_type_print(const struct expr *expr, struct output_ctx *octx)
{
struct group *gr;
- if (octx->numeric < NFT_NUMERIC_ALL) {
+ if (nft_output_guid(octx)) {
uint32_t gid = mpz_get_uint32(expr->value);
gr = getgrgid(gid);