blob: 7babe4f30e54c8f59b66a64aa599a6b6c53f9ed0 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Eric Andersen9615a082004-07-15 12:53:49 +00002/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
Eric Andersen27f64e12002-06-23 04:24:25 +00004
Eric Andersen9615a082004-07-15 12:53:49 +00005 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
Eric Andersen27f64e12002-06-23 04:24:25 +00009
Eric Andersen9615a082004-07-15 12:53:49 +000010 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
Eric Andersen27f64e12002-06-23 04:24:25 +000014
Eric Andersen9615a082004-07-15 12:53:49 +000015 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000020/* Declaration of types and functions for shadow password suite */
Eric Andersen9615a082004-07-15 12:53:49 +000021
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000022#ifndef BB_SHADOW_H
23#define BB_SHADOW_H 1
Eric Andersen27f64e12002-06-23 04:24:25 +000024
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000025PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
Denis Vlasenko98636eb2008-05-09 17:59:34 +000026
Mike Frysinger52a42672009-07-09 01:33:20 -040027/* Structure of the password file */
28struct spwd {
29 char *sp_namp; /* Login name */
30 char *sp_pwdp; /* Encrypted password */
31 long sp_lstchg; /* Date of last change */
32 long sp_min; /* Minimum number of days between changes */
33 long sp_max; /* Maximum number of days between changes */
34 long sp_warn; /* Number of days to warn user to change the password */
35 long sp_inact; /* Number of days the account may be inactive */
36 long sp_expire; /* Number of days since 1970-01-01 until account expires */
37 unsigned long sp_flag; /* Reserved */
38};
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000039
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000040#define setspent bb_internal_setspent
41#define endspent bb_internal_endspent
42#define getspent bb_internal_getspent
43#define getspnam bb_internal_getspnam
44#define sgetspent bb_internal_sgetspent
45#define fgetspent bb_internal_fgetspent
46#define putspent bb_internal_putspent
47#define getspent_r bb_internal_getspent_r
48#define getspnam_r bb_internal_getspnam_r
49#define sgetspent_r bb_internal_sgetspent_r
50#define fgetspent_r bb_internal_fgetspent_r
51#define lckpwdf bb_internal_lckpwdf
52#define ulckpwdf bb_internal_ulckpwdf
53
54
55/* All function names below should be remapped by #defines above
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000056 * in order to not collide with libc names. */
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000057
Denys Vlasenko8d22ca82010-03-31 14:43:58 +020058#ifdef UNUSED_FOR_NOW
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000059/* Open database for reading */
60extern void setspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000061
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000062/* Close database */
63extern void endspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000064
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000065/* Get next entry from database, perhaps after opening the file */
66extern struct spwd *getspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000067
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000068/* Get shadow entry matching NAME */
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000069extern struct spwd *getspnam(const char *__name);
Eric Andersen27f64e12002-06-23 04:24:25 +000070
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000071/* Read shadow entry from STRING */
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000072extern struct spwd *sgetspent(const char *__string);
Eric Andersen9615a082004-07-15 12:53:49 +000073
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000074/* Read next shadow entry from STREAM */
75extern struct spwd *fgetspent(FILE *__stream);
Eric Andersen9615a082004-07-15 12:53:49 +000076
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000077/* Write line containing shadow password entry to stream */
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000078extern int putspent(const struct spwd *__p, FILE *__stream);
Eric Andersen9615a082004-07-15 12:53:49 +000079
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000080/* Reentrant versions of some of the functions above */
81extern int getspent_r(struct spwd *__result_buf, char *__buffer,
Denys Vlasenko6830ade2013-01-15 13:58:01 +010082 size_t __buflen, struct spwd **__result);
Denys Vlasenko8d22ca82010-03-31 14:43:58 +020083#endif
Eric Andersen9615a082004-07-15 12:53:49 +000084
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000085extern int getspnam_r(const char *__name, struct spwd *__result_buf,
Denys Vlasenko6830ade2013-01-15 13:58:01 +010086 char *__buffer, size_t __buflen,
87 struct spwd **__result);
Eric Andersen9615a082004-07-15 12:53:49 +000088
Denys Vlasenko8d22ca82010-03-31 14:43:58 +020089#ifdef UNUSED_FOR_NOW
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000090extern int sgetspent_r(const char *__string, struct spwd *__result_buf,
Denys Vlasenko6830ade2013-01-15 13:58:01 +010091 char *__buffer, size_t __buflen,
92 struct spwd **__result);
Eric Andersen9615a082004-07-15 12:53:49 +000093
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000094extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf,
Denys Vlasenko6830ade2013-01-15 13:58:01 +010095 char *__buffer, size_t __buflen,
96 struct spwd **__result);
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000097/* Protect password file against multi writers */
98extern int lckpwdf(void);
Eric Andersen9615a082004-07-15 12:53:49 +000099
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +0000100/* Unlock password file */
101extern int ulckpwdf(void);
Denys Vlasenko8d22ca82010-03-31 14:43:58 +0200102#endif
Eric Andersen9615a082004-07-15 12:53:49 +0000103
Denis Vlasenkof81e8db2009-04-09 12:35:13 +0000104POP_SAVED_FUNCTION_VISIBILITY
Denis Vlasenko98636eb2008-05-09 17:59:34 +0000105
106#endif /* shadow.h */