blob: 1b14f0a7bc61c9e3bcad99cc90efa3da45b4cda3 [file] [log] [blame]
Eric Andersen9615a082004-07-15 12:53:49 +00001/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
Eric Andersen27f64e12002-06-23 04:24:25 +00003
Eric Andersen9615a082004-07-15 12:53:49 +00004 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
Eric Andersen27f64e12002-06-23 04:24:25 +00008
Eric Andersen9615a082004-07-15 12:53:49 +00009 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
Eric Andersen27f64e12002-06-23 04:24:25 +000013
Eric Andersen9615a082004-07-15 12:53:49 +000014 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19/* Declaration of types and functions for shadow password suite. */
20
21#if !defined CONFIG_USE_BB_SHADOW
Eric Andersen27f64e12002-06-23 04:24:25 +000022#include <shadow.h>
23#else
24
Eric Andersen9615a082004-07-15 12:53:49 +000025#ifndef _SHADOW_H
26#define _SHADOW_H 1
Eric Andersen27f64e12002-06-23 04:24:25 +000027
Eric Andersen9615a082004-07-15 12:53:49 +000028#include <stdio.h>
Eric Andersen27f64e12002-06-23 04:24:25 +000029
Eric Andersen9615a082004-07-15 12:53:49 +000030/* Paths to the user database files. */
31#ifndef _PATH_SHADOW
32#define _PATH_SHADOW "/etc/shadow"
33#endif
34#define SHADOW _PATH_SHADOW
Eric Andersen27f64e12002-06-23 04:24:25 +000035
Eric Andersen9615a082004-07-15 12:53:49 +000036
37/* Structure of the password file. */
38struct spwd
39{
40 char *sp_namp; /* Login name. */
41 char *sp_pwdp; /* Encrypted password. */
42 long int sp_lstchg; /* Date of last change. */
43 long int sp_min; /* Minimum number of days between changes. */
44 long int sp_max; /* Maximum number of days between changes. */
45 long int sp_warn; /* Number of days to warn user to change
46 the password. */
47 long int sp_inact; /* Number of days the account may be
48 inactive. */
49 long int sp_expire; /* Number of days since 1970-01-01 until
50 account expires. */
51 unsigned long int sp_flag; /* Reserved. */
Eric Andersen27f64e12002-06-23 04:24:25 +000052};
53
Eric Andersen27f64e12002-06-23 04:24:25 +000054
Eric Andersen9615a082004-07-15 12:53:49 +000055/* Open database for reading. */
56extern void setspent (void);
Eric Andersen27f64e12002-06-23 04:24:25 +000057
Eric Andersen9615a082004-07-15 12:53:49 +000058/* Close database. */
59extern void endspent (void);
Eric Andersen27f64e12002-06-23 04:24:25 +000060
Eric Andersen9615a082004-07-15 12:53:49 +000061/* Get next entry from database, perhaps after opening the file. */
62extern struct spwd *getspent (void);
Eric Andersen27f64e12002-06-23 04:24:25 +000063
Eric Andersen9615a082004-07-15 12:53:49 +000064/* Get shadow entry matching NAME. */
65extern struct spwd *getspnam (__const char *__name);
66
67/* Read shadow entry from STRING. */
68extern struct spwd *sgetspent (__const char *__string);
69
70/* Read next shadow entry from STREAM. */
71extern struct spwd *fgetspent (FILE *__stream);
72
73/* Write line containing shadow password entry to stream. */
74extern int putspent (__const struct spwd *__p, FILE *__stream);
75
76/* Reentrant versions of some of the functions above. */
77extern int getspent_r (struct spwd *__result_buf, char *__buffer,
78 size_t __buflen, struct spwd **__result);
79
80extern int getspnam_r (__const char *__name, struct spwd *__result_buf,
81 char *__buffer, size_t __buflen,
82 struct spwd **__result)__THROW;
83
84extern int sgetspent_r (__const char *__string, struct spwd *__result_buf,
85 char *__buffer, size_t __buflen,
86 struct spwd **__result);
87
88extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf,
89 char *__buffer, size_t __buflen,
90 struct spwd **__result);
91/* Protect password file against multi writers. */
92extern int lckpwdf (void);
93
94/* Unlock password file. */
95extern int ulckpwdf (void);
96
97#endif /* shadow.h */
98#endif