blob: 5a8b71a471fd54cd234ba6bb9b18fa1e7e3c75e7 [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
Eric Andersen9615a082004-07-15 12:53:49 +000022#ifndef _SHADOW_H
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000023#define _SHADOW_H 1
Eric Andersen27f64e12002-06-23 04:24:25 +000024
Denis Vlasenko98636eb2008-05-09 17:59:34 +000025#if __GNUC_PREREQ(4,1)
26# pragma GCC visibility push(hidden)
27#endif
28
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000029/* Paths to the user database files */
Eric Andersen9615a082004-07-15 12:53:49 +000030#ifndef _PATH_SHADOW
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000031#define _PATH_SHADOW "/etc/shadow"
Eric Andersen9615a082004-07-15 12:53:49 +000032#endif
Eric Andersen27f64e12002-06-23 04:24:25 +000033
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000034/* Structure of the password file */
35struct spwd {
36 char *sp_namp; /* Login name */
37 char *sp_pwdp; /* Encrypted password */
Denis Vlasenko87468852007-04-13 23:22:00 +000038 long sp_lstchg; /* Date of last change */
39 long sp_min; /* Minimum number of days between changes */
40 long sp_max; /* Maximum number of days between changes */
41 long sp_warn; /* Number of days to warn user to change the password */
42 long sp_inact; /* Number of days the account may be inactive */
43 long sp_expire; /* Number of days since 1970-01-01 until account expires */
44 unsigned long sp_flag; /* Reserved */
Eric Andersen27f64e12002-06-23 04:24:25 +000045};
46
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000047
48#define setspent bb_internal_setspent
49#define endspent bb_internal_endspent
50#define getspent bb_internal_getspent
51#define getspnam bb_internal_getspnam
52#define sgetspent bb_internal_sgetspent
53#define fgetspent bb_internal_fgetspent
54#define putspent bb_internal_putspent
55#define getspent_r bb_internal_getspent_r
56#define getspnam_r bb_internal_getspnam_r
57#define sgetspent_r bb_internal_sgetspent_r
58#define fgetspent_r bb_internal_fgetspent_r
59#define lckpwdf bb_internal_lckpwdf
60#define ulckpwdf bb_internal_ulckpwdf
61
62
63/* All function names below should be remapped by #defines above
64 * in order to not collide with libc names.
65 * In theory it isn't necessary, but I saw weird interactions at link time.
66 * Let's play safe */
67
68
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000069/* Open database for reading */
70extern void setspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000071
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000072/* Close database */
73extern void endspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000074
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000075/* Get next entry from database, perhaps after opening the file */
76extern struct spwd *getspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000077
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000078/* Get shadow entry matching NAME */
79extern struct spwd *getspnam(__const char *__name);
Eric Andersen27f64e12002-06-23 04:24:25 +000080
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000081/* Read shadow entry from STRING */
82extern struct spwd *sgetspent(__const char *__string);
Eric Andersen9615a082004-07-15 12:53:49 +000083
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000084/* Read next shadow entry from STREAM */
85extern struct spwd *fgetspent(FILE *__stream);
Eric Andersen9615a082004-07-15 12:53:49 +000086
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000087/* Write line containing shadow password entry to stream */
88extern int putspent(__const struct spwd *__p, FILE *__stream);
Eric Andersen9615a082004-07-15 12:53:49 +000089
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000090/* Reentrant versions of some of the functions above */
91extern int getspent_r(struct spwd *__result_buf, char *__buffer,
Eric Andersen9615a082004-07-15 12:53:49 +000092 size_t __buflen, struct spwd **__result);
93
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000094extern int getspnam_r(__const char *__name, struct spwd *__result_buf,
Eric Andersen9615a082004-07-15 12:53:49 +000095 char *__buffer, size_t __buflen,
Rob Landley97551972006-05-29 05:21:29 +000096 struct spwd **__result);
Eric Andersen9615a082004-07-15 12:53:49 +000097
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000098extern int sgetspent_r(__const char *__string, struct spwd *__result_buf,
Eric Andersen9615a082004-07-15 12:53:49 +000099 char *__buffer, size_t __buflen,
100 struct spwd **__result);
101
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +0000102extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf,
Eric Andersen9615a082004-07-15 12:53:49 +0000103 char *__buffer, size_t __buflen,
104 struct spwd **__result);
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +0000105/* Protect password file against multi writers */
106extern int lckpwdf(void);
Eric Andersen9615a082004-07-15 12:53:49 +0000107
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +0000108/* Unlock password file */
109extern int ulckpwdf(void);
Eric Andersen9615a082004-07-15 12:53:49 +0000110
Denis Vlasenko98636eb2008-05-09 17:59:34 +0000111#if __GNUC_PREREQ(4,1)
112# pragma GCC visibility pop
Eric Andersen9615a082004-07-15 12:53:49 +0000113#endif
Denis Vlasenko98636eb2008-05-09 17:59:34 +0000114
115#endif /* shadow.h */