Description

The user credential is a shared, read-only, ref-counted data structure. Its actual
size and layout are subject to change. The functions described in this
page allow the programmer to retrieve fields from the structure and to
initialize newly allocated credential structures.

crgetuid(), crgetruid(), and crgetsuid() return, respectively, the effective, real, and saved user
id from the user credential pointed to by cr.

crgetgid(), crgetrgid(), and crgetsgid() return, respectively, the effective, real, and saved group
id from the user credential pointed to by cr.

crgetzoneid() returns the zone id from the user credential pointed to by
cr.

crgetgroups() returns the group list of the user credential pointed to by
cr.

crgetngroups() returns the number of groups in the user credential pointed to
by cr.

crsetresuid() sets the real, effective and saved user id. All but one
can be specified as -1, which causes the original value not to
change.

crsetresgid() sets the real, effective and saved group id. All but one
can be specified as -1, which causes the original value not to
change.

crsetugid() initializes the real, effective and saved user id all to uid.
It initializes the real, effective, and saved group id all to gid.

crsetgroups() sets the number of groups in the user credential to ngroups
and copies the groups from gids to the user credential. If ngroups
is 0, gids need not point to valid storage.

It is an error to call this any of the crset*() functions
on a user credential structure that was newly allocated.

Return Values

The crget*() functions return the requested information.

The crset*id() functions return 0 on success and -1 if any of
the specified ids are invalid. The functions might cause a system panic
if called on a user credential structure that is referenced by other
parts of the system.