pam_passthru.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2005 Red Hat, Inc.
  35. * All rights reserved.
  36. * END COPYRIGHT BLOCK **/
  37. #ifdef HAVE_CONFIG_H
  38. # include <config.h>
  39. #endif
  40. /*
  41. * pam_passthru.h - Pass Through Authentication shared definitions
  42. *
  43. */
  44. #ifndef _PAM_PASSTHRU_H_
  45. #define _PAM_PASSTHRU_H_
  46. #include <stdio.h>
  47. #include <string.h>
  48. #include <time.h>
  49. #include <sys/types.h>
  50. #include "portable.h"
  51. #include "slapi-plugin.h"
  52. #include <nspr.h>
  53. /* Private API: to get slapd_pr_strerror() and SLAPI_COMPONENT_NAME_NSPR */
  54. #include "slapi-private.h"
  55. /*
  56. * macros
  57. */
  58. #define PAM_PASSTHRU_PLUGIN_SUBSYSTEM "pam_passthru-plugin" /* for logging */
  59. #define PAM_PASSTHRU_INT_POSTOP_DESC "PAM Passthru internal postop plugin"
  60. #define PAM_PASSTHRU_PREOP_DESC "PAM Passthru preop plugin"
  61. #define PAM_PASSTHRU_POSTOP_DESC "PAM Passthru postop plugin"
  62. #define PAM_PASSTHRU_ASSERT( expr ) PR_ASSERT( expr )
  63. #define PAM_PASSTHRU_OP_NOT_HANDLED 0
  64. #define PAM_PASSTHRU_OP_HANDLED 1
  65. #define PAM_PASSTHRU_SUCCESS 0
  66. #define PAM_PASSTHRU_FAILURE -1
  67. /* #define PAM_PASSTHRU_VERBOSE_LOGGING */
  68. /*
  69. * Plug-in globals
  70. */
  71. extern PRCList *pam_passthru_global_config;
  72. /*
  73. * structs
  74. */
  75. typedef struct pam_passthrusuffix {
  76. Slapi_DN *pamptsuffix_dn;
  77. struct pam_passthrusuffix *pamptsuffix_next;
  78. } Pam_PassthruSuffix;
  79. #define PAMPT_MISSING_SUFFIX_ERROR 0 /* error out if an included or excluded suffix is missing */
  80. #define PAMPT_MISSING_SUFFIX_ALLOW 1 /* allow but log missing suffixes */
  81. #define PAMPT_MISSING_SUFFIX_IGNORE 2 /* allow and don't log missing suffixes */
  82. #define PAMPT_MISSING_SUFFIX_ERROR_STRING "ERROR"
  83. #define PAMPT_MISSING_SUFFIX_ALLOW_STRING "ALLOW"
  84. #define PAMPT_MISSING_SUFFIX_IGNORE_STRING "IGNORE"
  85. typedef struct pam_passthruconfig {
  86. PRCList list;
  87. char *dn;
  88. Pam_PassthruSuffix *pamptconfig_includes; /* list of suffixes to include in this op */
  89. Pam_PassthruSuffix *pamptconfig_excludes; /* list of suffixes to exclude in this op */
  90. char *filter_str; /* search filter used to identify bind entries to include in this op */
  91. Slapi_Filter *slapi_filter; /* a Slapi_Filter version of the above filter */
  92. PRBool pamptconfig_fallback; /* if false, failure here fails entire bind */
  93. /* if true, failure here falls through to regular bind */
  94. PRBool pamptconfig_secure; /* if true, plugin only operates on secure connections */
  95. char *pamptconfig_pam_ident_attr; /* name of attribute in user entry for ENTRY map method */
  96. int pamptconfig_map_method1; /* how to map the BIND DN to the PAM identity */
  97. int pamptconfig_map_method2; /* how to map the BIND DN to the PAM identity */
  98. int pamptconfig_map_method3; /* how to map the BIND DN to the PAM identity */
  99. #define PAMPT_MAP_METHOD_NONE -1 /* do not map */
  100. #define PAMPT_MAP_METHOD_DN 0 /* use the full DN as the PAM identity */
  101. #define PAMPT_MAP_METHOD_RDN 1 /* use the leftmost RDN value as the PAM identity */
  102. #define PAMPT_MAP_METHOD_ENTRY 2 /* use the PAM identity attribute in the entry */
  103. char *pamptconfig_service; /* the PAM service name for pam_start() */
  104. } Pam_PassthruConfig;
  105. #define PAMPT_MAP_METHOD_DN_STRING "DN"
  106. #define PAMPT_MAP_METHOD_RDN_STRING "RDN"
  107. #define PAMPT_MAP_METHOD_ENTRY_STRING "ENTRY"
  108. #define PAMPT_MISSING_SUFFIX_ATTR "pamMissingSuffix" /* single valued */
  109. #define PAMPT_EXCLUDES_ATTR "pamExcludeSuffix" /* multi valued */
  110. #define PAMPT_INCLUDES_ATTR "pamIncludeSuffix" /* multi valued */
  111. #define PAMPT_PAM_IDENT_ATTR "pamIDAttr" /* single valued (for now) */
  112. #define PAMPT_MAP_METHOD_ATTR "pamIDMapMethod" /* single valued */
  113. #define PAMPT_FALLBACK_ATTR "pamFallback" /* single */
  114. #define PAMPT_SECURE_ATTR "pamSecure" /* single */
  115. #define PAMPT_SERVICE_ATTR "pamService" /* single */
  116. #define PAMPT_FILTER_ATTR "pamFilter" /* single */
  117. /*
  118. * public functions
  119. */
  120. void pam_passthruauth_set_plugin_identity(void * identity);
  121. void * pam_passthruauth_get_plugin_identity();
  122. void pam_passthruauth_set_plugin_sdn(const Slapi_DN *plugin_sdn);
  123. const Slapi_DN *pam_passthruauth_get_plugin_sdn();
  124. const char *pam_passthruauth_get_plugin_dn();
  125. void pam_passthru_read_lock();
  126. void pam_passthru_write_lock();
  127. void pam_passthru_unlock();
  128. /*
  129. * pam_ptconfig.c:
  130. */
  131. int pam_passthru_load_config(int skip_validate);
  132. void pam_passthru_delete_config();
  133. Pam_PassthruConfig *pam_passthru_get_config( Slapi_DN *bind_sdn );
  134. int pam_passthru_validate_config (Slapi_Entry* e, char *returntext);
  135. int pam_passthru_dn_is_config(Slapi_DN *sdn);
  136. void pam_passthru_set_config_area(Slapi_DN *sdn);
  137. Slapi_DN* pam_passthru_get_config_area();
  138. void pam_passthru_free_config_area();
  139. /*
  140. * pam_ptimpl.c
  141. */
  142. int pam_passthru_pam_init( void );
  143. int pam_passthru_pam_free( void );
  144. int pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg);
  145. #endif /* _PAM_PASSTHRU_H_ */