Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Mar 2009 12:54:03 GMT
From:      Andrey Zonov <andrey.zonov@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/132692: [getent] [patch] no support for netgroup
Message-ID:  <200903161254.n2GCs3gH087550@www.freebsd.org>
Resent-Message-ID: <200903161300.n2GD071p090510@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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 <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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903161254.n2GCs3gH087550>