---
name: "pam_putenv"
section: "3"
platform: "linux"
package: "pam"
version: "1.7.3-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/pam_putenv"
---

# pam\_putenv(3)

set or change PAM environment variable

## NAME

pam\_putenv - set or change PAM environment variable

## SYNOPSIS

```
#include <security/pam_appl.h>
```

**int pam\_putenv(pam\_handle\_t \****pamh***, const char \****name\_value***);**

## DESCRIPTION

The **pam\_putenv** function is used to add or change the value of PAM environment variables as associated with the *pamh* handle.

The *pamh* argument is an authentication handle obtained by a prior call to pam\_start(). The *name\_value* argument is a single NUL terminated string of one of the following forms:

NAME=value of variable

In this case the environment variable of the given NAME is set to the indicated value: *value of variable*. If this variable is already known, it is overwritten. Otherwise it is added to the PAM environment.

NAME=

This function sets the variable to an empty value. It is listed separately to indicate that this is the correct way to achieve such a setting.

NAME

Without an '=' the **pam\_putenv**() function will delete the corresponding variable from the PAM environment.

**pam\_putenv**() operates on a copy of *name\_value*, which means in contrast to [**putenv**(3)](/putenv/3.md), the application is responsible for freeing the data.

## RETURN VALUES

PAM\_PERM\_DENIED

Argument *name\_value* given is a NULL pointer.

PAM\_BAD\_ITEM

Variable requested (for deletion) is not currently set.

PAM\_ABORT

The *pamh* handle is corrupt.

PAM\_BUF\_ERR

Memory buffer error.

PAM\_SUCCESS

The environment variable was successfully updated.

## SEE ALSO

[**pam\_start**(3)](/pam_start/3.md), [**pam\_getenv**(3)](/pam_getenv/3.md), [**pam\_getenvlist**(3)](/pam_getenvlist/3.md), [**pam\_strerror**(3)](/pam_strerror/3.md), [**pam**(8)](/pam/8.md)
