"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 | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 22 | #ifndef BB_SHADOW_H |
| 23 | #define BB_SHADOW_H 1 |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 24 | |
Denis Vlasenko | 98636eb | 2008-05-09 17:59:34 +0000 | [diff] [blame] | 25 | #if __GNUC_PREREQ(4,1) |
| 26 | # pragma GCC visibility push(hidden) |
| 27 | #endif |
| 28 | |
Denis Vlasenko | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 29 | /* This file is #included after #include <shadow.h> |
Bernhard Reutner-Fischer | fd3552d | 2008-09-26 11:23:22 +0000 | [diff] [blame] | 30 | * We will use libc-defined structures, but will #define function names |
Denis Vlasenko | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 31 | * so that function calls are directed to bb_internal_XXX replacements |
| 32 | */ |
| 33 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 34 | /* Paths to the user database files */ |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 35 | #ifndef _PATH_SHADOW |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 36 | #define _PATH_SHADOW "/etc/shadow" |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 37 | #endif |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 38 | |
Denis Vlasenko | cb04ff5 | 2006-12-30 21:11:57 +0000 | [diff] [blame] | 39 | #define setspent bb_internal_setspent |
| 40 | #define endspent bb_internal_endspent |
| 41 | #define getspent bb_internal_getspent |
| 42 | #define getspnam bb_internal_getspnam |
| 43 | #define sgetspent bb_internal_sgetspent |
| 44 | #define fgetspent bb_internal_fgetspent |
| 45 | #define putspent bb_internal_putspent |
| 46 | #define getspent_r bb_internal_getspent_r |
| 47 | #define getspnam_r bb_internal_getspnam_r |
| 48 | #define sgetspent_r bb_internal_sgetspent_r |
| 49 | #define fgetspent_r bb_internal_fgetspent_r |
| 50 | #define lckpwdf bb_internal_lckpwdf |
| 51 | #define ulckpwdf bb_internal_ulckpwdf |
| 52 | |
| 53 | |
| 54 | /* All function names below should be remapped by #defines above |
Denis Vlasenko | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 55 | * in order to not collide with libc names. */ |
Denis Vlasenko | cb04ff5 | 2006-12-30 21:11:57 +0000 | [diff] [blame] | 56 | |
| 57 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 58 | /* Open database for reading */ |
| 59 | extern void setspent(void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 60 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 61 | /* Close database */ |
| 62 | extern void endspent(void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 63 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 64 | /* Get next entry from database, perhaps after opening the file */ |
| 65 | extern struct spwd *getspent(void); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 66 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 67 | /* Get shadow entry matching NAME */ |
Denis Vlasenko | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 68 | extern struct spwd *getspnam(const char *__name); |
Eric Andersen | 27f64e1 | 2002-06-23 04:24:25 +0000 | [diff] [blame] | 69 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 70 | /* Read shadow entry from STRING */ |
Denis Vlasenko | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 71 | extern struct spwd *sgetspent(const char *__string); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 72 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 73 | /* Read next shadow entry from STREAM */ |
| 74 | extern struct spwd *fgetspent(FILE *__stream); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 75 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 76 | /* Write line containing shadow password entry to stream */ |
Denis Vlasenko | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 77 | extern int putspent(const struct spwd *__p, FILE *__stream); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 78 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 79 | /* Reentrant versions of some of the functions above */ |
| 80 | extern int getspent_r(struct spwd *__result_buf, char *__buffer, |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 81 | size_t __buflen, struct spwd **__result); |
| 82 | |
Denis Vlasenko | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 83 | extern int getspnam_r(const char *__name, struct spwd *__result_buf, |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 84 | char *__buffer, size_t __buflen, |
Rob Landley | 9755197 | 2006-05-29 05:21:29 +0000 | [diff] [blame] | 85 | struct spwd **__result); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 86 | |
Denis Vlasenko | ee5dce3 | 2008-09-26 10:35:55 +0000 | [diff] [blame] | 87 | extern int sgetspent_r(const char *__string, struct spwd *__result_buf, |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 88 | char *__buffer, size_t __buflen, |
| 89 | struct spwd **__result); |
| 90 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 91 | extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf, |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 92 | char *__buffer, size_t __buflen, |
| 93 | struct spwd **__result); |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 94 | /* Protect password file against multi writers */ |
| 95 | extern int lckpwdf(void); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 96 | |
Denis Vlasenko | 7fa0fca | 2006-12-28 21:33:30 +0000 | [diff] [blame] | 97 | /* Unlock password file */ |
| 98 | extern int ulckpwdf(void); |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 99 | |
Denis Vlasenko | 98636eb | 2008-05-09 17:59:34 +0000 | [diff] [blame] | 100 | #if __GNUC_PREREQ(4,1) |
| 101 | # pragma GCC visibility pop |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 102 | #endif |
Denis Vlasenko | 98636eb | 2008-05-09 17:59:34 +0000 | [diff] [blame] | 103 | |
| 104 | #endif /* shadow.h */ |