]> git.ipfire.org Git - thirdparty/glibc.git/blob - shadow/shadow.h
Rename sys/ucontext.h to bits/ucontext.h.
[thirdparty/glibc.git] / shadow / shadow.h
1 /* Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18 /* Declaration of types and functions for "shadow" storage of hashed
19 passphrases. The shadow database is like the user database, but is
20 only accessible with special privileges, so that malicious users
21 cannot retrieve everyone else's hashed passphrase to brute-force at
22 their convenience. */
23
24 #ifndef _SHADOW_H
25 #define _SHADOW_H 1
26
27 #include <features.h>
28
29 #include <paths.h>
30
31 #include <bits/types/FILE.h>
32 #include <bits/types/size_t.h>
33
34 /* Paths to the user database files. */
35 #define SHADOW _PATH_SHADOW
36
37
38 __BEGIN_DECLS
39
40 /* A record in the shadow database. */
41 struct spwd
42 {
43 char *sp_namp; /* Login name. */
44 char *sp_pwdp; /* Hashed passphrase. */
45 long int sp_lstchg; /* Date of last change. */
46 long int sp_min; /* Minimum number of days between changes. */
47 long int sp_max; /* Maximum number of days between changes. */
48 long int sp_warn; /* Number of days to warn user to change
49 the password. */
50 long int sp_inact; /* Number of days the account may be
51 inactive. */
52 long int sp_expire; /* Number of days since 1970-01-01 until
53 account expires. */
54 unsigned long int sp_flag; /* Reserved. */
55 };
56
57
58 /* Open database for reading.
59
60 This function is not part of POSIX and therefore no official
61 cancellation point. But due to similarity with an POSIX interface
62 or due to the implementation it is a cancellation point and
63 therefore not marked with __THROW. */
64 extern void setspent (void);
65
66 /* Close database.
67
68 This function is not part of POSIX and therefore no official
69 cancellation point. But due to similarity with an POSIX interface
70 or due to the implementation it is a cancellation point and
71 therefore not marked with __THROW. */
72 extern void endspent (void);
73
74 /* Get next entry from database, perhaps after opening the file.
75
76 This function is not part of POSIX and therefore no official
77 cancellation point. But due to similarity with an POSIX interface
78 or due to the implementation it is a cancellation point and
79 therefore not marked with __THROW. */
80 extern struct spwd *getspent (void);
81
82 /* Get shadow entry matching NAME.
83
84 This function is not part of POSIX and therefore no official
85 cancellation point. But due to similarity with an POSIX interface
86 or due to the implementation it is a cancellation point and
87 therefore not marked with __THROW. */
88 extern struct spwd *getspnam (const char *__name);
89
90 /* Read shadow entry from STRING.
91
92 This function is not part of POSIX and therefore no official
93 cancellation point. But due to similarity with an POSIX interface
94 or due to the implementation it is a cancellation point and
95 therefore not marked with __THROW. */
96 extern struct spwd *sgetspent (const char *__string);
97
98 /* Read next shadow entry from STREAM.
99
100 This function is not part of POSIX and therefore no official
101 cancellation point. But due to similarity with an POSIX interface
102 or due to the implementation it is a cancellation point and
103 therefore not marked with __THROW. */
104 extern struct spwd *fgetspent (FILE *__stream);
105
106 /* Write line containing shadow entry to stream.
107
108 This function is not part of POSIX and therefore no official
109 cancellation point. But due to similarity with an POSIX interface
110 or due to the implementation it is a cancellation point and
111 therefore not marked with __THROW. */
112 extern int putspent (const struct spwd *__p, FILE *__stream);
113
114
115 #ifdef __USE_MISC
116 /* Reentrant versions of some of the functions above.
117
118 These functions are not part of POSIX and therefore no official
119 cancellation point. But due to similarity with an POSIX interface
120 or due to the implementation they are cancellation points and
121 therefore not marked with __THROW. */
122 extern int getspent_r (struct spwd *__result_buf, char *__buffer,
123 size_t __buflen, struct spwd **__result);
124
125 extern int getspnam_r (const char *__name, struct spwd *__result_buf,
126 char *__buffer, size_t __buflen,
127 struct spwd **__result);
128
129 extern int sgetspent_r (const char *__string, struct spwd *__result_buf,
130 char *__buffer, size_t __buflen,
131 struct spwd **__result);
132
133 extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf,
134 char *__buffer, size_t __buflen,
135 struct spwd **__result);
136 #endif /* misc */
137
138
139 /* The simple locking functionality provided here is not suitable for
140 multi-threaded applications. */
141
142 /* Request exclusive access to /etc/passwd and /etc/shadow. */
143 extern int lckpwdf (void) __THROW;
144
145 /* Release exclusive access to /etc/passwd and /etc/shadow. */
146 extern int ulckpwdf (void) __THROW;
147
148 __END_DECLS
149
150 #endif /* shadow.h */