634dfb466de14ba7d943d7a2a70b7b0929f5ecc6
[oweals/busybox.git] / include / shadow_.h
1 /* vi: set sw=4 ts=4: */
2 /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    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.
9
10    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.
14
15    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
20 /* Declaration of types and functions for shadow password suite */
21
22 #if !ENABLE_USE_BB_SHADOW
23 #include <shadow.h>
24 #else
25
26 #ifndef _SHADOW_H
27 #define _SHADOW_H       1
28
29 /* Paths to the user database files */
30 #ifndef _PATH_SHADOW
31 #define _PATH_SHADOW "/etc/shadow"
32 #endif
33
34 /* Structure of the password file */
35 struct spwd {
36         char *sp_namp;          /* Login name */
37         char *sp_pwdp;          /* Encrypted password */
38         long int sp_lstchg;     /* Date of last change */
39         long int sp_min;        /* Minimum number of days between changes */
40         long int sp_max;        /* Maximum number of days between changes */
41         long int sp_warn;       /* Number of days to warn user to change the password */
42         long int sp_inact;      /* Number of days the account may be inactive */
43         long int sp_expire;     /* Number of days since 1970-01-01 until account expires */
44         unsigned long int sp_flag;      /* Reserved */
45 };
46
47 /* Open database for reading */
48 extern void setspent(void);
49
50 /* Close database */
51 extern void endspent(void);
52
53 /* Get next entry from database, perhaps after opening the file */
54 extern struct spwd *getspent(void);
55
56 /* Get shadow entry matching NAME */
57 extern struct spwd *getspnam(__const char *__name);
58
59 /* Read shadow entry from STRING */
60 extern struct spwd *sgetspent(__const char *__string);
61
62 /* Read next shadow entry from STREAM */
63 extern struct spwd *fgetspent(FILE *__stream);
64
65 /* Write line containing shadow password entry to stream */
66 extern int putspent(__const struct spwd *__p, FILE *__stream);
67
68 /* Reentrant versions of some of the functions above */
69 extern int getspent_r(struct spwd *__result_buf, char *__buffer,
70                        size_t __buflen, struct spwd **__result);
71
72 extern int getspnam_r(__const char *__name, struct spwd *__result_buf,
73                        char *__buffer, size_t __buflen,
74                        struct spwd **__result);
75
76 extern int sgetspent_r(__const char *__string, struct spwd *__result_buf,
77                         char *__buffer, size_t __buflen,
78                         struct spwd **__result);
79
80 extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf,
81                         char *__buffer, size_t __buflen,
82                         struct spwd **__result);
83 /* Protect password file against multi writers */
84 extern int lckpwdf(void);
85
86 /* Unlock password file */
87 extern int ulckpwdf(void);
88
89 #endif /* shadow.h */
90 #endif