---
name: "openpam_readline"
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/openpam_readline"
---

# openpam\_readline(3)

read a line from a file

## NAME

**openpam\_readline** – read a line from a file

## SYNOPSIS

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

**#include \<stdio.h\>**

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

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

*char \**\

**openpam\_readline**(*FILE \*f*, *int \*lineno*, *size\_t \*lenp*);

## DESCRIPTION

This function is deprecated and may be removed in a future release without further warning. The **openpam\_readlinev**() function may be used to achieve similar results.

The **openpam\_readline**() function reads a line from a file, and returns it in a NUL-terminated buffer allocated with [malloc(3)](/malloc/3.md).

The **openpam\_readline**() function performs a certain amount of processing on the data it reads:

- Comments (introduced by a hash sign) are stripped.

- Blank lines are ignored.

- If a line ends in a backslash, the backslash is stripped and the next line is appended.

If *lineno* is not NULL, the integer variable it points to is incremented every time a newline character is read.

If *lenp* is not NULL, the length of the line (not including the terminating NUL character) is stored in the variable it points to.

The caller is responsible for releasing the returned buffer by passing it to [free(3)](/free/3.md).

## RETURN VALUES

The **openpam\_readline**() function returns NULL on failure.

## SEE ALSO

[openpam\_readlinev(3)](/openpam_readlinev/3.md), [openpam\_readword(3)](/openpam_readword/3.md), [pam(3)](/pam/3.md)

## STANDARDS

The **openpam\_readline**() function is an OpenPAM extension.

## AUTHORS

The **openpam\_readline**() 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*⟩.
