"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 | |
| 20 | /* Declaration of types and functions for shadow password suite. */ |
| 21 | |
| 22 | #if !defined CONFIG_USE_BB_SHADOW |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 23 | #include <shadow.h> |
| 24 | #else |
| 25 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 26 | #ifndef _SHADOW_H |
| 27 | #define _SHADOW_H 1 |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 28 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 29 | #include <stdio.h> |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 30 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 31 | /* Paths to the user database files. */ |
| 32 | #ifndef _PATH_SHADOW |
| 33 | #define _PATH_SHADOW "/etc/shadow" |
| 34 | #endif |
| 35 | #define SHADOW _PATH_SHADOW |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 36 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 37 | |
| 38 | /* Structure of the password file. */ |
| 39 | struct spwd |
| 40 | { |
| 41 | char *sp_namp; /* Login name. */ |
| 42 | char *sp_pwdp; /* Encrypted password. */ |
| 43 | long int sp_lstchg; /* Date of last change. */ |
| 44 | long int sp_min; /* Minimum number of days between changes. */ |
| 45 | long int sp_max; /* Maximum number of days between changes. */ |
| 46 | long int sp_warn; /* Number of days to warn user to change |
| 47 | the password. */ |
| 48 | long int sp_inact; /* Number of days the account may be |
| 49 | inactive. */ |
| 50 | long int sp_expire; /* Number of days since 1970-01-01 until |
| 51 | account expires. */ |
| 52 | unsigned long int sp_flag; /* Reserved. */ |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 55 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 56 | /* Open database for reading. */ |
| 57 | extern void setspent (void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 58 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 59 | /* Close database. */ |
| 60 | extern void endspent (void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 61 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 62 | /* Get next entry from database, perhaps after opening the file. */ |
| 63 | extern struct spwd *getspent (void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 64 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 65 | /* Get shadow entry matching NAME. */ |
| 66 | extern struct spwd *getspnam (__const char *__name); |
| 67 | |
| 68 | /* Read shadow entry from STRING. */ |
| 69 | extern struct spwd *sgetspent (__const char *__string); |
| 70 | |
| 71 | /* Read next shadow entry from STREAM. */ |
| 72 | extern struct spwd *fgetspent (FILE *__stream); |
| 73 | |
| 74 | /* Write line containing shadow password entry to stream. */ |
| 75 | extern int putspent (__const struct spwd *__p, FILE *__stream); |
| 76 | |
| 77 | /* Reentrant versions of some of the functions above. */ |
| 78 | extern int getspent_r (struct spwd *__result_buf, char *__buffer, |
| 79 | size_t __buflen, struct spwd **__result); |
| 80 | |
| 81 | extern int getspnam_r (__const char *__name, struct spwd *__result_buf, |
| 82 | char *__buffer, size_t __buflen, |
Rob Landley | 9755197 | 2006-05-29 05:21:29 +0000 | [diff] [blame] | 83 | struct spwd **__result); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 84 | |
| 85 | extern int sgetspent_r (__const char *__string, struct spwd *__result_buf, |
| 86 | char *__buffer, size_t __buflen, |
| 87 | struct spwd **__result); |
| 88 | |
| 89 | extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf, |
| 90 | char *__buffer, size_t __buflen, |
| 91 | struct spwd **__result); |
| 92 | /* Protect password file against multi writers. */ |
| 93 | extern int lckpwdf (void); |
| 94 | |
| 95 | /* Unlock password file. */ |
| 96 | extern int ulckpwdf (void); |
| 97 | |
| 98 | #endif /* shadow.h */ |
| 99 | #endif |