shadow.h 5.3 KB

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