---
name: "openpam_borrow_cred"
section: "3"
platform: "macos"
package: "OpenPAM"
version: "35"
release: "macOS 26.5"
platforms: ["freebsd", "macos"]
url: "https://new.carta.tech/openpam_borrow_cred"
---

# openpam\_borrow\_cred(3)

temporarily borrow user credentials

## NAME

**openpam\_borrow\_cred** – temporarily borrow user credentials

## LIBRARY

library “libpam”

## SYNOPSIS

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

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

**#include \<security/openpam.h\>**

*int*\

**openpam\_borrow\_cred**(*pam\_handle\_t \*pamh*, *const struct passwd \*pwd*);

## DESCRIPTION

The **openpam\_borrow\_cred** function saves the current credentials and switches to those of the user specified by its *pwd* argument. The affected credentials are the effective UID, the effective GID, and the group access list. The original credentials can be restored using [openpam\_restore\_cred(3)](/openpam_restore_cred/3.md).

## RETURN VALUES

The **openpam\_borrow\_cred** function returns one of the following values:

- \[PAM\_BUF\_ERR\]

  Memory buffer error.

- \[PAM\_PERM\_DENIED\]

  Permission denied.

- \[PAM\_SYSTEM\_ERR\]

  System error.

## SEE ALSO

[setegid(2)](/setegid/2.md), [seteuid(2)](/seteuid/2.md), [setgroups(2)](/setgroups/2.md), [openpam\_restore\_cred(3)](/openpam_restore_cred/3.md), [pam(3)](/pam/3.md), [pam\_strerror(3)](/pam_strerror/3.md)

## STANDARDS

The **openpam\_borrow\_cred** function is an OpenPAM extension.

## AUTHORS

The **openpam\_borrow\_cred** 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.
