Line data Source code
1 : /* Copyright (C) 1996-2022 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 : #define __need_size_t 32 : #include <stddef.h> 33 : 34 : #include <bits/types/FILE.h> 35 : 36 : /* Paths to the user database files. */ 37 : #define SHADOW _PATH_SHADOW 38 : 39 : 40 : __BEGIN_DECLS 41 : 42 : /* A record in the shadow database. */ 43 : struct spwd 44 : { 45 : char *sp_namp; /* Login name. */ 46 : char *sp_pwdp; /* Hashed passphrase. */ 47 : long int sp_lstchg; /* Date of last change. */ 48 : long int sp_min; /* Minimum number of days between changes. */ 49 : long int sp_max; /* Maximum number of days between changes. */ 50 : long int sp_warn; /* Number of days to warn user to change 51 : the password. */ 52 : long int sp_inact; /* Number of days the account may be 53 : inactive. */ 54 : long int sp_expire; /* Number of days since 1970-01-01 until 55 : account expires. */ 56 : unsigned long int sp_flag; /* Reserved. */ 57 : }; 58 : 59 : 60 : /* Open database for reading. 61 : 62 : This function is not part of POSIX and therefore no official 63 : cancellation point. But due to similarity with an POSIX interface 64 : or due to the implementation it is a cancellation point and 65 : therefore not marked with __THROW. */ 66 : extern void setspent (void); 67 : 68 : /* Close database. 69 : 70 : This function is not part of POSIX and therefore no official 71 : cancellation point. But due to similarity with an POSIX interface 72 : or due to the implementation it is a cancellation point and 73 : therefore not marked with __THROW. */ 74 : extern void endspent (void); 75 : 76 : /* Get next entry from database, perhaps after opening the file. 77 : 78 : This function is not part of POSIX and therefore no official 79 : cancellation point. But due to similarity with an POSIX interface 80 : or due to the implementation it is a cancellation point and 81 : therefore not marked with __THROW. */ 82 : extern struct spwd *getspent (void); 83 : 84 : /* Get shadow entry matching NAME. 85 : 86 : This function is not part of POSIX and therefore no official 87 : cancellation point. But due to similarity with an POSIX interface 88 : or due to the implementation it is a cancellation point and 89 : therefore not marked with __THROW. */ 90 0 : extern struct spwd *getspnam (const char *__name); 91 : 92 : /* Read shadow entry from STRING. 93 : 94 : This function is not part of POSIX and therefore no official 95 : cancellation point. But due to similarity with an POSIX interface 96 : or due to the implementation it is a cancellation point and 97 : therefore not marked with __THROW. */ 98 : extern struct spwd *sgetspent (const char *__string); 99 : 100 : /* Read next shadow entry from STREAM. 101 : 102 : This function is not part of POSIX and therefore no official 103 : cancellation point. But due to similarity with an POSIX interface 104 : or due to the implementation it is a cancellation point and 105 : therefore not marked with __THROW. */ 106 : extern struct spwd *fgetspent (FILE *__stream); 107 : 108 : /* Write line containing shadow entry to stream. 109 : 110 : This function is not part of POSIX and therefore no official 111 : cancellation point. But due to similarity with an POSIX interface 112 : or due to the implementation it is a cancellation point and 113 : therefore not marked with __THROW. */ 114 : extern int putspent (const struct spwd *__p, FILE *__stream); 115 : 116 : 117 : #ifdef __USE_MISC 118 : /* Reentrant versions of some of the functions above. 119 : 120 : These functions are not part of POSIX and therefore no official 121 : cancellation point. But due to similarity with an POSIX interface 122 : or due to the implementation they are cancellation points and 123 : therefore not marked with __THROW. */ 124 : extern int getspent_r (struct spwd *__result_buf, char *__buffer, 125 : size_t __buflen, struct spwd **__result); 126 : 127 : extern int getspnam_r (const char *__name, struct spwd *__result_buf, 128 : char *__buffer, size_t __buflen, 129 : struct spwd **__result); 130 : 131 : extern int sgetspent_r (const char *__string, struct spwd *__result_buf, 132 : char *__buffer, size_t __buflen, 133 : struct spwd **__result); 134 : 135 : extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf, 136 : char *__buffer, size_t __buflen, 137 : struct spwd **__result); 138 : #endif /* misc */ 139 : 140 : 141 : /* The simple locking functionality provided here is not suitable for 142 : multi-threaded applications. */ 143 : 144 : /* Request exclusive access to /etc/passwd and /etc/shadow. */ 145 : extern int lckpwdf (void) __THROW; 146 : 147 : /* Release exclusive access to /etc/passwd and /etc/shadow. */ 148 : extern int ulckpwdf (void) __THROW; 149 : 150 : __END_DECLS 151 : 152 : #endif /* shadow.h */