Sets the current process credentials.
Security Library (libc.a)
#include <usersec.h>
int setpcred ( User, Credentials)
char **Credentials;
char *User;
The setpcred subroutine sets a process' credentials according to the Credentials parameter. If the User parameter is specified, the credentials defined for the user in the user database are used. If the Credentials parameter is specified, the credentials in this string are used. If both the User and Credentials parameters are specified, both the user's and the supplied credentials are used. However, the supplied credentials of the Credentials parameter will override those of the user. At least one parameter must be specified.
The setpcred subroutine requires the setpenv subroutine to follow it.
Item | Description |
---|---|
User | Specifies the user for whom credentials are being established. |
Credentials | Defines specific credentials to be established. This parameter
points to an array of null-terminated character strings that may contain
the following values. The last character string must be null.
|
A process must have root user authority to set all credentials except the UMASK credential.
|
The soft limit credentials will override the equivalent hard limit credentials that may proceed them. To set the hard limits, the hard limit credentials should follow the soft limit credentials.
Upon successful return, the setpcred subroutine returns a value of 0. If setpcred fails, a value of -1 is returned and the errno global variable is set to indicate the error.
The setpcred subroutine fails if one or more of the following are true:
Item | Description |
---|---|
EINVAL | The Credentials parameter contains invalid credentials specifications. |
EINVAL | The User parameter is null and the Credentials parameter is either null or points to an empty string. |
EPERM | The process does not have the proper authority to set the requested credentials. |
Other errors may be set by subroutines invoked by the setpcred subroutine.