blob: 60f3e6b5f3d50b9a2e7210c91199b21d5ac53001 [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
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000022#ifndef BB_SHADOW_H
23#define BB_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 Vlasenkoee5dce32008-09-26 10:35:55 +000029/* This file is #included after #include <shadow.h>
Bernhard Reutner-Fischerfd3552d2008-09-26 11:23:22 +000030 * We will use libc-defined structures, but will #define function names
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000031 * so that function calls are directed to bb_internal_XXX replacements
32 */
33
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000034/* Paths to the user database files */
Eric Andersen9615a082004-07-15 12:53:49 +000035#ifndef _PATH_SHADOW
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000036#define _PATH_SHADOW "/etc/shadow"
Eric Andersen9615a082004-07-15 12:53:49 +000037#endif
Eric Andersen27f64e12002-06-23 04:24:25 +000038
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000039#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 Vlasenkoee5dce32008-09-26 10:35:55 +000055 * in order to not collide with libc names. */
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000056
57
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000058/* Open database for reading */
59extern void setspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000060
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000061/* Close database */
62extern void endspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000063
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000064/* Get next entry from database, perhaps after opening the file */
65extern struct spwd *getspent(void);
Eric Andersen27f64e12002-06-23 04:24:25 +000066
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000067/* Get shadow entry matching NAME */
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000068extern struct spwd *getspnam(const char *__name);
Eric Andersen27f64e12002-06-23 04:24:25 +000069
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000070/* Read shadow entry from STRING */
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000071extern struct spwd *sgetspent(const char *__string);
Eric Andersen9615a082004-07-15 12:53:49 +000072
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000073/* Read next shadow entry from STREAM */
74extern struct spwd *fgetspent(FILE *__stream);
Eric Andersen9615a082004-07-15 12:53:49 +000075
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000076/* Write line containing shadow password entry to stream */
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000077extern int putspent(const struct spwd *__p, FILE *__stream);
Eric Andersen9615a082004-07-15 12:53:49 +000078
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000079/* Reentrant versions of some of the functions above */
80extern int getspent_r(struct spwd *__result_buf, char *__buffer,
Eric Andersen9615a082004-07-15 12:53:49 +000081 size_t __buflen, struct spwd **__result);
82
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000083extern int getspnam_r(const char *__name, struct spwd *__result_buf,
Eric Andersen9615a082004-07-15 12:53:49 +000084 char *__buffer, size_t __buflen,
Rob Landley97551972006-05-29 05:21:29 +000085 struct spwd **__result);
Eric Andersen9615a082004-07-15 12:53:49 +000086
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000087extern int sgetspent_r(const char *__string, struct spwd *__result_buf,
Eric Andersen9615a082004-07-15 12:53:49 +000088 char *__buffer, size_t __buflen,
89 struct spwd **__result);
90
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000091extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf,
Eric Andersen9615a082004-07-15 12:53:49 +000092 char *__buffer, size_t __buflen,
93 struct spwd **__result);
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000094/* Protect password file against multi writers */
95extern int lckpwdf(void);
Eric Andersen9615a082004-07-15 12:53:49 +000096
Denis Vlasenko7fa0fca2006-12-28 21:33:30 +000097/* Unlock password file */
98extern int ulckpwdf(void);
Eric Andersen9615a082004-07-15 12:53:49 +000099
Denis Vlasenko98636eb2008-05-09 17:59:34 +0000100#if __GNUC_PREREQ(4,1)
101# pragma GCC visibility pop
Eric Andersen9615a082004-07-15 12:53:49 +0000102#endif
Denis Vlasenko98636eb2008-05-09 17:59:34 +0000103
104#endif /* shadow.h */