These functions are used to obtain entries describing user projects. Entries can come from any of the sources for a project specified in the /etc/nsswitch.conf file (see nsswitch.conf(4)).
The setprojent(), getprojent(), and endprojent() functions are used to enumerate project entries from the database.
The setprojent() function effectively rewinds the project database to allow repeated searches. It sets (or resets) the enumeration to the beginning of the set of project entries. This function should be called before the first call to getprojent().
The getprojent() function returns a pointer to a structure containing the broken-out fields of an entry in the project database. When first called, getprojent() returns a pointer to a project structure containing the first project structure in the project database.
Successive calls can be used to read the entire database.
The endprojent() function closes the project database and deallocates resources when processing is complete. It is permissible, though possibly less efficient, for the process to call more project functions after calling endprojent().
The getprojbyname() function searches the project database for an entry with the project name specified by the character string name.
The getprojbyid() function searches the project database for an entry with the (numeric) project ID specified by projid.
The getdefaultproj() function first looks up the project key word in the user_attr database used to define user attributes in restricted Solaris environments. If the database is available and the keyword is present, the function looks up the named project, returning NULL if it cannot be found or if the user is not a member of the named project. If absent, the function looks for a match in the project database for the special project user.username. If no match is found, or if the user is excluded from
project user.username, the function looks at the default group entry of the passwd database for the user, and looks for a match in the project database for the special name group.groupname, where groupname is the default group associated with the password entry corresponding to the given username. If no match is found, or if the user is excluded from project group.groupname, the function returns NULL. A special project entry called 'default' can be looked up and used as a last resort, unless the user is excluded from project 'default'. On successful lookup, this function returns a pointer to the valid project structure. By convention, the user must have a default project
defined on a system to be able to log on to that system.
The inproj() function checks if the user specified by username is able to use the project specified by projname. This function returns 1 if the user belongs to the list of project's users, if there is a project's group that contains
the specified user, if project is a user's default project, or if project's user or group list contains "*" wildcard. In all other cases it returns 0.
The getprojidbyname() function searches the project database for an entry with the project name specified by the character string name. This function returns the project ID if the requested entry is found; otherwise it returns -1.
The fgetprojent() function, unlike the other functions described above, does not use nsswitch.conf; it reads and parses the next line from the stream f, which is assumed to have the format of the project(4) file. This function returns the same values as getprojent().
The getprojent(), getprojbyname(), getprojbyid(), getdefaultproj(), and inproj() functions are reentrant interfaces for operations with the project database. These functions use buffers
supplied by the caller to store returned results and are safe for use in both single-threaded and multithreaded applications.
Reentrant interfaces require the additional arguments proj, buffer, and bufsize. The proj argument must be a pointer to a struct project structure allocated by the caller. On successful
completion, the function returns the project entry in this structure. Storage referenced by the project structure is allocated from the memory provided with the buffer argument, which is bufsize bytes in size.
For enumeration in multithreaded applications, the position within the enumeration is a process-wide property shared by all threads. The setprojent() function can be used in a multithreaded application but resets the enumeration position for all threads. If multiple threads interleave
calls to getprojent(), the threads will enumerate disjoint subsets of the project database. The inproj(), getprojbyname(), getprojbyid(), and getdefaultproj() functions leave the enumeration position in an indeterminate
state.
|