Thread (5 messages) flat view 5 messages, 3 authors, 2018-02-20

Re: [PATCH iproute2-next v2] ip link: add support to display extended tun attributes

From: David Ahern <hidden>
Date: 2018-02-20 20:19:07

On 2/20/18 11:40 AM, Stephen Hemminger wrote:
quoted
quoted
diff --git a/ip/iptuntap.c b/ip/iptuntap.c
index 4628db2832b4..07253870472f 100644
--- a/ip/iptuntap.c
+++ b/ip/iptuntap.c
@@ -469,3 +469,89 @@ int do_iptuntap(int argc, char **argv)
 		*argv);
 	exit(-1);
 }
+
+static void print_owner(FILE *f, uid_t uid)
+{
+	struct passwd *pw = getpwuid(uid);
+
+	if (pw)
+		fprintf(f, "user %s ", pw->pw_name);
+	else
+		fprintf(f, "user %u ", uid);
+}
+
+static void print_group(FILE *f, gid_t gid)
+{
+	struct group *group = getgrgid(gid);
+
+	if (group)
+		fprintf(f, "group %s ", group->gr_name);
+	else
+		fprintf(f, "group %u ", gid);
+}
+  

Those helpers can be re-used to make 'ip tuntap show' better too.
These should support JSON output.
Good point. Missed that detail. Sabrina: Please send a patch to fix the
json output.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help