Back to index

glibc  2.9
shadow.h
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /* Declaration of types and functions for shadow password suite.  */
00020 
00021 #ifndef _SHADOW_H
00022 #define _SHADOW_H    1
00023 
00024 #include <features.h>
00025 
00026 #include <paths.h>
00027 
00028 #define       __need_FILE
00029 #include <stdio.h>
00030 #define __need_size_t
00031 #include <stddef.h>
00032 
00033 /* Paths to the user database files.  */
00034 #define       SHADOW _PATH_SHADOW
00035 
00036 
00037 __BEGIN_DECLS
00038 
00039 /* Structure of the password file.  */
00040 struct spwd
00041   {
00042     char *sp_namp;          /* Login name.  */
00043     char *sp_pwdp;          /* Encrypted password.  */
00044     long int sp_lstchg;            /* Date of last change.  */
00045     long int sp_min;        /* Minimum number of days between changes.  */
00046     long int sp_max;        /* Maximum number of days between changes.  */
00047     long int sp_warn;              /* Number of days to warn user to change
00048                                the password.  */
00049     long int sp_inact;             /* Number of days the account may be
00050                                inactive.  */
00051     long int sp_expire;            /* Number of days since 1970-01-01 until
00052                                account expires.  */
00053     unsigned long int sp_flag;     /* Reserved.  */
00054   };
00055 
00056 
00057 /* Open database for reading.
00058 
00059    This function is not part of POSIX and therefore no official
00060    cancellation point.  But due to similarity with an POSIX interface
00061    or due to the implementation it is a cancellation point and
00062    therefore not marked with __THROW.  */
00063 extern void setspent (void);
00064 
00065 /* Close database.
00066 
00067    This function is not part of POSIX and therefore no official
00068    cancellation point.  But due to similarity with an POSIX interface
00069    or due to the implementation it is a cancellation point and
00070    therefore not marked with __THROW.  */
00071 extern void endspent (void);
00072 
00073 /* Get next entry from database, perhaps after opening the file.
00074 
00075    This function is not part of POSIX and therefore no official
00076    cancellation point.  But due to similarity with an POSIX interface
00077    or due to the implementation it is a cancellation point and
00078    therefore not marked with __THROW.  */
00079 extern struct spwd *getspent (void);
00080 
00081 /* Get shadow entry matching NAME.
00082 
00083    This function is not part of POSIX and therefore no official
00084    cancellation point.  But due to similarity with an POSIX interface
00085    or due to the implementation it is a cancellation point and
00086    therefore not marked with __THROW.  */
00087 extern struct spwd *getspnam (__const char *__name);
00088 
00089 /* Read shadow entry from STRING.
00090 
00091    This function is not part of POSIX and therefore no official
00092    cancellation point.  But due to similarity with an POSIX interface
00093    or due to the implementation it is a cancellation point and
00094    therefore not marked with __THROW.  */
00095 extern struct spwd *sgetspent (__const char *__string);
00096 
00097 /* Read next shadow entry from STREAM.
00098 
00099    This function is not part of POSIX and therefore no official
00100    cancellation point.  But due to similarity with an POSIX interface
00101    or due to the implementation it is a cancellation point and
00102    therefore not marked with __THROW.  */
00103 extern struct spwd *fgetspent (FILE *__stream);
00104 
00105 /* Write line containing shadow password entry to stream.
00106 
00107    This function is not part of POSIX and therefore no official
00108    cancellation point.  But due to similarity with an POSIX interface
00109    or due to the implementation it is a cancellation point and
00110    therefore not marked with __THROW.  */
00111 extern int putspent (__const struct spwd *__p, FILE *__stream);
00112 
00113 
00114 #ifdef __USE_MISC
00115 /* Reentrant versions of some of the functions above.
00116 
00117    These functions are not part of POSIX and therefore no official
00118    cancellation point.  But due to similarity with an POSIX interface
00119    or due to the implementation they are cancellation points and
00120    therefore not marked with __THROW.  */
00121 extern int getspent_r (struct spwd *__result_buf, char *__buffer,
00122                      size_t __buflen, struct spwd **__result);
00123 
00124 extern int getspnam_r (__const char *__name, struct spwd *__result_buf,
00125                      char *__buffer, size_t __buflen,
00126                      struct spwd **__result);
00127 
00128 extern int sgetspent_r (__const char *__string, struct spwd *__result_buf,
00129                      char *__buffer, size_t __buflen,
00130                      struct spwd **__result);
00131 
00132 extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf,
00133                      char *__buffer, size_t __buflen,
00134                      struct spwd **__result);
00135 #endif /* misc */
00136 
00137 
00138 /* The simple locking functionality provided here is not suitable for
00139    multi-threaded applications.  */
00140 
00141 /* Protect password file against multi writers.  */
00142 extern int lckpwdf (void) __THROW;
00143 
00144 /* Unlock password file.  */
00145 extern int ulckpwdf (void) __THROW;
00146 
00147 __END_DECLS
00148 
00149 #endif /* shadow.h */