[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

getpenv Subroutine

Purpose

Reads the current process environment.

Library

Security Library (libc.a)

Syntax

#include <usersec.h>
char **getpenv (Which)
int Which;

Description

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

Parameters

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:
PENV_USR
The normal user-state environment. Typically, the shell variables are contained here.
PENV_SYS
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.

Note: 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.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The ckuseracct subroutine, ckuserID subroutine, getpcred subroutine, setpenv subroutine.

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


[ Previous | Next | Contents | Glossary | Home | Search ]