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