fe.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. #ifndef _SLAPD_FE_H_
  42. #define _SLAPD_FE_H_
  43. #include <prio.h>
  44. #include "slap.h"
  45. /*
  46. * Global Variables...
  47. */
  48. #ifdef LDAP_DEBUG
  49. #if defined( _WIN32 )
  50. #ifndef DONT_DECLARE_SLAPD_LDAP_DEBUG
  51. extern __declspec(dllimport) int slapd_ldap_debug;
  52. #endif /* DONT_DECLARE_SLAPD_LDAP_DEBUG */
  53. #endif
  54. #endif
  55. extern Slapi_Counter *ops_initiated;
  56. extern Slapi_Counter *ops_completed;
  57. extern Slapi_Counter *max_threads_count;
  58. extern Slapi_Counter *conns_in_maxthreads;
  59. extern PRThread *listener_tid;
  60. extern PRThread *listener_tid;
  61. extern Slapi_Counter *num_conns;
  62. extern char *pid_file;
  63. extern char *start_pid_file;
  64. extern int should_detach;
  65. extern int connection_type; /* JCM - Evil. Solve by creating a real connection constructor & destructor */
  66. #ifndef HAVE_TIME_R
  67. extern PRLock *time_func_mutex;
  68. #endif /* HAVE_TIME_R */
  69. extern PRLock *currenttime_mutex;
  70. extern time_t starttime;
  71. extern char *configfile;
  72. #if defined( _WIN32 )
  73. extern LPTSTR pszServerName;
  74. #endif
  75. #if defined( _WIN32 )
  76. /* String constants (no change for international) */
  77. extern HANDLE hSlapdEventSource;
  78. extern SERVICE_STATUS LDAPServerStatus;
  79. extern SERVICE_STATUS_HANDLE hLDAPServerServiceStatus;
  80. #endif
  81. /*
  82. * auth.c
  83. *
  84. */
  85. void client_auth_init();
  86. void handle_handshake_done (PRFileDesc *prfd, void* clientData);
  87. int handle_bad_certificate (void* clientData, PRFileDesc *prfd);
  88. /*
  89. * connection.c
  90. */
  91. void op_thread_cleanup();
  92. /*
  93. * ntuserpin.c - Prompts for the key database passphrase.
  94. */
  95. #include "svrcore.h"
  96. typedef struct SVRCORENTUserPinObj SVRCORENTUserPinObj;
  97. SVRCOREError SVRCORE_CreateNTUserPinObj(SVRCORENTUserPinObj **out);
  98. void SVRCORE_SetNTUserPinInteractive(SVRCORENTUserPinObj *obj, PRBool interactive);
  99. void SVRCORE_DestroyNTUserPinObj(SVRCORENTUserPinObj *obj);
  100. /*
  101. * connection.c
  102. */
  103. void connection_abandon_operations( Connection *conn );
  104. int connection_activity( Connection *conn, int maxthreads );
  105. void init_op_threads();
  106. int connection_new_private(Connection *conn);
  107. void connection_remove_operation( Connection *conn, Operation *op );
  108. void connection_remove_operation_ext( Slapi_PBlock *pb, Connection *conn, Operation *op );
  109. int connection_operations_pending( Connection *conn, Operation *op2ignore,
  110. int test_resultsent );
  111. void connection_done(Connection *conn);
  112. void connection_cleanup(Connection *conn);
  113. void connection_reset(Connection* conn, int ns, PRNetAddr * from, int fromLen, int is_SSL);
  114. void connection_set_io_layer_cb( Connection *c, Conn_IO_Layer_cb push_cb, Conn_IO_Layer_cb pop_cb, void *cb_data );
  115. int connection_call_io_layer_callbacks( Connection *c );
  116. /*
  117. * conntable.c
  118. */
  119. /*
  120. * Note: the correct order to use when acquiring multiple locks is
  121. * c[i]->c_mutex followed by table_mutex.
  122. */
  123. struct connection_table
  124. {
  125. int size;
  126. /* An array of connections, file descriptors, and a mapping between them. */
  127. Connection *c;
  128. struct POLL_STRUCT *fd;
  129. int n_tcps; /* standard socket start index in fd */
  130. int n_tcpe; /* standard socket last ( +1 ) index in fd */
  131. int s_tcps; /* ssl socket start index in fd */
  132. int s_tcpe; /* ssl socket last ( +1 ) in fd */
  133. #ifndef XP_WIN32
  134. #if defined(ENABLE_LDAPI)
  135. int i_unixs; /* unix socket start index in fd */
  136. int i_unixe; /* unix socket last ( +1 ) in fd */
  137. #endif /* ENABLE_LDAPI */
  138. #endif
  139. PRLock *table_mutex;
  140. };
  141. typedef struct connection_table Connection_Table;
  142. extern Connection_Table *the_connection_table; /* JCM - Exported from globals.c for daemon.c, monitor.c, puke, gag, etc */
  143. Connection_Table *connection_table_new(int table_size);
  144. void connection_table_free(Connection_Table *ct);
  145. void connection_table_abandon_all_operations(Connection_Table *ct);
  146. Connection *connection_table_get_connection(Connection_Table *ct, int sd);
  147. void connection_table_move_connection_out_of_active_list(Connection_Table *ct, Connection *c);
  148. void connection_table_move_connection_on_to_active_list(Connection_Table *ct, Connection *c);
  149. void connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e);
  150. void connection_table_dump_activity_to_errors_log(Connection_Table *ct);
  151. Connection* connection_table_get_first_active_connection (Connection_Table *ct);
  152. Connection* connection_table_get_next_active_connection (Connection_Table *ct, Connection *c);
  153. typedef int (*Connection_Table_Iterate_Function)(Connection *c, void *arg);
  154. int connection_table_iterate_active_connections(Connection_Table *ct, void* arg, Connection_Table_Iterate_Function f);
  155. #if defined( _WIN32 )
  156. Connection* connection_table_get_connection_from_fd(Connection_Table *ct,PRFileDesc *prfd);
  157. #endif
  158. #if 0
  159. void connection_table_dump(Connection_Table *ct);
  160. #endif
  161. /*
  162. * daemon.c
  163. */
  164. int signal_listner();
  165. int daemon_pre_setuid_init(daemon_ports_t *ports);
  166. void slapd_daemon( daemon_ports_t *ports );
  167. void daemon_register_connection();
  168. int slapd_listenhost2addr( const char *listenhost, PRNetAddr ***addr );
  169. int daemon_register_reslimits( void );
  170. PRFileDesc * get_ssl_listener_fd();
  171. int configure_pr_socket( PRFileDesc **pr_socket, int secure, int local );
  172. void configure_ns_socket( int * ns );
  173. /*
  174. * sasl_io.c
  175. */
  176. int sasl_io_enable(Connection *c, void *data);
  177. int sasl_io_cleanup(Connection *c, void *data);
  178. /*
  179. * sasl_map.c
  180. */
  181. typedef struct sasl_map_data_ sasl_map_data;
  182. struct sasl_map_data_ {
  183. char *name;
  184. char *regular_expression;
  185. char *template_base_dn;
  186. char *template_search_filter;
  187. int priority;
  188. sasl_map_data *next; /* For linked list */
  189. sasl_map_data *prev;
  190. };
  191. typedef struct _sasl_map_private {
  192. Slapi_RWLock *lock;
  193. sasl_map_data *map_data_list;
  194. } sasl_map_private;
  195. int sasl_map_config_add(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg);
  196. int sasl_map_config_delete(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg);
  197. int sasl_map_config_modify(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg);
  198. int sasl_map_domap(sasl_map_data **map, char *sasl_user, char *sasl_realm, char **ldap_search_base, char **ldap_search_filter);
  199. int sasl_map_init();
  200. int sasl_map_done();
  201. void sasl_map_read_lock();
  202. void sasl_map_read_unlock();
  203. #endif