/* get the connection's fd */
ret = ldap_get_option(conn->ld, LDAP_OPT_DESC, (void *)&conn->fd);
if (ret != LDAP_SUCCESS) {
- i_fatal("LDAP: Can't get connection fd: %s", ldap_err2string(ret));
+ i_fatal("ldap(%s): Can't get connection fd: %s",
+ conn->set->uris, ldap_err2string(ret));
}
if (conn->fd <= STDERR_FILENO) {
/* Solaris LDAP library seems to be broken */
- i_fatal("LDAP: Buggy LDAP library returned wrong fd: %d", conn->fd);
+ i_fatal("ldap(%s): Buggy LDAP library returned wrong fd: %d",
+ conn->set->uris, conn->fd);
}
i_assert(conn->fd != -1);
net_set_nonblock(conn->fd, TRUE);
}
-static void ATTR_NULL(0)
-db_ldap_set_opt(LDAP *ld, int opt, const void *value, const char *optname,
- const char *value_str)
+static void ATTR_NULL(1)
+db_ldap_set_opt(struct ldap_connection *conn, LDAP *ld, int opt,
+ const void *value, const char *optname, const char *value_str)
{
int ret;
ret = ldap_set_option(ld, opt, value);
if (ret != LDAP_SUCCESS) {
- i_fatal("LDAP: Can't set option %s to %s: %s",
- optname, value_str, ldap_err2string(ret));
+ i_fatal("ldap(%s): Can't set option %s to %s: %s",
+ conn->set->uris, optname, value_str, ldap_err2string(ret));
}
}
-static void ATTR_NULL(0)
-db_ldap_set_opt_str(LDAP *ld, int opt, const char *value, const char *optname)
+static void ATTR_NULL(1)
+db_ldap_set_opt_str(struct ldap_connection *conn, LDAP *ld, int opt,
+ const char *value, const char *optname)
{
if (*value != '\0')
- db_ldap_set_opt(ld, opt, value, optname, value);
+ db_ldap_set_opt(conn, ld, opt, value, optname, value);
}
static void db_ldap_set_tls_options(struct ldap_connection *conn)
if (!conn->set->starttls && strstr(conn->set->uris, "ldaps:") == NULL)
return;
- db_ldap_set_opt_str(NULL, LDAP_OPT_X_TLS_CACERTFILE,
+ db_ldap_set_opt_str(conn, NULL, LDAP_OPT_X_TLS_CACERTFILE,
conn->ssl_set->ssl_client_ca_file, "ssl_client_ca_file");
- db_ldap_set_opt_str(NULL, LDAP_OPT_X_TLS_CACERTDIR,
+ db_ldap_set_opt_str(conn, NULL, LDAP_OPT_X_TLS_CACERTDIR,
conn->ssl_set->ssl_client_ca_dir, "ssl_client_ca_dir");
- db_ldap_set_opt_str(NULL, LDAP_OPT_X_TLS_CERTFILE,
+ db_ldap_set_opt_str(conn, NULL, LDAP_OPT_X_TLS_CERTFILE,
conn->ssl_set->ssl_client_cert_file, "ssl_client_cert_file");
- db_ldap_set_opt_str(NULL, LDAP_OPT_X_TLS_KEYFILE,
+ db_ldap_set_opt_str(conn, NULL, LDAP_OPT_X_TLS_KEYFILE,
conn->ssl_set->ssl_client_key_file, "ssl_client_key_file");
- db_ldap_set_opt_str(NULL, LDAP_OPT_X_TLS_CIPHER_SUITE,
+ db_ldap_set_opt_str(conn, NULL, LDAP_OPT_X_TLS_CIPHER_SUITE,
conn->ssl_set->ssl_cipher_list, "ssl_cipher_list");
- db_ldap_set_opt_str(NULL, LDAP_OPT_X_TLS_PROTOCOL_MIN,
+ db_ldap_set_opt_str(conn, NULL, LDAP_OPT_X_TLS_PROTOCOL_MIN,
conn->ssl_set->ssl_min_protocol, "ssl_min_protocol");
- db_ldap_set_opt_str(NULL, LDAP_OPT_X_TLS_ECNAME,
+ db_ldap_set_opt_str(conn, NULL, LDAP_OPT_X_TLS_ECNAME,
conn->ssl_set->ssl_curve_list, "ssl_curve_list");
bool requires = conn->ssl_set->ssl_client_require_valid_cert;
int opt = requires ? LDAP_OPT_X_TLS_HARD : LDAP_OPT_X_TLS_ALLOW;
- db_ldap_set_opt(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &opt,
+ db_ldap_set_opt(conn, NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &opt,
"ssl_client_require_valid_cert", requires ? "yes" : "no" );
#endif
}
tv.tv_sec = DB_LDAP_CONNECT_TIMEOUT_SECS; tv.tv_usec = 0;
ret = ldap_set_option(conn->ld, LDAP_OPT_NETWORK_TIMEOUT, &tv);
if (ret != LDAP_SUCCESS)
- i_fatal("LDAP: Can't set network-timeout: %s", ldap_err2string(ret));
+ i_fatal("ldap(%s): Can't set network-timeout: %s",
+ conn->set->uris, ldap_err2string(ret));
#endif
- db_ldap_set_opt(conn->ld, LDAP_OPT_DEREF, &conn->set->parsed_deref,
+ db_ldap_set_opt(conn, conn->ld, LDAP_OPT_DEREF, &conn->set->parsed_deref,
"ldap_deref", conn->set->deref);
#ifdef LDAP_OPT_DEBUG_LEVEL
int debug_level;
if (str_to_int(conn->set->debug_level, &debug_level) >= 0 && debug_level != 0) {
- db_ldap_set_opt(NULL, LDAP_OPT_DEBUG_LEVEL, &debug_level,
+ db_ldap_set_opt(conn, NULL, LDAP_OPT_DEBUG_LEVEL, &debug_level,
"ldap_debug_level", conn->set->debug_level);
event_set_forced_debug(conn->event, TRUE);
}
#endif
- db_ldap_set_opt(conn->ld, LDAP_OPT_PROTOCOL_VERSION,
+ db_ldap_set_opt(conn, conn->ld, LDAP_OPT_PROTOCOL_VERSION,
&conn->set->version,
"ldap_version", dec2str(conn->set->version));
db_ldap_set_tls_options(conn);
{
int ret = ldap_initialize(&conn->ld, conn->set->uris);
if (ret != LDAP_SUCCESS) {
- i_fatal("LDAP: ldap_initialize() failed with uris %s: %s",
+ i_fatal("ldap(%s): ldap_initialize() failed: %s",
conn->set->uris, ldap_err2string(ret));
}
db_ldap_set_options(conn);
if (ret == LDAP_OPERATIONS_ERROR &&
*conn->set->uris != '\0' &&
str_begins_with(conn->set->uris, "ldaps:")) {
- i_fatal("LDAP: Don't use both ldap_starttls=yes and ldaps URI");
+ i_fatal("ldap(%s): "
+ "Don't use both ldap_starttls=yes and ldaps URI",
+ conn->set->uris);
}
e_error(conn->event, "ldap_start_tls_s() failed: %s",
ldap_err2string(ret));
set = settings_get_or_fatal(event, &ldap_setting_parser_info);
ssl_set = settings_get_or_fatal(event, &ssl_setting_parser_info);
if (ldap_setting_post_check(set, &error) < 0)
- i_fatal("LDAP: %s", error);
+ i_fatal("ldap(%s): %s", set->uris, error);
/* see if it already exists */
struct ldap_connection *conn = db_ldap_conn_find(set, ssl_set);