diff mbox

[2/2] utils: add test for nfq_get_uid and nfq_get_gid

Message ID 1389101420-16557-3-git-send-email-valentina.giusti@bmw-carit.de
State Accepted
Headers show

Commit Message

valentina.giusti@bmw-carit.de Jan. 7, 2014, 1:30 p.m. UTC
From: Valentina Giusti <Valentina.Giusti@bmw-carit.de>

Signed-off-by: Valentina Giusti <Valentina.Giusti@bmw-carit.de>
---
 utils/nfqnl_test.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Pablo Neira Ayuso Jan. 7, 2014, 11:43 p.m. UTC | #1
Applied, but mangled the error message to avoid confusing users in
case they use an old kernel.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
valentina.giusti@bmw-carit.de Jan. 8, 2014, 9:36 a.m. UTC | #2
On 01/08/2014 12:43 AM, Pablo Neira Ayuso wrote:
> Applied, but mangled the error message to avoid confusing users in
> case they use an old kernel.
>
Thanks Pablo!

BR,
- Val
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/nfqnl_test.c b/utils/nfqnl_test.c
index a554f2d..c6b97c6 100644
--- a/utils/nfqnl_test.c
+++ b/utils/nfqnl_test.c
@@ -15,7 +15,7 @@  static u_int32_t print_pkt (struct nfq_data *tb)
 	int id = 0;
 	struct nfqnl_msg_packet_hdr *ph;
 	struct nfqnl_msg_packet_hw *hwph;
-	u_int32_t mark,ifi; 
+	u_int32_t mark, ifi, uid, gid;
 	int ret;
 	unsigned char *data;
 
@@ -55,6 +55,12 @@  static u_int32_t print_pkt (struct nfq_data *tb)
 	if (ifi)
 		printf("physoutdev=%u ", ifi);
 
+	if (nfq_get_uid(tb, &uid))
+		printf("uid=%u ", uid);
+
+	if (nfq_get_gid(tb, &gid))
+		printf("gid=%u ", gid);
+
 	ret = nfq_get_payload(tb, &data);
 	if (ret >= 0)
 		printf("payload_len=%d ", ret);
@@ -114,6 +120,10 @@  int main(int argc, char **argv)
 		exit(1);
 	}
 
+	printf("setting flags to request UID and GID\n");
+	if (nfq_set_queue_flags(qh, NFQA_CFG_F_UID_GID, NFQA_CFG_F_UID_GID))
+		fprintf(stderr, "can't request UID_GID flag\n");
+
 	fd = nfq_fd(h);
 
 	for (;;) {