TDE base libraries and programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.6KB

  1. /*****************************************************************
  2. *
  3. * kcheckpass
  4. *
  5. * Simple password checker. Just invoke and send it
  6. * the password on stdin.
  7. *
  8. * If the password was accepted, the program exits with 0;
  9. * if it was rejected, it exits with 1. Any other exit
  10. * code signals an error.
  11. *
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public
  15. * License as published by the Free Software Foundation; either
  16. * version 2 of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. * General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public
  24. * License along with this program; if not, write to the Free
  25. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  26. *
  27. * Copyright (C) 1998, Caldera, Inc.
  28. * Released under the GNU General Public License
  29. *
  30. * Olaf Kirch <okir@caldera.de> General Framework and PAM support
  31. * Christian Esken <esken@kde.org> Shadow and /etc/passwd support
  32. * Oswald Buddenhagen <ossi@kde.org> Binary server mode
  33. *
  34. * Other parts were taken from tdescreensaver's passwd.cpp
  35. *****************************************************************/
  36. #ifndef KCHECKPASS_H_
  37. #define KCHECKPASS_H_
  38. #include <config.h>
  39. #ifdef HAVE_CRYPT_H
  40. #include <crypt.h>
  41. #endif
  42. #ifdef HAVE_PATHS_H
  43. #include <paths.h>
  44. #endif
  45. #include <pwd.h>
  46. #include <sys/types.h>
  47. #ifndef _PATH_TMP
  48. #define _PATH_TMP "/tmp/"
  49. #endif
  50. #ifdef ultrix
  51. #include <auth.h>
  52. #endif
  53. #include <unistd.h>
  54. #ifdef OSF1_ENH_SEC
  55. #include <sys/security.h>
  56. #include <prot.h>
  57. #endif
  58. /* Make sure there is only one! */
  59. #if defined(HAVE_PAM)
  60. # undef HAVE_OSF_C2_PASSWD
  61. # undef HAVE_SHADOW
  62. #elif defined(HAVE_OSF_C2_PASSWD)
  63. # undef HAVE_SHADOW
  64. #elif defined(_AIX)
  65. # define HAVE_AIX_AUTH
  66. # undef HAVE_SHADOW
  67. #elif !defined(HAVE_SHADOW)
  68. # define HAVE_ETCPASSWD
  69. #endif
  70. #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
  71. # define ATTR_UNUSED __attribute__((unused))
  72. # define ATTR_NORETURN __attribute__((noreturn))
  73. # define ATTR_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
  74. #else
  75. # define ATTR_UNUSED
  76. # define ATTR_NORETURN
  77. # define ATTR_PRINTFLIKE(fmt,var)
  78. #endif
  79. #ifdef __cplusplus
  80. extern "C" {
  81. #endif
  82. /* these must match kcheckpass' exit codes */
  83. typedef enum {
  84. AuthOk = 0,
  85. AuthBad = 1,
  86. AuthError = 2,
  87. AuthAbort = 3
  88. } AuthReturn;
  89. typedef enum {
  90. ConvGetBinary,
  91. ConvGetNormal,
  92. ConvGetHidden,
  93. ConvPutInfo,
  94. ConvPutError
  95. } ConvRequest;
  96. /* these must match the defs in kgreeterplugin.h */
  97. typedef enum {
  98. IsUser = 1, /* unused in kcheckpass */
  99. IsPassword = 2
  100. } DataTag;
  101. /*****************************************************************
  102. * Authenticates user
  103. *****************************************************************/
  104. AuthReturn Authenticate(
  105. #ifdef HAVE_PAM
  106. const char *caller,
  107. #endif
  108. const char *method,
  109. const char *user,
  110. char *(*conv) (ConvRequest, const char *));
  111. /*****************************************************************
  112. * Output a message to stderr
  113. *****************************************************************/
  114. void message(const char *, ...) ATTR_PRINTFLIKE(1, 2);
  115. /*****************************************************************
  116. * Overwrite and free the passed string
  117. *****************************************************************/
  118. void dispose(char *);
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif