summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith M Wesolowski <wesolows@foobazco.org>2014-03-20 17:45:49 +0000
committerKeith M Wesolowski <wesolows@foobazco.org>2014-03-20 17:45:49 +0000
commit76436dc0854d1e18a76ccb58a9b496a0e93ae7c7 (patch)
tree80c482eb82eb7a55bb735e6502b6171d38b8290e
parentad740f5f23aca9052a27984d4912ec9379c611bf (diff)
parent00277c9e43668ff248a12ee635ce125957750373 (diff)
downloadillumos-joyent-76436dc0854d1e18a76ccb58a9b496a0e93ae7c7.tar.gz
[illumos-gate merge]20140320release-20140320
commit 00277c9e43668ff248a12ee635ce125957750373 3243 Add shadow support to getent(1) commit 04dfc08aa8f2f35510c97c3e9e543a45d0c5b7af 4625 add cscope output to .gitignore Conflicts: .gitignore
-rw-r--r--.gitignore11
-rw-r--r--usr/src/cmd/getent/Makefile2
-rw-r--r--usr/src/cmd/getent/dogetsp.c63
-rw-r--r--usr/src/cmd/getent/getent.c6
-rw-r--r--usr/src/cmd/getent/getent.h4
-rw-r--r--usr/src/man/man1m/getent.1m18
6 files changed, 93 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index 455d5238fa..75b983aada 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,13 @@
-<<<<<<< HEAD
-*.o
+# .gitignore for illumos checkouts.
+# Note: this does not try to ignore all files in a fully built workspace.
+# Rather, you are expected to "make clobber" before running "git status".
+cscope.files
+cscope.out
+ncscope.out
+cscope.in.out
+cscope.po.out
.make.state*
+*.o
*.po
*.so
*.so.1
diff --git a/usr/src/cmd/getent/Makefile b/usr/src/cmd/getent/Makefile
index 4b6e79c992..b11e0a6e2c 100644
--- a/usr/src/cmd/getent/Makefile
+++ b/usr/src/cmd/getent/Makefile
@@ -20,6 +20,7 @@
#
#
+# Copyright (c) 2014 Gary Mills
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -41,6 +42,7 @@ OBJECTS= \
dogetproject.o \
dogetproto.o \
dogetpw.o \
+ dogetsp.o \
dogetserv.o \
getent.o
diff --git a/usr/src/cmd/getent/dogetsp.c b/usr/src/cmd/getent/dogetsp.c
new file mode 100644
index 0000000000..11c09e2419
--- /dev/null
+++ b/usr/src/cmd/getent/dogetsp.c
@@ -0,0 +1,63 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2014 Gary Mills
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#include <stdio.h>
+#include <shadow.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "getent.h"
+
+/*
+ * getspnam - get entries from shadow database
+ */
+int
+dogetsp(const char **list)
+{
+ struct spwd *sp;
+ int rc = EXC_SUCCESS;
+ char *ptr;
+ uid_t uid;
+
+
+ if (list == NULL || *list == NULL) {
+ setspent();
+ while ((sp = getspent()) != NULL)
+ (void) putspent(sp, stdout);
+ endspent();
+ } else {
+ for (; *list != NULL; list++) {
+ sp = getspnam(*list);
+ if (sp == NULL)
+ rc = EXC_NAME_NOT_FOUND;
+ else
+ (void) putspent(sp, stdout);
+ }
+ }
+
+ return (rc);
+}
diff --git a/usr/src/cmd/getent/getent.c b/usr/src/cmd/getent/getent.c
index 394afd80a1..799568764e 100644
--- a/usr/src/cmd/getent/getent.c
+++ b/usr/src/cmd/getent/getent.c
@@ -20,12 +20,11 @@
* CDDL HEADER END
*/
/*
+ * Copyright (c) 2014 Gary Mills
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -42,6 +41,7 @@ struct table {
static struct table t[] = {
{ "passwd", dogetpw },
+ { "shadow", dogetsp },
{ "group", dogetgr },
{ "hosts", dogethost },
{ "ipnodes", dogetipnodes },
@@ -82,7 +82,7 @@ main(int argc, const char **argv)
switch (rc) {
case EXC_SYNTAX:
(void) fprintf(stderr,
- gettext("Syntax error\n"));
+ gettext("Syntax error\n"));
break;
case EXC_ENUM_NOT_SUPPORTED:
(void) fprintf(stderr,
diff --git a/usr/src/cmd/getent/getent.h b/usr/src/cmd/getent/getent.h
index d76aceced4..049a2536c3 100644
--- a/usr/src/cmd/getent/getent.h
+++ b/usr/src/cmd/getent/getent.h
@@ -20,6 +20,7 @@
* CDDL HEADER END
*/
/*
+ * Copyright (c) 2014 Gary Mills
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -27,8 +28,6 @@
#ifndef _GETENT_H
#define _GETENT_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -42,6 +41,7 @@ extern "C" {
#define EXC_ENUM_NOT_SUPPORTED 3
extern int dogetpw(const char **);
+extern int dogetsp(const char **);
extern int dogetgr(const char **);
extern int dogethost(const char **);
extern int dogetipnodes(const char **);
diff --git a/usr/src/man/man1m/getent.1m b/usr/src/man/man1m/getent.1m
index a59ea25d8a..2916b821fa 100644
--- a/usr/src/man/man1m/getent.1m
+++ b/usr/src/man/man1m/getent.1m
@@ -1,9 +1,10 @@
'\" te
+.\" Copyright (c) 2014 Gary Mills
.\" Copyright (C) 1999, Sun Microsystems, Inc. All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH GETENT 1M "Mar 26, 2007"
+.TH GETENT 1M "Mar 14, 2014"
.SH NAME
getent \- get entries from administrative database
.SH SYNOPSIS
@@ -21,10 +22,10 @@ sources that are specified for the \fIdatabase\fR in \fB/etc/nsswitch.conf\fR.
.sp
.LP
\fIdatabase\fR is the name of the database to be examined. This can be
-\fBpasswd\fR, \fBgroup\fR, \fBhosts\fR, \fBipnodes\fR, \fBservices\fR,
+\fBpasswd\fR, \fBshadow\fR, \fBgroup\fR, \fBhosts\fR, \fBipnodes\fR, \fBservices\fR,
\fBprotocols\fR, \fBethers\fR, \fBproject\fR, \fBnetworks\fR, or
\fBnetmasks\fR. For each of these databases, \fBgetent\fR uses the appropriate
-library routines described in \fBgetpwnam\fR(3C), \fBgetgrnam\fR(3C),
+library routines described in \fBgetpwnam\fR(3C), \fBgetspnam\fR(3C), \fBgetgrnam\fR(3C),
\fBgethostbyaddr\fR(3NSL), \fBgethostbyname\fR(3NSL),
\fBgetipnodebyaddr\fR(3SOCKET), \fBgetipnodebyname\fR(3SOCKET),
\fBgetservbyname\fR(3SOCKET), \fBgetprotobyname\fR(3SOCKET),
@@ -41,7 +42,7 @@ database. For example, it can be a \fIusername\fR or \fInumeric-uid\fR for
.LP
\fBgetent\fR prints out the database entries that match each of the supplied
keys, one per line, in the format of the matching administrative file:
-\fBpasswd\fR(4), \fBgroup\fR(4), \fBproject\fR(4), \fBhosts\fR(4),
+\fBpasswd\fR(4), \fBshadow\fR(4), \fBgroup\fR(4), \fBproject\fR(4), \fBhosts\fR(4),
\fBservices\fR(4), \fBprotocols\fR(4), \fBethers\fR(3SOCKET),
\fBnetworks\fR(4), or \fBnetmasks\fR(4). If no key is given, all entries
returned by the corresponding enumeration library routine, for example,
@@ -151,6 +152,15 @@ password file
.sp
.ne 2
.na
+\fB\fB/etc/shadow\fR\fR
+.ad
+.RS 22n
+shadowed password file
+.RE
+
+.sp
+.ne 2
+.na
\fB\fB/etc/group\fR\fR
.ad
.RS 22n