shadow.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* Copyright (C) 1996, 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. /* Declaration of types and functions for shadow password suite. */
  16. #ifndef _SHADOW_H
  17. #define _SHADOW_H 1
  18. #include <features.h>
  19. #include <paths.h>
  20. #define __need_FILE
  21. #include <stdio.h>
  22. #define __need_size_t
  23. #include <stddef.h>
  24. /* Paths to the user database files. */
  25. #define SHADOW _PATH_SHADOW
  26. __BEGIN_DECLS
  27. /* Structure of the password file. */
  28. struct spwd
  29. {
  30. char *sp_namp; /* Login name. */
  31. char *sp_pwdp; /* Encrypted password. */
  32. long int sp_lstchg; /* Date of last change. */
  33. long int sp_min; /* Minimum number of days between changes. */
  34. long int sp_max; /* Maximum number of days between changes. */
  35. long int sp_warn; /* Number of days to warn user to change
  36. the password. */
  37. long int sp_inact; /* Number of days the account may be
  38. inactive. */
  39. long int sp_expire; /* Number of days since 1970-01-01 until
  40. account expires. */
  41. unsigned long int sp_flag; /* Reserved. */
  42. };
  43. /* Open database for reading.
  44. This function is not part of POSIX and therefore no official
  45. cancellation point. But due to similarity with an POSIX interface
  46. or due to the implementation it is a cancellation point and
  47. therefore not marked with __THROW. */
  48. extern void setspent (void);
  49. /* Close database.
  50. This function is not part of POSIX and therefore no official
  51. cancellation point. But due to similarity with an POSIX interface
  52. or due to the implementation it is a cancellation point and
  53. therefore not marked with __THROW. */
  54. extern void endspent (void);
  55. /* Get next entry from database, perhaps after opening the file.
  56. This function is not part of POSIX and therefore no official
  57. cancellation point. But due to similarity with an POSIX interface
  58. or due to the implementation it is a cancellation point and
  59. therefore not marked with __THROW. */
  60. extern struct spwd *getspent (void);
  61. /* Get shadow entry matching NAME.
  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 struct spwd *getspnam (__const char *__name);
  67. /* Read shadow entry from STRING.
  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 struct spwd *sgetspent (__const char *__string);
  73. /* Read next shadow entry from STREAM.
  74. This function is not part of POSIX and therefore no official
  75. cancellation point. But due to similarity with an POSIX interface
  76. or due to the implementation it is a cancellation point and
  77. therefore not marked with __THROW. */
  78. extern struct spwd *fgetspent (FILE *__stream);
  79. /* Write line containing shadow password entry to stream.
  80. This function is not part of POSIX and therefore no official
  81. cancellation point. But due to similarity with an POSIX interface
  82. or due to the implementation it is a cancellation point and
  83. therefore not marked with __THROW. */
  84. extern int putspent (__const struct spwd *__p, FILE *__stream);
  85. #ifdef __USE_MISC
  86. /* Reentrant versions of some of the functions above.
  87. These functions are not part of POSIX and therefore no official
  88. cancellation point. But due to similarity with an POSIX interface
  89. or due to the implementation they are cancellation points and
  90. therefore not marked with __THROW. */
  91. extern int getspent_r (struct spwd *__result_buf, char *__buffer,
  92. size_t __buflen, struct spwd **__result);
  93. extern int getspnam_r (__const char *__name, struct spwd *__result_buf,
  94. char *__buffer, size_t __buflen,
  95. struct spwd **__result);
  96. extern int sgetspent_r (__const char *__string, struct spwd *__result_buf,
  97. char *__buffer, size_t __buflen,
  98. struct spwd **__result);
  99. extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf,
  100. char *__buffer, size_t __buflen,
  101. struct spwd **__result);
  102. #endif /* misc */
  103. /* The simple locking functionality provided here is not suitable for
  104. multi-threaded applications. */
  105. /* Protect password file against multi writers. */
  106. extern int lckpwdf (void) __THROW;
  107. /* Unlock password file. */
  108. extern int ulckpwdf (void) __THROW;
  109. __END_DECLS
  110. #endif /* shadow.h */