---
name: "pam_setenv"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd", "macos"]
url: "https://new.carta.tech/pam_setenv"
---

# pam\_setenv(3)

mirrors setenv(3)

## NAME

**pam\_setenv** – mirrors [setenv(3)](/setenv/3.md)

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<security/pam\_appl.h\>**

*int*\

**pam\_setenv**(*pam\_handle\_t \*pamh*, *const char \*name*, *const char \*value*, *int overwrite*);

## DESCRIPTION

The **pam\_setenv**() function sets an environment variable. Its semantics are similar to those of [setenv(3)](/setenv/3.md), but it modifies the PAM context's environment list instead of the application's.

## RETURN VALUES

The **pam\_setenv**() function returns one of the following values:

- \[PAM\_SUCCESS\]

  Success.

- \[PAM\_BUF\_ERR\]

  Memory buffer error.

- \[PAM\_SYSTEM\_ERR\]

  System error.

## SEE ALSO

[pam(3)](/pam/3.md), [pam\_getenv(3)](/pam_getenv/3.md), [pam\_getenvlist(3)](/pam_getenvlist/3.md), [pam\_putenv(3)](/pam_putenv/3.md), [pam\_strerror(3)](/pam_strerror/3.md), [setenv(3)](/setenv/3.md)

## STANDARDS

The **pam\_setenv**() function is an OpenPAM extension.

## AUTHORS

The **pam\_setenv**() function and this manual page were developed for the FreeBSD Project by ThinkSec AS and Network Associates Laboratories, the Security Research Division of Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 (“CBOSS”), as part of the DARPA CHATS research program.

The OpenPAM library is maintained by Dag-Erling Smørgrav ⟨*des@des.dev*⟩.
