1999-05-26 10:35:20 +08:00
|
|
|
/* config.c - ldap backend configuration file routine */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-27 14:35:14 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2006-01-04 07:11:52 +08:00
|
|
|
* Copyright 2003-2006 The OpenLDAP Foundation.
|
2003-12-09 01:41:40 +08:00
|
|
|
* Portions Copyright 1999-2003 Howard Chu.
|
|
|
|
* Portions Copyright 2000-2003 Pierangelo Masarati.
|
2003-11-27 14:35:14 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was initially developed by the Howard Chu for inclusion
|
|
|
|
* in OpenLDAP Software and subsequently enhanced by Pierangelo
|
|
|
|
* Masarati.
|
2001-01-17 15:09:22 +08:00
|
|
|
*/
|
1999-05-26 10:35:20 +08:00
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/string.h>
|
2005-05-23 15:25:00 +08:00
|
|
|
#include <ac/ctype.h>
|
1999-05-26 10:35:20 +08:00
|
|
|
#include <ac/socket.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
2005-05-22 03:07:14 +08:00
|
|
|
#include "config.h"
|
1999-05-26 10:35:20 +08:00
|
|
|
#include "back-ldap.h"
|
2002-08-06 10:36:34 +08:00
|
|
|
#include "lutil.h"
|
2005-05-22 03:07:14 +08:00
|
|
|
#include "ldif.h"
|
2004-07-26 16:31:01 +08:00
|
|
|
#undef ldap_debug
|
|
|
|
/* for advanced URL parsing */
|
|
|
|
#include "../../../libraries/libldap/ldap-int.h"
|
1999-05-26 10:35:20 +08:00
|
|
|
|
2003-02-16 19:21:15 +08:00
|
|
|
static SLAP_EXTOP_MAIN_FN ldap_back_exop_whoami;
|
|
|
|
|
2005-05-22 03:07:14 +08:00
|
|
|
static ConfigDriver ldap_back_cf_gen;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
LDAP_BACK_CFG_URI = 1,
|
|
|
|
LDAP_BACK_CFG_TLS,
|
|
|
|
LDAP_BACK_CFG_ACL_AUTHCDN,
|
|
|
|
LDAP_BACK_CFG_ACL_PASSWD,
|
|
|
|
LDAP_BACK_CFG_ACL_METHOD,
|
2005-05-23 15:25:00 +08:00
|
|
|
LDAP_BACK_CFG_ACL_BIND,
|
2005-05-22 03:07:14 +08:00
|
|
|
LDAP_BACK_CFG_IDASSERT_MODE,
|
|
|
|
LDAP_BACK_CFG_IDASSERT_AUTHCDN,
|
|
|
|
LDAP_BACK_CFG_IDASSERT_PASSWD,
|
|
|
|
LDAP_BACK_CFG_IDASSERT_AUTHZFROM,
|
|
|
|
LDAP_BACK_CFG_IDASSERT_METHOD,
|
2005-05-23 15:25:00 +08:00
|
|
|
LDAP_BACK_CFG_IDASSERT_BIND,
|
2005-05-22 03:07:14 +08:00
|
|
|
LDAP_BACK_CFG_REBIND,
|
|
|
|
LDAP_BACK_CFG_CHASE,
|
|
|
|
LDAP_BACK_CFG_T_F,
|
|
|
|
LDAP_BACK_CFG_WHOAMI,
|
2005-11-07 07:29:10 +08:00
|
|
|
LDAP_BACK_CFG_TIMEOUT,
|
2005-12-08 01:35:02 +08:00
|
|
|
LDAP_BACK_CFG_IDLE_TIMEOUT,
|
2006-02-02 07:10:12 +08:00
|
|
|
LDAP_BACK_CFG_CONN_TTL,
|
2005-11-20 02:01:28 +08:00
|
|
|
LDAP_BACK_CFG_REWRITE,
|
|
|
|
|
|
|
|
LDAP_BACK_CFG_LAST
|
2005-05-22 03:07:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigTable ldapcfg[] = {
|
|
|
|
{ "uri", "uri", 2, 2, 0,
|
2005-11-20 02:44:54 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_URI,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:0.14 "
|
|
|
|
"NAME 'olcDbURI' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'URI (list) for remote DSA' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
|
|
|
{ "tls", "what", 2, 2, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_TLS,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.1 "
|
|
|
|
"NAME 'olcDbStartTLS' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'StartTLS' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
|
|
|
{ "acl-authcDN", "DN", 2, 2, 0,
|
|
|
|
ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_ACL_AUTHCDN,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.2 "
|
|
|
|
"NAME 'olcDbACLAuthcDn' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Remote ACL administrative identity' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"OBSOLETE "
|
|
|
|
"SYNTAX OMsDN "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
2005-07-29 09:00:48 +08:00
|
|
|
/* deprecated, will be removed; aliases "acl-authcDN" */
|
2005-05-22 03:07:14 +08:00
|
|
|
{ "binddn", "DN", 2, 2, 0,
|
|
|
|
ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_ACL_AUTHCDN,
|
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
|
|
|
{ "acl-passwd", "cred", 2, 2, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_ACL_PASSWD,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.3 "
|
|
|
|
"NAME 'olcDbACLPasswd' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Remote ACL administrative identity credentials' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"OBSOLETE "
|
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
2005-07-29 09:00:48 +08:00
|
|
|
/* deprecated, will be removed; aliases "acl-passwd" */
|
2005-05-22 03:07:14 +08:00
|
|
|
{ "bindpw", "cred", 2, 2, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_ACL_PASSWD,
|
2005-05-22 03:07:14 +08:00
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
2005-07-29 09:00:48 +08:00
|
|
|
/* deprecated, will be removed; aliases "acl-bind" */
|
|
|
|
{ "acl-method", "args", 2, 0, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_ACL_METHOD,
|
2005-07-29 09:00:48 +08:00
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
2005-05-23 15:25:00 +08:00
|
|
|
{ "acl-bind", "args", 2, 0, 0,
|
2005-07-26 04:47:39 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_ACL_BIND,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.4 "
|
|
|
|
"NAME 'olcDbACLBind' "
|
|
|
|
"DESC 'Remote ACL administrative identity auth bind configuration' "
|
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
|
|
|
{ "idassert-authcDN", "DN", 2, 2, 0,
|
|
|
|
ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_AUTHCDN,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.5 "
|
|
|
|
"NAME 'olcDbIDAssertAuthcDn' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Remote Identity Assertion administrative identity' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"OBSOLETE "
|
|
|
|
"SYNTAX OMsDN "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
2005-07-29 09:00:48 +08:00
|
|
|
/* deprecated, will be removed; partially aliases "idassert-authcDN" */
|
2005-05-22 03:07:14 +08:00
|
|
|
{ "proxyauthzdn", "DN", 2, 2, 0,
|
|
|
|
ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_AUTHCDN,
|
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
|
|
|
{ "idassert-passwd", "cred", 2, 2, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_PASSWD,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.6 "
|
|
|
|
"NAME 'olcDbIDAssertPasswd' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Remote Identity Assertion administrative identity credentials' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"OBSOLETE "
|
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
2005-07-29 09:00:48 +08:00
|
|
|
/* deprecated, will be removed; partially aliases "idassert-passwd" */
|
2005-05-22 03:07:14 +08:00
|
|
|
{ "proxyauthzpw", "cred", 2, 2, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_PASSWD,
|
2005-05-22 03:07:14 +08:00
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
2005-05-23 15:25:00 +08:00
|
|
|
{ "idassert-bind", "args", 2, 0, 0,
|
2005-07-26 04:47:39 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_BIND,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.7 "
|
|
|
|
"NAME 'olcDbIDAssertBind' "
|
|
|
|
"DESC 'Remote Identity Assertion administrative identity auth bind configuration' "
|
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
2005-05-23 15:25:00 +08:00
|
|
|
{ "idassert-method", "args", 2, 0, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_METHOD,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
2005-05-22 03:07:14 +08:00
|
|
|
{ "idassert-mode", "mode>|u:<user>|[dn:]<DN", 2, 0, 0,
|
|
|
|
ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_MODE,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.8 "
|
|
|
|
"NAME 'olcDbIDAssertMode' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Remote Identity Assertion mode' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"OBSOLETE "
|
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE)",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
|
|
|
{ "idassert-authzFrom", "authzRule", 2, 2, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_AUTHZFROM,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.9 "
|
|
|
|
"NAME 'olcDbIDAssertAuthzFrom' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Remote Identity Assertion authz rules' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"X-ORDERED 'VALUES' )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
|
|
|
{ "rebind-as-user", "NO|yes", 1, 2, 0,
|
2005-11-20 01:48:33 +08:00
|
|
|
ARG_MAGIC|ARG_ON_OFF|LDAP_BACK_CFG_REBIND,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.10 "
|
|
|
|
"NAME 'olcDbRebindAsUser' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Rebind as user' "
|
2005-11-20 01:48:33 +08:00
|
|
|
"SYNTAX OMsBoolean "
|
2005-05-23 15:25:00 +08:00
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
|
|
|
{ "chase-referrals", "YES|no", 2, 2, 0,
|
2005-11-20 01:48:33 +08:00
|
|
|
ARG_MAGIC|ARG_ON_OFF|LDAP_BACK_CFG_CHASE,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.11 "
|
|
|
|
"NAME 'olcDbChaseReferrals' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Chase referrals' "
|
2005-11-20 01:48:33 +08:00
|
|
|
"SYNTAX OMsBoolean "
|
2005-05-23 15:25:00 +08:00
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
|
|
|
{ "t-f-support", "NO|yes|discover", 2, 2, 0,
|
2005-08-02 07:32:14 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_T_F,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.12 "
|
|
|
|
"NAME 'olcDbTFSupport' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Absolute filters support' "
|
2005-05-23 15:25:00 +08:00
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
|
|
|
{ "proxy-whoami", "NO|yes", 1, 2, 0,
|
2005-11-20 01:48:33 +08:00
|
|
|
ARG_MAGIC|ARG_ON_OFF|LDAP_BACK_CFG_WHOAMI,
|
2005-05-23 15:25:00 +08:00
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.13 "
|
|
|
|
"NAME 'olcDbProxyWhoAmI' "
|
2005-05-22 03:07:14 +08:00
|
|
|
"DESC 'Proxy whoAmI exop' "
|
2005-11-20 01:48:33 +08:00
|
|
|
"SYNTAX OMsBoolean "
|
2005-05-23 15:25:00 +08:00
|
|
|
"SINGLE-VALUE )",
|
2005-05-22 03:07:14 +08:00
|
|
|
NULL, NULL },
|
2005-11-20 07:23:18 +08:00
|
|
|
{ "timeout", "timeout(list)", 2, 0, 0,
|
2005-11-07 07:29:10 +08:00
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_TIMEOUT,
|
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.14 "
|
|
|
|
"NAME 'olcDbTimeout' "
|
|
|
|
"DESC 'Per-operation timeouts' "
|
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
|
|
|
NULL, NULL },
|
2005-12-08 01:35:02 +08:00
|
|
|
{ "idle-timeout", "timeout", 2, 0, 0,
|
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_IDLE_TIMEOUT,
|
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.15 "
|
|
|
|
"NAME 'olcDbIdleTimeout' "
|
|
|
|
"DESC 'connection idle timeout' "
|
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
|
|
|
NULL, NULL },
|
2006-02-02 07:10:12 +08:00
|
|
|
{ "conn-ttl", "ttl", 2, 0, 0,
|
|
|
|
ARG_MAGIC|LDAP_BACK_CFG_CONN_TTL,
|
|
|
|
ldap_back_cf_gen, "( OLcfgDbAt:3.16 "
|
|
|
|
"NAME 'olcDbConnTtl' "
|
|
|
|
"DESC 'connection ttl' "
|
|
|
|
"SYNTAX OMsDirectoryString "
|
|
|
|
"SINGLE-VALUE )",
|
|
|
|
NULL, NULL },
|
2005-05-22 03:07:14 +08:00
|
|
|
{ "suffixmassage", "[virtual]> <real", 2, 3, 0,
|
|
|
|
ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_REWRITE,
|
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
|
|
|
{ "map", "attribute|objectClass> [*|<local>] *|<remote", 3, 4, 0,
|
|
|
|
ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_REWRITE,
|
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
|
|
|
{ "rewrite", "<arglist>", 2, 4, STRLENOF( "rewrite" ),
|
|
|
|
ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_REWRITE,
|
|
|
|
ldap_back_cf_gen, NULL, NULL, NULL },
|
|
|
|
{ NULL, NULL, 0, 0, 0, ARG_IGNORED,
|
|
|
|
NULL, NULL, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigOCs ldapocs[] = {
|
|
|
|
{ "( OLcfgDbOc:3.1 "
|
|
|
|
"NAME 'olcLDAPConfig' "
|
|
|
|
"DESC 'LDAP backend configuration' "
|
|
|
|
"SUP olcDatabaseConfig "
|
|
|
|
"MUST olcDbURI "
|
|
|
|
"MAY ( olcDbStartTLS "
|
2005-05-23 15:25:00 +08:00
|
|
|
"$ olcDbACLAuthcDn "
|
|
|
|
"$ olcDbACLPasswd "
|
|
|
|
"$ olcDbACLBind "
|
2005-05-22 03:07:14 +08:00
|
|
|
"$ olcDbIDAssertAuthcDn "
|
|
|
|
"$ olcDbIDAssertPasswd "
|
2005-05-23 15:25:00 +08:00
|
|
|
"$ olcDbIDAssertBind "
|
2005-05-22 03:07:14 +08:00
|
|
|
"$ olcDbIDAssertMode "
|
|
|
|
"$ olcDbIDAssertAuthzFrom "
|
|
|
|
"$ olcDbRebindAsUser "
|
|
|
|
"$ olcDbChaseReferrals "
|
|
|
|
"$ olcDbTFSupport "
|
|
|
|
"$ olcDbProxyWhoAmI "
|
2005-11-07 07:29:10 +08:00
|
|
|
"$ olcDbTimeout "
|
2005-12-08 01:35:02 +08:00
|
|
|
"$ olcDbIdleTimeout "
|
2005-05-22 03:07:14 +08:00
|
|
|
") )",
|
|
|
|
Cft_Database, ldapcfg},
|
|
|
|
{ NULL, 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static slap_verbmasks idassert_mode[] = {
|
|
|
|
{ BER_BVC("self"), LDAP_BACK_IDASSERT_SELF },
|
|
|
|
{ BER_BVC("anonymous"), LDAP_BACK_IDASSERT_ANONYMOUS },
|
|
|
|
{ BER_BVC("none"), LDAP_BACK_IDASSERT_NOASSERT },
|
2005-05-23 15:25:00 +08:00
|
|
|
{ BER_BVC("legacy"), LDAP_BACK_IDASSERT_LEGACY },
|
2005-05-22 03:07:14 +08:00
|
|
|
{ BER_BVNULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static slap_verbmasks tls_mode[] = {
|
2005-05-23 22:14:34 +08:00
|
|
|
{ BER_BVC( "propagate" ), LDAP_BACK_F_TLS_PROPAGATE_MASK },
|
|
|
|
{ BER_BVC( "try-propagate" ), LDAP_BACK_F_PROPAGATE_TLS },
|
|
|
|
{ BER_BVC( "start" ), LDAP_BACK_F_TLS_USE_MASK },
|
|
|
|
{ BER_BVC( "try-start" ), LDAP_BACK_F_USE_TLS },
|
2005-11-20 01:48:33 +08:00
|
|
|
{ BER_BVC( "none" ), LDAP_BACK_F_NONE },
|
2005-05-22 03:07:14 +08:00
|
|
|
{ BER_BVNULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static slap_verbmasks t_f_mode[] = {
|
2005-05-23 22:14:34 +08:00
|
|
|
{ BER_BVC( "yes" ), LDAP_BACK_F_SUPPORT_T_F },
|
|
|
|
{ BER_BVC( "discover" ), LDAP_BACK_F_SUPPORT_T_F_DISCOVER },
|
2005-11-20 01:48:33 +08:00
|
|
|
{ BER_BVC( "no" ), LDAP_BACK_F_NONE },
|
2005-05-22 03:07:14 +08:00
|
|
|
{ BER_BVNULL, 0 }
|
|
|
|
};
|
|
|
|
|
2005-11-07 07:29:10 +08:00
|
|
|
static slap_cf_aux_table timeout_table[] = {
|
|
|
|
{ BER_BVC("add="), 0 * sizeof( time_t ), 'u', 0, NULL },
|
|
|
|
{ BER_BVC("delete="), 1 * sizeof( time_t ), 'u', 0, NULL },
|
|
|
|
{ BER_BVC("modify="), 2 * sizeof( time_t ), 'u', 0, NULL },
|
|
|
|
{ BER_BVC("modrdn="), 3 * sizeof( time_t ), 'u', 0, NULL },
|
|
|
|
{ BER_BVNULL, 0, 0, 0, NULL }
|
|
|
|
};
|
|
|
|
|
2005-05-22 03:07:14 +08:00
|
|
|
static int
|
|
|
|
ldap_back_cf_gen( ConfigArgs *c )
|
|
|
|
{
|
2005-11-19 23:00:50 +08:00
|
|
|
ldapinfo_t *li = ( ldapinfo_t * )c->be->be_private;
|
2005-05-22 03:07:14 +08:00
|
|
|
int rc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ( c->op == SLAP_CONFIG_EMIT ) {
|
2005-05-23 22:14:34 +08:00
|
|
|
struct berval bv = BER_BVNULL;
|
2005-05-22 03:07:14 +08:00
|
|
|
rc = 0;
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2006-03-25 06:49:51 +08:00
|
|
|
if ( li == NULL ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-05-22 03:07:14 +08:00
|
|
|
switch( c->type ) {
|
|
|
|
case LDAP_BACK_CFG_URI:
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_uri != NULL ) {
|
2005-11-20 02:44:54 +08:00
|
|
|
struct berval bv;
|
|
|
|
|
|
|
|
ber_str2bv( li->li_uri, 0, 0, &bv );
|
|
|
|
value_add_one( &c->rvalue_vals, &bv );
|
2005-05-22 03:07:14 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
rc = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-05-23 22:14:34 +08:00
|
|
|
case LDAP_BACK_CFG_TLS:
|
2005-11-19 23:00:50 +08:00
|
|
|
enum_to_verb( tls_mode, ( li->li_flags & LDAP_BACK_F_TLS_MASK ), &bv );
|
2005-12-08 01:35:02 +08:00
|
|
|
assert( !BER_BVISNULL( &bv ) );
|
|
|
|
value_add_one( &c->rvalue_vals, &bv );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_ACL_AUTHCDN:
|
|
|
|
case LDAP_BACK_CFG_ACL_PASSWD:
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_ACL_METHOD:
|
|
|
|
/* handled by LDAP_BACK_CFG_ACL_BIND */
|
2005-05-22 03:07:14 +08:00
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_ACL_BIND: {
|
2005-05-22 03:07:14 +08:00
|
|
|
int i;
|
|
|
|
|
2005-12-08 01:35:02 +08:00
|
|
|
if ( li->li_acl_authmethod == LDAP_AUTH_NONE ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
bindconf_unparse( &li->li_acl, &bv );
|
2005-05-22 03:07:14 +08:00
|
|
|
|
2006-04-02 07:44:42 +08:00
|
|
|
for ( i = 0; isspace( (unsigned char) bv.bv_val[ i ] ); i++ )
|
2005-05-22 03:07:14 +08:00
|
|
|
/* count spaces */ ;
|
|
|
|
|
|
|
|
if ( i ) {
|
2005-07-22 11:23:58 +08:00
|
|
|
bv.bv_len -= i;
|
|
|
|
AC_MEMCPY( bv.bv_val, &bv.bv_val[ i ],
|
|
|
|
bv.bv_len + 1 );
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
2005-07-22 11:23:58 +08:00
|
|
|
|
2005-07-26 08:11:11 +08:00
|
|
|
ber_bvarray_add( &c->rvalue_vals, &bv );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_MODE:
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_AUTHCDN:
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_PASSWD:
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_IDASSERT_METHOD:
|
|
|
|
/* handled by LDAP_BACK_CFG_IDASSERT_BIND */
|
2005-05-22 03:07:14 +08:00
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_AUTHZFROM: {
|
|
|
|
int i;
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_idassert_authz == NULL ) {
|
2005-05-22 03:07:14 +08:00
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
for ( i = 0; !BER_BVISNULL( &li->li_idassert_authz[ i ] ); i++ )
|
2005-05-22 03:07:14 +08:00
|
|
|
{
|
2005-11-19 23:00:50 +08:00
|
|
|
value_add_one( &c->rvalue_vals, &li->li_idassert_authz[ i ] );
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_IDASSERT_BIND: {
|
|
|
|
int i;
|
2005-07-22 11:23:58 +08:00
|
|
|
struct berval bc = BER_BVNULL;
|
2005-05-23 22:14:34 +08:00
|
|
|
char *ptr;
|
2005-05-23 15:25:00 +08:00
|
|
|
|
2005-12-08 01:35:02 +08:00
|
|
|
if ( li->li_idassert_authmethod == LDAP_AUTH_NONE ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_idassert_authmethod != LDAP_AUTH_NONE ) {
|
2005-07-22 10:29:49 +08:00
|
|
|
ber_len_t len;
|
2005-07-04 07:27:56 +08:00
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
switch ( li->li_idassert_mode ) {
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_IDASSERT_OTHERID:
|
|
|
|
case LDAP_BACK_IDASSERT_OTHERDN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: {
|
2005-05-23 22:14:34 +08:00
|
|
|
struct berval mode = BER_BVNULL;
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
enum_to_verb( idassert_mode, li->li_idassert_mode, &mode );
|
2005-05-23 22:14:34 +08:00
|
|
|
if ( BER_BVISNULL( &mode ) ) {
|
2005-05-23 15:25:00 +08:00
|
|
|
/* there's something wrong... */
|
|
|
|
assert( 0 );
|
|
|
|
rc = 1;
|
|
|
|
|
|
|
|
} else {
|
2005-05-23 22:14:34 +08:00
|
|
|
bv.bv_len = STRLENOF( "mode=" ) + mode.bv_len;
|
|
|
|
bv.bv_val = ch_malloc( bv.bv_len + 1 );
|
|
|
|
|
|
|
|
ptr = lutil_strcopy( bv.bv_val, "mode=" );
|
|
|
|
ptr = lutil_strcopy( ptr, mode.bv_val );
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_idassert_flags & LDAP_BACK_AUTH_NATIVE_AUTHZ ) {
|
2005-07-22 10:29:49 +08:00
|
|
|
len = bv.bv_len + STRLENOF( "authz=native" );
|
2005-05-23 22:14:34 +08:00
|
|
|
|
|
|
|
if ( !BER_BVISEMPTY( &bv ) ) {
|
|
|
|
len += STRLENOF( " " );
|
|
|
|
}
|
|
|
|
|
|
|
|
bv.bv_val = ch_realloc( bv.bv_val, len + 1 );
|
|
|
|
|
2005-07-22 10:29:49 +08:00
|
|
|
ptr = &bv.bv_val[ bv.bv_len ];
|
2005-05-23 22:14:34 +08:00
|
|
|
|
|
|
|
if ( !BER_BVISEMPTY( &bv ) ) {
|
|
|
|
ptr = lutil_strcopy( ptr, " " );
|
|
|
|
}
|
|
|
|
|
|
|
|
(void)lutil_strcopy( ptr, "authz=native" );
|
|
|
|
}
|
|
|
|
|
2005-07-22 10:29:49 +08:00
|
|
|
len = bv.bv_len + STRLENOF( "flags=non-prescriptive,override" );
|
2005-07-04 07:27:56 +08:00
|
|
|
/* flags */
|
|
|
|
if ( !BER_BVISEMPTY( &bv ) ) {
|
|
|
|
len += STRLENOF( " " );
|
|
|
|
}
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2005-07-04 07:27:56 +08:00
|
|
|
bv.bv_val = ch_realloc( bv.bv_val, len + 1 );
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2005-07-04 07:27:56 +08:00
|
|
|
ptr = &bv.bv_val[ bv.bv_len ];
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2005-07-04 07:27:56 +08:00
|
|
|
if ( !BER_BVISEMPTY( &bv ) ) {
|
|
|
|
ptr = lutil_strcopy( ptr, " " );
|
|
|
|
}
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2005-07-04 07:27:56 +08:00
|
|
|
ptr = lutil_strcopy( ptr, "flags=" );
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_idassert_flags & LDAP_BACK_AUTH_PRESCRIPTIVE ) {
|
2005-07-04 07:27:56 +08:00
|
|
|
ptr = lutil_strcopy( ptr, "prescriptive" );
|
|
|
|
} else {
|
|
|
|
ptr = lutil_strcopy( ptr, "non-prescriptive" );
|
2005-05-23 22:14:34 +08:00
|
|
|
}
|
2005-05-22 03:07:14 +08:00
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_idassert_flags & LDAP_BACK_AUTH_OVERRIDE ) {
|
2005-07-04 07:27:56 +08:00
|
|
|
ptr = lutil_strcopy( ptr, ",override" );
|
|
|
|
}
|
2005-05-22 03:07:14 +08:00
|
|
|
|
2005-07-04 07:27:56 +08:00
|
|
|
bv.bv_len = ( ptr - bv.bv_val );
|
|
|
|
/* end-of-flags */
|
|
|
|
}
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
bindconf_unparse( &li->li_idassert, &bc );
|
2005-05-23 22:14:34 +08:00
|
|
|
|
|
|
|
if ( !BER_BVISNULL( &bv ) ) {
|
2005-07-22 11:23:58 +08:00
|
|
|
ber_len_t len = bv.bv_len + bc.bv_len;
|
|
|
|
|
2005-07-26 08:11:11 +08:00
|
|
|
bv.bv_val = ch_realloc( bv.bv_val, len + 1 );
|
2005-05-23 15:25:00 +08:00
|
|
|
|
2005-05-23 22:14:34 +08:00
|
|
|
assert( bc.bv_val[ 0 ] == ' ' );
|
2005-05-23 15:25:00 +08:00
|
|
|
|
2005-07-26 08:11:11 +08:00
|
|
|
ptr = lutil_strcopy( &bv.bv_val[ bv.bv_len ], bc.bv_val );
|
2005-05-23 22:14:34 +08:00
|
|
|
free( bc.bv_val );
|
2005-07-26 08:11:11 +08:00
|
|
|
bv.bv_len = ptr - bv.bv_val;
|
2005-05-23 15:25:00 +08:00
|
|
|
|
|
|
|
} else {
|
2006-04-02 07:44:42 +08:00
|
|
|
for ( i = 0; isspace( (unsigned char) bc.bv_val[ i ] ); i++ )
|
2005-05-23 15:25:00 +08:00
|
|
|
/* count spaces */ ;
|
|
|
|
|
|
|
|
if ( i ) {
|
2005-05-23 22:14:34 +08:00
|
|
|
bc.bv_len -= i;
|
|
|
|
AC_MEMCPY( bc.bv_val, &bc.bv_val[ i ], bc.bv_len + 1 );
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
|
|
|
|
2005-07-26 08:11:11 +08:00
|
|
|
bv = bc;
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
|
|
|
|
2005-07-26 08:11:11 +08:00
|
|
|
ber_bvarray_add( &c->rvalue_vals, &bv );
|
|
|
|
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-23 22:14:34 +08:00
|
|
|
case LDAP_BACK_CFG_REBIND:
|
2005-11-20 01:48:33 +08:00
|
|
|
c->value_int = LDAP_BACK_SAVECRED( li );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
2005-05-23 22:14:34 +08:00
|
|
|
case LDAP_BACK_CFG_CHASE:
|
2005-11-20 01:48:33 +08:00
|
|
|
c->value_int = LDAP_BACK_CHASE_REFERRALS( li );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
2005-05-23 22:14:34 +08:00
|
|
|
case LDAP_BACK_CFG_T_F:
|
2005-11-20 01:48:33 +08:00
|
|
|
enum_to_verb( t_f_mode, (li->li_flags & LDAP_BACK_F_SUPPORT_T_F_MASK), &bv );
|
2005-05-23 22:14:34 +08:00
|
|
|
if ( BER_BVISNULL( &bv ) ) {
|
2005-05-22 03:07:14 +08:00
|
|
|
/* there's something wrong... */
|
|
|
|
assert( 0 );
|
|
|
|
rc = 1;
|
|
|
|
|
|
|
|
} else {
|
2005-08-02 07:32:14 +08:00
|
|
|
value_add_one( &c->rvalue_vals, &bv );
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-05-23 22:14:34 +08:00
|
|
|
case LDAP_BACK_CFG_WHOAMI:
|
2005-11-20 01:48:33 +08:00
|
|
|
c->value_int = LDAP_BACK_PROXY_WHOAMI( li );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
2005-11-07 07:29:10 +08:00
|
|
|
case LDAP_BACK_CFG_TIMEOUT:
|
|
|
|
BER_BVZERO( &bv );
|
|
|
|
|
2005-12-08 01:35:02 +08:00
|
|
|
for ( i = 0; i < LDAP_BACK_OP_LAST; i++ ) {
|
|
|
|
if ( li->li_timeout[ i ] != 0 ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( i == LDAP_BACK_OP_LAST ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
slap_cf_aux_table_unparse( li->li_timeout, &bv, timeout_table );
|
2005-11-07 07:29:10 +08:00
|
|
|
|
2005-12-08 01:35:02 +08:00
|
|
|
if ( BER_BVISNULL( &bv ) ) {
|
|
|
|
return 1;
|
|
|
|
}
|
2005-11-07 07:29:10 +08:00
|
|
|
|
2006-04-02 07:44:42 +08:00
|
|
|
for ( i = 0; isspace( (unsigned char) bv.bv_val[ i ] ); i++ )
|
2005-12-08 01:35:02 +08:00
|
|
|
/* count spaces */ ;
|
2005-11-07 07:29:10 +08:00
|
|
|
|
2005-12-08 01:35:02 +08:00
|
|
|
if ( i ) {
|
|
|
|
bv.bv_len -= i;
|
|
|
|
AC_MEMCPY( bv.bv_val, &bv.bv_val[ i ],
|
|
|
|
bv.bv_len + 1 );
|
2005-11-07 07:29:10 +08:00
|
|
|
}
|
2005-12-08 01:35:02 +08:00
|
|
|
|
|
|
|
ber_bvarray_add( &c->rvalue_vals, &bv );
|
2005-11-07 07:29:10 +08:00
|
|
|
break;
|
|
|
|
|
2005-12-08 01:35:02 +08:00
|
|
|
case LDAP_BACK_CFG_IDLE_TIMEOUT: {
|
|
|
|
char buf[ SLAP_TEXT_BUFLEN ];
|
|
|
|
|
|
|
|
if ( li->li_idle_timeout == 0 ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
lutil_unparse_time( buf, sizeof( buf ), li->li_idle_timeout );
|
|
|
|
ber_str2bv( buf, 0, 0, &bv );
|
|
|
|
value_add_one( &c->rvalue_vals, &bv );
|
|
|
|
} break;
|
|
|
|
|
2006-02-02 07:10:12 +08:00
|
|
|
case LDAP_BACK_CFG_CONN_TTL: {
|
|
|
|
char buf[ SLAP_TEXT_BUFLEN ];
|
|
|
|
|
|
|
|
if ( li->li_conn_ttl == 0 ) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
lutil_unparse_time( buf, sizeof( buf ), li->li_conn_ttl );
|
|
|
|
ber_str2bv( buf, 0, 0, &bv );
|
|
|
|
value_add_one( &c->rvalue_vals, &bv );
|
|
|
|
} break;
|
|
|
|
|
2005-05-22 03:07:14 +08:00
|
|
|
default:
|
2005-07-29 09:00:48 +08:00
|
|
|
/* FIXME: we need to handle all... */
|
2005-05-22 03:07:14 +08:00
|
|
|
assert( 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
2005-05-23 15:25:00 +08:00
|
|
|
|
|
|
|
} else if ( c->op == LDAP_MOD_DELETE ) {
|
|
|
|
rc = 0;
|
|
|
|
switch( c->type ) {
|
|
|
|
case LDAP_BACK_CFG_URI:
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_uri != NULL ) {
|
|
|
|
ch_free( li->li_uri );
|
|
|
|
li->li_uri = NULL;
|
2005-05-23 15:25:00 +08:00
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
assert( li->li_bvuri != NULL );
|
|
|
|
ber_bvarray_free( li->li_bvuri );
|
|
|
|
li->li_bvuri = NULL;
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
|
2005-05-25 19:54:19 +08:00
|
|
|
/* better cleanup the cached connections... */
|
|
|
|
/* NOTE: don't worry about locking: if we got here,
|
|
|
|
* other threads are suspended. */
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_conninfo.lai_tree != NULL ) {
|
|
|
|
avl_free( li->li_conninfo.lai_tree, ldap_back_conn_free );
|
|
|
|
li->li_conninfo.lai_tree = NULL;
|
|
|
|
}
|
2005-05-25 19:54:19 +08:00
|
|
|
|
2005-05-23 15:25:00 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_TLS:
|
2005-08-02 07:32:14 +08:00
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_ACL_AUTHCDN:
|
|
|
|
case LDAP_BACK_CFG_ACL_PASSWD:
|
|
|
|
case LDAP_BACK_CFG_ACL_METHOD:
|
|
|
|
/* handled by LDAP_BACK_CFG_ACL_BIND */
|
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_ACL_BIND:
|
2005-11-19 23:00:50 +08:00
|
|
|
bindconf_free( &li->li_acl );
|
2005-05-23 15:25:00 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_MODE:
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_AUTHCDN:
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_PASSWD:
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_METHOD:
|
|
|
|
/* handled by LDAP_BACK_CFG_IDASSERT_BIND */
|
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_AUTHZFROM:
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_idassert_authz != NULL ) {
|
|
|
|
ber_bvarray_free( li->li_idassert_authz );
|
|
|
|
li->li_idassert_authz = NULL;
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_BIND:
|
2005-11-19 23:00:50 +08:00
|
|
|
bindconf_free( &li->li_idassert );
|
2005-05-23 15:25:00 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_REBIND:
|
|
|
|
case LDAP_BACK_CFG_CHASE:
|
|
|
|
case LDAP_BACK_CFG_T_F:
|
|
|
|
case LDAP_BACK_CFG_WHOAMI:
|
|
|
|
rc = 1;
|
|
|
|
break;
|
|
|
|
|
2005-11-07 07:29:10 +08:00
|
|
|
case LDAP_BACK_CFG_TIMEOUT:
|
|
|
|
for ( i = 0; i < LDAP_BACK_OP_LAST; i++ ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_timeout[ i ] = 0;
|
2005-11-07 07:29:10 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-12-08 01:35:02 +08:00
|
|
|
case LDAP_BACK_CFG_IDLE_TIMEOUT:
|
|
|
|
li->li_idle_timeout = 0;
|
|
|
|
break;
|
|
|
|
|
2006-02-02 07:10:12 +08:00
|
|
|
case LDAP_BACK_CFG_CONN_TTL:
|
|
|
|
li->li_conn_ttl = 0;
|
|
|
|
break;
|
|
|
|
|
2005-05-23 15:25:00 +08:00
|
|
|
default:
|
2005-07-29 09:00:48 +08:00
|
|
|
/* FIXME: we need to handle all... */
|
2005-05-23 15:25:00 +08:00
|
|
|
assert( 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch( c->type ) {
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_URI: {
|
2005-11-19 23:00:50 +08:00
|
|
|
LDAPURLDesc *tmpludp, *lud;
|
|
|
|
char **urllist = NULL;
|
|
|
|
int urlrc = LDAP_URL_SUCCESS, i;
|
2005-05-23 15:25:00 +08:00
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_uri != NULL ) {
|
|
|
|
ch_free( li->li_uri );
|
|
|
|
li->li_uri = NULL;
|
2005-05-23 15:25:00 +08:00
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
assert( li->li_bvuri != NULL );
|
|
|
|
ber_bvarray_free( li->li_bvuri );
|
|
|
|
li->li_bvuri = NULL;
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PARANOID: DN and more are not required nor allowed */
|
2005-11-20 02:44:54 +08:00
|
|
|
urlrc = ldap_url_parselist_ext( &lud, c->argv[ 1 ], ", \t" );
|
2005-05-23 15:25:00 +08:00
|
|
|
if ( urlrc != LDAP_URL_SUCCESS ) {
|
|
|
|
char *why;
|
|
|
|
|
|
|
|
switch ( urlrc ) {
|
|
|
|
case LDAP_URL_ERR_MEM:
|
|
|
|
why = "no memory";
|
|
|
|
break;
|
|
|
|
case LDAP_URL_ERR_PARAM:
|
|
|
|
why = "parameter is bad";
|
|
|
|
break;
|
|
|
|
case LDAP_URL_ERR_BADSCHEME:
|
|
|
|
why = "URL doesn't begin with \"[c]ldap[si]://\"";
|
|
|
|
break;
|
|
|
|
case LDAP_URL_ERR_BADENCLOSURE:
|
|
|
|
why = "URL is missing trailing \">\"";
|
|
|
|
break;
|
|
|
|
case LDAP_URL_ERR_BADURL:
|
|
|
|
why = "URL is bad";
|
2005-11-19 23:00:50 +08:00
|
|
|
break;
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_URL_ERR_BADHOST:
|
|
|
|
why = "host/port is bad";
|
|
|
|
break;
|
|
|
|
case LDAP_URL_ERR_BADATTRS:
|
|
|
|
why = "bad (or missing) attributes";
|
|
|
|
break;
|
|
|
|
case LDAP_URL_ERR_BADSCOPE:
|
|
|
|
why = "scope string is invalid (or missing)";
|
|
|
|
break;
|
|
|
|
case LDAP_URL_ERR_BADFILTER:
|
|
|
|
why = "bad or missing filter";
|
|
|
|
break;
|
|
|
|
case LDAP_URL_ERR_BADEXTS:
|
|
|
|
why = "bad or missing extensions";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
why = "unknown reason";
|
|
|
|
break;
|
|
|
|
}
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg),
|
2005-05-23 15:25:00 +08:00
|
|
|
"unable to parse uri \"%s\" "
|
2005-12-08 01:35:02 +08:00
|
|
|
"in \"uri <uri>\" line: %s",
|
|
|
|
c->value_string, why );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-11-19 23:00:50 +08:00
|
|
|
urlrc = 1;
|
|
|
|
goto done_url;
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
for ( i = 0, tmpludp = lud;
|
2005-05-23 15:25:00 +08:00
|
|
|
tmpludp;
|
|
|
|
i++, tmpludp = tmpludp->lud_next )
|
|
|
|
{
|
|
|
|
if ( ( tmpludp->lud_dn != NULL
|
|
|
|
&& tmpludp->lud_dn[0] != '\0' )
|
|
|
|
|| tmpludp->lud_attrs != NULL
|
|
|
|
/* || tmpludp->lud_scope != LDAP_SCOPE_DEFAULT */
|
|
|
|
|| tmpludp->lud_filter != NULL
|
|
|
|
|| tmpludp->lud_exts != NULL )
|
|
|
|
{
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 15:25:00 +08:00
|
|
|
"warning, only protocol, "
|
|
|
|
"host and port allowed "
|
|
|
|
"in \"uri <uri>\" statement "
|
2005-12-08 01:35:02 +08:00
|
|
|
"for uri #%d of \"%s\"",
|
|
|
|
i, c->value_string );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
for ( i = 0, tmpludp = lud;
|
2005-05-23 15:25:00 +08:00
|
|
|
tmpludp;
|
|
|
|
i++, tmpludp = tmpludp->lud_next )
|
|
|
|
/* just count */
|
2005-07-22 21:21:10 +08:00
|
|
|
;
|
2005-05-23 15:25:00 +08:00
|
|
|
urllist = ch_calloc( sizeof( char * ), i + 1 );
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
for ( i = 0, tmpludp = lud;
|
2005-05-23 15:25:00 +08:00
|
|
|
tmpludp;
|
|
|
|
i++, tmpludp = tmpludp->lud_next )
|
|
|
|
{
|
|
|
|
LDAPURLDesc tmplud;
|
|
|
|
|
|
|
|
tmplud = *tmpludp;
|
|
|
|
tmplud.lud_dn = "";
|
|
|
|
tmplud.lud_attrs = NULL;
|
|
|
|
tmplud.lud_filter = NULL;
|
|
|
|
if ( !ldap_is_ldapi_url( tmplud.lud_scheme ) ) {
|
|
|
|
tmplud.lud_exts = NULL;
|
|
|
|
tmplud.lud_crit_exts = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
urllist[ i ] = ldap_url_desc2str( &tmplud );
|
|
|
|
|
|
|
|
if ( urllist[ i ] == NULL ) {
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg),
|
2005-05-23 15:25:00 +08:00
|
|
|
"unable to rebuild uri "
|
|
|
|
"in \"uri <uri>\" statement "
|
2005-12-08 01:35:02 +08:00
|
|
|
"for \"%s\"",
|
|
|
|
c->argv[ 1 ] );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-11-19 23:00:50 +08:00
|
|
|
urlrc = 1;
|
|
|
|
goto done_url;
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_uri = ldap_charray2str( urllist, " " );
|
|
|
|
for ( i = 0; urllist[ i ] != NULL; i++ ) {
|
|
|
|
struct berval bv;
|
|
|
|
|
|
|
|
ber_str2bv( urllist[ i ], 0, 0, &bv );
|
|
|
|
ber_bvarray_add( &li->li_bvuri, &bv );
|
|
|
|
urllist[ i ] = NULL;
|
|
|
|
}
|
|
|
|
ldap_memfree( urllist );
|
|
|
|
urllist = NULL;
|
|
|
|
|
|
|
|
done_url:;
|
|
|
|
if ( urllist ) {
|
|
|
|
ldap_charray_free( urllist );
|
|
|
|
}
|
|
|
|
if ( lud ) {
|
|
|
|
ldap_free_urllist( lud );
|
|
|
|
}
|
|
|
|
if ( urlrc != LDAP_URL_SUCCESS ) {
|
|
|
|
return 1;
|
|
|
|
}
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
2005-05-23 15:25:00 +08:00
|
|
|
}
|
2005-05-22 03:07:14 +08:00
|
|
|
|
|
|
|
case LDAP_BACK_CFG_TLS:
|
|
|
|
i = verb_to_mask( c->argv[1], tls_mode );
|
|
|
|
if ( BER_BVISNULL( &tls_mode[i].word ) ) {
|
|
|
|
return 1;
|
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_flags &= ~LDAP_BACK_F_TLS_MASK;
|
|
|
|
li->li_flags |= tls_mode[i].mask;
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_ACL_AUTHCDN:
|
2005-11-19 23:00:50 +08:00
|
|
|
switch ( li->li_acl_authmethod ) {
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_AUTH_NONE:
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_acl_authmethod = LDAP_AUTH_SIMPLE;
|
2005-05-23 15:25:00 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_AUTH_SIMPLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg),
|
2005-05-23 15:25:00 +08:00
|
|
|
"\"acl-authcDN <DN>\" incompatible "
|
2005-12-08 01:35:02 +08:00
|
|
|
"with auth method %d",
|
|
|
|
li->li_acl_authmethod );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 15:25:00 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( !BER_BVISNULL( &li->li_acl_authcDN ) ) {
|
|
|
|
free( li->li_acl_authcDN.bv_val );
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
2005-08-07 20:55:15 +08:00
|
|
|
ber_memfree_x( c->value_dn.bv_val, NULL );
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_acl_authcDN = c->value_ndn;
|
2005-08-07 20:55:15 +08:00
|
|
|
BER_BVZERO( &c->value_dn );
|
|
|
|
BER_BVZERO( &c->value_ndn );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_ACL_PASSWD:
|
2005-11-19 23:00:50 +08:00
|
|
|
switch ( li->li_acl_authmethod ) {
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_AUTH_NONE:
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_acl_authmethod = LDAP_AUTH_SIMPLE;
|
2005-05-23 15:25:00 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_AUTH_SIMPLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 15:25:00 +08:00
|
|
|
"\"acl-passwd <cred>\" incompatible "
|
2005-12-08 01:35:02 +08:00
|
|
|
"with auth method %d",
|
|
|
|
li->li_acl_authmethod );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 15:25:00 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( !BER_BVISNULL( &li->li_acl_passwd ) ) {
|
|
|
|
free( li->li_acl_passwd.bv_val );
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
ber_str2bv( c->argv[ 1 ], 0, 1, &li->li_acl_passwd );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_ACL_METHOD:
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_ACL_BIND:
|
2005-05-22 03:07:14 +08:00
|
|
|
for ( i = 1; i < c->argc; i++ ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( bindconf_parse( c->argv[ i ], &li->li_acl ) ) {
|
2005-05-22 03:07:14 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_MODE:
|
|
|
|
i = verb_to_mask( c->argv[1], idassert_mode );
|
|
|
|
if ( BER_BVISNULL( &idassert_mode[i].word ) ) {
|
|
|
|
if ( strncasecmp( c->argv[1], "u:", STRLENOF( "u:" ) ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_mode = LDAP_BACK_IDASSERT_OTHERID;
|
|
|
|
ber_str2bv( c->argv[1], 0, 1, &li->li_idassert_authzID );
|
|
|
|
li->li_idassert_authzID.bv_val[ 0 ] = 'u';
|
2005-05-22 03:07:14 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
struct berval id, ndn;
|
|
|
|
|
|
|
|
ber_str2bv( c->argv[1], 0, 0, &id );
|
|
|
|
|
|
|
|
if ( strncasecmp( c->argv[1], "dn:", STRLENOF( "dn:" ) ) == 0 ) {
|
|
|
|
id.bv_val += STRLENOF( "dn:" );
|
|
|
|
id.bv_len -= STRLENOF( "dn:" );
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = dnNormalize( 0, NULL, NULL, &id, &ndn, NULL );
|
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"%s: line %d: idassert ID \"%s\" is not a valid DN\n",
|
|
|
|
c->fname, c->lineno, c->argv[1] );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_authzID.bv_len = STRLENOF( "dn:" ) + ndn.bv_len;
|
|
|
|
li->li_idassert_authzID.bv_val = ch_malloc( li->li_idassert_authzID.bv_len + 1 );
|
|
|
|
AC_MEMCPY( li->li_idassert_authzID.bv_val, "dn:", STRLENOF( "dn:" ) );
|
|
|
|
AC_MEMCPY( &li->li_idassert_authzID.bv_val[ STRLENOF( "dn:" ) ], ndn.bv_val, ndn.bv_len + 1 );
|
2005-05-22 03:07:14 +08:00
|
|
|
ch_free( ndn.bv_val );
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_mode = LDAP_BACK_IDASSERT_OTHERDN;
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_mode = idassert_mode[i].mask;
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( c->argc > 2 ) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for ( i = 2; i < c->argc; i++ ) {
|
|
|
|
if ( strcasecmp( c->argv[ i ], "override" ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_flags |= LDAP_BACK_AUTH_OVERRIDE;
|
2005-05-22 03:07:14 +08:00
|
|
|
|
2005-07-04 07:27:56 +08:00
|
|
|
} else if ( strcasecmp( c->argv[ i ], "prescriptive" ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_flags |= LDAP_BACK_AUTH_PRESCRIPTIVE;
|
2005-07-04 07:27:56 +08:00
|
|
|
|
|
|
|
} else if ( strcasecmp( c->argv[ i ], "non-prescriptive" ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_flags &= ( ~LDAP_BACK_AUTH_PRESCRIPTIVE );
|
2005-07-04 07:27:56 +08:00
|
|
|
|
2005-05-22 03:07:14 +08:00
|
|
|
} else {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"%s: line %d: unknown flag #%d "
|
|
|
|
"in \"idassert-mode <args> "
|
|
|
|
"[<flags>]\" line.\n",
|
|
|
|
c->fname, c->lineno, i - 2 );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_AUTHCDN:
|
2005-11-19 23:00:50 +08:00
|
|
|
switch ( li->li_idassert_authmethod ) {
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_AUTH_NONE:
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_authmethod = LDAP_AUTH_SIMPLE;
|
2005-05-23 15:25:00 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_AUTH_SIMPLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 15:25:00 +08:00
|
|
|
"\"idassert-authcDN <DN>\" incompatible "
|
2005-12-08 01:35:02 +08:00
|
|
|
"with auth method %d",
|
|
|
|
li->li_idassert_authmethod );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 15:25:00 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( !BER_BVISNULL( &li->li_idassert_authcDN ) ) {
|
|
|
|
free( li->li_idassert_authcDN.bv_val );
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
2005-08-07 20:55:15 +08:00
|
|
|
ber_memfree_x( c->value_dn.bv_val, NULL );
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_authcDN = c->value_ndn;
|
2005-08-07 20:55:15 +08:00
|
|
|
BER_BVZERO( &c->value_dn );
|
|
|
|
BER_BVZERO( &c->value_ndn );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_PASSWD:
|
2005-11-19 23:00:50 +08:00
|
|
|
switch ( li->li_idassert_authmethod ) {
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_AUTH_NONE:
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_authmethod = LDAP_AUTH_SIMPLE;
|
2005-05-23 15:25:00 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_AUTH_SIMPLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 15:25:00 +08:00
|
|
|
"\"idassert-passwd <cred>\" incompatible "
|
2005-12-08 01:35:02 +08:00
|
|
|
"with auth method %d",
|
|
|
|
li->li_idassert_authmethod );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 15:25:00 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( !BER_BVISNULL( &li->li_idassert_passwd ) ) {
|
|
|
|
free( li->li_idassert_passwd.bv_val );
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
ber_str2bv( c->argv[ 1 ], 0, 1, &li->li_idassert_passwd );
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
2005-08-02 07:32:14 +08:00
|
|
|
case LDAP_BACK_CFG_IDASSERT_AUTHZFROM: {
|
|
|
|
struct berval bv;
|
2005-08-12 07:52:17 +08:00
|
|
|
#ifdef SLAP_AUTHZ_SYNTAX
|
|
|
|
struct berval in;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
ber_str2bv( c->argv[ 1 ], 0, 0, &in );
|
|
|
|
rc = authzNormalize( 0, NULL, NULL, &in, &bv, NULL );
|
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-08-12 07:52:17 +08:00
|
|
|
"\"idassert-authzFrom <authz>\": "
|
2005-12-08 01:35:02 +08:00
|
|
|
"invalid syntax" );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-08-12 07:52:17 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#else /* !SLAP_AUTHZ_SYNTAX */
|
2005-08-03 06:21:44 +08:00
|
|
|
ber_str2bv( c->argv[ 1 ], 0, 1, &bv );
|
2005-08-12 07:52:17 +08:00
|
|
|
#endif /* !SLAP_AUTHZ_SYNTAX */
|
2005-11-19 23:00:50 +08:00
|
|
|
ber_bvarray_add( &li->li_idassert_authz, &bv );
|
2005-08-02 07:32:14 +08:00
|
|
|
} break;
|
2005-05-22 03:07:14 +08:00
|
|
|
|
|
|
|
case LDAP_BACK_CFG_IDASSERT_METHOD:
|
2005-05-23 22:14:34 +08:00
|
|
|
/* no longer supported */
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 22:14:34 +08:00
|
|
|
"\"idassert-method <args>\": "
|
2005-12-08 01:35:02 +08:00
|
|
|
"no longer supported; use \"idassert-bind\"" );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 22:14:34 +08:00
|
|
|
return 1;
|
|
|
|
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_IDASSERT_BIND:
|
2005-05-22 03:07:14 +08:00
|
|
|
for ( i = 1; i < c->argc; i++ ) {
|
2005-05-23 15:25:00 +08:00
|
|
|
if ( strncasecmp( c->argv[ i ], "mode=", STRLENOF( "mode=" ) ) == 0 ) {
|
|
|
|
char *argvi = c->argv[ i ] + STRLENOF( "mode=" );
|
|
|
|
int j;
|
|
|
|
|
|
|
|
j = verb_to_mask( argvi, idassert_mode );
|
|
|
|
if ( BER_BVISNULL( &idassert_mode[ j ].word ) ) {
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 15:25:00 +08:00
|
|
|
"\"idassert-bind <args>\": "
|
2005-12-08 01:35:02 +08:00
|
|
|
"unknown mode \"%s\"",
|
|
|
|
argvi );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 15:25:00 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_mode = idassert_mode[ j ].mask;
|
2005-05-23 15:25:00 +08:00
|
|
|
|
2005-05-23 22:14:34 +08:00
|
|
|
} else if ( strncasecmp( c->argv[ i ], "authz=", STRLENOF( "authz=" ) ) == 0 ) {
|
|
|
|
char *argvi = c->argv[ i ] + STRLENOF( "authz=" );
|
|
|
|
|
|
|
|
if ( strcasecmp( argvi, "native" ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( li->li_idassert_authmethod != LDAP_AUTH_SASL ) {
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 22:14:34 +08:00
|
|
|
"\"idassert-bind <args>\": "
|
|
|
|
"authz=\"native\" incompatible "
|
2005-12-08 01:35:02 +08:00
|
|
|
"with auth method" );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 22:14:34 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_flags |= LDAP_BACK_AUTH_NATIVE_AUTHZ;
|
2005-05-23 22:14:34 +08:00
|
|
|
|
|
|
|
} else if ( strcasecmp( argvi, "proxyAuthz" ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_flags &= ~LDAP_BACK_AUTH_NATIVE_AUTHZ;
|
2005-05-23 22:14:34 +08:00
|
|
|
|
|
|
|
} else {
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 22:14:34 +08:00
|
|
|
"\"idassert-bind <args>\": "
|
2005-12-08 01:35:02 +08:00
|
|
|
"unknown authz \"%s\"",
|
|
|
|
argvi );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 22:14:34 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ( strncasecmp( c->argv[ i ], "flags=", STRLENOF( "flags=" ) ) == 0 ) {
|
|
|
|
char *argvi = c->argv[ i ] + STRLENOF( "flags=" );
|
|
|
|
char **flags = ldap_str2charray( argvi, "," );
|
|
|
|
int j;
|
|
|
|
|
|
|
|
if ( flags == NULL ) {
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 22:14:34 +08:00
|
|
|
"\"idassert-bind <args>\": "
|
2005-12-08 01:35:02 +08:00
|
|
|
"unable to parse flags \"%s\"",
|
|
|
|
argvi );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 22:14:34 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( j = 0; flags[ j ] != NULL; j++ ) {
|
|
|
|
if ( strcasecmp( flags[ j ], "override" ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_flags |= LDAP_BACK_AUTH_OVERRIDE;
|
2005-05-23 22:14:34 +08:00
|
|
|
|
2005-07-04 07:27:56 +08:00
|
|
|
} else if ( strcasecmp( flags[ j ], "prescriptive" ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_flags |= LDAP_BACK_AUTH_PRESCRIPTIVE;
|
2005-07-04 07:27:56 +08:00
|
|
|
|
|
|
|
} else if ( strcasecmp( flags[ j ], "non-prescriptive" ) == 0 ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_idassert_flags &= ( ~LDAP_BACK_AUTH_PRESCRIPTIVE );
|
2005-07-04 07:27:56 +08:00
|
|
|
|
2005-05-23 22:14:34 +08:00
|
|
|
} else {
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 22:14:34 +08:00
|
|
|
"\"idassert-bind <args>\": "
|
2005-12-08 01:35:02 +08:00
|
|
|
"unknown flag \"%s\"",
|
2006-02-16 09:10:45 +08:00
|
|
|
flags[ j ] );
|
2005-12-08 01:35:02 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 22:14:34 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ldap_charray_free( flags );
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
} else if ( bindconf_parse( c->argv[ i ], &li->li_idassert ) ) {
|
2005-05-22 03:07:14 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-11-20 01:48:33 +08:00
|
|
|
case LDAP_BACK_CFG_REBIND:
|
|
|
|
if ( c->argc == 1 || c->value_int ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_flags |= LDAP_BACK_F_SAVECRED;
|
2005-05-22 03:07:14 +08:00
|
|
|
|
|
|
|
} else {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_flags &= ~LDAP_BACK_F_SAVECRED;
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
2005-11-20 01:48:33 +08:00
|
|
|
break;
|
2005-05-22 03:07:14 +08:00
|
|
|
|
2005-11-20 01:48:33 +08:00
|
|
|
case LDAP_BACK_CFG_CHASE:
|
|
|
|
if ( c->argc == 1 || c->value_int ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_flags |= LDAP_BACK_F_CHASE_REFERRALS;
|
2005-05-22 03:07:14 +08:00
|
|
|
|
|
|
|
} else {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_flags &= ~LDAP_BACK_F_CHASE_REFERRALS;
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
2005-11-20 01:48:33 +08:00
|
|
|
break;
|
2005-05-22 03:07:14 +08:00
|
|
|
|
|
|
|
case LDAP_BACK_CFG_T_F:
|
|
|
|
i = verb_to_mask( c->argv[1], t_f_mode );
|
|
|
|
if ( BER_BVISNULL( &t_f_mode[i].word ) ) {
|
|
|
|
return 1;
|
|
|
|
}
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_flags &= ~LDAP_BACK_F_SUPPORT_T_F_MASK;
|
|
|
|
li->li_flags |= t_f_mode[i].mask;
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
2005-11-20 01:48:33 +08:00
|
|
|
case LDAP_BACK_CFG_WHOAMI:
|
|
|
|
if ( c->argc == 1 || c->value_int ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_flags |= LDAP_BACK_F_PROXY_WHOAMI;
|
2005-05-22 03:07:14 +08:00
|
|
|
load_extop( (struct berval *)&slap_EXOP_WHOAMI,
|
|
|
|
0, ldap_back_exop_whoami );
|
|
|
|
|
|
|
|
} else {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_flags &= ~LDAP_BACK_F_PROXY_WHOAMI;
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
2005-11-20 01:48:33 +08:00
|
|
|
break;
|
2005-11-07 07:29:10 +08:00
|
|
|
|
|
|
|
case LDAP_BACK_CFG_TIMEOUT:
|
|
|
|
for ( i = 1; i < c->argc; i++ ) {
|
2006-04-02 07:44:42 +08:00
|
|
|
if ( isdigit( (unsigned char) c->argv[ i ][ 0 ] ) ) {
|
2005-11-07 07:29:10 +08:00
|
|
|
int j;
|
|
|
|
unsigned u;
|
|
|
|
|
2005-11-24 09:10:05 +08:00
|
|
|
if ( lutil_atoux( &u, c->argv[ i ], 0 ) != 0 ) {
|
2005-11-07 07:29:10 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( j = 0; j < LDAP_BACK_OP_LAST; j++ ) {
|
2005-11-19 23:00:50 +08:00
|
|
|
li->li_timeout[ j ] = u;
|
2005-11-07 07:29:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( slap_cf_aux_table_parse( c->argv[ i ], li->li_timeout, timeout_table, "slapd-ldap timeout" ) ) {
|
2005-11-07 07:29:10 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2005-05-22 03:07:14 +08:00
|
|
|
break;
|
|
|
|
|
2005-12-08 01:35:02 +08:00
|
|
|
case LDAP_BACK_CFG_IDLE_TIMEOUT: {
|
|
|
|
unsigned long t;
|
|
|
|
|
|
|
|
if ( lutil_parse_time( c->argv[ 1 ], &t ) != 0 ) {
|
|
|
|
snprintf( c->msg, sizeof( c->msg),
|
|
|
|
"unable to parse idle timeout \"%s\"",
|
|
|
|
c->argv[ 1 ] );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
li->li_idle_timeout = (time_t)t;
|
|
|
|
} break;
|
|
|
|
|
2006-02-02 07:10:12 +08:00
|
|
|
case LDAP_BACK_CFG_CONN_TTL: {
|
|
|
|
unsigned long t;
|
|
|
|
|
|
|
|
if ( lutil_parse_time( c->argv[ 1 ], &t ) != 0 ) {
|
|
|
|
snprintf( c->msg, sizeof( c->msg),
|
|
|
|
"unable to parse conn ttl\"%s\"",
|
|
|
|
c->argv[ 1 ] );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
li->li_conn_ttl = (time_t)t;
|
|
|
|
} break;
|
|
|
|
|
2005-05-23 15:25:00 +08:00
|
|
|
case LDAP_BACK_CFG_REWRITE:
|
2005-12-08 01:35:02 +08:00
|
|
|
snprintf( c->msg, sizeof( c->msg ),
|
2005-05-23 15:25:00 +08:00
|
|
|
"rewrite/remap capabilities have been moved "
|
|
|
|
"to the \"rwm\" overlay; see slapo-rwm(5) "
|
|
|
|
"for details (hint: add \"overlay rwm\" "
|
2005-12-08 01:35:02 +08:00
|
|
|
"and prefix all directives with \"rwm-\")" );
|
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
|
2005-05-23 15:25:00 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
default:
|
2005-07-29 09:00:48 +08:00
|
|
|
/* FIXME: try to catch inconsistencies */
|
2005-05-23 15:25:00 +08:00
|
|
|
assert( 0 );
|
2005-07-29 09:00:48 +08:00
|
|
|
break;
|
2005-05-22 03:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ldap_back_init_cf( BackendInfo *bi )
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
AttributeDescription *ad = NULL;
|
|
|
|
const char *text;
|
|
|
|
|
2005-11-20 02:01:28 +08:00
|
|
|
/* Make sure we don't exceed the bits reserved for userland */
|
|
|
|
config_check_userland( LDAP_BACK_CFG_LAST );
|
|
|
|
|
2005-05-22 03:07:14 +08:00
|
|
|
bi->bi_cf_ocs = ldapocs;
|
|
|
|
|
|
|
|
rc = config_register_schema( ldapcfg, ldapocs );
|
|
|
|
if ( rc ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup olcDbAclPasswd and olcDbIDAssertPasswd
|
|
|
|
* to be base64-encoded when written in LDIF form;
|
|
|
|
* basically, we don't care if it fails */
|
2005-05-23 15:25:00 +08:00
|
|
|
rc = slap_str2ad( "olcDbACLPasswd", &ad, &text );
|
2005-05-22 03:07:14 +08:00
|
|
|
if ( rc ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
|
2005-05-23 15:25:00 +08:00
|
|
|
"warning, unable to get \"olcDbACLPasswd\" "
|
2005-05-22 03:07:14 +08:00
|
|
|
"attribute description: %d: %s\n",
|
|
|
|
rc, text, 0 );
|
|
|
|
} else {
|
|
|
|
(void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
|
|
|
|
ad->ad_type->sat_oid );
|
|
|
|
}
|
|
|
|
|
|
|
|
ad = NULL;
|
|
|
|
rc = slap_str2ad( "olcDbIDAssertPasswd", &ad, &text );
|
|
|
|
if ( rc ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
|
|
|
|
"warning, unable to get \"olcDbIDAssertPasswd\" "
|
|
|
|
"attribute description: %d: %s\n",
|
|
|
|
rc, text, 0 );
|
|
|
|
} else {
|
|
|
|
(void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
|
|
|
|
ad->ad_type->sat_oid );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-16 19:21:15 +08:00
|
|
|
static int
|
|
|
|
ldap_back_exop_whoami(
|
2004-11-13 22:43:30 +08:00
|
|
|
Operation *op,
|
|
|
|
SlapReply *rs )
|
2003-02-16 19:21:15 +08:00
|
|
|
{
|
|
|
|
struct berval *bv = NULL;
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
if ( op->oq_extended.rs_reqdata != NULL ) {
|
2003-02-16 19:21:15 +08:00
|
|
|
/* no request data should be provided */
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_text = "no request data expected";
|
2003-04-08 21:22:12 +08:00
|
|
|
return rs->sr_err = LDAP_PROTOCOL_ERROR;
|
2003-02-16 19:21:15 +08:00
|
|
|
}
|
|
|
|
|
2005-08-14 08:14:58 +08:00
|
|
|
Statslog( LDAP_DEBUG_STATS, "%s WHOAMI\n",
|
|
|
|
op->o_log_prefix, 0, 0, 0, 0 );
|
|
|
|
|
2003-04-08 21:22:12 +08:00
|
|
|
rs->sr_err = backend_check_restrictions( op, rs,
|
2003-03-30 17:03:54 +08:00
|
|
|
(struct berval *)&slap_EXOP_WHOAMI );
|
2003-04-08 21:22:12 +08:00
|
|
|
if( rs->sr_err != LDAP_SUCCESS ) return rs->sr_err;
|
2003-02-16 19:21:15 +08:00
|
|
|
|
|
|
|
/* if auth'd by back-ldap and request is proxied, forward it */
|
2005-11-28 07:19:17 +08:00
|
|
|
if ( op->o_conn->c_authz_backend
|
|
|
|
&& !strcmp( op->o_conn->c_authz_backend->be_type, "ldap" )
|
|
|
|
&& !dn_match( &op->o_ndn, &op->o_conn->c_ndn ) )
|
|
|
|
{
|
2005-11-19 23:00:50 +08:00
|
|
|
ldapconn_t *lc;
|
2003-05-02 21:26:25 +08:00
|
|
|
LDAPControl c, *ctrls[2] = {NULL, NULL};
|
2003-02-16 19:21:15 +08:00
|
|
|
LDAPMessage *res;
|
|
|
|
Operation op2 = *op;
|
|
|
|
ber_int_t msgid;
|
2005-05-22 03:07:14 +08:00
|
|
|
int doretry = 1;
|
2005-11-28 07:19:17 +08:00
|
|
|
char *ptr;
|
2003-02-16 19:21:15 +08:00
|
|
|
|
2003-05-02 21:26:25 +08:00
|
|
|
ctrls[0] = &c;
|
2003-03-30 17:03:54 +08:00
|
|
|
op2.o_ndn = op->o_conn->c_ndn;
|
2005-01-24 17:38:11 +08:00
|
|
|
lc = ldap_back_getconn(&op2, rs, LDAP_BACK_SENDERR);
|
2005-11-28 07:19:17 +08:00
|
|
|
if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
|
2003-02-16 19:21:15 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
c.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
|
|
|
|
c.ldctl_iscritical = 1;
|
2005-11-28 07:19:17 +08:00
|
|
|
c.ldctl_value.bv_val = op->o_tmpalloc(
|
|
|
|
op->o_ndn.bv_len + STRLENOF( "dn:" ) + 1,
|
|
|
|
op->o_tmpmemctx );
|
2003-02-16 19:21:15 +08:00
|
|
|
c.ldctl_value.bv_len = op->o_ndn.bv_len + 3;
|
2005-11-28 07:19:17 +08:00
|
|
|
ptr = c.ldctl_value.bv_val;
|
|
|
|
ptr = lutil_strcopy( ptr, "dn:" );
|
|
|
|
ptr = lutil_strncopy( ptr, op->o_ndn.bv_val, op->o_ndn.bv_len );
|
|
|
|
ptr[ 0 ] = '\0';
|
2003-02-16 19:21:15 +08:00
|
|
|
|
2004-10-01 20:00:41 +08:00
|
|
|
retry:
|
2005-11-28 07:19:17 +08:00
|
|
|
rs->sr_err = ldap_whoami( lc->lc_ld, ctrls, NULL, &msgid );
|
|
|
|
if ( rs->sr_err == LDAP_SUCCESS ) {
|
2005-12-14 04:11:26 +08:00
|
|
|
if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, NULL, &res ) == -1 ) {
|
2005-11-28 07:19:17 +08:00
|
|
|
ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER,
|
|
|
|
&rs->sr_err );
|
2005-05-22 03:07:14 +08:00
|
|
|
if ( rs->sr_err == LDAP_SERVER_DOWN && doretry ) {
|
|
|
|
doretry = 0;
|
2005-11-28 07:19:17 +08:00
|
|
|
if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
|
2004-10-01 20:00:41 +08:00
|
|
|
goto retry;
|
2005-11-28 07:19:17 +08:00
|
|
|
}
|
2004-10-01 20:00:41 +08:00
|
|
|
}
|
2004-07-05 07:35:18 +08:00
|
|
|
|
2003-02-16 19:21:15 +08:00
|
|
|
} else {
|
2005-11-28 07:19:17 +08:00
|
|
|
/* NOTE: are we sure "bv" will be malloc'ed
|
|
|
|
* with the appropriate memory? */
|
|
|
|
rs->sr_err = ldap_parse_whoami( lc->lc_ld, res, &bv );
|
2003-02-16 19:21:15 +08:00
|
|
|
ldap_msgfree(res);
|
|
|
|
}
|
|
|
|
}
|
2005-11-28 07:19:17 +08:00
|
|
|
op->o_tmpfree( c.ldctl_value.bv_val, op->o_tmpmemctx );
|
|
|
|
if ( rs->sr_err != LDAP_SUCCESS ) {
|
2004-04-06 01:36:53 +08:00
|
|
|
rs->sr_err = slap_map_api2result( rs );
|
2003-02-16 19:21:15 +08:00
|
|
|
}
|
2005-06-30 00:38:09 +08:00
|
|
|
|
|
|
|
if ( lc != NULL ) {
|
|
|
|
ldap_back_release_conn( &op2, rs, lc );
|
|
|
|
}
|
|
|
|
|
2003-02-16 19:21:15 +08:00
|
|
|
} else {
|
2005-11-28 07:19:17 +08:00
|
|
|
/* else just do the same as before */
|
|
|
|
bv = (struct berval *) ch_malloc( sizeof( struct berval ) );
|
2004-11-13 22:43:30 +08:00
|
|
|
if ( !BER_BVISEMPTY( &op->o_dn ) ) {
|
2005-11-28 07:19:17 +08:00
|
|
|
bv->bv_len = op->o_dn.bv_len + STRLENOF( "dn:" );
|
2003-02-16 19:21:15 +08:00
|
|
|
bv->bv_val = ch_malloc( bv->bv_len + 1 );
|
2005-11-28 07:19:17 +08:00
|
|
|
AC_MEMCPY( bv->bv_val, "dn:", STRLENOF( "dn:" ) );
|
|
|
|
AC_MEMCPY( &bv->bv_val[ STRLENOF( "dn:" ) ], op->o_dn.bv_val,
|
2003-02-16 19:21:15 +08:00
|
|
|
op->o_dn.bv_len );
|
2005-11-28 07:19:17 +08:00
|
|
|
bv->bv_val[ bv->bv_len ] = '\0';
|
|
|
|
|
2003-02-16 19:21:15 +08:00
|
|
|
} else {
|
|
|
|
bv->bv_len = 0;
|
|
|
|
bv->bv_val = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_rspdata = bv;
|
|
|
|
return rs->sr_err;
|
2003-02-16 19:21:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|