From nobody@FreeBSD.org  Mon Mar 16 12:54:04 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 62E80106564A
	for <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <andrey.zonov@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [getent] [patch] no support for netgroup
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         132692
>Category:       bin
>Synopsis:       [patch] getent(1): no support for netgroup
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 16 13:00:07 UTC 2009
>Closed-Date:    Thu May 23 15:53:17 CDT 2013
>Last-Modified:  Thu May 23 21:00:00 UTC 2013
>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 <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <stdbool.h>
 
 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:
Date: Thu, 18 Oct 2012 07:42:59 +0200
From: Johannes Knauf <johannes.knauf@physik.uni-erlangen.de>
To: bug-followup@FreeBSD.org, andrey.zonov@gmail.com
Subject: Re: bin/132692: [patch] getent(1): no support for netgroup

 getent netgroup is still missing in 9.1-RC2 although it is definitely needed.
State-Changed-From-To: open->closed 
State-Changed-By: ghelmer 
State-Changed-When: Thu May 23 15:52:48 CDT 2013 
State-Changed-Why:  
Committed to current in rev 250942. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132692 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/132692: commit references a PR
Date: Thu, 23 May 2013 20:52:43 +0000 (UTC)

 Author: ghelmer
 Date: Thu May 23 20:52:30 2013
 New Revision: 250942
 URL: http://svnweb.freebsd.org/changeset/base/250942
 
 Log:
   Add support for netgroup, based on patch in the PR but made consistent
   with existing style.
   
   PR:		bin/132692
 
 Modified:
   head/usr.bin/getent/getent.c
 
 Modified: head/usr.bin/getent/getent.c
 ==============================================================================
 --- head/usr.bin/getent/getent.c	Thu May 23 19:50:36 2013	(r250941)
 +++ head/usr.bin/getent/getent.c	Thu May 23 20:52:30 2013	(r250942)
 @@ -61,6 +61,7 @@ static int	parsenum(const char *, unsign
  static int	ethers(int, char *[]);
  static int	group(int, char *[]);
  static int	hosts(int, char *[]);
 +static int	netgroup(int, char *[]);
  static int	networks(int, char *[]);
  static int	passwd(int, char *[]);
  static int	protocols(int, char *[]);
 @@ -89,6 +90,7 @@ static struct getentdb {
  	{	"rpc",		rpc,		},
  	{	"services",	services,	},
  	{	"shells",	shells,		},
 +	{	"netgroup",	netgroup,	},
  	{	"utmpx",	utmpx,		},
  
  	{	NULL,		NULL,		},
 @@ -571,6 +573,47 @@ shells(int argc, char *argv[])
  }
  
  /*
 + * netgroup
 + */
 +static int
 +netgroup(int argc, char *argv[])
 +{
 +	char		*host, *user, *domain;
 +	int		first;
 +	int		rv, i;
 +
 +	assert(argc > 1);
 +	assert(argv != NULL);
 +
 +#define NETGROUPPRINT(s)	(((s) != NULL) ? (s) : "")
 +
 +	rv = RV_OK;
 +	if (argc == 2) {
 +		fprintf(stderr, "Enumeration not supported on netgroup\n");
 +		rv = RV_NOENUM;
 +	} else {
 +		for (i = 2; i < argc; i++) {
 +			setnetgrent(argv[i]);
 +			first = 1;
 +			while (getnetgrent(&host, &user, &domain) != 0) {
 +				if (first) {
 +					first = 0;
 +					(void)fputs(argv[i], stdout);
 +				}
 +				(void)printf(" (%s,%s,%s)",
 +				    NETGROUPPRINT(host),
 +				    NETGROUPPRINT(user),
 +				    NETGROUPPRINT(domain));
 +			}
 +			if (!first)
 +				(void)putchar('\n');
 +			endnetgrent();
 +		}
 +	}
 +	return rv;
 +}
 +
 +/*
   * utmpx
   */
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
