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

Technical Reference: Base Operating System and Extensions, Volume 1

getpenv Subroutine


Reads the current process environment.


Security Library (libc.a)


#include <usersec.h>

char **getpenv ( Which)
int Which;


The getpenv subroutine reads the specified environment variables and returns them in a character buffer.


Which Specifies which environment variables are to be returned. This parameter is a bit mask and may contain one or more of the following values, as defined in the usersec.h file:
The normal user-state environment. Typically, the shell variables are contained here.
The system-state environment. This data is located in system space and protected from unauthorized access.

All variables are returned by setting the Which parameter to logically OR the PENV_USER and PENV_SYSTEM values.

The variables are returned in a null-terminated array of character pointers in the form var=val. The user-state environment variables are prefaced by the string USRENVIRON:, and the system-state variables are prefaced with SYSENVIRON:. If a user-state environment is requested, the current directory is always returned in the PWD variable. If this variable is not present in the existing environment, the getpenv subroutine adds it to the returned string.

Return Values

Upon successful return, the getpenv subroutine returns the environment values. If the getpenv subroutine fails, a null value is returned and the errno global variable is set to indicate the error.

This subroutine can partially succeed, returning only the values that the process permits it to read.

Error Codes

The getpenv subroutine fails if one or more of the following are true:

EINVAL The Which parameter contains values other than PENV_USR or PENV_SYS.

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

Related Information

The ckuseracct (ckuseracct Subroutine) subroutine, ckuserID (ckuserID Subroutine) subroutine, getpcred (getpcred Subroutine) subroutine, setpenv 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 ]