diff --git a/usr.bin/getent/getent.1 b/usr.bin/getent/getent.1 index d8e06f99b4ca..3559e0274f59 100644 --- a/usr.bin/getent/getent.1 +++ b/usr.bin/getent/getent.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: getent.1,v 1.8 2004/12/03 23:05:32 lukem Exp $ +.\" $NetBSD: getent.1,v 1.9 2005/01/21 02:43:33 ginsbach Exp $ .\" .\" Copyright (c) 2004 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -67,6 +67,7 @@ may be one of: .It networks Ta name network [alias ...] .It passwd Ta user:passwd:uid:gid:gecos:home_dir_shell .It protocols Ta name protocol [alias ...] +.It rpc Ta name number [alias ...] .It services Ta name port/protocol [alias ...] .It shells Ta /path/to/shell .El @@ -105,6 +106,7 @@ or 3 if there is no support for enumeration on .Xr nsswitch.conf 5 , .Xr passwd 5 , .Xr protocols 5 , +.Xr rpc 5 , .Xr services 5 , .Xr shells 5 .Sh HISTORY diff --git a/usr.bin/getent/getent.c b/usr.bin/getent/getent.c index 4b6ac753d006..f018cb4d49d7 100644 --- a/usr.bin/getent/getent.c +++ b/usr.bin/getent/getent.c @@ -1,4 +1,4 @@ -/* $NetBSD: getent.c,v 1.5 2004/11/29 05:02:40 lukem Exp $ */ +/* $NetBSD: getent.c,v 1.6 2005/01/21 02:43:33 ginsbach Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #ifndef lint -__RCSID("$NetBSD: getent.c,v 1.5 2004/11/29 05:02:40 lukem Exp $"); +__RCSID("$NetBSD: getent.c,v 1.6 2005/01/21 02:43:33 ginsbach Exp $"); #endif /* not lint */ #include @@ -61,6 +61,8 @@ __RCSID("$NetBSD: getent.c,v 1.5 2004/11/29 05:02:40 lukem Exp $"); #include /* for INET6_ADDRSTRLEN */ +#include + static int usage(void); static int parsenum(const char *, unsigned long *); static int group(int, char *[]); @@ -68,6 +70,7 @@ static int hosts(int, char *[]); static int networks(int, char *[]); static int passwd(int, char *[]); static int protocols(int, char *[]); +static int rpc(int, char *[]); static int services(int, char *[]); static int shells(int, char *[]); @@ -87,6 +90,7 @@ static struct getentdb { { "networks", networks, }, { "passwd", passwd, }, { "protocols", protocols, }, + { "rpc", rpc, }, { "services", services, }, { "shells", shells, }, @@ -404,6 +408,46 @@ protocols(int argc, char *argv[]) return rv; } + /* + * rpc + */ + +static int +rpc(int argc, char *argv[]) +{ + struct rpcent *re; + unsigned long id; + int i, rv; + + assert(argc > 1); + assert(argv != NULL); + +#define RPCPRINT printfmtstrings(re->r_aliases, " ", " ", \ + "%-16s %6d", \ + re->r_name, re->r_number) + + setrpcent(1); + rv = RV_OK; + if (argc == 2) { + while ((re = getrpcent()) != NULL) + RPCPRINT; + } else { + for (i = 2; i < argc; i++) { + if (parsenum(argv[i], &id)) + re = getrpcbynumber((int)id); + else + re = getrpcbyname(argv[i]); + if (re != NULL) + RPCPRINT; + else { + rv = RV_NOTFOUND; + break; + } + } + } + endrpcent(); + return rv; +} /* * services