pam_passthru.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 <dirlite_strings.h> /* PLUGIN_MAGIC_VENDOR_STR */
  53. #include "dirver.h"
  54. #include <nspr.h>
  55. /* Private API: to get slapd_pr_strerror() and SLAPI_COMPONENT_NAME_NSPR */
  56. #include "slapi-private.h"
  57. /*
  58. * macros
  59. */
  60. #define PAM_PASSTHRU_PLUGIN_SUBSYSTEM "pam_passthru-plugin" /* for logging */
  61. #define PAM_PASSTHRU_ASSERT( expr ) PR_ASSERT( expr )
  62. #define PAM_PASSTHRU_OP_NOT_HANDLED 0
  63. #define PAM_PASSTHRU_OP_HANDLED 1
  64. /* #define PAM_PASSTHRU_VERBOSE_LOGGING */
  65. /*
  66. * structs
  67. */
  68. typedef struct pam_passthrusuffix {
  69. Slapi_DN *pamptsuffix_dn;
  70. struct pam_passthrusuffix *pamptsuffix_next;
  71. } Pam_PassthruSuffix;
  72. #define PAMPT_MISSING_SUFFIX_ERROR 0 /* error out if an included or excluded suffix is missing */
  73. #define PAMPT_MISSING_SUFFIX_ALLOW 1 /* allow but log missing suffixes */
  74. #define PAMPT_MISSING_SUFFIX_IGNORE 2 /* allow and don't log missing suffixes */
  75. #define PAMPT_MISSING_SUFFIX_ERROR_STRING "ERROR"
  76. #define PAMPT_MISSING_SUFFIX_ALLOW_STRING "ALLOW"
  77. #define PAMPT_MISSING_SUFFIX_IGNORE_STRING "IGNORE"
  78. typedef struct pam_passthruconfig {
  79. Slapi_Mutex *lock; /* for config access */
  80. Pam_PassthruSuffix *pamptconfig_includes; /* list of suffixes to include in this op */
  81. Pam_PassthruSuffix *pamptconfig_excludes; /* list of suffixes to exclude in this op */
  82. PRBool pamptconfig_fallback; /* if false, failure here fails entire bind */
  83. /* if true, failure here falls through to regular bind */
  84. PRBool pamptconfig_secure; /* if true, plugin only operates on secure connections */
  85. char *pamptconfig_pam_ident_attr; /* name of attribute in user entry for ENTRY map method */
  86. int pamptconfig_map_method1; /* how to map the BIND DN to the PAM identity */
  87. int pamptconfig_map_method2; /* how to map the BIND DN to the PAM identity */
  88. int pamptconfig_map_method3; /* how to map the BIND DN to the PAM identity */
  89. #define PAMPT_MAP_METHOD_NONE -1 /* do not map */
  90. #define PAMPT_MAP_METHOD_DN 0 /* use the full DN as the PAM identity */
  91. #define PAMPT_MAP_METHOD_RDN 1 /* use the leftmost RDN value as the PAM identity */
  92. #define PAMPT_MAP_METHOD_ENTRY 2 /* use the PAM identity attribute in the entry */
  93. char *pamptconfig_service; /* the PAM service name for pam_start() */
  94. } Pam_PassthruConfig;
  95. #define PAMPT_MAP_METHOD_DN_STRING "DN"
  96. #define PAMPT_MAP_METHOD_RDN_STRING "RDN"
  97. #define PAMPT_MAP_METHOD_ENTRY_STRING "ENTRY"
  98. #define PAMPT_MISSING_SUFFIX_ATTR "pamMissingSuffix" /* single valued */
  99. #define PAMPT_EXCLUDES_ATTR "pamExcludeSuffix" /* multi valued */
  100. #define PAMPT_INCLUDES_ATTR "pamIncludeSuffix" /* multi valued */
  101. #define PAMPT_PAM_IDENT_ATTR "pamIDAttr" /* single valued (for now) */
  102. #define PAMPT_MAP_METHOD_ATTR "pamIDMapMethod" /* single valued */
  103. #define PAMPT_FALLBACK_ATTR "pamFallback" /* single */
  104. #define PAMPT_SECURE_ATTR "pamSecure" /* single */
  105. #define PAMPT_SERVICE_ATTR "pamService" /* single */
  106. /*
  107. * public functions
  108. */
  109. void pam_passthruauth_set_plugin_identity(void * identity);
  110. void * pam_passthruauth_get_plugin_identity();
  111. /*
  112. * pam_ptconfig.c:
  113. */
  114. int pam_passthru_config( Slapi_Entry *config_e );
  115. Pam_PassthruConfig *pam_passthru_get_config( void );
  116. int pam_passthru_check_suffix(Pam_PassthruConfig *cfg, char *binddn);
  117. /*
  118. * pam_ptimpl.c
  119. */
  120. int pam_passthru_pam_init( void );
  121. int pam_passthru_do_pam_auth(Slapi_PBlock *pb, Pam_PassthruConfig *cfg);
  122. #endif /* _PAM_PASSTHRU_H_ */