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

# pam\_set\_data(3)

set module information

## NAME

**pam\_set\_data** – set module information

## SYNOPSIS

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

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

*int*\

**pam\_set\_data**(*pam\_handle\_t \*pamh*, *const char \*module\_data\_name*, *void \*data*, *void (\*cleanup)(pam\_handle\_t \*pamh, void \*data, int pam\_end\_status)*);

## DESCRIPTION

The **pam\_set\_data**() function associates a pointer to an opaque object with an arbitrary string specified by the *module\_data\_name* argument, in the PAM context specified by the *pamh* argument.

If not NULL, the *cleanup* argument should point to a function responsible for releasing the resources associated with the object.

This function and its counterpart [pam\_get\_data(3)](/pam_get_data/3.md) are useful for managing data that are meaningful only to a particular service module.

## RETURN VALUES

The **pam\_set\_data**() 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\_get\_data(3)](/pam_get_data/3.md), [pam\_strerror(3)](/pam_strerror/3.md)

## STANDARDS

*X/Open Single Sign-On Service (XSSO) - Pluggable Authentication Modules*, June 1997.

## AUTHORS

The **pam\_set\_data**() 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*⟩.
