summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/unix-formats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra/unix-formats.c')
-rw-r--r--src/vppinfra/unix-formats.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vppinfra/unix-formats.c b/src/vppinfra/unix-formats.c
index a4c81ca2f70..91986516108 100644
--- a/src/vppinfra/unix-formats.c
+++ b/src/vppinfra/unix-formats.c
@@ -49,6 +49,7 @@
#include <unistd.h>
#include <signal.h>
+#include <grp.h>
#include <time.h>
#include <sys/socket.h>
@@ -915,4 +916,29 @@ u8 * format_ucontext_pc (u8 * s, va_list * args)
return format (s, "%p", regs[reg_no]);
}
+uword
+unformat_unix_gid (unformat_input_t * input, va_list * args)
+{
+ gid_t *gid = va_arg (*args, gid_t *);
+ struct group *grp = 0;
+ int r;
+ u8 *s;
+
+ if (unformat (input, "%d", &r))
+ {
+ grp = getgrgid (r);
+ }
+ else if (unformat (input, "%s", &s))
+ {
+ grp = getgrnam ((char *) s);
+ vec_free (s);
+ }
+ if (grp)
+ {
+ *gid = grp->gr_gid;
+ return 1;
+ }
+ return 0;
+}
+
#endif /* __KERNEL__ */