[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

getpcred Subroutine

Purpose

Reads the current process credentials.

Library

Security Library (libc.a)

Syntax

#include <usersec.h>


char **getpcred ( Which)
int Which;

Description

The getpcred subroutine reads the specified process security credentials and returns a pointer to a NULL terminated array of pointers in allocated memory. Each pointer in the array points to a string containing an attribute/value pair in allocated memory. It's the responsibility of the caller to free each individual string as well as the array of pointers.

Parameters

Which Specifies which credentials are read. This parameter is a bit mask and can contain one or more of the following values, as defined in the usersec.h file:
CRED_RUID
Real user name
CRED_LUID
Login user name
CRED_RGID
Real group name
CRED_GROUPS
Supplementary group ID
CRED_AUDIT
Audit class of the current process
Note
A process must have root user authority to retrieve this credential. Otherwise, the getpcred subroutine returns a null pointer and the errno global variable is set to EPERM.
CRED_RLIMITS
BSD resource limits
Note
Use the getrlimit (getrlimit, getrlimit64, setrlimit, setrlimit64, or vlimit Subroutine) subroutine to control resource consumption.
CRED_UMASK
The umask.
If the Which parameter is null, all credentials are returned.

Return Values

When successful, the getpcred subroutine returns a pointer to a NULL terminated array of string pointers containing the requested values. If the getpcred subroutine is unsuccessful, a NULL pointer is returned and the errno global variable is set to indicate the error.

Error Codes

The getpcred subroutine fails if either of the following are true:

EINVAL The Which parameter contains invalid credentials requests.
EPERM The process does not have the proper authority to retrieve the requested credentials.

Other errors can also be set by any subroutines invoked by the getpcred subroutine.

Related Information

The ckuseracct (ckuseracct Subroutine) subroutine, ckuserID (ckuserID Subroutine) subroutine, getpenv (getpenv Subroutine) subroutine, setpenv subroutine, setpcred subroutine.

List of Security and Auditing Subroutines, Subroutines Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]