1 '\" te 2 .\" Copyright (c) 2014 Gary Mills 3 .\" Copyright (C) 1999, Sun Microsystems, Inc. All Rights Reserved 4 .\" 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. 5 .\" 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. 6 .\" 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] 7 .TH GETENT 1M "Mar 14, 2014" 8 .SH NAME 9 getent \- get entries from administrative database 10 .SH SYNOPSIS 11 .LP 12 .nf 13 \fBgetent\fR \fIdatabase\fR [\fIkey\fR]... 14 .fi 15 16 .SH DESCRIPTION 17 .sp 18 .LP 19 \fBgetent\fR gets a list of entries from the administrative database specified 20 by \fIdatabase\fR. The information generally comes from one or more of the 21 sources that are specified for the \fIdatabase\fR in \fB/etc/nsswitch.conf\fR. 22 .sp 23 .LP 24 \fIdatabase\fR is the name of the database to be examined. This can be 25 \fBpasswd\fR, \fBshadow\fR, \fBgroup\fR, \fBhosts\fR, \fBipnodes\fR, \fBservices\fR, 26 \fBprotocols\fR, \fBethers\fR, \fBproject\fR, \fBnetworks\fR, 27 \fBnetmasks\fR, or \fBnetgroup\fR. 28 For each of these databases, \fBgetent\fR uses the appropriate 29 library routines described in \fBgetpwnam\fR(3C), \fBgetspnam\fR(3C), \fBgetgrnam\fR(3C), 30 \fBgethostbyaddr\fR(3NSL), \fBgethostbyname\fR(3NSL), 31 \fBgetipnodebyaddr\fR(3SOCKET), \fBgetipnodebyname\fR(3SOCKET), 32 \fBgetservbyname\fR(3SOCKET), \fBgetprotobyname\fR(3SOCKET), 33 \fBethers\fR(3SOCKET), \fBgetprojbyname\fR(3PROJECT), 34 \fBgetnetbyname\fR(3SOCKET), or \fBgetnetgrent\fR(3C) respectively. 35 .sp 36 .LP 37 Each \fIkey\fR must be in a format appropriate for searching on the respective 38 database. For example, it can be a \fIusername\fR or \fInumeric-uid\fR for 39 \fBpasswd\fR; \fIhostname\fR or \fIIP\fR \fIaddress\fR for \fBhosts\fR; or 40 \fIservice\fR, \fIservice/protocol\fR, \fIport\fR, or \fIport/proto\fR for 41 \fBservices\fR. 42 .sp 43 .LP 44 \fBgetent\fR prints out the database entries that match each of the supplied 45 keys, one per line, in the format of the matching administrative file: 46 \fBpasswd\fR(4), \fBshadow\fR(4), \fBgroup\fR(4), \fBproject\fR(4), \fBhosts\fR(4), 47 \fBservices\fR(4), \fBprotocols\fR(4), \fBethers\fR(3SOCKET), 48 \fBnetworks\fR(4), or \fBnetmasks\fR(4). If no key is given, all entries 49 returned by the corresponding enumeration library routine, for example, 50 \fBgetpwent()\fR or \fBgethostent()\fR, are printed. Enumeration is not 51 supported on \fBipnodes\fR. 52 .SS "Key Interpretation for \fBpasswd\fR and \fBgroup\fR Databases" 53 .sp 54 .LP 55 When \fBgetent\fR is invoked with database set to \fBpasswd\fR, each key value 56 is processed as follows: 57 .RS +4 58 .TP 59 .ie t \(bu 60 .el o 61 If the key value consists only of numeric characters, \fBgetent\fR assumes that 62 the key value is a numeric user ID and searches the user database for a 63 matching user ID. 64 .RE 65 .RS +4 66 .TP 67 .ie t \(bu 68 .el o 69 If the user ID is not found in the user database or if the key value contains 70 any non-numeric characters, \fBgetent\fR assumes the key value is a user name 71 and searches the user database for a matching user name. 72 .RE 73 .sp 74 .LP 75 Similarly, when \fBgetent\fR is invoked with database set to \fBgroup\fR, each 76 key value is processed as follows: 77 .RS +4 78 .TP 79 .ie t \(bu 80 .el o 81 If the key value consists only of numeric characters, \fBgetent\fR assumes that 82 the key value is a numeric group ID and searches the group database for a 83 matching group ID. 84 .RE 85 .RS +4 86 .TP 87 .ie t \(bu 88 .el o 89 If the group ID is not found in the \fBgroup\fR database or if the key value 90 contains any non-numeric characters, \fBgetent\fR assumes the key value is a 91 group name and searches the \fBgroup\fR database for a matching group name. 92 .RE 93 .SH EXIT STATUS 94 .sp 95 .LP 96 The following exit values are returned: 97 .sp 98 .ne 2 99 .na 100 \fB\fB0\fR\fR 101 .ad 102 .RS 5n 103 Successful completion. 104 .RE 105 106 .sp 107 .ne 2 108 .na 109 \fB\fB1\fR\fR 110 .ad 111 .RS 5n 112 Command syntax was incorrect, an invalid option was used, or an internal error 113 occurred. 114 .RE 115 116 .sp 117 .ne 2 118 .na 119 \fB\fB2\fR\fR 120 .ad 121 .RS 5n 122 At least one of the specified entry names was not found in the database. 123 .RE 124 125 .sp 126 .ne 2 127 .na 128 \fB\fB3\fR\fR 129 .ad 130 .RS 5n 131 There is no support for enumeration on this database. 132 .RE 133 134 .SH FILES 135 .sp 136 .ne 2 137 .na 138 \fB\fB/etc/nsswitch.conf\fR\fR 139 .ad 140 .RS 22n 141 name service switch configuration file 142 .RE 143 144 .sp 145 .ne 2 146 .na 147 \fB\fB/etc/passwd\fR\fR 148 .ad 149 .RS 22n 150 password file 151 .RE 152 153 .sp 154 .ne 2 155 .na 156 \fB\fB/etc/shadow\fR\fR 157 .ad 158 .RS 22n 159 shadowed password file 160 .RE 161 162 .sp 163 .ne 2 164 .na 165 \fB\fB/etc/group\fR\fR 166 .ad 167 .RS 22n 168 group file 169 .RE 170 171 .sp 172 .ne 2 173 .na 174 \fB\fB/etc/inet/hosts\fR\fR 175 .ad 176 .RS 22n 177 IPv4 and IPv6 host name database 178 .RE 179 180 .sp 181 .ne 2 182 .na 183 \fB\fB/etc/services\fR\fR 184 .ad 185 .RS 22n 186 Internet services and aliases 187 .RE 188 189 .sp 190 .ne 2 191 .na 192 \fB\fB/etc/project\fR\fR 193 .ad 194 .RS 22n 195 project file 196 .RE 197 198 .sp 199 .ne 2 200 .na 201 \fB\fB/etc/protocols\fR\fR 202 .ad 203 .RS 22n 204 protocol name database 205 .RE 206 207 .sp 208 .ne 2 209 .na 210 \fB\fB/etc/ethers\fR\fR 211 .ad 212 .RS 22n 213 Ethernet address to hostname database or domain 214 .RE 215 216 .sp 217 .ne 2 218 .na 219 \fB\fB/etc/networks\fR\fR 220 .ad 221 .RS 22n 222 network name database 223 .RE 224 225 .sp 226 .ne 2 227 .na 228 \fB\fB/etc/netmasks\fR\fR 229 .ad 230 .RS 22n 231 network mask database 232 .RE 233 234 .SH SEE ALSO 235 .sp 236 .LP 237 \fBethers\fR(3SOCKET), \fBgetgrnam\fR(3C), \fBgethostbyaddr\fR(3NSL), 238 \fBgethostbyname\fR(3NSL), \fBgethostent\fR(3NSL), 239 \fBgetipnodebyaddr\fR(3SOCKET), \fBgetipnodebyname\fR(3SOCKET), 240 \fBgetnetbyname\fR(3SOCKET), \fBgetprojbyname\fR(3PROJECT), 241 \fBgetprotobyname\fR(3SOCKET), \fBgetpwnam\fR(3C), 242 \fBgetservbyname\fR(3SOCKET), \fBgroup\fR(4), \fBhosts\fR(4), 243 \fBnetmasks\fR(4), \fBnetworks\fR(4), \fBnsswitch.conf\fR(4), \fBpasswd\fR(4), 244 \fBproject\fR(4), \fBprotocols\fR(4), \fBservices\fR(4), \fBattributes\fR(5)