SHADOW(3) Library Calls SHADOW(3)

shadow, getspnam - Routinen für die Dateien mit verschlüsselten Passwörtern

#include <shadow.h>

struct spwd *getspent();

struct spwd *getspnam(char *name);

void setspent();

void endspent();

struct spwd *fgetspent(FILE *fp);

struct spwd *sgetspent(char *cp);

int putspent(struct spwd *p, FILE *fp);

int lckpwdf();

int ulckpwdf();

shadow manipulates the contents of the shadow password file, /etc/shadow. The structure in the #include file is:

struct spwd {
      char		*sp_namp; /* user login name */
      char		*sp_pwdp; /* encrypted password */
      long int		sp_lstchg; /* last password change */
      long int		sp_min; /* days until change allowed. */
      long int		sp_max; /* days before change required */
      long int		sp_warn; /* days warning for expiration */
      long int		sp_inact; /* days before account inactive */
      long int		sp_expire; /* date when account expires */
      unsigned long int	sp_flag; /* reserved for future use */
}

Die Bedeutung dieser Felder ist:

•sp_namp - Verweis auf den Anmeldenamen, mit NULL als Schlusszeichen
•sp_pwdp - Verweis auf verschlüsseltes Passwort, mit NULL als Schlusszeichen
•sp_lstchg - Tag, gezählt ab dem 1. Januar 1970, an dem das Passwort das letzte Mal geändert wurde
•sp_min - Anzahl der Tage, die das Passwort nicht geändert werden darf
•sp_max - Anzahl der Tage, nach denen das Passwort geändert werden muss
•sp_warn - Anzahl der Tage vor dem Ablaufen des Passworts, an welchen der Benutzer eine entsprechende Warnung erhält
•sp_inact - Anzahl der Tage nach Ablauf des Passworts, nach denen der Benutzer als inaktiv angesehen wird und den Zugriff auf das Konto verliert
•sp_expire - Tage, gezählt ab dem 1. Januar 1970, an dem das Konto erlöschen soll
•sp_flag - für zukünftigen Gebrauch reserviert

getspent, getspname, fgetspent, and sgetspent each return a pointer to a struct spwd. getspent returns the next entry from the file, and fgetspent returns the next entry from the given stream, which is assumed to be a file of the proper format. sgetspent returns a pointer to a struct spwd using the provided string as input. getspnam searches from the current position in the file for an entry matching name.

setspent and endspent may be used to begin and end, respectively, access to the shadow password file.

The lckpwdf and ulckpwdf routines should be used to insure exclusive access to the /etc/shadow file. lckpwdf attempts to acquire a lock using pw_lock for up to 15 seconds. It continues by attempting to acquire a second lock using spw_lock for the remainder of the initial 15 seconds. Should either attempt fail after a total of 15 seconds, lckpwdf returns -1. When both locks are acquired 0 is returned.

Routines return NULL if no more entries are available or if an error occurs during processing. Routines which have int as the return value return 0 for success and -1 for failure.

Nur der Systemadministrator kann diese Routinen verwenden, da der Zugriff auf die geschützte Passwortdatei beschränkt ist.

/etc/shadow

geschützte Informationen zu den Benutzerkonten

getpwent(3), shadow(5).

26.03.2024 shadow-utils 4.15.1