| 1 |
#ifndef LOOKUP_LDAP_H |
| 2 |
#define LOOKUP_LDAP_H |
| 3 |
|
| 4 |
#include <ldap.h> |
| 5 |
|
| 6 |
#ifdef WITH_SASL |
| 7 |
#include <openssl/ssl.h> |
| 8 |
#include <openssl/evp.h> |
| 9 |
#include <openssl/err.h> |
| 10 |
#include <sasl/sasl.h> |
| 11 |
#include <krb5.h> |
| 12 |
#endif |
| 13 |
|
| 14 |
#include <libxml/tree.h> |
| 15 |
|
| 16 |
#include "list.h" |
| 17 |
#include "dclist.h" |
| 18 |
|
| 19 |
struct ldap_schema { |
| 20 |
char *map_class; |
| 21 |
char *map_attr; |
| 22 |
char *entry_class; |
| 23 |
char *entry_attr; |
| 24 |
char *value_attr; |
| 25 |
}; |
| 26 |
|
| 27 |
struct ldap_uri { |
| 28 |
char *uri; |
| 29 |
struct list_head list; |
| 30 |
}; |
| 31 |
|
| 32 |
struct ldap_searchdn { |
| 33 |
char *basedn; |
| 34 |
struct ldap_searchdn *next; |
| 35 |
}; |
| 36 |
|
| 37 |
struct ldap_conn { |
| 38 |
LDAP *ldap; |
| 39 |
#ifdef WITH_SASL |
| 40 |
sasl_conn_t *sasl_conn; |
| 41 |
#endif |
| 42 |
}; |
| 43 |
|
| 44 |
struct lookup_context { |
| 45 |
char *mapname; |
| 46 |
unsigned int format; |
| 47 |
|
| 48 |
char *server; |
| 49 |
int port; |
| 50 |
char *base; |
| 51 |
char *qdn; |
| 52 |
unsigned int timeout; |
| 53 |
unsigned int network_timeout; |
| 54 |
unsigned long timestamp; |
| 55 |
unsigned int check_defaults; |
| 56 |
|
| 57 |
/* LDAP version 2 or 3 */ |
| 58 |
int version; |
| 59 |
|
| 60 |
/* LDAP lookup configuration */ |
| 61 |
struct ldap_schema *schema; |
| 62 |
|
| 63 |
/* |
| 64 |
* List of servers and base dns for searching. |
| 65 |
* uri is the list of servers to attempt connection to and is |
| 66 |
* used only if server, above, is NULL. The head of the list |
| 67 |
* is the server which we are currently connected to. |
| 68 |
* cur_host tracks chnages to connected server, triggering |
| 69 |
* a scan of basedns when it changes. |
| 70 |
* sdns is the list of basdns to check, done in the order |
| 71 |
* given in configuration. |
| 72 |
*/ |
| 73 |
pthread_mutex_t uris_mutex; |
| 74 |
struct list_head *uris; |
| 75 |
struct ldap_uri *uri; |
| 76 |
struct dclist *dclist; |
| 77 |
char *cur_host; |
| 78 |
struct ldap_searchdn *sdns; |
| 79 |
|
| 80 |
/* TLS and SASL authentication information */ |
| 81 |
char *auth_conf; |
| 82 |
unsigned use_tls; |
| 83 |
unsigned tls_required; |
| 84 |
unsigned auth_required; |
| 85 |
char *sasl_mech; |
| 86 |
char *user; |
| 87 |
char *secret; |
| 88 |
char *client_princ; |
| 89 |
char *client_cc; |
| 90 |
int kinit_successful; |
| 91 |
#ifdef WITH_SASL |
| 92 |
/* Kerberos */ |
| 93 |
krb5_context krb5ctxt; |
| 94 |
krb5_ccache krb5_ccache; |
| 95 |
/* SASL external */ |
| 96 |
char *extern_cert; |
| 97 |
char *extern_key; |
| 98 |
#endif |
| 99 |
/* keytab file name needs to be added */ |
| 100 |
|
| 101 |
struct parse_mod *parse; |
| 102 |
}; |
| 103 |
|
| 104 |
|
| 105 |
#define LDAP_AUTH_CONF_FILE "test" |
| 106 |
|
| 107 |
#define LDAP_TLS_DONT_USE 0 |
| 108 |
#define LDAP_TLS_REQUIRED 1 |
| 109 |
#define LDAP_TLS_INIT 1 |
| 110 |
#define LDAP_TLS_RELEASE 2 |
| 111 |
|
| 112 |
#define LDAP_AUTH_NOTREQUIRED 0x0001 |
| 113 |
#define LDAP_AUTH_REQUIRED 0x0002 |
| 114 |
#define LDAP_AUTH_AUTODETECT 0x0004 |
| 115 |
#define LDAP_NEED_AUTH (LDAP_AUTH_REQUIRED|LDAP_AUTH_AUTODETECT) |
| 116 |
|
| 117 |
#define LDAP_AUTH_USESIMPLE 0x0008 |
| 118 |
|
| 119 |
/* lookup_ldap.c */ |
| 120 |
LDAP *init_ldap_connection(unsigned logopt, const char *uri, struct lookup_context *ctxt); |
| 121 |
int unbind_ldap_connection(unsigned logopt, struct ldap_conn *conn, struct lookup_context *ctxt); |
| 122 |
int authtype_requires_creds(const char *authtype); |
| 123 |
|
| 124 |
#ifdef WITH_SASL |
| 125 |
/* cyrus-sasl.c */ |
| 126 |
int autofs_sasl_client_init(unsigned logopt); |
| 127 |
int autofs_sasl_init(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt); |
| 128 |
int autofs_sasl_bind(unsigned logopt, struct ldap_conn *conn, struct lookup_context *ctxt); |
| 129 |
void autofs_sasl_unbind(struct ldap_conn *conn, struct lookup_context *ctxt); |
| 130 |
void autofs_sasl_dispose(struct ldap_conn *conn, struct lookup_context *ctxt); |
| 131 |
void autofs_sasl_done(void); |
| 132 |
int sasl_do_kinit(unsigned logopt, struct lookup_context *ctxt); |
| 133 |
int sasl_do_kinit_ext_cc(unsigned logopt, struct lookup_context *ctxt); |
| 134 |
#ifdef WITH_LDAP_CYRUS_SASL |
| 135 |
void autofs_ldap_sasl_freedefs(void *defaults); |
| 136 |
void *autofs_ldap_sasl_defaults(LDAP *ld, char *mech, char *realm, char *authcid, char *passwd, char *authzid ); |
| 137 |
int autofs_ldap_sasl_interact(LDAP *ld, unsigned flags, void *defaults, void *in ); |
| 138 |
#endif |
| 139 |
/* cyrus-sasl-extern */ |
| 140 |
int do_sasl_extern(LDAP *ldap, struct lookup_context *ctxt); |
| 141 |
#endif |
| 142 |
|
| 143 |
#endif |