shadow.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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, see
  13. <http://www.gnu.org/licenses/>. */
  14. /* Declaration of types and functions for shadow password suite. */
  15. #ifndef _SHADOW_H
  16. #define _SHADOW_H 1
  17. #include <features.h>
  18. #include <paths.h>
  19. #define __need_FILE
  20. #include <stdio.h>
  21. #define __need_size_t
  22. #include <stddef.h>
  23. /* Paths to the user database files. */
  24. #define SHADOW _PATH_SHADOW
  25. __BEGIN_DECLS
  26. /* Structure of the password file. */
  27. struct spwd
  28. {
  29. char *sp_namp; /* Login name. */
  30. char *sp_pwdp; /* Encrypted password. */
  31. long int sp_lstchg; /* Date of last change. */
  32. long int sp_min; /* Minimum number of days between changes. */
  33. long int sp_max; /* Maximum number of days between changes. */
  34. long int sp_warn; /* Number of days to warn user to change
  35. the password. */
  36. long int sp_inact; /* Number of days the account may be
  37. inactive. */
  38. long int sp_expire; /* Number of days since 1970-01-01 until
  39. account expires. */
  40. unsigned long int sp_flag; /* Reserved. */
  41. };
  42. /* Open database for reading.
  43. This function is not part of POSIX and therefore no official
  44. cancellation point. But due to similarity with an POSIX interface
  45. or due to the implementation it is a cancellation point and
  46. therefore not marked with __THROW. */
  47. extern void setspent (void);
  48. /* Close database.
  49. This function is not part of POSIX and therefore no official
  50. cancellation point. But due to similarity with an POSIX interface
  51. or due to the implementation it is a cancellation point and
  52. therefore not marked with __THROW. */
  53. extern void endspent (void);
  54. /* Get next entry from database, perhaps after opening the file.
  55. This function is not part of POSIX and therefore no official
  56. cancellation point. But due to similarity with an POSIX interface
  57. or due to the implementation it is a cancellation point and
  58. therefore not marked with __THROW. */
  59. extern struct spwd *getspent (void);
  60. /* Get shadow entry matching NAME.
  61. This function is not part of POSIX and therefore no official
  62. cancellation point. But due to similarity with an POSIX interface
  63. or due to the implementation it is a cancellation point and
  64. therefore not marked with __THROW. */
  65. extern struct spwd *getspnam (__const char *__name);
  66. /* Read shadow entry from STRING.
  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 struct spwd *sgetspent (__const char *__string);
  72. /* Read next shadow entry from STREAM.
  73. This function is not part of POSIX and therefore no official
  74. cancellation point. But due to similarity with an POSIX interface
  75. or due to the implementation it is a cancellation point and
  76. therefore not marked with __THROW. */
  77. extern struct spwd *fgetspent (FILE *__stream);
  78. /* Write line containing shadow password entry to stream.
  79. This function is not part of POSIX and therefore no official
  80. cancellation point. But due to similarity with an POSIX interface
  81. or due to the implementation it is a cancellation point and
  82. therefore not marked with __THROW. */
  83. extern int putspent (__const struct spwd *__p, FILE *__stream);
  84. #ifdef __USE_MISC
  85. /* Reentrant versions of some of the functions above.
  86. These functions are 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 they are cancellation points and
  89. therefore not marked with __THROW. */
  90. extern int getspent_r (struct spwd *__result_buf, char *__buffer,
  91. size_t __buflen, struct spwd **__result);
  92. libc_hidden_proto(getspent_r)
  93. extern int getspnam_r (__const char *__name, struct spwd *__result_buf,
  94. char *__buffer, size_t __buflen,
  95. struct spwd **__result);
  96. libc_hidden_proto(getspnam_r)
  97. extern int sgetspent_r (__const char *__string, struct spwd *__result_buf,
  98. char *__buffer, size_t __buflen,
  99. struct spwd **__result);
  100. libc_hidden_proto(sgetspent_r)
  101. extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf,
  102. char *__buffer, size_t __buflen,
  103. struct spwd **__result);
  104. libc_hidden_proto(fgetspent_r)
  105. #endif /* misc */
  106. /* The simple locking functionality provided here is not suitable for
  107. multi-threaded applications. */
  108. /* Protect password file against multi writers. */
  109. extern int lckpwdf (void) __THROW;
  110. /* Unlock password file. */
  111. extern int ulckpwdf (void) __THROW;
  112. __END_DECLS
  113. #endif /* shadow.h */