getttyent(3) — Subroutines
NAME
getttyent, getttyent_r, getttynam, getttynam_r, setttyent, setttyent_r, endttyent, endttyent_r − Get a /etc/securettys file entry
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <ttyent.h>
struct ttyent ∗getttyent ( void );
int getttyent_r(
struct ttyent ∗tte,
char ∗buf,
int len,
FILE ∗∗tty_fp);
struct ttyent ∗getttynam(
const char ∗name);
int getttynam_r(
const char ∗name,
struct ttyent ∗tte,
char ∗buf,
int len);
int setttyent(void);
int setttyent_r(
FILE ∗∗tty_fp);
void endttyent(void);
void endttyent_r(
FILE ∗∗tty_fp);
PARAMETERS
ttePoints to the ttyent structure.
nameSpecifies the name of the requested tty description.
bufIs data for the tty.
lenSpecifies the length of buf.
tty_fpSpecifies a secure ttys file stream.
DESCRIPTION
The getttyent() and getttynam() functions each return a pointer to an object that has the following ttyent fields. This fields describe a line from the secure tty description file.
The members of the structure include the following:
ty_nameName of the character-special file.
ty_gettyThe string "none".
ty_typeThe string "none".
ty_statusA mask of bit fields. The TTY_SECURE flag indicates users with a user ID of 0 (zero) are allowed to log in on this terminal.
ty_windowA NULL pointer
ty_comment
A NULL pointer.
If any of the fields pointing to character strings are unspecified, they are returned as NULL pointers. The field ty_status will be 0 (zero) if root logins are not allowed.
The getttyent() function reads the next line from the tty file, opening the file if necessary. The setttyent() function rewinds the file if open, or opens the file if it is unopened. The endttyent() function closes any open files.
The getttynam() function searches from the beginning of the file until a matching name is found or until EOF (End-Of-File) is encountered.
The getttyent_r(), setttyent_r(), endttyent_r(), and getttynam_r() functions are the reentrant versions of the getttyent(), setttyent(), endttyent(), and getttynam() functions. Upon successful completion, both the getttyent_r() and getttynam_r() functions store the pointer to a ttyent structure in tte.
NOTES
These functions exist for compatibility with earlier systems.
For the getttyent(), setttyent(), endttyent(), and getttynam() functions, all information is contained in a static area so it must be copied if it is to be saved.
The ∗tty_fp parameter should be initialized to NULL by the user before the first call.
RETURN VALUES
Upon successful completion, the getttyent() and getttynam() functions return pointer tte. When a failure or EOF occurs, the getttyent() and getttynam() functions return a NULL pointer. Upon successful completion, the setttyent() function returns a value of 1. Otherwise, the setttyent() function returns 0 (zero).
The getttyent_r(), getttynam_r(), and setttyent_r() functions return a value of 0 (zero) for success, and a value of -1 for failure.
ERRORS
If any of the following conditions occurs, the getttyent_r() or getttynam_r() functions set errno to the corresponding value:
[ESRCH]The search failed.
In addition, if any of the following conditions occurs, the getttyent_r() or setttyent_r() functions set errno to the corresponding value:
[EINVAL]The tty_fp, tte, or buf parameter is invalid, or the len parameter is too small.
FILES
/etc/securettys Contains the terminal control database file.
RELATED INFORMATION
Commands: login(1)
Files: securettys(4).