"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 2 | /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 4 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 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. |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 9 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 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. |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 14 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 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 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 20 | /* Declaration of types and functions for shadow password suite */ |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 21 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 22 | #if !ENABLE_USE_BB_SHADOW |
Denis Vlasenko | cb04ff5 | 2006-12-30 21:11:57 +0000 | [diff] [blame] | 23 | |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 24 | #include <shadow.h> |
Denis Vlasenko | cb04ff5 | 2006-12-30 21:11:57 +0000 | [diff] [blame] | 25 | |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 26 | #else |
| 27 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 28 | #ifndef _SHADOW_H |
Denis Vlasenko | cb04ff5 | 2006-12-30 21:11:57 +0000 | [diff] [blame] | 29 | #define _SHADOW_H 1 |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 30 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 31 | /* Paths to the user database files */ |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 32 | #ifndef _PATH_SHADOW |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 33 | #define _PATH_SHADOW "/etc/shadow" |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 34 | #endif |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 35 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 36 | /* Structure of the password file */ |
| 37 | struct spwd { |
| 38 | char *sp_namp; /* Login name */ |
| 39 | char *sp_pwdp; /* Encrypted password */ |
| 40 | long int sp_lstchg; /* Date of last change */ |
| 41 | long int sp_min; /* Minimum number of days between changes */ |
| 42 | long int sp_max; /* Maximum number of days between changes */ |
| 43 | long int sp_warn; /* Number of days to warn user to change the password */ |
| 44 | long int sp_inact; /* Number of days the account may be inactive */ |
| 45 | long int sp_expire; /* Number of days since 1970-01-01 until account expires */ |
| 46 | unsigned long int sp_flag; /* Reserved */ |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
Denis Vlasenko | cb04ff5 | 2006-12-30 21:11:57 +0000 | [diff] [blame] | 49 | |
| 50 | #define setspent bb_internal_setspent |
| 51 | #define endspent bb_internal_endspent |
| 52 | #define getspent bb_internal_getspent |
| 53 | #define getspnam bb_internal_getspnam |
| 54 | #define sgetspent bb_internal_sgetspent |
| 55 | #define fgetspent bb_internal_fgetspent |
| 56 | #define putspent bb_internal_putspent |
| 57 | #define getspent_r bb_internal_getspent_r |
| 58 | #define getspnam_r bb_internal_getspnam_r |
| 59 | #define sgetspent_r bb_internal_sgetspent_r |
| 60 | #define fgetspent_r bb_internal_fgetspent_r |
| 61 | #define lckpwdf bb_internal_lckpwdf |
| 62 | #define ulckpwdf bb_internal_ulckpwdf |
| 63 | |
| 64 | |
| 65 | /* All function names below should be remapped by #defines above |
| 66 | * in order to not collide with libc names. |
| 67 | * In theory it isn't necessary, but I saw weird interactions at link time. |
| 68 | * Let's play safe */ |
| 69 | |
| 70 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 71 | /* Open database for reading */ |
| 72 | extern void setspent(void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 73 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 74 | /* Close database */ |
| 75 | extern void endspent(void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 76 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 77 | /* Get next entry from database, perhaps after opening the file */ |
| 78 | extern struct spwd *getspent(void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 79 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 80 | /* Get shadow entry matching NAME */ |
| 81 | extern struct spwd *getspnam(__const char *__name); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 82 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 83 | /* Read shadow entry from STRING */ |
| 84 | extern struct spwd *sgetspent(__const char *__string); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 85 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 86 | /* Read next shadow entry from STREAM */ |
| 87 | extern struct spwd *fgetspent(FILE *__stream); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 88 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 89 | /* Write line containing shadow password entry to stream */ |
| 90 | extern int putspent(__const struct spwd *__p, FILE *__stream); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 91 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 92 | /* Reentrant versions of some of the functions above */ |
| 93 | extern int getspent_r(struct spwd *__result_buf, char *__buffer, |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 94 | size_t __buflen, struct spwd **__result); |
| 95 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 96 | extern int getspnam_r(__const char *__name, struct spwd *__result_buf, |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 97 | char *__buffer, size_t __buflen, |
Rob Landley | 9755197 | 2006-05-29 05:21:29 +0000 | [diff] [blame] | 98 | struct spwd **__result); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 99 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 100 | extern int sgetspent_r(__const char *__string, struct spwd *__result_buf, |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 101 | char *__buffer, size_t __buflen, |
| 102 | struct spwd **__result); |
| 103 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 104 | extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf, |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 105 | char *__buffer, size_t __buflen, |
| 106 | struct spwd **__result); |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 107 | /* Protect password file against multi writers */ |
| 108 | extern int lckpwdf(void); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 109 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 110 | /* Unlock password file */ |
| 111 | extern int ulckpwdf(void); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 112 | |
| 113 | #endif /* shadow.h */ |
| 114 | #endif |