[Midnightbsd-cvs] src [11507] trunk/usr.bin/getent/getent.c: sync getent with freebsd.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jul 7 13:45:55 EDT 2018
Revision: 11507
http://svnweb.midnightbsd.org/src/?rev=11507
Author: laffer1
Date: 2018-07-07 13:45:54 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
sync getent with freebsd.
Modified Paths:
--------------
trunk/usr.bin/getent/Makefile
trunk/usr.bin/getent/getent.1
trunk/usr.bin/getent/getent.c
Property Changed:
----------------
trunk/usr.bin/getent/getent.1
Modified: trunk/usr.bin/getent/Makefile
===================================================================
--- trunk/usr.bin/getent/Makefile 2018-07-07 17:45:24 UTC (rev 11506)
+++ trunk/usr.bin/getent/Makefile 2018-07-07 17:45:54 UTC (rev 11507)
@@ -1,4 +1,5 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/getent/Makefile 201386 2010-01-02 10:27:05Z ed $
PROG= getent
Modified: trunk/usr.bin/getent/getent.1
===================================================================
--- trunk/usr.bin/getent/getent.1 2018-07-07 17:45:24 UTC (rev 11506)
+++ trunk/usr.bin/getent/getent.1 2018-07-07 17:45:54 UTC (rev 11507)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $NetBSD: getent.1,v 1.13 2005/09/11 23:16:15 wiz Exp $
.\"
.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -27,7 +28,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/getent/getent.1 203971 2010-02-16 21:43:57Z imp $
.\"
.Dd August 24, 2005
.Dt GETENT 1
Property changes on: trunk/usr.bin/getent/getent.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/getent/getent.c
===================================================================
--- trunk/usr.bin/getent/getent.c 2018-07-07 17:45:24 UTC (rev 11506)
+++ trunk/usr.bin/getent/getent.c 2018-07-07 17:45:54 UTC (rev 11507)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $NetBSD: getent.c,v 1.7 2005/08/24 14:31:02 ginsbach Exp $ */
/*-
@@ -30,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/getent/getent.c 250942 2013-05-23 20:52:30Z ghelmer $");
#include <sys/socket.h>
#include <sys/param.h>
@@ -61,6 +62,7 @@
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 +91,7 @@
{ "rpc", rpc, },
{ "services", services, },
{ "shells", shells, },
+ { "netgroup", netgroup, },
{ "utmpx", utmpx, },
{ NULL, NULL, },
@@ -571,6 +574,47 @@
}
/*
+ * 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
*/
@@ -610,6 +654,17 @@
printf("\" pid=\"%d\" user=\"%s\" line=\"%s\" host=\"%s\"\n",
ut->ut_pid, ut->ut_user, ut->ut_line, ut->ut_host);
break;
+ case INIT_PROCESS:
+ printf("init process: id=\"");
+ UTMPXPRINTID;
+ printf("\" pid=\"%d\"\n", ut->ut_pid);
+ break;
+ case LOGIN_PROCESS:
+ printf("login process: id=\"");
+ UTMPXPRINTID;
+ printf("\" pid=\"%d\" user=\"%s\" line=\"%s\" host=\"%s\"\n",
+ ut->ut_pid, ut->ut_user, ut->ut_line, ut->ut_host);
+ break;
case DEAD_PROCESS:
printf("dead process: id=\"");
UTMPXPRINTID;
@@ -616,7 +671,7 @@
printf("\" pid=\"%d\"\n", ut->ut_pid);
break;
default:
- printf("unknown record type\n");
+ printf("unknown record type %hu\n", ut->ut_type);
break;
}
}
More information about the Midnightbsd-cvs
mailing list