shadow_.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* vi: set sw=4 ts=4: */
  2. /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  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. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. /* Declaration of types and functions for shadow password suite */
  17. #if !ENABLE_USE_BB_SHADOW
  18. #include <shadow.h>
  19. #else
  20. #ifndef _SHADOW_H
  21. #define _SHADOW_H 1
  22. /* Paths to the user database files */
  23. #ifndef _PATH_SHADOW
  24. #define _PATH_SHADOW "/etc/shadow"
  25. #endif
  26. /* Structure of the password file */
  27. struct spwd {
  28. char *sp_namp; /* Login name */
  29. char *sp_pwdp; /* Encrypted password */
  30. long sp_lstchg; /* Date of last change */
  31. long sp_min; /* Minimum number of days between changes */
  32. long sp_max; /* Maximum number of days between changes */
  33. long sp_warn; /* Number of days to warn user to change the password */
  34. long sp_inact; /* Number of days the account may be inactive */
  35. long sp_expire; /* Number of days since 1970-01-01 until account expires */
  36. unsigned long sp_flag; /* Reserved */
  37. };
  38. #define setspent bb_internal_setspent
  39. #define endspent bb_internal_endspent
  40. #define getspent bb_internal_getspent
  41. #define getspnam bb_internal_getspnam
  42. #define sgetspent bb_internal_sgetspent
  43. #define fgetspent bb_internal_fgetspent
  44. #define putspent bb_internal_putspent
  45. #define getspent_r bb_internal_getspent_r
  46. #define getspnam_r bb_internal_getspnam_r
  47. #define sgetspent_r bb_internal_sgetspent_r
  48. #define fgetspent_r bb_internal_fgetspent_r
  49. #define lckpwdf bb_internal_lckpwdf
  50. #define ulckpwdf bb_internal_ulckpwdf
  51. /* All function names below should be remapped by #defines above
  52. * in order to not collide with libc names.
  53. * In theory it isn't necessary, but I saw weird interactions at link time.
  54. * Let's play safe */
  55. /* Open database for reading */
  56. extern void setspent(void);
  57. /* Close database */
  58. extern void endspent(void);
  59. /* Get next entry from database, perhaps after opening the file */
  60. extern struct spwd *getspent(void);
  61. /* Get shadow entry matching NAME */
  62. extern struct spwd *getspnam(__const char *__name);
  63. /* Read shadow entry from STRING */
  64. extern struct spwd *sgetspent(__const char *__string);
  65. /* Read next shadow entry from STREAM */
  66. extern struct spwd *fgetspent(FILE *__stream);
  67. /* Write line containing shadow password entry to stream */
  68. extern int putspent(__const struct spwd *__p, FILE *__stream);
  69. /* Reentrant versions of some of the functions above */
  70. extern int getspent_r(struct spwd *__result_buf, char *__buffer,
  71. size_t __buflen, struct spwd **__result);
  72. extern int getspnam_r(__const char *__name, struct spwd *__result_buf,
  73. char *__buffer, size_t __buflen,
  74. struct spwd **__result);
  75. extern int sgetspent_r(__const char *__string, struct spwd *__result_buf,
  76. char *__buffer, size_t __buflen,
  77. struct spwd **__result);
  78. extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf,
  79. char *__buffer, size_t __buflen,
  80. struct spwd **__result);
  81. /* Protect password file against multi writers */
  82. extern int lckpwdf(void);
  83. /* Unlock password file */
  84. extern int ulckpwdf(void);
  85. #endif /* shadow.h */
  86. #endif