From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 3 17:20:13 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B452916A41F for ; Thu, 3 Nov 2005 17:20:13 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D33BE43D49 for ; Thu, 3 Nov 2005 17:20:12 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id jA3HKCvC060543 for ; Thu, 3 Nov 2005 17:20:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id jA3HKCXj060542; Thu, 3 Nov 2005 17:20:12 GMT (envelope-from gnats) Resent-Date: Thu, 3 Nov 2005 17:20:12 GMT Resent-Message-Id: <200511031720.jA3HKCXj060542@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Nelson Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF4D416A41F for ; Thu, 3 Nov 2005 17:18:34 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id B7E9843D46 for ; Thu, 3 Nov 2005 17:18:33 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id jA3HIWm8035745; Thu, 3 Nov 2005 11:18:32 -0600 (CST) (envelope-from dan) Message-Id: <200511031718.jA3HIWm8035745@dan.emsphone.com> Date: Thu, 3 Nov 2005 11:18:32 -0600 (CST) From: Dan Nelson To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/88460: Import /usr/bin/getent from NetBSD X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2005 17:20:13 -0000 >Number: 88460 >Category: bin >Synopsis: Import /usr/bin/getent from NetBSD >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Nov 03 17:20:12 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Dan Nelson >Release: FreeBSD 5.4-STABLE i386 >Organization: The Allant Group >Environment: System: FreeBSD dan.emsphone.com 5.4-STABLE FreeBSD 5.4-STABLE #415: Wed Oct 26 12:24:22 CDT 2005 zsh@dan.emsphone.com:/usr/src/sys/i386/compile/DANSMP i386 >Description: I miss the getent command, which is available in a lot of other OSes. This is NetBSD's version, which builds cleanly with only some include changes. >How-To-Repeat: >Fix: Included are the diffs from NetBSD's sources, plus a shar of the resulting files. diff -bup getent-netbsd/Makefile getent-dan/Makefile --- getent-netbsd/Makefile Sun Nov 28 23:02:52 2004 +++ getent-dan/Makefile Thu Nov 3 11:06:00 2005 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2004/11/29 05:02:52 lukem Exp $ +# $FreeBSD$ WARNS= 3 PROG= getent diff -bup getent-netbsd/getent.1 getent-dan/getent.1 --- getent-netbsd/getent.1 Sun Sep 11 18:16:15 2005 +++ getent-dan/getent.1 Thu Nov 3 11:05:26 2005 @@ -34,6 +34,8 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" +.\" $FreeBSD$ +.\" .Dd August 24, 2005 .Dt GETENT 1 .Os @@ -118,7 +120,9 @@ or 3 if there is no support for enumerat A .Nm command appeared in -.Nx 3.0 . +.Nx 3.0 , +and was imported into +.Fx 7.0 . It was based on the command of the same name in .Tn Solaris and diff -bup getent-netbsd/getent.c getent-dan/getent.c --- getent-netbsd/getent.c Wed Aug 24 09:31:02 2005 +++ getent-dan/getent.c Thu Nov 3 11:02:00 2005 @@ -37,11 +37,16 @@ */ #include +#if 0 #ifndef lint __RCSID("$NetBSD: getent.c,v 1.7 2005/08/24 14:31:02 ginsbach Exp $"); #endif /* not lint */ +#endif + +__FBSDID("$FreeBSD$"); #include +#include #include #include @@ -60,7 +65,7 @@ __RCSID("$NetBSD: getent.c,v 1.7 2005/08 #include #include -#include +#include #include /* for INET6_ADDRSTRLEN */ # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # getent.1 # getent.c # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' X# $FreeBSD$ X XWARNS= 3 XPROG= getent X X.include END-of-Makefile echo x - getent.1 sed 's/^X//' >getent.1 << 'END-of-getent.1' X.\" $NetBSD: getent.1,v 1.13 2005/09/11 23:16:15 wiz Exp $ X.\" X.\" Copyright (c) 2004 The NetBSD Foundation, Inc. X.\" All rights reserved. X.\" X.\" This code is derived from software contributed to The NetBSD Foundation X.\" by Luke Mewburn. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 3. All advertising materials mentioning features or use of this software X.\" must display the following acknowledgement: X.\" This product includes software developed by the NetBSD X.\" Foundation, Inc. and its contributors. X.\" 4. Neither the name of The NetBSD Foundation nor the names of its X.\" contributors may be used to endorse or promote products derived X.\" from this software without specific prior written permission. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS X.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED X.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR X.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS X.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR X.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF X.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS X.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN X.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) X.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE X.\" POSSIBILITY OF SUCH DAMAGE. X.\" X.\" $FreeBSD$ X.\" X.Dd August 24, 2005 X.Dt GETENT 1 X.Os X.Sh NAME X.Nm getent X.Nd get entries from administrative database X.Sh SYNOPSIS X.Nm X.Ar database X.Op Ar key ... X.Sh DESCRIPTION XThe X.Nm Xprogram retrieves and displays entries from the administrative Xdatabase specified by X.Ar database , Xusing the lookup order specified in X.Xr nsswitch.conf 5 . XThe display format for a given X.Ar database Xis as per the X.Dq traditional Xfile format for that database. X.Pp X.Ar database Xmay be one of: X.Bl -column "netgroup" -offset indent -compact X.Sy Database Ta Sy Display format X.It ethers Ta address name X.It group Ta group:passwd:gid:[member[,member]...] X.It hosts Ta address name [alias ...] X.It networks Ta name network [alias ...] X.It passwd Ta user:passwd:uid:gid:gecos:home_dir:shell X.It protocols Ta name protocol [alias ...] X.It rpc Ta name number [alias ...] X.It services Ta name port/protocol [alias ...] X.It shells Ta /path/to/shell X.El X.Pp XIf one or more X.Ar key Xarguments are provided, they will be looked up in X.Ar database Xusing the appropriate function. XFor example, X.Sy passwd Xsupports a numeric UID or user name; X.Sy hosts Xsupports an IPv4 address, IPv6 address, or host name; Xand X.Sy services Xsupports a service name, service name/protocol name, numeric port, or Xnumeric port/protocol name. X.Pp XIf no X.Ar key Xis provided and X.Ar database Xsupports enumeration, all entries for X.Ar database Xwill be retrieved using the appropriate enumeration function and printed. X.Sh DIAGNOSTICS X.Nm Xexits 0 on success, X1 if there was an error in the command syntax, X2 if one of the specified key names was not found in X.Ar database , Xor 3 if there is no support for enumeration on X.Ar database . X.Sh SEE ALSO X.Xr ethers 5 , X.Xr group 5 , X.Xr hosts 5 , X.Xr networks 5 , X.Xr nsswitch.conf 5 , X.Xr passwd 5 , X.Xr protocols 5 , X.Xr rpc 5 , X.Xr services 5 , X.Xr shells 5 X.Sh HISTORY XA X.Nm Xcommand appeared in X.Nx 3.0 , Xand was imported into X.Fx 7.0 . XIt was based on the command of the same name in X.Tn Solaris Xand X.Tn Linux . END-of-getent.1 echo x - getent.c sed 's/^X//' >getent.c << 'END-of-getent.c' X/* $NetBSD: getent.c,v 1.7 2005/08/24 14:31:02 ginsbach Exp $ */ X X/*- X * Copyright (c) 2004 The NetBSD Foundation, Inc. X * All rights reserved. X * X * This code is derived from software contributed to The NetBSD Foundation X * by Luke Mewburn. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by the NetBSD X * Foundation, Inc. and its contributors. X * 4. Neither the name of The NetBSD Foundation nor the names of its X * contributors may be used to endorse or promote products derived X * from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS X * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED X * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR X * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS X * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR X * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF X * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS X * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN X * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) X * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE X * POSSIBILITY OF SUCH DAMAGE. X */ X X#include X#if 0 X#ifndef lint X__RCSID("$NetBSD: getent.c,v 1.7 2005/08/24 14:31:02 ginsbach Exp $"); X#endif /* not lint */ X#endif X X__FBSDID("$FreeBSD$"); X X#include X#include X X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X X#include X#include X X#include X#include X X#include /* for INET6_ADDRSTRLEN */ X X#include X Xstatic int usage(void); Xstatic int parsenum(const char *, unsigned long *); Xstatic int ethers(int, char *[]); Xstatic int group(int, char *[]); Xstatic int hosts(int, char *[]); Xstatic int networks(int, char *[]); Xstatic int passwd(int, char *[]); Xstatic int protocols(int, char *[]); Xstatic int rpc(int, char *[]); Xstatic int services(int, char *[]); Xstatic int shells(int, char *[]); X Xenum { X RV_OK = 0, X RV_USAGE = 1, X RV_NOTFOUND = 2, X RV_NOENUM = 3, X}; X Xstatic struct getentdb { X const char *name; X int (*callback)(int, char *[]); X} databases[] = { X { "ethers", ethers, }, X { "group", group, }, X { "hosts", hosts, }, X { "networks", networks, }, X { "passwd", passwd, }, X { "protocols", protocols, }, X { "rpc", rpc, }, X { "services", services, }, X { "shells", shells, }, X X { NULL, NULL, }, X}; X X Xint Xmain(int argc, char *argv[]) X{ X struct getentdb *curdb; X X setprogname(argv[0]); X X if (argc < 2) X usage(); X for (curdb = databases; curdb->name != NULL; curdb++) { X if (strcmp(curdb->name, argv[1]) == 0) { X exit(curdb->callback(argc, argv)); X break; X } X } X fprintf(stderr, "Unknown database: %s\n", argv[1]); X usage(); X /* NOTREACHED */ X return RV_USAGE; X} X Xstatic int Xusage(void) X{ X struct getentdb *curdb; X X fprintf(stderr, "Usage: %s database [key ...]\n", X getprogname()); X fprintf(stderr, " database may be one of:\n\t"); X for (curdb = databases; curdb->name != NULL; curdb++) { X fprintf(stderr, " %s", curdb->name); X } X fprintf(stderr, "\n"); X exit(RV_USAGE); X /* NOTREACHED */ X} X Xstatic int Xparsenum(const char *word, unsigned long *result) X{ X unsigned long num; X char *ep; X X assert(word != NULL); X assert(result != NULL); X X if (!isdigit((unsigned char)word[0])) X return 0; X errno = 0; X num = strtoul(word, &ep, 10); X if (num == ULONG_MAX && errno == ERANGE) X return 0; X if (*ep != '\0') X return 0; X *result = num; X return 1; X} X X/* X * printfmtstrings -- X * vprintf(format, ...), X * then the aliases (beginning with prefix, separated by sep), X * then a newline X */ Xstatic void Xprintfmtstrings(char *strings[], const char *prefix, const char *sep, X const char *fmt, ...) X{ X va_list ap; X const char *curpref; X int i; X X va_start(ap, fmt); X vprintf(fmt, ap); X X curpref = prefix; X for (i = 0; strings[i] != NULL; i++) { X printf("%s%s", curpref, strings[i]); X curpref = sep; X } X printf("\n"); X} X X X /* X * ethers X */ X Xstatic int Xethers(int argc, char *argv[]) X{ X char hostname[MAXHOSTNAMELEN + 1], *hp; X struct ether_addr ea, *eap; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X#define ETHERSPRINT printf("%-17s %s\n", ether_ntoa(eap), hp) X X rv = RV_OK; X if (argc == 2) { X fprintf(stderr, "Enumeration not supported on ethers\n"); X rv = RV_NOENUM; X } else { X for (i = 2; i < argc; i++) { X if ((eap = ether_aton(argv[i])) == NULL) { X eap = &ea; X hp = argv[i]; X if (ether_hostton(hp, eap) != 0) { X rv = RV_NOTFOUND; X break; X } X } else { X hp = hostname; X if (ether_ntohost(hp, eap) != 0) { X rv = RV_NOTFOUND; X break; X } X } X ETHERSPRINT; X } X } X return rv; X} X X /* X * group X */ X Xstatic int Xgroup(int argc, char *argv[]) X{ X struct group *gr; X unsigned long id; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X#define GROUPPRINT printfmtstrings(gr->gr_mem, ":", ",", "%s:%s:%u", \ X gr->gr_name, gr->gr_passwd, gr->gr_gid) X X setgroupent(1); X rv = RV_OK; X if (argc == 2) { X while ((gr = getgrent()) != NULL) X GROUPPRINT; X } else { X for (i = 2; i < argc; i++) { X if (parsenum(argv[i], &id)) X gr = getgrgid((gid_t)id); X else X gr = getgrnam(argv[i]); X if (gr != NULL) X GROUPPRINT; X else { X rv = RV_NOTFOUND; X break; X } X } X } X endgrent(); X return rv; X} X X X /* X * hosts X */ X Xstatic void Xhostsprint(const struct hostent *he) X{ X char buf[INET6_ADDRSTRLEN]; X X assert(he != NULL); X if (inet_ntop(he->h_addrtype, he->h_addr, buf, sizeof(buf)) == NULL) X strlcpy(buf, "# unknown", sizeof(buf)); X printfmtstrings(he->h_aliases, " ", " ", "%-16s %s", buf, he->h_name); X} X Xstatic int Xhosts(int argc, char *argv[]) X{ X struct hostent *he; X char addr[IN6ADDRSZ]; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X sethostent(1); X rv = RV_OK; X if (argc == 2) { X while ((he = gethostent()) != NULL) X hostsprint(he); X } else { X for (i = 2; i < argc; i++) { X if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0) X he = gethostbyaddr(addr, IN6ADDRSZ, AF_INET6); X else if (inet_pton(AF_INET, argv[i], (void *)addr) > 0) X he = gethostbyaddr(addr, INADDRSZ, AF_INET); X else X he = gethostbyname(argv[i]); X if (he != NULL) X hostsprint(he); X else { X rv = RV_NOTFOUND; X break; X } X } X } X endhostent(); X return rv; X} X X X /* X * networks X */ X Xstatic void Xnetworksprint(const struct netent *ne) X{ X char buf[INET6_ADDRSTRLEN]; X struct in_addr ianet; X X assert(ne != NULL); X ianet = inet_makeaddr(ne->n_net, 0); X if (inet_ntop(ne->n_addrtype, &ianet, buf, sizeof(buf)) == NULL) X strlcpy(buf, "# unknown", sizeof(buf)); X printfmtstrings(ne->n_aliases, " ", " ", "%-16s %s", ne->n_name, buf); X} X Xstatic int Xnetworks(int argc, char *argv[]) X{ X struct netent *ne; X in_addr_t net; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X setnetent(1); X rv = RV_OK; X if (argc == 2) { X while ((ne = getnetent()) != NULL) X networksprint(ne); X } else { X for (i = 2; i < argc; i++) { X net = inet_network(argv[i]); X if (net != INADDR_NONE) X ne = getnetbyaddr(net, AF_INET); X else X ne = getnetbyname(argv[i]); X if (ne != NULL) X networksprint(ne); X else { X rv = RV_NOTFOUND; X break; X } X } X } X endnetent(); X return rv; X} X X X /* X * passwd X */ X Xstatic int Xpasswd(int argc, char *argv[]) X{ X struct passwd *pw; X unsigned long id; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X#define PASSWDPRINT printf("%s:%s:%u:%u:%s:%s:%s\n", \ X pw->pw_name, pw->pw_passwd, pw->pw_uid, \ X pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell) X X setpassent(1); X rv = RV_OK; X if (argc == 2) { X while ((pw = getpwent()) != NULL) X PASSWDPRINT; X } else { X for (i = 2; i < argc; i++) { X if (parsenum(argv[i], &id)) X pw = getpwuid((uid_t)id); X else X pw = getpwnam(argv[i]); X if (pw != NULL) X PASSWDPRINT; X else { X rv = RV_NOTFOUND; X break; X } X } X } X endpwent(); X return rv; X} X X X /* X * protocols X */ X Xstatic int Xprotocols(int argc, char *argv[]) X{ X struct protoent *pe; X unsigned long id; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X#define PROTOCOLSPRINT printfmtstrings(pe->p_aliases, " ", " ", \ X "%-16s %5d", pe->p_name, pe->p_proto) X X setprotoent(1); X rv = RV_OK; X if (argc == 2) { X while ((pe = getprotoent()) != NULL) X PROTOCOLSPRINT; X } else { X for (i = 2; i < argc; i++) { X if (parsenum(argv[i], &id)) X pe = getprotobynumber((int)id); X else X pe = getprotobyname(argv[i]); X if (pe != NULL) X PROTOCOLSPRINT; X else { X rv = RV_NOTFOUND; X break; X } X } X } X endprotoent(); X return rv; X} X X /* X * rpc X */ X Xstatic int Xrpc(int argc, char *argv[]) X{ X struct rpcent *re; X unsigned long id; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X#define RPCPRINT printfmtstrings(re->r_aliases, " ", " ", \ X "%-16s %6d", \ X re->r_name, re->r_number) X X setrpcent(1); X rv = RV_OK; X if (argc == 2) { X while ((re = getrpcent()) != NULL) X RPCPRINT; X } else { X for (i = 2; i < argc; i++) { X if (parsenum(argv[i], &id)) X re = getrpcbynumber((int)id); X else X re = getrpcbyname(argv[i]); X if (re != NULL) X RPCPRINT; X else { X rv = RV_NOTFOUND; X break; X } X } X } X endrpcent(); X return rv; X} X X /* X * services X */ X Xstatic int Xservices(int argc, char *argv[]) X{ X struct servent *se; X unsigned long id; X char *proto; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X#define SERVICESPRINT printfmtstrings(se->s_aliases, " ", " ", \ X "%-16s %5d/%s", \ X se->s_name, ntohs(se->s_port), se->s_proto) X X setservent(1); X rv = RV_OK; X if (argc == 2) { X while ((se = getservent()) != NULL) X SERVICESPRINT; X } else { X for (i = 2; i < argc; i++) { X proto = strchr(argv[i], '/'); X if (proto != NULL) X *proto++ = '\0'; X if (parsenum(argv[i], &id)) X se = getservbyport((int)id, proto); X else X se = getservbyname(argv[i], proto); X if (se != NULL) X SERVICESPRINT; X else { X rv = RV_NOTFOUND; X break; X } X } X } X endservent(); X return rv; X} X X X /* X * shells X */ X Xstatic int Xshells(int argc, char *argv[]) X{ X const char *sh; X int i, rv; X X assert(argc > 1); X assert(argv != NULL); X X#define SHELLSPRINT printf("%s\n", sh) X X setusershell(); X rv = RV_OK; X if (argc == 2) { X while ((sh = getusershell()) != NULL) X SHELLSPRINT; X } else { X for (i = 2; i < argc; i++) { X setusershell(); X while ((sh = getusershell()) != NULL) { X if (strcmp(sh, argv[i]) == 0) { X SHELLSPRINT; X break; X } X } X if (sh == NULL) { X rv = RV_NOTFOUND; X break; X } X } X } X endusershell(); X return rv; X} END-of-getent.c exit >Release-Note: >Audit-Trail: >Unformatted: