From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 16 13:00:08 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F3481065673 for ; Mon, 16 Mar 2009 13:00:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BE7F38FC17 for ; Mon, 16 Mar 2009 13:00:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n2GD073u090511 for ; Mon, 16 Mar 2009 13:00:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n2GD071p090510; Mon, 16 Mar 2009 13:00:07 GMT (envelope-from gnats) Resent-Date: Mon, 16 Mar 2009 13:00:07 GMT Resent-Message-Id: <200903161300.n2GD071p090510@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, Andrey Zonov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 62E80106564A for ; Mon, 16 Mar 2009 12:54:04 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 519A68FC16 for ; Mon, 16 Mar 2009 12:54:04 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n2GCs3H5087569 for ; Mon, 16 Mar 2009 12:54:03 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n2GCs3gH087550; Mon, 16 Mar 2009 12:54:03 GMT (envelope-from nobody) Message-Id: <200903161254.n2GCs3gH087550@www.freebsd.org> Date: Mon, 16 Mar 2009 12:54:03 GMT From: Andrey Zonov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/132692: [getent] [patch] no support for netgroup 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: Mon, 16 Mar 2009 13:00:08 -0000 >Number: 132692 >Category: bin >Synopsis: [getent] [patch] no support for netgroup >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Mar 16 13:00:07 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Andrey Zonov >Release: 7.1-RELEASE-p2 >Organization: >Environment: FreeBSD [hide] 7.1-RELEASE-p2 FreeBSD 7.1-RELEASE-p2 #0: Sun Jan 18 16:15:29 MSK 2009 root@[hide]:/place/usr/obj/place/usr/src/sys/GENERIC amd64 >Description: In FreeBSD getent not supported source "netgroup" :( In NetBSD "getent netgroup" is enable and i make patch for FreeBSD. >How-To-Repeat: >Fix: Patch attached with submission follows: --- getent.c.orig 2009-03-16 14:47:44.000000000 +0300 +++ getent.c 2009-03-16 14:54:13.000000000 +0300 @@ -60,6 +60,7 @@ #include #include #include +#include static int usage(void); static int parsenum(const char *, unsigned long *); @@ -72,6 +73,8 @@ static int rpc(int, char *[]); static int services(int, char *[]); static int shells(int, char *[]); +static int netgroup(int, char *[]); + enum { RV_OK = 0, @@ -93,6 +96,7 @@ { "rpc", rpc, }, { "services", services, }, { "shells", shells, }, + { "netgroup", netgroup, }, { NULL, NULL, }, }; @@ -562,3 +566,44 @@ endusershell(); return rv; } + +/* + * netgroup + */ +static int +netgroup(int argc, char *argv[]) +{ + const char *host, *user, *domain; + bool first; + int rv, i; + + assert(argc > 1); + assert(argv != NULL); + +#define NETGROUPPRINT(s) (((s) != NULL) ? (s) : "") + + rv = RV_OK; + if (argc == 2) { + warnx("Enumeration not supported on netgroup"); + rv = RV_NOENUM; + } else { + for (i = 2; i < argc; i++) { + setnetgrent(argv[i]); + first = true; + while (getnetgrent(&host, &user, &domain) != 0) { + if (first) { + first = false; + (void)fputs(argv[i], stdout); + } + (void)printf(" (%s,%s,%s)", + NETGROUPPRINT(host), + NETGROUPPRINT(user), + NETGROUPPRINT(domain)); + } + if (!first) + (void)putchar('\n'); + endnetgrent(); + } + } + return rv; +} >Release-Note: >Audit-Trail: >Unformatted: