1 '\" te 2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved. 3 .\" 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. 4 .\" 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. 5 .\" 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] 6 .TH GETPROJENT 3PROJECT "Apr 5, 2004" 7 .SH NAME 8 getprojent, getprojbyname, getprojbyid, getdefaultproj, inproj, 9 getprojidbyname, setprojent, endprojent, fgetprojent \- project database entry 10 operations 11 .SH SYNOPSIS 12 .LP 13 .nf 14 cc [ \fIflag\fR... ] \fIfile\fR... \(milproject [ \fIlibrary\fR... ] 15 #include <project.h> 16 17 \fBstruct project *\fR\fBgetprojent\fR(\fBstruct project *\fR\fIproj\fR, \fBvoid *\fR\fIbuffer\fR, 18 \fBsize_t\fR \fIbufsize\fR); 19 .fi 20 21 .LP 22 .nf 23 \fBstruct project *\fR\fBgetprojbyname\fR(\fBconst char *\fR\fIname\fR, 24 \fBstruct project *\fR\fIproj\fR, \fBvoid *\fR\fIbuffer\fR, \fBsize_t\fR \fIbufsize\fR); 25 .fi 26 27 .LP 28 .nf 29 \fBstruct project *\fR\fBgetprojbyid\fR(\fBprojid_t\fR \fIprojid\fR, 30 \fBstruct project *\fR\fIproj\fR, \fBvoid *\fR\fIbuffer\fR, \fBsize_t\fR \fIbufsize\fR); 31 .fi 32 33 .LP 34 .nf 35 \fBstruct project *\fR\fBgetdefaultproj\fR(\fBconst char *\fR\fIusername\fR, 36 \fBstruct project *\fR\fIproj\fR, \fBvoid *\fR\fIbuffer\fR, \fBsize_t\fR \fIbufsize\fR); 37 .fi 38 39 .LP 40 .nf 41 \fBint\fR \fBinproj\fR(\fBconst char *\fR\fIusername\fR, \fBconst char *\fR\fIprojname\fR, 42 \fBvoid *\fR\fIbuffer\fR, \fBsize_t\fR \fIbufsize\fR); 43 .fi 44 45 .LP 46 .nf 47 \fBprojid_t\fR \fBgetprojidbyname\fR(\fBconst char *\fR\fIname\fR); 48 .fi 49 50 .LP 51 .nf 52 \fBvoid\fR \fBsetprojent\fR(\fBvoid\fR); 53 .fi 54 55 .LP 56 .nf 57 \fBvoid\fR \fBendprojent\fR(\fBvoid\fR); 58 .fi 59 60 .LP 61 .nf 62 \fBstruct project *\fR\fBfgetprojent\fR(\fBFILE *\fR\fIf\fR, \fBstruct project *\fR\fIproj\fR, 63 \fBvoid *\fR\fIbuffer\fR, \fBsize_t\fR \fIbufsize\fR); 64 .fi 65 66 .SH DESCRIPTION 67 .LP 68 These functions are used to obtain entries describing user projects. Entries 69 can come from any of the sources for a project specified in the 70 \fB/etc/nsswitch.conf\fR file (see \fBnsswitch.conf\fR(4)). 71 .sp 72 .LP 73 The \fBsetprojent()\fR, \fBgetprojent()\fR, and \fBendprojent()\fR functions 74 are used to enumerate project entries from the database. 75 .sp 76 .LP 77 The \fBsetprojent()\fR function effectively rewinds the project database to 78 allow repeated searches. It sets (or resets) the enumeration to the beginning 79 of the set of project entries. This function should be called before the first 80 call to \fBgetprojent()\fR. 81 .sp 82 .LP 83 The \fBgetprojent()\fR function returns a pointer to a structure containing the 84 broken-out fields of an entry in the project database. When first called, 85 \fBgetprojent()\fR returns a pointer to a project structure containing the 86 first project structure in the project database. Successive calls can be used 87 to read the entire database. 88 .sp 89 .LP 90 The \fBendprojent()\fR function closes the project database and deallocates 91 resources when processing is complete. It is permissible, though possibly less 92 efficient, for the process to call more project functions after calling 93 \fBendprojent()\fR. 94 .sp 95 .LP 96 The \fBgetprojbyname()\fR function searches the project database for an entry 97 with the project name specified by the character string \fIname\fR. 98 .sp 99 .LP 100 The \fBgetprojbyid()\fR function searches the project database for an entry 101 with the (numeric) project \fBID\fR specified by \fIprojid\fR. 102 .sp 103 .LP 104 The \fBgetdefaultproj()\fR function first looks up the project key word in the 105 \fBuser_attr\fR database used to define user attributes in restricted Solaris 106 environments. If the database is available and the keyword is present, the 107 function looks up the named project, returning \fINULL\fR if it cannot be found 108 or if the user is not a member of the named project. If absent, the function 109 looks for a match in the project database for the special project 110 \fBuser\fR.\fIusername\fR. If no match is found, or if the user is excluded 111 from project \fBuser\fR.\fIusername\fR, the function looks at the default group 112 entry of the \fBpasswd\fR database for the user, and looks for a match in the 113 project database for the special name \fBgroup\fR.\fIgroupname\fR, where 114 \fIgroupname\fR is the default group associated with the password entry 115 corresponding to the given \fIusername\fR. If no match is found, or if the user 116 is excluded from project \fBgroup\fR.\fIgroupname\fR, the function returns 117 \fINULL\fR. A special project entry called 'default' can be looked up and used 118 as a last resort, unless the user is excluded from project 'default'. On 119 successful lookup, this function returns a pointer to the valid \fBproject\fR 120 structure. By convention, the user must have a default project defined on a 121 system to be able to log on to that system. 122 .sp 123 .LP 124 The \fBinproj()\fR function checks if the user specified by \fIusername\fR is 125 able to use the project specified by \fIprojname\fR. This function returns 1 if 126 the user belongs to the list of project's users, if there is a project's group 127 that contains the specified user, if project is a user's default project, or if 128 project's user or group list contains "*" wildcard. In all other cases it 129 returns 0. 130 .sp 131 .LP 132 The \fBgetprojidbyname()\fR function searches the project database for an entry 133 with the project name specified by the character string name. This function 134 returns the project ID if the requested entry is found; otherwise it returns 135 \(mi1. 136 .sp 137 .LP 138 The \fBfgetprojent()\fR function, unlike the other functions described above, 139 does not use \fBnsswitch.conf\fR; it reads and parses the next line from the 140 stream \fIf\fR, which is assumed to have the format of the \fBproject\fR(4) 141 file. This function returns the same values as \fBgetprojent()\fR. 142 .sp 143 .LP 144 The \fBgetprojent()\fR, \fBgetprojbyname()\fR, \fBgetprojbyid()\fR, 145 \fBgetdefaultproj()\fR, and \fBinproj()\fR functions are reentrant interfaces 146 for operations with the \fBproject\fR database. These functions use buffers 147 supplied by the caller to store returned results and are safe for use in both 148 single-threaded and multithreaded applications. 149 .sp 150 .LP 151 Reentrant interfaces require the additional arguments \fIproj\fR, \fIbuffer\fR, 152 and \fIbufsize\fR. The \fIproj\fR argument must be a pointer to a \fBstruct 153 project\fR structure allocated by the caller. On successful completion, the 154 function returns the project entry in this structure. Storage referenced by the 155 \fBproject\fR structure is allocated from the memory provided with the 156 \fIbuffer\fR argument, which is \fIbufsize\fR bytes in size. The content of 157 the memory buffer could be lost in cases when these functions return errors. 158 .sp 159 .LP 160 For enumeration in multithreaded applications, the position within the 161 enumeration is a process-wide property shared by all threads. The 162 \fBsetprojent()\fR function can be used in a multithreaded application but 163 resets the enumeration position for all threads. If multiple threads interleave 164 calls to \fBgetprojent()\fR, the threads will enumerate disjoint subsets of the 165 project database. The \fBinproj()\fR, \fBgetprojbyname()\fR, 166 \fBgetprojbyid()\fR, and \fBgetdefaultproj()\fR functions leave the enumeration 167 position in an indeterminate state. 168 .SH RETURN VALUES 169 .LP 170 Project entries are represented by the \fBstruct project\fR structure defined 171 in <\fBproject.h\fR>. 172 .sp 173 .in +2 174 .nf 175 struct project { 176 char *pj_name; /* name of the project */ 177 projid_t pj_projid; /* numerical project id */ 178 char *pj_comment; /* project comment */ 179 char **pj_users; /* vector of pointers to 180 project user names */ 181 char **pj_groups; /* vector of pointers to 182 project group names */ 183 char *pj_attr; /* project attributes */ 184 }; 185 .fi 186 .in -2 187 188 .sp 189 .LP 190 The \fBgetprojbyname()\fR and \fBgetprojbyid()\fR functions each return a 191 pointer to a \fBstruct project\fR if they successfully locate the requested 192 entry; otherwise they return \fINULL\fR. 193 .sp 194 .LP 195 The \fBgetprojent()\fR function returns a pointer to a \fBstruct project\fR if 196 it successfully enumerates an entry; otherwise it returns \fINULL\fR, 197 indicating the end of the enumeration. 198 .sp 199 .LP 200 The \fBgetprojidbyname()\fR function returns the project ID if the requested 201 entry is found; otherwise it returns \(mi1 and sets errno to indicate the 202 error. 203 .sp 204 .LP 205 When the pointer returned by the reentrant functions \fBgetprojbyname()\fR, 206 \fBgetprojbyid()\fR, and \fBgetprojent()\fR is non-null, it is always equal to 207 the \fIproj\fR pointer that was supplied by the caller. 208 .sp 209 .LP 210 Upon failure, \fBNULL\fR is returned and errno is set to indicate the error. 211 .SH ERRORS 212 .LP 213 The \fBgetprojent()\fR, \fBgetprojbyname()\fR, \fBgetprojbyid()\fR, 214 \fBinproj()\fR, \fBgetprojidbyname()\fR, \fBfgetprojent()\fR, and 215 \fBgetdefaultproj()\fR functions will fail if: 216 .sp 217 .ne 2 218 .na 219 \fB\fBEINTR\fR\fR 220 .ad 221 .RS 10n 222 A signal was caught during the operation. 223 .RE 224 225 .sp 226 .ne 2 227 .na 228 \fB\fBEIO\fR\fR 229 .ad 230 .RS 10n 231 An I/O error has occurred. 232 .RE 233 234 .sp 235 .ne 2 236 .na 237 \fB\fBEMFILE\fR\fR 238 .ad 239 .RS 10n 240 There are \fBOPEN_MAX\fR file descriptors currently open in the calling 241 process. 242 .RE 243 244 .sp 245 .ne 2 246 .na 247 \fB\fBENFILE\fR\fR 248 .ad 249 .RS 10n 250 The maximum allowable number of files is currently open in the system. 251 .RE 252 253 .sp 254 .ne 2 255 .na 256 \fB\fBERANGE\fR\fR 257 .ad 258 .RS 10n 259 Insufficient storage was supplied by \fIbuffer\fR and \fIbufsize\fR to contain 260 the data to be referenced by the resulting \fBproject\fR structure. 261 .RE 262 263 .sp 264 .LP 265 These functions can also fail if the name service switch does not specify valid 266 \fBproject\fR(4) name service sources. In the case of an incompletely 267 configured name service switch configuration, \fBgetprojbyid()\fR and other 268 functions can return error values other than those documented above. These 269 conditions usually occur when the \fBnsswitch.conf\fR file indicates that one 270 or more name services is providing entries for the project database when that 271 name service does not actually make a project table available. 272 .SH USAGE 273 .LP 274 When compiling multithreaded applications, see \fBIntro\fR(3), Notes On 275 Multithreaded Applications. 276 .sp 277 .LP 278 Use of the enumeration interface \fBgetprojent()\fR is discouraged. Enumeration 279 is supported for the project file, NIS, and LDAP but in general is not 280 efficient. The semantics of enumeration are discussed further in 281 \fBnsswitch.conf\fR(4). 282 .SH ATTRIBUTES 283 .LP 284 See \fBattributes\fR(5) for descriptions of the following attributes: 285 .sp 286 287 .sp 288 .TS 289 box; 290 c | c 291 l | l . 292 ATTRIBUTE TYPE ATTRIBUTE VALUE 293 _ 294 Interface Stability Evolving 295 _ 296 MT-Level See Description. 297 .TE 298 299 .SH SEE ALSO 300 .LP 301 \fBIntro\fR(3), \fBlibproject\fR(3LIB), \fBproject_walk\fR(3PROJECT), 302 \fBsysconf\fR(3C), \fBnsswitch.conf\fR(4), \fBproject\fR(4), 303 \fBattributes\fR(5)