From 88c039607518e62d035ab7479c8a31970ba85977 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 9 Aug 2005 23:03:43 +0000 Subject: [PATCH] Sync with HEAD --- configure | 2106 +++++++++-------- include/ldap.h | 3 +- include/ldap_cdefs.h | 18 + include/portable.h.in | 6 + include/slapi-plugin.h | 201 +- libraries/liblber/memory.c | 22 +- libraries/liblber/options.c | 36 +- libraries/liblber/sockbuf.c | 4 +- libraries/libldap/abandon.c | 1 + libraries/libldap/cyrus.c | 14 +- libraries/libldap/error.c | 2 +- libraries/libldap/getdn.c | 138 +- libraries/libldap/groupings.c | 2 + libraries/libldap/ldap-int.h | 2 +- libraries/libldap/options.c | 6 +- libraries/libldap/ppolicy.c | 8 +- libraries/libldap/request.c | 139 +- libraries/libldap/result.c | 212 +- libraries/libldap/schema.c | 28 +- libraries/libldap/string.c | 4 +- libraries/libldap/unbind.c | 10 + libraries/libldap/url.c | 8 +- libraries/libldap/util-int.c | 14 +- libraries/libldap_r/tpool.c | 1 - libraries/liblutil/getpeereid.c | 2 +- libraries/liblutil/ldif.c | 12 +- libraries/liblutil/passwd.c | 27 +- libraries/librewrite/context.c | 10 +- libraries/librewrite/ldapmap.c | 4 +- libraries/librewrite/map.c | 6 +- libraries/librewrite/rule.c | 8 +- libraries/librewrite/session.c | 2 +- libraries/librewrite/subst.c | 4 +- libraries/librewrite/xmap.c | 4 +- servers/slapd/Makefile.in | 27 +- servers/slapd/abandon.c | 1 - servers/slapd/acl.c | 92 +- servers/slapd/aclparse.c | 12 +- servers/slapd/ad.c | 15 +- servers/slapd/add.c | 164 +- servers/slapd/at.c | 122 +- servers/slapd/attr.c | 2 +- servers/slapd/back-bdb/add.c | 2 +- servers/slapd/back-bdb/alock.c | 7 +- servers/slapd/back-bdb/back-bdb.h | 10 +- servers/slapd/back-bdb/cache.c | 38 +- servers/slapd/back-bdb/config.c | 6 +- servers/slapd/back-bdb/dn2id.c | 23 +- servers/slapd/back-bdb/filterindex.c | 4 +- servers/slapd/back-bdb/idl.c | 2 - servers/slapd/back-bdb/index.c | 4 +- servers/slapd/back-bdb/init.c | 51 +- servers/slapd/back-bdb/modify.c | 2 +- servers/slapd/back-bdb/modrdn.c | 6 +- servers/slapd/back-bdb/operational.c | 6 +- servers/slapd/back-bdb/proto-bdb.h | 8 +- servers/slapd/back-bdb/search.c | 4 +- servers/slapd/back-bdb/tools.c | 22 +- servers/slapd/back-ldap/back-ldap.h | 1 - servers/slapd/back-ldap/bind.c | 131 +- servers/slapd/back-ldap/chain.c | 53 +- servers/slapd/back-ldap/config.c | 140 +- servers/slapd/back-ldap/delete.c | 4 +- servers/slapd/back-ldap/init.c | 7 +- servers/slapd/back-ldap/modify.c | 2 +- servers/slapd/back-ldap/modrdn.c | 2 +- servers/slapd/back-ldap/proto-ldap.h | 2 + servers/slapd/back-ldap/search.c | 71 +- servers/slapd/back-ldap/unbind.c | 12 +- servers/slapd/back-ldbm/add.c | 2 +- servers/slapd/back-ldbm/alias.c | 2 +- servers/slapd/back-ldbm/cache.c | 16 +- servers/slapd/back-ldbm/close.c | 2 - servers/slapd/back-ldbm/dn2id.c | 2 +- servers/slapd/back-ldbm/modify.c | 2 +- servers/slapd/back-ldbm/modrdn.c | 3 +- servers/slapd/back-ldbm/operational.c | 4 +- servers/slapd/back-ldbm/search.c | 5 +- servers/slapd/back-ldbm/tools.c | 4 +- servers/slapd/back-ldif/ldif.c | 95 +- servers/slapd/back-meta/add.c | 51 +- servers/slapd/back-meta/back-meta.h | 10 + servers/slapd/back-meta/bind.c | 64 +- servers/slapd/back-meta/candidates.c | 6 +- servers/slapd/back-meta/compare.c | 1 - servers/slapd/back-meta/config.c | 83 +- servers/slapd/back-meta/conn.c | 97 +- servers/slapd/back-meta/delete.c | 51 +- servers/slapd/back-meta/dncache.c | 12 +- servers/slapd/back-meta/map.c | 8 +- servers/slapd/back-meta/modify.c | 46 +- servers/slapd/back-meta/modrdn.c | 61 +- servers/slapd/back-meta/suffixmassage.c | 2 +- servers/slapd/back-meta/unbind.c | 26 +- servers/slapd/back-monitor/back-monitor.h | 7 +- servers/slapd/back-monitor/backend.c | 13 +- servers/slapd/back-monitor/cache.c | 108 +- servers/slapd/back-monitor/conn.c | 50 +- servers/slapd/back-monitor/database.c | 17 +- servers/slapd/back-monitor/init.c | 194 +- servers/slapd/back-monitor/log.c | 34 +- servers/slapd/back-monitor/operation.c | 42 +- servers/slapd/back-monitor/operational.c | 6 +- servers/slapd/back-monitor/overlay.c | 8 +- .../slapd/back-monitor/proto-back-monitor.h | 51 +- servers/slapd/back-monitor/rww.c | 15 +- servers/slapd/back-monitor/search.c | 67 +- servers/slapd/back-monitor/sent.c | 41 +- servers/slapd/back-monitor/thread.c | 17 +- servers/slapd/back-monitor/time.c | 17 +- servers/slapd/back-perl/compare.c | 2 +- servers/slapd/back-relay/init.c | 2 +- servers/slapd/back-sql/add.c | 119 +- servers/slapd/back-sql/api.c | 8 +- servers/slapd/back-sql/back-sql.h | 2 - servers/slapd/back-sql/bind.c | 1 - servers/slapd/back-sql/compare.c | 4 +- servers/slapd/back-sql/config.c | 6 +- servers/slapd/back-sql/delete.c | 9 +- servers/slapd/back-sql/entry-id.c | 74 +- servers/slapd/back-sql/init.c | 130 +- servers/slapd/back-sql/modify.c | 3 +- servers/slapd/back-sql/modrdn.c | 8 +- servers/slapd/back-sql/operational.c | 7 +- servers/slapd/back-sql/proto-sql.h | 12 +- .../rdbms_depend/ibmdb2/testdb_data.sql | 2 +- .../rdbms_depend/mssql/testdb_metadata.sql | 2 +- .../rdbms_depend/mysql/backsql_drop.sql | 2 - .../rdbms_depend/mysql/testdb_data.sql | 2 +- .../rdbms_depend/oracle/testdb_metadata.sql | 2 +- .../rdbms_depend/pgsql/testdb_data.sql | 2 +- .../rdbms_depend/pgsql/testdb_drop.sql | 7 + .../rdbms_depend/timesten/testdb_metadata.sql | 2 +- servers/slapd/back-sql/schema-map.c | 12 +- servers/slapd/back-sql/search.c | 41 +- servers/slapd/back-sql/sql-wrap.c | 171 +- servers/slapd/back-sql/util.c | 24 +- servers/slapd/backend.c | 308 +-- servers/slapd/backover.c | 240 +- servers/slapd/bconfig.c | 345 ++- servers/slapd/bind.c | 113 - servers/slapd/cancel.c | 1 - servers/slapd/compare.c | 43 +- servers/slapd/component.c | 16 +- servers/slapd/config.c | 177 +- servers/slapd/config.h | 12 +- servers/slapd/connection.c | 16 +- servers/slapd/controls.c | 186 +- servers/slapd/cr.c | 10 +- servers/slapd/ctxcsn.c | 2 - servers/slapd/daemon.c | 28 +- servers/slapd/delete.c | 43 +- servers/slapd/dn.c | 82 +- servers/slapd/entry.c | 14 +- servers/slapd/extended.c | 82 +- servers/slapd/filter.c | 4 +- servers/slapd/filterentry.c | 4 +- servers/slapd/frontend.c | 14 +- servers/slapd/init.c | 4 +- servers/slapd/ldapsync.c | 36 +- servers/slapd/limits.c | 75 +- servers/slapd/main.c | 48 +- servers/slapd/modify.c | 140 +- servers/slapd/modrdn.c | 38 - servers/slapd/mods.c | 10 +- servers/slapd/mra.c | 4 +- servers/slapd/oc.c | 11 +- servers/slapd/oidm.c | 6 +- servers/slapd/operation.c | 13 +- servers/slapd/operational.c | 2 +- servers/slapd/overlays/accesslog.c | 30 +- servers/slapd/overlays/dynlist.c | 6 +- servers/slapd/overlays/glue.c | 34 +- servers/slapd/overlays/lastmod.c | 3 - servers/slapd/overlays/overlays.c | 6 + servers/slapd/overlays/pcache.c | 33 +- servers/slapd/overlays/ppolicy.c | 33 +- servers/slapd/overlays/refint.c | 4 +- servers/slapd/overlays/retcode.c | 1143 +++++++++ servers/slapd/overlays/rwm.c | 71 +- servers/slapd/overlays/rwmdn.c | 12 +- servers/slapd/overlays/rwmmap.c | 27 +- servers/slapd/overlays/seqmod.c | 2 +- servers/slapd/overlays/syncprov.c | 32 +- servers/slapd/overlays/translucent.c | 12 +- servers/slapd/overlays/unique.c | 2 +- servers/slapd/passwd.c | 4 +- servers/slapd/phonetic.c | 2 + servers/slapd/proto-slap.h | 125 +- servers/slapd/repl.c | 54 +- servers/slapd/result.c | 136 +- servers/slapd/root_dse.c | 8 +- servers/slapd/sasl.c | 51 +- servers/slapd/saslauthz.c | 43 +- servers/slapd/schema.c | 2 +- servers/slapd/schema/core.schema | 4 +- servers/slapd/schema/cosine.schema | 2 +- servers/slapd/schema/nis.schema | 39 +- servers/slapd/schema_check.c | 14 +- servers/slapd/schema_init.c | 30 +- servers/slapd/schema_prep.c | 13 +- servers/slapd/search.c | 157 -- servers/slapd/sl_malloc.c | 32 +- servers/slapd/slap.h | 38 +- servers/slapd/slapadd.c | 27 +- servers/slapd/slapi/Makefile.in | 4 +- servers/slapd/slapi/TODO | 2 +- servers/slapd/slapi/ibm_pblock_params.h | 77 - servers/slapd/slapi/plugin.c | 194 +- servers/slapd/slapi/proto-slapi.h | 371 +-- servers/slapd/slapi/slapi.h | 485 +--- servers/slapd/slapi/slapi_dn.c | 665 ++++++ servers/slapd/slapi/slapi_ext.c | 44 +- servers/slapd/slapi/slapi_ops.c | 1712 ++++++-------- servers/slapd/slapi/slapi_overlay.c | 899 +++++++ servers/slapd/slapi/slapi_pblock.c | 1168 +++++++-- servers/slapd/slapi/slapi_utils.c | 1889 +++++---------- servers/slapd/starttls.c | 1 - servers/slapd/str2filter.c | 6 - servers/slapd/syncrepl.c | 30 +- servers/slapd/value.c | 2 +- servers/slapd/zn_malloc.c | 4 +- servers/slurpd/ldap_op.c | 6 +- servers/slurpd/re.c | 2 + tests/data/acl.out.master | 8 +- tests/data/meta.out | 12 +- tests/data/metaconcurrency.out | 2 +- tests/data/ppolicy.ldif | 2 +- tests/data/relay.out | 22 +- tests/data/retcode.conf | 115 + tests/data/slapd-acl.conf | 10 +- tests/data/slapd-cache-master.conf | 2 +- tests/data/slapd-chain1.conf | 10 +- tests/data/slapd-chain2.conf | 10 +- tests/data/slapd-component.conf | 5 +- tests/data/slapd-dn.conf | 2 +- tests/data/slapd-glue-ldap.conf | 76 + tests/data/slapd-glue-syncrepl1.conf | 33 +- tests/data/slapd-glue-syncrepl2.conf | 33 +- tests/data/slapd-glue.conf | 33 +- tests/data/slapd-idassert.conf | 18 +- tests/data/slapd-ldapglue.conf | 18 +- tests/data/slapd-ldapgluegroups.conf | 10 +- tests/data/slapd-ldapgluepeople.conf | 10 +- tests/data/slapd-limits.conf | 6 +- tests/data/slapd-master.conf | 5 +- tests/data/slapd-meta.conf | 2 +- tests/data/slapd-meta2.conf | 1 + tests/data/slapd-ppolicy.conf | 2 +- tests/data/slapd-proxycache.conf | 4 +- tests/data/slapd-pw.conf | 2 +- tests/data/slapd-ref-slave.conf | 8 +- tests/data/slapd-referrals.conf | 5 +- tests/data/slapd-refint.conf | 10 +- tests/data/slapd-relay.conf | 6 +- tests/data/slapd-repl-master.conf | 8 +- tests/data/slapd-repl-slave.conf | 6 +- tests/data/slapd-retcode.conf | 54 + tests/data/slapd-schema.conf | 6 +- tests/data/slapd-syncrepl-master.conf | 11 +- tests/data/slapd-syncrepl-slave-persist1.conf | 32 +- tests/data/slapd-syncrepl-slave-persist2.conf | 31 +- tests/data/slapd-syncrepl-slave-persist3.conf | 31 +- tests/data/slapd-syncrepl-slave-refresh1.conf | 37 +- tests/data/slapd-syncrepl-slave-refresh2.conf | 35 +- tests/data/slapd-translucent-local.conf | 10 +- tests/data/slapd-translucent-remote.conf | 10 +- tests/data/slapd-unique.conf | 2 +- tests/data/slapd-whoami.conf | 2 +- tests/data/slapd.conf | 4 +- tests/data/slapd2.conf | 2 +- tests/data/sql-concurrency/do_add.1 | 9 + tests/data/sql-concurrency/do_add.2 | 10 + tests/data/sql-concurrency/do_add.3 | 10 + tests/data/sql-concurrency/do_add.4 | 10 + tests/data/sql-concurrency/do_modrdn.0 | 2 + tests/data/sql-concurrency/do_read.0 | 4 + tests/data/sql-concurrency/do_search.0 | 12 + tests/data/sql-read.out | 36 +- tests/data/sql-write.out | 10 +- tests/data/test-meta.ldif | 2 +- tests/progs/slapd-modify.c | 4 +- tests/run.in | 3 +- tests/scripts/conf.sh | 35 +- tests/scripts/defines.sh | 5 + tests/scripts/relay | 4 +- tests/scripts/test006-acls | 36 +- tests/scripts/test020-proxycache | 5 + tests/scripts/test022-ppolicy | 26 + tests/scripts/test030-relay | 2 +- tests/scripts/test033-glue-syncrepl | 114 + tests/scripts/test037-manage | 199 ++ tests/scripts/test038-retcode | 107 + tests/scripts/test039-glue-ldap-concurrency | 199 ++ 294 files changed, 11581 insertions(+), 8062 deletions(-) create mode 100644 servers/slapd/overlays/retcode.c delete mode 100644 servers/slapd/slapi/ibm_pblock_params.h create mode 100644 servers/slapd/slapi/slapi_dn.c create mode 100644 servers/slapd/slapi/slapi_overlay.c create mode 100644 tests/data/retcode.conf create mode 100644 tests/data/slapd-glue-ldap.conf create mode 100644 tests/data/slapd-retcode.conf create mode 100644 tests/data/sql-concurrency/do_add.1 create mode 100644 tests/data/sql-concurrency/do_add.2 create mode 100644 tests/data/sql-concurrency/do_add.3 create mode 100644 tests/data/sql-concurrency/do_add.4 create mode 100644 tests/data/sql-concurrency/do_modrdn.0 create mode 100644 tests/data/sql-concurrency/do_read.0 create mode 100644 tests/data/sql-concurrency/do_search.0 create mode 100755 tests/scripts/test033-glue-syncrepl create mode 100755 tests/scripts/test037-manage create mode 100755 tests/scripts/test038-retcode create mode 100755 tests/scripts/test039-glue-ldap-concurrency diff --git a/configure b/configure index 39983a5ac2..25e9bbcef9 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # $OpenLDAP$ -# from OpenLDAP: pkg/ldap/configure.in,v 1.560.2.9 2005/06/10 15:11:24 kurt Exp +# from OpenLDAP: pkg/ldap/configure.in,v 1.560.2.11 2005/08/09 16:41:26 kurt Exp # This work is part of OpenLDAP Software . # @@ -76,7 +76,7 @@ ac_help="$ac_help ac_help="$ac_help --enable-modules enable dynamic module support [no]" ac_help="$ac_help - --enable-rewrite enable DN rewriting in back-ldap and the rwm overlay [auto]" + --enable-rewrite enable DN rewriting in back-ldap and rwm overlay [auto]" ac_help="$ac_help --enable-rlookups enable reverse lookups of client hostnames [no]" ac_help="$ac_help @@ -89,68 +89,70 @@ ac_help="$ac_help SLAPD Backend Options:" ac_help="$ac_help - --enable-backends enable all available backends no|yes|mod [no]" + --enable-backends enable all available backends no|yes|mod" ac_help="$ac_help - --enable-bdb enable Berkeley DB backend no|yes|mod [yes]" + --enable-bdb enable Berkeley DB backend no|yes|mod [${ol_dflt_backends-yes}]" ac_help="$ac_help - --enable-dnssrv enable dnssrv backend no|yes|mod [no]" + --enable-dnssrv enable dnssrv backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help - --enable-hdb enable Hierarchical DB backend no|yes|mod [yes]" + --enable-hdb enable Hierarchical DB backend no|yes|mod [${ol_dflt_backends-yes}]" ac_help="$ac_help - --enable-ldap enable ldap backend no|yes|mod [no]" + --enable-ldap enable ldap backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help - --enable-ldbm enable ldbm backend no|yes|mod [no]" + --enable-ldbm enable ldbm backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help --with-ldbm-api with LDBM API auto|berkeley|bcompat|mdbm|gdbm [auto]" ac_help="$ac_help --with-ldbm-type use LDBM type auto|btree|hash [auto]" ac_help="$ac_help - --enable-meta enable metadirectory backend no|yes|mod [no]" + --enable-meta enable metadirectory backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help - --enable-monitor enable monitor backend no|yes|mod [yes]" + --enable-monitor enable monitor backend no|yes|mod [${ol_dflt_backends-yes}]" ac_help="$ac_help - --enable-null enable null backend no|yes|mod [no]" + --enable-null enable null backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help - --enable-passwd enable passwd backend no|yes|mod [no]" + --enable-passwd enable passwd backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help - --enable-perl enable perl backend no|yes|mod [no]" + --enable-perl enable perl backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help - --enable-relay enable relay backend no|yes|mod [yes]" + --enable-relay enable relay backend no|yes|mod [${ol_dflt_backends-yes}]" ac_help="$ac_help - --enable-shell enable shell backend no|yes|mod [no]" + --enable-shell enable shell backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help - --enable-sql enable sql backend no|yes|mod [no]" + --enable-sql enable sql backend no|yes|mod [${ol_dflt_backends-no}]" ac_help="$ac_help SLAPD Overlay Options:" ac_help="$ac_help - --enable-overlays enable all available overlays no|yes|mod [no]" + --enable-overlays enable all available overlays no|yes|mod" ac_help="$ac_help - --enable-accesslog In-Directory Access Logging overlay no|yes|mod [no]" + --enable-accesslog In-Directory Access Logging overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-denyop Deny Operation overlay no|yes|mod [no]" + --enable-denyop Deny Operation overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-dyngroup Dynamic Group overlay no|yes|mod [no]" + --enable-dyngroup Dynamic Group overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-dynlist Dynamic List overlay no|yes|mod [no]" + --enable-dynlist Dynamic List overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-glue Backend Glue overlay no|yes|mod [yes]" + --enable-glue Backend Glue overlay no|yes|mod [${ol_dflt_overlays-yes}]" ac_help="$ac_help - --enable-lastmod Last Modification overlay no|yes|mod [no]" + --enable-lastmod Last Modification overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-ppolicy Password Policy overlay no|yes|mod [no]" + --enable-ppolicy Password Policy overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-proxycache Proxy Cache overlay no|yes|mod [no]" + --enable-proxycache Proxy Cache overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-refint Referential Integrity overlay no|yes|mod [no]" + --enable-refint Referential Integrity overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-rwm Rewrite/Remap overlay no|yes|mod [no]" + --enable-retcode Return Code testing overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-syncprov Syncrepl Provider overlay no|yes|mod [yes]" + --enable-rwm Rewrite/Remap overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help - --enable-translucent Translucent Proxy overlay no|yes|mod [no]" + --enable-syncprov Syncrepl Provider overlay no|yes|mod [${ol_dflt_overlays-yes}]" ac_help="$ac_help - --enable-unique Attribute Uniqueness overlay no|yes|mod [no]" + --enable-translucent Translucent Proxy overlay no|yes|mod [${ol_dflt_overlays-no}]" +ac_help="$ac_help + --enable-unique Attribute Uniqueness overlay no|yes|mod [${ol_dflt_overlays-no}]" ac_help="$ac_help SLURPD (Replication Daemon) Options:" @@ -893,7 +895,7 @@ echo "Configuring ${TB}${OL_STRING}${TN} ${OPENLDAP_CVS}..." echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:897: checking host system type" >&5 +echo "configure:899: checking host system type" >&5 if test "x$ac_cv_host" = "x" || (test "x$host" != "xNONE" && test "x$host" != "x$ac_cv_host_alias"); then # Make sure we can run config.sub. @@ -934,7 +936,7 @@ host_os=$ac_cv_host_os echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:938: checking target system type" >&5 +echo "configure:940: checking target system type" >&5 if test "x$ac_cv_target" = "x" || (test "x$target" != "xNONE" && test "x$target" != "x$ac_cv_target_alias"); then # Make sure we can run config.sub. @@ -974,7 +976,7 @@ target_os=$ac_cv_target_os echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:978: checking build system type" >&5 +echo "configure:980: checking build system type" >&5 if test "x$ac_cv_build" = "x" || (test "x$build" != "xNONE" && test "x$build" != "x$ac_cv_build_alias"); then # Make sure we can run config.sub. @@ -1051,7 +1053,7 @@ test "$host_alias" != "$target_alias" && # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1055: checking for a BSD compatible install" >&5 +echo "configure:1057: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"\${ac_cv_path_install+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1108,7 +1110,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:1112: checking whether build environment is sane" >&5 +echo "configure:1114: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -1169,7 +1171,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1173: checking for $ac_word" >&5 +echo "configure:1175: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_AWK+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1199,7 +1201,7 @@ test -n "$AWK" && break done echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:1203: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:1205: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1239,7 +1241,7 @@ fi missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:1243: checking for working aclocal" >&5 +echo "configure:1245: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1252,7 +1254,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:1256: checking for working autoconf" >&5 +echo "configure:1258: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1265,7 +1267,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:1269: checking for working automake" >&5 +echo "configure:1271: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1278,7 +1280,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:1282: checking for working autoheader" >&5 +echo "configure:1284: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1291,7 +1293,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:1295: checking for working makeinfo" >&5 +echo "configure:1297: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1311,7 +1313,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1315: checking for $ac_word" >&5 +echo "configure:1317: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_AMTAR+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1383,7 +1385,7 @@ OPENLDAP_RELEASE_DATE="$OL_RELEASE_DATE" echo $ac_n "checking configure arguments""... $ac_c" 1>&6 -echo "configure:1387: checking configure arguments" >&5 +echo "configure:1389: checking configure arguments" >&5 top_builddir=`pwd` @@ -1936,10 +1938,9 @@ if test "${enable_backends+set}" = set; then fi ol_enable_backends="$ol_arg" -else - ol_enable_backends="no" fi # end --enable-backends +test -n "$ol_enable_backends" && ol_dflt_backends="$ol_enable_backends" # OpenLDAP --enable-bdb # Check whether --enable-bdb or --disable-bdb was given. if test "${enable_bdb+set}" = set; then @@ -1957,7 +1958,7 @@ if test "${enable_bdb+set}" = set; then ol_enable_bdb="$ol_arg" else - ol_enable_bdb="yes" + ol_enable_bdb="${ol_dflt_backends-yes}" fi # end --enable-bdb # OpenLDAP --enable-dnssrv @@ -1977,7 +1978,7 @@ if test "${enable_dnssrv+set}" = set; then ol_enable_dnssrv="$ol_arg" else - ol_enable_dnssrv="no" + ol_enable_dnssrv="${ol_dflt_backends-no}" fi # end --enable-dnssrv # OpenLDAP --enable-hdb @@ -1997,7 +1998,7 @@ if test "${enable_hdb+set}" = set; then ol_enable_hdb="$ol_arg" else - ol_enable_hdb="yes" + ol_enable_hdb="${ol_dflt_backends-yes}" fi # end --enable-hdb # OpenLDAP --enable-ldap @@ -2017,7 +2018,7 @@ if test "${enable_ldap+set}" = set; then ol_enable_ldap="$ol_arg" else - ol_enable_ldap="no" + ol_enable_ldap="${ol_dflt_backends-no}" fi # end --enable-ldap # OpenLDAP --enable-ldbm @@ -2037,7 +2038,7 @@ if test "${enable_ldbm+set}" = set; then ol_enable_ldbm="$ol_arg" else - ol_enable_ldbm="no" + ol_enable_ldbm="${ol_dflt_backends-no}" fi # end --enable-ldbm # OpenLDAP --with-ldbm_api @@ -2099,7 +2100,7 @@ if test "${enable_meta+set}" = set; then ol_enable_meta="$ol_arg" else - ol_enable_meta="no" + ol_enable_meta="${ol_dflt_backends-no}" fi # end --enable-meta # OpenLDAP --enable-monitor @@ -2119,7 +2120,7 @@ if test "${enable_monitor+set}" = set; then ol_enable_monitor="$ol_arg" else - ol_enable_monitor="yes" + ol_enable_monitor="${ol_dflt_backends-yes}" fi # end --enable-monitor # OpenLDAP --enable-null @@ -2139,7 +2140,7 @@ if test "${enable_null+set}" = set; then ol_enable_null="$ol_arg" else - ol_enable_null="no" + ol_enable_null="${ol_dflt_backends-no}" fi # end --enable-null # OpenLDAP --enable-passwd @@ -2159,7 +2160,7 @@ if test "${enable_passwd+set}" = set; then ol_enable_passwd="$ol_arg" else - ol_enable_passwd="no" + ol_enable_passwd="${ol_dflt_backends-no}" fi # end --enable-passwd # OpenLDAP --enable-perl @@ -2179,7 +2180,7 @@ if test "${enable_perl+set}" = set; then ol_enable_perl="$ol_arg" else - ol_enable_perl="no" + ol_enable_perl="${ol_dflt_backends-no}" fi # end --enable-perl # OpenLDAP --enable-relay @@ -2199,7 +2200,7 @@ if test "${enable_relay+set}" = set; then ol_enable_relay="$ol_arg" else - ol_enable_relay="yes" + ol_enable_relay="${ol_dflt_backends-yes}" fi # end --enable-relay # OpenLDAP --enable-shell @@ -2219,7 +2220,7 @@ if test "${enable_shell+set}" = set; then ol_enable_shell="$ol_arg" else - ol_enable_shell="no" + ol_enable_shell="${ol_dflt_backends-no}" fi # end --enable-shell # OpenLDAP --enable-sql @@ -2239,12 +2240,12 @@ if test "${enable_sql+set}" = set; then ol_enable_sql="$ol_arg" else - ol_enable_sql="no" + ol_enable_sql="${ol_dflt_backends-no}" fi # end --enable-sql Overlays="accesslog denyop dyngroup dynlist glue lastmod ppolicy proxycache \ - refint rwm syncprov translucent unique" + refint retcode rwm syncprov translucent unique" # Check whether --with-xxslapoverlays or --without-xxslapoverlays was given. if test "${with_xxslapoverlays+set}" = set; then @@ -2269,10 +2270,9 @@ if test "${enable_overlays+set}" = set; then fi ol_enable_overlays="$ol_arg" -else - ol_enable_overlays="no" fi # end --enable-overlays +test -n "$ol_enable_overlays" && ol_dflt_overlays="$ol_enable_overlays" # OpenLDAP --enable-accesslog # Check whether --enable-accesslog or --disable-accesslog was given. if test "${enable_accesslog+set}" = set; then @@ -2290,7 +2290,7 @@ if test "${enable_accesslog+set}" = set; then ol_enable_accesslog="$ol_arg" else - ol_enable_accesslog="no" + ol_enable_accesslog="${ol_dflt_overlays-no}" fi # end --enable-accesslog @@ -2311,7 +2311,7 @@ if test "${enable_denyop+set}" = set; then ol_enable_denyop="$ol_arg" else - ol_enable_denyop="no" + ol_enable_denyop="${ol_dflt_overlays-no}" fi # end --enable-denyop @@ -2332,7 +2332,7 @@ if test "${enable_dyngroup+set}" = set; then ol_enable_dyngroup="$ol_arg" else - ol_enable_dyngroup="no" + ol_enable_dyngroup="${ol_dflt_overlays-no}" fi # end --enable-dyngroup @@ -2353,7 +2353,7 @@ if test "${enable_dynlist+set}" = set; then ol_enable_dynlist="$ol_arg" else - ol_enable_dynlist="no" + ol_enable_dynlist="${ol_dflt_overlays-no}" fi # end --enable-dynlist @@ -2374,7 +2374,7 @@ if test "${enable_glue+set}" = set; then ol_enable_glue="$ol_arg" else - ol_enable_glue="yes" + ol_enable_glue="${ol_dflt_overlays-yes}" fi # end --enable-glue @@ -2395,7 +2395,7 @@ if test "${enable_lastmod+set}" = set; then ol_enable_lastmod="$ol_arg" else - ol_enable_lastmod="no" + ol_enable_lastmod="${ol_dflt_overlays-no}" fi # end --enable-lastmod @@ -2416,7 +2416,7 @@ if test "${enable_ppolicy+set}" = set; then ol_enable_ppolicy="$ol_arg" else - ol_enable_ppolicy="no" + ol_enable_ppolicy="${ol_dflt_overlays-no}" fi # end --enable-ppolicy @@ -2437,7 +2437,7 @@ if test "${enable_proxycache+set}" = set; then ol_enable_proxycache="$ol_arg" else - ol_enable_proxycache="no" + ol_enable_proxycache="${ol_dflt_overlays-no}" fi # end --enable-proxycache @@ -2458,10 +2458,31 @@ if test "${enable_refint+set}" = set; then ol_enable_refint="$ol_arg" else - ol_enable_refint="no" + ol_enable_refint="${ol_dflt_overlays-no}" fi # end --enable-refint +# OpenLDAP --enable-retcode + # Check whether --enable-retcode or --disable-retcode was given. +if test "${enable_retcode+set}" = set; then + enableval="$enable_retcode" + + ol_arg=invalid + for ol_val in no yes mod ; do + if test "$enableval" = "$ol_val" ; then + ol_arg="$ol_val" + fi + done + if test "$ol_arg" = "invalid" ; then + { echo "configure: error: bad value $enableval for --enable-retcode" 1>&2; exit 1; } + fi + ol_enable_retcode="$ol_arg" + +else + ol_enable_retcode="${ol_dflt_overlays-no}" +fi +# end --enable-retcode + # OpenLDAP --enable-rwm # Check whether --enable-rwm or --disable-rwm was given. if test "${enable_rwm+set}" = set; then @@ -2479,7 +2500,7 @@ if test "${enable_rwm+set}" = set; then ol_enable_rwm="$ol_arg" else - ol_enable_rwm="no" + ol_enable_rwm="${ol_dflt_overlays-no}" fi # end --enable-rwm @@ -2500,7 +2521,7 @@ if test "${enable_syncprov+set}" = set; then ol_enable_syncprov="$ol_arg" else - ol_enable_syncprov="yes" + ol_enable_syncprov="${ol_dflt_overlays-yes}" fi # end --enable-syncprov @@ -2521,7 +2542,7 @@ if test "${enable_translucent+set}" = set; then ol_enable_translucent="$ol_arg" else - ol_enable_translucent="no" + ol_enable_translucent="${ol_dflt_overlays-no}" fi # end --enable-translucent @@ -2542,7 +2563,7 @@ if test "${enable_unique+set}" = set; then ol_enable_unique="$ol_arg" else - ol_enable_unique="no" + ol_enable_unique="${ol_dflt_overlays-no}" fi # end --enable-unique @@ -2629,34 +2650,14 @@ fi -# Activate any backends that were not explicitly enabled. -# Note that back_bdb defaults to "yes" so this loop won't touch it. -if test $ol_enable_backends != no ; then - for i in $Backends; do - eval "ol_tmp=\$ol_enable_$i" - if test $ol_tmp = no ; then - eval "ol_enable_$i=$ol_enable_backends" - fi - done -fi -# Activate the overlays -if test $ol_enable_overlays != no ; then - for i in $Overlays; do - eval "ol_tmp=\$ol_enable_$i" - if test $ol_tmp = no ; then - eval "ol_enable_$i=$ol_enable_overlays" - fi - done -fi - # validate options if test $ol_enable_slapd = no ; then if test $ol_enable_slapi = yes ; then echo "configure: warning: slapd disabled, ignoring --enable-slapi argument" 1>&2 fi - if test $ol_enable_backends != no ; then + case "$ol_enable_backends" in yes | mod) echo "configure: warning: slapd disabled, ignoring --enable-backends argument" 1>&2 - fi + esac for i in $Backends; do eval "ol_tmp=\$ol_enable_$i" if test $ol_tmp != no ; then @@ -2691,9 +2692,9 @@ if test $ol_enable_slapd = no ; then if test $ol_enable_rewrite = yes ; then echo "configure: warning: slapd disabled, ignoring --enable-rewrite argument" 1>&2 fi - if test $ol_enable_overlays != no ; then + case "$ol_enable_overlays" in yes | mod) echo "configure: warning: slapd disabled, ignoring --enable-overlays argument" 1>&2 - fi + esac for i in $Overlays; do eval "ol_tmp=\$ol_enable_$i" if test $ol_tmp != no ; then @@ -2705,8 +2706,8 @@ if test $ol_enable_slapd = no ; then # force settings to no ol_enable_slapi=no - ol_enable_backends=no - ol_enable_overlays=no + ol_enable_backends= + ol_enable_overlays= ol_enable_modules=no ol_enable_multimaster=no ol_enable_rlookups=no @@ -2862,6 +2863,7 @@ BUILD_LASTMOD=no BUILD_PPOLICY=no BUILD_PROXYCACHE=no BUILD_REFINT=no +BUILD_RETCODE=no BUILD_RWM=no BUILD_SYNCPROV=no BUILD_TRANSLUCENT=no @@ -2922,7 +2924,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2926: checking for $ac_word" >&5 +echo "configure:2928: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2974,7 +2976,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2978: checking for $ac_word" >&5 +echo "configure:2980: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3016,7 +3018,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3020: checking for $ac_word" >&5 +echo "configure:3022: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_AR+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3066,12 +3068,12 @@ if test "X${PATH_SEPARATOR+set}" != Xset; then fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:3070: checking for Cygwin environment" >&5 +echo "configure:3072: checking for Cygwin environment" >&5 if eval "test \"\${ac_cv_cygwin+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -3098,19 +3100,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:3102: checking for mingw32 environment" >&5 +echo "configure:3104: checking for mingw32 environment" >&5 if eval "test \"\${ac_cv_mingw32+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3116: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -3126,19 +3128,19 @@ echo "$ac_t""$ac_cv_mingw32" 1>&6 MINGW32= test "$ac_cv_mingw32" = yes && MINGW32=yes echo $ac_n "checking for EMX OS/2 environment""... $ac_c" 1>&6 -echo "configure:3130: checking for EMX OS/2 environment" >&5 +echo "configure:3132: checking for EMX OS/2 environment" >&5 if eval "test \"\${ac_cv_emxos2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3144: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_emxos2=yes else @@ -3154,7 +3156,7 @@ echo "$ac_t""$ac_cv_emxos2" 1>&6 EMXOS2= test "$ac_cv_emxos2" = yes && EMXOS2=yes echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:3158: checking how to run the C preprocessor" >&5 +echo "configure:3160: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -3169,13 +3171,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3179: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3181: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -3186,13 +3188,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3196: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3198: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -3203,13 +3205,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3213: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3215: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -3259,7 +3261,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3263: checking for $ac_word" >&5 +echo "configure:3265: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3289,7 +3291,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3293: checking for $ac_word" >&5 +echo "configure:3295: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3340,7 +3342,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3344: checking for $ac_word" >&5 +echo "configure:3346: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3372,7 +3374,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:3376: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5 +echo "configure:3378: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -3383,12 +3385,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 3387 "configure" +#line 3389 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:3392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -3414,12 +3416,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:3418: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:3420: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:3423: checking whether we are using GNU C" >&5 +echo "configure:3425: checking whether we are using GNU C" >&5 if eval "test \"\${ac_cv_prog_gcc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3428,7 +3430,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:3432: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:3434: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -3447,7 +3449,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:3451: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:3453: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"\${ac_cv_prog_cc_g+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3490,7 +3492,7 @@ ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:3494: checking for ld used by GCC" >&5 +echo "configure:3496: checking for ld used by GCC" >&5 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw @@ -3520,10 +3522,10 @@ echo "configure:3494: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:3524: checking for GNU ld" >&5 +echo "configure:3526: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:3527: checking for non-GNU ld" >&5 +echo "configure:3529: checking for non-GNU ld" >&5 fi if eval "test \"\${lt_cv_path_LD+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3558,7 +3560,7 @@ else fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:3562: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:3564: checking if the linker ($LD) is GNU ld" >&5 if eval "test \"\${lt_cv_prog_gnu_ld+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3575,7 +3577,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6 -echo "configure:3579: checking for $LD option to reload object files" >&5 +echo "configure:3581: checking for $LD option to reload object files" >&5 if eval "test \"\${lt_cv_ld_reload_flag+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3587,7 +3589,7 @@ reload_flag=$lt_cv_ld_reload_flag test -n "$reload_flag" && reload_flag=" $reload_flag" echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:3591: checking for BSD-compatible nm" >&5 +echo "configure:3593: checking for BSD-compatible nm" >&5 if eval "test \"\${lt_cv_path_NM+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3625,7 +3627,7 @@ NM="$lt_cv_path_NM" echo "$ac_t""$NM" 1>&6 echo $ac_n "checking for a sed that does not truncate output""... $ac_c" 1>&6 -echo "configure:3629: checking for a sed that does not truncate output" >&5 +echo "configure:3631: checking for a sed that does not truncate output" >&5 if eval "test \"\${lt_cv_path_SED+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3709,7 +3711,7 @@ fi echo "$ac_t""$SED" 1>&6 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:3713: checking whether ln -s works" >&5 +echo "configure:3715: checking whether ln -s works" >&5 if eval "test \"\${ac_cv_prog_LN_S+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3730,7 +3732,7 @@ else fi echo $ac_n "checking how to recognise dependent libraries""... $ac_c" 1>&6 -echo "configure:3734: checking how to recognise dependent libraries" >&5 +echo "configure:3736: checking how to recognise dependent libraries" >&5 if eval "test \"\${lt_cv_deplibs_check_method+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3920,13 +3922,13 @@ file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:3924: checking for object suffix" >&5 +echo "configure:3926: checking for object suffix" >&5 if eval "test \"\${ac_cv_objext+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:3930: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3932: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -3947,7 +3949,7 @@ ac_objext=$ac_cv_objext echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:3951: checking for executable suffix" >&5 +echo "configure:3953: checking for executable suffix" >&5 if eval "test \"\${ac_cv_exeext+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3957,7 +3959,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:3961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:3963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.C | *.o | *.obj | *.xcoff) ;; @@ -3988,7 +3990,7 @@ fi # Check for command to grab the raw symbol name followed by C symbol from nm. echo $ac_n "checking command to parse $NM output""... $ac_c" 1>&6 -echo "configure:3992: checking command to parse $NM output" >&5 +echo "configure:3994: checking command to parse $NM output" >&5 if eval "test \"\${lt_cv_sys_global_symbol_pipe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4071,10 +4073,10 @@ void nm_test_func(){} int main(){nm_test_var='a';nm_test_func();return(0);} EOF - if { (eval echo configure:4075: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + if { (eval echo configure:4077: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then # Now try to grab the symbols. nlist=conftest.nm - if { (eval echo configure:4078: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then + if { (eval echo configure:4080: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -4125,7 +4127,7 @@ EOF save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$no_builtin_flag" - if { (eval echo configure:4129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest$ac_exeext; then + if { (eval echo configure:4131: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS="$save_LIBS" @@ -4174,17 +4176,17 @@ for ac_hdr in dlfcn.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4178: checking for $ac_hdr" >&5 +echo "configure:4180: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4188: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4190: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4220,7 +4222,7 @@ case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6 -echo "configure:4224: checking for ${ac_tool_prefix}file" >&5 +echo "configure:4226: checking for ${ac_tool_prefix}file" >&5 if eval "test \"\${lt_cv_path_MAGIC_CMD+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4282,7 +4284,7 @@ fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then echo $ac_n "checking for file""... $ac_c" 1>&6 -echo "configure:4286: checking for file" >&5 +echo "configure:4288: checking for file" >&5 if eval "test \"\${lt_cv_path_MAGIC_CMD+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4353,7 +4355,7 @@ esac # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4357: checking for $ac_word" >&5 +echo "configure:4359: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4385,7 +4387,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4389: checking for $ac_word" >&5 +echo "configure:4391: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4420,7 +4422,7 @@ fi # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4424: checking for $ac_word" >&5 +echo "configure:4426: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_STRIP+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4452,7 +4454,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4456: checking for $ac_word" >&5 +echo "configure:4458: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_STRIP+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4501,8 +4503,8 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 4505 "configure"' > conftest.$ac_ext - if { (eval echo configure:4506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 4507 "configure"' > conftest.$ac_ext + if { (eval echo configure:4508: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" @@ -4523,7 +4525,7 @@ case $host in SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:4527: checking whether the C compiler needs -belf" >&5 +echo "configure:4529: checking whether the C compiler needs -belf" >&5 if eval "test \"\${lt_cv_cc_needs_belf+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4536,14 +4538,14 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_needs_belf=yes else @@ -4573,7 +4575,7 @@ echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4577: checking for $ac_word" >&5 +echo "configure:4579: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_DLLTOOL+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4605,7 +4607,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4609: checking for $ac_word" >&5 +echo "configure:4611: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_DLLTOOL+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4640,7 +4642,7 @@ fi # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4644: checking for $ac_word" >&5 +echo "configure:4646: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_AS+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4672,7 +4674,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4676: checking for $ac_word" >&5 +echo "configure:4678: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_AS+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4707,7 +4709,7 @@ fi # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4711: checking for $ac_word" >&5 +echo "configure:4713: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_OBJDUMP+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4739,7 +4741,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4743: checking for $ac_word" >&5 +echo "configure:4745: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_OBJDUMP+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4775,12 +4777,12 @@ fi # recent cygwin and mingw systems supply a stub DllMain which the user # can override, but on older systems we have to supply one echo $ac_n "checking if libtool should supply DllMain function""... $ac_c" 1>&6 -echo "configure:4779: checking if libtool should supply DllMain function" >&5 +echo "configure:4781: checking if libtool should supply DllMain function" >&5 if eval "test \"\${lt_cv_need_dllmain+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_need_dllmain=no else @@ -4809,19 +4811,19 @@ echo "$ac_t""$lt_cv_need_dllmain" 1>&6 SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mdll" echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6 -echo "configure:4813: checking how to link DLLs" >&5 +echo "configure:4815: checking how to link DLLs" >&5 if eval "test \"\${lt_cv_cc_dll_switch+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_dll_switch=-mdll else @@ -4935,7 +4937,7 @@ set dummy $CC compiler="$2" echo $ac_n "checking for objdir""... $ac_c" 1>&6 -echo "configure:4939: checking for objdir" >&5 +echo "configure:4941: checking for objdir" >&5 rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then @@ -4962,7 +4964,7 @@ test -z "$pic_mode" && pic_mode=default # in isolation, and that seeing it set (from the cache) indicates that # the associated values are set (in the cache) correctly too. echo $ac_n "checking for $compiler option to produce PIC""... $ac_c" 1>&6 -echo "configure:4966: checking for $compiler option to produce PIC" >&5 +echo "configure:4968: checking for $compiler option to produce PIC" >&5 if eval "test \"\${lt_cv_prog_cc_pic+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5114,21 +5116,21 @@ else # Check to make sure the pic_flag actually works. echo $ac_n "checking if $compiler PIC flag $lt_cv_prog_cc_pic works""... $ac_c" 1>&6 -echo "configure:5118: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5 +echo "configure:5120: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5 if eval "test \"\${lt_cv_prog_cc_pic_works+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5134: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* case $host_os in hpux9* | hpux10* | hpux11*) @@ -5180,7 +5182,7 @@ if test -n "$lt_cv_prog_cc_shlib"; then fi echo $ac_n "checking if $compiler static flag $lt_cv_prog_cc_static works""... $ac_c" 1>&6 -echo "configure:5184: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5 +echo "configure:5186: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5 if eval "test \"\${lt_cv_prog_cc_static_works+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5188,14 +5190,14 @@ else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5201: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_prog_cc_static_works=yes else @@ -5222,7 +5224,7 @@ can_build_shared="$lt_cv_prog_cc_can_build_shared" # Check to see if options -o and -c are simultaneously supported by compiler echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6 -echo "configure:5226: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo "configure:5228: checking if $compiler supports -c -o file.$ac_objext" >&5 if eval "test \"\${lt_cv_compiler_c_o+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5241,7 +5243,7 @@ chmod -w . save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" compiler_c_o=no -if { (eval echo configure:5245: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then +if { (eval echo configure:5247: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s out/conftest.err; then @@ -5270,7 +5272,7 @@ echo "$ac_t""$compiler_c_o" 1>&6 if test x"$compiler_c_o" = x"yes"; then # Check to see if we can write to a .lo echo $ac_n "checking if $compiler supports -c -o file.lo""... $ac_c" 1>&6 -echo "configure:5274: checking if $compiler supports -c -o file.lo" >&5 +echo "configure:5276: checking if $compiler supports -c -o file.lo" >&5 if eval "test \"\${lt_cv_compiler_o_lo+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5281,14 +5283,14 @@ else save_objext="$ac_objext" ac_objext=lo cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5294: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -5319,7 +5321,7 @@ hard_links="nottested" if test "$compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user echo $ac_n "checking if we can lock with hard links""... $ac_c" 1>&6 -echo "configure:5323: checking if we can lock with hard links" >&5 +echo "configure:5325: checking if we can lock with hard links" >&5 hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no @@ -5338,20 +5340,20 @@ fi if test "$GCC" = yes; then # Check to see if options -fno-rtti -fno-exceptions are supported by compiler echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions""... $ac_c" 1>&6 -echo "configure:5342: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo "configure:5344: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 echo "int some_variable = 0;" > conftest.$ac_ext save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" compiler_rtti_exceptions=no cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5357: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -5378,7 +5380,7 @@ fi # See if the linker supports building shared libraries. echo $ac_n "checking whether the linker ($LD) supports shared libraries""... $ac_c" 1>&6 -echo "configure:5382: checking whether the linker ($LD) supports shared libraries" >&5 +echo "configure:5384: checking whether the linker ($LD) supports shared libraries" >&5 allow_undefined_flag= no_undefined_flag= @@ -6083,7 +6085,7 @@ test "$ld_shlibs" = no && can_build_shared=no # Check hardcoding attributes. echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6 -echo "configure:6087: checking how to hardcode library paths into programs" >&5 +echo "configure:6089: checking how to hardcode library paths into programs" >&5 hardcode_action= if test -n "$hardcode_libdir_flag_spec" || \ test -n "$runpath_var"; then @@ -6111,7 +6113,7 @@ echo "$ac_t""$hardcode_action" 1>&6 striplib= old_striplib= echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6 -echo "configure:6115: checking whether stripping libraries is possible" >&5 +echo "configure:6117: checking whether stripping libraries is possible" >&5 if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" @@ -6125,7 +6127,7 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown # PORTME Fill in your ld.so characteristics echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6 -echo "configure:6129: checking dynamic linker characteristics" >&5 +echo "configure:6131: checking dynamic linker characteristics" >&5 library_names_spec= libname_spec='lib$name' soname_spec= @@ -6547,11 +6549,11 @@ test "$dynamic_linker" = no && can_build_shared=no # Report the final consequences. echo $ac_n "checking if libtool supports shared libraries""... $ac_c" 1>&6 -echo "configure:6551: checking if libtool supports shared libraries" >&5 +echo "configure:6553: checking if libtool supports shared libraries" >&5 echo "$ac_t""$can_build_shared" 1>&6 echo $ac_n "checking whether to build shared libraries""... $ac_c" 1>&6 -echo "configure:6555: checking whether to build shared libraries" >&5 +echo "configure:6557: checking whether to build shared libraries" >&5 test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and @@ -6574,7 +6576,7 @@ esac echo "$ac_t""$enable_shared" 1>&6 echo $ac_n "checking whether to build static libraries""... $ac_c" 1>&6 -echo "configure:6578: checking whether to build static libraries" >&5 +echo "configure:6580: checking whether to build static libraries" >&5 # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes echo "$ac_t""$enable_static" 1>&6 @@ -6615,12 +6617,12 @@ else *) echo $ac_n "checking for dllload""... $ac_c" 1>&6 -echo "configure:6619: checking for dllload" >&5 +echo "configure:6621: checking for dllload" >&5 if eval "test \"\${ac_cv_func_dllload+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_dllload=yes" else @@ -6662,12 +6664,12 @@ if eval "test \"`echo '$ac_cv_func_'dllload`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for shl_load""... $ac_c" 1>&6 -echo "configure:6666: checking for shl_load" >&5 +echo "configure:6668: checking for shl_load" >&5 if eval "test \"\${ac_cv_func_shl_load+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_shl_load=yes" else @@ -6709,7 +6711,7 @@ if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 -echo "configure:6713: checking for shl_load in -ldld" >&5 +echo "configure:6715: checking for shl_load in -ldld" >&5 ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6717,7 +6719,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldld $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6747,12 +6749,12 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:6751: checking for dlopen" >&5 +echo "configure:6753: checking for dlopen" >&5 if eval "test \"\${ac_cv_func_dlopen+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_dlopen=yes" else @@ -6794,7 +6796,7 @@ if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:6798: checking for dlopen in -ldl" >&5 +echo "configure:6800: checking for dlopen in -ldl" >&5 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6802,7 +6804,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6832,7 +6834,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dlopen in -lsvld""... $ac_c" 1>&6 -echo "configure:6836: checking for dlopen in -lsvld" >&5 +echo "configure:6838: checking for dlopen in -lsvld" >&5 ac_lib_var=`echo svld'_'dlopen | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6840,7 +6842,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsvld $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6870,7 +6872,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 -echo "configure:6874: checking for dld_link in -ldld" >&5 +echo "configure:6876: checking for dld_link in -ldld" >&5 ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6878,7 +6880,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldld $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6948,7 +6950,7 @@ fi LIBS="$lt_cv_dlopen_libs $LIBS" echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 -echo "configure:6952: checking whether a program can dlopen itself" >&5 +echo "configure:6954: checking whether a program can dlopen itself" >&5 if eval "test \"\${lt_cv_dlopen_self+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6958,7 +6960,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then + if { (eval echo configure:7025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? case x$lt_status in @@ -7042,7 +7044,7 @@ echo "$ac_t""$lt_cv_dlopen_self" 1>&6 if test "x$lt_cv_dlopen_self" = xyes; then LDFLAGS="$LDFLAGS $link_static_flag" echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 -echo "configure:7046: checking whether a statically linked program can dlopen itself" >&5 +echo "configure:7048: checking whether a statically linked program can dlopen itself" >&5 if eval "test \"\${lt_cv_dlopen_self_static+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7052,7 +7054,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then + if { (eval echo configure:7119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? case x$lt_status in @@ -7162,14 +7164,14 @@ if test "$enable_shared" = yes && test "$GCC" = yes; then # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. echo $ac_n "checking whether -lc should be explicitly linked in""... $ac_c" 1>&6 -echo "configure:7166: checking whether -lc should be explicitly linked in" >&5 +echo "configure:7168: checking whether -lc should be explicitly linked in" >&5 if eval "test \"\${lt_cv_archive_cmds_need_lc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else $rm conftest* echo 'static int dummy;' > conftest.$ac_ext - if { (eval echo configure:7173: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + if { (eval echo configure:7175: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then soname=conftest lib=conftest libobjs=conftest.$ac_objext @@ -7182,7 +7184,7 @@ else libname=conftest save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= - if { (eval echo configure:7186: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; } + if { (eval echo configure:7188: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; } then lt_cv_archive_cmds_need_lc=no else @@ -7772,7 +7774,7 @@ if test $ol_enable_perl != no ; then # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7776: checking for $ac_word" >&5 +echo "configure:7778: checking for $ac_word" >&5 if eval "test \"\${ac_cv_path_PERLBIN+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7825,7 +7827,7 @@ fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:7829: checking how to run the C preprocessor" >&5 +echo "configure:7831: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -7840,13 +7842,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7850: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7852: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -7857,13 +7859,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7867: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7869: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -7874,13 +7876,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7884: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7886: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -7907,12 +7909,12 @@ echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:7911: checking for Cygwin environment" >&5 +echo "configure:7913: checking for Cygwin environment" >&5 if eval "test \"\${ac_cv_cygwin+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7929: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -7939,19 +7941,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:7943: checking for mingw32 environment" >&5 +echo "configure:7945: checking for mingw32 environment" >&5 if eval "test \"\${ac_cv_mingw32+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7957: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -7970,7 +7972,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:7974: checking for executable suffix" >&5 +echo "configure:7976: checking for executable suffix" >&5 if eval "test \"\${ac_cv_exeext+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7980,7 +7982,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:7984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:7986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.C | *.o | *.obj | *.xcoff) ;; @@ -8001,13 +8003,13 @@ echo "$ac_t""${ac_cv_exeext}" 1>&6 ac_exeext=$EXEEXT echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:8005: checking for object suffix" >&5 +echo "configure:8007: checking for object suffix" >&5 if eval "test \"\${ac_cv_objext+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:8011: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:8013: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -8031,7 +8033,7 @@ EOF echo $ac_n "checking for be_app in -lbe""... $ac_c" 1>&6 -echo "configure:8035: checking for be_app in -lbe" >&5 +echo "configure:8037: checking for be_app in -lbe" >&5 ac_lib_var=`echo be'_'be_app | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8039,7 +8041,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lbe -lroot -lnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8076,7 +8078,7 @@ fi echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 -echo "configure:8080: checking for ${CC-cc} option to accept ANSI C" >&5 +echo "configure:8082: checking for ${CC-cc} option to accept ANSI C" >&5 if eval "test \"\${am_cv_prog_cc_stdc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8093,7 +8095,7 @@ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIO do CC="$ac_save_CC $ac_arg" cat > conftest.$ac_ext < #include @@ -8130,7 +8132,7 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } EOF -if { (eval echo configure:8134: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:8136: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_prog_cc_stdc="$ac_arg"; break else @@ -8164,7 +8166,7 @@ if test -z "${MKDEP}"; then OL_MKDEP="${CC-cc}" if test -z "${MKDEP_FLAGS}"; then echo $ac_n "checking for ${OL_MKDEP} depend flag""... $ac_c" 1>&6 -echo "configure:8168: checking for ${OL_MKDEP} depend flag" >&5 +echo "configure:8170: checking for ${OL_MKDEP} depend flag" >&5 if eval "test \"\${ol_cv_mkdep+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8174,7 +8176,7 @@ else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } \ + if { ac_try='$OL_MKDEP $flag conftest.c'; { (eval echo configure:8180: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } \ | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1 then if test ! -f conftest."${ac_object}" ; then @@ -8207,7 +8209,7 @@ if test "${ol_cv_mkdep}" = no ; then fi echo $ac_n "checking for afopen in -ls""... $ac_c" 1>&6 -echo "configure:8211: checking for afopen in -ls" >&5 +echo "configure:8213: checking for afopen in -ls" >&5 ac_lib_var=`echo s'_'afopen | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8215,7 +8217,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ls $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8270,17 +8272,17 @@ if test $ol_enable_modules != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:8274: checking for $ac_hdr" >&5 +echo "configure:8276: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:8284: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8286: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8312,7 +8314,7 @@ done fi echo $ac_n "checking for lt_dlinit in -lltdl""... $ac_c" 1>&6 -echo "configure:8316: checking for lt_dlinit in -lltdl" >&5 +echo "configure:8318: checking for lt_dlinit in -lltdl" >&5 ac_lib_var=`echo ltdl'_'lt_dlinit | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8320,7 +8322,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lltdl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8383,13 +8385,13 @@ fi # test for EBCDIC echo $ac_n "checking for EBCDIC""... $ac_c" 1>&6 -echo "configure:8387: checking for EBCDIC" >&5 +echo "configure:8389: checking for EBCDIC" >&5 if eval "test \"\${ol_cv_cpp_ebcdic+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8404: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8422,12 +8424,12 @@ EOF fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:8426: checking for ANSI C header files" >&5 +echo "configure:8428: checking for ANSI C header files" >&5 if eval "test \"\${ol_cv_header_stdc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -8435,7 +8437,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:8439: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8441: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8452,7 +8454,7 @@ rm -f conftest* if test $ol_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -8470,7 +8472,7 @@ fi if test $ol_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -8491,7 +8493,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #ifndef HAVE_EBCDIC @@ -8509,7 +8511,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:8513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:8515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then : else @@ -8543,12 +8545,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:8547: checking for $ac_hdr that defines DIR" >&5 +echo "configure:8549: checking for $ac_hdr that defines DIR" >&5 if eval "test \"\${ac_cv_header_dirent_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -8556,7 +8558,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:8560: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:8562: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -8581,7 +8583,7 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:8585: checking for opendir in -ldir" >&5 +echo "configure:8587: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8589,7 +8591,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8622,7 +8624,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:8626: checking for opendir in -lx" >&5 +echo "configure:8628: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8630,7 +8632,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8664,12 +8666,12 @@ fi fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:8668: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:8670: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"\${ac_cv_header_sys_wait_h+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -8685,7 +8687,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:8689: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:8691: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -8706,12 +8708,12 @@ EOF fi echo $ac_n "checking POSIX termios""... $ac_c" 1>&6 -echo "configure:8710: checking POSIX termios" >&5 +echo "configure:8712: checking POSIX termios" >&5 if eval "test \"\${am_cv_sys_posix_termios+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -8721,7 +8723,7 @@ int main() { tcgetattr(0, 0); ; return 0; } EOF -if { (eval echo configure:8725: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_sys_posix_termios=yes else @@ -8737,7 +8739,7 @@ echo "$ac_t""$am_cv_sys_posix_termios" 1>&6 echo $ac_n "checking whether use of TIOCGWINSZ requires sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:8741: checking whether use of TIOCGWINSZ requires sys/ioctl.h" >&5 +echo "configure:8743: checking whether use of TIOCGWINSZ requires sys/ioctl.h" >&5 if eval "test \"\${am_cv_sys_tiocgwinsz_needs_sys_ioctl_h+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8746,7 +8748,7 @@ else gwinsz_in_termios_h=no if test $am_cv_sys_posix_termios = yes; then cat > conftest.$ac_ext < # include @@ -8766,7 +8768,7 @@ rm -f conftest* if test $gwinsz_in_termios_h = no; then cat > conftest.$ac_ext < # include @@ -8803,9 +8805,9 @@ fi for ac_hdr in \ arpa/inet.h \ - arpa/nameser.h \ + arpa/nameser.h \ assert.h \ - bits/types.h \ + bits/types.h \ conio.h \ crypt.h \ direct.h \ @@ -8818,7 +8820,7 @@ for ac_hdr in \ libutil.h \ limits.h \ locale.h \ - netinet/tcp.h \ + netinet/tcp.h \ malloc.h \ memory.h \ psap.h \ @@ -8836,11 +8838,11 @@ for ac_hdr in \ sys/errno.h \ sys/ioctl.h \ sys/param.h \ - sys/resource.h \ - sys/select.h \ - sys/socket.h \ + sys/resource.h \ + sys/select.h \ + sys/socket.h \ sys/stat.h \ - sys/syslog.h \ + sys/syslog.h \ sys/time.h \ sys/types.h \ sys/ucred.h \ @@ -8848,23 +8850,24 @@ for ac_hdr in \ syslog.h \ termios.h \ unistd.h \ + utime.h \ winsock.h \ winsock2.h \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:8858: checking for $ac_hdr" >&5 +echo "configure:8861: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:8868: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8871: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8895,12 +8898,12 @@ done for ac_func in sigaction sigset do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8899: checking for $ac_func" >&5 +echo "configure:8902: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8951,7 +8954,7 @@ done if test $ac_cv_func_sigaction = no && test $ac_cv_func_sigaction = no ; then echo $ac_n "checking for sigset in -lV3""... $ac_c" 1>&6 -echo "configure:8955: checking for sigset in -lV3" >&5 +echo "configure:8958: checking for sigset in -lV3" >&5 ac_lib_var=`echo V3'_'sigset | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8959,7 +8962,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lV3 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9001,7 +9004,7 @@ fi if test "$ac_cv_cygwin" != yes && test "$ac_cv_header_winsock_h" = yes; then echo $ac_n "checking for winsock""... $ac_c" 1>&6 -echo "configure:9005: checking for winsock" >&5 +echo "configure:9008: checking for winsock" >&5 if eval "test \"\${ol_cv_winsock+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -9009,7 +9012,7 @@ else for curlib in ws2_32 wsock32; do LIBS="$LIBS -l$curlib" cat > conftest.$ac_ext < @@ -9022,7 +9025,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:9026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_winsock=yes else @@ -9060,12 +9063,12 @@ fi echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:9064: checking for socket" >&5 +echo "configure:9067: checking for socket" >&5 if eval "test \"\${ac_cv_func_socket+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else @@ -9108,7 +9111,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:9112: checking for main in -lsocket" >&5 +echo "configure:9115: checking for main in -lsocket" >&5 ac_lib_var=`echo socket'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9116,14 +9119,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9151,7 +9154,7 @@ else fi echo $ac_n "checking for main in -lnet""... $ac_c" 1>&6 -echo "configure:9155: checking for main in -lnet" >&5 +echo "configure:9158: checking for main in -lnet" >&5 ac_lib_var=`echo net'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9159,14 +9162,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9194,7 +9197,7 @@ else fi echo $ac_n "checking for main in -lnsl_s""... $ac_c" 1>&6 -echo "configure:9198: checking for main in -lnsl_s" >&5 +echo "configure:9201: checking for main in -lnsl_s" >&5 ac_lib_var=`echo nsl_s'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9202,14 +9205,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl_s $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9216: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9237,7 +9240,7 @@ else fi echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:9241: checking for main in -lnsl" >&5 +echo "configure:9244: checking for main in -lnsl" >&5 ac_lib_var=`echo nsl'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9245,14 +9248,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9280,7 +9283,7 @@ else fi echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6 -echo "configure:9284: checking for socket in -linet" >&5 +echo "configure:9287: checking for socket in -linet" >&5 ac_lib_var=`echo inet'_'socket | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9288,7 +9291,7 @@ else ac_save_LIBS="$LIBS" LIBS="-linet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9327,7 +9330,7 @@ else fi echo $ac_n "checking for main in -lgen""... $ac_c" 1>&6 -echo "configure:9331: checking for main in -lgen" >&5 +echo "configure:9334: checking for main in -lgen" >&5 ac_lib_var=`echo gen'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9335,14 +9338,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lgen $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9374,12 +9377,12 @@ fi echo $ac_n "checking for select""... $ac_c" 1>&6 -echo "configure:9378: checking for select" >&5 +echo "configure:9381: checking for select" >&5 if eval "test \"\${ac_cv_func_select+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_select=yes" else @@ -9426,7 +9429,7 @@ fi if test "${ac_cv_header_winsock_h}" != yes; then echo $ac_n "checking types of arguments for select()""... $ac_c" 1>&6 -echo "configure:9430: checking types of arguments for select()" >&5 +echo "configure:9433: checking types of arguments for select()" >&5 if eval "test \"\${ac_cv_func_select_arg234+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -9440,7 +9443,7 @@ else for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do cat > conftest.$ac_ext < @@ -9459,7 +9462,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:9463: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:9466: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_not_found=no ; break 3 else @@ -9503,12 +9506,12 @@ fi for ac_func in poll do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:9507: checking for $ac_func" >&5 +echo "configure:9510: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -9560,17 +9563,17 @@ for ac_hdr in poll.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:9564: checking for $ac_hdr" >&5 +echo "configure:9567: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:9574: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9577: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -9601,17 +9604,17 @@ for ac_hdr in sys/epoll.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:9605: checking for $ac_hdr" >&5 +echo "configure:9608: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:9615: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9618: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -9639,12 +9642,12 @@ done if test "${ac_cv_header_sys_epoll_h}" = yes; then echo $ac_n "checking for epoll system call""... $ac_c" 1>&6 -echo "configure:9643: checking for epoll system call" >&5 +echo "configure:9646: checking for epoll system call" >&5 if test "$cross_compiling" = yes; then echo "$ac_t""no" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:9659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF @@ -9672,13 +9675,13 @@ fi # strerror checks echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6 -echo "configure:9676: checking declaration of sys_errlist" >&5 +echo "configure:9679: checking declaration of sys_errlist" >&5 if eval "test \"\${ol_cv_dcl_sys_errlist+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -9691,7 +9694,7 @@ int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:9695: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:9698: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_dcl_sys_errlist=yes ol_cv_have_sys_errlist=yes @@ -9714,20 +9717,20 @@ EOF echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6 -echo "configure:9718: checking existence of sys_errlist" >&5 +echo "configure:9721: checking existence of sys_errlist" >&5 if eval "test \"\${ol_cv_have_sys_errlist+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:9731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_have_sys_errlist=yes else @@ -9750,12 +9753,12 @@ fi for ac_func in strerror strerror_r do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:9754: checking for $ac_func" >&5 +echo "configure:9757: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -9806,13 +9809,13 @@ done ol_cv_func_strerror_r=no if test "${ac_cv_func_strerror_r}" = yes ; then echo $ac_n "checking non-posix strerror_r""... $ac_c" 1>&6 -echo "configure:9810: checking non-posix strerror_r" >&5 +echo "configure:9813: checking non-posix strerror_r" >&5 if eval "test \"\${ol_cv_nonposix_strerror_r+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -9828,7 +9831,7 @@ rm -f conftest* if test $ol_decl_strerror_r = yes ; then cat > conftest.$ac_ext < int main() { @@ -9839,7 +9842,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:9843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:9846: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_nonposix_strerror_r=yes else @@ -9854,7 +9857,7 @@ rm -f conftest* ol_cv_nonposix_strerror=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:9872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_nonposix_strerror_r=yes else @@ -9891,13 +9894,13 @@ fi elif test "${ac_cv_func_strerror}" = no ; then echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6 -echo "configure:9895: checking declaration of sys_errlist" >&5 +echo "configure:9898: checking declaration of sys_errlist" >&5 if eval "test \"\${ol_cv_dcl_sys_errlist+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -9910,7 +9913,7 @@ int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:9914: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:9917: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_dcl_sys_errlist=yes ol_cv_have_sys_errlist=yes @@ -9933,20 +9936,20 @@ EOF echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6 -echo "configure:9937: checking existence of sys_errlist" >&5 +echo "configure:9940: checking existence of sys_errlist" >&5 if eval "test \"\${ol_cv_have_sys_errlist+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:9950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_have_sys_errlist=yes else @@ -9974,17 +9977,17 @@ for ac_hdr in regex.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:9978: checking for $ac_hdr" >&5 +echo "configure:9981: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:9988: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -10015,14 +10018,14 @@ if test "$ac_cv_header_regex_h" != yes ; then fi echo $ac_n "checking for library containing regfree""... $ac_c" 1>&6 -echo "configure:10019: checking for library containing regfree" >&5 +echo "configure:10022: checking for library containing regfree" >&5 if eval "test \"\${ac_cv_search_regfree+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_func_search_save_LIBS="$LIBS" ac_cv_search_regfree="no" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10040: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_regfree="none required" else @@ -10044,7 +10047,7 @@ rm -f conftest* test "$ac_cv_search_regfree" = "no" && for ac_lib in regex gnuregex; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_regfree="-l$ac_lib" break @@ -10078,7 +10081,7 @@ fi echo $ac_n "checking for compatible POSIX regex""... $ac_c" 1>&6 -echo "configure:10082: checking for compatible POSIX regex" >&5 +echo "configure:10085: checking for compatible POSIX regex" >&5 if eval "test \"\${ol_cv_c_posix_regex+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10087,7 +10090,7 @@ else ol_cv_c_posix_regex=cross else cat > conftest.$ac_ext < @@ -10113,7 +10116,7 @@ main() return rc; } EOF -if { (eval echo configure:10117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:10120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_c_posix_regex=yes else @@ -10139,17 +10142,17 @@ for ac_hdr in sys/uuid.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:10143: checking for $ac_hdr" >&5 +echo "configure:10146: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:10153: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10156: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -10179,14 +10182,14 @@ if test $ac_cv_header_sys_uuid_h = yes ; then save_LIBS="$LIBS" echo $ac_n "checking for library containing uuid_to_str""... $ac_c" 1>&6 -echo "configure:10183: checking for library containing uuid_to_str" >&5 +echo "configure:10186: checking for library containing uuid_to_str" >&5 if eval "test \"\${ac_cv_search_uuid_to_str+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_func_search_save_LIBS="$LIBS" ac_cv_search_uuid_to_str="no" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_uuid_to_str="none required" else @@ -10208,7 +10211,7 @@ rm -f conftest* test "$ac_cv_search_uuid_to_str" = "no" && for ac_lib in uuid; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_uuid_to_str="-l$ac_lib" break @@ -10254,11 +10257,11 @@ fi if test $have_uuid = no ; then echo $ac_n "checking to see if -lrpcrt4 is needed for win32 UUID support""... $ac_c" 1>&6 -echo "configure:10258: checking to see if -lrpcrt4 is needed for win32 UUID support" >&5 +echo "configure:10261: checking to see if -lrpcrt4 is needed for win32 UUID support" >&5 save_LIBS="$LIBS" LIBS="$LIBS -lrpcrt4" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* need_rpcrt=yes else @@ -10291,7 +10294,7 @@ fi ol_cv_lib_resolver=no if test $ol_cv_lib_resolver = no ; then echo $ac_n "checking for resolver link (default)""... $ac_c" 1>&6 -echo "configure:10295: checking for resolver link (default)" >&5 +echo "configure:10298: checking for resolver link (default)" >&5 if eval "test \"\${ol_cv_resolver_none+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10301,7 +10304,7 @@ else LIBS="$ol_RESOLVER_LIB $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10355: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_resolver_none=yes else @@ -10372,7 +10375,7 @@ fi if test $ol_cv_lib_resolver = no ; then echo $ac_n "checking for resolver link (-lresolv)""... $ac_c" 1>&6 -echo "configure:10376: checking for resolver link (-lresolv)" >&5 +echo "configure:10379: checking for resolver link (-lresolv)" >&5 if eval "test \"\${ol_cv_resolver_resolv+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10382,7 +10385,7 @@ else LIBS="$ol_RESOLVER_LIB $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_resolver_resolv=yes else @@ -10453,7 +10456,7 @@ fi if test $ol_cv_lib_resolver = no ; then echo $ac_n "checking for resolver link (-lbind)""... $ac_c" 1>&6 -echo "configure:10457: checking for resolver link (-lbind)" >&5 +echo "configure:10460: checking for resolver link (-lbind)" >&5 if eval "test \"\${ol_cv_resolver_bind+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10463,7 +10466,7 @@ else LIBS="$ol_RESOLVER_LIB $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10517: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_resolver_bind=yes else @@ -10561,12 +10564,12 @@ fi for ac_func in hstrerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:10565: checking for $ac_func" >&5 +echo "configure:10568: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -10618,12 +10621,12 @@ done for ac_func in getaddrinfo getnameinfo gai_strerror inet_ntop do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:10622: checking for $ac_func" >&5 +echo "configure:10625: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10654: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -10679,13 +10682,13 @@ if test $ac_cv_func_getaddrinfo = no -o $ac_cv_func_inet_ntop = no ; then fi elif test $ol_enable_ipv6 != no ; then echo $ac_n "checking INET6_ADDRSTRLEN""... $ac_c" 1>&6 -echo "configure:10683: checking INET6_ADDRSTRLEN" >&5 +echo "configure:10686: checking INET6_ADDRSTRLEN" >&5 if eval "test \"\${ol_cv_inet6_addrstrlen+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -10710,13 +10713,13 @@ echo "$ac_t""$ol_cv_inet6_addrstrlen" 1>&6 echo $ac_n "checking struct sockaddr_storage""... $ac_c" 1>&6 -echo "configure:10714: checking struct sockaddr_storage" >&5 +echo "configure:10717: checking struct sockaddr_storage" >&5 if eval "test \"\${ol_cv_struct_sockaddr_storage+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -10728,7 +10731,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:10732: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:10735: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_struct_sockaddr_storage=yes else @@ -10759,17 +10762,17 @@ if test $ol_enable_local != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:10763: checking for $ac_hdr" >&5 +echo "configure:10766: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:10773: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10776: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -10815,17 +10818,17 @@ if test $ol_with_kerberos = yes -o $ol_with_kerberos = auto \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:10819: checking for $ac_hdr" >&5 +echo "configure:10822: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:10829: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10832: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -10857,17 +10860,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:10861: checking for $ac_hdr" >&5 +echo "configure:10864: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:10871: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10874: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -10901,7 +10904,7 @@ done if test $krb5_impl = mit; then echo $ac_n "checking for main in -lk5crypto""... $ac_c" 1>&6 -echo "configure:10905: checking for main in -lk5crypto" >&5 +echo "configure:10908: checking for main in -lk5crypto" >&5 ac_lib_var=`echo k5crypto'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -10909,14 +10912,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lk5crypto $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -10939,7 +10942,7 @@ fi echo $ac_n "checking for main in -lkrb5""... $ac_c" 1>&6 -echo "configure:10943: checking for main in -lkrb5" >&5 +echo "configure:10946: checking for main in -lkrb5" >&5 ac_lib_var=`echo krb5'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -10947,14 +10950,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lkrb5 -l$krb5crypto -lcom_err $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -10979,7 +10982,7 @@ fi elif test $krb5_impl = heimdal; then echo $ac_n "checking for main in -ldes""... $ac_c" 1>&6 -echo "configure:10983: checking for main in -ldes" >&5 +echo "configure:10986: checking for main in -ldes" >&5 ac_lib_var=`echo des'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -10987,14 +10990,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ldes $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -11017,7 +11020,7 @@ fi echo $ac_n "checking for main in -lkrb5""... $ac_c" 1>&6 -echo "configure:11021: checking for main in -lkrb5" >&5 +echo "configure:11024: checking for main in -lkrb5" >&5 ac_lib_var=`echo krb5'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11025,14 +11028,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lkrb5 -l$krb5crypto -lasn1 -lroken -lcom_err $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -11091,17 +11094,17 @@ if test $ol_link_krb5 = yes -a \( $ol_with_kerberos = yes -o \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11095: checking for $ac_hdr" >&5 +echo "configure:11098: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:11105: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11108: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -11131,7 +11134,7 @@ done if test $ac_cv_header_kerberosIV_krb_h = yes ; then if test $krb5_impl = mit; then echo $ac_n "checking for main in -lkrb4""... $ac_c" 1>&6 -echo "configure:11135: checking for main in -lkrb4" >&5 +echo "configure:11138: checking for main in -lkrb4" >&5 ac_lib_var=`echo krb4'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11139,14 +11142,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lkrb4 -ldes425 -lkrb5 -l$krb5crypto -lcom_err $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -11171,7 +11174,7 @@ fi elif test $krb5_impl = heimdal; then echo $ac_n "checking for main in -lkrb4""... $ac_c" 1>&6 -echo "configure:11175: checking for main in -lkrb4" >&5 +echo "configure:11178: checking for main in -lkrb4" >&5 ac_lib_var=`echo krb4'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11179,14 +11182,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lkrb4 -lkrb5 -l$krb5crypto -lasn1 -lroken -lcom_err $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -11228,7 +11231,7 @@ EOF echo $ac_n "checking for des_debug in Kerberos libraries""... $ac_c" 1>&6 -echo "configure:11232: checking for des_debug in Kerberos libraries" >&5 +echo "configure:11235: checking for des_debug in Kerberos libraries" >&5 if eval "test \"\${ol_cv_var_des_debug+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -11236,7 +11239,7 @@ else save_LIBS="$LIBS" LIBS="$KRB4_LIBS $KRB5_LIBS $LIBS" cat > conftest.$ac_ext < @@ -11249,7 +11252,7 @@ des_debug = 1; ; return 0; } EOF -if { (eval echo configure:11253: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11256: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_var_des_debug=yes else @@ -11288,17 +11291,17 @@ if test $ol_with_kerberos = yes -o $ol_with_kerberos = auto \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11292: checking for $ac_hdr" >&5 +echo "configure:11295: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:11302: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11305: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -11327,7 +11330,7 @@ done if test $ac_cv_header_krb_h = yes ; then echo $ac_n "checking for main in -lkrb""... $ac_c" 1>&6 -echo "configure:11331: checking for main in -lkrb" >&5 +echo "configure:11334: checking for main in -lkrb" >&5 ac_lib_var=`echo krb'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11335,14 +11338,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lkrb -ldes $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -11409,17 +11412,17 @@ if test $ol_with_tls != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11413: checking for $ac_hdr" >&5 +echo "configure:11416: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:11423: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11426: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -11449,7 +11452,7 @@ done if test $ac_cv_header_openssl_ssl_h = yes \ -o $ac_cv_header_ssl_h = yes ; then echo $ac_n "checking for SSLeay_add_ssl_algorithms in -lssl""... $ac_c" 1>&6 -echo "configure:11453: checking for SSLeay_add_ssl_algorithms in -lssl" >&5 +echo "configure:11456: checking for SSLeay_add_ssl_algorithms in -lssl" >&5 ac_lib_var=`echo ssl'_'SSLeay_add_ssl_algorithms | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11457,7 +11460,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lssl -lcrypto $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11475: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -11493,7 +11496,7 @@ fi if test $have_ssleay = no ; then echo $ac_n "checking for SSL_library_init in -lssl""... $ac_c" 1>&6 -echo "configure:11497: checking for SSL_library_init in -lssl" >&5 +echo "configure:11500: checking for SSL_library_init in -lssl" >&5 ac_lib_var=`echo ssl'_'SSL_library_init | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11501,7 +11504,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lssl -lcrypto $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11519: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -11538,7 +11541,7 @@ fi if test $have_ssleay = no ; then echo $ac_n "checking for ssl3_accept in -lssl""... $ac_c" 1>&6 -echo "configure:11542: checking for ssl3_accept in -lssl" >&5 +echo "configure:11545: checking for ssl3_accept in -lssl" >&5 ac_lib_var=`echo ssl'_'ssl3_accept | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11546,7 +11549,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lssl -lcrypto -lRSAglue -lrsaref $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -11602,13 +11605,13 @@ EOF fi fi echo $ac_n "checking OpenSSL library version (CRL checking capability)""... $ac_c" 1>&6 -echo "configure:11606: checking OpenSSL library version (CRL checking capability)" >&5 +echo "configure:11609: checking OpenSSL library version (CRL checking capability)" >&5 if eval "test \"\${ol_cv_ssl_crl_compat+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 -echo "configure:11689: checking for _beginthread" >&5 +echo "configure:11692: checking for _beginthread" >&5 if eval "test \"\${ac_cv_func__beginthread+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__beginthread=yes" else @@ -11770,17 +11773,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11774: checking for $ac_hdr" >&5 +echo "configure:11777: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:11784: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11787: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -11809,13 +11812,13 @@ done if test $ac_cv_header_pthread_h = yes ; then echo $ac_n "checking POSIX thread version""... $ac_c" 1>&6 -echo "configure:11813: checking POSIX thread version" >&5 +echo "configure:11816: checking POSIX thread version" >&5 if eval "test \"\${ol_cv_pthread_version+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -11826,11 +11829,11 @@ int main() { ; return 0; } EOF -if { (eval echo configure:11830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:11833: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat > conftest.$ac_ext < EOF @@ -11850,7 +11853,7 @@ else rm -rf conftest* cat > conftest.$ac_ext < @@ -11867,7 +11870,7 @@ else rm -rf conftest* cat > conftest.$ac_ext < EOF @@ -11879,7 +11882,7 @@ else rm -rf conftest* cat > conftest.$ac_ext < @@ -11926,12 +11929,12 @@ EOF echo $ac_n "checking for LinuxThreads pthread.h""... $ac_c" 1>&6 -echo "configure:11930: checking for LinuxThreads pthread.h" >&5 +echo "configure:11933: checking for LinuxThreads pthread.h" >&5 if eval "test \"\${ol_cv_header_linux_threads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -11958,12 +11961,12 @@ EOF echo $ac_n "checking for GNU Pth pthread.h""... $ac_c" 1>&6 -echo "configure:11962: checking for GNU Pth pthread.h" >&5 +echo "configure:11965: checking for GNU Pth pthread.h" >&5 if eval "test \"\${ol_cv_header_gnu_pth_pthread_h+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifdef _POSIX_THREAD_IS_GNU_PTH @@ -11992,17 +11995,17 @@ echo "$ac_t""$ol_cv_header_gnu_pth_pthread_h" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11996: checking for $ac_hdr" >&5 +echo "configure:11999: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:12006: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:12009: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -12032,14 +12035,14 @@ done echo $ac_n "checking for pthread_create in default libraries""... $ac_c" 1>&6 -echo "configure:12036: checking for pthread_create in default libraries" >&5 +echo "configure:12039: checking for pthread_create in default libraries" >&5 if eval "test \"\${ol_cv_pthread_create+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -12106,7 +12109,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:12110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:12113: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_create=yes else @@ -12118,7 +12121,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -12190,7 +12193,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:12194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:12197: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_create=yes else @@ -12215,7 +12218,7 @@ echo "$ac_t""$ol_cv_pthread_create" 1>&6 if test "$ol_link_threads" = no ; then # try -kthread echo $ac_n "checking for pthread link with -kthread""... $ac_c" 1>&6 -echo "configure:12219: checking for pthread link with -kthread" >&5 +echo "configure:12222: checking for pthread link with -kthread" >&5 if eval "test \"\${ol_cv_pthread_kthread+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -12226,7 +12229,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -12293,7 +12296,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:12297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:12300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_kthread=yes else @@ -12305,7 +12308,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -12377,7 +12380,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:12381: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:12384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_kthread=yes else @@ -12407,7 +12410,7 @@ fi if test "$ol_link_threads" = no ; then # try -pthread echo $ac_n "checking for pthread link with -pthread""... $ac_c" 1>&6 -echo "configure:12411: checking for pthread link with -pthread" >&5 +echo "configure:12414: checking for pthread link with -pthread" >&5 if eval "test \"\${ol_cv_pthread_pthread+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -12418,7 +12421,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -12485,7 +12488,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:12489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:12492: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_pthread=yes else @@ -12497,7 +12500,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -12569,7 +12572,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:12573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:12576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_pthread=yes else @@ -12599,7 +12602,7 @@ fi if test "$ol_link_threads" = no ; then # try -pthreads echo $ac_n "checking for pthread link with -pthreads""... $ac_c" 1>&6 -echo "configure:12603: checking for pthread link with -pthreads" >&5 +echo "configure:12606: checking for pthread link with -pthreads" >&5 if eval "test \"\${ol_cv_pthread_pthreads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -12610,7 +12613,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -12677,7 +12680,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:12681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:12684: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_pthreads=yes else @@ -12689,7 +12692,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -12761,7 +12764,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:12765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:12768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_pthreads=yes else @@ -12791,7 +12794,7 @@ fi if test "$ol_link_threads" = no ; then # try -mthreads echo $ac_n "checking for pthread link with -mthreads""... $ac_c" 1>&6 -echo "configure:12795: checking for pthread link with -mthreads" >&5 +echo "configure:12798: checking for pthread link with -mthreads" >&5 if eval "test \"\${ol_cv_pthread_mthreads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -12802,7 +12805,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -12869,7 +12872,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:12873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:12876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_mthreads=yes else @@ -12881,7 +12884,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -12953,7 +12956,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:12957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:12960: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_mthreads=yes else @@ -12983,7 +12986,7 @@ fi if test "$ol_link_threads" = no ; then # try -thread echo $ac_n "checking for pthread link with -thread""... $ac_c" 1>&6 -echo "configure:12987: checking for pthread link with -thread" >&5 +echo "configure:12990: checking for pthread link with -thread" >&5 if eval "test \"\${ol_cv_pthread_thread+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -12994,7 +12997,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -13061,7 +13064,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:13065: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:13068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_thread=yes else @@ -13073,7 +13076,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -13145,7 +13148,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:13149: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:13152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_thread=yes else @@ -13176,7 +13179,7 @@ fi if test "$ol_link_threads" = no ; then # try -lpthread -lmach -lexc -lc_r echo $ac_n "checking for pthread link with -lpthread -lmach -lexc -lc_r""... $ac_c" 1>&6 -echo "configure:13180: checking for pthread link with -lpthread -lmach -lexc -lc_r" >&5 +echo "configure:13183: checking for pthread link with -lpthread -lmach -lexc -lc_r" >&5 if eval "test \"\${ol_cv_pthread_lpthread_lmach_lexc_lc_r+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -13187,7 +13190,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -13254,7 +13257,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:13258: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:13261: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lpthread_lmach_lexc_lc_r=yes else @@ -13266,7 +13269,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -13338,7 +13341,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:13342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:13345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lpthread_lmach_lexc_lc_r=yes else @@ -13368,7 +13371,7 @@ fi if test "$ol_link_threads" = no ; then # try -lpthread -lmach -lexc echo $ac_n "checking for pthread link with -lpthread -lmach -lexc""... $ac_c" 1>&6 -echo "configure:13372: checking for pthread link with -lpthread -lmach -lexc" >&5 +echo "configure:13375: checking for pthread link with -lpthread -lmach -lexc" >&5 if eval "test \"\${ol_cv_pthread_lpthread_lmach_lexc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -13379,7 +13382,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -13446,7 +13449,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:13450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:13453: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lpthread_lmach_lexc=yes else @@ -13458,7 +13461,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -13530,7 +13533,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:13534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:13537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lpthread_lmach_lexc=yes else @@ -13561,7 +13564,7 @@ fi if test "$ol_link_threads" = no ; then # try -lpthread -Wl,-woff,85 echo $ac_n "checking for pthread link with -lpthread -Wl,-woff,85""... $ac_c" 1>&6 -echo "configure:13565: checking for pthread link with -lpthread -Wl,-woff,85" >&5 +echo "configure:13568: checking for pthread link with -lpthread -Wl,-woff,85" >&5 if eval "test \"\${ol_cv_pthread_lib_lpthread_woff+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -13572,7 +13575,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -13639,7 +13642,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:13643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:13646: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lib_lpthread_woff=yes else @@ -13651,7 +13654,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -13723,7 +13726,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:13727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:13730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lib_lpthread_woff=yes else @@ -13754,7 +13757,7 @@ fi if test "$ol_link_threads" = no ; then # try -lpthread echo $ac_n "checking for pthread link with -lpthread""... $ac_c" 1>&6 -echo "configure:13758: checking for pthread link with -lpthread" >&5 +echo "configure:13761: checking for pthread link with -lpthread" >&5 if eval "test \"\${ol_cv_pthread_lpthread+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -13765,7 +13768,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -13832,7 +13835,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:13836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:13839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lpthread=yes else @@ -13844,7 +13847,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -13916,7 +13919,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:13920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:13923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lpthread=yes else @@ -13946,7 +13949,7 @@ fi if test "$ol_link_threads" = no ; then # try -lc_r echo $ac_n "checking for pthread link with -lc_r""... $ac_c" 1>&6 -echo "configure:13950: checking for pthread link with -lc_r" >&5 +echo "configure:13953: checking for pthread link with -lc_r" >&5 if eval "test \"\${ol_cv_pthread_lc_r+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -13957,7 +13960,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -14024,7 +14027,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:14028: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:14031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lc_r=yes else @@ -14036,7 +14039,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -14108,7 +14111,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:14112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:14115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lc_r=yes else @@ -14139,7 +14142,7 @@ fi if test "$ol_link_threads" = no ; then # try -threads echo $ac_n "checking for pthread link with -threads""... $ac_c" 1>&6 -echo "configure:14143: checking for pthread link with -threads" >&5 +echo "configure:14146: checking for pthread link with -threads" >&5 if eval "test \"\${ol_cv_pthread_threads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -14150,7 +14153,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -14217,7 +14220,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:14221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:14224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_threads=yes else @@ -14229,7 +14232,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -14301,7 +14304,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:14305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:14308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_threads=yes else @@ -14332,7 +14335,7 @@ fi if test "$ol_link_threads" = no ; then # try -lpthreads -lmach -lexc -lc_r echo $ac_n "checking for pthread link with -lpthreads -lmach -lexc -lc_r""... $ac_c" 1>&6 -echo "configure:14336: checking for pthread link with -lpthreads -lmach -lexc -lc_r" >&5 +echo "configure:14339: checking for pthread link with -lpthreads -lmach -lexc -lc_r" >&5 if eval "test \"\${ol_cv_pthread_lpthreads_lmach_lexc_lc_r+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -14343,7 +14346,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -14410,7 +14413,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:14414: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:14417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lpthreads_lmach_lexc_lc_r=yes else @@ -14422,7 +14425,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -14494,7 +14497,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:14498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:14501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lpthreads_lmach_lexc_lc_r=yes else @@ -14524,7 +14527,7 @@ fi if test "$ol_link_threads" = no ; then # try -lpthreads -lmach -lexc echo $ac_n "checking for pthread link with -lpthreads -lmach -lexc""... $ac_c" 1>&6 -echo "configure:14528: checking for pthread link with -lpthreads -lmach -lexc" >&5 +echo "configure:14531: checking for pthread link with -lpthreads -lmach -lexc" >&5 if eval "test \"\${ol_cv_pthread_lpthreads_lmach_lexc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -14535,7 +14538,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -14602,7 +14605,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:14606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:14609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lpthreads_lmach_lexc=yes else @@ -14614,7 +14617,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -14686,7 +14689,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:14690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:14693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lpthreads_lmach_lexc=yes else @@ -14716,7 +14719,7 @@ fi if test "$ol_link_threads" = no ; then # try -lpthreads -lexc echo $ac_n "checking for pthread link with -lpthreads -lexc""... $ac_c" 1>&6 -echo "configure:14720: checking for pthread link with -lpthreads -lexc" >&5 +echo "configure:14723: checking for pthread link with -lpthreads -lexc" >&5 if eval "test \"\${ol_cv_pthread_lpthreads_lexc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -14727,7 +14730,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -14794,7 +14797,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:14798: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:14801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lpthreads_lexc=yes else @@ -14806,7 +14809,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -14878,7 +14881,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:14882: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:14885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lpthreads_lexc=yes else @@ -14909,7 +14912,7 @@ fi if test "$ol_link_threads" = no ; then # try -lpthreads echo $ac_n "checking for pthread link with -lpthreads""... $ac_c" 1>&6 -echo "configure:14913: checking for pthread link with -lpthreads" >&5 +echo "configure:14916: checking for pthread link with -lpthreads" >&5 if eval "test \"\${ol_cv_pthread_lib_lpthreads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -14920,7 +14923,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -14987,7 +14990,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:14991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:14994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lib_lpthreads=yes else @@ -14999,7 +15002,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -15071,7 +15074,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:15075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:15078: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_lib_lpthreads=yes else @@ -15108,12 +15111,12 @@ fi for ac_func in sched_yield pthread_yield thr_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:15112: checking for $ac_func" >&5 +echo "configure:15115: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -15166,7 +15169,7 @@ done $ac_cv_func_pthread_yield = no -a \ $ac_cv_func_thr_yield = no ; then echo $ac_n "checking for sched_yield in -lrt""... $ac_c" 1>&6 -echo "configure:15170: checking for sched_yield in -lrt" >&5 +echo "configure:15173: checking for sched_yield in -lrt" >&5 ac_lib_var=`echo rt'_'sched_yield | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -15174,7 +15177,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lrt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -15221,12 +15224,12 @@ fi for ac_func in pthread_kill pthread_rwlock_destroy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:15225: checking for $ac_func" >&5 +echo "configure:15228: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15257: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -15276,13 +15279,13 @@ done echo $ac_n "checking for pthread_detach with ""... $ac_c" 1>&6 -echo "configure:15280: checking for pthread_detach with " >&5 +echo "configure:15283: checking for pthread_detach with " >&5 if eval "test \"\${ol_cv_func_pthread_detach+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -15294,7 +15297,7 @@ int main() { pthread_detach(NULL); ; return 0; } EOF -if { (eval echo configure:15298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15301: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_func_pthread_detach=yes else @@ -15326,12 +15329,12 @@ EOF do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:15330: checking for $ac_func" >&5 +echo "configure:15333: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -15384,12 +15387,12 @@ done for ac_func in pthread_kill_other_threads_np do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:15388: checking for $ac_func" >&5 +echo "configure:15391: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -15438,7 +15441,7 @@ fi done echo $ac_n "checking for LinuxThreads implementation""... $ac_c" 1>&6 -echo "configure:15442: checking for LinuxThreads implementation" >&5 +echo "configure:15445: checking for LinuxThreads implementation" >&5 if eval "test \"\${ol_cv_sys_linux_threads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -15451,7 +15454,7 @@ echo "$ac_t""$ol_cv_sys_linux_threads" 1>&6 echo $ac_n "checking for LinuxThreads consistency""... $ac_c" 1>&6 -echo "configure:15455: checking for LinuxThreads consistency" >&5 +echo "configure:15458: checking for LinuxThreads consistency" >&5 if eval "test \"\${ol_cv_linux_threads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -15476,7 +15479,7 @@ echo "$ac_t""$ol_cv_linux_threads" 1>&6 fi echo $ac_n "checking if pthread_create() works""... $ac_c" 1>&6 -echo "configure:15480: checking if pthread_create() works" >&5 +echo "configure:15483: checking if pthread_create() works" >&5 if eval "test \"\${ol_cv_pthread_create_works+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -15485,7 +15488,7 @@ else ol_cv_pthread_create_works=yes else cat > conftest.$ac_ext < @@ -15557,7 +15560,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:15561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:15564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_create_works=yes else @@ -15579,7 +15582,7 @@ echo "$ac_t""$ol_cv_pthread_create_works" 1>&6 if test $ol_with_yielding_select = auto ; then echo $ac_n "checking if select yields when using pthreads""... $ac_c" 1>&6 -echo "configure:15583: checking if select yields when using pthreads" >&5 +echo "configure:15586: checking if select yields when using pthreads" >&5 if eval "test \"\${ol_cv_pthread_select_yields+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -15588,7 +15591,7 @@ else ol_cv_pthread_select_yields=cross else cat > conftest.$ac_ext < @@ -15665,7 +15668,7 @@ int main(argc, argv) exit(2); } EOF -if { (eval echo configure:15669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:15672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_pthread_select_yields=no else @@ -15709,17 +15712,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:15713: checking for $ac_hdr" >&5 +echo "configure:15716: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:15723: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:15726: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -15749,12 +15752,12 @@ done ol_with_threads=found echo $ac_n "checking for cthread_fork""... $ac_c" 1>&6 -echo "configure:15753: checking for cthread_fork" >&5 +echo "configure:15756: checking for cthread_fork" >&5 if eval "test \"\${ac_cv_func_cthread_fork+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_cthread_fork=yes" else @@ -15800,7 +15803,7 @@ fi if test $ol_link_threads = no ; then echo $ac_n "checking for cthread_fork with -all_load""... $ac_c" 1>&6 -echo "configure:15804: checking for cthread_fork with -all_load" >&5 +echo "configure:15807: checking for cthread_fork with -all_load" >&5 if eval "test \"\${ol_cv_cthread_all_load+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -15808,7 +15811,7 @@ else save_LIBS="$LIBS" LIBS="-all_load $LIBS" cat > conftest.$ac_ext < int main() { @@ -15817,7 +15820,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:15821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15824: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_cthread_all_load=yes else @@ -15847,12 +15850,12 @@ echo "$ac_t""$ol_cv_cthread_all_load" 1>&6 save_LIBS="$LIBS" LIBS="$LIBS -lthreads" echo $ac_n "checking for cthread_fork""... $ac_c" 1>&6 -echo "configure:15851: checking for cthread_fork" >&5 +echo "configure:15854: checking for cthread_fork" >&5 if eval "test \"\${ac_cv_func_cthread_fork+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_cthread_fork=yes" else @@ -15926,17 +15929,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:15930: checking for $ac_hdr" >&5 +echo "configure:15933: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:15940: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:15943: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -15965,7 +15968,7 @@ done if test $ac_cv_header_pth_h = yes ; then echo $ac_n "checking for pth_version in -lpth""... $ac_c" 1>&6 -echo "configure:15969: checking for pth_version in -lpth" >&5 +echo "configure:15972: checking for pth_version in -lpth" >&5 ac_lib_var=`echo pth'_'pth_version | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -15973,7 +15976,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpth $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:15991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -16029,17 +16032,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:16033: checking for $ac_hdr" >&5 +echo "configure:16036: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:16043: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:16046: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -16067,7 +16070,7 @@ done if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6 -echo "configure:16071: checking for thr_create in -lthread" >&5 +echo "configure:16074: checking for thr_create in -lthread" >&5 ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -16075,7 +16078,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:16093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -16126,12 +16129,12 @@ EOF do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:16130: checking for $ac_func" >&5 +echo "configure:16133: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:16162: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -16186,17 +16189,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:16190: checking for $ac_hdr" >&5 +echo "configure:16193: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:16200: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:16203: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -16224,7 +16227,7 @@ done if test $ac_cv_header_lwp_lwp_h = yes ; then echo $ac_n "checking for lwp_create in -llwp""... $ac_c" 1>&6 -echo "configure:16228: checking for lwp_create in -llwp" >&5 +echo "configure:16231: checking for lwp_create in -llwp" >&5 ac_lib_var=`echo lwp'_'lwp_create | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -16232,7 +16235,7 @@ else ac_save_LIBS="$LIBS" LIBS="-llwp $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:16250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -16296,17 +16299,17 @@ if test $ol_with_threads = manual ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:16300: checking for $ac_hdr" >&5 +echo "configure:16303: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:16310: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:16313: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -16335,12 +16338,12 @@ done for ac_func in sched_yield pthread_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:16339: checking for $ac_func" >&5 +echo "configure:16342: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:16371: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -16390,12 +16393,12 @@ done echo $ac_n "checking for LinuxThreads pthread.h""... $ac_c" 1>&6 -echo "configure:16394: checking for LinuxThreads pthread.h" >&5 +echo "configure:16397: checking for LinuxThreads pthread.h" >&5 if eval "test \"\${ol_cv_header_linux_threads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -16425,17 +16428,17 @@ EOF do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:16429: checking for $ac_hdr" >&5 +echo "configure:16432: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:16439: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:16442: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -16465,17 +16468,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:16469: checking for $ac_hdr" >&5 +echo "configure:16472: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:16479: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:16482: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -16505,17 +16508,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:16509: checking for $ac_hdr" >&5 +echo "configure:16512: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:16519: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:16522: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -16574,20 +16577,20 @@ EOF echo $ac_n "checking for thread specific errno""... $ac_c" 1>&6 -echo "configure:16578: checking for thread specific errno" >&5 +echo "configure:16581: checking for thread specific errno" >&5 if eval "test \"\${ol_cv_errno_thread_specific+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { errno = 0; ; return 0; } EOF -if { (eval echo configure:16591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:16594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_errno_thread_specific=yes else @@ -16603,20 +16606,20 @@ fi echo "$ac_t""$ol_cv_errno_thread_specific" 1>&6 echo $ac_n "checking for thread specific h_errno""... $ac_c" 1>&6 -echo "configure:16607: checking for thread specific h_errno" >&5 +echo "configure:16610: checking for thread specific h_errno" >&5 if eval "test \"\${ol_cv_h_errno_thread_specific+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { h_errno = 0; ; return 0; } EOF -if { (eval echo configure:16620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:16623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_h_errno_thread_specific=yes else @@ -16669,12 +16672,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:16673: checking for $ac_func" >&5 +echo "configure:16676: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:16705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -16727,19 +16730,19 @@ if test "$ac_cv_func_ctime_r" = no ; then ol_cv_func_ctime_r_nargs=0 else echo $ac_n "checking number of arguments of ctime_r""... $ac_c" 1>&6 -echo "configure:16731: checking number of arguments of ctime_r" >&5 +echo "configure:16734: checking number of arguments of ctime_r" >&5 if eval "test \"\${ol_cv_func_ctime_r_nargs+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { time_t ti; char *buffer; ctime_r(&ti,buffer,32); ; return 0; } EOF -if { (eval echo configure:16743: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:16746: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_ctime_r_nargs3=yes else @@ -16751,14 +16754,14 @@ fi rm -f conftest* cat > conftest.$ac_ext < int main() { time_t ti; char *buffer; ctime_r(&ti,buffer); ; return 0; } EOF -if { (eval echo configure:16762: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:16765: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_ctime_r_nargs2=yes else @@ -16798,12 +16801,12 @@ fi if test "$ac_cv_func_gethostbyname_r" = yes ; then echo $ac_n "checking number of arguments of gethostbyname_r""... $ac_c" 1>&6 -echo "configure:16802: checking number of arguments of gethostbyname_r" >&5 +echo "configure:16805: checking number of arguments of gethostbyname_r" >&5 if eval "test \"\${ol_cv_func_gethostbyname_r_nargs+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -16817,7 +16820,7 @@ struct hostent hent; char buffer[BUFSIZE]; buffer, bufsize, &h_errno); ; return 0; } EOF -if { (eval echo configure:16821: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:16824: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_gethostbyname_r_nargs5=yes else @@ -16829,7 +16832,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < #include @@ -16844,7 +16847,7 @@ struct hostent hent;struct hostent *rhent; &rhent, &h_errno); ; return 0; } EOF -if { (eval echo configure:16848: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:16851: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_gethostbyname_r_nargs6=yes else @@ -16885,12 +16888,12 @@ fi if test "$ac_cv_func_gethostbyaddr_r" = yes ; then echo $ac_n "checking number of arguments of gethostbyaddr_r""... $ac_c" 1>&6 -echo "configure:16889: checking number of arguments of gethostbyaddr_r" >&5 +echo "configure:16892: checking number of arguments of gethostbyaddr_r" >&5 if eval "test \"\${ol_cv_func_gethostbyaddr_r_nargs+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -16906,7 +16909,7 @@ struct hostent hent; char buffer[BUFSIZE]; alen, AF_INET, &hent, buffer, bufsize, &h_errno); ; return 0; } EOF -if { (eval echo configure:16910: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:16913: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_gethostbyaddr_r_nargs7=yes else @@ -16918,7 +16921,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < #include @@ -16936,7 +16939,7 @@ struct hostent hent; &rhent, &h_errno); ; return 0; } EOF -if { (eval echo configure:16940: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:16943: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_gethostbyaddr_r_nargs8=yes else @@ -16986,17 +16989,17 @@ if test $ol_with_ldbm_api = auto \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:16990: checking for $ac_hdr" >&5 +echo "configure:16993: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:17000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:17003: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -17024,13 +17027,13 @@ done if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then echo $ac_n "checking if Berkeley DB header compatibility""... $ac_c" 1>&6 -echo "configure:17028: checking if Berkeley DB header compatibility" >&5 +echo "configure:17031: checking if Berkeley DB header compatibility" >&5 if eval "test \"\${ol_cv_header_db1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 ol_cv_lib_db=no if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (default)""... $ac_c" 1>&6 -echo "configure:17071: checking for Berkeley DB link (default)" >&5 +echo "configure:17074: checking for Berkeley DB link (default)" >&5 if eval "test \"\${ol_cv_db_none+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17077,7 +17080,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17131: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_none=yes else @@ -17148,7 +17151,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb43)""... $ac_c" 1>&6 -echo "configure:17152: checking for Berkeley DB link (-ldb43)" >&5 +echo "configure:17155: checking for Berkeley DB link (-ldb43)" >&5 if eval "test \"\${ol_cv_db_db43+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17158,7 +17161,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db43=yes else @@ -17229,7 +17232,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-43)""... $ac_c" 1>&6 -echo "configure:17233: checking for Berkeley DB link (-ldb-43)" >&5 +echo "configure:17236: checking for Berkeley DB link (-ldb-43)" >&5 if eval "test \"\${ol_cv_db_db_43+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17239,7 +17242,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17293: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_43=yes else @@ -17310,7 +17313,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4.3)""... $ac_c" 1>&6 -echo "configure:17314: checking for Berkeley DB link (-ldb-4.3)" >&5 +echo "configure:17317: checking for Berkeley DB link (-ldb-4.3)" >&5 if eval "test \"\${ol_cv_db_db_4_dot_3+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17320,7 +17323,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17374: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_dot_3=yes else @@ -17391,7 +17394,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4-3)""... $ac_c" 1>&6 -echo "configure:17395: checking for Berkeley DB link (-ldb-4-3)" >&5 +echo "configure:17398: checking for Berkeley DB link (-ldb-4-3)" >&5 if eval "test \"\${ol_cv_db_db_4_3+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17401,7 +17404,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_3=yes else @@ -17472,7 +17475,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb42)""... $ac_c" 1>&6 -echo "configure:17476: checking for Berkeley DB link (-ldb42)" >&5 +echo "configure:17479: checking for Berkeley DB link (-ldb42)" >&5 if eval "test \"\${ol_cv_db_db42+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17482,7 +17485,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db42=yes else @@ -17553,7 +17556,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-42)""... $ac_c" 1>&6 -echo "configure:17557: checking for Berkeley DB link (-ldb-42)" >&5 +echo "configure:17560: checking for Berkeley DB link (-ldb-42)" >&5 if eval "test \"\${ol_cv_db_db_42+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17563,7 +17566,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_42=yes else @@ -17634,7 +17637,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4.2)""... $ac_c" 1>&6 -echo "configure:17638: checking for Berkeley DB link (-ldb-4.2)" >&5 +echo "configure:17641: checking for Berkeley DB link (-ldb-4.2)" >&5 if eval "test \"\${ol_cv_db_db_4_dot_2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17644,7 +17647,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_dot_2=yes else @@ -17715,7 +17718,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4-2)""... $ac_c" 1>&6 -echo "configure:17719: checking for Berkeley DB link (-ldb-4-2)" >&5 +echo "configure:17722: checking for Berkeley DB link (-ldb-4-2)" >&5 if eval "test \"\${ol_cv_db_db_4_2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17725,7 +17728,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_2=yes else @@ -17796,7 +17799,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4)""... $ac_c" 1>&6 -echo "configure:17800: checking for Berkeley DB link (-ldb-4)" >&5 +echo "configure:17803: checking for Berkeley DB link (-ldb-4)" >&5 if eval "test \"\${ol_cv_db_db_4+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17806,7 +17809,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17860: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4=yes else @@ -17877,7 +17880,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb4)""... $ac_c" 1>&6 -echo "configure:17881: checking for Berkeley DB link (-ldb4)" >&5 +echo "configure:17884: checking for Berkeley DB link (-ldb4)" >&5 if eval "test \"\${ol_cv_db_db4+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17887,7 +17890,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db4=yes else @@ -17958,7 +17961,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb)""... $ac_c" 1>&6 -echo "configure:17962: checking for Berkeley DB link (-ldb)" >&5 +echo "configure:17965: checking for Berkeley DB link (-ldb)" >&5 if eval "test \"\${ol_cv_db_db+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -17968,7 +17971,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db=yes else @@ -18039,7 +18042,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb41)""... $ac_c" 1>&6 -echo "configure:18043: checking for Berkeley DB link (-ldb41)" >&5 +echo "configure:18046: checking for Berkeley DB link (-ldb41)" >&5 if eval "test \"\${ol_cv_db_db41+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18049,7 +18052,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18103: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db41=yes else @@ -18120,7 +18123,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-41)""... $ac_c" 1>&6 -echo "configure:18124: checking for Berkeley DB link (-ldb-41)" >&5 +echo "configure:18127: checking for Berkeley DB link (-ldb-41)" >&5 if eval "test \"\${ol_cv_db_db_41+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18130,7 +18133,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_41=yes else @@ -18201,7 +18204,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4.1)""... $ac_c" 1>&6 -echo "configure:18205: checking for Berkeley DB link (-ldb-4.1)" >&5 +echo "configure:18208: checking for Berkeley DB link (-ldb-4.1)" >&5 if eval "test \"\${ol_cv_db_db_4_dot_1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18211,7 +18214,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_dot_1=yes else @@ -18282,7 +18285,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4-1)""... $ac_c" 1>&6 -echo "configure:18286: checking for Berkeley DB link (-ldb-4-1)" >&5 +echo "configure:18289: checking for Berkeley DB link (-ldb-4-1)" >&5 if eval "test \"\${ol_cv_db_db_4_1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18292,7 +18295,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18346: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_1=yes else @@ -18363,7 +18366,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb3)""... $ac_c" 1>&6 -echo "configure:18367: checking for Berkeley DB link (-ldb3)" >&5 +echo "configure:18370: checking for Berkeley DB link (-ldb3)" >&5 if eval "test \"\${ol_cv_db_db3+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18373,7 +18376,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db3=yes else @@ -18444,7 +18447,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-3)""... $ac_c" 1>&6 -echo "configure:18448: checking for Berkeley DB link (-ldb-3)" >&5 +echo "configure:18451: checking for Berkeley DB link (-ldb-3)" >&5 if eval "test \"\${ol_cv_db_db_3+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18454,7 +18457,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_3=yes else @@ -18525,7 +18528,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb2)""... $ac_c" 1>&6 -echo "configure:18529: checking for Berkeley DB link (-ldb2)" >&5 +echo "configure:18532: checking for Berkeley DB link (-ldb2)" >&5 if eval "test \"\${ol_cv_db_db2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18535,7 +18538,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db2=yes else @@ -18606,7 +18609,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-2)""... $ac_c" 1>&6 -echo "configure:18610: checking for Berkeley DB link (-ldb-2)" >&5 +echo "configure:18613: checking for Berkeley DB link (-ldb-2)" >&5 if eval "test \"\${ol_cv_db_db_2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18616,7 +18619,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_2=yes else @@ -18687,7 +18690,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb1)""... $ac_c" 1>&6 -echo "configure:18691: checking for Berkeley DB link (-ldb1)" >&5 +echo "configure:18694: checking for Berkeley DB link (-ldb1)" >&5 if eval "test \"\${ol_cv_db_db1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18697,7 +18700,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18751: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db1=yes else @@ -18768,7 +18771,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-1)""... $ac_c" 1>&6 -echo "configure:18772: checking for Berkeley DB link (-ldb-1)" >&5 +echo "configure:18775: checking for Berkeley DB link (-ldb-1)" >&5 if eval "test \"\${ol_cv_db_db_1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18778,7 +18781,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18832: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_1=yes else @@ -18860,17 +18863,17 @@ for ac_hdr in db.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:18864: checking for $ac_hdr" >&5 +echo "configure:18867: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:18874: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:18877: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -18900,7 +18903,7 @@ if test $ac_cv_header_db_h = yes; then ol_cv_lib_db=no if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (default)""... $ac_c" 1>&6 -echo "configure:18904: checking for Berkeley DB link (default)" >&5 +echo "configure:18907: checking for Berkeley DB link (default)" >&5 if eval "test \"\${ol_cv_db_none+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18910,7 +18913,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_none=yes else @@ -18981,7 +18984,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb43)""... $ac_c" 1>&6 -echo "configure:18985: checking for Berkeley DB link (-ldb43)" >&5 +echo "configure:18988: checking for Berkeley DB link (-ldb43)" >&5 if eval "test \"\${ol_cv_db_db43+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18991,7 +18994,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db43=yes else @@ -19062,7 +19065,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-43)""... $ac_c" 1>&6 -echo "configure:19066: checking for Berkeley DB link (-ldb-43)" >&5 +echo "configure:19069: checking for Berkeley DB link (-ldb-43)" >&5 if eval "test \"\${ol_cv_db_db_43+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19072,7 +19075,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19126: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_43=yes else @@ -19143,7 +19146,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4.3)""... $ac_c" 1>&6 -echo "configure:19147: checking for Berkeley DB link (-ldb-4.3)" >&5 +echo "configure:19150: checking for Berkeley DB link (-ldb-4.3)" >&5 if eval "test \"\${ol_cv_db_db_4_dot_3+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19153,7 +19156,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19207: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_dot_3=yes else @@ -19224,7 +19227,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4-3)""... $ac_c" 1>&6 -echo "configure:19228: checking for Berkeley DB link (-ldb-4-3)" >&5 +echo "configure:19231: checking for Berkeley DB link (-ldb-4-3)" >&5 if eval "test \"\${ol_cv_db_db_4_3+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19234,7 +19237,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19288: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_3=yes else @@ -19305,7 +19308,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb42)""... $ac_c" 1>&6 -echo "configure:19309: checking for Berkeley DB link (-ldb42)" >&5 +echo "configure:19312: checking for Berkeley DB link (-ldb42)" >&5 if eval "test \"\${ol_cv_db_db42+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19315,7 +19318,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db42=yes else @@ -19386,7 +19389,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-42)""... $ac_c" 1>&6 -echo "configure:19390: checking for Berkeley DB link (-ldb-42)" >&5 +echo "configure:19393: checking for Berkeley DB link (-ldb-42)" >&5 if eval "test \"\${ol_cv_db_db_42+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19396,7 +19399,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_42=yes else @@ -19467,7 +19470,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4.2)""... $ac_c" 1>&6 -echo "configure:19471: checking for Berkeley DB link (-ldb-4.2)" >&5 +echo "configure:19474: checking for Berkeley DB link (-ldb-4.2)" >&5 if eval "test \"\${ol_cv_db_db_4_dot_2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19477,7 +19480,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_dot_2=yes else @@ -19548,7 +19551,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4-2)""... $ac_c" 1>&6 -echo "configure:19552: checking for Berkeley DB link (-ldb-4-2)" >&5 +echo "configure:19555: checking for Berkeley DB link (-ldb-4-2)" >&5 if eval "test \"\${ol_cv_db_db_4_2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19558,7 +19561,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_2=yes else @@ -19629,7 +19632,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4)""... $ac_c" 1>&6 -echo "configure:19633: checking for Berkeley DB link (-ldb-4)" >&5 +echo "configure:19636: checking for Berkeley DB link (-ldb-4)" >&5 if eval "test \"\${ol_cv_db_db_4+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19639,7 +19642,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4=yes else @@ -19710,7 +19713,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb4)""... $ac_c" 1>&6 -echo "configure:19714: checking for Berkeley DB link (-ldb4)" >&5 +echo "configure:19717: checking for Berkeley DB link (-ldb4)" >&5 if eval "test \"\${ol_cv_db_db4+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19720,7 +19723,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19774: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db4=yes else @@ -19791,7 +19794,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb)""... $ac_c" 1>&6 -echo "configure:19795: checking for Berkeley DB link (-ldb)" >&5 +echo "configure:19798: checking for Berkeley DB link (-ldb)" >&5 if eval "test \"\${ol_cv_db_db+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19801,7 +19804,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db=yes else @@ -19872,7 +19875,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb41)""... $ac_c" 1>&6 -echo "configure:19876: checking for Berkeley DB link (-ldb41)" >&5 +echo "configure:19879: checking for Berkeley DB link (-ldb41)" >&5 if eval "test \"\${ol_cv_db_db41+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19882,7 +19885,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:19936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db41=yes else @@ -19953,7 +19956,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-41)""... $ac_c" 1>&6 -echo "configure:19957: checking for Berkeley DB link (-ldb-41)" >&5 +echo "configure:19960: checking for Berkeley DB link (-ldb-41)" >&5 if eval "test \"\${ol_cv_db_db_41+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -19963,7 +19966,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20017: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_41=yes else @@ -20034,7 +20037,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4.1)""... $ac_c" 1>&6 -echo "configure:20038: checking for Berkeley DB link (-ldb-4.1)" >&5 +echo "configure:20041: checking for Berkeley DB link (-ldb-4.1)" >&5 if eval "test \"\${ol_cv_db_db_4_dot_1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20044,7 +20047,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_dot_1=yes else @@ -20115,7 +20118,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-4-1)""... $ac_c" 1>&6 -echo "configure:20119: checking for Berkeley DB link (-ldb-4-1)" >&5 +echo "configure:20122: checking for Berkeley DB link (-ldb-4-1)" >&5 if eval "test \"\${ol_cv_db_db_4_1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20125,7 +20128,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_4_1=yes else @@ -20196,7 +20199,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb3)""... $ac_c" 1>&6 -echo "configure:20200: checking for Berkeley DB link (-ldb3)" >&5 +echo "configure:20203: checking for Berkeley DB link (-ldb3)" >&5 if eval "test \"\${ol_cv_db_db3+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20206,7 +20209,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db3=yes else @@ -20277,7 +20280,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-3)""... $ac_c" 1>&6 -echo "configure:20281: checking for Berkeley DB link (-ldb-3)" >&5 +echo "configure:20284: checking for Berkeley DB link (-ldb-3)" >&5 if eval "test \"\${ol_cv_db_db_3+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20287,7 +20290,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_3=yes else @@ -20358,7 +20361,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb2)""... $ac_c" 1>&6 -echo "configure:20362: checking for Berkeley DB link (-ldb2)" >&5 +echo "configure:20365: checking for Berkeley DB link (-ldb2)" >&5 if eval "test \"\${ol_cv_db_db2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20368,7 +20371,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db2=yes else @@ -20439,7 +20442,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-2)""... $ac_c" 1>&6 -echo "configure:20443: checking for Berkeley DB link (-ldb-2)" >&5 +echo "configure:20446: checking for Berkeley DB link (-ldb-2)" >&5 if eval "test \"\${ol_cv_db_db_2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20449,7 +20452,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_2=yes else @@ -20520,7 +20523,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb1)""... $ac_c" 1>&6 -echo "configure:20524: checking for Berkeley DB link (-ldb1)" >&5 +echo "configure:20527: checking for Berkeley DB link (-ldb1)" >&5 if eval "test \"\${ol_cv_db_db1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20530,7 +20533,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20584: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db1=yes else @@ -20601,7 +20604,7 @@ fi if test $ol_cv_lib_db = no ; then echo $ac_n "checking for Berkeley DB link (-ldb-1)""... $ac_c" 1>&6 -echo "configure:20605: checking for Berkeley DB link (-ldb-1)" >&5 +echo "configure:20608: checking for Berkeley DB link (-ldb-1)" >&5 if eval "test \"\${ol_cv_db_db_1+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20611,7 +20614,7 @@ else LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20665: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_db_db_1=yes else @@ -20684,7 +20687,7 @@ fi if test "$ol_cv_lib_db" != no ; then ol_cv_berkeley_db=yes echo $ac_n "checking for Berkeley DB version match""... $ac_c" 1>&6 -echo "configure:20688: checking for Berkeley DB version match" >&5 +echo "configure:20691: checking for Berkeley DB version match" >&5 if eval "test \"\${ol_cv_berkeley_db_version+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20699,7 +20702,7 @@ else ol_cv_berkeley_db_version=cross else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:20742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_berkeley_db_version=yes else @@ -20759,7 +20762,7 @@ echo "$ac_t""$ol_cv_berkeley_db_version" 1>&6 fi echo $ac_n "checking for Berkeley DB thread support""... $ac_c" 1>&6 -echo "configure:20763: checking for Berkeley DB thread support" >&5 +echo "configure:20766: checking for Berkeley DB thread support" >&5 if eval "test \"\${ol_cv_berkeley_db_thread+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -20774,7 +20777,7 @@ else ol_cv_berkeley_db_thread=cross else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:20848: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_berkeley_db_thread=yes else @@ -20904,13 +20907,13 @@ if test $ol_enable_bdb != no -o $ol_enable_hdb != no; then { echo "configure: error: BDB/HDB: BerkeleyDB not available" 1>&2; exit 1; } else echo $ac_n "checking Berkeley DB version for BDB backend""... $ac_c" 1>&6 -echo "configure:20908: checking Berkeley DB version for BDB backend" >&5 +echo "configure:20911: checking Berkeley DB version for BDB backend" >&5 if eval "test \"\${ol_cv_bdb_compat+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -20957,18 +20960,18 @@ fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = mdbm ; then echo $ac_n "checking for MDBM library""... $ac_c" 1>&6 -echo "configure:20961: checking for MDBM library" >&5 +echo "configure:20964: checking for MDBM library" >&5 if eval "test \"\${ol_cv_lib_mdbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for mdbm_set_chain""... $ac_c" 1>&6 -echo "configure:20967: checking for mdbm_set_chain" >&5 +echo "configure:20970: checking for mdbm_set_chain" >&5 if eval "test \"\${ac_cv_func_mdbm_set_chain+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:20999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_mdbm_set_chain=yes" else @@ -21011,7 +21014,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for mdbm_set_chain in -lmdbm""... $ac_c" 1>&6 -echo "configure:21015: checking for mdbm_set_chain in -lmdbm" >&5 +echo "configure:21018: checking for mdbm_set_chain in -lmdbm" >&5 ac_lib_var=`echo mdbm'_'mdbm_set_chain | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -21019,7 +21022,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lmdbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -21065,17 +21068,17 @@ echo "$ac_t""$ol_cv_lib_mdbm" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:21069: checking for $ac_hdr" >&5 +echo "configure:21072: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:21079: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:21082: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -21102,7 +21105,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:21106: checking for db" >&5 +echo "configure:21109: checking for db" >&5 if eval "test \"\${ol_cv_mdbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -21135,18 +21138,18 @@ fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then echo $ac_n "checking for GDBM library""... $ac_c" 1>&6 -echo "configure:21139: checking for GDBM library" >&5 +echo "configure:21142: checking for GDBM library" >&5 if eval "test \"\${ol_cv_lib_gdbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for gdbm_open""... $ac_c" 1>&6 -echo "configure:21145: checking for gdbm_open" >&5 +echo "configure:21148: checking for gdbm_open" >&5 if eval "test \"\${ac_cv_func_gdbm_open+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gdbm_open=yes" else @@ -21189,7 +21192,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6 -echo "configure:21193: checking for gdbm_open in -lgdbm" >&5 +echo "configure:21196: checking for gdbm_open in -lgdbm" >&5 ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -21197,7 +21200,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lgdbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -21243,17 +21246,17 @@ echo "$ac_t""$ol_cv_lib_gdbm" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:21247: checking for $ac_hdr" >&5 +echo "configure:21250: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:21257: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:21260: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -21280,7 +21283,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:21284: checking for db" >&5 +echo "configure:21287: checking for db" >&5 if eval "test \"\${ol_cv_gdbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -21314,18 +21317,18 @@ fi if test $ol_with_ldbm_api = ndbm ; then echo $ac_n "checking for NDBM library""... $ac_c" 1>&6 -echo "configure:21318: checking for NDBM library" >&5 +echo "configure:21321: checking for NDBM library" >&5 if eval "test \"\${ol_cv_lib_ndbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for dbm_open""... $ac_c" 1>&6 -echo "configure:21324: checking for dbm_open" >&5 +echo "configure:21327: checking for dbm_open" >&5 if eval "test \"\${ac_cv_func_dbm_open+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21356: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_dbm_open=yes" else @@ -21368,7 +21371,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbm_open in -lndbm""... $ac_c" 1>&6 -echo "configure:21372: checking for dbm_open in -lndbm" >&5 +echo "configure:21375: checking for dbm_open in -lndbm" >&5 ac_lib_var=`echo ndbm'_'dbm_open | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -21376,7 +21379,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lndbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -21407,7 +21410,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6 -echo "configure:21411: checking for dbm_open in -ldbm" >&5 +echo "configure:21414: checking for dbm_open in -ldbm" >&5 ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -21415,7 +21418,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -21463,17 +21466,17 @@ echo "$ac_t""$ol_cv_lib_ndbm" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:21467: checking for $ac_hdr" >&5 +echo "configure:21470: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:21477: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:21480: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -21500,7 +21503,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:21504: checking for db" >&5 +echo "configure:21507: checking for db" >&5 if eval "test \"\${ol_cv_ndbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -21560,17 +21563,17 @@ if test $ol_enable_wrappers != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:21564: checking for $ac_hdr" >&5 +echo "configure:21567: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:21574: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:21577: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -21592,11 +21595,11 @@ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then EOF echo $ac_n "checking for TCP wrappers library""... $ac_c" 1>&6 -echo "configure:21596: checking for TCP wrappers library" >&5 +echo "configure:21599: checking for TCP wrappers library" >&5 save_LIBS="$LIBS" LIBS="$LIBS -lwrap" cat > conftest.$ac_ext < @@ -21611,7 +21614,7 @@ hosts_access(req) ; return 0; } EOF -if { (eval echo configure:21615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""-lwrap" 1>&6 have_wrappers=yes @@ -21623,7 +21626,7 @@ else LIBS="$LIBS -lnsl" cat > conftest.$ac_ext < @@ -21638,7 +21641,7 @@ hosts_access(req) ; return 0; } EOF -if { (eval echo configure:21642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""-lwrap -lnsl" 1>&6 have_wrappers=yes @@ -21678,12 +21681,12 @@ fi if test $ol_enable_syslog != no ; then echo $ac_n "checking for openlog""... $ac_c" 1>&6 -echo "configure:21682: checking for openlog" >&5 +echo "configure:21685: checking for openlog" >&5 if eval "test \"\${ac_cv_func_openlog+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_openlog=yes" else @@ -21739,17 +21742,17 @@ if test $ol_enable_sql != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:21743: checking for $ac_hdr" >&5 +echo "configure:21746: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:21753: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:21756: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -21782,7 +21785,7 @@ done LIBS="$LTHREAD_LIBS" echo $ac_n "checking for SQLDriverConnect in -liodbc""... $ac_c" 1>&6 -echo "configure:21786: checking for SQLDriverConnect in -liodbc" >&5 +echo "configure:21789: checking for SQLDriverConnect in -liodbc" >&5 ac_lib_var=`echo iodbc'_'SQLDriverConnect | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -21790,7 +21793,7 @@ else ac_save_LIBS="$LIBS" LIBS="-liodbc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -21826,7 +21829,7 @@ fi ol_link_sql="-liodbc" else echo $ac_n "checking for SQLDriverConnect in -lodbc""... $ac_c" 1>&6 -echo "configure:21830: checking for SQLDriverConnect in -lodbc" >&5 +echo "configure:21833: checking for SQLDriverConnect in -lodbc" >&5 ac_lib_var=`echo odbc'_'SQLDriverConnect | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -21834,7 +21837,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lodbc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -21889,17 +21892,17 @@ if test $ol_with_cyrus_sasl != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:21893: checking for $ac_hdr" >&5 +echo "configure:21896: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:21903: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:21906: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -21928,7 +21931,7 @@ done if test $ac_cv_header_sasl_sasl_h = yes -o $ac_cv_header_sasl_h = yes; then echo $ac_n "checking for sasl_client_init in -lsasl2""... $ac_c" 1>&6 -echo "configure:21932: checking for sasl_client_init in -lsasl2" >&5 +echo "configure:21935: checking for sasl_client_init in -lsasl2" >&5 ac_lib_var=`echo sasl2'_'sasl_client_init | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -21936,7 +21939,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsasl2 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21954: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -21966,7 +21969,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for sasl_client_init in -lsasl""... $ac_c" 1>&6 -echo "configure:21970: checking for sasl_client_init in -lsasl" >&5 +echo "configure:21973: checking for sasl_client_init in -lsasl" >&5 ac_lib_var=`echo sasl'_'sasl_client_init | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -21974,7 +21977,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsasl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:21992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -22021,13 +22024,13 @@ fi fi else echo $ac_n "checking Cyrus SASL library version""... $ac_c" 1>&6 -echo "configure:22025: checking Cyrus SASL library version" >&5 +echo "configure:22028: checking Cyrus SASL library version" >&5 if eval "test \"\${ol_cv_sasl_compat+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 -echo "configure:22080: checking for sasl_version" >&5 +echo "configure:22083: checking for sasl_version" >&5 if eval "test \"\${ac_cv_func_sasl_version+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:22112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_sasl_version=yes" else @@ -22166,13 +22169,13 @@ if test $ol_with_fetch != no ; then ol_LIBS=$LIBS LIBS="-lfetch -lcom_err $LIBS" echo $ac_n "checking fetch(3) library""... $ac_c" 1>&6 -echo "configure:22170: checking fetch(3) library" >&5 +echo "configure:22173: checking fetch(3) library" >&5 if eval "test \"\${ol_cv_lib_fetch+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -22182,7 +22185,7 @@ int main() { struct url *u = fetchParseURL("file:///"); ; return 0; } EOF -if { (eval echo configure:22186: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:22189: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_lib_fetch=yes else @@ -22219,12 +22222,12 @@ if test $ol_enable_crypt != no ; then LIBS="$TLS_LIBS $LIBS" echo $ac_n "checking for crypt""... $ac_c" 1>&6 -echo "configure:22223: checking for crypt" >&5 +echo "configure:22226: checking for crypt" >&5 if eval "test \"\${ac_cv_func_crypt+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:22255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_crypt=yes" else @@ -22268,7 +22271,7 @@ else LIBS="$save_LIBS" echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6 -echo "configure:22272: checking for crypt in -lcrypt" >&5 +echo "configure:22275: checking for crypt in -lcrypt" >&5 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -22276,7 +22279,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcrypt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:22294: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -22332,12 +22335,12 @@ fi if test $ol_enable_proctitle != no ; then echo $ac_n "checking for setproctitle""... $ac_c" 1>&6 -echo "configure:22336: checking for setproctitle" >&5 +echo "configure:22339: checking for setproctitle" >&5 if eval "test \"\${ac_cv_func_setproctitle+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:22368: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_setproctitle=yes" else @@ -22380,7 +22383,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for setproctitle in -lutil""... $ac_c" 1>&6 -echo "configure:22384: checking for setproctitle in -lutil" >&5 +echo "configure:22387: checking for setproctitle in -lutil" >&5 ac_lib_var=`echo util'_'setproctitle | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -22388,7 +22391,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lutil $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:22406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -22439,17 +22442,17 @@ if test $ol_enable_slp != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:22443: checking for $ac_hdr" >&5 +echo "configure:22446: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:22453: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:22456: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -22478,7 +22481,7 @@ done if test $ac_cv_header_slp_h = yes ; then echo $ac_n "checking for SLPOpen in -lslp""... $ac_c" 1>&6 -echo "configure:22482: checking for SLPOpen in -lslp" >&5 +echo "configure:22485: checking for SLPOpen in -lslp" >&5 ac_lib_var=`echo slp'_'SLPOpen | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -22486,7 +22489,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lslp $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:22504: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -22539,17 +22542,17 @@ if test "$ol_with_multiple_precision" != "no" ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:22543: checking for $ac_hdr" >&5 +echo "configure:22546: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:22553: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:22556: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -22579,17 +22582,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:22583: checking for $ac_hdr" >&5 +echo "configure:22586: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:22593: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:22596: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -22619,17 +22622,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:22623: checking for $ac_hdr" >&5 +echo "configure:22626: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:22633: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:22636: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -22678,7 +22681,7 @@ done if test $ac_cv_header_gmp_h = yes ; then echo $ac_n "checking for __gmpz_add_ui in -lgmp""... $ac_c" 1>&6 -echo "configure:22682: checking for __gmpz_add_ui in -lgmp" >&5 +echo "configure:22685: checking for __gmpz_add_ui in -lgmp" >&5 ac_lib_var=`echo gmp'_'__gmpz_add_ui | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -22686,7 +22689,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lgmp $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:22704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -22724,7 +22727,7 @@ fi fi echo $ac_n "checking for multiple precision support""... $ac_c" 1>&6 -echo "configure:22728: checking for multiple precision support" >&5 +echo "configure:22731: checking for multiple precision support" >&5 ol_mp_support="none" case "$ol_with_multiple_precision" in @@ -22783,20 +22786,20 @@ fi echo $ac_n "checking long long""... $ac_c" 1>&6 -echo "configure:22787: checking long long" >&5 +echo "configure:22790: checking long long" >&5 if eval "test \"\${ol_cv_type_long_long+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:22803: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_type_long_long=yes else @@ -22817,12 +22820,12 @@ EOF fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:22821: checking for ANSI C header files" >&5 +echo "configure:22824: checking for ANSI C header files" >&5 if eval "test \"\${ac_cv_header_stdc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -22830,7 +22833,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:22834: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:22837: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -22847,7 +22850,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -22865,7 +22868,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -22886,7 +22889,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #if ((' ' & 0x0FF) == 0x020) @@ -22904,7 +22907,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:22908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:22911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then : else @@ -22928,12 +22931,12 @@ EOF fi echo $ac_n "checking for mode_t""... $ac_c" 1>&6 -echo "configure:22932: checking for mode_t" >&5 +echo "configure:22935: checking for mode_t" >&5 if eval "test \"\${ac_cv_type_mode_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -22964,12 +22967,12 @@ EOF fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:22968: checking for off_t" >&5 +echo "configure:22971: checking for off_t" >&5 if eval "test \"\${ac_cv_type_off_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -23000,12 +23003,12 @@ EOF fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:23004: checking for pid_t" >&5 +echo "configure:23007: checking for pid_t" >&5 if eval "test \"\${ac_cv_type_pid_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -23036,19 +23039,19 @@ EOF fi echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6 -echo "configure:23040: checking for ptrdiff_t" >&5 +echo "configure:23043: checking for ptrdiff_t" >&5 if eval "test \"\${am_cv_type_ptrdiff_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { ptrdiff_t p ; return 0; } EOF -if { (eval echo configure:23052: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23055: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_type_ptrdiff_t=yes else @@ -23069,12 +23072,12 @@ EOF fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:23073: checking return type of signal handlers" >&5 +echo "configure:23076: checking return type of signal handlers" >&5 if eval "test \"\${ac_cv_type_signal+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -23091,7 +23094,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:23095: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23098: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -23110,12 +23113,12 @@ EOF echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:23114: checking for size_t" >&5 +echo "configure:23117: checking for size_t" >&5 if eval "test \"\${ac_cv_type_size_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -23147,12 +23150,12 @@ fi echo $ac_n "checking for ssize_t""... $ac_c" 1>&6 -echo "configure:23151: checking for ssize_t" >&5 +echo "configure:23154: checking for ssize_t" >&5 if eval "test \"\${ac_cv_type_ssize_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -23183,12 +23186,12 @@ EOF fi echo $ac_n "checking for caddr_t""... $ac_c" 1>&6 -echo "configure:23187: checking for caddr_t" >&5 +echo "configure:23190: checking for caddr_t" >&5 if eval "test \"\${ac_cv_type_caddr_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -23220,12 +23223,12 @@ fi echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 -echo "configure:23224: checking for socklen_t" >&5 +echo "configure:23227: checking for socklen_t" >&5 if eval "test \"\${ol_cv_type_socklen_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_type_socklen_t=yes else @@ -23260,12 +23263,12 @@ EOF fi echo $ac_n "checking for member st_blksize in aggregate type struct stat""... $ac_c" 1>&6 -echo "configure:23264: checking for member st_blksize in aggregate type struct stat" >&5 +echo "configure:23267: checking for member st_blksize in aggregate type struct stat" >&5 if eval "test \"\${ac_cv_c_struct_member_st_blksize+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -23273,7 +23276,7 @@ int main() { struct stat foo; foo.st_blksize; ; return 0; } EOF -if { (eval echo configure:23277: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23280: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_struct_member_st_blksize=yes else @@ -23295,12 +23298,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:23299: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:23302: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"\${ac_cv_header_time+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -23309,7 +23312,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:23313: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23316: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -23330,12 +23333,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:23334: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:23337: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"\${ac_cv_struct_tm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -23343,7 +23346,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:23347: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23350: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -23364,12 +23367,12 @@ EOF fi echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:23368: checking for uid_t in sys/types.h" >&5 +echo "configure:23371: checking for uid_t in sys/types.h" >&5 if eval "test \"\${ac_cv_type_uid_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -23398,19 +23401,19 @@ EOF fi echo $ac_n "checking for sig_atomic_t""... $ac_c" 1>&6 -echo "configure:23402: checking for sig_atomic_t" >&5 +echo "configure:23405: checking for sig_atomic_t" >&5 if eval "test \"\${ol_cv_type_sig_atomic_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { sig_atomic_t atomic; ; return 0; } EOF -if { (eval echo configure:23414: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23417: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_type_sig_atomic_t=yes else @@ -23434,13 +23437,13 @@ EOF # test for pw_gecos in struct passwd echo $ac_n "checking struct passwd for pw_gecos""... $ac_c" 1>&6 -echo "configure:23438: checking struct passwd for pw_gecos" >&5 +echo "configure:23441: checking struct passwd for pw_gecos" >&5 if eval "test \"\${ol_cv_struct_passwd_pw_gecos+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { @@ -23450,7 +23453,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:23454: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23457: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_struct_passwd_pw_gecos=yes else @@ -23472,13 +23475,13 @@ fi # test for pw_passwd in struct passwd echo $ac_n "checking struct passwd for pw_passwd""... $ac_c" 1>&6 -echo "configure:23476: checking struct passwd for pw_passwd" >&5 +echo "configure:23479: checking struct passwd for pw_passwd" >&5 if eval "test \"\${ol_cv_struct_passwd_pw_passwd+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { @@ -23488,7 +23491,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:23492: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23495: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_struct_passwd_pw_passwd=yes else @@ -23510,7 +23513,7 @@ fi echo $ac_n "checking if toupper() requires islower()""... $ac_c" 1>&6 -echo "configure:23514: checking if toupper() requires islower()" >&5 +echo "configure:23517: checking if toupper() requires islower()" >&5 if eval "test \"\${ol_cv_c_upper_lower+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -23519,7 +23522,7 @@ else ol_cv_c_upper_lower=safe else cat > conftest.$ac_ext < @@ -23531,7 +23534,7 @@ main() exit(1); } EOF -if { (eval echo configure:23535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:23538: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ol_cv_c_upper_lower=no else @@ -23554,12 +23557,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:23558: checking for working const" >&5 +echo "configure:23561: checking for working const" >&5 if eval "test \"\${ac_cv_c_const+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -23629,12 +23632,12 @@ EOF fi echo $ac_n "checking if compiler understands volatile""... $ac_c" 1>&6 -echo "configure:23633: checking if compiler understands volatile" >&5 +echo "configure:23636: checking if compiler understands volatile" >&5 if eval "test \"\${ol_cv_c_volatile+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23650: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_c_volatile=yes else @@ -23674,14 +23677,14 @@ EOF else echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:23678: checking whether byte ordering is bigendian" >&5 +echo "configure:23681: checking whether byte ordering is bigendian" >&5 if eval "test \"\${ac_cv_c_bigendian+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext < #include @@ -23692,11 +23695,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:23696: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23699: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext < #include @@ -23707,7 +23710,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:23711: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23714: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -23727,7 +23730,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:23747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ac_cv_c_bigendian=no else @@ -23766,13 +23769,13 @@ fi fi echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:23770: checking size of short" >&5 +echo "configure:23773: checking size of short" >&5 if eval "test \"\${ac_cv_sizeof_short+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else for ac_size in 4 8 1 2 16 ; do # List sizes in rough order of prevalence. cat > conftest.$ac_ext < @@ -23783,7 +23786,7 @@ int main() { switch (0) case 0: case (sizeof (short) == $ac_size):; ; return 0; } EOF -if { (eval echo configure:23787: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23790: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sizeof_short=$ac_size else @@ -23806,13 +23809,13 @@ EOF echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:23810: checking size of int" >&5 +echo "configure:23813: checking size of int" >&5 if eval "test \"\${ac_cv_sizeof_int+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else for ac_size in 4 8 1 2 16 ; do # List sizes in rough order of prevalence. cat > conftest.$ac_ext < @@ -23823,7 +23826,7 @@ int main() { switch (0) case 0: case (sizeof (int) == $ac_size):; ; return 0; } EOF -if { (eval echo configure:23827: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sizeof_int=$ac_size else @@ -23846,13 +23849,13 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:23850: checking size of long" >&5 +echo "configure:23853: checking size of long" >&5 if eval "test \"\${ac_cv_sizeof_long+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else for ac_size in 4 8 1 2 16 ; do # List sizes in rough order of prevalence. cat > conftest.$ac_ext < @@ -23863,7 +23866,7 @@ int main() { switch (0) case 0: case (sizeof (long) == $ac_size):; ; return 0; } EOF -if { (eval echo configure:23867: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23870: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sizeof_long=$ac_size else @@ -23886,13 +23889,13 @@ EOF echo $ac_n "checking size of wchar_t""... $ac_c" 1>&6 -echo "configure:23890: checking size of wchar_t" >&5 +echo "configure:23893: checking size of wchar_t" >&5 if eval "test \"\${ac_cv_sizeof_wchar_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else for ac_size in 4 8 1 2 16 ; do # List sizes in rough order of prevalence. cat > conftest.$ac_ext < @@ -23903,7 +23906,7 @@ int main() { switch (0) case 0: case (sizeof (wchar_t) == $ac_size):; ; return 0; } EOF -if { (eval echo configure:23907: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:23910: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sizeof_wchar_t=$ac_size else @@ -23954,7 +23957,7 @@ EOF echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:23958: checking for 8-bit clean memcmp" >&5 +echo "configure:23961: checking for 8-bit clean memcmp" >&5 if eval "test \"\${ac_cv_func_memcmp_clean+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -23962,7 +23965,7 @@ else ac_cv_func_memcmp_clean=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 +if { (eval echo configure:23979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>&5 then ac_cv_func_memcmp_clean=yes else @@ -23998,12 +24001,12 @@ EOF fi echo $ac_n "checking for strftime""... $ac_c" 1>&6 -echo "configure:24002: checking for strftime" >&5 +echo "configure:24005: checking for strftime" >&5 if eval "test \"\${ac_cv_func_strftime+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24034: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_strftime=yes" else @@ -24049,7 +24052,7 @@ else echo "$ac_t""no" 1>&6 # strftime is in -lintl on SCO UNIX. echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6 -echo "configure:24053: checking for strftime in -lintl" >&5 +echo "configure:24056: checking for strftime in -lintl" >&5 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -24057,7 +24060,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -24096,12 +24099,12 @@ fi echo $ac_n "checking for inet_aton()""... $ac_c" 1>&6 -echo "configure:24100: checking for inet_aton()" >&5 +echo "configure:24103: checking for inet_aton()" >&5 if eval "test \"\${ol_cv_func_inet_aton+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_func_inet_aton=yes else @@ -24145,12 +24148,12 @@ EOF echo $ac_n "checking for _spawnlp""... $ac_c" 1>&6 -echo "configure:24149: checking for _spawnlp" >&5 +echo "configure:24152: checking for _spawnlp" >&5 if eval "test \"\${ac_cv_func__spawnlp+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__spawnlp=yes" else @@ -24198,12 +24201,12 @@ fi echo $ac_n "checking for _snprintf""... $ac_c" 1>&6 -echo "configure:24202: checking for _snprintf" >&5 +echo "configure:24205: checking for _snprintf" >&5 if eval "test \"\${ac_cv_func__snprintf+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__snprintf=yes" else @@ -24253,12 +24256,12 @@ fi echo $ac_n "checking for _vsnprintf""... $ac_c" 1>&6 -echo "configure:24257: checking for _vsnprintf" >&5 +echo "configure:24260: checking for _vsnprintf" >&5 if eval "test \"\${ac_cv_func__vsnprintf+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__vsnprintf=yes" else @@ -24308,12 +24311,12 @@ fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:24312: checking for vprintf" >&5 +echo "configure:24315: checking for vprintf" >&5 if eval "test \"\${ac_cv_func_vprintf+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -24361,12 +24364,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:24365: checking for _doprnt" >&5 +echo "configure:24368: checking for _doprnt" >&5 if eval "test \"\${ac_cv_func__doprnt+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -24419,12 +24422,12 @@ if test $ac_cv_func_vprintf = yes ; then for ac_func in snprintf vsnprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:24423: checking for $ac_func" >&5 +echo "configure:24426: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -24531,12 +24534,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:24535: checking for $ac_func" >&5 +echo "configure:24538: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -24588,12 +24591,12 @@ done for ac_func in getopt getpeereid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:24592: checking for $ac_func" >&5 +echo "configure:24595: checking for $ac_func" >&5 if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24624: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -24649,19 +24652,19 @@ if test "$ac_cv_func_getopt" != yes; then fi if test "$ac_cv_func_getpeereid" != yes; then echo $ac_n "checking for msg_accrights in msghdr""... $ac_c" 1>&6 -echo "configure:24653: checking for msg_accrights in msghdr" >&5 +echo "configure:24656: checking for msg_accrights in msghdr" >&5 if eval "test \"\${ol_cv_msghdr_msg_accrights+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { struct msghdr m; m.msg_accrightslen=0 ; return 0; } EOF -if { (eval echo configure:24665: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:24668: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_msghdr_msg_accrights=yes else @@ -24684,19 +24687,19 @@ EOF if test "$ac_cv_func_getpeereid" != yes; then echo $ac_n "checking for msg_control in msghdr""... $ac_c" 1>&6 -echo "configure:24688: checking for msg_control in msghdr" >&5 +echo "configure:24691: checking for msg_control in msghdr" >&5 if eval "test \"\${ol_cv_msghdr_msg_control+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { struct msghdr m; m.msg_control=(struct cmsghdr *)0 ; return 0; } EOF -if { (eval echo configure:24700: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:24703: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_msghdr_msg_control=yes else @@ -24741,17 +24744,17 @@ if test "$ol_enable_slapi" != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:24745: checking for $ac_hdr" >&5 +echo "configure:24748: checking for $ac_hdr" >&5 if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:24755: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:24758: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -24782,7 +24785,7 @@ done { echo "configure: error: could not locate " 1>&2; exit 1; } fi echo $ac_n "checking for lt_dlinit in -lltdl""... $ac_c" 1>&6 -echo "configure:24786: checking for lt_dlinit in -lltdl" >&5 +echo "configure:24789: checking for lt_dlinit in -lltdl" >&5 ac_lib_var=`echo ltdl'_'lt_dlinit | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -24790,7 +24793,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lltdl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:24808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -25281,6 +25284,21 @@ EOF fi +if test "$ol_enable_retcode" != no ; then + BUILD_RETCODE=$ol_enable_retcode + if test "$ol_enable_retcode" = mod ; then + MFLAG=SLAPD_MOD_DYNAMIC + SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS retcode.la" + else + MFLAG=SLAPD_MOD_STATIC + SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS retcode.o" + fi + cat >> confdefs.h < header file. */ #undef HAVE_UNISTD_H +/* Define if you have the header file. */ +#undef HAVE_UTIME_H + /* Define if you have the header file. */ #undef HAVE_WINSOCK_H @@ -1061,6 +1064,9 @@ /* define for Referential Integrity overlay */ #undef SLAPD_OVER_REFINT +/* define for Referential Integrity overlay */ +#undef SLAPD_OVER_RETCODE + /* define for Rewrite/Remap overlay */ #undef SLAPD_OVER_RWM diff --git a/include/slapi-plugin.h b/include/slapi-plugin.h index dcb3a95a63..8344cf766a 100644 --- a/include/slapi-plugin.h +++ b/include/slapi-plugin.h @@ -40,6 +40,9 @@ typedef struct slapi_mod Slapi_Mod; typedef struct slapi_mods Slapi_Mods; typedef struct slapi_componentid Slapi_ComponentId; +#define SLAPI_ATTR_UNIQUEID "entryUUID" +#define SLAPI_ATTR_OBJECTCLASS "objectClass" + /* pblock routines */ int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value ); int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value ); @@ -76,6 +79,7 @@ char *slapi_dn_normalize( char *dn ); char *slapi_dn_normalize_case( char *dn ); int slapi_dn_issuffix( char *dn, char *suffix ); char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn ); +int slapi_dn_isbesuffix( Slapi_PBlock *pb, char *dn ); char *slapi_dn_parent( const char *dn ); int slapi_dn_isparent( const char *parentdn, const char *childdn ); char *slapi_dn_ignore_case( char *dn ); @@ -141,7 +145,7 @@ Slapi_Value *slapi_value_new_value(const Slapi_Value *v); Slapi_Value *slapi_value_new_string(const char *s); Slapi_Value *slapi_value_init(Slapi_Value *v); Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval); -Slapi_Value *slapi_value_init_string(Slapi_Value *v,const char *s); +Slapi_Value *slapi_value_init_string(Slapi_Value *v, const char *s); Slapi_Value *slapi_value_dup(const Slapi_Value *v); void slapi_value_free(Slapi_Value **value); const struct berval *slapi_value_get_berval( const Slapi_Value *value ); @@ -156,7 +160,7 @@ unsigned int slapi_value_get_uint(const Slapi_Value *value); long slapi_value_get_long(const Slapi_Value *value); unsigned long slapi_value_get_ulong(const Slapi_Value *value); size_t slapi_value_get_length(const Slapi_Value *value); -int slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value *v2); +int slapi_value_compare(const Slapi_Attr *a, const Slapi_Value *v1, const Slapi_Value *v2); Slapi_ValueSet *slapi_valueset_new( void ); void slapi_valueset_free(Slapi_ValueSet *vs); @@ -168,6 +172,70 @@ int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v); int slapi_valueset_count( const Slapi_ValueSet *vs); void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2); +/* DNs */ +Slapi_DN *slapi_sdn_new( void ); +Slapi_DN *slapi_sdn_new_dn_byval( const char *dn ); +Slapi_DN *slapi_sdn_new_ndn_byval( const char *ndn ); +Slapi_DN *slapi_sdn_new_dn_byref( const char *dn ); +Slapi_DN *slapi_sdn_new_ndn_byref( const char *ndn ); +Slapi_DN *slapi_sdn_new_dn_passin( const char *dn ); +Slapi_DN *slapi_sdn_set_dn_byval( Slapi_DN *sdn, const char *dn ); +Slapi_DN *slapi_sdn_set_dn_byref( Slapi_DN *sdn, const char *dn ); +Slapi_DN *slapi_sdn_set_dn_passin( Slapi_DN *sdn, const char *dn ); +Slapi_DN *slapi_sdn_set_ndn_byval( Slapi_DN *sdn, const char *ndn ); +Slapi_DN *slapi_sdn_set_ndn_byref( Slapi_DN *sdn, const char *ndn ); +void slapi_sdn_done( Slapi_DN *sdn ); +void slapi_sdn_free( Slapi_DN **sdn ); +const char * slapi_sdn_get_dn( const Slapi_DN *sdn ); +const char * slapi_sdn_get_ndn( const Slapi_DN *sdn ); +void slapi_sdn_get_parent( const Slapi_DN *sdn,Slapi_DN *sdn_parent ); +void slapi_sdn_get_backend_parent( const Slapi_DN *sdn, Slapi_DN *sdn_parent, const Slapi_Backend *backend ); +Slapi_DN * slapi_sdn_dup( const Slapi_DN *sdn ); +void slapi_sdn_copy( const Slapi_DN *from, Slapi_DN *to ); +int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 ); +int slapi_sdn_isempty( const Slapi_DN *sdn ); +int slapi_sdn_issuffix(const Slapi_DN *sdn, const Slapi_DN *suffixsdn ); +int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child ); +int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child ); +int slapi_sdn_get_ndn_len( const Slapi_DN *sdn ); +int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope ); +void slapi_sdn_get_rdn( const Slapi_DN *sdn,Slapi_RDN *rdn ); +Slapi_DN *slapi_sdn_set_rdn( Slapi_DN *sdn, const Slapi_RDN *rdn ); +Slapi_DN *slapi_sdn_set_parent( Slapi_DN *sdn, const Slapi_DN *parentdn ); +int slapi_sdn_is_rdn_component( const Slapi_DN *rdn, const Slapi_Attr *a, const Slapi_Value *v ); +char * slapi_moddn_get_newdn( Slapi_DN *dn_olddn, char *newrdn, char *newsuperiordn ); + +/* RDNs */ +Slapi_RDN *slapi_rdn_new( void ); +Slapi_RDN *slapi_rdn_new_dn( const char *dn ); +Slapi_RDN *slapi_rdn_new_sdn( const Slapi_DN *sdn ); +Slapi_RDN *slapi_rdn_new_rdn( const Slapi_RDN *fromrdn ); +void slapi_rdn_init( Slapi_RDN *rdn ); +void slapi_rdn_init_dn( Slapi_RDN *rdn, const char *dn ); +void slapi_rdn_init_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn ); +void slapi_rdn_init_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn ); +void slapi_rdn_set_dn( Slapi_RDN *rdn, const char *dn ); +void slapi_rdn_set_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn ); +void slapi_rdn_set_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn ); +void slapi_rdn_free( Slapi_RDN **rdn ); +void slapi_rdn_done( Slapi_RDN *rdn ); +int slapi_rdn_get_first( Slapi_RDN *rdn, char **type, char **value ); +int slapi_rdn_get_next( Slapi_RDN *rdn, int index, char **type, char **value ); +int slapi_rdn_get_index( Slapi_RDN *rdn, const char *type, const char *value, size_t length ); +int slapi_rdn_get_index_attr( Slapi_RDN *rdn, const char *type, char **value ); +int slapi_rdn_contains( Slapi_RDN *rdn, const char *type, const char *value,size_t length ); +int slapi_rdn_contains_attr( Slapi_RDN *rdn, const char *type, char **value ); +int slapi_rdn_add( Slapi_RDN *rdn, const char *type, const char *value ); +int slapi_rdn_remove_index( Slapi_RDN *rdn, int atindex ); +int slapi_rdn_remove( Slapi_RDN *rdn, const char *type, const char *value, size_t length ); +int slapi_rdn_remove_attr( Slapi_RDN *rdn, const char *type ); +int slapi_rdn_isempty( const Slapi_RDN *rdn ); +int slapi_rdn_get_num_components( Slapi_RDN *rdn ); +int slapi_rdn_compare( Slapi_RDN *rdn1, Slapi_RDN *rdn2 ); +const char *slapi_rdn_get_rdn( const Slapi_RDN *rdn ); +const char *slapi_rdn_get_nrdn( const Slapi_RDN *rdn ); +Slapi_DN *slapi_sdn_add_rdn( Slapi_DN *sdn, const Slapi_RDN *rdn ); + /* locks and synchronization */ typedef struct slapi_mutex Slapi_Mutex; typedef struct slapi_condvar Slapi_CondVar; @@ -189,7 +257,7 @@ void slapi_ch_free( void **ptr ); void slapi_ch_free_string( char **ptr ); char *slapi_ch_calloc( unsigned long nelem, unsigned long size ); char *slapi_ch_realloc( char *block, unsigned long size ); -char *slapi_ch_strdup( char *s ); +char *slapi_ch_strdup( const char *s ); void slapi_ch_array_free( char **arrayp ); struct berval *slapi_ch_bvdup(const struct berval *v); struct berval **slapi_ch_bvecdup(const struct berval **v); @@ -218,6 +286,13 @@ void slapi_register_supported_saslmechanism(char *mechanism); char **slapi_get_supported_saslmechanisms(); char **slapi_get_supported_extended_ops(void); +/* operation */ +int slapi_op_abandoned( Slapi_PBlock *pb ); +unsigned long slapi_op_get_type(Slapi_Operation * op); +void slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag); +void slapi_operation_clear_flag(Slapi_Operation *op, unsigned long flag); +int slapi_operation_is_flag_set(Slapi_Operation *op, unsigned long flag); +char *slapi_op_type_to_string(unsigned long type); /* send ldap result back */ void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched, @@ -236,6 +311,7 @@ int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval ); Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f ); Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev ); int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type ); +int slapi_x_filter_set_attribute_type( Slapi_Filter *f, const char *type ); int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial, char ***any, char **final ); Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2); @@ -266,13 +342,60 @@ Slapi_PBlock *slapi_delete_internal( char * dn, LDAPControl **controls, Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn, int deloldrdn, LDAPControl **controls, int log_change ); -#if 0 -Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn, - char *newParent, int deloldrdn, LDAPControl **controls, - int log_change ); -#endif +Slapi_PBlock *slapi_rename_internal( const char * olddn, const char *newrdn, + const char *newsuperior, int delolrdn, + LDAPControl **controls, int log_change ); void slapi_free_search_results_internal(Slapi_PBlock *pb); +/* new internal add/delete/search/modify routines */ +typedef void (*plugin_result_callback)( int rc, void *callback_data ); +typedef int (*plugin_referral_entry_callback)( char * referral, + void *callback_data ); +typedef int (*plugin_search_entry_callback)( Slapi_Entry *e, + void *callback_data ); +void slapi_free_search_results_internal( Slapi_PBlock *pb ); + +#define SLAPI_OP_FLAG_NEVER_CHAIN 0x0800 + +int slapi_search_internal_pb( Slapi_PBlock *pb ); +int slapi_search_internal_callback_pb( Slapi_PBlock *pb, void *callback_data, + plugin_result_callback prc, plugin_search_entry_callback psec, + plugin_referral_entry_callback prec ); +int slapi_add_internal_pb( Slapi_PBlock *pb ); +int slapi_modify_internal_pb( Slapi_PBlock *pb ); +int slapi_modrdn_internal_pb( Slapi_PBlock *pb ); +int slapi_delete_internal_pb( Slapi_PBlock *pb ); + +int slapi_seq_internal_callback_pb(Slapi_PBlock *pb, void *callback_data, + plugin_result_callback res_callback, + plugin_search_entry_callback srch_callback, + plugin_referral_entry_callback ref_callback); + +void slapi_search_internal_set_pb( Slapi_PBlock *pb, const char *base, + int scope, const char *filter, char **attrs, int attrsonly, + LDAPControl **controls, const char *uniqueid, + Slapi_ComponentId *plugin_identity, int operation_flags ); +void slapi_add_entry_internal_set_pb( Slapi_PBlock *pb, Slapi_Entry *e, + LDAPControl **controls, Slapi_ComponentId *plugin_identity, + int operation_flags ); +int slapi_add_internal_set_pb( Slapi_PBlock *pb, const char *dn, + LDAPMod **attrs, LDAPControl **controls, + Slapi_ComponentId *plugin_identity, int operation_flags ); +void slapi_modify_internal_set_pb( Slapi_PBlock *pb, const char *dn, + LDAPMod **mods, LDAPControl **controls, const char *uniqueid, + Slapi_ComponentId *plugin_identity, int operation_flags ); +void slapi_rename_internal_set_pb( Slapi_PBlock *pb, const char *olddn, + const char *newrdn, const char *newsuperior, int deloldrdn, + LDAPControl **controls, const char *uniqueid, + Slapi_ComponentId *plugin_identity, int operation_flags ); +void slapi_delete_internal_set_pb( Slapi_PBlock *pb, const char *dn, + LDAPControl **controls, const char *uniqueid, + Slapi_ComponentId *plugin_identity, int operation_flags ); +void slapi_seq_internal_set_pb( Slapi_PBlock *pb, char *ibase, int type, + char *attrname, char *val, char **attrs, int attrsonly, + LDAPControl **controls, Slapi_ComponentId *plugin_identity, + int operation_flags ); + /* connection related routines */ int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL); int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort); @@ -288,6 +411,12 @@ int compute_rewrite_search_filter(Slapi_PBlock *pb); int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn); int slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb); +/* backend routines */ +void slapi_be_set_readonly( Slapi_Backend *be, int readonly ); +int slapi_be_get_readonly( Slapi_Backend *be ); +const char *slapi_x_be_get_updatedn( Slapi_Backend *be ); +Slapi_Backend *slapi_be_select( const Slapi_DN *sdn ); + /* ACL plugins; only SLAPI_PLUGIN_ACL_ALLOW_ACCESS supported now */ typedef int (*slapi_acl_callback_t)(Slapi_PBlock *pb, Slapi_Entry *e, @@ -384,7 +513,8 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); /* operation params */ #define SLAPI_OPINITIATED_TIME 140 #define SLAPI_REQUESTOR_DN 141 -#define SLAPI_REQUESTOR_ISUPDATEDN 142 +#define SLAPI_IS_REPLICATED_OPERATION 142 +#define SLAPI_REQUESTOR_ISUPDATEDN SLAPI_IS_REPLICATED_OPERATION /* connection structure params*/ #define SLAPI_CONN_DN 143 @@ -397,6 +527,9 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); #define SLAPI_X_CONN_IS_UDP 1302 #define SLAPI_X_CONN_SSF 1303 #define SLAPI_X_CONN_SASL_CONTEXT 1304 +#define SLAPI_X_OPERATION_DELETE_GLUE_PARENT 1305 +#define SLAPI_X_MANAGEDIT 1306 +#define SLAPI_X_OPERATION_NO_SCHEMA_CHECK 1307 /* Authentication types */ #define SLAPD_AUTH_NONE "none" @@ -415,12 +548,17 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); #define SLAPI_PLUGIN_OBJECT 10 #define SLAPI_PLUGIN_DESTROY_FN 11 #define SLAPI_PLUGIN_DESCRIPTION 12 +#define SLAPI_PLUGIN_IDENTITY 13 /* internal opreations params */ #define SLAPI_PLUGIN_INTOP_RESULT 15 #define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16 #define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17 +/* transaction arguments */ +#define SLAPI_PARENT_TXN 190 +#define SLAPI_TXN 191 + /* function pointer params for backends */ #define SLAPI_PLUGIN_DB_BIND_FN 200 #define SLAPI_PLUGIN_DB_UNBIND_FN 201 @@ -456,7 +594,7 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); #define SLAPI_PLUGIN_EXT_OP_FN 300 #define SLAPI_PLUGIN_EXT_OP_OIDLIST 301 -/* functions for preoperation functions */ +/* preoperation */ #define SLAPI_PLUGIN_PRE_BIND_FN 401 #define SLAPI_PLUGIN_PRE_UNBIND_FN 402 #define SLAPI_PLUGIN_PRE_SEARCH_FN 403 @@ -470,7 +608,19 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); #define SLAPI_PLUGIN_PRE_REFERRAL_FN 411 #define SLAPI_PLUGIN_PRE_RESULT_FN 412 -/* functions for postoperation functions*/ +/* internal preoperation */ +#define SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN 420 +#define SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN 421 +#define SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN 422 +#define SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN 423 + +/* backend preoperation */ +#define SLAPI_PLUGIN_BE_PRE_ADD_FN 450 +#define SLAPI_PLUGIN_BE_PRE_MODIFY_FN 451 +#define SLAPI_PLUGIN_BE_PRE_MODRDN_FN 452 +#define SLAPI_PLUGIN_BE_PRE_DELETE_FN 453 + +/* postoperation */ #define SLAPI_PLUGIN_POST_BIND_FN 501 #define SLAPI_PLUGIN_POST_UNBIND_FN 502 #define SLAPI_PLUGIN_POST_SEARCH_FN 503 @@ -484,6 +634,18 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); #define SLAPI_PLUGIN_POST_REFERRAL_FN 511 #define SLAPI_PLUGIN_POST_RESULT_FN 512 +/* internal postoperation */ +#define SLAPI_PLUGIN_INTERNAL_POST_ADD_FN 520 +#define SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN 521 +#define SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN 522 +#define SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN 523 + +/* backend postoperation */ +#define SLAPI_PLUGIN_BE_POST_ADD_FN 550 +#define SLAPI_PLUGIN_BE_POST_MODIFY_FN 551 +#define SLAPI_PLUGIN_BE_POST_MODRDN_FN 552 +#define SLAPI_PLUGIN_BE_POST_DELETE_FN 553 + #define SLAPI_OPERATION_TYPE 590 #define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600 @@ -568,16 +730,23 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); #define SLAPI_CONFIG_ARGV 43 /* operational params */ +#define SLAPI_TARGET_ADDRESS 48 +#define SLAPI_TARGET_UNIQUEID 49 #define SLAPI_TARGET_DN 50 -#define SLAPI_REQCONTROLS 51 /* server LDAPv3 controls */ +#define SLAPI_REQCONTROLS 51 #define SLAPI_RESCONTROLS 55 #define SLAPI_ADD_RESCONTROL 56 +#define SLAPI_CONTROLS_ARG 58 /* add params */ #define SLAPI_ADD_TARGET SLAPI_TARGET_DN #define SLAPI_ADD_ENTRY 60 +#define SLAPI_ADD_EXISTING_DN_ENTRY 61 +#define SLAPI_ADD_PARENT_ENTRY 62 +#define SLAPI_ADD_PARENT_UNIQUEID 63 +#define SLAPI_ADD_EXISTING_UNIQUEID_ENTRY 64 /* bind params */ #define SLAPI_BIND_TARGET SLAPI_TARGET_DN @@ -593,16 +762,23 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); /* delete params */ #define SLAPI_DELETE_TARGET SLAPI_TARGET_DN +#define SLAPI_DELETE_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY /* modify params */ #define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN #define SLAPI_MODIFY_MODS 90 +#define SLAPI_MODIFY_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY /* modrdn params */ #define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN #define SLAPI_MODRDN_NEWRDN 100 #define SLAPI_MODRDN_DELOLDRDN 101 #define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */ +#define SLAPI_MODRDN_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY +#define SLAPI_MODRDN_PARENT_ENTRY 104 +#define SLAPI_MODRDN_NEWPARENT_ENTRY 105 +#define SLAPI_MODRDN_TARGET_ENTRY 106 +#define SLAPI_MODRDN_NEWSUPERIOR_ADDRESS 107 /* search params */ #define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN @@ -630,6 +806,7 @@ int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); #define SLAPI_FAIL_DISKFULL -2 #define SLAPI_FAIL_GENERAL -1 +#define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2 #define SLAPI_BIND_SUCCESS 0 #define SLAPI_BIND_FAIL 2 #define SLAPI_BIND_ANONYMOUS 3 diff --git a/libraries/liblber/memory.c b/libraries/liblber/memory.c index 904630fd30..a9dc92b915 100644 --- a/libraries/liblber/memory.c +++ b/libraries/liblber/memory.c @@ -143,8 +143,9 @@ ber_memfree_x( void *p, void *ctx ) ber_int_options.lbo_meminuse -= mh->bm_length; #ifdef LDAP_MEMORY_TRACE - fprintf(stderr, "0x%08x 0x%08x -f- %d ber_memfree %d\n", - mh->bm_sequence, mh, mh->bm_length, ber_int_options.lbo_meminuse); + fprintf(stderr, "0x%08lx 0x%08lx -f- %ld ber_memfree %ld\n", + (long)mh->bm_sequence, (long)mh, (long)mh->bm_length, + ber_int_options.lbo_meminuse); #endif /* Fill the free space with poison */ memset( mh, 0xff, mh->bm_length + sizeof(struct ber_mem_hdr) + sizeof(ber_int_t)); @@ -155,7 +156,7 @@ ber_memfree_x( void *p, void *ctx ) return; } - assert( ber_int_memory_fns->bmf_free ); + assert( ber_int_memory_fns->bmf_free != 0 ); (*ber_int_memory_fns->bmf_free)( p, ctx ); } @@ -220,8 +221,9 @@ ber_memalloc_x( ber_len_t s, void *ctx ) #ifdef LDAP_MEMORY_TRACE mh->bm_sequence = sequence++; - fprintf(stderr, "0x%08x 0x%08x -a- %d ber_memalloc %d\n", - mh->bm_sequence, mh, mh->bm_length, ber_int_options.lbo_meminuse); + fprintf(stderr, "0x%08lx 0x%08lx -a- %ld ber_memalloc %ld\n", + (long)mh->bm_sequence, (long)mh, (long)mh->bm_length, + ber_int_options.lbo_meminuse); #endif /* poison new memory */ memset( (char *)&mh[1], 0xff, s); @@ -277,8 +279,9 @@ ber_memcalloc_x( ber_len_t n, ber_len_t s, void *ctx ) #ifdef LDAP_MEMORY_TRACE mh->bm_sequence = sequence++; - fprintf(stderr, "0x%08x 0x%08x -a- %d ber_memcalloc %d\n", - mh->bm_sequence, mh, mh->bm_length, ber_int_options.lbo_meminuse); + fprintf(stderr, "0x%08lx 0x%08lx -a- %ld ber_memcalloc %ld\n", + (long)mh->bm_sequence, (long)mh, (long)mh->bm_length, + ber_int_options.lbo_meminuse); #endif BER_MEM_VALID( &mh[1] ); new = &mh[1]; @@ -351,8 +354,9 @@ ber_memrealloc_x( void* p, ber_len_t s, void *ctx ) ber_int_options.lbo_meminuse += s - oldlen; #ifdef LDAP_MEMORY_TRACE - fprintf(stderr, "0x%08x 0x%08x -a- %d ber_memrealloc %d\n", - mh->bm_sequence, mh, mh->bm_length, ber_int_options.lbo_meminuse); + fprintf(stderr, "0x%08lx 0x%08lx -a- %ld ber_memrealloc %ld\n", + (long)mh->bm_sequence, (long)mh, (long)mh->bm_length, + ber_int_options.lbo_meminuse); #endif BER_MEM_VALID( &mh[1] ); return &mh[1]; diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c index 11a44c265c..39f58a6bef 100644 --- a/libraries/liblber/options.c +++ b/libraries/liblber/options.c @@ -25,6 +25,8 @@ char ber_pvt_opt_on; /* used to get a non-NULL address for *_OPT_ON */ struct lber_options ber_int_options = { LBER_UNINITIALIZED, 0, 0, 0 }; +static BerMemoryFunctions ber_int_memory_fns_datum; + int ber_get_option( void *item, @@ -43,10 +45,12 @@ ber_get_option( } if(item == NULL) { - if(option == LBER_OPT_BER_DEBUG) { + switch ( option ) { + case LBER_OPT_BER_DEBUG: * (int *) outvalue = ber_int_debug; return LBER_OPT_SUCCESS; - } else if(option == LBER_OPT_MEMORY_INUSE) { + + case LBER_OPT_MEMORY_INUSE: /* The memory inuse is a global variable on kernal implementations. * This means that memory debug is shared by all LDAP processes * so for this variable to have much meaning, only one LDAP process @@ -60,7 +64,8 @@ ber_get_option( #else return LBER_OPT_ERROR; #endif - } else if(option == LBER_OPT_LOG_PRINT_FILE) { + + case LBER_OPT_LOG_PRINT_FILE: *((FILE**)outvalue) = (FILE*)ber_pvt_err_file; return LBER_OPT_SUCCESS; } @@ -124,11 +129,10 @@ ber_set_option( if( (ber_int_options.lbo_valid == LBER_UNINITIALIZED) && ( ber_int_memory_fns == NULL ) && ( option == LBER_OPT_MEMORY_FNS ) - && ( invalue != NULL )) + && ( invalue != NULL ) ) { const BerMemoryFunctions *f = (const BerMemoryFunctions *) invalue; - /* make sure all functions are provided */ if(!( f->bmf_malloc && f->bmf_calloc && f->bmf_realloc && f->bmf_free )) @@ -137,13 +141,7 @@ ber_set_option( return LBER_OPT_ERROR; } - ber_int_memory_fns = (BerMemoryFunctions *) - (*(f->bmf_malloc))(sizeof(BerMemoryFunctions), NULL); - - if ( ber_int_memory_fns == NULL ) { - ber_errno = LBER_ERROR_MEMORY; - return LBER_OPT_ERROR; - } + ber_int_memory_fns = &ber_int_memory_fns_datum; AC_MEMCPY(ber_int_memory_fns, f, sizeof(BerMemoryFunctions)); @@ -160,17 +158,20 @@ ber_set_option( } if(item == NULL) { - if(option == LBER_OPT_BER_DEBUG) { + switch ( option ) { + case LBER_OPT_BER_DEBUG: ber_int_debug = * (const int *) invalue; return LBER_OPT_SUCCESS; - } else if(option == LBER_OPT_LOG_PRINT_FN) { + case LBER_OPT_LOG_PRINT_FN: ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue; return LBER_OPT_SUCCESS; - } else if(option == LBER_OPT_LOG_PRINT_FILE) { + + case LBER_OPT_LOG_PRINT_FILE: ber_pvt_err_file = (void *) invalue; return LBER_OPT_SUCCESS; - } else if(option == LBER_OPT_MEMORY_INUSE) { + + case LBER_OPT_MEMORY_INUSE: /* The memory inuse is a global variable on kernal implementations. * This means that memory debug is shared by all LDAP processes * so for this variable to have much meaning, only one LDAP process @@ -184,8 +185,9 @@ ber_set_option( #else return LBER_OPT_ERROR; #endif - } else if(option == LBER_OPT_LOG_PROC) { + case LBER_OPT_LOG_PROC: ber_int_log_proc = (BER_LOG_FN)invalue; + return LBER_OPT_SUCCESS; } ber_errno = LBER_ERROR_PARAM; diff --git a/libraries/liblber/sockbuf.c b/libraries/liblber/sockbuf.c index 390f3e4416..4960c93bb4 100644 --- a/libraries/liblber/sockbuf.c +++ b/libraries/liblber/sockbuf.c @@ -104,13 +104,13 @@ ber_sockbuf_ctrl( Sockbuf *sb, int opt, void *arg ) case LBER_SB_OPT_GET_FD: if ( arg != NULL ) { - *((int *)arg) = sb->sb_fd; + *((ber_socket_t *)arg) = sb->sb_fd; } ret = ( sb->sb_fd == AC_SOCKET_INVALID ? -1 : 1); break; case LBER_SB_OPT_SET_FD: - sb->sb_fd = *((int *)arg); + sb->sb_fd = *((ber_socket_t *)arg); ret = 1; break; diff --git a/libraries/libldap/abandon.c b/libraries/libldap/abandon.c index 1b2964961e..1e11effc53 100644 --- a/libraries/libldap/abandon.c +++ b/libraries/libldap/abandon.c @@ -238,6 +238,7 @@ do_abandon( } else { /* send the message */ if ( lr != NULL ) { + assert( lr->lr_conn != NULL ); sb = lr->lr_conn->lconn_sb; } else { sb = ld->ld_sb; diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index 553d39faa9..18c493688c 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -207,7 +207,7 @@ sb_sasl_pkt_length( const unsigned char *buf, int debuglevel ) | buf[1] << 16 | buf[2] << 8 | buf[3]; - + if ( size > SASL_MAX_BUFF_SIZE ) { /* somebody is trying to mess me up. */ ber_log_printf( LDAP_DEBUG_ANY, debuglevel, @@ -877,7 +877,7 @@ static struct { { BER_BVC("minssf="), 0, GOT_MINSSF, 0 }, { BER_BVC("maxssf="), 0, GOT_MAXSSF, INT_MAX }, { BER_BVC("maxbufsize="), 0, GOT_MAXBUF, 65536 }, - { BER_BVNULL, 0, 0 } + { BER_BVNULL, 0, 0, 0 } }; void ldap_pvt_sasl_secprops_unparse( @@ -895,7 +895,7 @@ void ldap_pvt_sasl_secprops_unparse( comma = 0; for ( i=0; !BER_BVISNULL( &sprops[i].key ); i++ ) { if ( sprops[i].ival ) { - int v; + int v = 0; switch( sprops[i].ival ) { case GOT_MINSSF: v = secprops->min_ssf; break; @@ -928,7 +928,7 @@ void ldap_pvt_sasl_secprops_unparse( comma = 0; for ( i=0; !BER_BVISNULL( &sprops[i].key ); i++ ) { if ( sprops[i].ival ) { - int v; + int v = 0; switch( sprops[i].ival ) { case GOT_MINSSF: v = secprops->min_ssf; break; @@ -1206,7 +1206,7 @@ int ldap_pvt_sasl_mutex_lock(void *mutex) return SASL_OK; } #else /* !LDAP_DEBUG_R_SASL */ - assert( mutex ); + assert( mutex != NULL ); #endif /* !LDAP_DEBUG_R_SASL */ return ldap_pvt_thread_mutex_lock( (ldap_pvt_thread_mutex_t *)mutex ) ? SASL_FAIL : SASL_OK; @@ -1219,7 +1219,7 @@ int ldap_pvt_sasl_mutex_unlock(void *mutex) return SASL_OK; } #else /* !LDAP_DEBUG_R_SASL */ - assert( mutex ); + assert( mutex != NULL ); #endif /* !LDAP_DEBUG_R_SASL */ return ldap_pvt_thread_mutex_unlock( (ldap_pvt_thread_mutex_t *)mutex ) ? SASL_FAIL : SASL_OK; @@ -1232,7 +1232,7 @@ void ldap_pvt_sasl_mutex_dispose(void *mutex) return; } #else /* !LDAP_DEBUG_R_SASL */ - assert( mutex ); + assert( mutex != NULL ); #endif /* !LDAP_DEBUG_R_SASL */ (void) ldap_pvt_thread_mutex_destroy( (ldap_pvt_thread_mutex_t *)mutex ); LDAP_FREE( mutex ); diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index befab53b3b..3cb13f70e7 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -179,7 +179,7 @@ ldap_perror( LDAP *ld, LDAP_CONST char *str ) assert( ld != NULL ); assert( LDAP_VALID( ld ) ); - assert( str ); + assert( str != NULL ); e = ldap_int_error( ld->ld_errno ); diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index ca45d8247f..9bff47c05b 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -358,7 +358,7 @@ ldap_dn_normalize( LDAP_CONST char *dnin, Debug( LDAP_DEBUG_TRACE, "ldap_dn_normalize\n", 0, 0, 0 ); - assert( dnout ); + assert( dnout != NULL ); *dnout = NULL; @@ -557,14 +557,14 @@ ldap_dn_normalize( LDAP_CONST char *dnin, * LDAPAVA helpers (will become part of the API for operations * on structural representations of DNs). */ -LDAPAVA * +static LDAPAVA * ldapava_new( const struct berval *attr, const struct berval *val, unsigned flags, void *ctx ) { LDAPAVA *ava; - assert( attr ); - assert( val ); + assert( attr != NULL ); + assert( val != NULL ); ava = LDAP_MALLOCX( sizeof( LDAPAVA ) + attr->bv_len + 1, ctx ); @@ -586,7 +586,7 @@ ldapava_new( const struct berval *attr, const struct berval *val, void ldapava_free( LDAPAVA *ava, void *ctx ) { - assert( ava ); + assert( ava != NULL ); #if 0 /* ava's private must be freed by caller @@ -673,7 +673,7 @@ ldap_str2dn( LDAP_CONST char *str, LDAPDN *dn, unsigned flags ) { struct berval bv; - assert( str ); + assert( str != NULL ); bv.bv_len = strlen( str ); bv.bv_val = (char *) str; @@ -700,9 +700,9 @@ ldap_bv2dn_x( struct berval *bvin, LDAPDN *dn, unsigned flags, void *ctx ) char *str, *end; struct berval bvtmp, *bv = &bvtmp; - assert( bvin ); - assert( bvin->bv_val ); - assert( dn ); + assert( bvin != NULL ); + assert( bvin->bv_val != NULL ); + assert( dn != NULL ); *bv = *bvin; str = bv->bv_val; @@ -911,7 +911,7 @@ ldap_str2rdn( LDAP_CONST char *str, LDAPRDN *rdn, { struct berval bv; - assert( str ); + assert( str != NULL ); assert( str[ 0 ] != '\0' ); /* FIXME: is this required? */ bv.bv_len = strlen( str ); @@ -949,11 +949,11 @@ ldap_bv2rdn_x( struct berval *bv, LDAPRDN *rdn, char *str; ber_len_t stoplen; - assert( bv ); - assert( bv->bv_len ); - assert( bv->bv_val ); + assert( bv != NULL ); + assert( bv->bv_len != 0 ); + assert( bv->bv_val != NULL ); assert( rdn || flags & LDAP_DN_SKIP ); - assert( n ); + assert( n != NULL ); str = bv->bv_val; stoplen = bv->bv_len; @@ -1435,9 +1435,9 @@ str2strval( const char *str, ber_len_t stoplen, struct berval *val, const char * const char *p, *end, *startPos, *endPos = NULL; ber_len_t len, escapes; - assert( str ); - assert( val ); - assert( next ); + assert( str != NULL ); + assert( val != NULL ); + assert( next != NULL ); *next = NULL; end = str + stoplen; @@ -1581,9 +1581,9 @@ DCE2strval( const char *str, struct berval *val, const char **next, unsigned fla const char *p, *startPos, *endPos = NULL; ber_len_t len, escapes; - assert( str ); - assert( val ); - assert( next ); + assert( str != NULL ); + assert( val != NULL ); + assert( next != NULL ); *next = NULL; @@ -1666,9 +1666,9 @@ IA52strval( const char *str, struct berval *val, const char **next, unsigned fla const char *p, *startPos, *endPos = NULL; ber_len_t len, escapes; - assert( str ); - assert( val ); - assert( next ); + assert( str != NULL ); + assert( val != NULL ); + assert( next != NULL ); *next = NULL; @@ -1742,9 +1742,9 @@ quotedIA52strval( const char *str, struct berval *val, const char **next, unsign ber_len_t len; unsigned escapes = 0; - assert( str ); - assert( val ); - assert( next ); + assert( str != NULL ); + assert( val != NULL ); + assert( next != NULL ); *next = NULL; @@ -1832,8 +1832,8 @@ hexstr2bin( const char *str, char *c ) { char c1, c2; - assert( str ); - assert( c ); + assert( str != NULL ); + assert( c != NULL ); c1 = str[ 0 ]; c2 = str[ 1 ]; @@ -1874,9 +1874,9 @@ hexstr2binval( const char *str, struct berval *val, const char **next, unsigned ber_len_t len; ber_len_t s, d; - assert( str ); - assert( val ); - assert( next ); + assert( str != NULL ); + assert( val != NULL ); + assert( next != NULL ); *next = NULL; @@ -1976,8 +1976,8 @@ byte2hexpair( const char *val, char *pair ) { static const char hexdig[] = "0123456789ABCDEF"; - assert( val ); - assert( pair ); + assert( val != NULL ); + assert( pair != NULL ); /* * we assume the string has enough room for the hex encoding @@ -1998,8 +1998,8 @@ binval2hexstr( struct berval *val, char *str ) { ber_len_t s, d; - assert( val ); - assert( str ); + assert( val != NULL ); + assert( str != NULL ); if ( val->bv_len == 0 ) { return( 0 ); @@ -2031,8 +2031,8 @@ strval2strlen( struct berval *val, unsigned flags, ber_len_t *len ) int escaped_ascii_len = LDAP_DN_IS_PRETTY( flags ) ? 2 : 3; #endif /* PRETTY_ESCAPE */ - assert( val ); - assert( len ); + assert( val != NULL ); + assert( len != NULL ); *len = 0; if ( val->bv_len == 0 ) { @@ -2109,9 +2109,9 @@ strval2str( struct berval *val, char *str, unsigned flags, ber_len_t *len ) { ber_len_t s, d, end; - assert( val ); - assert( str ); - assert( len ); + assert( val != NULL ); + assert( str != NULL ); + assert( len != NULL ); if ( val->bv_len == 0 ) { *len = 0; @@ -2208,8 +2208,8 @@ strval2IA5strlen( struct berval *val, unsigned flags, ber_len_t *len ) ber_len_t l; char *p; - assert( val ); - assert( len ); + assert( val != NULL ); + assert( len != NULL ); *len = 0; if ( val->bv_len == 0 ) { @@ -2250,9 +2250,9 @@ strval2IA5str( struct berval *val, char *str, unsigned flags, ber_len_t *len ) { ber_len_t s, d, end; - assert( val ); - assert( str ); - assert( len ); + assert( val != NULL ); + assert( str != NULL ); + assert( len != NULL ); if ( val->bv_len == 0 ) { *len = 0; @@ -2298,8 +2298,8 @@ strval2DCEstrlen( struct berval *val, unsigned flags, ber_len_t *len ) ber_len_t l; char *p; - assert( val ); - assert( len ); + assert( val != NULL ); + assert( len != NULL ); *len = 0; if ( val->bv_len == 0 ) { @@ -2338,9 +2338,9 @@ strval2DCEstr( struct berval *val, char *str, unsigned flags, ber_len_t *len ) { ber_len_t s, d; - assert( val ); - assert( str ); - assert( len ); + assert( val != NULL ); + assert( str != NULL ); + assert( len != NULL ); if ( val->bv_len == 0 ) { *len = 0; @@ -2384,8 +2384,8 @@ strval2ADstrlen( struct berval *val, unsigned flags, ber_len_t *len ) ber_len_t l; char *p; - assert( val ); - assert( len ); + assert( val != NULL ); + assert( len != NULL ); *len = 0; if ( val->bv_len == 0 ) { @@ -2424,9 +2424,9 @@ strval2ADstr( struct berval *val, char *str, unsigned flags, ber_len_t *len ) { ber_len_t s, d; - assert( val ); - assert( str ); - assert( len ); + assert( val != NULL ); + assert( str != NULL ); + assert( len != NULL ); if ( val->bv_len == 0 ) { *len = 0; @@ -2477,9 +2477,9 @@ dn2domain( LDAPDN dn, struct berval *bv, int pos, int *iRDN ) /* we are guaranteed there's enough memory in str */ /* sanity */ - assert( dn ); - assert( bv ); - assert( iRDN ); + assert( dn != NULL ); + assert( bv != NULL ); + assert( iRDN != NULL ); assert( *iRDN >= 0 ); str = bv->bv_val + pos; @@ -2488,10 +2488,10 @@ dn2domain( LDAPDN dn, struct berval *bv, int pos, int *iRDN ) LDAPRDN rdn; LDAPAVA *ava; - assert( dn[ i ] ); + assert( dn[ i ] != NULL ); rdn = dn[ i ]; - assert( rdn[ 0 ] ); + assert( rdn[ 0 ] != NULL ); ava = rdn[ 0 ]; if ( !LDAP_DN_IS_RDN_DC( rdn ) ) { @@ -2678,8 +2678,8 @@ rdn2UFNstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len ) int iAVA; ber_len_t l = 0; - assert( rdn ); - assert( len ); + assert( rdn != NULL ); + assert( len != NULL ); *len = 0; @@ -2757,8 +2757,8 @@ rdn2ADstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len ) int iAVA; ber_len_t l = 0; - assert( rdn ); - assert( len ); + assert( rdn != NULL ); + assert( len != NULL ); *len = 0; @@ -2838,7 +2838,7 @@ ldap_rdn2str( LDAPRDN rdn, char **str, unsigned flags ) struct berval bv; int rc; - assert( str ); + assert( str != NULL ); if((flags & LDAP_DN_FORMAT_MASK) == LDAP_DN_FORMAT_LBER) { return LDAP_PARAM_ERROR; @@ -2861,7 +2861,7 @@ ldap_rdn2bv_x( LDAPRDN rdn, struct berval *bv, unsigned flags, void *ctx ) int rc, back; ber_len_t l; - assert( bv ); + assert( bv != NULL ); bv->bv_len = 0; bv->bv_val = NULL; @@ -2971,7 +2971,7 @@ int ldap_dn2str( LDAPDN dn, char **str, unsigned flags ) struct berval bv; int rc; - assert( str ); + assert( str != NULL ); if((flags & LDAP_DN_FORMAT_MASK) == LDAP_DN_FORMAT_LBER) { return LDAP_PARAM_ERROR; @@ -2997,7 +2997,7 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx ) int ( *sv2l ) ( struct berval *v, unsigned f, ber_len_t *l ); int ( *sv2s ) ( struct berval *v, char *s, unsigned f, ber_len_t *l ); - assert( bv ); + assert( bv != NULL ); bv->bv_len = 0; bv->bv_val = NULL; @@ -3356,7 +3356,7 @@ ldap_X509dn2bv( void *x509_name, struct berval *bv, LDAPDN_rewrite_func *func, struct berval Val; - assert( bv ); + assert( bv != NULL ); bv->bv_len = 0; bv->bv_val = NULL; diff --git a/libraries/libldap/groupings.c b/libraries/libldap/groupings.c index 24a655d7ff..fe768f17ac 100644 --- a/libraries/libldap/groupings.c +++ b/libraries/libldap/groupings.c @@ -127,6 +127,7 @@ int ldap_grouping_end( LDAPControl **cctrls, int *msgidp ) { + return 0; } int ldap_grouping_end_s( @@ -137,6 +138,7 @@ int ldap_grouping_end_s( LDAPControl **cctrls, struct berval **retgrpdatap ) { + return 0; } #endif diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index 504b5d5b35..11100f21f7 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -119,7 +119,7 @@ LDAP_BEGIN_DECL #define LDAP_BOOL_TLS 3 #define LDAP_BOOLEANS unsigned long -#define LDAP_BOOL(n) (1 << (n)) +#define LDAP_BOOL(n) ((LDAP_BOOLEANS)1 << (n)) #define LDAP_BOOL_GET(lo, bool) \ ((lo)->ldo_booleans & LDAP_BOOL(bool) ? -1 : 0) #define LDAP_BOOL_SET(lo, bool) ((lo)->ldo_booleans |= LDAP_BOOL(bool)) diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index 6f678680cf..e8106c5e7d 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -388,7 +388,8 @@ ldap_set_option( LDAPControl *const *controls = (LDAPControl *const *) invalue; - ldap_controls_free( lo->ldo_sctrls ); + if( lo->ldo_sctrls ) + ldap_controls_free( lo->ldo_sctrls ); if( controls == NULL || *controls == NULL ) { lo->ldo_sctrls = NULL; @@ -407,7 +408,8 @@ ldap_set_option( LDAPControl *const *controls = (LDAPControl *const *) invalue; - ldap_controls_free( lo->ldo_cctrls ); + if( lo->ldo_cctrls ) + ldap_controls_free( lo->ldo_cctrls ); if( controls == NULL || *controls == NULL ) { lo->ldo_cctrls = NULL; diff --git a/libraries/libldap/ppolicy.c b/libraries/libldap/ppolicy.c index a54181dca6..0092cd8fcf 100644 --- a/libraries/libldap/ppolicy.c +++ b/libraries/libldap/ppolicy.c @@ -130,15 +130,15 @@ ldap_parse_passwordpolicy_control( LDAPPasswordPolicyError *errorp ) { BerElement *ber; - int i, exp = -1, grace = -1; + int exp = -1, grace = -1; ber_tag_t tag; ber_len_t berLen; char *last; - LDAPPasswordPolicyError err = PP_noError; + int err = PP_noError; assert( ld != NULL ); assert( LDAP_VALID( ld ) ); - assert( ctrl ); + assert( ctrl != NULL ); /* Create a BerElement from the berval returned in the control. */ ber = ber_init(&ctrl->ldctl_value); @@ -172,7 +172,7 @@ ldap_parse_passwordpolicy_control( break; case PPOLICY_ERROR: - if (ber_get_enum( ber, (int *)&err ) == LBER_DEFAULT) goto exit; + if (ber_get_enum( ber, &err ) == LBER_DEFAULT) goto exit; break; default: goto exit; diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 089bf61cbe..7e352fa23e 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -55,6 +55,7 @@ static LDAPConn *find_connection LDAP_P(( LDAP *ld, LDAPURLDesc *srv, int any )); static void use_connection LDAP_P(( LDAP *ld, LDAPConn *lc )); +static void ldap_free_request_int LDAP_P(( LDAP *ld, LDAPRequest *lr )); static BerElement * re_encode_request( LDAP *ld, @@ -135,7 +136,7 @@ ldap_send_initial_request( ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); #endif rc = ldap_send_server_request( ld, ber, msgid, NULL, - servers, NULL, NULL ); + servers, NULL, NULL ); #ifdef LDAP_R_COMPILE ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); #endif @@ -234,13 +235,14 @@ ldap_send_server_request( rc = 0; if ( ld->ld_requests && ld->ld_requests->lr_status == LDAP_REQST_WRITING && - ldap_int_flush_request( ld, ld->ld_requests ) < 0 ) { + ldap_int_flush_request( ld, ld->ld_requests ) < 0 ) + { rc = -1; } if ( rc ) return rc; - if (( lr = (LDAPRequest *)LDAP_CALLOC( 1, sizeof( LDAPRequest ))) == - NULL ) { + lr = (LDAPRequest *)LDAP_CALLOC( 1, sizeof( LDAPRequest )); + if ( lr == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; ldap_free_connection( ld, lc, 0, 0 ); ber_free( ber, 1 ); @@ -261,7 +263,7 @@ ldap_send_server_request( ++parentreq->lr_outrefcnt; } lr->lr_origid = parentreq->lr_origid; - lr->lr_parentcnt = parentreq->lr_parentcnt + 1; + lr->lr_parentcnt = ++parentreq->lr_parentcnt; lr->lr_parent = parentreq; lr->lr_refnext = parentreq->lr_child; parentreq->lr_child = lr; @@ -269,11 +271,11 @@ ldap_send_server_request( lr->lr_origid = lr->lr_msgid; } + lr->lr_prev = NULL; if (( lr->lr_next = ld->ld_requests ) != NULL ) { lr->lr_next->lr_prev = lr; } ld->ld_requests = lr; - lr->lr_prev = NULL; ld->ld_errno = LDAP_SUCCESS; if ( ldap_int_flush_request( ld, lr ) == -1 ) { @@ -289,27 +291,36 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, { LDAPConn *lc; LDAPURLDesc *srv; - Sockbuf *sb = NULL; - Debug( LDAP_DEBUG_TRACE, "ldap_new_connection\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_new_connection %d %d %d\n", + use_ldsb, connect, (bind != NULL) ); /* * make a new LDAP server connection * XXX open connection synchronously for now */ - if (( lc = (LDAPConn *)LDAP_CALLOC( 1, sizeof( LDAPConn ))) == NULL || - ( !use_ldsb && ( (sb = ber_sockbuf_alloc()) == NULL ))) { - if ( lc != NULL ) { - LDAP_FREE( (char *)lc ); - } + lc = (LDAPConn *)LDAP_CALLOC( 1, sizeof( LDAPConn ) ); + if ( lc == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( NULL ); } + + if ( use_ldsb ) { + assert( ld->ld_sb != NULL ); + lc->lconn_sb = ld->ld_sb; - lc->lconn_sb = ( use_ldsb ) ? ld->ld_sb : sb; + } else { + lc->lconn_sb = ber_sockbuf_alloc(); + if ( lc->lconn_sb == NULL ) { + LDAP_FREE( (char *)lc ); + ld->ld_errno = LDAP_NO_MEMORY; + return( NULL ); + } + } if ( connect ) { for ( srv = srvlist; srv != NULL; srv = srv->lud_next ) { - if ( ldap_int_open_connection( ld, lc, srv, 0 ) != -1 ) { + if ( ldap_int_open_connection( ld, lc, srv, 0 ) != -1 ) + { break; } } @@ -318,12 +329,12 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, if ( !use_ldsb ) { ber_sockbuf_free( lc->lconn_sb ); } - LDAP_FREE( (char *)lc ); - ld->ld_errno = LDAP_SERVER_DOWN; - return( NULL ); + LDAP_FREE( (char *)lc ); + ld->ld_errno = LDAP_SERVER_DOWN; + return( NULL ); } - lc->lconn_server = ldap_url_dup(srv); + lc->lconn_server = ldap_url_dup( srv ); } lc->lconn_status = LDAP_CONNST_CONNECTED; @@ -338,7 +349,8 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, int err = 0; LDAPConn *savedefconn; - /* Set flag to prevent additional referrals from being processed on this + /* Set flag to prevent additional referrals + * from being processed on this * connection until the bind has completed */ lc->lconn_rebind_inprogress = 1; @@ -355,27 +367,27 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, Debug( LDAP_DEBUG_TRACE, "Call application rebind_proc\n", 0, 0, 0); #ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); - ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex ); + ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); + ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex ); #endif err = (*ld->ld_rebind_proc)( ld, bind->ri_url, bind->ri_request, bind->ri_msgid, ld->ld_rebind_params ); #ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex ); - ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); + ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex ); + ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); #endif ld->ld_defconn = savedefconn; --lc->lconn_refcnt; - if( err != 0) { - err = -1; + if ( err != 0 ) { + err = -1; ldap_free_connection( ld, lc, 1, 0 ); lc = NULL; + } + ldap_free_urldesc( srvfunc ); } - ldap_free_urldesc( srvfunc); - } } else { savedefconn = ld->ld_defconn; ++lc->lconn_refcnt; /* avoid premature free */ @@ -396,12 +408,12 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, ld->ld_defconn = savedefconn; --lc->lconn_refcnt; - if ( err != 0 ) { - ldap_free_connection( ld, lc, 1, 0 ); - lc = NULL; + if ( err != 0 ) { + ldap_free_connection( ld, lc, 1, 0 ); + lc = NULL; + } } - } - if( lc != NULL) + if ( lc != NULL ) lc->lconn_rebind_inprogress = 0; } @@ -460,7 +472,9 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) { LDAPConn *tmplc, *prevlc; - Debug( LDAP_DEBUG_TRACE, "ldap_free_connection\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, + "ldap_free_connection %d %d\n", + force, unbind, 0 ); if ( force || --lc->lconn_refcnt <= 0 ) { if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) { @@ -470,15 +484,17 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) } } - if( lc->lconn_ber != NULL ) { + if ( lc->lconn_ber != NULL ) { ber_free( lc->lconn_ber, 1 ); } ldap_int_sasl_close( ld, lc ); prevlc = NULL; - for ( tmplc = ld->ld_conns; tmplc != NULL; - tmplc = tmplc->lconn_next ) { + for ( tmplc = ld->ld_conns; + tmplc != NULL; + tmplc = tmplc->lconn_next ) + { if ( tmplc == lc ) { if ( prevlc == NULL ) { ld->ld_conns = tmplc->lconn_next; @@ -495,23 +511,39 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) LDAP_FREE( lc->lconn_krbinstance ); } #endif + + /* FIXME: is this at all possible? */ + if ( force ) { + LDAPRequest *lr; + + for ( lr = ld->ld_requests; lr; ) { + LDAPRequest *lr_next = lr->lr_next; + + if ( lr->lr_conn == lc ) { + ldap_free_request_int( ld, lr ); + } + + lr = lr_next; + } + } if ( lc->lconn_sb != ld->ld_sb ) { ber_sockbuf_free( lc->lconn_sb ); } - if( lc->lconn_rebind_queue != NULL) { + if ( lc->lconn_rebind_queue != NULL) { int i; - for( i = 0; lc->lconn_rebind_queue[i] != NULL; i++) { - LDAP_VFREE(lc->lconn_rebind_queue[i]); + for( i = 0; lc->lconn_rebind_queue[i] != NULL; i++ ) { + LDAP_VFREE( lc->lconn_rebind_queue[i] ); } - LDAP_FREE( lc->lconn_rebind_queue); + LDAP_FREE( lc->lconn_rebind_queue ); } LDAP_FREE( lc ); - Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: actually freed\n", - 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, + "ldap_free_connection: actually freed\n", + 0, 0, 0 ); } else { lc->lconn_lastused = time( NULL ); Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: refcnt %d\n", - lc->lconn_refcnt, 0, 0 ); + lc->lconn_refcnt, 0, 0 ); } } @@ -608,11 +640,14 @@ ldap_dump_requests_and_responses( LDAP *ld ) } #endif /* LDAP_DEBUG */ -void +static void ldap_free_request_int( LDAP *ld, LDAPRequest *lr ) { if ( lr->lr_prev == NULL ) { + /* free'ing the first request? */ + assert( ld->ld_requests == lr ); ld->ld_requests = lr->lr_next; + } else { lr->lr_prev->lr_next = lr->lr_next; } @@ -706,7 +741,7 @@ int ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char **errstrp, int *hadrefp ) { char *unfollowed; - int unfollowedcnt = 0; + int unfollowedcnt = 0; LDAPRequest *origreq; LDAPURLDesc *srv = NULL; BerElement *ber; @@ -918,11 +953,11 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * } } /* end for loop */ done: - LDAP_VFREE(refarray); - ldap_free_urllist(srv); + LDAP_VFREE( refarray ); + ldap_free_urllist( srv ); LDAP_FREE( *errstrp ); - if( rc == 0) { + if( rc == 0 ) { *errstrp = NULL; LDAP_FREE( unfollowed ); return count; @@ -1032,12 +1067,12 @@ ldap_chase_referrals( LDAP *ld, rinfo.ri_msgid = origreq->lr_origid; #ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); + ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); #endif rc = ldap_send_server_request( ld, ber, id, - lr, srv, NULL, &rinfo ); + lr, srv, NULL, &rinfo ); #ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); + ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); #endif LDAP_FREE( rinfo.ri_url ); diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 5eaa9ab31b..56eb3291c3 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -187,8 +187,8 @@ chkResponseList( tmp = lm; } } else { - assert(lm->lm_chain_tail); - assert(lm->lm_chain_tail->lm_chain); + assert(lm->lm_chain_tail != NULL); + assert(lm->lm_chain_tail->lm_chain != NULL); if ((lm->lm_chain_tail->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || (lm->lm_chain_tail->lm_chain->lm_msgtype @@ -222,7 +222,7 @@ chkResponseList( if ( all == LDAP_MSG_ONE && lm->lm_chain != NULL ) { lm->lm_chain->lm_next = lm->lm_next; lm->lm_chain->lm_chain_tail = ( lm->lm_chain_tail != lm ) ? lm->lm_chain_tail : lm->lm_chain; - assert(lm->lm_chain->lm_chain_tail); + assert(lm->lm_chain->lm_chain_tail != NULL); lm->lm_chain = NULL; lm->lm_chain_tail = NULL; } @@ -307,54 +307,55 @@ wait4msg( } if ( !lc_ready ) { - rc = ldap_int_select( ld, tvp ); + rc = ldap_int_select( ld, tvp ); #ifdef LDAP_DEBUG - if ( rc == -1 ) { - Debug( LDAP_DEBUG_TRACE, - "ldap_int_select returned -1: errno %d\n", - errno, 0, 0 ); - } + if ( rc == -1 ) { + Debug( LDAP_DEBUG_TRACE, + "ldap_int_select returned -1: errno %d\n", + errno, 0, 0 ); + } #endif - if ( rc == 0 || ( rc == -1 && ( - !LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART) - || errno != EINTR ))) - { - ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN : - LDAP_TIMEOUT); - return( rc ); - } - - if ( rc == -1 ) { - rc = -2; /* select interrupted: loop */ - } else { - rc = -2; + if ( rc == 0 || ( rc == -1 && ( + !LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART) + || errno != EINTR ))) + { + ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN : + LDAP_TIMEOUT); + return( rc ); + } + + if ( rc == -1 ) { + rc = -2; /* select interrupted: loop */ + } else { + rc = -2; #ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); + ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); #endif - if ( ld->ld_requests && + if ( ld->ld_requests && ld->ld_requests->lr_status == LDAP_REQST_WRITING && ldap_is_write_ready( ld, - ld->ld_requests->lr_conn->lconn_sb ) ) { + ld->ld_requests->lr_conn->lconn_sb ) ) + { ldap_int_flush_request( ld, ld->ld_requests ); } #ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); + ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); #endif - for ( lc = ld->ld_conns; rc == -2 && lc != NULL; - lc = nextlc ) { - nextlc = lc->lconn_next; - if ( lc->lconn_status == - LDAP_CONNST_CONNECTED && - ldap_is_read_ready( ld, - lc->lconn_sb )) { - rc = try_read1msg( ld, msgid, all, - lc->lconn_sb, &lc, result ); - if ( lc == NULL ) lc = nextlc; - } - } - } - } + for ( lc = ld->ld_conns; rc == -2 && lc != NULL; + lc = nextlc ) + { + nextlc = lc->lconn_next; + if ( lc->lconn_status == LDAP_CONNST_CONNECTED && + ldap_is_read_ready( ld, lc->lconn_sb )) + { + rc = try_read1msg( ld, msgid, all, + lc->lconn_sb, &lc, result ); + if ( lc == NULL ) lc = nextlc; + } + } + } + } } if ( rc == -2 && tvp != NULL ) { @@ -386,7 +387,7 @@ try_read1msg( LDAPMessage **result ) { BerElement *ber; - LDAPMessage *new, *l, *prev, *tmp, *chain_head; + LDAPMessage *newmsg, *l, *prev; ber_int_t id; ber_tag_t tag; ber_len_t len; @@ -396,9 +397,12 @@ try_read1msg( BerElement tmpber; int rc, refer_cnt, hadref, simple_request; ber_int_t lderr; + #ifdef LDAP_CONNECTIONLESS + LDAPMessage *tmp = NULL, *chain_head = NULL; int firstmsg = 1, moremsgs = 0, isv2 = 0; #endif + /* * v3ref = flag for V3 referral / search reference * 0 = not a ref, 1 = sucessfully chased ref, -1 = pass ref to application @@ -480,7 +484,8 @@ retry_ber: return( -2 ); /* continue looking */ } - if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) { + lr = ldap_find_request_by_msgid( ld, id ); + if ( lr == NULL ) { Debug( LDAP_DEBUG_ANY, "no request for response with msgid %ld (tossing)\n", (long) id, 0, 0 ); @@ -501,7 +506,7 @@ nextresp2: Debug( LDAP_DEBUG_TRACE, "ldap_read: message type %s msgid %ld, original id %ld\n", - ldap_int_msgtype2str( tag ), + ldap_int_msgtype2str( tag ), (long) lr->lr_msgid, (long) lr->lr_origid ); id = lr->lr_origid; @@ -547,12 +552,25 @@ nextresp2: } } else { /* Check for V3 referral */ - ber_len_t len; + ber_len_t len; + char *lr_res_error = NULL; + if ( ber_scanf( &tmpber, "{iaa",/*}*/ &lderr, - &lr->lr_res_matched, &lr->lr_res_error ) - != LBER_ERROR ) { + &lr->lr_res_matched, &lr_res_error ) + != LBER_ERROR ) + { + if ( lr_res_error != NULL ) { + if ( lr->lr_res_error != NULL ) { + (void)ldap_append_referral( ld, &lr->lr_res_error, lr_res_error ); + LDAP_FREE( (char *)lr_res_error ); + + } else { + lr->lr_res_error = lr_res_error; + } + } + /* Check if V3 referral */ - if( ber_peek_tag( &tmpber, &len) == LDAP_TAG_REFERRAL ) { + if ( ber_peek_tag( &tmpber, &len ) == LDAP_TAG_REFERRAL ) { /* We have a V3 referral, assume we cannot chase it */ v3ref = -1; if( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) @@ -607,6 +625,8 @@ nextresp2: ( lr->lr_parent != NULL || LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) ) ) { + char *lr_res_error = NULL; + tmpber = *ber; /* struct copy */ if ( v3ref == 1 ) { /* V3 search reference or V3 referral @@ -617,8 +637,18 @@ nextresp2: if ( tag == LDAP_RES_SEARCH_RESULT ) refer_cnt = 0; } else if ( ber_scanf( &tmpber, "{iaa}", &lderr, - &lr->lr_res_matched, &lr->lr_res_error ) - != LBER_ERROR ) { + &lr->lr_res_matched, &lr_res_error ) + != LBER_ERROR ) + { + if ( lr_res_error != NULL ) { + if ( lr->lr_res_error != NULL ) { + (void)ldap_append_referral( ld, &lr->lr_res_error, lr_res_error ); + LDAP_FREE( (char *)lr_res_error ); + } else { + lr->lr_res_error = lr_res_error; + } + } + if ( lderr != LDAP_SUCCESS ) { /* referrals are in error string */ refer_cnt = ldap_chase_referrals( ld, lr, @@ -709,11 +739,23 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); } } +#ifdef LDAP_R_COMPILE + ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); +#endif ldap_free_request( ld, lr ); +#ifdef LDAP_R_COMPILE + ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); +#endif } if ( lc != NULL ) { +#ifdef LDAP_R_COMPILE + ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); +#endif ldap_free_connection( ld, lc, 0, 1 ); +#ifdef LDAP_R_COMPILE + ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); +#endif *lcp = NULL; } } @@ -724,14 +766,14 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); } /* make a new ldap message */ - if ( (new = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) )) - == NULL ) { + newmsg = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) ); + if ( newmsg == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( -1 ); } - new->lm_msgid = (int)id; - new->lm_msgtype = tag; - new->lm_ber = ber; + newmsg->lm_msgid = (int)id; + newmsg->lm_msgtype = tag; + newmsg->lm_ber = ber; #ifdef LDAP_CONNECTIONLESS /* CLDAP replies all fit in a single datagram. In LDAPv2 RFC1798 @@ -780,15 +822,16 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); /* set up response chain */ if ( firstmsg ) { firstmsg = 0; - new->lm_next = ld->ld_responses; - ld->ld_responses = new; - new->lm_chain_tail = new; - chain_head = new; + newmsg->lm_next = ld->ld_responses; + ld->ld_responses = newmsg; + newmsg->lm_chain_tail = newmsg; + chain_head = newmsg; } else { - tmp->lm_chain = new; + assert( tmp != NULL ); + tmp->lm_chain = newmsg; chain_head->lm_chain_tail = tmp; } - tmp = new; + tmp = newmsg; /* "ok" means there's more to parse */ if (ok) { if (isv2) goto nextresp2; @@ -807,25 +850,25 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); * stick the result onto the end of the chain, and then pull the * first response off the head of the chain. */ - tmp->lm_chain = new; + tmp->lm_chain = newmsg; chain_head->lm_chain_tail = tmp; *result = chkResponseList( ld, msgid, all ); ld->ld_errno = LDAP_SUCCESS; return( (*result)->lm_msgtype ); } } -#endif +#endif /* LDAP_CONNECTIONLESS */ /* is this the one we're looking for? */ if ( msgid == LDAP_RES_ANY || id == msgid ) { if ( all == LDAP_MSG_ONE - || (new->lm_msgtype != LDAP_RES_SEARCH_RESULT - && new->lm_msgtype != LDAP_RES_SEARCH_ENTRY - && new->lm_msgtype != LDAP_RES_SEARCH_REFERENCE) ) { - *result = new; + || (newmsg->lm_msgtype != LDAP_RES_SEARCH_RESULT + && newmsg->lm_msgtype != LDAP_RES_SEARCH_ENTRY + && newmsg->lm_msgtype != LDAP_RES_SEARCH_REFERENCE) ) { + *result = newmsg; ld->ld_errno = LDAP_SUCCESS; return( tag ); - } else if ( new->lm_msgtype == LDAP_RES_SEARCH_RESULT) { + } else if ( newmsg->lm_msgtype == LDAP_RES_SEARCH_RESULT) { foundit = 1; /* return the chain later */ } } @@ -838,7 +881,7 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); prev = NULL; for ( l = ld->ld_responses; l != NULL; l = l->lm_next ) { - if ( l->lm_msgid == new->lm_msgid ) + if ( l->lm_msgid == newmsg->lm_msgid ) break; prev = l; } @@ -846,37 +889,37 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); /* not part of an existing search response */ if ( l == NULL ) { if ( foundit ) { - *result = new; + *result = newmsg; goto exit; } - new->lm_next = ld->ld_responses; - ld->ld_responses = new; - new->lm_chain_tail = new; + newmsg->lm_next = ld->ld_responses; + ld->ld_responses = newmsg; + newmsg->lm_chain_tail = newmsg; goto exit; } Debug( LDAP_DEBUG_TRACE, "adding response id %ld type %ld:\n", - (long) new->lm_msgid, (long) new->lm_msgtype, 0 ); + (long) newmsg->lm_msgid, (long) newmsg->lm_msgtype, 0 ); /* part of a search response - add to end of list of entries */ if (l->lm_chain == NULL) { assert(l->lm_chain_tail == l); - l->lm_chain = new; + l->lm_chain = newmsg; } else { - assert(l->lm_chain_tail); - assert(l->lm_chain_tail->lm_chain); + assert(l->lm_chain_tail != NULL); + assert(l->lm_chain_tail->lm_chain != NULL); if ((l->lm_chain_tail->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || (l->lm_chain_tail->lm_chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) || (l->lm_chain_tail->lm_chain->lm_msgtype == LDAP_RES_INTERMEDIATE)) { - l->lm_chain_tail->lm_chain->lm_chain = new; + l->lm_chain_tail->lm_chain->lm_chain = newmsg; l->lm_chain_tail = l->lm_chain_tail->lm_chain; } else { /*FIXME: ldap_msgfree( l->lm_chain_tail->lm_chain );*/ - l->lm_chain_tail->lm_chain = new; + l->lm_chain_tail->lm_chain = newmsg; } } @@ -918,10 +961,10 @@ build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr ) } if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid, - lr->lr_res_msgtype, lr->lr_res_errno, - lr->lr_res_matched ? lr->lr_res_matched : "", - lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) { - + lr->lr_res_msgtype, lr->lr_res_errno, + lr->lr_res_matched ? lr->lr_res_matched : "", + lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) + { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free(ber, 1); return( LBER_ERROR ); @@ -967,14 +1010,15 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) lr->lr_res_error ); } } else if ( lr->lr_res_errno != LDAP_SUCCESS && - parentr->lr_res_errno == LDAP_SUCCESS ) { + parentr->lr_res_errno == LDAP_SUCCESS ) + { parentr->lr_res_errno = lr->lr_res_errno; if ( parentr->lr_res_error != NULL ) { LDAP_FREE( parentr->lr_res_error ); } parentr->lr_res_error = lr->lr_res_error; lr->lr_res_error = NULL; - if ( LDAP_NAME_ERROR( lr->lr_res_errno )) { + if ( LDAP_NAME_ERROR( lr->lr_res_errno ) ) { if ( parentr->lr_res_matched != NULL ) { LDAP_FREE( parentr->lr_res_matched ); } diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 6c76569b79..07a315a957 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -970,11 +970,6 @@ ldap_attributetype2bv( LDAPAttributeType * at, struct berval *bv ) #define TK_DOLLAR 6 #define TK_QDESCR TK_QDSTRING -struct token { - int type; - char *sval; -}; - static int get_token( const char ** sp, char ** token_val ) { @@ -1312,6 +1307,11 @@ parse_oids(const char **sp, int *code, const int allow_quoted) ( allow_quoted && kind == TK_QDSTRING ) ) { res[pos++] = sval; res[pos] = NULL; + } else if ( kind == TK_RIGHTPAREN ) { + /* FIXME: be liberal in what we accept... */ + parse_whsp(sp); + LDAP_FREE(res); + return NULL; } else { *code = LDAP_SCHERR_UNEXPTOKEN; LDAP_FREE(sval); @@ -1924,7 +1924,7 @@ ldap_str2matchingruleuse( LDAP_CONST char * s, mru->mru_applies_oids = parse_oids(&ss, code, flags); - if ( !mru->mru_applies_oids ) { + if ( !mru->mru_applies_oids && *code != LDAP_SUCCESS ) { *errp = ss; ldap_matchingruleuse_free(mru); return NULL; @@ -2520,7 +2520,7 @@ ldap_str2objectclass( LDAP_CONST char * s, oc->oc_sup_oids = parse_oids(&ss, code, flags); - if ( !oc->oc_sup_oids ) { + if ( !oc->oc_sup_oids && *code != LDAP_SUCCESS ) { *errp = ss; ldap_objectclass_free(oc); return NULL; @@ -2568,7 +2568,7 @@ ldap_str2objectclass( LDAP_CONST char * s, } seen_must = 1; oc->oc_at_oids_must = parse_oids(&ss,code,0); - if ( !oc->oc_at_oids_must ) { + if ( !oc->oc_at_oids_must && *code != LDAP_SUCCESS ) { *errp = ss; ldap_objectclass_free(oc); return NULL; @@ -2584,7 +2584,7 @@ ldap_str2objectclass( LDAP_CONST char * s, } seen_may = 1; oc->oc_at_oids_may = parse_oids(&ss,code,0); - if ( !oc->oc_at_oids_may ) { + if ( !oc->oc_at_oids_may && *code != LDAP_SUCCESS ) { *errp = ss; ldap_objectclass_free(oc); return NULL; @@ -2809,7 +2809,7 @@ ldap_str2contentrule( LDAP_CONST char * s, } seen_must = 1; cr->cr_at_oids_must = parse_oids(&ss,code,0); - if ( !cr->cr_at_oids_must ) { + if ( !cr->cr_at_oids_must && *code != LDAP_SUCCESS ) { *errp = ss; ldap_contentrule_free(cr); return NULL; @@ -2825,7 +2825,7 @@ ldap_str2contentrule( LDAP_CONST char * s, } seen_may = 1; cr->cr_at_oids_may = parse_oids(&ss,code,0); - if ( !cr->cr_at_oids_may ) { + if ( !cr->cr_at_oids_may && *code != LDAP_SUCCESS ) { *errp = ss; ldap_contentrule_free(cr); return NULL; @@ -2841,7 +2841,7 @@ ldap_str2contentrule( LDAP_CONST char * s, } seen_not = 1; cr->cr_at_oids_not = parse_oids(&ss,code,0); - if ( !cr->cr_at_oids_not ) { + if ( !cr->cr_at_oids_not && *code != LDAP_SUCCESS ) { *errp = ss; ldap_contentrule_free(cr); return NULL; @@ -3211,7 +3211,7 @@ ldap_str2nameform( LDAP_CONST char * s, } seen_must = 1; nf->nf_at_oids_must = parse_oids(&ss,code,0); - if ( !nf->nf_at_oids_must ) { + if ( !nf->nf_at_oids_must && *code != LDAP_SUCCESS ) { *errp = ss; ldap_nameform_free(nf); return NULL; @@ -3227,7 +3227,7 @@ ldap_str2nameform( LDAP_CONST char * s, } seen_may = 1; nf->nf_at_oids_may = parse_oids(&ss,code,0); - if ( !nf->nf_at_oids_may ) { + if ( !nf->nf_at_oids_may && *code != LDAP_SUCCESS ) { *errp = ss; ldap_nameform_free(nf); return NULL; diff --git a/libraries/libldap/string.c b/libraries/libldap/string.c index 60c228914b..a3ea27a8f2 100644 --- a/libraries/libldap/string.c +++ b/libraries/libldap/string.c @@ -126,7 +126,7 @@ ldap_pvt_str2upperbv( char *str, struct berval *bv ) { char *s = NULL; - assert( bv ); + assert( bv != NULL ); /* to upper */ if ( str ) { @@ -161,7 +161,7 @@ ldap_pvt_str2lowerbv( char *str, struct berval *bv ) { char *s = NULL; - assert( bv ); + assert( bv != NULL ); /* to lower */ if ( str ) { diff --git a/libraries/libldap/unbind.c b/libraries/libldap/unbind.c index 0158edf5b4..c58d7a2a0a 100644 --- a/libraries/libldap/unbind.c +++ b/libraries/libldap/unbind.c @@ -172,6 +172,16 @@ ldap_ld_free( } #endif + if ( ld->ld_options.ldo_sctrls != NULL ) { + ldap_controls_free( ld->ld_options.ldo_sctrls ); + ld->ld_options.ldo_sctrls = NULL; + } + + if ( ld->ld_options.ldo_cctrls != NULL ) { + ldap_controls_free( ld->ld_options.ldo_cctrls ); + ld->ld_options.ldo_cctrls = NULL; + } + ber_sockbuf_free( ld->ld_sb ); #ifdef LDAP_R_COMPILE diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index b6a669fce9..2c1be570f6 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -53,7 +53,7 @@ static const char* skip_url_prefix LDAP_P(( int ldap_pvt_url_scheme2proto( const char *scheme ) { - assert( scheme ); + assert( scheme != NULL ); if( scheme == NULL ) { return -1; @@ -81,7 +81,7 @@ int ldap_pvt_url_scheme2proto( const char *scheme ) int ldap_pvt_url_scheme_port( const char *scheme, int port ) { - assert( scheme ); + assert( scheme != NULL ); if( port ) return port; if( scheme == NULL ) return port; @@ -110,7 +110,7 @@ int ldap_pvt_url_scheme_port( const char *scheme, int port ) int ldap_pvt_url_scheme2tls( const char *scheme ) { - assert( scheme ); + assert( scheme != NULL ); if( scheme == NULL ) { return -1; @@ -804,7 +804,7 @@ ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) return LDAP_URL_ERR_BADSCHEME; } - assert( scheme ); + assert( scheme != NULL ); /* make working copy of the remainder of the URL */ url = LDAP_STRDUP( url_tmp ); diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c index 407d13628d..089a17cafd 100644 --- a/libraries/libldap/util-int.c +++ b/libraries/libldap/util-int.c @@ -59,9 +59,9 @@ extern int h_errno; # include ldap_pvt_thread_mutex_t ldap_int_resolv_mutex; -#if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \ - && defined( CTIME_R_NARGS ) -# define USE_CTIME_R +# if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \ + && defined( CTIME_R_NARGS ) +# define USE_CTIME_R # else static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex; # endif @@ -110,12 +110,14 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf ) #define BUFSTART (1024-32) #define BUFMAX (32*1024-32) +#if defined(LDAP_R_COMPILE) static char *safe_realloc( char **buf, int len ); -#if !defined(HAVE_GETHOSTBYNAME_R) && defined(LDAP_R_COMPILE) +#if !(defined(HAVE_GETHOSTBYNAME_R) && defined(HAVE_GETHOSTBYADDR_R)) static int copy_hostent( struct hostent *res, char **buf, struct hostent * src ); #endif +#endif int ldap_pvt_gethostbyname_a( const char *name, @@ -195,7 +197,7 @@ int ldap_pvt_gethostbyname_a( #endif } -#if !defined( GETNAMEINFO ) && !defined( HAVE_HERROR ) +#if !defined( HAVE_GETNAMEINFO ) && !defined( HAVE_HSTRERROR ) static const char * hp_strerror( int err ) { @@ -463,7 +465,7 @@ static int copy_hostent( int n_alias=0; int total_alias_len=0; int n_addr=0; - int total_addr_len; + int total_addr_len=0; int total_len; /* calculate the size needed for the buffer */ diff --git a/libraries/libldap_r/tpool.c b/libraries/libldap_r/tpool.c index 0148df89fc..04a71b645c 100644 --- a/libraries/libldap_r/tpool.c +++ b/libraries/libldap_r/tpool.c @@ -222,7 +222,6 @@ ldap_pvt_thread_pool_submit ( if (ctx) { LDAP_SLIST_REMOVE_HEAD(&pool->ltp_free_list, ltc_next.l); } else { - int i; ctx = (ldap_int_thread_ctx_t *) LDAP_MALLOC( sizeof(ldap_int_thread_ctx_t)); if (ctx == NULL) { diff --git a/libraries/liblutil/getpeereid.c b/libraries/liblutil/getpeereid.c index 3d7ce7a6e1..ce8c232aa8 100644 --- a/libraries/liblutil/getpeereid.c +++ b/libraries/liblutil/getpeereid.c @@ -49,7 +49,7 @@ int getpeereid( int s, uid_t *euid, gid_t *egid ) #ifdef LDAP_PF_LOCAL #if defined( SO_PEERCRED ) struct ucred peercred; - size_t peercredlen = sizeof peercred; + socklen_t peercredlen = sizeof peercred; if(( getsockopt( s, SOL_SOCKET, SO_PEERCRED, (void *)&peercred, &peercredlen ) == 0 ) diff --git a/libraries/liblutil/ldif.c b/libraries/liblutil/ldif.c index f29d4c3084..69a2c28b6a 100644 --- a/libraries/liblutil/ldif.c +++ b/libraries/liblutil/ldif.c @@ -389,9 +389,9 @@ ldif_must_b64_encode_register( LDAP_CONST char *name, LDAP_CONST char *oid ) int i; ber_len_t len; - assert( must_b64_encode ); - assert( name ); - assert( oid ); + assert( must_b64_encode != NULL ); + assert( name != NULL ); + assert( oid != NULL ); len = strlen( name ); @@ -444,7 +444,7 @@ ldif_must_b64_encode_release( void ) { int i; - assert( must_b64_encode ); + assert( must_b64_encode != NULL ); if ( must_b64_encode == default_must_b64_encode ) { return; @@ -470,8 +470,8 @@ ldif_must_b64_encode( LDAP_CONST char *s ) int i; struct berval bv; - assert( must_b64_encode ); - assert( s ); + assert( must_b64_encode != NULL ); + assert( s != NULL ); ber_str2bv( s, 0, 0, &bv ); diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index db5e865003..4d12404e66 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -216,7 +216,7 @@ static const struct pw_scheme *get_scheme( } } - return (const struct pw_scheme *) NULL; + return NULL; } int lutil_passwd_scheme( @@ -682,18 +682,21 @@ static int chk_md5( */ static void lmPasswd_to_key( - const unsigned char *lmPasswd, + const char *lmPasswd, des_cblock *key) { + const unsigned char *lpw = (const unsigned char *) lmPasswd; + unsigned char *k = (unsigned char *) key; + /* make room for parity bits */ - ((char *)key)[0] = lmPasswd[0]; - ((char *)key)[1] = ((lmPasswd[0]&0x01)<<7) | (lmPasswd[1]>>1); - ((char *)key)[2] = ((lmPasswd[1]&0x03)<<6) | (lmPasswd[2]>>2); - ((char *)key)[3] = ((lmPasswd[2]&0x07)<<5) | (lmPasswd[3]>>3); - ((char *)key)[4] = ((lmPasswd[3]&0x0F)<<4) | (lmPasswd[4]>>4); - ((char *)key)[5] = ((lmPasswd[4]&0x1F)<<3) | (lmPasswd[5]>>5); - ((char *)key)[6] = ((lmPasswd[5]&0x3F)<<2) | (lmPasswd[6]>>6); - ((char *)key)[7] = ((lmPasswd[6]&0x7F)<<1); + k[0] = lpw[0]; + k[1] = ((lpw[0] & 0x01) << 7) | (lpw[1] >> 1); + k[2] = ((lpw[1] & 0x03) << 6) | (lpw[2] >> 2); + k[3] = ((lpw[2] & 0x07) << 5) | (lpw[3] >> 3); + k[4] = ((lpw[3] & 0x0F) << 4) | (lpw[4] >> 4); + k[5] = ((lpw[4] & 0x1F) << 3) | (lpw[5] >> 5); + k[6] = ((lpw[5] & 0x3F) << 2) | (lpw[6] >> 6); + k[7] = ((lpw[6] & 0x7F) << 1); des_set_odd_parity( key ); } @@ -778,9 +781,7 @@ static int chk_crypt( const struct berval * cred, const char **text ) { - char *cr; unsigned int i; - int rc; for( i=0; ibv_len; i++) { if(cred->bv_val[i] == '\0') { @@ -817,7 +818,7 @@ static int chk_unix( const char **text ) { unsigned int i; - char *pw,*cr; + char *pw; for( i=0; ibv_len; i++) { if(cred->bv_val[i] == '\0') { diff --git a/libraries/librewrite/context.c b/libraries/librewrite/context.c index 5f4c19d6f2..c5770de892 100644 --- a/libraries/librewrite/context.c +++ b/libraries/librewrite/context.c @@ -433,7 +433,7 @@ rewrite_context_free( { struct rewrite_context *context = (struct rewrite_context *)tmp; - assert( tmp ); + assert( tmp != NULL ); rewrite_context_destroy( &context ); } @@ -446,12 +446,12 @@ rewrite_context_destroy( struct rewrite_context *context; struct rewrite_rule *r; - assert( pcontext ); - assert( *pcontext ); + assert( pcontext != NULL ); + assert( *pcontext != NULL ); context = *pcontext; - assert( context->lc_rule ); + assert( context->lc_rule != NULL ); for ( r = context->lc_rule->lr_next; r; ) { struct rewrite_rule *cr = r; @@ -463,7 +463,7 @@ rewrite_context_destroy( free( context->lc_rule ); context->lc_rule = NULL; - assert( context->lc_name ); + assert( context->lc_name != NULL ); free( context->lc_name ); context->lc_name = NULL; diff --git a/libraries/librewrite/ldapmap.c b/libraries/librewrite/ldapmap.c index 186fd601dc..1cb8f9cd0a 100644 --- a/libraries/librewrite/ldapmap.c +++ b/libraries/librewrite/ldapmap.c @@ -339,8 +339,8 @@ map_ldap_destroy( { struct ldap_map_data *data; - assert( pmap ); - assert( *pmap ); + assert( pmap != NULL ); + assert( *pmap != NULL ); data = ( struct ldap_map_data * )(*pmap)->lb_private; diff --git a/libraries/librewrite/map.c b/libraries/librewrite/map.c index fe06eb14ac..8d72ac35bd 100644 --- a/libraries/librewrite/map.c +++ b/libraries/librewrite/map.c @@ -438,7 +438,7 @@ rewrite_builtin_map_free( { struct rewrite_builtin_map *map = ( struct rewrite_builtin_map * )tmp; - assert( map ); + assert( map != NULL ); switch ( map->lb_type ) { case REWRITE_BUILTIN_MAP_LDAP: @@ -461,8 +461,8 @@ rewrite_map_destroy( { struct rewrite_map *map; - assert( pmap ); - assert( *pmap ); + assert( pmap != NULL ); + assert( *pmap != NULL ); map = *pmap; diff --git a/libraries/librewrite/rule.c b/libraries/librewrite/rule.c index 6a9e43c372..b3fba216e9 100644 --- a/libraries/librewrite/rule.c +++ b/libraries/librewrite/rule.c @@ -72,8 +72,8 @@ destroy_action( { struct rewrite_action *action; - assert( paction ); - assert( *paction ); + assert( paction != NULL ); + assert( *paction != NULL ); action = *paction; @@ -462,8 +462,8 @@ rewrite_rule_destroy( struct rewrite_rule *rule; struct rewrite_action *action; - assert( prule ); - assert( *prule ); + assert( prule != NULL ); + assert( *prule != NULL ); rule = *prule; diff --git a/libraries/librewrite/session.c b/libraries/librewrite/session.c index 18e21a5fe1..ac9196cec8 100644 --- a/libraries/librewrite/session.c +++ b/libraries/librewrite/session.c @@ -177,7 +177,7 @@ rewrite_session_return( struct rewrite_session *session ) { - assert( session ); + assert( session != NULL ); ldap_pvt_thread_mutex_unlock( &session->ls_mutex ); } diff --git a/libraries/librewrite/subst.c b/libraries/librewrite/subst.c index 5ab89cd7f6..83ac4c6e1a 100644 --- a/libraries/librewrite/subst.c +++ b/libraries/librewrite/subst.c @@ -453,8 +453,8 @@ rewrite_subst_destroy( int n; struct rewrite_subst *subst; - assert( psubst ); - assert( *psubst ); + assert( psubst != NULL ); + assert( *psubst != NULL ); subst = *psubst; diff --git a/libraries/librewrite/xmap.c b/libraries/librewrite/xmap.c index ca6e6819be..bc36edd044 100644 --- a/libraries/librewrite/xmap.c +++ b/libraries/librewrite/xmap.c @@ -437,8 +437,8 @@ rewrite_xmap_destroy( { struct rewrite_map *map; - assert( pmap ); - assert( *pmap ); + assert( pmap != NULL ); + assert( *pmap != NULL ); map = *pmap; diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in index 4fb79fd895..f63dd543ff 100644 --- a/servers/slapd/Makefile.in +++ b/servers/slapd/Makefile.in @@ -401,23 +401,16 @@ all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) dynamic_overlays touch all-cffiles install-schema: FORCE - @-$(MKDIR) $(DESTDIR)$(schemadir) - i="$(srcdir)/schema/README" ; \ - SF=`basename $$i` ; \ - SD="$(DESTDIR)$(schemadir)/$$SF" ; \ - echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \ - $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD - for i in $(srcdir)/schema/*.schema ; do \ - SF=`basename $$i` ; \ - SD="$(DESTDIR)$(schemadir)/$$SF" ; \ - if test ! -f $$SD ; then \ - echo "installing $$SF in $(schemadir)" ; \ - echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \ - $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \ - else \ - echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \ - fi ; \ - $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \ + @if test -e $(DESTDIR)$(schemadir) ; then \ + echo "MOVING EXISTING SCHEMA DIR to $(DESTDIR)$(schemadir).$$$$" ; \ + mv $(DESTDIR)$(schemadir) $(DESTDIR)$(schemadir).$$$$ ; \ + fi + $(MKDIR) $(DESTDIR)$(schemadir) + @SD=$(DESTDIR)$(schemadir) ; \ + files=`cd $(srcdir)/schema ; echo README *.ldif *.schema` ; \ + for i in $$files ; do \ + echo $(INSTALL) $(INSTALLFLAGS) -m 444 schema/$$i $$SD/$$i ; \ + $(INSTALL) $(INSTALLFLAGS) -m 444 $(srcdir)/schema/$$i $$SD/$$i ; \ done install-conf: FORCE diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index 95df80c2a5..df2f937f49 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -36,7 +36,6 @@ do_abandon( Operation *op, SlapReply *rs ) { ber_int_t id; Operation *o; - int i; Debug( LDAP_DEBUG_TRACE, "do_abandon\n", 0, 0, 0 ); diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 40de548d29..ba67c1fed4 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -37,10 +37,6 @@ #include "lber_pvt.h" #include "lutil.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif /* LDAPI_SLAPI */ - #define ACL_BUF_SIZE 1024 /* use most appropriate size */ /* @@ -166,7 +162,7 @@ slap_access_always_allowed( AccessControlState *state, slap_mask_t *maskp ) { - assert( maskp ); + assert( maskp != NULL ); ACL_PRIV_SET( *maskp, ACL_ACCESS2PRIV( access ) ); @@ -207,16 +203,6 @@ slap_access_allowed( assert( attr != NULL ); -#ifdef LDAP_SLAPI - if ( op->o_pb != NULL ) { - ret = slapi_int_access_allowed( op, e, desc, val, access, state ); - if ( ret == 0 ) { - /* ACL plugin denied access */ - goto done; - } - } -#endif /* LDAP_SLAPI */ - /* grant database root access */ if ( be_isroot( op ) ) { Debug( LDAP_DEBUG_ACL, "<= root access granted\n", 0, 0, 0 ); @@ -350,6 +336,39 @@ done: return ret; } +int +fe_access_allowed( + Operation *op, + Entry *e, + AttributeDescription *desc, + struct berval *val, + slap_access_t access, + AccessControlState *state, + slap_mask_t *maskp ) +{ + BackendDB *be_orig; + int rc; + + /* + * NOTE: control gets here if FIXME + * if an appropriate backend cannot be selected for the operation, + * we assume that the frontend should handle this + * FIXME: should select_backend() take care of this, + * and return frontendDB instead of NULL? maybe for some value + * of the flags? + */ + be_orig = op->o_bd; + + op->o_bd = select_backend( &op->o_req_ndn, 0, 0 ); + if ( op->o_bd == NULL ) { + op->o_bd = frontendDB; + } + rc = slap_access_allowed( op, e, desc, val, access, state, maskp ); + op->o_bd = be_orig; + + return rc; +} + int access_allowed_mask( Operation *op, @@ -373,7 +392,6 @@ access_allowed_mask( const char *attr; int st_same_attr = 0; static AccessControlState state_init = ACL_STATE_INIT; - BI_access_allowed *bi_access_allowed = NULL; assert( e != NULL ); assert( desc != NULL ); @@ -444,11 +462,18 @@ access_allowed_mask( /* this is enforced in backend_add() */ if ( op->o_bd->bd_info->bi_access_allowed ) { /* delegate to backend */ - ret = op->o_bd->bd_info->bi_access_allowed( op, e, desc, val, access, state, &mask ); + ret = op->o_bd->bd_info->bi_access_allowed( op, e, + desc, val, access, state, &mask ); } else { - /* use default */ - ret = slap_access_allowed( op, e, desc, val, access, state, &mask ); + BackendDB *be_orig = op->o_bd; + + /* use default (but pass through frontend + * for global ACL overlays) */ + op->o_bd = frontendDB; + ret = frontendDB->bd_info->bi_access_allowed( op, e, + desc, val, access, state, &mask ); + op->o_bd = be_orig; } if ( !ret ) { @@ -581,16 +606,6 @@ access_allowed_mask( } assert( be != NULL ); -#ifdef LDAP_SLAPI - if ( op->o_pb != NULL ) { - ret = slapi_int_access_allowed( op, e, desc, val, access, state ); - if ( ret == 0 ) { - /* ACL plugin denied access */ - goto done; - } - } -#endif /* LDAP_SLAPI */ - /* grant database root access */ if ( be_isroot( op ) ) { Debug( LDAP_DEBUG_ACL, "<= root access granted\n", 0, 0, 0 ); @@ -1751,6 +1766,9 @@ slap_acl_mask( continue; } + Debug( LDAP_DEBUG_ACL, "<= check a_group_pat: %s\n", + b->a_group_pat.bv_val, 0, 0 ); + /* b->a_group is an unexpanded entry name, expanded it should be an * entry with objectclass group* and we test to see if odn is one of * the values in the attribute group @@ -1838,6 +1856,9 @@ slap_acl_mask( struct berval bv; char buf[ACL_BUF_SIZE]; + Debug( LDAP_DEBUG_ACL, "<= check a_set_pat: %s\n", + b->a_set_pat.bv_val, 0, 0 ); + if ( b->a_set_style == ACL_STYLE_EXPAND ) { int tmp_nmatch; regmatch_t tmp_matches[2], @@ -1940,6 +1961,9 @@ slap_acl_mask( slap_dynacl_t *da; slap_access_t tgrant, tdeny; + Debug( LDAP_DEBUG_ACL, "<= check a_dynacl\n", + 0, 0, 0 ); + /* this case works different from the others above. * since aci's themselves give permissions, we need * to first check b->a_access_mask, the ACL's access level. @@ -1963,6 +1987,9 @@ slap_acl_mask( for ( da = b->a_dynacl; da; da = da->da_next ) { slap_access_t grant, deny; + Debug( LDAP_DEBUG_ACL, " <= check a_dynacl: %s\n", + da->da_name, 0, 0 ); + (void)( *da->da_mask )( da->da_private, op, e, desc, val, nmatch, matches, &grant, &deny ); tgrant |= grant; @@ -2007,6 +2034,9 @@ slap_acl_mask( BerVarray bvals = NULL; int ret, stop; + Debug( LDAP_DEBUG_ACL, " <= check a_aci_at: %s\n", + b->a_aci_at->ad_cname.bv_val, 0, 0 ); + /* this case works different from the others above. * since aci's themselves give permissions, we need * to first check b->a_access_mask, the ACL's access level. @@ -3208,7 +3238,7 @@ dynacl_aci_unparse( void *priv, struct berval *bv ) AttributeDescription *ad = ( AttributeDescription * )priv; char *ptr; - assert( ad ); + assert( ad != NULL ); bv->bv_val = ch_malloc( STRLENOF(" aci=") + ad->ad_cname.bv_len + 1 ); ptr = lutil_strcopy( bv->bv_val, " aci=" ); @@ -3440,8 +3470,8 @@ slap_dynacl_get( const char *name ) int acl_init( void ) { - int i, rc; #ifdef SLAP_DYNACL + int i, rc; slap_dynacl_t *known_dynacl[] = { #ifdef SLAPD_ACI_ENABLED &dynacl_aci, diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index b1760206ff..30a4b455f6 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -961,12 +961,12 @@ parse_acl( fprintf( stderr, "%s: line %d: \"onelevel\" should be used " "instead of \"level{1}\" in by DN clause\n", - fname, lineno, 0 ); + fname, lineno ); } else if ( level == 0 && sty == ACL_STYLE_LEVEL ) { fprintf( stderr, "%s: line %d: \"base\" should be used " "instead of \"level{0}\" in by DN clause\n", - fname, lineno, 0 ); + fname, lineno ); } bdn->a_level = level; @@ -1034,7 +1034,7 @@ parse_acl( fprintf( stderr, "%s: line %d: " "deprecated group style \"regex\"; " "use \"expand\" instead\n", - fname, lineno, style ); + fname, lineno ); sty = ACL_STYLE_EXPAND; break; @@ -2290,7 +2290,7 @@ acl_destroy( AccessControl *a, AccessControl *end ) { AccessControl *n; - for (; a && a!= end; a=n) { + for ( ; a && a != end; a = n ) { n = a->acl_next; acl_free( a ); } @@ -2454,10 +2454,10 @@ access2text( Access *b, char *ptr ) if ( !BER_BVISEMPTY( &b->a_group_pat ) ) { ptr = lutil_strcopy( ptr, " group/" ); ptr = lutil_strcopy( ptr, b->a_group_oc ? - b->a_group_oc->soc_cname.bv_val : "groupOfNames" ); + b->a_group_oc->soc_cname.bv_val : SLAPD_GROUP_CLASS ); *ptr++ = '/'; ptr = lutil_strcopy( ptr, b->a_group_at ? - b->a_group_at->ad_cname.bv_val : "member" ); + b->a_group_at->ad_cname.bv_val : SLAPD_GROUP_ATTR ); *ptr++ = '.'; ptr = lutil_strcopy( ptr, style_strings[b->a_group_style] ); *ptr++ = '='; diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 34f8cb4f20..2aa538e725 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -510,7 +510,6 @@ int ad_inlist( for( ; attrs->an_name.bv_val; attrs++ ) { AttributeType *a; ObjectClass *oc; - int rc; if ( attrs->an_desc ) { int lr; @@ -584,8 +583,6 @@ int ad_inlist( } if( oc != NULL ) { if ( attrs->an_oc_exclude ) { - int gotit = 0; - if ( oc == slap_schema.si_oc_extensibleObject ) { /* extensibleObject allows the return of anything */ return 0; @@ -778,13 +775,17 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) AttributeName *anew; /* find last element in list */ - for (i = 0; an && an[i].an_name.bv_val; i++); + i = 0; + if ( an != NULL ) { + for ( i = 0; !BER_BVISNULL( &an[ i ].an_name ) ; i++) + ; + } /* protect the input string from strtok */ str = ch_strdup( in ); /* Count words in string */ - j=1; + j = 1; for ( s = str; *s; s++ ) { if ( strchr( brkstr, *s ) != NULL ) { j++; @@ -842,7 +843,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr ) anew++; } - anew->an_name.bv_val = NULL; + BER_BVZERO( &anew->an_name ); free( str ); return( an ); @@ -993,8 +994,6 @@ file2anlist( AttributeName *an, const char *fname, const char *brkstr ) } while ( fgets( lcur, LBUFSIZ, fp ) != NULL ) { - char *str, *s, *next; - const char *delimstr = brkstr; if ( ( c = strchr( lcur, '\n' ) ) ) { if ( c == line ) { *c = '\0'; diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 537129fdd4..7df87348aa 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -32,15 +32,6 @@ #include "slap.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" - -static void init_add_pblock( Operation *op, struct berval *dn, Entry *e, - int manageDSAit ); -static int call_add_preop_plugins( Operation *op ); -static void call_add_postop_plugins( Operation *op ); -#endif /* LDAP_SLAPI */ - int do_add( Operation *op, SlapReply *rs ) { @@ -175,6 +166,14 @@ do_add( Operation *op, SlapReply *rs ) /* temporary; remove if not invoking backend function */ op->ora_modlist = modlist; + /* call this so global overlays/SLAPI have access to ora_e */ + rs->sr_err = slap_mods2entry( op->ora_modlist, &op->ora_e, + 1, 0, &rs->sr_text, textbuf, textlen ); + if ( rs->sr_err != LDAP_SUCCESS ) { + send_ldap_result( op, rs ); + goto done; + } + op->o_bd = frontendDB; rc = frontendDB->be_add( op, rs ); if ( rc == 0 ) { @@ -196,8 +195,9 @@ done:; slap_graduate_commit_csn( op ); if ( modlist != NULL ) { - slap_mods_free( modlist ); + slap_mods_free( modlist, 0 ); } + if ( op->ora_e != NULL ) { entry_free( op->ora_e ); } @@ -273,10 +273,6 @@ fe_op_add( Operation *op, SlapReply *rs ) goto done; } -#ifdef LDAP_SLAPI - if ( op->o_pb ) init_add_pblock( op, &op->o_req_dn, op->ora_e, manageDSAit ); -#endif /* LDAP_SLAPI */ - /* * do the add if 1 && (2 || 3) * 1) there is an add function implemented in this backend; @@ -315,6 +311,7 @@ fe_op_add( Operation *op, SlapReply *rs ) assert( (*modtail)->sml_desc != NULL ); } + rs->sr_err = slap_mods_opattrs( op, modlist, modtail, &rs->sr_text, textbuf, textlen, 1 ); @@ -322,28 +319,22 @@ fe_op_add( Operation *op, SlapReply *rs ) send_ldap_result( op, rs ); goto done; } - } - rs->sr_err = slap_mods2entry( modlist, &op->ora_e, - repl_user, 0, &rs->sr_text, textbuf, textlen ); - if ( rs->sr_err != LDAP_SUCCESS ) { - send_ldap_result( op, rs ); - goto done; - } + /* check for duplicate values */ + rs->sr_err = slap_mods_no_repl_user_mod_check( op, + modlist, &rs->sr_text, textbuf, textlen ); + if ( rs->sr_err != LDAP_SUCCESS ) { + send_ldap_result( op, rs ); + goto done; + } -#ifdef LDAP_SLAPI - /* - * Call the preoperation plugin here, because the entry - * will actually contain something. - */ - if ( op->o_pb ) { - rs->sr_err = call_add_preop_plugins( op ); + rs->sr_err = slap_mods2entry( *modtail, &op->ora_e, + 0, 0, &rs->sr_text, textbuf, textlen ); if ( rs->sr_err != LDAP_SUCCESS ) { - /* plugin will have sent result */ + send_ldap_result( op, rs ); goto done; } } -#endif /* LDAP_SLAPI */ #ifdef SLAPD_MULTIMASTER if ( !repl_user ) @@ -364,19 +355,6 @@ fe_op_add( Operation *op, SlapReply *rs ) #ifndef SLAPD_MULTIMASTER } else { BerVarray defref = NULL; -#ifdef LDAP_SLAPI - /* - * SLAPI_ADD_ENTRY will be empty, but this may be acceptable - * on replicas (for now, it involves the minimum code intrusion). - */ - if ( op->o_pb ) { - rs->sr_err = call_add_preop_plugins( op ); - if ( rs->sr_err != LDAP_SUCCESS ) { - /* plugin will have sent result */ - goto done; - } - } -#endif /* LDAP_SLAPI */ defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; @@ -400,24 +378,11 @@ fe_op_add( Operation *op, SlapReply *rs ) #endif /* SLAPD_MULTIMASTER */ } } else { -#ifdef LDAP_SLAPI - if ( op->o_pb ) { - rs->sr_err = call_add_preop_plugins( op ); - if ( rs->sr_err != LDAP_SUCCESS ) { - /* plugin will have sent result */ - goto done; - } - } -#endif Debug( LDAP_DEBUG_ARGS, " do_add: no backend support\n", 0, 0, 0 ); send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "operation not supported within namingContext" ); } -#ifdef LDAP_SLAPI - if ( op->o_pb ) call_add_postop_plugins( op ); -#endif /* LDAP_SLAPI */ - done:; return rc; } @@ -426,22 +391,25 @@ int slap_mods2entry( Modifications *mods, Entry **e, - int repl_user, + int initial, int dup, const char **text, char *textbuf, size_t textlen ) { - Attribute **tail = &(*e)->e_attrs; - assert( *tail == NULL ); + Attribute **tail; + + if ( initial ) { + assert( (*e)->e_attrs == NULL ); + } + + for ( tail = &(*e)->e_attrs; *tail != NULL; tail = &(*tail)->a_next ) + ; *text = textbuf; for( ; mods != NULL; mods = mods->sml_next ) { Attribute *attr; - if ( !repl_user ) { - assert( mods->sml_op == LDAP_MOD_ADD ); - } assert( mods->sml_desc != NULL ); attr = attr_find( (*e)->e_attrs, mods->sml_desc ); @@ -451,11 +419,15 @@ slap_mods2entry( #ifdef SLURPD_FRIENDLY ber_len_t i,j; - if( !repl_user ) { - snprintf( textbuf, textlen, - "attribute '%s' provided more than once", - mods->sml_desc->ad_cname.bv_val ); - return LDAP_TYPE_OR_VALUE_EXISTS; + if ( !initial ) { + /* + * This check allows overlays to override operational + * attributes by setting them directly in the entry. + * We assume slap_mods_no_user_mod_check() was called + * with the user modifications. + */ + *text = NULL; + return LDAP_SUCCESS; } for( i=0; attr->a_vals[i].bv_val; i++ ) { @@ -475,12 +447,11 @@ slap_mods2entry( for ( j = 0; mods->sml_values[j].bv_val; j++ ) { ber_dupbv( &attr->a_vals[i+j], &mods->sml_values[j] ); } - BER_BVZERO( &attr->a_vals[i+j] ); + BER_BVZERO( &attr->a_vals[i+j] ); + j++; } else { AC_MEMCPY( &attr->a_vals[i], mods->sml_values, sizeof( struct berval ) * j ); - ch_free( mods->sml_values ); - mods->sml_values = NULL; } if( mods->sml_nvalues ) { @@ -494,8 +465,6 @@ slap_mods2entry( } else { AC_MEMCPY( &attr->a_nvals[i], mods->sml_nvalues, sizeof( struct berval ) * j ); - ch_free( mods->sml_nvalues ); - mods->sml_nvalues = NULL; } } else { attr->a_nvals = attr->a_vals; @@ -549,7 +518,6 @@ slap_mods2entry( /* move ad to attr structure */ attr->a_desc = mods->sml_desc; - if ( !dup ) mods->sml_desc = NULL; /* move values to attr structure */ /* should check for duplicates */ @@ -563,7 +531,6 @@ slap_mods2entry( BER_BVZERO( &attr->a_vals[i] ); } else { attr->a_vals = mods->sml_values; - mods->sml_values = NULL; } if ( mods->sml_nvalues ) { @@ -577,7 +544,6 @@ slap_mods2entry( BER_BVZERO( &attr->a_nvals[i] ); } else { attr->a_nvals = mods->sml_nvalues; - mods->sml_nvalues = NULL; } } else { attr->a_nvals = attr->a_vals; @@ -660,51 +626,3 @@ slap_entry2mods( return LDAP_SUCCESS; } -#ifdef LDAP_SLAPI -static void init_add_pblock( Operation *op, - struct berval *dn, Entry *e, int manageDSAit ) -{ - slapi_int_pblock_set_operation( op->o_pb, op ); - slapi_pblock_set( op->o_pb, SLAPI_ADD_TARGET, (void *)dn->bv_val ); - slapi_pblock_set( op->o_pb, SLAPI_ADD_ENTRY, (void *)e ); - slapi_pblock_set( op->o_pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit ); -} - -static int call_add_preop_plugins( Operation *op ) -{ - int rc; - - rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_ADD_FN, op->o_pb ); - if ( rc < 0 ) { - /* - * A preoperation plugin failure will abort the - * entire operation. - */ - Debug(LDAP_DEBUG_TRACE, - "do_add: add preoperation plugin failed.\n", - 0, 0, 0); - - if (( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, - (void *)&rc ) != 0 ) || rc == LDAP_SUCCESS ) - { - rc = LDAP_OTHER; - } - } else { - rc = LDAP_SUCCESS; - } - - return rc; -} - -static void call_add_postop_plugins( Operation *op ) -{ - int rc; - - rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_ADD_FN, op->o_pb ); - if ( rc < 0 ) { - Debug(LDAP_DEBUG_TRACE, - "do_add: add postoperation plugin failed\n", - 0, 0, 0); - } -} -#endif /* LDAP_SLAPI */ diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 14ed55b749..44ec64c2e0 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -214,7 +214,31 @@ at_destroy( void ) a = LDAP_STAILQ_FIRST(&attr_list); LDAP_STAILQ_REMOVE_HEAD(&attr_list, sat_next); - if (a->sat_subtypes) ldap_memfree(a->sat_subtypes); + if ( a->sat_equality ) { + MatchingRule *mr; + + mr = mr_find( a->sat_equality->smr_oid ); + assert( mr != NULL ); + if ( mr != a->sat_equality ) { + ch_free( a->sat_equality ); + a->sat_equality = NULL; + } + } + + assert( a->sat_syntax != NULL ); + if ( a->sat_syntax != NULL ) { + Syntax *syn; + + syn = syn_find( a->sat_syntax->ssyn_oid ); + assert( syn != NULL ); + if ( syn != a->sat_syntax ) { + ch_free( a->sat_syntax ); + a->sat_syntax = NULL; + } + } + + if ( a->sat_oidmacro ) ldap_memfree( a->sat_oidmacro ); + if ( a->sat_subtypes ) ldap_memfree( a->sat_subtypes ); ad_destroy(a->sat_ad); ldap_pvt_thread_mutex_destroy(&a->sat_ad_mutex); ldap_attributetype_free((LDAPAttributeType *)a); @@ -228,7 +252,7 @@ at_destroy( void ) int at_start( AttributeType **at ) { - assert( at ); + assert( at != NULL ); *at = LDAP_STAILQ_FIRST(&attr_list); @@ -238,7 +262,7 @@ at_start( AttributeType **at ) int at_next( AttributeType **at ) { - assert( at ); + assert( at != NULL ); #if 1 /* pedantic check */ { @@ -250,7 +274,7 @@ at_next( AttributeType **at ) } } - assert( tmp ); + assert( tmp != NULL ); } #endif @@ -383,10 +407,10 @@ at_insert( int at_add( - LDAPAttributeType *at, - int user, - AttributeType **rsat, - const char **err ) + LDAPAttributeType *at, + int user, + AttributeType **rsat, + const char **err ) { AttributeType *sat; MatchingRule *mr; @@ -475,28 +499,33 @@ at_add( if ( supsat == NULL ) { *err = at->at_sup_oid; - return SLAP_SCHERR_ATTR_NOT_FOUND; + code = SLAP_SCHERR_ATTR_NOT_FOUND; + goto error_return; } sat->sat_sup = supsat; if ( at_append_to_list(sat, &supsat->sat_subtypes) ) { - return SLAP_SCHERR_OUTOFMEM; + code = SLAP_SCHERR_OUTOFMEM; + goto error_return; } if ( sat->sat_usage != supsat->sat_usage ) { /* subtypes must have same usage as their SUP */ - return SLAP_SCHERR_ATTR_BAD_USAGE; + code = SLAP_SCHERR_ATTR_BAD_USAGE; + goto error_return; } if ( supsat->sat_obsolete && !sat->sat_obsolete ) { /* subtypes must be obsolete if super is */ - return SLAP_SCHERR_ATTR_BAD_SUP; + code = SLAP_SCHERR_ATTR_BAD_SUP; + goto error_return; } if ( sat->sat_flags & SLAP_AT_FINAL ) { /* cannot subtype a "final" attribute type */ - return SLAP_SCHERR_ATTR_BAD_SUP; + code = SLAP_SCHERR_ATTR_BAD_SUP; + goto error_return; } } @@ -540,17 +569,20 @@ at_add( syn = syn_find(sat->sat_syntax_oid); if ( syn == NULL ) { *err = sat->sat_syntax_oid; - return SLAP_SCHERR_SYN_NOT_FOUND; + code = SLAP_SCHERR_SYN_NOT_FOUND; + goto error_return; } if( sat->sat_syntax != NULL && sat->sat_syntax != syn ) { - return SLAP_SCHERR_ATTR_BAD_SUP; + code = SLAP_SCHERR_ATTR_BAD_SUP; + goto error_return; } sat->sat_syntax = syn; } else if ( sat->sat_syntax == NULL ) { - return SLAP_SCHERR_ATTR_INCOMPLETE; + code = SLAP_SCHERR_ATTR_INCOMPLETE; + goto error_return; } if ( sat->sat_equality_oid ) { @@ -558,18 +590,21 @@ at_add( if( mr == NULL ) { *err = sat->sat_equality_oid; - return SLAP_SCHERR_MR_NOT_FOUND; + code = SLAP_SCHERR_MR_NOT_FOUND; + goto error_return; } if(( mr->smr_usage & SLAP_MR_EQUALITY ) != SLAP_MR_EQUALITY ) { *err = sat->sat_equality_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } if( sat->sat_syntax != mr->smr_syntax ) { if( mr->smr_compat_syntaxes == NULL ) { *err = sat->sat_equality_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } for(i=0; mr->smr_compat_syntaxes[i]; i++) { @@ -581,7 +616,8 @@ at_add( if( i >= 0 ) { *err = sat->sat_equality_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } } @@ -592,25 +628,29 @@ at_add( if ( sat->sat_ordering_oid ) { if( !sat->sat_equality ) { *err = sat->sat_ordering_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } mr = mr_find(sat->sat_ordering_oid); if( mr == NULL ) { *err = sat->sat_ordering_oid; - return SLAP_SCHERR_MR_NOT_FOUND; + code = SLAP_SCHERR_MR_NOT_FOUND; + goto error_return; } if(( mr->smr_usage & SLAP_MR_ORDERING ) != SLAP_MR_ORDERING ) { *err = sat->sat_ordering_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } if( sat->sat_syntax != mr->smr_syntax ) { if( mr->smr_compat_syntaxes == NULL ) { *err = sat->sat_ordering_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } for(i=0; mr->smr_compat_syntaxes[i]; i++) { @@ -622,7 +662,8 @@ at_add( if( i >= 0 ) { *err = sat->sat_ordering_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } } @@ -632,19 +673,22 @@ at_add( if ( sat->sat_substr_oid ) { if( !sat->sat_equality ) { *err = sat->sat_substr_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } mr = mr_find(sat->sat_substr_oid); if( mr == NULL ) { *err = sat->sat_substr_oid; - return SLAP_SCHERR_MR_NOT_FOUND; + code = SLAP_SCHERR_MR_NOT_FOUND; + goto error_return; } if(( mr->smr_usage & SLAP_MR_SUBSTR ) != SLAP_MR_SUBSTR ) { *err = sat->sat_substr_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } /* due to funky LDAP builtin substring rules, @@ -655,7 +699,8 @@ at_add( if( sat->sat_syntax != sat->sat_equality->smr_syntax ) { if( sat->sat_equality->smr_compat_syntaxes == NULL ) { *err = sat->sat_substr_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } for(i=0; sat->sat_equality->smr_compat_syntaxes[i]; i++) { @@ -669,7 +714,8 @@ at_add( if( i >= 0 ) { *err = sat->sat_substr_oid; - return SLAP_SCHERR_ATTR_BAD_MR; + code = SLAP_SCHERR_ATTR_BAD_MR; + goto error_return; } } @@ -677,8 +723,22 @@ at_add( } code = at_insert( sat, err ); - if ( code == 0 && rsat ) + if ( code != 0 ) { +error_return:; + if ( sat ) { + ldap_pvt_thread_mutex_destroy( &sat->sat_ad_mutex ); + ch_free( sat ); + } + + if ( oidm ) { + SLAP_FREE( at->at_oid ); + at->at_oid = oidm; + } + + } else if ( rsat ) { *rsat = sat; + } + return code; } diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 7042d18c2b..d0738ed01a 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -126,7 +126,7 @@ attr_dup( Attribute *a ) BER_BVZERO( &tmp->a_vals[i] ); /* a_nvals must be non null; it may be equal to a_vals */ - assert( a->a_nvals ); + assert( a->a_nvals != NULL ); if ( a->a_nvals != a->a_vals ) { tmp->a_nvals = ch_malloc( (i + 1) * sizeof(struct berval) ); diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 4ef340e92b..227652077e 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -52,7 +52,7 @@ bdb_add(Operation *op, SlapReply *rs ) ctrls[num_ctrls] = 0; /* check entry's schema */ - rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e, NULL, + rs->sr_err = entry_schema_check( op, op->oq_add.rs_e, NULL, get_manageDIT(op), &rs->sr_text, textbuf, textlen ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-bdb/alock.c b/servers/slapd/back-bdb/alock.c index 4951e8ffab..92fc243edc 100644 --- a/servers/slapd/back-bdb/alock.c +++ b/servers/slapd/back-bdb/alock.c @@ -234,7 +234,7 @@ alock_read_slot ( alock_info_t * info, if (slot_data->al_appname) free (slot_data->al_appname); slot_data->al_appname = calloc (1, ALOCK_MAX_APPNAME); - strncpy (slot_data->al_appname, slotbuf+32, ALOCK_MAX_APPNAME-1); + strncpy (slot_data->al_appname, (char *)slotbuf+32, ALOCK_MAX_APPNAME-1); (slot_data->al_appname) [ALOCK_MAX_APPNAME-1] = '\0'; return 0; @@ -259,7 +259,7 @@ alock_write_slot ( alock_info_t * info, alock_write_iattr (slotbuf+16, slot_data->al_stamp); alock_write_iattr (slotbuf+24, slot_data->al_pid); - strncpy (slotbuf+32, slot_data->al_appname, ALOCK_MAX_APPNAME-1); + strncpy ((char *)slotbuf+32, slot_data->al_appname, ALOCK_MAX_APPNAME-1); slotbuf[ALOCK_SLOT_SIZE-1] = '\0'; res = lseek (info->al_fd, @@ -295,11 +295,12 @@ alock_query_slot ( alock_info_t * info ) (void) memset ((void *) &slot_data, 0, sizeof (alock_slot_t)); alock_read_slot (info, &slot_data); - if (slot_data.al_lock == ALOCK_UNLOCKED) return ALOCK_UNLOCKED; if (slot_data.al_appname != NULL) free (slot_data.al_appname); slot_data.al_appname = NULL; + if (slot_data.al_lock == ALOCK_UNLOCKED) return ALOCK_UNLOCKED; + res = alock_test_lock (info->al_fd, info->al_slot); if (res < 0) return -1; if (res > 0) { diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index dea33f671d..e28d7c189b 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -195,6 +195,10 @@ struct bdb_info { #define BDB_UPD_CONFIG 0x04 #define BDB_DEL_INDEX 0x08 #define BDB_RE_OPEN 0x10 +#ifdef BDB_HIER + int bi_modrdns; /* number of modrdns completed */ + ldap_pvt_thread_mutex_t bi_modrdns_mutex; +#endif }; #define bi_id2entry bi_databases[BDB_ID2ENTRY] @@ -261,11 +265,11 @@ struct bdb_op_info { /* Copy an ID "src" to pointer "dst" in big-endian byte order */ #define BDB_ID2DISK( src, dst ) \ do { int i0; ID tmp; unsigned char *_p; \ - tmp = (src); _p = (char *)(dst); \ + tmp = (src); _p = (unsigned char *)(dst); \ for ( i0=sizeof(ID)-1; i0>=0; i0-- ) { \ _p[i0] = tmp & 0xff; tmp >>= 8; \ } \ - } while(0); + } while(0) /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */ #define BDB_DISK2ID( src, dst ) \ @@ -274,7 +278,7 @@ struct bdb_op_info { for ( i0=0; i0e_name; DB_LOCK lock; int rc; +#ifdef BDB_HIER + struct berval rdn = e->e_name; +#endif ei.bei_id = e->e_id; ei.bei_parent = eip; @@ -972,20 +974,22 @@ bdb_cache_modify( */ int bdb_cache_modrdn( + struct bdb_info *bdb, Entry *e, struct berval *nrdn, Entry *new, EntryInfo *ein, - DB_ENV *env, u_int32_t locker, DB_LOCK *lock ) { EntryInfo *ei = BEI(e), *pei; - struct berval rdn; int rc; +#ifdef BDB_HIER + struct berval rdn; +#endif /* Get write lock on data */ - rc = bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock ); + rc = bdb_cache_entry_db_relock( bdb->bi_dbenv, locker, ei, 1, 0, lock ); if ( rc ) return rc; /* If we've done repeated mods on a cached entry, then e_attrs @@ -1030,12 +1034,11 @@ bdb_cache_modrdn( } #ifdef BDB_HIER { - int max = ei->bei_modrdns; /* Record the generation number of this change */ - for ( pei = ein; pei->bei_parent; pei = pei->bei_parent ) { - if ( pei->bei_modrdns > max ) max = pei->bei_modrdns; - } - ei->bei_modrdns = max + 1; + ldap_pvt_thread_mutex_lock( &bdb->bi_modrdns_mutex ); + bdb->bi_modrdns++; + ei->bei_modrdns = bdb->bi_modrdns; + ldap_pvt_thread_mutex_unlock( &bdb->bi_modrdns_mutex ); } #endif avl_insert( &ein->bei_kids, ei, bdb_rdn_cmp, avl_dup_error ); @@ -1060,7 +1063,7 @@ bdb_cache_delete( EntryInfo *ei = BEI(e); int rc; - assert( e->e_private ); + assert( e->e_private != NULL ); /* Set this early, warn off any queriers */ ei->bei_state |= CACHE_ENTRY_DELETED; @@ -1315,15 +1318,15 @@ static void bdb_locker_id_free( void *key, void *data ) { DB_ENV *env = key; - int lockid = (int) data; + u_int32_t lockid = (u_int32_t) data; int rc; rc = XLOCK_ID_FREE( env, lockid ); if ( rc == EINVAL ) { DB_LOCKREQ lr; Debug( LDAP_DEBUG_ANY, - "bdb_locker_id_free: %d err %s(%d)\n", - lockid, db_strerror(rc), rc ); + "bdb_locker_id_free: %lu err %s(%d)\n", + (unsigned long) lockid, db_strerror(rc), rc ); /* release all locks held by this locker. */ lr.op = DB_LOCK_PUT_ALL; lr.obj = NULL; @@ -1333,9 +1336,10 @@ bdb_locker_id_free( void *key, void *data ) } int -bdb_locker_id( Operation *op, DB_ENV *env, int *locker ) +bdb_locker_id( Operation *op, DB_ENV *env, u_int32_t *locker ) { - int i, rc, lockid; + int i, rc; + u_int32_t lockid; void *data; void *ctx; @@ -1372,12 +1376,12 @@ bdb_locker_id( Operation *op, DB_ENV *env, int *locker ) return rc; } } else { - lockid = (int)data; + lockid = (u_int32_t) data; } *locker = lockid; return 0; } -#endif +#endif /* BDB_REUSE_LOCKERS */ void bdb_cache_delete_entry( diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index 1c01c2296f..82169471e9 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -263,7 +263,7 @@ bdb_online_index( void *ctx, void *arg ) id++; getnext = 1; } -out: + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); ldap_pvt_runqueue_stoptask( &slapd_rq, rtask ); bdb->bi_index_task = NULL; @@ -356,12 +356,12 @@ bdb_cf_gen(ConfigArgs *c) bdb->bi_flags |= BDB_HAS_CONFIG; while ( fgets( buf, sizeof(buf), f )) { ber_str2bv( buf, 0, 1, &bv ); - if ( bv.bv_val[bv.bv_len-1] == '\n' ) { + if ( bv.bv_len > 0 && bv.bv_val[bv.bv_len-1] == '\n' ) { bv.bv_len--; bv.bv_val[bv.bv_len] = '\0'; } /* shouldn't need this, but ... */ - if ( bv.bv_val[bv.bv_len-1] == '\r' ) { + if ( bv.bv_len > 0 && bv.bv_val[bv.bv_len-1] == '\r' ) { bv.bv_len--; bv.bv_val[bv.bv_len] = '\0'; } diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 89bfae0ebf..89d5704c64 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -381,10 +381,7 @@ bdb_dn2idl( } #else /* BDB_HIER */ -/* Experimental management routines for a hierarchically structured database. - * - * Unsupported! Use at your own risk! - * -- Howard Chu, Symas Corp. 2003. +/* Management routines for a hierarchically structured database. * * Instead of a ldbm-style dn2id database, we use a hierarchical one. Each * entry in this database is a struct diskNode, keyed by entryID and with @@ -402,9 +399,9 @@ bdb_dn2idl( */ typedef struct diskNode { unsigned char nrdnlen[2]; - unsigned char nrdn[1]; - unsigned char rdn[1]; - unsigned char entryID[sizeof(ID)]; + char nrdn[1]; + char rdn[1]; /* variable placement */ + unsigned char entryID[sizeof(ID)]; /* variable placement */ } diskNode; /* This function constructs a full DN for a given entry. @@ -516,7 +513,7 @@ hdb_dn2id_add( * will fail harmlessly. */ if ( eip->bei_id == 0 ) { - diskNode dummy = {0}; + diskNode dummy = {{0, 0}, "", "", ""}; data.data = &dummy; data.size = sizeof(diskNode); data.flags = DB_DBT_USERMEM; @@ -555,7 +552,7 @@ hdb_dn2id_delete( DBT key, data; DBC *cursor; diskNode *d; - int rc, nrlen; + int rc; ID nid; unsigned char dlen[2]; @@ -634,7 +631,7 @@ hdb_dn2id( diskNode *d; char *ptr; unsigned char dlen[2]; - ID idp; + ID idp, parentID; nrlen = dn_rdnlen( op->o_bd, in ); if (!nrlen) nrlen = in->bv_len; @@ -644,7 +641,8 @@ hdb_dn2id( key.data = &idp; key.ulen = sizeof(ID); key.flags = DB_DBT_USERMEM; - BDB_ID2DISK( ei->bei_parent->bei_id, &idp ); + parentID = ( ei->bei_parent != NULL ) ? ei->bei_parent->bei_id : 0; + BDB_ID2DISK( parentID, &idp ); DBTzero(&data); data.size = sizeof(diskNode) + nrlen - sizeof(ID) - 1; @@ -675,7 +673,7 @@ hdb_dn2id( ei->bei_rdn.bv_len = data.size - sizeof(diskNode) - nrlen; ptr = d->nrdn + nrlen + 1; ber_str2bv( ptr, ei->bei_rdn.bv_len, 1, &ei->bei_rdn ); - if ( !ei->bei_parent->bei_dkids ) { + if ( ei->bei_parent != NULL && !ei->bei_parent->bei_dkids ) { db_recno_t dkids; /* How many children does the parent have? */ /* FIXME: do we need to lock the parent @@ -705,7 +703,6 @@ hdb_dn2id_parent( int rc = 0; diskNode *d; char *ptr; - unsigned char *pt2; ID nid; DBTzero(&key); diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index a8961d1bee..21431fec2d 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -154,7 +154,7 @@ bdb_filter_candidates( /* if no GE index, use pres */ Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 ); if( f->f_ava->aa_desc->ad_type->sat_ordering && - ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage && SLAP_MR_ORDERED_INDEX ) ) + ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage & SLAP_MR_ORDERED_INDEX ) ) rc = inequality_candidates( op, f->f_ava, ids, tmp, LDAP_FILTER_GE ); else rc = presence_candidates( op, f->f_ava->aa_desc, ids ); @@ -164,7 +164,7 @@ bdb_filter_candidates( /* if no LE index, use pres */ Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 ); if( f->f_ava->aa_desc->ad_type->sat_ordering && - ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage && SLAP_MR_ORDERED_INDEX ) ) + ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage & SLAP_MR_ORDERED_INDEX ) ) rc = inequality_candidates( op, f->f_ava, ids, tmp, LDAP_FILTER_LE ); else rc = presence_candidates( op, f->f_ava->aa_desc, ids ); diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index c00ba93235..5c5e0ef304 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -1212,8 +1212,6 @@ ID bdb_idl_next( ID *ids, ID *cursor ) */ int bdb_idl_append_one( ID *ids, ID id ) { - unsigned x; - if (BDB_IDL_IS_RANGE( ids )) { /* if already in range, treat as a dup */ if (id >= BDB_IDL_FIRST(ids) && id <= BDB_IDL_LAST(ids)) diff --git a/servers/slapd/back-bdb/index.c b/servers/slapd/back-bdb/index.c index 91c5a74626..0e17da25b7 100644 --- a/servers/slapd/back-bdb/index.c +++ b/servers/slapd/back-bdb/index.c @@ -170,7 +170,7 @@ static int indexer( DB *db; struct berval *keys; - assert( mask ); + assert( mask != 0 ); rc = bdb_db_cache( op->o_bd, atname->bv_val, &db ); @@ -389,7 +389,7 @@ bdb_index_entry( #ifdef LDAP_COMP_MATCH ComponentReference *cr_list = NULL; ComponentReference *cr = NULL, *dupped_cr = NULL; - void* decoded_comp, *extracted_comp; + void* decoded_comp; ComponentSyntaxInfo* csi_attr; Syntax* syn; AttributeType* at; diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index a2810c1eca..581fe1abd6 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -22,6 +22,12 @@ #include #include #include +#ifdef HAVE_UTIME_H +# ifdef HAVE_SYS_TYPES_H +# include +# endif +# include +#endif /* HAVE_UTIME_H */ #include "back-bdb.h" #include #include @@ -66,6 +72,9 @@ bdb_db_init( BackendDB *be ) ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex ); ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex ); +#ifdef BDB_HIER + ldap_pvt_thread_mutex_init( &bdb->bi_modrdns_mutex ); +#endif ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex ); ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex ); ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock ); @@ -243,7 +252,6 @@ bdb_db_recover( BackendDB *be ) return bdb_do_recovery( be ); } -re_exit: Debug( LDAP_DEBUG_ANY, "bdb_db_recover: Database cannot be recovered. "\ "Restore from backup!\n", 0, 0, 0); @@ -262,6 +270,13 @@ bdb_db_open( BackendDB *be ) char path[MAXPATHLEN]; char *ptr; + if ( be->be_suffix == NULL ) { + Debug( LDAP_DEBUG_ANY, + "bdb_db_open: need suffix\n", + 0, 0, 0 ); + return -1; + } + Debug( LDAP_DEBUG_ARGS, "bdb_db_open: %s\n", be->be_suffix[0].bv_val, 0, 0 ); @@ -543,6 +558,10 @@ bdb_db_close( BackendDB *be ) struct bdb_db_info *db; bdb_idl_cache_entry_t *entry, *next_entry; + /* backend_shutdown closes everything, even if not all were opened */ + if ( !( bdb->bi_flags & BDB_IS_OPEN )) + return 0; + bdb->bi_flags &= ~BDB_IS_OPEN; ber_bvarray_free( bdb->bi_db_config ); @@ -605,6 +624,32 @@ bdb_db_close( BackendDB *be ) db_strerror(rc), rc, 0 ); return rc; } + +#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 2 + /* Delete the environment if we were in quick mode. This + * works around a bug in bdb4.2 that interferes with the + * operation of db_stat and other tools after a slapadd -q + * or slapindex -q has taken place. + */ + if( slapMode & SLAP_TOOL_QUICK ) { + rc = db_env_create( &bdb->bi_dbenv, 0 ); + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "bdb_db_close: db_env_create failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); + return rc; + } + rc = bdb->bi_dbenv->remove(bdb->bi_dbenv, bdb->bi_dbenv_home, + DB_FORCE); + bdb->bi_dbenv = NULL; + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "bdb_db_close: dbenv_remove failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); + return rc; + } + } +#endif } rc = alock_close( &bdb->bi_alock_info ); @@ -620,7 +665,6 @@ bdb_db_close( BackendDB *be ) static int bdb_db_destroy( BackendDB *be ) { - int rc; struct bdb_info *bdb = (struct bdb_info *) be->be_private; if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home ); @@ -631,6 +675,9 @@ bdb_db_destroy( BackendDB *be ) ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock ); ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex ); ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex ); +#ifdef BDB_HIER + ldap_pvt_thread_mutex_destroy( &bdb->bi_modrdns_mutex ); +#endif ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex ); ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex ); ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock ); diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 7e85e8b322..d342febff2 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -196,7 +196,7 @@ int bdb_modify_internal( } /* check that the entry still obeys the schema */ - rc = entry_schema_check( op->o_bd, e, save_attrs, get_manageDIT(op), + rc = entry_schema_check( op, e, save_attrs, get_manageDIT(op), text, textbuf, textlen ); if ( rc != LDAP_SUCCESS || op->o_noop ) { attrs_free( e->e_attrs ); diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 54c487c450..0a6b8d7fd2 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -797,8 +797,8 @@ retry: /* transaction retry */ } } else { - rc = bdb_cache_modrdn( e, &op->orr_nnewrdn, &dummy, neip, - bdb->bi_dbenv, locker, &lock ); + rc = bdb_cache_modrdn( bdb, e, &op->orr_nnewrdn, &dummy, neip, + locker, &lock ); switch( rc ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: @@ -874,7 +874,7 @@ done: if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val ); free( mod ); } - slap_mods_free( mod ); + slap_mods_free( mod, 1 ); } /* LDAP v3 Support */ diff --git a/servers/slapd/back-bdb/operational.c b/servers/slapd/back-bdb/operational.c index 671a67dfff..5716f475af 100644 --- a/servers/slapd/back-bdb/operational.c +++ b/servers/slapd/back-bdb/operational.c @@ -36,7 +36,7 @@ bdb_hasSubordinates( { int rc; - assert( e ); + assert( e != NULL ); /* NOTE: this should never happen, but it actually happens * when using back-relay; until we find a better way to @@ -89,7 +89,7 @@ bdb_operational( { Attribute **ap; - assert( rs->sr_entry ); + assert( rs->sr_entry != NULL ); for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) /* just count */ ; @@ -102,7 +102,7 @@ bdb_operational( rc = bdb_hasSubordinates( op, rs->sr_entry, &hasSubordinates ); if ( rc == LDAP_SUCCESS ) { *ap = slap_operational_hasSubordinate( hasSubordinates == LDAP_COMPARE_TRUE ); - assert( *ap ); + assert( *ap != NULL ); ap = &(*ap)->a_next; } diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 7d3d49b7d3..5955721f4e 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -413,7 +413,7 @@ void bdb_cache_return_entry_rw( DB_ENV *env, Cache *cache, Entry *e, #if 0 void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw ); #else -#define bdb_unlocked_cache_return_entry_rw( a, b, c ) +#define bdb_unlocked_cache_return_entry_rw( a, b, c ) ((void)0) #endif #define bdb_unlocked_cache_return_entry_r( c, e ) \ bdb_unlocked_cache_return_entry_rw((c), (e), 0) @@ -445,11 +445,11 @@ int bdb_cache_add( u_int32_t locker ); int bdb_cache_modrdn( + struct bdb_info *bdb, Entry *e, struct berval *nrdn, Entry *new, EntryInfo *ein, - DB_ENV *env, u_int32_t locker, DB_LOCK *lock ); @@ -522,9 +522,9 @@ int bdb_cache_entry_db_unlock( #ifdef BDB_REUSE_LOCKERS #define bdb_locker_id BDB_SYMBOL(locker_id) -int bdb_locker_id( Operation *op, DB_ENV *env, int *locker ); +int bdb_locker_id( Operation *op, DB_ENV *env, u_int32_t *locker ); -#define LOCK_ID_FREE(env, locker) +#define LOCK_ID_FREE(env, locker) ((void)0) #define LOCK_ID(env, locker) bdb_locker_id(op, env, locker) #else diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index ebb8901d74..819e3c5196 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -314,7 +314,9 @@ bdb_search( Operation *op, SlapReply *rs ) Entry *matched = NULL; EntryInfo *ei, ei_root = {0}; struct berval realbase = BER_BVNULL; +#ifdef SLAP_ACL_HONOR_DISCLOSE slap_mask_t mask; +#endif int manageDSAit; int tentries = 0; ID lastid = NOID; @@ -954,7 +956,7 @@ static int oc_filter( { int rc = 0; - assert( f ); + assert( f != NULL ); if( cur > *max ) *max = cur; diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index c64176b963..bafba3549e 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -140,7 +140,8 @@ ID bdb_tool_dn2id_get( { Operation op = {0}; Opheader ohdr = {0}; - EntryInfo ei = {0}; + EntryInfo *ei = NULL; + int rc; if ( BER_BVISEMPTY(dn) ) return 0; @@ -150,11 +151,12 @@ ID bdb_tool_dn2id_get( op.o_tmpmemctx = NULL; op.o_tmpmfuncs = &ch_mfuncs; - ei.bei_id = NOID; - - bdb_dn2id( &op, NULL, dn, &ei ); + rc = bdb_cache_find_ndn( &op, NULL, dn, &ei ); + if ( ei ) bdb_cache_entryinfo_unlock( ei ); + if ( rc == DB_NOTFOUND ) + return NOID; - return ei.bei_id; + return ei->bei_id; } int bdb_tool_id2entry_get( @@ -183,7 +185,9 @@ Entry* bdb_tool_entry_get( BackendDB *be, ID id ) { int rc; Entry *e = NULL; +#ifndef BDB_HIER struct berval bv; +#endif assert( be != NULL ); assert( slapMode & SLAP_TOOL_MODE ); @@ -327,8 +331,8 @@ ID bdb_tool_entry_put( assert( be != NULL ); assert( slapMode & SLAP_TOOL_MODE ); - assert( text ); - assert( text->bv_val ); + assert( text != NULL ); + assert( text->bv_val != NULL ); assert( text->bv_val[0] == '\0' ); /* overconservative? */ Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_tool_entry_put) @@ -524,8 +528,8 @@ ID bdb_tool_entry_modify( assert( be != NULL ); assert( slapMode & SLAP_TOOL_MODE ); - assert( text ); - assert( text->bv_val ); + assert( text != NULL ); + assert( text->bv_val != NULL ); assert( text->bv_val[0] == '\0' ); /* overconservative? */ assert ( e->e_id != NOID ); diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h index d33ea3c183..7a62b1dff2 100644 --- a/servers/slapd/back-ldap/back-ldap.h +++ b/servers/slapd/back-ldap/back-ldap.h @@ -38,7 +38,6 @@ struct ldapconn { struct berval lc_local_ndn; int lc_bound; int lc_ispriv; - ldap_pvt_thread_mutex_t lc_mutex; unsigned lc_refcnt; }; diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 9834bd1fe0..d9e395d3ed 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -92,9 +92,8 @@ ldap_back_bind( Operation *op, SlapReply *rs ) if ( !BER_BVISNULL( &lc->lc_cred ) ) { memset( lc->lc_cred.bv_val, 0, lc->lc_cred.bv_len ); - ch_free( lc->lc_cred.bv_val ); } - ber_dupbv( &lc->lc_cred, &op->orb_cred ); + ber_bvreplace( &lc->lc_cred, &op->orb_cred ); ldap_set_rebind_proc( lc->lc_ld, ldap_back_rebind, lc ); } } @@ -126,15 +125,12 @@ retry_lock:; ldap_back_conn_cmp ); assert( lc != NULL ); - if ( !BER_BVISNULL( &lc->lc_local_ndn ) ) { - ch_free( lc->lc_local_ndn.bv_val ); - } - ber_dupbv( &lc->lc_local_ndn, &op->o_req_ndn ); + ber_bvreplace( &lc->lc_local_ndn, &op->o_req_ndn ); lerr = avl_insert( &li->conntree, (caddr_t)lc, ldap_back_conn_cmp, ldap_back_conn_dup ); ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); if ( lerr == -1 ) { - /* handle this! (e.g. wait until refcnt goes to 1...) */ + /* we can do this because lc_refcnt == 1 */ ldap_back_conn_free( lc ); lc = NULL; } @@ -238,18 +234,8 @@ int ldap_back_freeconn( Operation *op, struct ldapconn *lc ) { struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private; - int rc = 0; -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &li->conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); assert( lc->lc_refcnt > 0 ); if ( --lc->lc_refcnt == 0 ) { @@ -259,9 +245,10 @@ retry_lock:; ldap_back_conn_free( (void *)lc ); } + ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); - return rc; + return 0; } static int @@ -371,7 +358,7 @@ retry:; if ( rs->sr_err == LDAP_SERVER_DOWN || ( rs->sr_err != LDAP_SUCCESS && LDAP_BACK_TLS_CRITICAL( li ) ) ) { - ldap_unbind_ext_s( ld, NULL, NULL ); + ldap_unbind_ext( ld, NULL, NULL ); goto error_return; } @@ -381,8 +368,7 @@ retry:; #endif /* HAVE_TLS */ if ( *lcp == NULL ) { - *lcp = (struct ldapconn *)ch_malloc( sizeof( struct ldapconn ) ); - memset( *lcp, 0, sizeof( struct ldapconn ) ); + *lcp = (struct ldapconn *)ch_calloc( 1, sizeof( struct ldapconn ) ); } (*lcp)->lc_ld = ld; (*lcp)->lc_refcnt = 1; @@ -406,7 +392,9 @@ struct ldapconn * ldap_back_getconn( Operation *op, SlapReply *rs, ldap_back_send_t sendok ) { struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private; - struct ldapconn *lc, lc_curr = { 0 }; + struct ldapconn *lc, + lc_curr = { 0 }; + int refcnt = 1; /* Searches for a ldapconn in the avl tree */ @@ -423,6 +411,7 @@ ldap_back_getconn( Operation *op, SlapReply *rs, ldap_back_send_t sendok ) } /* Internal searches are privileged and shared. So is root. */ + /* FIXME: there seem to be concurrency issues */ if ( op->o_do_not_cache || be_isroot( op ) ) { lc_curr.lc_local_ndn = op->o_bd->be_rootndn; lc_curr.lc_conn = NULL; @@ -432,27 +421,17 @@ ldap_back_getconn( Operation *op, SlapReply *rs, ldap_back_send_t sendok ) lc_curr.lc_local_ndn = op->o_ndn; } -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &li->conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); lc = (struct ldapconn *)avl_find( li->conntree, (caddr_t)&lc_curr, ldap_back_conn_cmp ); if ( lc != NULL ) { - lc->lc_refcnt++; + refcnt = ++lc->lc_refcnt; } ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); /* Looks like we didn't get a bind. Open a new session... */ if ( lc == NULL ) { - /* lc here must be NULL */ if ( ldap_back_prepare_conn( &lc, op, rs, sendok ) != LDAP_SUCCESS ) { return NULL; } @@ -460,8 +439,6 @@ retry_lock:; lc->lc_conn = lc_curr.lc_conn; ber_dupbv( &lc->lc_local_ndn, &lc_curr.lc_local_ndn ); - ldap_pvt_thread_mutex_init( &lc->lc_mutex ); - if ( lc_curr.lc_ispriv ) { ber_dupbv( &lc->lc_cred, &li->acl_passwd ); ber_dupbv( &lc->lc_bound_ndn, &li->acl_authcDN ); @@ -471,7 +448,7 @@ retry_lock:; BER_BVZERO( &lc->lc_cred ); BER_BVZERO( &lc->lc_bound_ndn ); if ( op->o_conn && !BER_BVISEMPTY( &op->o_ndn ) - && op->o_bd == op->o_conn->c_authz_backend ) + && op->o_bd->be_private == op->o_conn->c_authz_backend->be_private ) { ber_dupbv( &lc->lc_bound_ndn, &op->o_ndn ); } @@ -480,16 +457,7 @@ retry_lock:; lc->lc_bound = 0; /* Inserts the newly created ldapconn in the avl tree */ -retry_lock2:; - switch ( ldap_pvt_thread_mutex_trylock( &li->conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock2; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); assert( lc->lc_refcnt == 1 ); rs->sr_err = avl_insert( &li->conntree, (caddr_t)lc, @@ -503,7 +471,7 @@ retry_lock2:; Debug( LDAP_DEBUG_TRACE, "=>ldap_back_getconn: conn %p inserted (refcnt=%u)\n", - (void *)lc, lc->lc_refcnt, 0 ); + (void *)lc, refcnt, 0 ); /* Err could be -1 in case a duplicate ldapconn is inserted */ if ( rs->sr_err != 0 ) { @@ -519,7 +487,7 @@ retry_lock2:; } else { Debug( LDAP_DEBUG_TRACE, "=>ldap_back_getconn: conn %p fetched (refcnt=%u)\n", - (void *)lc, lc->lc_refcnt, 0 ); + (void *)lc, refcnt, 0 ); } return lc; @@ -533,17 +501,7 @@ ldap_back_release_conn( { struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private; -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &li->conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } - + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); assert( lc->lc_refcnt > 0 ); lc->lc_refcnt--; ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); @@ -555,6 +513,8 @@ retry_lock:; * Note: as the check for the value of lc->lc_bound was already here, I removed * it from all the callers, and I made the function return the flag, so * it can be used to simplify the check. + * + * Note: dolock indicates whether li->conn_mutex must be locked or not */ static int ldap_back_dobind_int( @@ -658,21 +618,12 @@ retry:; if ( rs->sr_err == LDAP_SERVER_DOWN ) { if ( retries > 0 ) { if ( dolock ) { -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &li->conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); } assert( lc->lc_refcnt > 0 ); if ( lc->lc_refcnt == 1 ) { - ldap_unbind_ext_s( lc->lc_ld, NULL, NULL ); + ldap_unbind_ext( lc->lc_ld, NULL, NULL ); lc->lc_ld = NULL; /* lc here must be the regular lc, reset and ready for init */ @@ -707,13 +658,7 @@ done:; int ldap_back_dobind( struct ldapconn *lc, Operation *op, SlapReply *rs, ldap_back_send_t sendok ) { - int rc; - - ldap_pvt_thread_mutex_lock( &lc->lc_mutex ); - rc = ldap_back_dobind_int( lc, op, rs, sendok, 1, 1 ); - ldap_pvt_thread_mutex_unlock( &lc->lc_mutex ); - - return rc; + return ldap_back_dobind_int( lc, op, rs, sendok, 1, 1 ); } /* @@ -829,20 +774,10 @@ ldap_back_retry( struct ldapconn *lc, Operation *op, SlapReply *rs, ldap_back_se int rc = 0; struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private; -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &li->conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); if ( lc->lc_refcnt == 1 ) { - ldap_pvt_thread_mutex_lock( &lc->lc_mutex ); - ldap_unbind_ext_s( lc->lc_ld, NULL, NULL ); + ldap_unbind_ext( lc->lc_ld, NULL, NULL ); lc->lc_ld = NULL; lc->lc_bound = 0; @@ -851,7 +786,6 @@ retry_lock:; if ( rc == LDAP_SUCCESS ) { rc = ldap_back_dobind_int( lc, op, rs, sendok, 0, 0 ); } - ldap_pvt_thread_mutex_unlock( &lc->lc_mutex ); } ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); @@ -1090,8 +1024,12 @@ ldap_back_proxy_authz_ctrl( rs->sr_err = LDAP_SUCCESS; + /* FIXME: SASL/EXTERNAL over ldapi:// doesn't honor the authcID, + * but if it is not set this test fails. We need a different + * means to detect if idassert is enabled */ if ( ( BER_BVISNULL( &li->idassert_authcID ) || BER_BVISEMPTY( &li->idassert_authcID ) ) - && ( BER_BVISNULL( &li->idassert_authcDN ) || BER_BVISEMPTY( &li->idassert_authcDN ) ) ) { + && ( BER_BVISNULL( &li->idassert_authcDN ) || BER_BVISEMPTY( &li->idassert_authcDN ) ) ) + { goto done; } @@ -1153,7 +1091,8 @@ ldap_back_proxy_authz_ctrl( rc = slap_sasl_matches( op, li->idassert_authz, &authcDN, & authcDN ); if ( rc != LDAP_SUCCESS ) { - if ( li->idassert_flags & LDAP_BACK_AUTH_PRESCRIPTIVE ) { + if ( li->idassert_flags & LDAP_BACK_AUTH_PRESCRIPTIVE ) + { /* op->o_conn->c_ndn is not authorized * to use idassert */ return rc; @@ -1249,7 +1188,7 @@ ldap_back_proxy_authz_ctrl( ctrls[ 0 ]->ldctl_value.bv_len = assertedID.bv_len + STRLENOF( "dn:" ); ctrls[ 0 ]->ldctl_value.bv_val = ch_malloc( ctrls[ 0 ]->ldctl_value.bv_len + 1 ); AC_MEMCPY( ctrls[ 0 ]->ldctl_value.bv_val, "dn:", STRLENOF( "dn:" ) ); - AC_MEMCPY( ctrls[ 0 ]->ldctl_value.bv_val + STRLENOF( "dn:" ), + AC_MEMCPY( &ctrls[ 0 ]->ldctl_value.bv_val[ STRLENOF( "dn:" ) ], assertedID.bv_val, assertedID.bv_len + 1 ); break; } @@ -1280,7 +1219,7 @@ ldap_back_proxy_authz_ctrl_free( Operation *op, LDAPControl ***pctrls ) * added by back-ldap, so it's the only one we explicitly * free */ if ( ctrls && ctrls != op->o_ctrls ) { - assert( ctrls[ 0 ] ); + assert( ctrls[ 0 ] != NULL ); if ( !BER_BVISNULL( &ctrls[ 0 ]->ldctl_value ) ) { free( ctrls[ 0 ]->ldctl_value.bv_val ); diff --git a/servers/slapd/back-ldap/chain.c b/servers/slapd/back-ldap/chain.c index 8b79f2ac50..2cba84c833 100644 --- a/servers/slapd/back-ldap/chain.c +++ b/servers/slapd/back-ldap/chain.c @@ -132,8 +132,8 @@ chaining_control_remove( * added by the chain overlay, so it's the only one we explicitly * free */ if ( op->o_ctrls != oldctrls ) { - assert( op->o_ctrls ); - assert( op->o_ctrls[ 0 ] ); + assert( op->o_ctrls != NULL ); + assert( op->o_ctrls[ 0 ] != NULL ); free( op->o_ctrls ); @@ -441,43 +441,10 @@ ldap_chain_response( Operation *op, SlapReply *rs ) } break; case LDAP_REQ_ADD: - { - int cleanup_attrs = 0; - - if ( op->ora_e->e_attrs == NULL ) { - char textbuf[ SLAP_TEXT_BUFLEN ]; - size_t textlen = sizeof( textbuf ); - -#if 0 - /* FIXME: op->o_bd is still set to the BackendDB - * structure of the database that tried to handle - * the operation and actually returned a referral - * ... */ - assert( SLAP_DBFLAGS( op->o_bd ) & SLAP_DBFLAG_GLOBAL_OVERLAY ); -#endif - - /* global overlay: create entry */ - /* NOTE: this is a hack to use the chain overlay - * as global. I expect to be able to remove this - * soon by using slap_mods2entry() earlier in - * do_add(), adding the operational attrs later - * if required. */ - rs->sr_err = slap_mods2entry( op->ora_modlist, - &op->ora_e, 0, 1, - &rs->sr_text, textbuf, textlen ); - if ( rs->sr_err != LDAP_SUCCESS ) { - send_ldap_result( op, rs ); - rc = 1; - break; - } - } + /* slap_mods2entry () should be called in do_add() */ + assert( op->ora_e->e_attrs != NULL ); rc = ldap_chain_op( op, rs, lback->bi_op_add, ref ); - if ( cleanup_attrs ) { - attrs_free( op->ora_e->e_attrs ); - op->ora_e->e_attrs = NULL; - } break; - } case LDAP_REQ_DELETE: rc = ldap_chain_op( op, rs, lback->bi_op_delete, ref ); break; @@ -679,9 +646,11 @@ enum { PC_CHAINING = 1 }; +#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR static ConfigDriver chain_cf_gen; -static ConfigLDAPadd chain_ldadd; static ConfigCfAdd chain_cfadd; +#endif +static ConfigLDAPadd chain_ldadd; static ConfigTable chaincfg[] = { #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR @@ -719,6 +688,8 @@ chain_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca ) return LDAP_SUCCESS; } +#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR + static int chain_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *ca ) { @@ -742,7 +713,6 @@ chain_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *ca ) return 0; } -#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR static slap_verbmasks chaining_mode[] = { { BER_BVC("referralsRequired"), LDAP_REFERRALS_REQUIRED }, { BER_BVC("referralsPreferred"), LDAP_REFERRALS_PREFERRED }, @@ -750,13 +720,14 @@ static slap_verbmasks chaining_mode[] = { { BER_BVC("chainingPreferred"), LDAP_CHAINING_PREFERRED }, { BER_BVNULL, 0 } }; -#endif static int chain_cf_gen( ConfigArgs *c ) { slap_overinst *on = (slap_overinst *)c->bi; +#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR ldap_chain_t *lc = (ldap_chain_t *)on->on_bi.bi_private; +#endif int rc = 0; @@ -935,6 +906,8 @@ chain_cf_gen( ConfigArgs *c ) return rc; } +#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */ + static int ldap_chain_db_config( BackendDB *be, diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index 16e1cd0a5c..7a8af5776a 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -72,7 +72,7 @@ static ConfigTable ldapcfg[] = { "SINGLE-VALUE )", NULL, NULL }, { "tls", "what", 2, 2, 0, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_TLS, + ARG_MAGIC|LDAP_BACK_CFG_TLS, ldap_back_cf_gen, "( OLcfgDbAt:3.1 " "NAME 'olcDbStartTLS' " "DESC 'StartTLS' " @@ -88,12 +88,12 @@ static ConfigTable ldapcfg[] = { "SYNTAX OMsDN " "SINGLE-VALUE )", NULL, NULL }, - /* deprecated; aliases "acl-authcDN" */ + /* deprecated, will be removed; aliases "acl-authcDN" */ { "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, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_ACL_PASSWD, + ARG_MAGIC|LDAP_BACK_CFG_ACL_PASSWD, ldap_back_cf_gen, "( OLcfgDbAt:3.3 " "NAME 'olcDbACLPasswd' " "DESC 'Remote ACL administrative identity credentials' " @@ -101,22 +101,22 @@ static ConfigTable ldapcfg[] = { "SYNTAX OMsDirectoryString " "SINGLE-VALUE )", NULL, NULL }, - /* deprecated; aliases "acl-passwd" */ + /* deprecated, will be removed; aliases "acl-passwd" */ { "bindpw", "cred", 2, 2, 0, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_ACL_PASSWD, + ARG_MAGIC|LDAP_BACK_CFG_ACL_PASSWD, + ldap_back_cf_gen, NULL, NULL, NULL }, + /* deprecated, will be removed; aliases "acl-bind" */ + { "acl-method", "args", 2, 0, 0, + ARG_MAGIC|LDAP_BACK_CFG_ACL_METHOD, ldap_back_cf_gen, NULL, NULL, NULL }, { "acl-bind", "args", 2, 0, 0, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_ACL_BIND, + ARG_MAGIC|LDAP_BACK_CFG_ACL_BIND, ldap_back_cf_gen, "( OLcfgDbAt:3.4 " "NAME 'olcDbACLBind' " "DESC 'Remote ACL administrative identity auth bind configuration' " "SYNTAX OMsDirectoryString " "SINGLE-VALUE )", NULL, NULL }, - /* deprecated; aliases "acl-bind" */ - { "acl-method", "args", 2, 0, 0, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_ACL_BIND, - ldap_back_cf_gen, NULL, NULL, NULL }, { "idassert-authcDN", "DN", 2, 2, 0, ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_AUTHCDN, ldap_back_cf_gen, "( OLcfgDbAt:3.5 " @@ -126,12 +126,12 @@ static ConfigTable ldapcfg[] = { "SYNTAX OMsDN " "SINGLE-VALUE )", NULL, NULL }, - /* deprecated; partially aliases "idassert-authcDN" */ + /* deprecated, will be removed; partially aliases "idassert-authcDN" */ { "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, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_PASSWD, + ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_PASSWD, ldap_back_cf_gen, "( OLcfgDbAt:3.6 " "NAME 'olcDbIDAssertPasswd' " "DESC 'Remote Identity Assertion administrative identity credentials' " @@ -139,12 +139,12 @@ static ConfigTable ldapcfg[] = { "SYNTAX OMsDirectoryString " "SINGLE-VALUE )", NULL, NULL }, - /* deprecated; partially aliases "idassert-passwd" */ + /* deprecated, will be removed; partially aliases "idassert-passwd" */ { "proxyauthzpw", "cred", 2, 2, 0, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_PASSWD, + ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_PASSWD, ldap_back_cf_gen, NULL, NULL, NULL }, { "idassert-bind", "args", 2, 0, 0, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_BIND, + ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_BIND, ldap_back_cf_gen, "( OLcfgDbAt:3.7 " "NAME 'olcDbIDAssertBind' " "DESC 'Remote Identity Assertion administrative identity auth bind configuration' " @@ -152,7 +152,7 @@ static ConfigTable ldapcfg[] = { "SINGLE-VALUE )", NULL, NULL }, { "idassert-method", "args", 2, 0, 0, - ARG_BERVAL|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_BIND, + ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_METHOD, ldap_back_cf_gen, NULL, NULL, NULL }, { "idassert-mode", "mode>|u:|[dn:]value_bv, &bv ); + value_add_one( &c->rvalue_vals, &bv ); } break; @@ -315,17 +315,18 @@ ldap_back_cf_gen( ConfigArgs *c ) case LDAP_BACK_CFG_ACL_BIND: { int i; - bindconf_unparse( &li->acl_sb, &c->value_bv ); + bindconf_unparse( &li->acl_sb, &bv ); - for ( i = 0; isspace( c->value_bv.bv_val[ i ] ); i++ ) + for ( i = 0; isspace( bv.bv_val[ i ] ); i++ ) /* count spaces */ ; if ( i ) { - c->value_bv.bv_len -= i; - AC_MEMCPY( c->value_bv.bv_val, &c->value_bv.bv_val[ i ], - c->value_bv.bv_len + 1 ); + bv.bv_len -= i; + AC_MEMCPY( bv.bv_val, &bv.bv_val[ i ], + bv.bv_len + 1 ); } - + + ber_bvarray_add( &c->rvalue_vals, &bv ); break; } @@ -347,23 +348,18 @@ ldap_back_cf_gen( ConfigArgs *c ) for ( i = 0; !BER_BVISNULL( &li->idassert_authz[ i ] ); i++ ) { - struct berval bv; - - ber_dupbv( &bv, &li->idassert_authz[ i ] ); - ber_bvarray_add( &c->rvalue_vals, &bv ); + value_add_one( &c->rvalue_vals, &li->idassert_authz[ i ] ); } break; } case LDAP_BACK_CFG_IDASSERT_BIND: { int i; - struct berval bv = BER_BVNULL, - bc = BER_BVNULL; + struct berval bc = BER_BVNULL; char *ptr; if ( li->idassert_authmethod != LDAP_AUTH_NONE ) { - ber_len_t len = bv.bv_len - + STRLENOF( "flags=override,non-prescriptive" ); + ber_len_t len; switch ( li->idassert_mode ) { case LDAP_BACK_IDASSERT_OTHERID: @@ -391,7 +387,7 @@ ldap_back_cf_gen( ConfigArgs *c ) } if ( li->idassert_flags & LDAP_BACK_AUTH_NATIVE_AUTHZ ) { - ber_len_t len = bv.bv_len + STRLENOF( "authz=native" ); + len = bv.bv_len + STRLENOF( "authz=native" ); if ( !BER_BVISEMPTY( &bv ) ) { len += STRLENOF( " " ); @@ -399,7 +395,7 @@ ldap_back_cf_gen( ConfigArgs *c ) bv.bv_val = ch_realloc( bv.bv_val, len + 1 ); - ptr = bv.bv_val + bv.bv_len; + ptr = &bv.bv_val[ bv.bv_len ]; if ( !BER_BVISEMPTY( &bv ) ) { ptr = lutil_strcopy( ptr, " " ); @@ -408,6 +404,7 @@ ldap_back_cf_gen( ConfigArgs *c ) (void)lutil_strcopy( ptr, "authz=native" ); } + len = bv.bv_len + STRLENOF( "flags=non-prescriptive,override" ); /* flags */ if ( !BER_BVISEMPTY( &bv ) ) { len += STRLENOF( " " ); @@ -440,17 +437,15 @@ ldap_back_cf_gen( ConfigArgs *c ) bindconf_unparse( &li->idassert_sb, &bc ); if ( !BER_BVISNULL( &bv ) ) { - char *ptr; + ber_len_t len = bv.bv_len + bc.bv_len; - c->value_bv.bv_len = bv.bv_len + bc.bv_len; - c->value_bv.bv_val = ch_realloc( bv.bv_val, c->value_bv.bv_len + 1 ); + bv.bv_val = ch_realloc( bv.bv_val, len + 1 ); assert( bc.bv_val[ 0 ] == ' ' ); - ptr = lutil_strcopy( c->value_bv.bv_val, bv.bv_val ); - (void)lutil_strcopy( ptr, bc.bv_val ); - + ptr = lutil_strcopy( &bv.bv_val[ bv.bv_len ], bc.bv_val ); free( bc.bv_val ); + bv.bv_len = ptr - bv.bv_val; } else { for ( i = 0; isspace( bc.bv_val[ i ] ); i++ ) @@ -461,9 +456,11 @@ ldap_back_cf_gen( ConfigArgs *c ) AC_MEMCPY( bc.bv_val, &bc.bv_val[ i ], bc.bv_len + 1 ); } - c->value_bv = bv; + bv = bc; } + ber_bvarray_add( &c->rvalue_vals, &bv ); + break; } @@ -475,7 +472,7 @@ ldap_back_cf_gen( ConfigArgs *c ) rc = 1; } else { - ber_dupbv( &c->value_bv, &bv ); + value_add_one( &c->rvalue_vals, &bv ); } break; @@ -487,7 +484,7 @@ ldap_back_cf_gen( ConfigArgs *c ) rc = 1; } else { - ber_dupbv( &c->value_bv, &bv ); + value_add_one( &c->rvalue_vals, &bv ); } break; @@ -499,7 +496,7 @@ ldap_back_cf_gen( ConfigArgs *c ) rc = 1; } else { - ber_dupbv( &c->value_bv, &bv ); + value_add_one( &c->rvalue_vals, &bv ); } break; @@ -511,12 +508,12 @@ ldap_back_cf_gen( ConfigArgs *c ) rc = 1; } else { - ber_dupbv( &c->value_bv, &bv ); + value_add_one( &c->rvalue_vals, &bv ); } break; default: - /* we need to handle all... */ + /* FIXME: we need to handle all... */ assert( 0 ); break; } @@ -545,6 +542,9 @@ ldap_back_cf_gen( ConfigArgs *c ) break; case LDAP_BACK_CFG_TLS: + rc = 1; + break; + case LDAP_BACK_CFG_ACL_AUTHCDN: case LDAP_BACK_CFG_ACL_PASSWD: case LDAP_BACK_CFG_ACL_METHOD: @@ -583,7 +583,7 @@ ldap_back_cf_gen( ConfigArgs *c ) break; default: - /* we need to handle all... */ + /* FIXME: we need to handle all... */ assert( 0 ); break; } @@ -594,7 +594,9 @@ ldap_back_cf_gen( ConfigArgs *c ) switch( c->type ) { case LDAP_BACK_CFG_URI: { LDAPURLDesc *tmpludp; +#if 0 char **urllist; +#endif int urlrc, i; if ( c->argc != 2 ) { @@ -688,7 +690,7 @@ ldap_back_cf_gen( ConfigArgs *c ) tmpludp; i++, tmpludp = tmpludp->lud_next ) /* just count */ - + ; urllist = ch_calloc( sizeof( char * ), i + 1 ); for ( i = 0, tmpludp = li->lud; @@ -722,7 +724,8 @@ ldap_back_cf_gen( ConfigArgs *c ) li->url = ldap_charray2str( urllist, " " ); ldap_charray_free( urllist ); #else - li->url = ch_strdup( c->value_string ); + li->url = c->value_string; + c->value_string = NULL; #endif break; } @@ -755,7 +758,10 @@ ldap_back_cf_gen( ConfigArgs *c ) if ( !BER_BVISNULL( &li->acl_authcDN ) ) { free( li->acl_authcDN.bv_val ); } + ber_memfree_x( c->value_dn.bv_val, NULL ); li->acl_authcDN = c->value_ndn; + BER_BVZERO( &c->value_dn ); + BER_BVZERO( &c->value_ndn ); break; case LDAP_BACK_CFG_ACL_PASSWD: @@ -777,7 +783,7 @@ ldap_back_cf_gen( ConfigArgs *c ) if ( !BER_BVISNULL( &li->acl_passwd ) ) { free( li->acl_passwd.bv_val ); } - li->acl_passwd = c->value_bv; + ber_str2bv( c->argv[ 1 ], 0, 1, &li->acl_passwd ); break; case LDAP_BACK_CFG_ACL_METHOD: @@ -872,7 +878,10 @@ ldap_back_cf_gen( ConfigArgs *c ) if ( !BER_BVISNULL( &li->idassert_authcDN ) ) { free( li->idassert_authcDN.bv_val ); } + ber_memfree_x( c->value_dn.bv_val, NULL ); li->idassert_authcDN = c->value_ndn; + BER_BVZERO( &c->value_dn ); + BER_BVZERO( &c->value_ndn ); break; case LDAP_BACK_CFG_IDASSERT_PASSWD: @@ -894,12 +903,15 @@ ldap_back_cf_gen( ConfigArgs *c ) if ( !BER_BVISNULL( &li->idassert_passwd ) ) { free( li->idassert_passwd.bv_val ); } - li->idassert_passwd = c->value_bv; + ber_str2bv( c->argv[ 1 ], 0, 1, &li->idassert_passwd ); break; - case LDAP_BACK_CFG_IDASSERT_AUTHZFROM: - ber_bvarray_add( &li->idassert_authz, &c->value_bv ); - break; + case LDAP_BACK_CFG_IDASSERT_AUTHZFROM: { + struct berval bv; + + ber_str2bv( c->argv[ 1 ], 0, 1, &bv ); + ber_bvarray_add( &li->idassert_authz, &bv ); + } break; case LDAP_BACK_CFG_IDASSERT_METHOD: /* no longer supported */ @@ -1091,7 +1103,9 @@ ldap_back_cf_gen( ConfigArgs *c ) return 1; default: + /* FIXME: try to catch inconsistencies */ assert( 0 ); + break; } return 0; @@ -1175,7 +1189,9 @@ ldap_back_db_config( /* URI of server to query (obsoletes "server" directive) */ } else if ( strcasecmp( argv[0], "uri" ) == 0 ) { LDAPURLDesc *tmpludp; +#if 0 char **urllist; +#endif int urlrc, i; if ( argc != 2 ) { @@ -1267,7 +1283,7 @@ ldap_back_db_config( tmpludp; i++, tmpludp = tmpludp->lud_next ) /* just count */ - + ; urllist = ch_calloc( sizeof( char * ), i + 1 ); for ( i = 0, tmpludp = li->lud; @@ -1605,10 +1621,10 @@ retry: /* else just do the same as before */ bv = (struct berval *) ch_malloc( sizeof(struct berval) ); if ( !BER_BVISEMPTY( &op->o_dn ) ) { - bv->bv_len = op->o_dn.bv_len + sizeof("dn:") - 1; + bv->bv_len = op->o_dn.bv_len + STRLENOF("dn:"); bv->bv_val = ch_malloc( bv->bv_len + 1 ); - AC_MEMCPY( bv->bv_val, "dn:", sizeof("dn:") - 1 ); - AC_MEMCPY( &bv->bv_val[sizeof("dn:") - 1], op->o_dn.bv_val, + AC_MEMCPY( bv->bv_val, "dn:", STRLENOF("dn:") ); + AC_MEMCPY( &bv->bv_val[STRLENOF("dn:")], op->o_dn.bv_val, op->o_dn.bv_len ); bv->bv_val[bv->bv_len] = '\0'; } else { diff --git a/servers/slapd/back-ldap/delete.c b/servers/slapd/back-ldap/delete.c index 08c970388e..4c615b5e48 100644 --- a/servers/slapd/back-ldap/delete.c +++ b/servers/slapd/back-ldap/delete.c @@ -45,14 +45,14 @@ ldap_back_delete( lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR ); if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) { - return -1; + return rs->sr_err; } ctrls = op->o_ctrls; rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls ); if ( rc != LDAP_SUCCESS ) { send_ldap_result( op, rs ); - rc = -1; + rc = rs->sr_err; goto cleanup; } diff --git a/servers/slapd/back-ldap/init.c b/servers/slapd/back-ldap/init.c index 49837a167f..f250f6d0d9 100644 --- a/servers/slapd/back-ldap/init.c +++ b/servers/slapd/back-ldap/init.c @@ -204,7 +204,7 @@ ldap_back_conn_free( void *v_lc ) struct ldapconn *lc = v_lc; if ( lc->lc_ld != NULL ) { - ldap_unbind_ext_s( lc->lc_ld, NULL, NULL ); + ldap_unbind_ext( lc->lc_ld, NULL, NULL ); } if ( !BER_BVISNULL( &lc->lc_bound_ndn ) ) { ch_free( lc->lc_bound_ndn.bv_val ); @@ -216,7 +216,6 @@ ldap_back_conn_free( void *v_lc ) if ( !BER_BVISNULL( &lc->lc_local_ndn ) ) { ch_free( lc->lc_local_ndn.bv_val ); } - ldap_pvt_thread_mutex_destroy( &lc->lc_mutex ); ch_free( lc ); } @@ -284,6 +283,10 @@ ldap_back_db_destroy( ch_free( li->idassert_sasl_realm.bv_val ); BER_BVZERO( &li->idassert_sasl_realm ); } + if ( li->idassert_authz != NULL ) { + ber_bvarray_free( li->idassert_authz ); + li->idassert_authz = NULL; + } if ( li->conntree ) { avl_free( li->conntree, ldap_back_conn_free ); } diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index 5acd9a1aae..6ba89953ea 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -48,7 +48,7 @@ ldap_back_modify( lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR ); if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) { - return -1; + return rs->sr_err; } for ( i = 0, ml = op->oq_modify.rs_modlist; ml; i++, ml = ml->sml_next ) diff --git a/servers/slapd/back-ldap/modrdn.c b/servers/slapd/back-ldap/modrdn.c index 437ba646e7..0890b26d19 100644 --- a/servers/slapd/back-ldap/modrdn.c +++ b/servers/slapd/back-ldap/modrdn.c @@ -45,7 +45,7 @@ ldap_back_modrdn( lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR ); if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) { - return -1; + return rs->sr_err; } if ( op->orr_newSup ) { diff --git a/servers/slapd/back-ldap/proto-ldap.h b/servers/slapd/back-ldap/proto-ldap.h index 5f29e710a3..1a812f3d87 100644 --- a/servers/slapd/back-ldap/proto-ldap.h +++ b/servers/slapd/back-ldap/proto-ldap.h @@ -58,6 +58,8 @@ int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs, ber_int_t msgid, ldap_back_send_t sendok); int back_ldap_LTX_init_module(int argc, char *argv[]); +int ldap_back_init_cf( BackendInfo *bi ); + extern int ldap_back_conn_cmp( const void *c1, const void *c2); extern int ldap_back_conn_dup( void *c1, void *c2 ); extern void ldap_back_conn_free( void *c ); diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 307e2dbfd6..85c334f9c9 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -152,7 +152,7 @@ ldap_back_search( filter = BER_BVNULL; int i; char **attrs = NULL; - int dontfreetext = 0; + int freetext = 0; int do_retry = 1; LDAPControl **ctrls = NULL; @@ -201,7 +201,6 @@ ldap_back_search( ctrls = op->o_ctrls; rc = ldap_back_proxy_authz_ctrl( lc, op, rs, &ctrls ); if ( rc != LDAP_SUCCESS ) { - dontfreetext = 1; goto finish; } @@ -255,6 +254,9 @@ fail:; { /* check for abandon */ if ( op->o_abandon ) { + if ( rc > 0 ) { + ldap_msgfree( res ); + } ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL ); rc = SLAPD_ABANDON; goto finish; @@ -308,7 +310,6 @@ fail:; } else if ( rc == LDAP_RES_SEARCH_REFERENCE ) { char **references = NULL; - int cnt; do_retry = 0; rc = ldap_parse_reference( lc->lc_ld, res, @@ -318,21 +319,31 @@ fail:; continue; } - if ( references == NULL ) { - continue; - } + /* FIXME: there MUST be at least one */ + if ( references && references[ 0 ] && references[ 0 ][ 0 ] ) { + int cnt; - for ( cnt = 0; references[ cnt ]; cnt++ ) - /* NO OP */ ; - - rs->sr_ref = ch_calloc( cnt + 1, sizeof( struct berval ) ); + for ( cnt = 0; references[ cnt ]; cnt++ ) + /* NO OP */ ; - for ( cnt = 0; references[ cnt ]; cnt++ ) { - ber_str2bv( references[ cnt ], 0, 0, &rs->sr_ref[ cnt ] ); - } + /* FIXME: there MUST be at least one */ + rs->sr_ref = ch_malloc( ( cnt + 1 ) * sizeof( struct berval ) ); + + for ( cnt = 0; references[ cnt ]; cnt++ ) { + ber_str2bv( references[ cnt ], 0, 0, &rs->sr_ref[ cnt ] ); + } + BER_BVZERO( &rs->sr_ref[ cnt ] ); + + /* ignore return value by now */ + ( void )send_search_reference( op, rs ); - /* ignore return value by now */ - ( void )send_search_reference( op, rs ); + } else { + Debug( LDAP_DEBUG_ANY, + "%s ldap_back_search: " + "got SEARCH_REFERENCE " + "with no referrals\n", + op->o_log_prefix, 0, 0 ); + } /* cleanup */ if ( references ) { @@ -352,27 +363,40 @@ fail:; rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err, &match.bv_val, (char **)&rs->sr_text, &references, &rs->sr_ctrls, 1 ); + freetext = 1; if ( rc != LDAP_SUCCESS ) { rs->sr_err = rc; } rs->sr_err = slap_map_api2result( rs ); - if ( references ) { + if ( references && references[ 0 ] && references[ 0 ][ 0 ] ) { int cnt; + if ( rs->sr_err != LDAP_REFERRAL ) { + /* FIXME: error */ + Debug( LDAP_DEBUG_ANY, + "%s ldap_back_search: " + "got referrals with %d\n", + op->o_log_prefix, + rs->sr_err, 0 ); + rs->sr_err = LDAP_REFERRAL; + } + for ( cnt = 0; references[ cnt ]; cnt++ ) /* NO OP */ ; - rs->sr_ref = ch_calloc( cnt + 1, sizeof( struct berval ) ); + rs->sr_ref = ch_malloc( ( cnt + 1 ) * sizeof( struct berval ) ); for ( cnt = 0; references[ cnt ]; cnt++ ) { + /* duplicating ...*/ ber_str2bv( references[ cnt ], 0, 1, &rs->sr_ref[ cnt ] ); } + BER_BVZERO( &rs->sr_ref[ cnt ] ); + } - /* cleanup */ - if ( references ) { - ldap_value_free( references ); - } + /* cleanup */ + if ( references ) { + ldap_value_free( references ); } rc = 0; @@ -397,6 +421,7 @@ fail:; if ( !BER_BVISNULL( &match ) && !BER_BVISEMPTY( &match ) ) { rs->sr_matched = match.bv_val; } + if ( rs->sr_v2ref ) { rs->sr_err = LDAP_REFERRAL; } @@ -423,7 +448,7 @@ finish:; } if ( rs->sr_text ) { - if ( !dontfreetext ) { + if ( freetext ) { LDAP_FREE( (char *)rs->sr_text ); } rs->sr_text = NULL; @@ -459,7 +484,7 @@ ldap_build_entry( int last; /* safe assumptions ... */ - assert( ent ); + assert( ent != NULL ); BER_BVZERO( &ent->e_bv ); if ( ber_scanf( &ber, "{m{", bdn ) == LBER_ERROR ) { diff --git a/servers/slapd/back-ldap/unbind.c b/servers/slapd/back-ldap/unbind.c index aa699342b6..180441a44d 100644 --- a/servers/slapd/back-ldap/unbind.c +++ b/servers/slapd/back-ldap/unbind.c @@ -48,17 +48,7 @@ ldap_back_conn_destroy( lc_curr.lc_conn = conn; lc_curr.lc_local_ndn = conn->c_ndn; -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &li->conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } - + ldap_pvt_thread_mutex_trylock( &li->conn_mutex ); lc = avl_delete( &li->conntree, (caddr_t)&lc_curr, ldap_back_conn_cmp ); ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 39b03af185..413d292508 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -45,7 +45,7 @@ ldbm_back_add( Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", op->o_req_dn.bv_val, 0, 0); - rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e, NULL, + rs->sr_err = entry_schema_check( op, op->oq_add.rs_e, NULL, get_manageDIT(op), &rs->sr_text, textbuf, textlen ); if ( rs->sr_err != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-ldbm/alias.c b/servers/slapd/back-ldbm/alias.c index e31a33b6cb..ae2c11bdf4 100644 --- a/servers/slapd/back-ldbm/alias.c +++ b/servers/slapd/back-ldbm/alias.c @@ -228,7 +228,7 @@ static int dnlist_subordinate( BerVarray dnlist, struct berval *dn ) { - assert( dnlist ); + assert( dnlist != NULL ); for( ; dnlist->bv_val != NULL; dnlist++ ) { if( dnIsSuffix( dnlist, dn ) ) { diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index 4cc80c455b..e98cfdce80 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -75,8 +75,8 @@ cache_entry_private_init( Entry*e ) void cache_entry_commit( Entry *e ) { - assert( e ); - assert( e->e_private ); + assert( e != NULL ); + assert( e->e_private != NULL ); assert( LEI(e)->lei_state == CACHE_ENTRY_CREATING ); /* assert( LEI(e)->lei_refcnt == 1 ); */ @@ -86,7 +86,7 @@ cache_entry_commit( Entry *e ) static int cache_entry_private_destroy( Entry*e ) { - assert( e->e_private ); + assert( e->e_private != NULL ); free( e->e_private ); e->e_private = NULL; @@ -106,7 +106,7 @@ cache_return_entry_rw( Cache *cache, Entry *e, int rw ) /* set cache mutex */ ldap_pvt_thread_mutex_lock( &cache->c_mutex ); - assert( e->e_private ); + assert( e->e_private != NULL ); id = e->e_id; refcnt = --LEI(e)->lei_refcnt; @@ -326,7 +326,7 @@ cache_update_entry( /* set cache mutex */ ldap_pvt_thread_mutex_lock( &cache->c_mutex ); - assert( e->e_private ); + assert( e->e_private != NULL ); if ( avl_insert( &cache->c_dntree, (caddr_t) e, entry_dn_cmp, avl_dup_error ) != 0 ) @@ -437,7 +437,7 @@ try_again: * we do not need to lock the entry if we only * check the state, refcnt, LRU, and id. */ - assert( ep->e_private ); + assert( ep->e_private != NULL ); /* save id */ id = ep->e_id; @@ -509,7 +509,7 @@ try_again: count++; - assert( ep->e_private ); + assert( ep->e_private != NULL ); ep_id = ep->e_id; state = LEI(ep)->lei_state; @@ -575,7 +575,7 @@ cache_delete_entry( /* set cache mutex */ ldap_pvt_thread_mutex_lock( &cache->c_mutex ); - assert( e->e_private ); + assert( e->e_private != NULL ); Debug( LDAP_DEBUG_TRACE, "====> cache_delete_entry( %ld )\n", e->e_id, 0, 0 ); diff --git a/servers/slapd/back-ldbm/close.c b/servers/slapd/back-ldbm/close.c index 167f78d0fd..2e2090e286 100644 --- a/servers/slapd/back-ldbm/close.c +++ b/servers/slapd/back-ldbm/close.c @@ -26,8 +26,6 @@ int ldbm_back_db_close( Backend *be ) { - struct ldbminfo *li = (struct ldbminfo *) be->be_private; - Debug( LDAP_DEBUG_TRACE, "ldbm backend syncing\n", 0, 0, 0 ); ldbm_cache_flush_all( be ); diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index ae9489a519..c3022e3b19 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -122,7 +122,7 @@ dn2id( Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn->bv_val, 0, 0 ); - assert( idp ); + assert( idp != NULL ); /* first check the cache */ *idp = cache_find_entry_ndn2id( be, &li->li_cache, dn ); diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 51d10c2691..2dd696919f 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -164,7 +164,7 @@ int ldbm_modify_internal( } /* check that the entry still obeys the schema */ - rc = entry_schema_check( op->o_bd, e, save_attrs, get_manageDIT(op), + rc = entry_schema_check( op, e, save_attrs, get_manageDIT(op), text, textbuf, textlen ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "entry failed schema check: %s\n", diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index c999b27b64..c8ef1e5446 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -52,7 +52,6 @@ ldbm_back_modrdn( int isroot = -1; int rc_id = 0; ID id = NOID; - const char *text = NULL; char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof textbuf; /* Added to support newSuperior */ @@ -530,7 +529,7 @@ return_results: tmp = mod->sml_next; free( mod ); } - slap_mods_free( mod ); + slap_mods_free( mod, 1 ); } /* LDAP v3 Support */ diff --git a/servers/slapd/back-ldbm/operational.c b/servers/slapd/back-ldbm/operational.c index b62c84bada..890870f89a 100644 --- a/servers/slapd/back-ldbm/operational.c +++ b/servers/slapd/back-ldbm/operational.c @@ -55,7 +55,7 @@ ldbm_back_operational( { Attribute **ap; - assert( rs->sr_entry ); + assert( rs->sr_entry != NULL ); for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) /* just count */ ; @@ -67,7 +67,7 @@ ldbm_back_operational( hs = has_children( op->o_bd, rs->sr_entry ); *ap = slap_operational_hasSubordinate( hs ); - assert( *ap ); + assert( *ap != NULL ); ap = &(*ap)->a_next; } diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 4038ee5689..94dd13553f 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -39,8 +39,7 @@ ldbm_back_search( SlapReply *rs ) { struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private; - int rc, err; - const char *text = NULL; + int rc; time_t stoptime; ID_BLOCK *candidates; ID id, cursor; @@ -369,6 +368,8 @@ searchit: ? LDAP_SCOPE_BASE : LDAP_SCOPE_SUBTREE ); + ber_bvarray_free( erefs ); + send_search_reference( op, rs ); ber_bvarray_free( rs->sr_ref ); diff --git a/servers/slapd/back-ldbm/tools.c b/servers/slapd/back-ldbm/tools.c index 4fffb1f9d5..945bc2ecea 100644 --- a/servers/slapd/back-ldbm/tools.c +++ b/servers/slapd/back-ldbm/tools.c @@ -183,8 +183,8 @@ ID ldbm_tool_entry_put( assert( slapMode & SLAP_TOOL_MODE ); assert( id2entry != NULL ); - assert( text ); - assert( text->bv_val ); + assert( text != NULL ); + assert( text->bv_val != NULL ); assert( text->bv_val[0] == '\0' ); /* overconservative? */ if ( next_id_get( be, &id ) || id == NOID ) { diff --git a/servers/slapd/back-ldif/ldif.c b/servers/slapd/back-ldif/ldif.c index a9550a5415..77ee590e58 100644 --- a/servers/slapd/back-ldif/ldif.c +++ b/servers/slapd/back-ldif/ldif.c @@ -330,7 +330,7 @@ static int r_enum_tree(enumCookie *ck, struct berval *path, ? LDAP_SCOPE_BASE : LDAP_SCOPE_SUBTREE ); ck->rs->sr_entry = e; - rc = send_search_reference( ck->op, ck->rs ); + rc = send_search_reference( ck->op, ck->rs ) < 0; ber_bvarray_free( ck->rs->sr_ref ); ber_bvarray_free( erefs ); ck->rs->sr_ref = NULL; @@ -341,7 +341,7 @@ static int r_enum_tree(enumCookie *ck, struct berval *path, ck->rs->sr_entry = e; ck->rs->sr_attrs = ck->op->ors_attrs; ck->rs->sr_flags = REP_ENTRY_MODIFIABLE; - rc = send_search_entry(ck->op, ck->rs); + rc = send_search_entry(ck->op, ck->rs) < 0; ck->rs->sr_entry = NULL; } fd = 1; @@ -388,7 +388,7 @@ static int r_enum_tree(enumCookie *ck, struct berval *path, while(1) { struct berval fname, itmp; struct dirent * dir; - bvlist *bvl, *prev; + bvlist *bvl, **prev; dir = readdir(dir_of_path); if(dir == NULL) break; /* end of the directory */ @@ -416,15 +416,14 @@ static int r_enum_tree(enumCookie *ck, struct berval *path, } } - for (ptr = list, prev = (bvlist *)&list; ptr; - prev = ptr, ptr = ptr->next) { + for (prev = &list; (ptr = *prev) != NULL; prev = &ptr->next) { int cmp = strcmp( bvl->bv.bv_val, ptr->bv.bv_val ); if ( !cmp && bvl->num.bv_val ) cmp = bvl->inum - ptr->inum; if ( cmp < 0 ) break; } - prev->next = bvl; + *prev = bvl; bvl->next = ptr; } @@ -467,11 +466,14 @@ enum_tree( struct ldif_info *ni = (struct ldif_info *) ck->op->o_bd->be_private; struct berval path; struct berval pdn, pndn; + int rc; dnParent( &ck->op->o_req_dn, &pdn ); dnParent( &ck->op->o_req_ndn, &pndn ); dn2path( &ck->op->o_req_ndn, &ck->op->o_bd->be_nsuffix[0], &ni->li_base_path, &path); - return r_enum_tree(ck, &path, &pdn, &pndn); + rc = r_enum_tree(ck, &path, &pdn, &pndn); + ch_free( path.bv_val ); + return rc; } /* Get the parent path plus the LDIF suffix */ @@ -518,7 +520,6 @@ static int apply_modify_to_entry(Entry * entry, get_permissiveModify(op), &rs->sr_text, textbuf, sizeof( textbuf ) ); - break; case LDAP_MOD_REPLACE: @@ -526,10 +527,17 @@ static int apply_modify_to_entry(Entry * entry, get_permissiveModify(op), &rs->sr_text, textbuf, sizeof( textbuf ) ); - break; + case LDAP_MOD_INCREMENT: + rc = modify_increment_values( entry, + mods, get_permissiveModify(op), + &rs->sr_text, textbuf, + sizeof( textbuf ) ); + break; + break; + case SLAP_MOD_SOFTADD: mods->sm_op = LDAP_MOD_ADD; rc = modify_add_values(entry, mods, @@ -552,7 +560,7 @@ static int apply_modify_to_entry(Entry * entry, entry->e_ocflags = 0; } /* check that the entry still obeys the schema */ - rc = entry_schema_check(op->o_bd, entry, NULL, 0, + rc = entry_schema_check(op, entry, NULL, 0, &rs->sr_text, textbuf, sizeof( textbuf ) ); } return rc; @@ -677,10 +685,10 @@ ldif_back_referrals( Operation *op, SlapReply *rs ) rs->sr_matched = NULL; ber_bvarray_free( refs ); - - entry_free( entry ); } + entry_free( entry ); + return rc; } @@ -738,7 +746,7 @@ ldif_back_bind( Operation *op, SlapReply *rs ) static int ldif_back_search(Operation *op, SlapReply *rs) { struct ldif_info *ni = (struct ldif_info *) op->o_bd->be_private; - enumCookie ck = {0}; + enumCookie ck = { NULL, NULL, NULL, 0, 0 }; ck.op = op; ck.rs = rs; @@ -759,7 +767,7 @@ static int ldif_back_add(Operation *op, SlapReply *rs) { int statres; char textbuf[SLAP_TEXT_BUFLEN]; - rs->sr_err = entry_schema_check(op->o_bd, e, NULL, 0, + rs->sr_err = entry_schema_check(op, e, NULL, 0, &rs->sr_text, textbuf, sizeof( textbuf ) ); if ( rs->sr_err != LDAP_SUCCESS ) goto send_res; @@ -1001,39 +1009,25 @@ static int ldif_back_modrdn(Operation *op, SlapReply *rs) { return 0; } -static int ldif_back_compare(Operation *op, SlapReply *rs) { +/* return LDAP_SUCCESS IFF we can retrieve the specified entry. + */ +int ldif_back_entry_get( + Operation *op, + struct berval *ndn, + ObjectClass *oc, + AttributeDescription *at, + int rw, + Entry **ent ) +{ struct ldif_info *ni = (struct ldif_info *) op->o_bd->be_private; - Entry * e = NULL; - Attribute *a; - ldap_pvt_thread_mutex_lock(&ni->li_mutex); + ldap_pvt_thread_mutex_lock( &ni->li_mutex ); - e = (Entry *) get_entry(op, &ni->li_base_path); - if(e != NULL) { - for(a = attrs_find( e->e_attrs, op->oq_compare.rs_ava->aa_desc ); - a != NULL; - a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc )) { - rs->sr_err = LDAP_COMPARE_FALSE; - - if (value_find_ex(op->oq_compare.rs_ava->aa_desc, - SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | - SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - a->a_nvals, &op->oq_compare.rs_ava->aa_value, - op->o_tmpmemctx ) == 0) { - rs->sr_err = LDAP_COMPARE_TRUE; - break; - } - } - } - else { - rs->sr_err = LDAP_NO_SUCH_OBJECT; - } + *ent = (Entry *) get_entry( op, &ni->li_base_path ); - if(e != NULL) - entry_free(e); - ldap_pvt_thread_mutex_unlock(&ni->li_mutex); - send_ldap_result(op, rs); - return 0; + ldap_pvt_thread_mutex_unlock( &ni->li_mutex ); + + return ( *ent == NULL ? 1 : 0 ); } static int ldif_tool_entry_open(BackendDB * be, int mode) { @@ -1162,6 +1156,8 @@ ldif_back_db_destroy( ) { struct ldif_info *ni = be->be_private; + + ch_free(ni->li_base_path.bv_val); ldap_pvt_thread_mutex_destroy(&ni->li_mutex); free( be->be_private ); return 0; @@ -1192,6 +1188,7 @@ ldif_back_initialize( int rc; bi->bi_flags |= + SLAP_BFLAG_INCREMENT | SLAP_BFLAG_REFERRALS; bi->bi_controls = controls; @@ -1210,7 +1207,7 @@ ldif_back_initialize( bi->bi_op_bind = ldif_back_bind; bi->bi_op_unbind = 0; bi->bi_op_search = ldif_back_search; - bi->bi_op_compare = ldif_back_compare; + bi->bi_op_compare = 0; bi->bi_op_modify = ldif_back_modify; bi->bi_op_modrdn = ldif_back_modrdn; bi->bi_op_add = ldif_back_add; @@ -1224,6 +1221,14 @@ ldif_back_initialize( bi->bi_connection_init = 0; bi->bi_connection_destroy = 0; + bi->bi_entry_get_rw = ldif_back_entry_get; + +#if 0 /* NOTE: uncomment to completely disable access control */ +#ifdef SLAP_OVERLAY_ACCESS + bi->bi_access_allowed = slap_access_always_allowed; +#endif /* SLAP_OVERLAY_ACCESS */ +#endif + bi->bi_tool_entry_open = ldif_tool_entry_open; bi->bi_tool_entry_close = ldif_tool_entry_close; bi->bi_tool_entry_first = ldif_tool_entry_first; @@ -1237,6 +1242,8 @@ ldif_back_initialize( bi->bi_tool_id2entry_get = 0; bi->bi_tool_entry_modify = 0; + bi->bi_cf_ocs = ldifocs; + rc = config_register_schema( ldifcfg, ldifocs ); if ( rc ) return rc; return 0; diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index 31b0fcb59a..9628cdd6ec 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -43,6 +43,7 @@ meta_back_add( Operation *op, SlapReply *rs ) LDAPMod **attrs; struct berval mdn = BER_BVNULL, mapped; dncookie dc; + int msgid; int do_retry = 1; Debug(LDAP_DEBUG_ARGS, "==> meta_back_add: %s\n", @@ -163,20 +164,58 @@ meta_back_add( Operation *op, SlapReply *rs ) attrs[ i ] = NULL; retry:; -#if 0 rs->sr_err = ldap_add_ext( mc->mc_conns[ candidate ].msc_ld, mdn.bv_val, attrs, op->o_ctrls, NULL, &msgid ); - rs->sr_err = meta_back_op_result( op, rs, &mc->mc_conns[ candidate ], msgid, LDAP_BACK_SENDERR ); -#endif - rs->sr_err = ldap_add_ext_s( mc->mc_conns[ candidate ].msc_ld, mdn.bv_val, - attrs, op->o_ctrls, NULL ); if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) { do_retry = 0; if ( meta_back_retry( op, rs, mc, candidate, LDAP_BACK_SENDERR ) ) { goto retry; } + + } else if ( rs->sr_err == LDAP_SUCCESS ) { + struct timeval tv, *tvp = NULL; + LDAPMessage *res = NULL; + int rc; + + if ( mi->mi_targets[ candidate ].mt_timeout[ META_OP_ADD ] != 0 ) { + tv.tv_sec = mi->mi_targets[ candidate ].mt_timeout[ META_OP_ADD ]; + tv.tv_usec = 0; + tvp = &tv; + } + + rs->sr_err = LDAP_OTHER; + rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, + msgid, LDAP_MSG_ONE, tvp, &res ); + switch ( rc ) { + case -1: + send_ldap_result( op, rs ); + goto cleanup; + + case 0: + ldap_abandon_ext( mc->mc_conns[ candidate ].msc_ld, + msgid, NULL, NULL ); + rs->sr_err = op->o_protocol >= LDAP_VERSION3 ? + LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR; + send_ldap_result( op, rs ); + goto cleanup; + + case LDAP_RES_ADD: + rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld, + res, &rs->sr_err, NULL, NULL, NULL, NULL, 1 ); + if ( rc != LDAP_SUCCESS ) { + rs->sr_err = rc; + } + break; + + default: + ldap_msgfree( res ); + break; + } } + (void)meta_back_op_result( mc, op, rs, candidate ); + +cleanup:; for ( --i; i >= 0; --i ) { free( attrs[ i ]->mod_bvalues ); free( attrs[ i ] ); @@ -187,8 +226,6 @@ retry:; BER_BVZERO( &mdn ); } - (void)meta_back_op_result( mc, op, rs, candidate ); - done:; meta_back_release_conn( op, mc ); diff --git a/servers/slapd/back-meta/back-meta.h b/servers/slapd/back-meta/back-meta.h index c3c23adadb..daf6e85df9 100644 --- a/servers/slapd/back-meta/back-meta.h +++ b/servers/slapd/back-meta/back-meta.h @@ -193,6 +193,14 @@ typedef struct metaconn_t { * in one block with the metaconn_t structure */ } metaconn_t; +enum { + META_OP_ADD = 0, + META_OP_DELETE, + META_OP_MODIFY, + META_OP_MODRDN, + META_OP_LAST +}; + typedef struct metatarget_t { char *mt_uri; @@ -215,6 +223,7 @@ typedef struct metatarget_t { unsigned mt_flags; int mt_version; + time_t mt_timeout[ META_OP_LAST ]; } metatarget_t; typedef struct metadncache_t { @@ -253,6 +262,7 @@ typedef struct metainfo_t { #define META_BACK_ONERR_CONTINUE(mi) ( !META_BACK_ONERR_CONTINUE( (mi) ) ) int mi_version; + time_t mi_timeout[ META_OP_LAST ]; } metainfo_t; typedef enum meta_op_type { diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index a3d67e4595..f7bc68ff87 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -223,8 +223,11 @@ retry:; tv.tv_usec = META_BIND_TIMEOUT; switch ( ldap_result( msc->msc_ld, msgid, 0, &tv, &res ) ) { case 0: - Debug( LDAP_DEBUG_ANY, "%s meta_back_single_bind: ldap_result=%d nretries=%d\n", - op->o_log_prefix, 0, nretries ); + Debug( LDAP_DEBUG_ANY, + "%s meta_back_single_bind: " + "ldap_result=0 nretries=%d%s\n", + op->o_log_prefix, nretries, + rebinding ? " rebinding" : "" ); if ( nretries != META_RETRY_NEVER ) { ldap_pvt_thread_yield(); @@ -255,30 +258,25 @@ retry:; ldap_abandon_ext( msc->msc_ld, msgid, NULL, NULL ); } - Debug( LDAP_DEBUG_ANY, "### %s meta_back_single_bind: err=%d nretries=%d\n", + Debug( LDAP_DEBUG_ANY, + "### %s meta_back_single_bind: " + "err=%d nretries=%d\n", op->o_log_prefix, rs->sr_err, nretries ); rc = slap_map_api2result( rs ); if ( rs->sr_err == LDAP_UNAVAILABLE && nretries != META_RETRY_NEVER ) { -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } - + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); if ( mc->mc_refcnt == 1 ) { ldap_unbind_ext_s( msc->msc_ld, NULL, NULL ); msc->msc_ld = NULL; msc->msc_bound = 0; - /* mc here must be the regular mc, reset and ready for init */ - rc = meta_back_init_one_conn( op, rs, mt, msc, - LDAP_BACK_DONTSEND ); + ( void )rewrite_session_delete( mt->mt_rwmap.rwm_rw, op->o_conn ); + + /* mc here must be the regular mc, + * reset and ready for init */ + rc = meta_back_init_one_conn( op, rs, + mt, msc, LDAP_BACK_DONTSEND ); } else { /* can't do anything about it */ @@ -392,8 +390,11 @@ retry:; tv.tv_usec = META_BIND_TIMEOUT; switch ( ldap_result( msc->msc_ld, msgid, 0, &tv, &res ) ) { case 0: - Debug( LDAP_DEBUG_ANY, "%s meta_back_single_dobind: ldap_result=%d nretries=%d\n", - op->o_log_prefix, 0, nretries ); + Debug( LDAP_DEBUG_ANY, + "%s meta_back_single_dobind: " + "ldap_result=0 nretries=%d%s\n", + op->o_log_prefix, nretries, + rebinding ? " rebinding" : "" ); if ( nretries != META_RETRY_NEVER ) { ldap_pvt_thread_yield(); @@ -425,22 +426,15 @@ retry:; ldap_abandon_ext( msc->msc_ld, msgid, NULL, NULL ); } - Debug( LDAP_DEBUG_ANY, "### %s meta_back_single_dobind: err=%d nretries=%d\n", - op->o_log_prefix, rs->sr_err, nretries ); + Debug( LDAP_DEBUG_ANY, + "### %s meta_back_single_dobind: " + "err=%d nretries=%d\n", + op->o_log_prefix, rs->sr_err, nretries ); rc = slap_map_api2result( rs ); if ( rc == LDAP_UNAVAILABLE && nretries != META_RETRY_NEVER ) { if ( dolock ) { -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); } if ( mc->mc_refcnt == 1 ) { @@ -448,8 +442,12 @@ retry_lock:; msc->msc_ld = NULL; msc->msc_bound = 0; - /* mc here must be the regular mc, reset and ready for init */ - rc = meta_back_init_one_conn( op, rs, mt, msc, LDAP_BACK_DONTSEND ); + ( void )rewrite_session_delete( mt->mt_rwmap.rwm_rw, op->o_conn ); + + /* mc here must be the regular mc, + * reset and ready for init */ + rc = meta_back_init_one_conn( op, rs, + mt, msc, LDAP_BACK_DONTSEND ); } else { diff --git a/servers/slapd/back-meta/candidates.c b/servers/slapd/back-meta/candidates.c index 76023a8837..a59606ff70 100644 --- a/servers/slapd/back-meta/candidates.c +++ b/servers/slapd/back-meta/candidates.c @@ -50,10 +50,6 @@ * A possible extension will include the handling of multiple suffixes */ -static int -meta_back_is_candidate_unique( - metainfo_t *mi, - struct berval *ndn ); /* * returns 1 if suffix is candidate for dn, otherwise 0 @@ -80,6 +76,7 @@ meta_back_is_candidate( return META_NOT_CANDIDATE; } +#if 0 /* * meta_back_is_candidate_unique * @@ -99,6 +96,7 @@ meta_back_is_candidate_unique( return 1; } +#endif /* 0 */ /* * meta_back_select_unique_candidate diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index 42a99e59b7..9fd06be3e0 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -71,7 +71,6 @@ meta_back_compare( Operation *op, SlapReply *rs ) dc.ctx = "compareDN"; for ( i = 0; i < mi->mi_ntargets; i++ ) { - metasingleconn_t *msc = &mc->mc_conns[ i ]; struct berval mdn = BER_BVNULL; struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname; struct berval mapped_value = op->orc_ava->aa_value; diff --git a/servers/slapd/back-meta/config.c b/servers/slapd/back-meta/config.c index 62fcd5f071..24f357ed5e 100644 --- a/servers/slapd/back-meta/config.c +++ b/servers/slapd/back-meta/config.c @@ -96,6 +96,7 @@ meta_back_db_config( LDAPURLDesc *ludp, *tmpludp; struct berval dn; int rc; + int c; if ( argc != 2 ) { fprintf( stderr, @@ -129,6 +130,10 @@ meta_back_db_config( mi->mi_targets[ i ].mt_flags = mi->flags; mi->mi_targets[ i ].mt_version = mi->mi_version; + for ( c = 0; c < META_OP_LAST; c++ ) { + mi->mi_targets[ i ].mt_timeout[ c ] = mi->mi_timeout[ c ]; + } + /* * uri MUST be legal! */ @@ -492,6 +497,67 @@ meta_back_db_config( return 1; } + } else if ( strcasecmp( argv[ 0 ], "timeout" ) == 0 ) { + char *sep, *next; + time_t *tv = mi->mi_ntargets ? + mi->mi_targets[ mi->mi_ntargets - 1 ].mt_timeout + : mi->mi_timeout; + int c; + + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: \"timeout [{add|delete|modify|modrdn}=] [...]\" takes at least 1 argument\n", + fname, lineno ); + return( 1 ); + } + + for ( c = 1; c < argc; c++ ) { + time_t *t = NULL, val; + + sep = strchr( argv[ c ], '=' ); + if ( sep != NULL ) { + size_t len = sep - argv[ c ]; + + if ( strncasecmp( argv[ c ], "add", len ) == 0 ) { + t = &tv[ META_OP_ADD ]; + } else if ( strncasecmp( argv[ c ], "delete", len ) == 0 ) { + t = &tv[ META_OP_DELETE ]; + } else if ( strncasecmp( argv[ c ], "modify", len ) == 0 ) { + t = &tv[ META_OP_MODIFY ]; + } else if ( strncasecmp( argv[ c ], "modrdn", len ) == 0 ) { + t = &tv[ META_OP_MODRDN ]; + } else { + fprintf( stderr, + "%s: line %d: unknown operation \"%s\" for timeout #%d.\n", + fname, lineno, argv[ c ], c ); + return 1; + } + sep++; + + } else { + sep = argv[ c ]; + } + + val = strtoul( sep, &next, 10 ); + if ( next == sep || next[ 0 ] != '\0' ) { + fprintf( stderr, + "%s: line %d: unable to parse value \"%s\" for timeout.\n", + fname, lineno, sep ); + return 1; + } + + if ( t ) { + *t = val; + + } else { + int i; + + for ( i = 0; i < META_OP_LAST; i++ ) { + tv[ i ] = val; + } + } + } + /* name to use as pseudo-root dn */ } else if ( strcasecmp( argv[ 0 ], "pseudorootdn" ) == 0 ) { int i = mi->mi_ntargets - 1; @@ -544,7 +610,7 @@ meta_back_db_config( /* dn massaging */ } else if ( strcasecmp( argv[ 0 ], "suffixmassage" ) == 0 ) { BackendDB *tmp_be; - int i = mi->mi_ntargets - 1; + int i = mi->mi_ntargets - 1, rc; struct berval dn, nvnc, pvnc, nrnc, prnc; if ( i < 0 ) { @@ -572,8 +638,7 @@ meta_back_db_config( return 1; } - dn.bv_val = argv[ 1 ]; - dn.bv_len = strlen( argv[ 1 ] ); + ber_str2bv( argv[ 1 ], 0, 0, &dn ); if ( dnPrettyNormal( NULL, &dn, &pvnc, &nvnc, NULL ) != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: " "suffix '%s' is invalid\n", @@ -592,8 +657,7 @@ meta_back_db_config( return 1; } - dn.bv_val = argv[ 2 ]; - dn.bv_len = strlen( argv[ 2 ] ); + ber_str2bv( argv[ 2 ], 0, 0, &dn ); if ( dnPrettyNormal( NULL, &dn, &prnc, &nrnc, NULL ) != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: " "massaged suffix '%s' is invalid\n", @@ -624,8 +688,15 @@ meta_back_db_config( * FIXME: no extra rewrite capabilities should be added * to the database */ - return suffix_massage_config( mi->mi_targets[ i ].mt_rwmap.rwm_rw, + rc = suffix_massage_config( mi->mi_targets[ i ].mt_rwmap.rwm_rw, &pvnc, &nvnc, &prnc, &nrnc ); + + free( pvnc.bv_val ); + free( nvnc.bv_val ); + free( prnc.bv_val ); + free( nrnc.bv_val ); + + return rc; /* rewrite stuff ... */ } else if ( strncasecmp( argv[ 0 ], "rewrite", 7 ) == 0 ) { diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index 1379d8c3a1..422107d78d 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -178,16 +178,7 @@ meta_back_freeconn( assert( mc != NULL ); -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); if ( --mc->mc_refcnt == 0 ) { meta_back_conn_free( mc ); @@ -217,8 +208,7 @@ meta_back_init_one_conn( * Already init'ed */ if ( msc->msc_ld != NULL ) { - rs->sr_err = LDAP_SUCCESS; - goto error_return; + return rs->sr_err = LDAP_SUCCESS; } /* @@ -242,14 +232,14 @@ meta_back_init_one_conn( } #ifdef HAVE_TLS - /* start TLS ("start-tls"/"try-start-tls" statements) */ + /* start TLS ("tls [try-]{start|propagate}" statement) */ if ( ( LDAP_BACK_USE_TLS( mi ) || ( op->o_conn->c_is_tls && LDAP_BACK_PROPAGATE_TLS( mi ) ) ) && !ldap_is_ldaps_url( mt->mt_uri ) ) { #ifdef SLAP_STARTTLS_ASYNCHRONOUS /* - * use asynchronous StartTLS - * in case, chase referral (not implemented yet) + * use asynchronous StartTLS; in case, chase referral + * FIXME: OpenLDAP does not return referral on StartTLS yet */ int msgid; @@ -345,11 +335,6 @@ retry:; (void *)&network_timeout ); } - /* - * Sets a cookie for the rewrite session - */ - ( void )rewrite_session_init( mt->mt_rwmap.rwm_rw, op->o_conn ); - /* * If the connection DN is not null, an attempt to rewrite it is made */ @@ -382,7 +367,13 @@ retry:; msc->msc_bound = META_UNBOUND; error_return:; - if ( rs->sr_err != LDAP_SUCCESS ) { + if ( rs->sr_err == LDAP_SUCCESS ) { + /* + * Sets a cookie for the rewrite session + */ + ( void )rewrite_session_init( mt->mt_rwmap.rwm_rw, op->o_conn ); + + } else { rs->sr_err = slap_map_api2result( rs ); if ( sendok & LDAP_BACK_SENDERR ) { send_ldap_result( op, rs ); @@ -412,25 +403,23 @@ meta_back_retry( metasingleconn_t *msc = &mc->mc_conns[ candidate ]; retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); assert( mc->mc_refcnt > 0 ); if ( mc->mc_refcnt == 1 ) { - ldap_pvt_thread_mutex_lock( &mc->mc_mutex ); + while ( ldap_pvt_thread_mutex_trylock( &mc->mc_mutex ) ) { + ldap_pvt_thread_mutex_unlock( &mi->mi_conn_mutex ); + ldap_pvt_thread_yield(); + goto retry_lock; + } ldap_unbind_ext_s( msc->msc_ld, NULL, NULL ); msc->msc_ld = NULL; msc->msc_bound = 0; + ( void )rewrite_session_delete( mt->mt_rwmap.rwm_rw, op->o_conn ); + /* mc here must be the regular mc, reset and ready for init */ rc = meta_back_init_one_conn( op, rs, mt, msc, sendok ); @@ -570,7 +559,6 @@ meta_back_candidates_get( Operation *op ) { metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; metacandidates_t *mc; - SlapReply *rs; if ( op->o_threadctx ) { void *data = NULL; @@ -670,16 +658,7 @@ meta_back_getconn( /* Searches for a metaconn in the avl tree */ mc_curr.mc_conn = op->o_conn; -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); mc = (metaconn_t *)avl_find( mi->mi_conntree, (caddr_t)&mc_curr, meta_back_conn_cmp ); if ( mc ) { @@ -848,16 +827,7 @@ retry_lock:; * the reason is that the connection might have been * created by meta_back_get_candidate() */ mc_curr.mc_conn = op->o_conn; -retry_lock2:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock2; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); mc = (metaconn_t *)avl_find( mi->mi_conntree, (caddr_t)&mc_curr, meta_back_conn_cmp ); if ( mc != NULL ) { @@ -1002,16 +972,7 @@ done:; /* * Inserts the newly created metaconn in the avl tree */ -retry_lock3:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock3; - - case 0: - break; - } + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); err = avl_insert( &mi->mi_conntree, ( caddr_t )mc, meta_back_conn_cmp, meta_back_conn_dup ); @@ -1064,17 +1025,7 @@ meta_back_release_conn( assert( mc != NULL ); -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } - + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); assert( mc->mc_refcnt > 0 ); mc->mc_refcnt--; ldap_pvt_thread_mutex_unlock( &mi->mi_conn_mutex ); diff --git a/servers/slapd/back-meta/delete.c b/servers/slapd/back-meta/delete.c index d247de359a..7c1463d60f 100644 --- a/servers/slapd/back-meta/delete.c +++ b/servers/slapd/back-meta/delete.c @@ -39,6 +39,7 @@ meta_back_delete( Operation *op, SlapReply *rs ) int candidate = -1; struct berval mdn = BER_BVNULL; dncookie dc; + int msgid; int do_retry = 1; mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR ); @@ -62,22 +63,64 @@ meta_back_delete( Operation *op, SlapReply *rs ) } retry:; - rs->sr_err = ldap_delete_ext_s( mc->mc_conns[ candidate ].msc_ld, - mdn.bv_val, op->o_ctrls, NULL ); + rs->sr_err = ldap_delete_ext( mc->mc_conns[ candidate ].msc_ld, + mdn.bv_val, op->o_ctrls, NULL, &msgid ); if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) { do_retry = 0; if ( meta_back_retry( op, rs, mc, candidate, LDAP_BACK_SENDERR ) ) { goto retry; } + + } else if ( rs->sr_err == LDAP_SUCCESS ) { + struct timeval tv, *tvp = NULL; + LDAPMessage *res = NULL; + int rc; + + if ( mi->mi_targets[ candidate ].mt_timeout[ META_OP_DELETE ] != 0 ) { + tv.tv_sec = mi->mi_targets[ candidate ].mt_timeout[ META_OP_DELETE ]; + tv.tv_usec = 0; + tvp = &tv; + } + + rs->sr_err = LDAP_OTHER; + rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, + msgid, LDAP_MSG_ONE, tvp, &res ); + switch ( rc ) { + case -1: + rs->sr_err = LDAP_OTHER; + send_ldap_result( op, rs ); + goto cleanup; + + case 0: + ldap_abandon_ext( mc->mc_conns[ candidate ].msc_ld, + msgid, NULL, NULL ); + rs->sr_err = op->o_protocol >= LDAP_VERSION3 ? + LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR; + send_ldap_result( op, rs ); + goto cleanup; + + case LDAP_RES_DELETE: + rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld, + res, &rs->sr_err, NULL, NULL, NULL, NULL, 1 ); + if ( rc != LDAP_SUCCESS ) { + rs->sr_err = rc; + } + break; + + default: + ldap_msgfree( res ); + break; + } } + rs->sr_err = meta_back_op_result( mc, op, rs, candidate ); + +cleanup:; if ( mdn.bv_val != op->o_req_dn.bv_val ) { free( mdn.bv_val ); BER_BVZERO( &mdn ); } - rs->sr_err = meta_back_op_result( mc, op, rs, candidate ); - done:; meta_back_release_conn( op, mc ); diff --git a/servers/slapd/back-meta/dncache.c b/servers/slapd/back-meta/dncache.c index cfe5a80c5f..ccaf446de6 100644 --- a/servers/slapd/back-meta/dncache.c +++ b/servers/slapd/back-meta/dncache.c @@ -97,8 +97,8 @@ meta_dncache_get_target( time_t curr_time; int target = META_TARGET_NONE; - assert( cache ); - assert( ndn ); + assert( cache != NULL ); + assert( ndn != NULL ); tmp_entry.dn = *ndn; ldap_pvt_thread_mutex_lock( &cache->mutex ); @@ -149,8 +149,8 @@ meta_dncache_update_entry( time_t curr_time = 0L; int err = 0; - assert( cache ); - assert( ndn ); + assert( cache != NULL ); + assert( ndn != NULL ); /* * if cache->ttl < 0, cache never expires; @@ -209,8 +209,8 @@ meta_dncache_delete_entry( metadncacheentry_t *entry, tmp_entry; - assert( cache ); - assert( ndn ); + assert( cache != NULL ); + assert( ndn != NULL ); tmp_entry.dn = *ndn; diff --git a/servers/slapd/back-meta/map.c b/servers/slapd/back-meta/map.c index 87ca4b9031..550c06ad13 100644 --- a/servers/slapd/back-meta/map.c +++ b/servers/slapd/back-meta/map.c @@ -87,7 +87,7 @@ ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping **m ) { struct ldapmapping *mapping; - assert( m ); + assert( m != NULL ); *m = NULL; @@ -116,7 +116,7 @@ ldap_back_mapping ( struct ldapmap *map, struct berval *s, struct ldapmapping ** Avlnode *tree; struct ldapmapping fmapping; - assert( m ); + assert( m != NULL ); if ( remap == BACKLDAP_REMAP ) { tree = map->remap; @@ -601,8 +601,8 @@ ldap_back_referral_result_rewrite( { int i, last; - assert( dc ); - assert( a_vals ); + assert( dc != NULL ); + assert( a_vals != NULL ); for ( last = 0; !BER_BVISNULL( &a_vals[ last ] ); last++ ) ; diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index 2d51289cb1..f2b40d24a4 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -45,6 +45,7 @@ meta_back_modify( Operation *op, SlapReply *rs ) struct berval mdn = BER_BVNULL; struct berval mapped; dncookie dc; + int msgid; int do_retry = 1; mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR ); @@ -172,13 +173,54 @@ meta_back_modify( Operation *op, SlapReply *rs ) modv[ i ] = 0; retry:; - rs->sr_err = ldap_modify_ext_s( mc->mc_conns[ candidate ].msc_ld, mdn.bv_val, - modv, op->o_ctrls, NULL ); + rs->sr_err = ldap_modify_ext( mc->mc_conns[ candidate ].msc_ld, mdn.bv_val, + modv, op->o_ctrls, NULL, &msgid ); if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) { do_retry = 0; if ( meta_back_retry( op, rs, mc, candidate, LDAP_BACK_SENDERR ) ) { goto retry; } + + } else if ( rs->sr_err == LDAP_SUCCESS ) { + struct timeval tv, *tvp = NULL; + LDAPMessage *res = NULL; + + if ( mi->mi_targets[ candidate ].mt_timeout[ META_OP_MODIFY ] != 0 ) { + tv.tv_sec = mi->mi_targets[ candidate ].mt_timeout[ META_OP_MODIFY ]; + tv.tv_usec = 0; + tvp = &tv; + } + + rs->sr_err = LDAP_OTHER; + rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, + msgid, LDAP_MSG_ONE, tvp, &res ); + switch ( rc ) { + case -1: + rc = -1; + break; + + case 0: + ldap_abandon_ext( mc->mc_conns[ candidate ].msc_ld, + msgid, NULL, NULL ); + rs->sr_err = op->o_protocol >= LDAP_VERSION3 ? + LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR; + rc = -1; + break; + + case LDAP_RES_MODIFY: + rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld, + res, &rs->sr_err, NULL, NULL, NULL, NULL, 1 ); + if ( rc != LDAP_SUCCESS ) { + rs->sr_err = rc; + } + rc = 0; + break; + + default: + rc = -1; + ldap_msgfree( res ); + break; + } } cleanup:; diff --git a/servers/slapd/back-meta/modrdn.c b/servers/slapd/back-meta/modrdn.c index a63e99e48c..741571c32d 100644 --- a/servers/slapd/back-meta/modrdn.c +++ b/servers/slapd/back-meta/modrdn.c @@ -34,13 +34,14 @@ int meta_back_modrdn( Operation *op, SlapReply *rs ) { - metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; - metaconn_t *mc; - int candidate = -1; - struct berval mdn = BER_BVNULL, - mnewSuperior = BER_BVNULL; - dncookie dc; - int do_retry = 1; + metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; + metaconn_t *mc; + int candidate = -1; + struct berval mdn = BER_BVNULL, + mnewSuperior = BER_BVNULL; + dncookie dc; + int msgid; + int do_retry = 1; mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR ); if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) { @@ -101,15 +102,53 @@ meta_back_modrdn( Operation *op, SlapReply *rs ) } retry:; - rs->sr_err = ldap_rename_s( mc->mc_conns[ candidate ].msc_ld, + rs->sr_err = ldap_rename( mc->mc_conns[ candidate ].msc_ld, mdn.bv_val, op->orr_newrdn.bv_val, mnewSuperior.bv_val, op->orr_deleteoldrdn, - op->o_ctrls, NULL ); + op->o_ctrls, NULL, &msgid ); if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) { do_retry = 0; if ( meta_back_retry( op, rs, mc, candidate, LDAP_BACK_SENDERR ) ) { goto retry; } + + } else if ( rs->sr_err == LDAP_SUCCESS ) { + struct timeval tv, *tvp = NULL; + LDAPMessage *res = NULL; + int rc; + + if ( mi->mi_targets[ candidate ].mt_timeout[ META_OP_MODRDN ] != 0 ) { + tv.tv_sec = mi->mi_targets[ candidate ].mt_timeout[ META_OP_MODRDN ]; + tv.tv_usec = 0; + tvp = &tv; + } + + rs->sr_err = LDAP_OTHER; + rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, + msgid, LDAP_MSG_ONE, tvp, &res ); + switch ( rc ) { + case -1: + break; + + case 0: + ldap_abandon_ext( mc->mc_conns[ candidate ].msc_ld, + msgid, NULL, NULL ); + rs->sr_err = op->o_protocol >= LDAP_VERSION3 ? + LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR; + break; + + case LDAP_RES_RENAME: + rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld, + res, &rs->sr_err, NULL, NULL, NULL, NULL, 1 ); + if ( rc != LDAP_SUCCESS ) { + rs->sr_err = rc; + } + break; + + default: + ldap_msgfree( res ); + break; + } } cleanup:; @@ -127,10 +166,10 @@ cleanup:; if ( rs->sr_err == LDAP_SUCCESS ) { meta_back_op_result( mc, op, rs, candidate ); + } else { + send_ldap_result( op, rs ); } - send_ldap_result( op, rs ); - meta_back_release_conn( op, mc ); return rs->sr_err; diff --git a/servers/slapd/back-meta/suffixmassage.c b/servers/slapd/back-meta/suffixmassage.c index 244e4666eb..da96c8be2d 100644 --- a/servers/slapd/back-meta/suffixmassage.c +++ b/servers/slapd/back-meta/suffixmassage.c @@ -126,7 +126,7 @@ ldap_back_dn_massage( int i, src, dst; struct berval pretty = {0,NULL}, *dn = odn; - assert( res ); + assert( res != NULL ); if ( dn == NULL ) { res->bv_val = NULL; diff --git a/servers/slapd/back-meta/unbind.c b/servers/slapd/back-meta/unbind.c index 1fd72e7271..93a694b02b 100644 --- a/servers/slapd/back-meta/unbind.c +++ b/servers/slapd/back-meta/unbind.c @@ -40,6 +40,8 @@ meta_back_conn_destroy( metainfo_t *mi = ( metainfo_t * )be->be_private; metaconn_t *mc, mc_curr = { 0 }; + int i; + Debug( LDAP_DEBUG_TRACE, "=>meta_back_conn_destroy: fetching conn %ld\n", @@ -47,24 +49,12 @@ meta_back_conn_destroy( mc_curr.mc_conn = conn; -retry_lock:; - switch ( ldap_pvt_thread_mutex_trylock( &mi->mi_conn_mutex ) ) { - case LDAP_PVT_THREAD_EBUSY: - default: - ldap_pvt_thread_yield(); - goto retry_lock; - - case 0: - break; - } - + ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex ); mc = avl_delete( &mi->mi_conntree, ( caddr_t )&mc_curr, meta_back_conn_cmp ); ldap_pvt_thread_mutex_unlock( &mi->mi_conn_mutex ); if ( mc ) { - int i; - Debug( LDAP_DEBUG_TRACE, "=>meta_back_conn_destroy: destroying conn %ld\n", mc->mc_conn->c_connid, 0, 0 ); @@ -75,16 +65,20 @@ retry_lock:; * Cleanup rewrite session */ for ( i = 0; i < mi->mi_ntargets; ++i ) { - rewrite_session_delete( mi->mi_targets[ i ].mt_rwmap.rwm_rw, conn ); - if ( mc->mc_conns[ i ].msc_ld != NULL ) { meta_clear_one_candidate( &mc->mc_conns[ i ] ); } } + meta_back_conn_free( mc ); } - /* no response to unbind */ + /* + * Cleanup rewrite session + */ + for ( i = 0; i < mi->mi_ntargets; ++i ) { + rewrite_session_delete( mi->mi_targets[ i ].mt_rwmap.rwm_rw, conn ); + } return 0; } diff --git a/servers/slapd/back-monitor/back-monitor.h b/servers/slapd/back-monitor/back-monitor.h index 8cd40f186b..e688f943c3 100644 --- a/servers/slapd/back-monitor/back-monitor.h +++ b/servers/slapd/back-monitor/back-monitor.h @@ -40,7 +40,7 @@ typedef struct monitor_callback_t { /* modify callback for user-defined entries */ int (*mc_free)( Entry *e, void *priv ); - /* update callback + /* delete callback for user-defined entries */ void *mc_private; /* opaque pointer to private data */ @@ -122,6 +122,7 @@ typedef struct monitor_info_t { AttributeDescription *mi_ad_monitorConnectionActivityTime; AttributeDescription *mi_ad_monitorIsShadow; AttributeDescription *mi_ad_monitorUpdateRef; + AttributeDescription *mi_ad_monitorRuntimeConfig; /* * Generic description attribute @@ -192,7 +193,7 @@ enum { #define SLAPD_MONITOR_OPS_DN \ SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN -#define SLAPD_MONITOR_OVERLAY_NAME "Overlay" +#define SLAPD_MONITOR_OVERLAY_NAME "Overlays" #define SLAPD_MONITOR_OVERLAY_RDN \ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME #define SLAPD_MONITOR_OVERLAY_DN \ @@ -250,6 +251,8 @@ typedef struct monitor_subsys_t { /* initialize entry and subentries */ int ( *mss_open )( BackendDB *, struct monitor_subsys_t *ms ); + /* destroy structure */ + int ( *mss_destroy )( BackendDB *, struct monitor_subsys_t *ms ); /* update existing dynamic entry and subentries */ int ( *mss_update )( Operation *, SlapReply *, Entry * ); /* create new dynamic subentries */ diff --git a/servers/slapd/back-monitor/backend.c b/servers/slapd/back-monitor/backend.c index 976b68a5eb..10732fb4d9 100644 --- a/servers/slapd/back-monitor/backend.c +++ b/servers/slapd/back-monitor/backend.c @@ -57,8 +57,7 @@ monitor_subsys_backend_init( return -1; } - if ( monitor_cache_get( mi, &ms->mss_ndn, &e_backend ) ) - { + if ( monitor_cache_get( mi, &ms->mss_ndn, &e_backend ) ) { Debug( LDAP_DEBUG_ANY, "monitor_subsys_backend_init: " "unable to get entry \"%s\"\n", @@ -73,7 +72,7 @@ monitor_subsys_backend_init( i = -1; LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next ) { char buf[ BACKMONITOR_BUFSIZE ]; - BackendDB *be; + BackendDB *be; struct berval bv; int j; Entry *e; @@ -85,6 +84,8 @@ monitor_subsys_backend_init( "objectClass: %s\n" "structuralObjectClass: %s\n" "cn: Backend %d\n" + "%s: %s\n" + "%s: %s\n" "creatorsName: %s\n" "modifiersName: %s\n" "createTimestamp: %s\n" @@ -94,6 +95,10 @@ monitor_subsys_backend_init( mi->mi_oc_monitoredObject->soc_cname.bv_val, mi->mi_oc_monitoredObject->soc_cname.bv_val, i, + mi->mi_ad_monitoredInfo->ad_cname.bv_val, + bi->bi_type, + mi->mi_ad_monitorRuntimeConfig->ad_cname.bv_val, + bi->bi_cf_ocs == NULL ? "FALSE" : "TRUE", mi->mi_creatorsName.bv_val, mi->mi_creatorsName.bv_val, mi->mi_startTime.bv_val, @@ -109,8 +114,6 @@ monitor_subsys_backend_init( } ber_str2bv( bi->bi_type, 0, 0, &bv ); - attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, - &bv, NULL ); attr_merge_normalize_one( e_backend, mi->mi_ad_monitoredInfo, &bv, NULL ); diff --git a/servers/slapd/back-monitor/cache.c b/servers/slapd/back-monitor/cache.c index 8a48d9efae..0ac86a5639 100644 --- a/servers/slapd/back-monitor/cache.c +++ b/servers/slapd/back-monitor/cache.c @@ -44,9 +44,8 @@ typedef struct monitor_cache_t { */ int monitor_cache_cmp( - const void *c1, - const void *c2 -) + const void *c1, + const void *c2 ) { monitor_cache_t *cc1 = ( monitor_cache_t * )c1; monitor_cache_t *cc2 = ( monitor_cache_t * )c2; @@ -62,9 +61,8 @@ monitor_cache_cmp( */ int monitor_cache_dup( - void *c1, - void *c2 -) + void *c1, + void *c2 ) { monitor_cache_t *cc1 = ( monitor_cache_t * )c1; monitor_cache_t *cc2 = ( monitor_cache_t * )c2; @@ -80,9 +78,8 @@ monitor_cache_dup( */ int monitor_cache_add( - monitor_info_t *mi, - Entry *e -) + monitor_info_t *mi, + Entry *e ) { monitor_cache_t *mc; monitor_entry_t *mp; @@ -110,18 +107,17 @@ monitor_cache_add( */ int monitor_cache_lock( - Entry *e -) + Entry *e ) { - monitor_entry_t *mp; + monitor_entry_t *mp; - assert( e != NULL ); - assert( e->e_private != NULL ); + assert( e != NULL ); + assert( e->e_private != NULL ); - mp = ( monitor_entry_t * )e->e_private; - ldap_pvt_thread_mutex_lock( &mp->mp_mutex ); + mp = ( monitor_entry_t * )e->e_private; + ldap_pvt_thread_mutex_lock( &mp->mp_mutex ); - return( 0 ); + return( 0 ); } /* @@ -130,10 +126,9 @@ monitor_cache_lock( */ int monitor_cache_get( - monitor_info_t *mi, - struct berval *ndn, - Entry **ep -) + monitor_info_t *mi, + struct berval *ndn, + Entry **ep ) { monitor_cache_t tmp_mc, *mc; @@ -141,6 +136,8 @@ monitor_cache_get( assert( ndn != NULL ); assert( ep != NULL ); + *ep = NULL; + tmp_mc.mc_ndn = *ndn; ldap_pvt_thread_mutex_lock( &mi->mi_cache_mutex ); mc = ( monitor_cache_t * )avl_find( mi->mi_cache, @@ -149,16 +146,12 @@ monitor_cache_get( if ( mc != NULL ) { /* entry is returned with mutex locked */ monitor_cache_lock( mc->mc_e ); - ldap_pvt_thread_mutex_unlock( &mi->mi_cache_mutex ); *ep = mc->mc_e; - - return( 0 ); } - + ldap_pvt_thread_mutex_unlock( &mi->mi_cache_mutex ); - *ep = NULL; - return( -1 ); + return ( *ep == NULL ? -1 : 0 ); } /* @@ -169,12 +162,11 @@ monitor_cache_get( */ int monitor_cache_dn2entry( - Operation *op, - SlapReply *rs, - struct berval *ndn, - Entry **ep, - Entry **matched -) + Operation *op, + SlapReply *rs, + struct berval *ndn, + Entry **ep, + Entry **matched ) { monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private; int rc; @@ -219,7 +211,9 @@ monitor_cache_dn2entry( } if ( !rc ) { + monitor_cache_lock( *ep ); monitor_cache_release( mi, e_parent ); + } else { *matched = e_parent; } @@ -234,8 +228,7 @@ monitor_cache_dn2entry( int monitor_cache_release( monitor_info_t *mi, - Entry *e -) + Entry *e ) { monitor_entry_t *mp; @@ -254,7 +247,9 @@ monitor_cache_release( mc = avl_delete( &mi->mi_cache, ( caddr_t )&tmp_mc, monitor_cache_cmp ); ldap_pvt_thread_mutex_unlock( &mi->mi_cache_mutex ); - ch_free( mc ); + if ( mc != NULL ) { + ch_free( mc ); + } ldap_pvt_thread_mutex_unlock( &mp->mp_mutex ); ldap_pvt_thread_mutex_destroy( &mp->mp_mutex ); @@ -270,3 +265,44 @@ monitor_cache_release( return( 0 ); } +static void +monitor_entry_destroy( void *v_mc ) +{ + monitor_cache_t *mc = (monitor_cache_t *)v_mc; + + if ( mc->mc_e != NULL ) { + monitor_entry_t *mp; + + assert( mc->mc_e->e_private != NULL ); + + mp = ( monitor_entry_t * )mc->mc_e->e_private; + + if ( mp->mp_cb ) { + if ( mp->mp_cb->mc_free ) { + mp->mp_cb->mc_free( mc->mc_e, + mp->mp_cb->mc_private ); + } + ch_free( mp->mp_cb ); + } + + ldap_pvt_thread_mutex_destroy( &mp->mp_mutex ); + + ch_free( mp ); + mc->mc_e->e_private = NULL; + entry_free( mc->mc_e ); + } + + ch_free( mc ); +} + +int +monitor_cache_destroy( + monitor_info_t *mi ) +{ + if ( mi->mi_cache ) { + avl_free( mi->mi_cache, monitor_entry_destroy ); + } + + return 0; +} + diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 670b015aec..b5fcab790a 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -32,11 +32,24 @@ #define MONITOR_LEGACY_CONN #endif +static int +monitor_subsys_conn_update( + Operation *op, + SlapReply *rs, + Entry *e ); + +static int +monitor_subsys_conn_create( + Operation *op, + SlapReply *rs, + struct berval *ndn, + Entry *e_parent, + Entry **ep ); + int monitor_subsys_conn_init( BackendDB *be, - monitor_subsys_t *ms -) + monitor_subsys_t *ms ) { monitor_info_t *mi; Entry *e, **ep, *e_conn; @@ -46,6 +59,9 @@ monitor_subsys_conn_init( assert( be != NULL ); + ms->mss_update = monitor_subsys_conn_update; + ms->mss_create = monitor_subsys_conn_create; + mi = ( monitor_info_t * )be->be_private; if ( monitor_cache_get( mi, &ms->mss_ndn, &e_conn ) ) { @@ -171,12 +187,11 @@ monitor_subsys_conn_init( return( 0 ); } -int +static int monitor_subsys_conn_update( Operation *op, SlapReply *rs, - Entry *e -) + Entry *e ) { monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private; @@ -185,8 +200,8 @@ monitor_subsys_conn_update( current_bv = BER_BVC( "cn=current" ); struct berval rdn; - assert( mi ); - assert( e ); + assert( mi != NULL ); + assert( e != NULL ); dnRdn( &e->e_nname, &rdn ); @@ -234,8 +249,7 @@ conn_create( monitor_info_t *mi, Connection *c, Entry **ep, - monitor_subsys_t *ms -) + monitor_subsys_t *ms ) { monitor_entry_t *mp; struct tm *ltm; @@ -427,12 +441,13 @@ conn_create( mi->mi_ad_monitorConnectionAuthzDN->ad_cname.bv_val, c->c_dn.bv_len ? c->c_dn.bv_val : SLAPD_ANONYMOUS, + /* NOTE: client connections leave the c_peer_* fields NULL */ mi->mi_ad_monitorConnectionListener->ad_cname.bv_val, c->c_listener_url.bv_val, mi->mi_ad_monitorConnectionPeerDomain->ad_cname.bv_val, - c->c_peer_domain.bv_val, + BER_BVISNULL( &c->c_peer_domain ) ? "unknown" : c->c_peer_domain.bv_val, mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val, - c->c_peer_name.bv_val, + BER_BVISNULL( &c->c_peer_name ) ? "unknown" : c->c_peer_name.bv_val, mi->mi_ad_monitorConnectionPeerAddress->ad_cname.bv_val, c->c_sock_name.bv_val, @@ -471,14 +486,13 @@ conn_create( return SLAP_CB_CONTINUE; } -int +static int monitor_subsys_conn_create( Operation *op, SlapReply *rs, struct berval *ndn, Entry *e_parent, - Entry **ep -) + Entry **ep ) { monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private; @@ -503,9 +517,11 @@ monitor_subsys_conn_create( /* create all the children of e_parent */ for ( c = connection_first( &connindex ); c != NULL; - c = connection_next( c, &connindex )) + c = connection_next( c, &connindex ) ) { - if ( conn_create( mi, c, &e, ms ) || e == NULL ) { + if ( conn_create( mi, c, &e, ms ) != SLAP_CB_CONTINUE + || e == NULL ) + { for ( ; e_tmp != NULL; ) { mp = ( monitor_entry_t * )e_tmp->e_private; e = mp->mp_next; @@ -523,7 +539,7 @@ monitor_subsys_conn_create( mp->mp_next = e_tmp; e_tmp = e; } - connection_done(c); + connection_done( c ); *ep = e; } else { diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index f6d5d94a80..ae234a143b 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -54,6 +54,12 @@ static int monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e ); #define PATH_MAX 4095 #endif /* ! PATH_MAX */ +static int +monitor_subsys_database_modify( + Operation *op, + SlapReply *rs, + Entry *e ); + static struct restricted_ops_t { struct berval op; unsigned int tag; @@ -129,6 +135,8 @@ monitor_subsys_database_init( assert( be != NULL ); + ms->mss_modify = monitor_subsys_database_modify; + mi = ( monitor_info_t * )be->be_private; ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME ); @@ -280,7 +288,7 @@ monitor_subsys_database_init( break; } } - assert( on2 ); + assert( on2 != NULL ); snprintf( buf, sizeof( buf ), "cn=Overlay %d,%s", @@ -429,7 +437,7 @@ monitor_subsys_database_init( break; } } - assert( on2 ); + assert( on2 != NULL ); snprintf( buf, sizeof( buf ), "dn: cn=Overlay %d,cn=Database %d,%s\n" @@ -545,12 +553,11 @@ value_mask( BerVarray v, slap_mask_t cur, slap_mask_t *delta ) return LDAP_SUCCESS; } -int +static int monitor_subsys_database_modify( Operation *op, SlapReply *rs, - Entry *e -) + Entry *e ) { monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private; int rc = LDAP_OTHER; diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index df6a08a990..ce8967c304 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -26,6 +26,7 @@ #include #include "slap.h" +#include "config.h" #include "lber_pvt.h" #include "back-monitor.h" @@ -61,6 +62,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_backend_init, + NULL, /* destroy */ NULL, /* update */ NULL, /* create */ NULL /* modify */ @@ -71,8 +73,9 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_VOLATILE_CH, monitor_subsys_conn_init, - monitor_subsys_conn_update, - monitor_subsys_conn_create, + NULL, /* destroy */ + NULL, /* update */ + NULL, /* create */ NULL /* modify */ }, { SLAPD_MONITOR_DATABASE_NAME, @@ -81,9 +84,10 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_database_init, + NULL, /* destroy */ NULL, /* update */ NULL, /* create */ - monitor_subsys_database_modify + NULL /* modify */ }, { SLAPD_MONITOR_LISTENER_NAME, BER_BVNULL, BER_BVNULL, BER_BVNULL, @@ -91,6 +95,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_listener_init, + NULL, /* destroy */ NULL, /* update */ NULL, /* create */ NULL /* modify */ @@ -102,9 +107,10 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_NONE, monitor_subsys_log_init, + NULL, /* destroy */ NULL, /* update */ NULL, /* create */ - monitor_subsys_log_modify + NULL, /* modify */ }, { SLAPD_MONITOR_OPS_NAME, BER_BVNULL, BER_BVNULL, BER_BVNULL, @@ -112,7 +118,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_ops_init, - monitor_subsys_ops_update, + NULL, /* destroy */ + NULL, /* update */ NULL, /* create */ NULL, /* modify */ }, { @@ -122,6 +129,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_overlay_init, + NULL, /* destroy */ NULL, /* update */ NULL, /* create */ NULL, /* modify */ @@ -132,6 +140,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_NONE, NULL, /* init */ + NULL, /* destroy */ NULL, /* update */ NULL, /* create */ NULL /* modify */ @@ -142,7 +151,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_sent_init, - monitor_subsys_sent_update, + NULL, /* destroy */ + NULL, /* update */ NULL, /* create */ NULL, /* modify */ }, { @@ -152,7 +162,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_thread_init, - monitor_subsys_thread_update, + NULL, /* destroy */ + NULL, /* update */ NULL, /* create */ NULL /* modify */ }, { @@ -162,7 +173,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_time_init, - monitor_subsys_time_update, + NULL, /* destroy */ + NULL, /* update */ NULL, /* create */ NULL, /* modify */ }, { @@ -172,6 +184,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_NONE, NULL, /* init */ + NULL, /* destroy */ NULL, /* update */ NULL, /* create */ NULL /* modify */ @@ -182,7 +195,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = { BER_BVNULL }, MONITOR_F_PERSISTENT_CH, monitor_subsys_rww_init, - monitor_subsys_rww_update, + NULL, /* destroy */ + NULL, /* update */ NULL, /* create */ NULL /* modify */ }, { NULL } @@ -216,7 +230,7 @@ monitor_back_register_subsys( /* FIXME: this should only be possible * if be_monitor is already initialized */ - assert( be_monitor ); + assert( be_monitor != NULL ); if ( ms->mss_open && ( *ms->mss_open )( be_monitor, ms ) ) { return -1; @@ -618,7 +632,11 @@ monitor_filter2ndn( op->o_tag = LDAP_REQ_SEARCH; /* use global malloc for now */ - op->o_tmpmemctx = NULL; + if ( op->o_tmpmemctx ) { + /* FIXME: connection_fake_init() calls slap_sl_mem_create, so we destroy it for now */ + slap_sl_mem_destroy( NULL, op->o_tmpmemctx ); + op->o_tmpmemctx = NULL; + } op->o_tmpmfuncs = &ch_mfuncs; op->o_bd = be_monitor; @@ -631,7 +649,7 @@ monitor_filter2ndn( } else { if ( dnPrettyNormal( NULL, base, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ) ) { - /* error */ + return -1; } } @@ -916,7 +934,7 @@ monitor_back_initialize( slap_mask_t flags; int offset; } moc[] = { - { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 " + { "monitor", "( 1.3.6.1.4.1.4203.666.3.16.1 " "NAME 'monitor' " "DESC 'OpenLDAP system monitoring' " "SUP top STRUCTURAL " @@ -930,44 +948,44 @@ monitor_back_initialize( "$ monitorOverlay " ") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, offsetof(monitor_info_t, mi_oc_monitor) }, - { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 " + { "monitorServer", "( 1.3.6.1.4.1.4203.666.3.16.2 " "NAME 'monitorServer' " "DESC 'Server monitoring root entry' " "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, offsetof(monitor_info_t, mi_oc_monitorServer) }, - { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.8 " + { "monitorContainer", "( 1.3.6.1.4.1.4203.666.3.16.3 " "NAME 'monitorContainer' " "DESC 'monitor container class' " "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, offsetof(monitor_info_t, mi_oc_monitorContainer) }, - { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.9 " + { "monitorCounterObject", "( 1.3.6.1.4.1.4203.666.3.16.4 " "NAME 'monitorCounterObject' " "DESC 'monitor counter class' " "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, offsetof(monitor_info_t, mi_oc_monitorCounterObject) }, - { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.10 " + { "monitorOperation", "( 1.3.6.1.4.1.4203.666.3.16.5 " "NAME 'monitorOperation' " "DESC 'monitor operation class' " "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, offsetof(monitor_info_t, mi_oc_monitorOperation) }, - { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.11 " + { "monitorConnection", "( 1.3.6.1.4.1.4203.666.3.16.6 " "NAME 'monitorConnection' " "DESC 'monitor connection class' " "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, offsetof(monitor_info_t, mi_oc_monitorConnection) }, - { "managedObject", "( 1.3.6.1.4.1.4203.666.3.12 " + { "managedObject", "( 1.3.6.1.4.1.4203.666.3.16.7 " "NAME 'managedObject' " "DESC 'monitor managed entity class' " "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, offsetof(monitor_info_t, mi_oc_managedObject) }, - { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.14 " + { "monitoredObject", "( 1.3.6.1.4.1.4203.666.3.16.8 " "NAME 'monitoredObject' " "DESC 'monitor monitored entity class' " "SUP monitor STRUCTURAL )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE, offsetof(monitor_info_t, mi_oc_monitoredObject) }, { NULL, NULL, 0, -1 } }, mat[] = { - { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.14 " + { "monitoredInfo", "( 1.3.6.1.4.1.4203.666.1.55.1 " "NAME 'monitoredInfo' " "DESC 'monitored info' " /* "SUP name " */ @@ -977,12 +995,12 @@ monitor_back_initialize( "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitoredInfo) }, - { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.15 " + { "managedInfo", "( 1.3.6.1.4.1.4203.666.1.55.2 " "NAME 'managedInfo' " "DESC 'monitor managed info' " "SUP name )", SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_managedInfo) }, - { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.16 " + { "monitorCounter", "( 1.3.6.1.4.1.4203.666.1.55.3 " "NAME 'monitorCounter' " "DESC 'monitor counter' " "EQUALITY integerMatch " @@ -991,28 +1009,28 @@ monitor_back_initialize( "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorCounter) }, - { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.17 " + { "monitorOpCompleted", "( 1.3.6.1.4.1.4203.666.1.55.4 " "NAME 'monitorOpCompleted' " "DESC 'monitor completed operations' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorOpCompleted) }, - { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.18 " + { "monitorOpInitiated", "( 1.3.6.1.4.1.4203.666.1.55.5 " "NAME 'monitorOpInitiated' " "DESC 'monitor initiated operations' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorOpInitiated) }, - { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.19 " + { "monitorConnectionNumber", "( 1.3.6.1.4.1.4203.666.1.55.6 " "NAME 'monitorConnectionNumber' " "DESC 'monitor connection number' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionNumber) }, - { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.20 " + { "monitorConnectionAuthzDN", "( 1.3.6.1.4.1.4203.666.1.55.7 " "NAME 'monitorConnectionAuthzDN' " "DESC 'monitor connection authorization DN' " /* "SUP distinguishedName " */ @@ -1021,21 +1039,21 @@ monitor_back_initialize( "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionAuthzDN) }, - { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.21 " + { "monitorConnectionLocalAddress", "( 1.3.6.1.4.1.4203.666.1.55.8 " "NAME 'monitorConnectionLocalAddress' " "DESC 'monitor connection local address' " "SUP monitoredInfo " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionLocalAddress) }, - { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.22 " + { "monitorConnectionPeerAddress", "( 1.3.6.1.4.1.4203.666.1.55.9 " "NAME 'monitorConnectionPeerAddress' " "DESC 'monitor connection peer address' " "SUP monitoredInfo " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionPeerAddress) }, - { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.24 " + { "monitorTimestamp", "( 1.3.6.1.4.1.4203.666.1.55.10 " "NAME 'monitorTimestamp' " "DESC 'monitor timestamp' " "EQUALITY generalizedTimeMatch " @@ -1045,14 +1063,14 @@ monitor_back_initialize( "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorTimestamp) }, - { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 " + { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.55.11 " "NAME 'monitorOverlay' " "DESC 'name of overlays defined for a given database' " "SUP monitoredInfo " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorOverlay) }, - { "readOnly", "( 1.3.6.1.4.1.4203.666.1.31 " + { "readOnly", "( 1.3.6.1.4.1.4203.666.1.55.12 " "NAME 'readOnly' " "DESC 'read/write status of a given database' " "EQUALITY booleanMatch " @@ -1060,89 +1078,89 @@ monitor_back_initialize( "SINGLE-VALUE " "USAGE directoryOperation )", SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_readOnly) }, - { "restrictedOperation", "( 1.3.6.1.4.1.4203.666.1.32 " + { "restrictedOperation", "( 1.3.6.1.4.1.4203.666.1.55.13 " "NAME 'restrictedOperation' " "DESC 'name of restricted operation for a given database' " "SUP managedInfo )", SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_restrictedOperation ) }, - { "monitorConnectionProtocol", "( 1.3.6.1.4.1.4203.666.1.39 " + { "monitorConnectionProtocol", "( 1.3.6.1.4.1.4203.666.1.55.14 " "NAME 'monitorConnectionProtocol' " "DESC 'monitor connection protocol' " "SUP monitoredInfo " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionProtocol) }, - { "monitorConnectionOpsReceived", "( 1.3.6.1.4.1.4203.666.1.40 " + { "monitorConnectionOpsReceived", "( 1.3.6.1.4.1.4203.666.1.55.15 " "NAME 'monitorConnectionOpsReceived' " "DESC 'monitor number of operations received by the connection' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionOpsReceived) }, - { "monitorConnectionOpsExecuting", "( 1.3.6.1.4.1.4203.666.1.41 " + { "monitorConnectionOpsExecuting", "( 1.3.6.1.4.1.4203.666.1.55.16 " "NAME 'monitorConnectionOpsExecuting' " "DESC 'monitor number of operations in execution within the connection' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionOpsExecuting) }, - { "monitorConnectionOpsPending", "( 1.3.6.1.4.1.4203.666.1.42 " + { "monitorConnectionOpsPending", "( 1.3.6.1.4.1.4203.666.1.55.17 " "NAME 'monitorConnectionOpsPending' " "DESC 'monitor number of pending operations within the connection' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionOpsPending) }, - { "monitorConnectionOpsCompleted", "( 1.3.6.1.4.1.4203.666.1.43 " + { "monitorConnectionOpsCompleted", "( 1.3.6.1.4.1.4203.666.1.55.18 " "NAME 'monitorConnectionOpsCompleted' " "DESC 'monitor number of operations completed within the connection' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionOpsCompleted) }, - { "monitorConnectionGet", "( 1.3.6.1.4.1.4203.666.1.44 " + { "monitorConnectionGet", "( 1.3.6.1.4.1.4203.666.1.55.19 " "NAME 'monitorConnectionGet' " "DESC 'number of times connection_get() was called so far' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionGet) }, - { "monitorConnectionRead", "( 1.3.6.1.4.1.4203.666.1.45 " + { "monitorConnectionRead", "( 1.3.6.1.4.1.4203.666.1.55.20 " "NAME 'monitorConnectionRead' " "DESC 'number of times connection_read() was called so far' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionRead) }, - { "monitorConnectionWrite", "( 1.3.6.1.4.1.4203.666.1.46 " + { "monitorConnectionWrite", "( 1.3.6.1.4.1.4203.666.1.55.21 " "NAME 'monitorConnectionWrite' " "DESC 'number of times connection_write() was called so far' " "SUP monitorCounter " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionWrite) }, - { "monitorConnectionMask", "( 1.3.6.1.4.1.4203.666.1.47 " + { "monitorConnectionMask", "( 1.3.6.1.4.1.4203.666.1.55.22 " "NAME 'monitorConnectionMask' " "DESC 'monitor connection mask' " "SUP monitoredInfo " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionMask) }, - { "monitorConnectionListener", "( 1.3.6.1.4.1.4203.666.1.48 " + { "monitorConnectionListener", "( 1.3.6.1.4.1.4203.666.1.55.23 " "NAME 'monitorConnectionListener' " "DESC 'monitor connection listener' " "SUP monitoredInfo " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionListener) }, - { "monitorConnectionPeerDomain", "( 1.3.6.1.4.1.4203.666.1.49 " + { "monitorConnectionPeerDomain", "( 1.3.6.1.4.1.4203.666.1.55.24 " "NAME 'monitorConnectionPeerDomain' " "DESC 'monitor connection peer domain' " "SUP monitoredInfo " "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionPeerDomain) }, - { "monitorConnectionStartTime", "( 1.3.6.1.4.1.4203.666.1.50 " + { "monitorConnectionStartTime", "( 1.3.6.1.4.1.4203.666.1.55.25 " "NAME 'monitorConnectionStartTime' " "DESC 'monitor connection start time' " "SUP monitorTimestamp " @@ -1150,7 +1168,7 @@ monitor_back_initialize( "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionStartTime) }, - { "monitorConnectionActivityTime", "( 1.3.6.1.4.1.4203.666.1.51 " + { "monitorConnectionActivityTime", "( 1.3.6.1.4.1.4203.666.1.55.26 " "NAME 'monitorConnectionActivityTime' " "DESC 'monitor connection activity time' " "SUP monitorTimestamp " @@ -1158,7 +1176,7 @@ monitor_back_initialize( "NO-USER-MODIFICATION " "USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorConnectionActivityTime) }, - { "monitorIsShadow", "( 1.3.6.1.4.1.4203.666.1.52 " + { "monitorIsShadow", "( 1.3.6.1.4.1.4203.666.1.55.27 " "NAME 'monitorIsShadow' " "DESC 'TRUE if the database is shadow' " "EQUALITY booleanMatch " @@ -1166,16 +1184,38 @@ monitor_back_initialize( "SINGLE-VALUE " "USAGE directoryOperation )", SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorIsShadow) }, - { "monitorUpdateRef", "( 1.3.6.1.4.1.4203.666.1.53 " + { "monitorUpdateRef", "( 1.3.6.1.4.1.4203.666.1.55.28 " "NAME 'monitorUpdateRef' " "DESC 'update referral for shadow databases' " "SUP monitoredInfo " "SINGLE-VALUE " "USAGE directoryOperation )", SLAP_AT_HIDE, offsetof(monitor_info_t, mi_ad_monitorUpdateRef) }, + { "monitorRuntimeConfig", "( 1.3.6.1.4.1.4203.666.1.55.29 " + "NAME 'monitorRuntimeConfig' " + "DESC 'TRUE if component allows runtime configuration' " + "EQUALITY booleanMatch " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 " + "SINGLE-VALUE " + "USAGE directoryOperation )", SLAP_AT_HIDE, + offsetof(monitor_info_t, mi_ad_monitorRuntimeConfig) }, { NULL, NULL, 0, -1 } }; - + static ConfigTable monitorcfg[] = { + { NULL, NULL, 0, 0, 0, ARG_IGNORED, + NULL, NULL, NULL, NULL } + }; + static ConfigOCs monitorocs[] = { + { "( OLcfgDbOc:4.1 " + "NAME 'olcMonitorConfig' " + "DESC 'Monitor backend configuration' " + "SUP olcDatabaseConfig " + ")", + Cft_Database, monitorcfg }, + { NULL, 0, NULL } + }; + int rc; + bi->bi_controls = controls; bi->bi_init = 0; @@ -1224,6 +1264,19 @@ monitor_back_initialize( bi->bi_connection_init = 0; bi->bi_connection_destroy = 0; + /* + * configuration objectClasses (fake) + */ + bi->bi_cf_ocs = monitorocs; + + rc = config_register_schema( monitorcfg, monitorocs ); + if ( rc ) { + return rc; + } + + /* + * register subsys + */ for ( ms = known_monitor_subsys; ms->mss_name != NULL; ms++ ) { if ( monitor_back_register_subsys( ms ) ) { return -1; @@ -1326,7 +1379,6 @@ int monitor_back_db_init( BackendDB *be ) { - monitor_info_t *mi; int rc; struct berval dn, ndn; struct berval bv; @@ -1350,8 +1402,8 @@ monitor_back_db_init( rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, - "unable to normalize monitor DN \"%s\"\n", - SLAPD_MONITOR_DN, 0, 0 ); + "unable to normalize monitor DN \"%s\" (%d)\n", + dn.bv_val, rc, 0 ); return -1; } @@ -1361,11 +1413,9 @@ monitor_back_db_init( /* NOTE: only one monitor database is allowed, * so we use static storage */ - mi = &monitor_info; - - ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex ); + ldap_pvt_thread_mutex_init( &monitor_info.mi_cache_mutex ); - be->be_private = mi; + be->be_private = &monitor_info; return 0; } @@ -1387,7 +1437,7 @@ monitor_back_db_open( #endif static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; - assert( be_monitor ); + assert( be_monitor != NULL ); if ( be != be_monitor ) { be_monitor = be; } @@ -1590,7 +1640,7 @@ monitor_back_db_open( ep = &mp->mp_next; } - assert( be ); + assert( be != NULL ); be->be_private = mi; @@ -1702,7 +1752,9 @@ monitor_back_db_config( int argc, char **argv ) { +#if 0 monitor_info_t *mi = ( monitor_info_t * )be->be_private; +#endif /* * eventually, will hold database specific configuration parameters @@ -1716,11 +1768,37 @@ monitor_back_db_destroy( { monitor_info_t *mi = ( monitor_info_t * )be->be_private; + if ( mi == NULL ) { + return -1; + } + /* * FIXME: destroys all the data */ /* NOTE: mi points to static storage; don't free it */ + (void)monitor_cache_destroy( mi ); + + if ( monitor_subsys ) { + int i; + + for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) { + if ( monitor_subsys[ i ]->mss_destroy ) { + monitor_subsys[ i ]->mss_destroy( be, monitor_subsys[ i ] ); + } + + if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_rdn ) ) { + ch_free( monitor_subsys[ i ]->mss_rdn.bv_val ); + } + } + + ch_free( monitor_subsys ); + } + + ldap_pvt_thread_mutex_destroy( &monitor_info.mi_cache_mutex ); + + be->be_private = NULL; + return 0; } diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index d54b572ee7..6a390891d4 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -31,6 +31,17 @@ #include "ldif.h" #include "back-monitor.h" +static int +monitor_subsys_log_destroy( + BackendDB *be, + monitor_subsys_t *ms ); + +static int +monitor_subsys_log_modify( + Operation *op, + SlapReply *rs, + Entry *e ); + /* * log mutex */ @@ -77,6 +88,9 @@ monitor_subsys_log_init( Entry *e; int i; + ms->mss_destroy = monitor_subsys_log_destroy; + ms->mss_modify = monitor_subsys_log_modify; + ldap_pvt_thread_mutex_init( &monitor_log_mutex ); mi = ( monitor_info_t * )be->be_private; @@ -118,7 +132,23 @@ monitor_subsys_log_init( return( 0 ); } -int +static int +monitor_subsys_log_destroy( + BackendDB *be, + monitor_subsys_t *ms ) +{ + int i; + + for ( i = 0; int_2_level[ i ].i != 0; i++ ) { + if ( !BER_BVISNULL( &int_2_level[ i ].n ) ) { + ch_free( int_2_level[ i ].n.bv_val ); + } + } + + return 0; +} + +static int monitor_subsys_log_modify( Operation *op, SlapReply *rs, @@ -197,7 +227,7 @@ monitor_subsys_log_modify( } /* check that the entry still obeys the schema */ - rc = entry_schema_check( be_monitor, e, save_attrs, 0, + rc = entry_schema_check( op, e, save_attrs, 0, &text, textbuf, sizeof( textbuf ) ); if ( rc != LDAP_SUCCESS ) { rs->sr_err = rc; diff --git a/servers/slapd/back-monitor/operation.c b/servers/slapd/back-monitor/operation.c index a5ac6cf8a5..f7aa7c6483 100644 --- a/servers/slapd/back-monitor/operation.c +++ b/servers/slapd/back-monitor/operation.c @@ -45,11 +45,21 @@ struct monitor_ops_t { { BER_BVNULL, BER_BVNULL } }; +static int +monitor_subsys_ops_destroy( + BackendDB *be, + monitor_subsys_t *ms ); + +static int +monitor_subsys_ops_update( + Operation *op, + SlapReply *rs, + Entry *e ); + int monitor_subsys_ops_init( BackendDB *be, - monitor_subsys_t *ms -) + monitor_subsys_t *ms ) { monitor_info_t *mi; @@ -61,6 +71,9 @@ monitor_subsys_ops_init( assert( be != NULL ); + ms->mss_destroy = monitor_subsys_ops_destroy; + ms->mss_update = monitor_subsys_ops_update; + mi = ( monitor_info_t * )be->be_private; if ( monitor_cache_get( mi, @@ -152,12 +165,27 @@ monitor_subsys_ops_init( return( 0 ); } -int +static int +monitor_subsys_ops_destroy( + BackendDB *be, + monitor_subsys_t *ms ) +{ + int i; + + for ( i = 0; i < SLAP_OP_LAST; i++ ) { + if ( !BER_BVISNULL( &monitor_op[ i ].nrdn ) ) { + ch_free( monitor_op[ i ].nrdn.bv_val ); + } + } + + return 0; +} + +static int monitor_subsys_ops_update( Operation *op, SlapReply *rs, - Entry *e -) + Entry *e ) { monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private; @@ -168,8 +196,8 @@ monitor_subsys_ops_update( Attribute *a; static struct berval bv_ops = BER_BVC( "cn=operations" ); - assert( mi ); - assert( e ); + assert( mi != NULL ); + assert( e != NULL ); dnRdn( &e->e_nname, &rdn ); diff --git a/servers/slapd/back-monitor/operational.c b/servers/slapd/back-monitor/operational.c index 2437b5f230..b59399f650 100644 --- a/servers/slapd/back-monitor/operational.c +++ b/servers/slapd/back-monitor/operational.c @@ -41,7 +41,7 @@ monitor_back_operational( { Attribute **ap; - assert( rs->sr_entry ); + assert( rs->sr_entry != NULL ); for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) /* just count */ ; @@ -54,11 +54,11 @@ monitor_back_operational( mp = ( monitor_entry_t * )rs->sr_entry->e_private; - assert( mp ); + assert( mp != NULL ); hs = MONITOR_HAS_CHILDREN( mp ); *ap = slap_operational_hasSubordinate( hs ); - assert( *ap ); + assert( *ap != NULL ); ap = &(*ap)->a_next; } diff --git a/servers/slapd/back-monitor/overlay.c b/servers/slapd/back-monitor/overlay.c index 568a808d2a..bc6610a7b8 100644 --- a/servers/slapd/back-monitor/overlay.c +++ b/servers/slapd/back-monitor/overlay.c @@ -80,6 +80,8 @@ monitor_subsys_overlay_init( "objectClass: %s\n" "structuralObjectClass: %s\n" "cn: Overlay %d\n" + "%s: %s\n" + "%s: %s\n" "creatorsName: %s\n" "modifiersName: %s\n" "createTimestamp: %s\n" @@ -89,6 +91,10 @@ monitor_subsys_overlay_init( mi->mi_oc_monitoredObject->soc_cname.bv_val, mi->mi_oc_monitoredObject->soc_cname.bv_val, i, + mi->mi_ad_monitoredInfo->ad_cname.bv_val, + on->on_bi.bi_type, + mi->mi_ad_monitorRuntimeConfig->ad_cname.bv_val, + on->on_bi.bi_cf_ocs ? "TRUE" : "FALSE", mi->mi_creatorsName.bv_val, mi->mi_creatorsName.bv_val, mi->mi_startTime.bv_val, @@ -104,8 +110,6 @@ monitor_subsys_overlay_init( } ber_str2bv( on->on_bi.bi_type, 0, 0, &bv ); - attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, - &bv, NULL ); attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo, &bv, NULL ); diff --git a/servers/slapd/back-monitor/proto-back-monitor.h b/servers/slapd/back-monitor/proto-back-monitor.h index d73bf61d6b..70007135bd 100644 --- a/servers/slapd/back-monitor/proto-back-monitor.h +++ b/servers/slapd/back-monitor/proto-back-monitor.h @@ -68,6 +68,10 @@ monitor_cache_release LDAP_P(( monitor_info_t *mi, Entry *e )); +extern int +monitor_cache_destroy LDAP_P(( + monitor_info_t *mi )); + /* * connections */ @@ -75,18 +79,6 @@ extern int monitor_subsys_conn_init LDAP_P(( BackendDB *be, monitor_subsys_t *ms )); -extern int -monitor_subsys_conn_update LDAP_P(( - Operation *op, - SlapReply *rs, - Entry *e )); -extern int -monitor_subsys_conn_create LDAP_P(( - Operation *op, - SlapReply *rs, - struct berval *ndn, - Entry *e_parent, - Entry **ep )); /* * databases @@ -95,11 +87,6 @@ extern int monitor_subsys_database_init LDAP_P(( BackendDB *be, monitor_subsys_t *ms )); -extern int -monitor_subsys_database_modify LDAP_P(( - Operation *op, - SlapReply *rs, - Entry *e )); /* * entry @@ -190,11 +177,6 @@ extern int monitor_subsys_log_init LDAP_P(( BackendDB *be, monitor_subsys_t *ms )); -extern int -monitor_subsys_log_modify LDAP_P(( - Operation *op, - SlapReply *rs, - Entry *e )); /* * operations @@ -203,11 +185,6 @@ extern int monitor_subsys_ops_init LDAP_P(( BackendDB *be, monitor_subsys_t *ms )); -extern int -monitor_subsys_ops_update LDAP_P(( - Operation *op, - SlapReply *rs, - Entry *e )); /* * overlay @@ -224,11 +201,6 @@ extern int monitor_subsys_sent_init LDAP_P(( BackendDB *be, monitor_subsys_t *ms )); -extern int -monitor_subsys_sent_update LDAP_P(( - Operation *op, - SlapReply *rs, - Entry *e )); /* * threads @@ -237,11 +209,6 @@ extern int monitor_subsys_thread_init LDAP_P(( BackendDB *be, monitor_subsys_t *ms )); -extern int -monitor_subsys_thread_update LDAP_P(( - Operation *op, - SlapReply *rs, - Entry *e )); /* * time @@ -249,11 +216,6 @@ monitor_subsys_thread_update LDAP_P(( extern int monitor_subsys_time_init LDAP_P(( BackendDB *be, monitor_subsys_t *ms )); -extern int -monitor_subsys_time_update LDAP_P(( - Operation *op, - SlapReply *rs, - Entry *e )); /* * waiters @@ -262,11 +224,6 @@ extern int monitor_subsys_rww_init LDAP_P(( BackendDB *be, monitor_subsys_t *ms )); -extern int -monitor_subsys_rww_update LDAP_P(( - Operation *op, - SlapReply *rs, - Entry *e )); /* * former external.h diff --git a/servers/slapd/back-monitor/rww.c b/servers/slapd/back-monitor/rww.c index b8f82ab049..0edea5d079 100644 --- a/servers/slapd/back-monitor/rww.c +++ b/servers/slapd/back-monitor/rww.c @@ -28,6 +28,12 @@ #include "lutil.h" #include "back-monitor.h" +static int +monitor_subsys_rww_update( + Operation *op, + SlapReply *rs, + Entry *e ); + enum { MONITOR_RWW_READ = 0, MONITOR_RWW_WRITE, @@ -58,6 +64,8 @@ monitor_subsys_rww_init( assert( be != NULL ); + ms->mss_update = monitor_subsys_rww_update; + mi = ( monitor_info_t * )be->be_private; if ( monitor_cache_get( mi, &ms->mss_ndn, &e_conn ) ) { @@ -139,12 +147,11 @@ monitor_subsys_rww_init( return( 0 ); } -int +static int monitor_subsys_rww_update( Operation *op, SlapReply *rs, - Entry *e -) + Entry *e ) { monitor_info_t *mi = (monitor_info_t *)op->o_bd->be_private; Connection *c; @@ -206,7 +213,7 @@ monitor_subsys_rww_update( snprintf( buf, sizeof( buf ), "%ld", num ); a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter ); - assert( a ); + assert( a != NULL ); len = strlen( buf ); if ( len > a->a_vals[ 0 ].bv_len ) { a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 ); diff --git a/servers/slapd/back-monitor/search.c b/servers/slapd/back-monitor/search.c index d2e7982c00..591287d06c 100644 --- a/servers/slapd/back-monitor/search.c +++ b/servers/slapd/back-monitor/search.c @@ -39,14 +39,17 @@ monitor_send_children( ) { monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private; - Entry *e, *e_tmp, *e_ch; + Entry *e, + *e_tmp, + *e_ch = NULL, + *e_nonvolatile = NULL; monitor_entry_t *mp; - int rc; + int rc, + nonvolatile = 0; mp = ( monitor_entry_t * )e_parent->e_private; - e = mp->mp_children; + e_nonvolatile = e = mp->mp_children; - e_ch = NULL; if ( MONITOR_HAS_VOLATILE_CH( mp ) ) { monitor_entry_create( op, rs, NULL, e_parent, &e_ch ); } @@ -64,7 +67,6 @@ monitor_send_children( /* if no persistent, return only volatile */ if ( e == NULL ) { e = e_ch; - monitor_cache_lock( e_ch ); /* else append persistent to volatile */ } else { @@ -83,13 +85,27 @@ monitor_send_children( } /* return entries */ - for ( ; e != NULL; ) { - mp = ( monitor_entry_t * )e->e_private; - + for ( monitor_cache_lock( e ); e != NULL; ) { monitor_entry_update( op, rs, e ); if ( op->o_abandon ) { - monitor_cache_release( mi, e ); + /* FIXME: may leak generated children */ + if ( nonvolatile == 0 ) { + for ( e_tmp = e; e_tmp != NULL; ) { + mp = ( monitor_entry_t * )e_tmp->e_private; + e = e_tmp; + e_tmp = mp->mp_next; + monitor_cache_release( mi, e ); + + if ( e_tmp == e_nonvolatile ) { + break; + } + } + + } else { + monitor_cache_release( mi, e ); + } + return SLAPD_ABANDON; } @@ -101,22 +117,43 @@ monitor_send_children( rs->sr_entry = NULL; } - if ( ( mp->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) ) - && sub ) - { + mp = ( monitor_entry_t * )e->e_private; + e_tmp = mp->mp_next; + + if ( sub ) { rc = monitor_send_children( op, rs, e, sub ); if ( rc ) { - monitor_cache_release( mi, e ); + /* FIXME: may leak generated children */ + if ( nonvolatile == 0 ) { + for ( ; e_tmp != NULL; ) { + mp = ( monitor_entry_t * )e_tmp->e_private; + e = e_tmp; + e_tmp = mp->mp_next; + monitor_cache_release( mi, e ); + + if ( e_tmp == e_nonvolatile ) { + break; + } + } + } + return( rc ); } } - e_tmp = mp->mp_next; if ( e_tmp != NULL ) { monitor_cache_lock( e_tmp ); } - monitor_cache_release( mi, e ); + + if ( !sub ) { + /* otherwise the recursive call already released */ + monitor_cache_release( mi, e ); + } + e = e_tmp; + if ( e == e_nonvolatile ) { + nonvolatile = 1; + } } return LDAP_SUCCESS; diff --git a/servers/slapd/back-monitor/sent.c b/servers/slapd/back-monitor/sent.c index 6600ee6ae1..f6c0a9f17f 100644 --- a/servers/slapd/back-monitor/sent.c +++ b/servers/slapd/back-monitor/sent.c @@ -27,6 +27,17 @@ #include "slap.h" #include "back-monitor.h" +static int +monitor_subsys_sent_destroy( + BackendDB *be, + monitor_subsys_t *ms ); + +static int +monitor_subsys_sent_update( + Operation *op, + SlapReply *rs, + Entry *e ); + enum { MONITOR_SENT_BYTES = 0, MONITOR_SENT_PDU, @@ -50,8 +61,7 @@ struct monitor_sent_t { int monitor_subsys_sent_init( BackendDB *be, - monitor_subsys_t *ms -) + monitor_subsys_t *ms ) { monitor_info_t *mi; @@ -61,6 +71,9 @@ monitor_subsys_sent_init( assert( be != NULL ); + ms->mss_destroy = monitor_subsys_sent_destroy; + ms->mss_update = monitor_subsys_sent_update; + mi = ( monitor_info_t * )be->be_private; if ( monitor_cache_get( mi, &ms->mss_ndn, &e_sent ) ) { @@ -143,7 +156,23 @@ monitor_subsys_sent_init( return( 0 ); } -int +static int +monitor_subsys_sent_destroy( + BackendDB *be, + monitor_subsys_t *ms ) +{ + int i; + + for ( i = 0; i < MONITOR_SENT_LAST; i++ ) { + if ( !BER_BVISNULL( &monitor_sent[ i ].nrdn ) ) { + ch_free( monitor_sent[ i ].nrdn.bv_val ); + } + } + + return 0; +} + +static int monitor_subsys_sent_update( Operation *op, SlapReply *rs, @@ -156,8 +185,8 @@ monitor_subsys_sent_update( Attribute *a; int i; - assert( mi ); - assert( e ); + assert( mi != NULL ); + assert( e != NULL ); dnRdn( &e->e_nname, &nrdn ); @@ -195,7 +224,7 @@ monitor_subsys_sent_update( ldap_pvt_thread_mutex_unlock(&slap_counters.sc_sent_mutex); a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter ); - assert( a ); + assert( a != NULL ); /* NOTE: no minus sign is allowed in the counters... */ UI2BV( &a->a_vals[ 0 ], n ); diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index 5d393a8e19..c76acaa864 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -29,9 +29,15 @@ #include +static int +monitor_subsys_thread_update( + Operation *op, + SlapReply *rs, + Entry *e ); + /* -* * initializes log subentry -* */ + * initializes log subentry + */ int monitor_subsys_thread_init( BackendDB *be, @@ -43,6 +49,8 @@ monitor_subsys_thread_init( Entry *e, **ep, *e_thread; static char buf[ BACKMONITOR_BUFSIZE ]; + ms->mss_update = monitor_subsys_thread_update; + mi = ( monitor_info_t * )be->be_private; if ( monitor_cache_get( mi, &ms->mss_ndn, &e_thread ) ) { @@ -216,12 +224,11 @@ monitor_subsys_thread_init( return( 0 ); } -int +static int monitor_subsys_thread_update( Operation *op, SlapReply *rs, - Entry *e -) + Entry *e ) { monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private; Attribute *a; diff --git a/servers/slapd/back-monitor/time.c b/servers/slapd/back-monitor/time.c index 685365c9eb..61273a6839 100644 --- a/servers/slapd/back-monitor/time.c +++ b/servers/slapd/back-monitor/time.c @@ -31,11 +31,16 @@ #include "proto-slap.h" #include "back-monitor.h" +static int +monitor_subsys_time_update( + Operation *op, + SlapReply *rs, + Entry *e ); + int monitor_subsys_time_init( BackendDB *be, - monitor_subsys_t *ms -) + monitor_subsys_t *ms ) { monitor_info_t *mi; @@ -45,6 +50,8 @@ monitor_subsys_time_init( assert( be != NULL ); + ms->mss_update = monitor_subsys_time_update; + mi = ( monitor_info_t * )be->be_private; if ( monitor_cache_get( mi, @@ -166,7 +173,7 @@ monitor_subsys_time_init( return( 0 ); } -int +static int monitor_subsys_time_update( Operation *op, SlapReply *rs, @@ -176,8 +183,8 @@ monitor_subsys_time_update( static struct berval bv_current = BER_BVC( "cn=current" ); struct berval rdn; - assert( mi ); - assert( e ); + assert( mi != NULL ); + assert( e != NULL ); dnRdn( &e->e_nname, &rdn ); diff --git a/servers/slapd/back-perl/compare.c b/servers/slapd/back-perl/compare.c index 75ade4a965..f28605f627 100644 --- a/servers/slapd/back-perl/compare.c +++ b/servers/slapd/back-perl/compare.c @@ -30,7 +30,7 @@ perl_back_compare( SlapReply *rs ) { int count; - char *avastr, *ptr; + char *avastr; PerlBackend *perl_back = (PerlBackend *)op->o_bd->be_private; diff --git a/servers/slapd/back-relay/init.c b/servers/slapd/back-relay/init.c index d3b19e6d49..b458740d7f 100644 --- a/servers/slapd/back-relay/init.c +++ b/servers/slapd/back-relay/init.c @@ -100,7 +100,7 @@ relay_back_db_open( Backend *be ) ri->ri_bd = select_backend( &ri->ri_realsuffix, 0, 1 ); /* must be there: it was during config! */ - assert( ri->ri_bd ); + assert( ri->ri_bd != NULL ); /* inherit controls */ AC_MEMCPY( be->be_ctrls, ri->ri_bd->be_ctrls, sizeof( be->be_ctrls ) ); diff --git a/servers/slapd/back-sql/add.c b/servers/slapd/back-sql/add.c index 0a5e44561c..d8f3842366 100644 --- a/servers/slapd/back-sql/add.c +++ b/servers/slapd/back-sql/add.c @@ -66,7 +66,7 @@ backsql_modify_delete_all_values( SQLHSTMT asth = SQL_NULL_HSTMT; BACKSQL_ROW_NTS row; - assert( at ); + assert( at != NULL ); if ( at->bam_delete_proc == NULL ) { Debug( LDAP_DEBUG_TRACE, " backsql_modify_delete_all_values(): " @@ -124,16 +124,17 @@ backsql_modify_delete_all_values( return rs->sr_err = LDAP_OTHER; } - backsql_BindRowAsStrings( asth, &row ); + backsql_BindRowAsStrings_x( asth, &row, op->o_tmpmemctx ); for ( rc = SQLFetch( asth ); BACKSQL_SUCCESS( rc ); rc = SQLFetch( asth ) ) { - int i; + int i; /* first parameter no, parameter order */ - SQLUSMALLINT pno, po; + SQLUSMALLINT pno = 0, + po = 0; /* procedure return code */ - int prc = LDAP_SUCCESS; + int prc = LDAP_SUCCESS; for ( i = 0; i < row.ncols; i++ ) { SQLHSTMT sth = SQL_NULL_HSTMT; @@ -151,7 +152,8 @@ backsql_modify_delete_all_values( sth, rc ); rs->sr_text = "SQL-backend error"; - return rs->sr_err = LDAP_OTHER; + rs->sr_err = LDAP_OTHER; + goto done; } if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) { @@ -168,11 +170,9 @@ backsql_modify_delete_all_values( SQLFreeStmt( sth, SQL_DROP ); rs->sr_text = "SQL-backend error"; - return rs->sr_err = LDAP_OTHER; + rs->sr_err = LDAP_OTHER; + goto done; } - - } else { - pno = 0; } po = ( BACKSQL_IS_DEL( at->bam_param_order ) ) > 0; rc = backsql_BindParamID( sth, pno + 1 + po, @@ -187,17 +187,18 @@ backsql_modify_delete_all_values( SQLFreeStmt( sth, SQL_DROP ); rs->sr_text = "SQL-backend error"; - return rs->sr_err = LDAP_OTHER; + rs->sr_err = LDAP_OTHER; + goto done; } #ifdef BACKSQL_ARBITRARY_KEY Debug( LDAP_DEBUG_TRACE, " backsql_modify_delete_all_values() " - "arg%d=%s\n", + "arg(%d)=%s\n", pno + 1 + po, e_id->eid_keyval.bv_val, 0 ); #else /* ! BACKSQL_ARBITRARY_KEY */ Debug( LDAP_DEBUG_TRACE, " backsql_modify_delete_all_values() " - "arg%d=%lu\n", + "arg(%d)=%lu\n", pno + 1 + po, e_id->eid_keyval, 0 ); #endif /* ! BACKSQL_ARBITRARY_KEY */ @@ -218,12 +219,13 @@ backsql_modify_delete_all_values( SQLFreeStmt( sth, SQL_DROP ); rs->sr_text = "SQL-backend error"; - return rs->sr_err = LDAP_OTHER; + rs->sr_err = LDAP_OTHER; + goto done; } Debug( LDAP_DEBUG_TRACE, " backsql_modify_delete_all_values(): " - "arg%d=%s; executing \"%s\"\n", + "arg(%d)=%s; executing \"%s\"\n", pno + 2 - po, row.cols[ i ], at->bam_delete_proc ); rc = SQLExecute( sth ); @@ -248,15 +250,19 @@ backsql_modify_delete_all_values( } rs->sr_text = op->o_req_dn.bv_val; SQLFreeStmt( sth, SQL_DROP ); - return rs->sr_err; + goto done; } SQLFreeStmt( sth, SQL_DROP ); } } - backsql_FreeRow( &row ); + + rs->sr_err = LDAP_SUCCESS; + +done:; + backsql_FreeRow_x( &row, op->o_tmpmemctx ); SQLFreeStmt( asth, SQL_DROP ); - return LDAP_SUCCESS; + return rs->sr_err; } int @@ -268,9 +274,8 @@ backsql_modify_internal( backsql_entryID *e_id, Modifications *modlist ) { - backsql_info *bi = (backsql_info*)op->o_bd->be_private; + backsql_info *bi = (backsql_info *)op->o_bd->be_private; RETCODE rc; - SQLHSTMT sth = SQL_NULL_HSTMT; Modifications *ml; Debug( LDAP_DEBUG_TRACE, "==>backsql_modify_internal(): " @@ -290,10 +295,6 @@ backsql_modify_internal( backsql_at_map_rec *at = NULL; struct berval *at_val; int i; - /* first parameter position, parameter order */ - SQLUSMALLINT pno, po; - /* procedure return code */ - int prc = LDAP_SUCCESS; ad = ml->sml_mod.sm_desc; sm_op = ( ml->sml_mod.sm_op & LDAP_MOD_OP ); @@ -422,6 +423,13 @@ add_only:; !BER_BVISNULL( at_val ); i++, at_val++ ) { + SQLHSTMT sth = SQL_NULL_HSTMT; + /* first parameter position, parameter order */ + SQLUSMALLINT pno = 0, + po; + /* procedure return code */ + int prc = LDAP_SUCCESS; + rc = backsql_Prepare( dbh, &sth, at->bam_add_proc, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, @@ -452,9 +460,6 @@ add_only:; rs->sr_err = LDAP_OTHER; goto done; } - - } else { - pno = 0; } po = ( BACKSQL_IS_ADD( at->bam_param_order ) ) > 0; rc = backsql_BindParamID( sth, pno + 1 + po, @@ -475,12 +480,12 @@ add_only:; #ifdef BACKSQL_ARBITRARY_KEY Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): " - "arg%d=\"%s\"\n", + "arg(%d)=\"%s\"\n", pno + 1 + po, e_id->eid_keyval.bv_val, 0 ); #else /* ! BACKSQL_ARBITRARY_KEY */ Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): " - "arg%d=\"%lu\"\n", + "arg(%d)=\"%lu\"\n", pno + 1 + po, e_id->eid_keyval, 0 ); #endif /* ! BACKSQL_ARBITRARY_KEY */ @@ -505,23 +510,41 @@ add_only:; } Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): " - "arg%d=\"%s\"; executing \"%s\"\n", + "arg(%d)=\"%s\"; executing \"%s\"\n", pno + 2 - po, at_val->bv_val, at->bam_add_proc ); rc = SQLExecute( sth ); - if ( rc != SQL_SUCCESS ) { + if ( rc == SQL_SUCCESS && prc == LDAP_SUCCESS ) { + rs->sr_err = LDAP_SUCCESS; + + } else { Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): " - "add_proc execution failed\n", - 0, 0, 0 ); - backsql_PrintErrors( bi->sql_db_env, - dbh, sth, rc ); + "add_proc execution failed " + "(rc=%d, prc=%d)\n", + rc, prc, 0 ); + if ( prc != LDAP_SUCCESS ) { + /* SQL procedure executed fine + * but returned an error */ + SQLFreeStmt( sth, SQL_DROP ); - SQLFreeStmt( sth, SQL_DROP ); - rs->sr_err = LDAP_OTHER; - rs->sr_text = "SQL-backend error"; - goto done; + rs->sr_err = BACKSQL_SANITIZE_ERROR( prc ); + rs->sr_text = at->bam_ad->ad_cname.bv_val; + return rs->sr_err; + + } else { + backsql_PrintErrors( bi->sql_db_env, dbh, + sth, rc ); + if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) + { + SQLFreeStmt( sth, SQL_DROP ); + + rs->sr_err = LDAP_OTHER; + rs->sr_text = "SQL-backend error"; + goto done; + } + } } SQLFreeStmt( sth, SQL_DROP ); } @@ -563,7 +586,13 @@ add_only:; !BER_BVISNULL( at_val ); i++, at_val++ ) { - prc = LDAP_SUCCESS; + SQLHSTMT sth = SQL_NULL_HSTMT; + /* first parameter position, parameter order */ + SQLUSMALLINT pno = 0, + po; + /* procedure return code */ + int prc = LDAP_SUCCESS; + rc = backsql_Prepare( dbh, &sth, at->bam_delete_proc, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, @@ -594,9 +623,6 @@ add_only:; rs->sr_err = LDAP_OTHER; goto done; } - - } else { - pno = 0; } po = ( BACKSQL_IS_DEL( at->bam_param_order ) ) > 0; rc = backsql_BindParamID( sth, pno + 1 + po, @@ -617,12 +643,12 @@ add_only:; #ifdef BACKSQL_ARBITRARY_KEY Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): " - "arg%d=\"%s\"\n", + "arg(%d)=\"%s\"\n", pno + 1 + po, e_id->eid_keyval.bv_val, 0 ); #else /* ! BACKSQL_ARBITRARY_KEY */ Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): " - "arg%d=\"%lu\"\n", + "arg(%d)=\"%lu\"\n", pno + 1 + po, e_id->eid_keyval, 0 ); #endif /* ! BACKSQL_ARBITRARY_KEY */ @@ -930,7 +956,7 @@ backsql_add( Operation *op, SlapReply *rs ) if ( BACKSQL_CHECK_SCHEMA( bi ) ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; - rs->sr_err = entry_schema_check( op->o_bd, op->ora_e, NULL, 0, + rs->sr_err = entry_schema_check( op, op->ora_e, NULL, 0, &rs->sr_text, textbuf, sizeof( textbuf ) ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): " @@ -1076,7 +1102,6 @@ backsql_add( Operation *op, SlapReply *rs ) bsi.bsi_e = &p; rs->sr_err = backsql_init_search( &bsi, &pdn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_no_attrs, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); if ( rs->sr_err != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-sql/api.c b/servers/slapd/back-sql/api.c index e4584c3ebf..d1f983b058 100644 --- a/servers/slapd/back-sql/api.c +++ b/servers/slapd/back-sql/api.c @@ -35,8 +35,8 @@ backsql_api_config( backsql_info *bi, const char *name, int argc, char *argv[] ) { backsql_api *ba; - assert( bi ); - assert( name ); + assert( bi != NULL ); + assert( name != NULL ); for ( ba = backsqlapi; ba; ba = ba->ba_next ) { if ( strcasecmp( name, ba->ba_name ) == 0 ) { @@ -66,7 +66,7 @@ backsql_api_destroy( backsql_info *bi ) { backsql_api *ba; - assert( bi ); + assert( bi != NULL ); ba = bi->sql_api; @@ -88,7 +88,7 @@ backsql_api_register( backsql_api *ba ) { backsql_api *ba2; - assert( ba ); + assert( ba != NULL ); assert( ba->ba_private == NULL ); if ( ba->ba_name == NULL ) { diff --git a/servers/slapd/back-sql/back-sql.h b/servers/slapd/back-sql/back-sql.h index 21c152e2b1..78ca48e791 100644 --- a/servers/slapd/back-sql/back-sql.h +++ b/servers/slapd/back-sql/back-sql.h @@ -436,8 +436,6 @@ typedef struct backsql_srch_info { * is used */ #define BACKSQL_SCOPE_BASE_LIKE ( LDAP_SCOPE_BASE | 0x1000 ) Filter *bsi_filter; - int bsi_slimit, - bsi_tlimit; time_t bsi_stoptime; backsql_entryID *bsi_id_list, diff --git a/servers/slapd/back-sql/bind.c b/servers/slapd/back-sql/bind.c index 0bc12e5a24..a4284437f7 100644 --- a/servers/slapd/back-sql/bind.c +++ b/servers/slapd/back-sql/bind.c @@ -76,7 +76,6 @@ backsql_bind( Operation *op, SlapReply *rs ) bsi.bsi_e = &e; rc = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, anlist, BACKSQL_ISF_GET_ENTRY ); if ( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-sql/compare.c b/servers/slapd/back-sql/compare.c index 9baf9ff35d..bc5d166c3d 100644 --- a/servers/slapd/back-sql/compare.c +++ b/servers/slapd/back-sql/compare.c @@ -60,9 +60,7 @@ backsql_compare( Operation *op, SlapReply *rs ) * Get the entry */ bsi.bsi_e = &e; - rc = backsql_init_search( &bsi, &op->o_req_ndn, - LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, + rc = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, (time_t)(-1), NULL, dbh, op, rs, anlist, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); switch ( rc ) { diff --git a/servers/slapd/back-sql/config.c b/servers/slapd/back-sql/config.c index aa66ac02b7..062c0367ca 100644 --- a/servers/slapd/back-sql/config.c +++ b/servers/slapd/back-sql/config.c @@ -53,7 +53,7 @@ backsql_db_config( backsql_info *bi = (backsql_info *)be->be_private; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_config()\n", 0, 0, 0 ); - assert( bi ); + assert( bi != NULL ); if ( !strcasecmp( argv[ 0 ], "dbhost" ) ) { if ( argc < 2 ) { @@ -649,7 +649,7 @@ read_baseObject( int rc = 0, lineno = 0, lmax = 0; char *buf = NULL; - assert( fname ); + assert( fname != NULL ); fp = ldif_open( fname, "r" ); if ( fp == NULL ) { @@ -788,7 +788,7 @@ create_baseObject( struct berval bv = BER_BVNULL; const char *text = NULL; - assert( ava ); + assert( ava != NULL ); rc = slap_bv2ad( &ava->la_attr, &ad, &text ); if ( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-sql/delete.c b/servers/slapd/back-sql/delete.c index e8bf7142c6..1f059c2895 100644 --- a/servers/slapd/back-sql/delete.c +++ b/servers/slapd/back-sql/delete.c @@ -93,7 +93,7 @@ backsql_delete( Operation *op, SlapReply *rs ) struct berval pdn = BER_BVNULL; int manageDSAit = get_manageDSAit( op ); /* first parameter no */ - SQLUSMALLINT pno; + SQLUSMALLINT pno = 0; Debug( LDAP_DEBUG_TRACE, "==>backsql_delete(): deleting entry \"%s\"\n", op->o_req_ndn.bv_val, 0, 0 ); @@ -115,7 +115,6 @@ backsql_delete( Operation *op, SlapReply *rs ) bsi.bsi_e = &d; rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_no_attrs, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); switch ( rs->sr_err ) { @@ -172,7 +171,7 @@ backsql_delete( Operation *op, SlapReply *rs ) goto done; } - rs->sr_err = backsql_has_children( bi, dbh, &op->o_req_ndn ); + rs->sr_err = backsql_has_children( op, dbh, &op->o_req_ndn ); switch ( rs->sr_err ) { case LDAP_COMPARE_FALSE: rs->sr_err = LDAP_SUCCESS; @@ -223,7 +222,6 @@ backsql_delete( Operation *op, SlapReply *rs ) e_id = bsi.bsi_base_id; rs->sr_err = backsql_init_search( &bsi, &pdn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_no_attrs, BACKSQL_ISF_GET_ENTRY ); if ( rs->sr_err != LDAP_SUCCESS ) { @@ -287,9 +285,6 @@ backsql_delete( Operation *op, SlapReply *rs ) e = NULL; goto done; } - - } else { - pno = 0; } rc = backsql_BindParamID( sth, pno + 1, SQL_PARAM_INPUT, &e_id.eid_keyval ); diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index 87aba87a7d..9690774a09 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -39,7 +39,7 @@ backsql_free_entryID( Operation *op, backsql_entryID *id, int freeit ) { backsql_entryID *next; - assert( id ); + assert( id != NULL ); next = id->eid_next; @@ -154,7 +154,7 @@ backsql_dn2id( /* begin TimesTen */ Debug( LDAP_DEBUG_TRACE, " backsql_dn2id(\"%s\"): id_query \"%s\"\n", ndn->bv_val, bi->sql_id_query, 0 ); - assert( bi->sql_id_query ); + assert( bi->sql_id_query != NULL ); rc = backsql_Prepare( dbh, &sth, bi->sql_id_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, @@ -231,7 +231,7 @@ backsql_dn2id( goto done; } - backsql_BindRowAsStrings( sth, &row ); + backsql_BindRowAsStrings_x( sth, &row, op->o_tmpmemctx ); rc = SQLFetch( sth ); if ( BACKSQL_SUCCESS( rc ) ) { char buf[ SLAP_TEXT_BUFLEN ]; @@ -324,9 +324,10 @@ backsql_dn2id( } } } - backsql_FreeRow( &row ); done:; + backsql_FreeRow_x( &row, op->o_tmpmemctx ); + Debug( LDAP_DEBUG_TRACE, "<==backsql_dn2id(\"%s\"): err=%d\n", ndn->bv_val, res, 0 ); @@ -343,11 +344,12 @@ done:; int backsql_count_children( - backsql_info *bi, + Operation *op, SQLHDBC dbh, struct berval *dn, unsigned long *nchildren ) { + backsql_info *bi = (backsql_info *)op->o_bd->be_private; SQLHSTMT sth = SQL_NULL_HSTMT; BACKSQL_ROW_NTS row; RETCODE rc; @@ -367,7 +369,7 @@ backsql_count_children( /* begin TimesTen */ Debug(LDAP_DEBUG_TRACE, "children id query \"%s\"\n", bi->sql_has_children_query, 0, 0); - assert( bi->sql_has_children_query ); + assert( bi->sql_has_children_query != NULL ); rc = backsql_Prepare( dbh, &sth, bi->sql_has_children_query, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, @@ -399,7 +401,7 @@ backsql_count_children( return LDAP_OTHER; } - backsql_BindRowAsStrings( sth, &row ); + backsql_BindRowAsStrings_x( sth, &row, op->o_tmpmemctx ); rc = SQLFetch( sth ); if ( BACKSQL_SUCCESS( rc ) ) { @@ -416,7 +418,7 @@ backsql_count_children( } else { res = LDAP_OTHER; } - backsql_FreeRow( &row ); + backsql_FreeRow_x( &row, op->o_tmpmemctx ); SQLFreeStmt( sth, SQL_DROP ); @@ -428,14 +430,14 @@ backsql_count_children( int backsql_has_children( - backsql_info *bi, + Operation *op, SQLHDBC dbh, struct berval *dn ) { unsigned long nchildren; int rc; - rc = backsql_count_children( bi, dbh, dn, &nchildren ); + rc = backsql_count_children( op, dbh, dn, &nchildren ); if ( rc == LDAP_SUCCESS ) { return nchildren > 0 ? LDAP_COMPARE_TRUE : LDAP_COMPARE_FALSE; @@ -455,11 +457,13 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) BACKSQL_ROW_NTS row; unsigned long i, k = 0, - oldcount = 0; + oldcount = 0, + res = 0; #ifdef BACKSQL_COUNTQUERY unsigned long count, countsize = sizeof( count ), - j; + j, + append = 0; Attribute *attr = NULL; slap_mr_normalize_func *normfunc = NULL; @@ -469,8 +473,8 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) slap_syntax_transform_func *pretty = NULL; #endif /* BACKSQL_PRETTY_VALIDATE */ - assert( at ); - assert( bsi ); + assert( at != NULL ); + assert( bsi != NULL ); #ifdef BACKSQL_ARBITRARY_KEY Debug( LDAP_DEBUG_TRACE, "==>backsql_get_attr_vals(): " @@ -581,7 +585,7 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) } } else { - Attribute **ap; + append = 1; /* Make space for the array of values */ attr = (Attribute *) ch_malloc( sizeof( Attribute ) ); @@ -609,10 +613,6 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) } else { attr->a_nvals = attr->a_vals; } - - for ( ap = &bsi->bsi_e->e_attrs; (*ap) != NULL; ap = &(*ap)->a_next ) - /* goto last */ ; - *ap = attr; } #endif /* BACKSQL_COUNTQUERY */ @@ -654,7 +654,7 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) return 1; } - backsql_BindRowAsStrings( sth, &row ); + backsql_BindRowAsStrings_x( sth, &row, bsi->bsi_op->o_tmpmemctx ); #ifdef BACKSQL_COUNTQUERY j = oldcount; #endif /* BACKSQL_COUNTQUERY */ @@ -679,7 +679,8 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) "in schema (%d)\n", bsi->bsi_e->e_name.bv_val, row.col_names[ i ].bv_val, retval ); - return 1; + res = 1; + goto done; } if ( ad != at->bam_ad ) { @@ -690,7 +691,8 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) bsi->bsi_e->e_name.bv_val, ad->ad_cname.bv_val, at->bam_ad->ad_cname.bv_val ); - return 1; + res = 1; + goto done; } #endif /* BACKSQL_TRACE */ @@ -804,15 +806,35 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) } } - backsql_FreeRow( &row ); +#ifdef BACKSQL_COUNTQUERY + if ( BER_BVISNULL( &attr->a_vals[ 0 ] ) ) { + /* don't leave around attributes with no values */ + attr_free( attr ); + + } else if ( append ) { + Attribute **ap; + + for ( ap = &bsi->bsi_e->e_attrs; (*ap) != NULL; ap = &(*ap)->a_next ) + /* goto last */ ; + *ap = attr; + } +#endif /* BACKSQL_COUNTQUERY */ + SQLFreeStmt( sth, SQL_DROP ); Debug( LDAP_DEBUG_TRACE, "<==backsql_get_attr_vals()\n", 0, 0, 0 ); if ( at->bam_next ) { - return backsql_get_attr_vals( at->bam_next, v_bsi ); + res = backsql_get_attr_vals( at->bam_next, v_bsi ); + } else { + res = 1; } - return 1; +#ifdef BACKSQL_TRACE +done:; +#endif /* BACKSQL_TRACE */ + backsql_FreeRow_x( &row, bsi->bsi_op->o_tmpmemctx ); + + return res; } int @@ -825,7 +847,7 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid ) Debug( LDAP_DEBUG_TRACE, "==>backsql_id2entry()\n", 0, 0, 0 ); - assert( bsi->bsi_e ); + assert( bsi->bsi_e != NULL ); memset( bsi->bsi_e, 0, sizeof( Entry ) ); diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c index 90906ce294..1c9913febd 100644 --- a/servers/slapd/back-sql/init.c +++ b/servers/slapd/back-sql/init.c @@ -97,17 +97,23 @@ backsql_db_init( BackendDB *bd ) { backsql_info *bi; + int rc = 0; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_init()\n", 0, 0, 0 ); - bi = (backsql_info *)ch_malloc( sizeof( backsql_info ) ); - memset( bi, '\0', sizeof( backsql_info ) ); + + bi = (backsql_info *)ch_calloc( 1, sizeof( backsql_info ) ); ldap_pvt_thread_mutex_init( &bi->sql_dbconn_mutex ); ldap_pvt_thread_mutex_init( &bi->sql_schema_mutex ); - backsql_init_db_env( bi ); + + if ( backsql_init_db_env( bi ) != SQL_SUCCESS ) { + rc = -1; + } bd->be_private = bi; + Debug( LDAP_DEBUG_TRACE, "<==backsql_db_init()\n", 0, 0, 0 ); - return 0; + + return rc; } int @@ -117,6 +123,7 @@ backsql_db_destroy( backsql_info *bi = (backsql_info*)bd->be_private; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_destroy()\n", 0, 0, 0 ); + ldap_pvt_thread_mutex_lock( &bi->sql_dbconn_mutex ); backsql_free_db_env( bi ); ldap_pvt_thread_mutex_unlock( &bi->sql_dbconn_mutex ); @@ -125,37 +132,76 @@ backsql_db_destroy( backsql_destroy_schema_map( bi ); ldap_pvt_thread_mutex_unlock( &bi->sql_schema_mutex ); ldap_pvt_thread_mutex_destroy( &bi->sql_schema_mutex ); - free( bi->sql_dbname ); - free( bi->sql_dbuser ); + + if ( bi->sql_dbname ) { + ch_free( bi->sql_dbname ); + } + if ( bi->sql_dbuser ) { + ch_free( bi->sql_dbuser ); + } if ( bi->sql_dbpasswd ) { - free( bi->sql_dbpasswd ); + ch_free( bi->sql_dbpasswd ); } if ( bi->sql_dbhost ) { - free( bi->sql_dbhost ); + ch_free( bi->sql_dbhost ); } if ( bi->sql_upper_func.bv_val ) { - free( bi->sql_upper_func.bv_val ); - free( bi->sql_upper_func_open.bv_val ); - free( bi->sql_upper_func_close.bv_val ); + ch_free( bi->sql_upper_func.bv_val ); + ch_free( bi->sql_upper_func_open.bv_val ); + ch_free( bi->sql_upper_func_close.bv_val ); + } + if ( bi->sql_concat_func ) { + ber_bvarray_free( bi->sql_concat_func ); + } + if ( !BER_BVISNULL( &bi->sql_strcast_func ) ) { + ch_free( bi->sql_strcast_func.bv_val ); + } + if ( !BER_BVISNULL( &bi->sql_children_cond ) ) { + ch_free( bi->sql_children_cond.bv_val ); + } + if ( !BER_BVISNULL( &bi->sql_subtree_cond ) ) { + ch_free( bi->sql_subtree_cond.bv_val ); + } + if ( !BER_BVISNULL( &bi->sql_dn_oc_aliasing ) ) { + ch_free( bi->sql_dn_oc_aliasing.bv_val ); + } + if ( bi->sql_oc_query ) { + ch_free( bi->sql_oc_query ); + } + if ( bi->sql_at_query ) { + ch_free( bi->sql_at_query ); + } + if ( bi->sql_id_query ) { + ch_free( bi->sql_id_query ); + } + if ( bi->sql_has_children_query ) { + ch_free( bi->sql_has_children_query ); + } + if ( bi->sql_insentry_stmt ) { + ch_free( bi->sql_insentry_stmt ); + } + if ( bi->sql_delentry_stmt ) { + ch_free( bi->sql_delentry_stmt ); + } + if ( bi->sql_renentry_stmt ) { + ch_free( bi->sql_renentry_stmt ); + } + if ( bi->sql_delobjclasses_stmt ) { + ch_free( bi->sql_delobjclasses_stmt ); + } + if ( !BER_BVISNULL( &bi->sql_aliasing ) ) { + ch_free( bi->sql_aliasing.bv_val ); + } + if ( !BER_BVISNULL( &bi->sql_aliasing_quote ) ) { + ch_free( bi->sql_aliasing_quote.bv_val ); } - - free( bi->sql_subtree_cond.bv_val ); - free( bi->sql_oc_query ); - free( bi->sql_at_query ); - free( bi->sql_insentry_stmt ); - free( bi->sql_delentry_stmt ); - free( bi->sql_renentry_stmt ); - free( bi->sql_delobjclasses_stmt ); - - free( bi->sql_aliasing.bv_val ); - free( bi->sql_aliasing_quote.bv_val ); if ( bi->sql_anlist ) { int i; - for ( i = 0; !BER_BVISNULL( &bi->sql_anlist[i].an_name ); i++ ) + for ( i = 0; !BER_BVISNULL( &bi->sql_anlist[ i ].an_name ); i++ ) { - ch_free( bi->sql_anlist[i].an_name.bv_val ); + ch_free( bi->sql_anlist[ i ].an_name.bv_val ); } ch_free( bi->sql_anlist ); } @@ -164,7 +210,7 @@ backsql_db_destroy( entry_free( bi->sql_baseObject ); } - free( bi ); + ch_free( bi ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_destroy()\n", 0, 0, 0 ); return 0; @@ -247,10 +293,10 @@ backsql_db_open( /* normalize filter values only if necessary */ bi->sql_caseIgnoreMatch = mr_find( "caseIgnoreMatch" ); - assert( bi->sql_caseIgnoreMatch ); + assert( bi->sql_caseIgnoreMatch != NULL ); bi->sql_telephoneNumberMatch = mr_find( "telephoneNumberMatch" ); - assert( bi->sql_telephoneNumberMatch ); + assert( bi->sql_telephoneNumberMatch != NULL ); if ( bi->sql_dbuser == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " @@ -259,7 +305,7 @@ backsql_db_open( return 1; } - if ( bi->sql_subtree_cond.bv_val == NULL ) { + if ( BER_BVISNULL( &bi->sql_subtree_cond ) ) { /* * Prepare concat function for subtree search condition */ @@ -309,6 +355,8 @@ backsql_db_open( &concat ); } + ch_free( concat.bv_val ); + bi->sql_subtree_cond = bb.bb_val; Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " @@ -422,6 +470,7 @@ backsql_db_open( bi->sql_delobjclasses_stmt = ch_strdup( backsql_def_delobjclasses_stmt ); } + /* This should just be to force schema loading */ op->o_hdr = (Opheader *)&op[ 1 ]; op->o_connid = (unsigned long)(-1); op->o_bd = bd; @@ -431,6 +480,17 @@ backsql_db_open( return 1; } + if ( backsql_free_db_conn( op ) != SQL_SUCCESS ) { + Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " + "connection free failed\n", 0, 0, 0 ); + } + if ( !BACKSQL_SCHEMA_LOADED( bi ) ) { + Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " + "test failed, schema map not loaded - exiting\n", + 0, 0, 0 ); + return 1; + } + /* * Prepare ID selection query */ @@ -488,14 +548,6 @@ backsql_db_open( &bi->sql_aliasing_quote, "dn", &bi->sql_aliasing_quote ); bi->sql_dn_oc_aliasing = bb.bb_val; - backsql_free_db_conn( op ); - if ( !BACKSQL_SCHEMA_LOADED( bi ) ) { - Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): " - "test failed, schema map not loaded - exiting\n", - 0, 0, 0 ); - return 1; - } - /* should never happen! */ assert( bd->be_nsuffix != NULL ); @@ -515,8 +567,14 @@ int backsql_db_close( BackendDB *bd ) { + backsql_info *bi = (backsql_info*)bd->be_private; + Debug( LDAP_DEBUG_TRACE, "==>backsql_db_close()\n", 0, 0, 0 ); + + backsql_conn_destroy( bi ); + Debug( LDAP_DEBUG_TRACE, "<==backsql_db_close()\n", 0, 0, 0 ); + return 0; } diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index fa2d1e9d4b..c9060f98eb 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -65,7 +65,6 @@ backsql_modify( Operation *op, SlapReply *rs ) bsi.bsi_e = &m; rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); @@ -151,7 +150,7 @@ backsql_modify( Operation *op, SlapReply *rs ) goto do_transact; } - rs->sr_err = entry_schema_check( op->o_bd, &m, NULL, 0, + rs->sr_err = entry_schema_check( op, &m, NULL, 0, &rs->sr_text, textbuf, sizeof( textbuf ) ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): " diff --git a/servers/slapd/back-sql/modrdn.c b/servers/slapd/back-sql/modrdn.c index ce904498e2..306e557d02 100644 --- a/servers/slapd/back-sql/modrdn.c +++ b/servers/slapd/back-sql/modrdn.c @@ -74,7 +74,6 @@ backsql_modrdn( Operation *op, SlapReply *rs ) bsi.bsi_e = &r; rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); @@ -129,7 +128,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) goto done; } - if ( backsql_has_children( bi, dbh, &op->o_req_ndn ) == LDAP_COMPARE_TRUE ) { + if ( backsql_has_children( op, dbh, &op->o_req_ndn ) == LDAP_COMPARE_TRUE ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "entry \"%s\" has children\n", op->o_req_dn.bv_val, 0, 0 ); @@ -171,7 +170,6 @@ backsql_modrdn( Operation *op, SlapReply *rs ) e_id = bsi.bsi_base_id; rs->sr_err = backsql_init_search( &bsi, &pndn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, BACKSQL_ISF_GET_ENTRY ); @@ -226,7 +224,6 @@ backsql_modrdn( Operation *op, SlapReply *rs ) bsi.bsi_e = &n; rs->sr_err = backsql_init_search( &bsi, new_npdn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); @@ -455,7 +452,6 @@ backsql_modrdn( Operation *op, SlapReply *rs ) bsi.bsi_e = &r; rs->sr_err = backsql_init_search( &bsi, &new_ndn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); @@ -495,7 +491,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) e_id = bsi.bsi_base_id; - rs->sr_err = entry_schema_check( op->o_bd, &r, NULL, 0, + rs->sr_err = entry_schema_check( op, &r, NULL, 0, &rs->sr_text, textbuf, sizeof( textbuf ) ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): " diff --git a/servers/slapd/back-sql/operational.c b/servers/slapd/back-sql/operational.c index e0f4af3b1a..6edde629ca 100644 --- a/servers/slapd/back-sql/operational.c +++ b/servers/slapd/back-sql/operational.c @@ -84,7 +84,7 @@ backsql_operational_entryCSN( Operation *op ) #ifdef BACKSQL_SYNCPROV if ( op->o_sync && op->o_tag == LDAP_REQ_SEARCH ) { - assert( op->o_private ); + assert( op->o_private != NULL ); entryCSN = *((struct berval *)op->o_private); @@ -158,13 +158,13 @@ backsql_operational( && !got[ BACKSQL_OP_HASSUBORDINATES ] && attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL ) { - rc = backsql_has_children( bi, dbh, &rs->sr_entry->e_nname ); + rc = backsql_has_children( op, dbh, &rs->sr_entry->e_nname ); switch( rc ) { case LDAP_COMPARE_TRUE: case LDAP_COMPARE_FALSE: *ap = slap_operational_hasSubordinate( rc == LDAP_COMPARE_TRUE ); - assert( *ap ); + assert( *ap != NULL ); ap = &(*ap)->a_next; rc = 0; break; @@ -184,7 +184,6 @@ backsql_operational( rc = backsql_init_search( &bsi, &rs->sr_entry->e_nname, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, NULL, BACKSQL_ISF_GET_ID ); if ( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-sql/proto-sql.h b/servers/slapd/back-sql/proto-sql.h index 3a5bd3e2d9..16a7ec6683 100644 --- a/servers/slapd/back-sql/proto-sql.h +++ b/servers/slapd/back-sql/proto-sql.h @@ -116,12 +116,12 @@ int backsql_dn2id( Operation *op, SlapReply *rs, SQLHDBC dbh, int matched, int muck ); /* stores in *nchildren the count of children for an entry */ -int backsql_count_children( backsql_info *bi, SQLHDBC dbh, +int backsql_count_children( Operation *op, SQLHDBC dbh, struct berval *dn, unsigned long *nchildren ); /* returns LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE if the entry corresponding * to DN has/has not children */ -int backsql_has_children( backsql_info *bi, SQLHDBC dbh, struct berval *dn ); +int backsql_has_children( Operation *op, SQLHDBC dbh, struct berval *dn ); /* frees *id and returns next in list */ backsql_entryID *backsql_free_entryID( Operation *op, backsql_entryID *id, @@ -164,7 +164,7 @@ int backsql_destroy_schema_map( backsql_info *si ); */ int backsql_init_search( backsql_srch_info *bsi, - struct berval *nbase, int scope, int slimit, int tlimit, + struct berval *nbase, int scope, time_t stoptime, Filter *filter, SQLHDBC dbh, Operation *op, SlapReply *rs, AttributeName *attrs, unsigned flags ); @@ -203,12 +203,18 @@ RETCODE backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char* query, int timeout ); backsql_BindParamInt( (sth), (par_ind), (io), (id) ) #endif /* ! BACKSQL_ARBITRARY_KEY */ +RETCODE backsql_BindRowAsStrings_x( SQLHSTMT sth, BACKSQL_ROW_NTS *row, void *ctx ); + RETCODE backsql_BindRowAsStrings( SQLHSTMT sth, BACKSQL_ROW_NTS *row ); +RETCODE backsql_FreeRow_x( BACKSQL_ROW_NTS *row, void *ctx ); + RETCODE backsql_FreeRow( BACKSQL_ROW_NTS *row ); void backsql_PrintErrors( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT sth, int rc ); +int backsql_conn_destroy( backsql_info *bi ); + int backsql_init_db_env( backsql_info *si ); int backsql_free_db_env( backsql_info *si ); diff --git a/servers/slapd/back-sql/rdbms_depend/ibmdb2/testdb_data.sql b/servers/slapd/back-sql/rdbms_depend/ibmdb2/testdb_data.sql index c204ecd8ce..7bef37495a 100644 --- a/servers/slapd/back-sql/rdbms_depend/ibmdb2/testdb_data.sql +++ b/servers/slapd/back-sql/rdbms_depend/ibmdb2/testdb_data.sql @@ -15,4 +15,4 @@ insert into authors_docs (pers_id,doc_id) values (1,1); insert into authors_docs (pers_id,doc_id) values (1,2); insert into authors_docs (pers_id,doc_id) values (2,1); -insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9010/'); +insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9012/'); diff --git a/servers/slapd/back-sql/rdbms_depend/mssql/testdb_metadata.sql b/servers/slapd/back-sql/rdbms_depend/mssql/testdb_metadata.sql index 9a9582d177..e08752343a 100644 --- a/servers/slapd/back-sql/rdbms_depend/mssql/testdb_metadata.sql +++ b/servers/slapd/back-sql/rdbms_depend/mssql/testdb_metadata.sql @@ -99,7 +99,7 @@ insert into ldap_entry_objclasses (entry_id,oc_name) values (4,'referral'); insert into ldap_referrals (entry_id,url) -values (4,'ldap://localhost:9010/'); +values (4,'ldap://localhost:9012/'); -- support procedures diff --git a/servers/slapd/back-sql/rdbms_depend/mysql/backsql_drop.sql b/servers/slapd/back-sql/rdbms_depend/mysql/backsql_drop.sql index b497eb9d54..a81fa8b2d4 100644 --- a/servers/slapd/back-sql/rdbms_depend/mysql/backsql_drop.sql +++ b/servers/slapd/back-sql/rdbms_depend/mysql/backsql_drop.sql @@ -1,5 +1,3 @@ -DROP TABLE IF EXISTS ldap_referrals; - DROP TABLE IF EXISTS ldap_entry_objclasses; DROP TABLE IF EXISTS ldap_attr_mappings; diff --git a/servers/slapd/back-sql/rdbms_depend/mysql/testdb_data.sql b/servers/slapd/back-sql/rdbms_depend/mysql/testdb_data.sql index c204ecd8ce..7bef37495a 100644 --- a/servers/slapd/back-sql/rdbms_depend/mysql/testdb_data.sql +++ b/servers/slapd/back-sql/rdbms_depend/mysql/testdb_data.sql @@ -15,4 +15,4 @@ insert into authors_docs (pers_id,doc_id) values (1,1); insert into authors_docs (pers_id,doc_id) values (1,2); insert into authors_docs (pers_id,doc_id) values (2,1); -insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9010/'); +insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9012/'); diff --git a/servers/slapd/back-sql/rdbms_depend/oracle/testdb_metadata.sql b/servers/slapd/back-sql/rdbms_depend/oracle/testdb_metadata.sql index f6c8d14acc..354d7bd592 100644 --- a/servers/slapd/back-sql/rdbms_depend/oracle/testdb_metadata.sql +++ b/servers/slapd/back-sql/rdbms_depend/oracle/testdb_metadata.sql @@ -115,7 +115,7 @@ values (4,'referral'); -- entry_id the "ldap_entries.id" of the entry that should be treated as a referral -- url the URI of the referral insert into ldap_referrals (entry_id,url) -values (4,'ldap://localhost:9010/'); +values (4,'ldap://localhost:9012/'); -- procedures diff --git a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql index c204ecd8ce..7bef37495a 100644 --- a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql +++ b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_data.sql @@ -15,4 +15,4 @@ insert into authors_docs (pers_id,doc_id) values (1,1); insert into authors_docs (pers_id,doc_id) values (1,2); insert into authors_docs (pers_id,doc_id) values (2,1); -insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9010/'); +insert into referrals (id,name,url) values (1,'Referral','ldap://localhost:9012/'); diff --git a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_drop.sql b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_drop.sql index 908cd44123..c061ff8acb 100644 --- a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_drop.sql +++ b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_drop.sql @@ -4,3 +4,10 @@ DROP TABLE documents; DROP TABLE authors_docs; DROP TABLE phones; DROP TABLE referrals; +DROP FUNCTION create_person (); +DROP FUNCTION update_person_cn (varchar, int); +DROP FUNCTION add_phone (varchar, int); +DROP FUNCTION create_doc (); +DROP FUNCTION create_o (); +DROP FUNCTION create_referral (); + diff --git a/servers/slapd/back-sql/rdbms_depend/timesten/testdb_metadata.sql b/servers/slapd/back-sql/rdbms_depend/timesten/testdb_metadata.sql index 40e8001a8c..f9e341906a 100644 --- a/servers/slapd/back-sql/rdbms_depend/timesten/testdb_metadata.sql +++ b/servers/slapd/back-sql/rdbms_depend/timesten/testdb_metadata.sql @@ -105,4 +105,4 @@ insert into ldap_entry_objclasses (entry_id,oc_name) values (4,'referral'); insert into ldap_referrals (entry_id,url) -values (4,'ldap://localhost:9010'); +values (4,'ldap://localhost:9012'); diff --git a/servers/slapd/back-sql/schema-map.c b/servers/slapd/back-sql/schema-map.c index 44698952f5..02a73924ce 100644 --- a/servers/slapd/back-sql/schema-map.c +++ b/servers/slapd/back-sql/schema-map.c @@ -800,9 +800,9 @@ backsql_supad2at( backsql_oc_map_rec *objclass, AttributeDescription *supad, struct supad2at_t va = { 0 }; int rc; - assert( objclass ); - assert( supad ); - assert( pret ); + assert( objclass != NULL ); + assert( supad != NULL ); + assert( pret != NULL ); *pret = NULL; @@ -843,6 +843,12 @@ backsql_free_attr( void *v_at ) ch_free( at->bam_query ); } +#ifdef BACKSQL_COUNTQUERY + if ( at->bam_countquery != NULL ) { + ch_free( at->bam_countquery ); + } +#endif /* BACKSQL_COUNTQUERY */ + /* TimesTen */ if ( !BER_BVISNULL( &at->bam_sel_expr_u ) ) { ch_free( at->bam_sel_expr_u.bv_val ); diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index aa08445385..44b0617772 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -109,8 +109,6 @@ backsql_init_search( backsql_srch_info *bsi, struct berval *nbase, int scope, - int slimit, - int tlimit, time_t stoptime, Filter *filter, SQLHDBC dbh, @@ -127,8 +125,6 @@ backsql_init_search( BER_BVZERO( &bsi->bsi_base_id.eid_dn ); BER_BVZERO( &bsi->bsi_base_id.eid_ndn ); bsi->bsi_scope = scope; - bsi->bsi_slimit = slimit; - bsi->bsi_tlimit = tlimit; bsi->bsi_filter = filter; bsi->bsi_dbh = dbh; bsi->bsi_op = op; @@ -272,7 +268,7 @@ backsql_init_search( int getentry = BACKSQL_IS_GET_ENTRY( flags ); int gotit = 0; - assert( op->o_bd->be_private ); + assert( op->o_bd->be_private != NULL ); rc = backsql_dn2id( op, rs, dbh, nbase, &bsi->bsi_base_id, matched, 1 ); @@ -1250,7 +1246,7 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query ) backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private; int rc; - assert( query ); + assert( query != NULL ); BER_BVZERO( query ); bsi->bsi_use_subtree_shortcut = 0; @@ -1344,7 +1340,7 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query ) int i; BackendDB *bd = bsi->bsi_op->o_bd; - assert( bd->be_nsuffix ); + assert( bd->be_nsuffix != NULL ); for ( i = 0; !BER_BVISNULL( &bd->be_nsuffix[ i ] ); i++ ) { @@ -1695,7 +1691,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi ) return BACKSQL_AVL_CONTINUE; } - backsql_BindRowAsStrings( sth, &row ); + backsql_BindRowAsStrings_x( sth, &row, bsi->bsi_op->o_tmpmemctx ); rc = SQLFetch( sth ); for ( ; BACKSQL_SUCCESS( rc ); rc = SQLFetch( sth ) ) { struct berval dn, pdn, ndn; @@ -1761,7 +1757,7 @@ backsql_oc_get_candidates( void *v_oc, void *v_bsi ) break; } } - backsql_FreeRow( &row ); + backsql_FreeRow_x( &row, bsi->bsi_op->o_tmpmemctx ); SQLFreeStmt( sth, SQL_DROP ); Debug( LDAP_DEBUG_TRACE, "<==backsql_oc_get_candidates(): %d\n", @@ -1827,7 +1823,6 @@ backsql_search( Operation *op, SlapReply *rs ) bsi.bsi_e = &base_entry; rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn, op->ors_scope, - op->ors_slimit, op->ors_tlimit, stoptime, op->ors_filter, dbh, op, rs, op->ors_attrs, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); @@ -1848,6 +1843,10 @@ backsql_search( Operation *op, SlapReply *rs ) } break; } + + /* an entry was created; free it */ + entry_clean( bsi.bsi_e ); + /* fall thru */ default: @@ -1868,8 +1867,13 @@ backsql_search( Operation *op, SlapReply *rs ) #endif /* SLAP_ACL_HONOR_DISCLOSE */ send_ldap_result( op, rs ); - goto done; + if ( rs->sr_ref ) { + ber_bvarray_free( rs->sr_ref ); + rs->sr_ref = NULL; + } + + goto done; } #ifdef SLAP_ACL_HONOR_DISCLOSE /* NOTE: __NEW__ "search" access is required @@ -1945,6 +1949,7 @@ backsql_search( Operation *op, SlapReply *rs ) /* check for abandon */ if ( op->o_abandon ) { + eid = bsi.bsi_id_list; rs->sr_err = SLAPD_ABANDON; goto send_results; } @@ -2078,7 +2083,6 @@ backsql_search( Operation *op, SlapReply *rs ) rc = backsql_init_search( &bsi2, &e->e_nname, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, rs, NULL, BACKSQL_ISF_GET_ENTRY ); @@ -2131,7 +2135,7 @@ backsql_search( Operation *op, SlapReply *rs ) * filter_has_subordinates() */ if ( bsi.bsi_flags & BSQL_SF_FILTER_HASSUBORDINATE ) { - rc = backsql_has_children( bi, dbh, &e->e_nname ); + rc = backsql_has_children( op, dbh, &e->e_nname ); switch ( rc ) { case LDAP_COMPARE_TRUE: @@ -2216,9 +2220,7 @@ next_entry:; } next_entry2:; - if ( op->ors_slimit != SLAP_NO_LIMIT - && rs->sr_nentries >= op->ors_slimit ) - { + if ( --op->ors_slimit == -1 ) { rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; goto send_results; } @@ -2239,6 +2241,12 @@ send_results:; send_ldap_result( op, rs ); } + /* cleanup in case of abandon */ + for ( ; eid != NULL; + eid = backsql_free_entryID( op, + eid, eid == &bsi.bsi_base_id ? 0 : 1 ) ) + ; + backsql_entry_clean( op, &base_entry ); /* in case we got here accidentally */ @@ -2328,7 +2336,6 @@ backsql_entry_get( rc = backsql_init_search( &bsi, ndn, LDAP_SCOPE_BASE, - SLAP_NO_LIMIT, SLAP_NO_LIMIT, (time_t)(-1), NULL, dbh, op, &rs, at ? anlist : NULL, BACKSQL_ISF_GET_ENTRY ); diff --git a/servers/slapd/back-sql/sql-wrap.c b/servers/slapd/back-sql/sql-wrap.c index 61beb4f14a..aaa0a1ac64 100644 --- a/servers/slapd/back-sql/sql-wrap.c +++ b/servers/slapd/back-sql/sql-wrap.c @@ -130,7 +130,7 @@ backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char *query, int timeout ) } RETCODE -backsql_BindRowAsStrings( SQLHSTMT sth, BACKSQL_ROW_NTS *row ) +backsql_BindRowAsStrings_x( SQLHSTMT sth, BACKSQL_ROW_NTS *row, void *ctx ) { RETCODE rc; SQLCHAR colname[ 64 ]; @@ -161,62 +161,45 @@ backsql_BindRowAsStrings( SQLHSTMT sth, BACKSQL_ROW_NTS *row ) "ncols=%d\n", (int)row->ncols, 0, 0 ); #endif /* BACKSQL_TRACE */ - row->col_names = (BerVarray)ch_calloc( row->ncols + 1, - sizeof( struct berval ) ); - row->cols = (char **)ch_calloc( row->ncols + 1, - sizeof( char * ) ); - row->col_prec = (UDWORD *)ch_calloc( row->ncols, - sizeof( UDWORD ) ); - row->value_len = (SQLINTEGER *)ch_calloc( row->ncols, - sizeof( SQLINTEGER ) ); + row->col_names = (BerVarray)ber_memcalloc_x( row->ncols + 1, + sizeof( struct berval ), ctx ); + row->cols = (char **)ber_memcalloc_x( row->ncols + 1, + sizeof( char * ), ctx ); + row->col_prec = (UDWORD *)ber_memcalloc_x( row->ncols, + sizeof( UDWORD ), ctx ); + row->value_len = (SQLINTEGER *)ber_memcalloc_x( row->ncols, + sizeof( SQLINTEGER ), ctx ); for ( i = 1; i <= row->ncols; i++ ) { rc = SQLDescribeCol( sth, (SQLSMALLINT)i, &colname[ 0 ], (SQLUINTEGER)( sizeof( colname ) - 1 ), &name_len, &col_type, &col_prec, &col_scale, &col_null ); - ber_str2bv( (char *)colname, 0, 1, &row->col_names[ i - 1 ] ); + /* FIXME: test rc? */ + + ber_str2bv_x( (char *)colname, 0, 1, + &row->col_names[ i - 1 ], ctx ); #ifdef BACKSQL_TRACE Debug( LDAP_DEBUG_TRACE, "backsql_BindRowAsStrings: " "col_name=%s, col_prec[%d]=%d\n", colname, (int)i, (int)col_prec ); #endif /* BACKSQL_TRACE */ - if ( col_type == SQL_LONGVARCHAR - || col_type == SQL_LONGVARBINARY) { -#if 0 - row->cols[ i - 1 ] = NULL; - row->col_prec[ i - 1 ] = -1; - - /* - * such fields must be handled - * in some other way since they return 2G - * as their precision (at least it does so - * with MS SQL Server w/native driver) - * for now, we just set fixed precision - * for such fields - dirty hack, but... - * no time to deal with SQLGetData() - */ -#endif + if ( col_type != SQL_CHAR && col_type != SQL_VARCHAR ) + { col_prec = MAX_ATTR_LEN; - row->cols[ i - 1 ] = (char *)ch_calloc( col_prec + 1, sizeof( char ) ); - row->col_prec[ i - 1 ] = col_prec; - rc = SQLBindCol( sth, (SQLUSMALLINT)i, - SQL_C_CHAR, - (SQLPOINTER)row->cols[ i - 1 ], - col_prec + 1, - &row->value_len[ i - 1 ] ); - } else { - row->cols[ i - 1 ] = (char *)ch_calloc( col_prec + 1, sizeof( char ) ); - row->col_prec[ i - 1 ] = col_prec; - rc = SQLBindCol( sth, (SQLUSMALLINT)i, - SQL_C_CHAR, - (SQLPOINTER)row->cols[ i - 1 ], - col_prec + 1, - &row->value_len[ i - 1 ] ); } + + row->cols[ i - 1 ] = (char *)ber_memcalloc_x( col_prec + 1, + sizeof( char ), ctx ); + row->col_prec[ i - 1 ] = col_prec; + rc = SQLBindCol( sth, (SQLUSMALLINT)i, + SQL_C_CHAR, + (SQLPOINTER)row->cols[ i - 1 ], + col_prec + 1, + &row->value_len[ i - 1 ] ); + /* FIXME: test rc? */ } - row->col_names[ i - 1 ].bv_val = NULL; - row->col_names[ i - 1 ].bv_len = 0; + BER_BVZERO( &row->col_names[ i - 1 ] ); row->cols[ i - 1 ] = NULL; } @@ -228,20 +211,33 @@ backsql_BindRowAsStrings( SQLHSTMT sth, BACKSQL_ROW_NTS *row ) } RETCODE -backsql_FreeRow( BACKSQL_ROW_NTS *row ) +backsql_BindRowAsStrings( SQLHSTMT sth, BACKSQL_ROW_NTS *row ) +{ + return backsql_BindRowAsStrings_x( sth, row, NULL ); +} + +RETCODE +backsql_FreeRow_x( BACKSQL_ROW_NTS *row, void *ctx ) { if ( row->cols == NULL ) { return SQL_ERROR; } - ber_bvarray_free( row->col_names ); - ldap_charray_free( row->cols ); - free( row->col_prec ); - free( row->value_len ); + ber_bvarray_free_x( row->col_names, ctx ); + ber_memvfree_x( (void **)row->cols, ctx ); + ber_memfree_x( row->col_prec, ctx ); + ber_memfree_x( row->value_len, ctx ); return SQL_SUCCESS; } + +RETCODE +backsql_FreeRow( BACKSQL_ROW_NTS *row ) +{ + return backsql_FreeRow_x( row, NULL ); +} + static int backsql_cmp_connid( const void *v_c1, const void *v_c2 ) { @@ -257,10 +253,13 @@ backsql_cmp_connid( const void *v_c1, const void *v_c2 ) return 0; } -static int -backsql_close_db_conn( backsql_db_conn *conn ) +static void +backsql_close_db_conn( void *v_conn ) { - Debug( LDAP_DEBUG_TRACE, "==>backsql_close_db_conn()\n", 0, 0, 0 ); + backsql_db_conn *conn = (backsql_db_conn *)v_conn; + + Debug( LDAP_DEBUG_TRACE, "==>backsql_close_db_conn(%lu)\n", + conn->ldap_cid, 0, 0 ); /* * Default transact is SQL_ROLLBACK; commit is required only @@ -272,8 +271,19 @@ backsql_close_db_conn( backsql_db_conn *conn ) SQLTransact( SQL_NULL_HENV, conn->dbh, SQL_ROLLBACK ); SQLDisconnect( conn->dbh ); SQLFreeConnect( conn->dbh ); - Debug( LDAP_DEBUG_TRACE, "<==backsql_close_db_conn()\n", 0, 0, 0 ); - return 1; + ch_free( conn ); + + Debug( LDAP_DEBUG_TRACE, "<==backsql_close_db_conn(%lu)\n", + conn->ldap_cid, 0, 0 ); +} + +int +backsql_conn_destroy( + backsql_info *bi ) +{ + avl_free( bi->sql_db_conns, backsql_close_db_conn ); + + return 0; } int @@ -283,6 +293,7 @@ backsql_init_db_env( backsql_info *bi ) int ret = SQL_SUCCESS; Debug( LDAP_DEBUG_TRACE, "==>backsql_init_db_env()\n", 0, 0, 0 ); + rc = SQLAllocEnv( &bi->sql_db_env ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "init_db_env: SQLAllocEnv failed:\n", @@ -291,7 +302,9 @@ backsql_init_db_env( backsql_info *bi ) SQL_NULL_HENV, rc ); ret = SQL_ERROR; } + Debug( LDAP_DEBUG_TRACE, "<==backsql_init_db_env()=%d\n", ret, 0, 0 ); + return ret; } @@ -300,10 +313,8 @@ backsql_free_db_env( backsql_info *bi ) { Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_env()\n", 0, 0, 0 ); -#ifdef BACKSQL_TRACE - Debug( LDAP_DEBUG_TRACE, "free_db_env(): delete AVL tree here!!!\n", - 0, 0, 0 ); -#endif /* BACKSQL_TRACE */ + (void)SQLFreeEnv( bi->sql_db_env ); + bi->sql_db_env = SQL_NULL_HENV; /* * stop, if frontend waits for all threads to shutdown @@ -311,6 +322,7 @@ backsql_free_db_env( backsql_info *bi ) * everything is already deleted... */ Debug( LDAP_DEBUG_TRACE, "<==backsql_free_db_env()\n", 0, 0, 0 ); + return SQL_SUCCESS; } @@ -322,16 +334,18 @@ backsql_open_db_conn( backsql_info *bi, unsigned long ldap_cid, backsql_db_conn backsql_db_conn *dbc; int rc; - assert( pdbc ); + assert( pdbc != NULL ); *pdbc = NULL; - Debug( LDAP_DEBUG_TRACE, "==>backsql_open_db_conn()\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "==>backsql_open_db_conn(%lu)\n", + ldap_cid, 0, 0 ); + dbc = (backsql_db_conn *)ch_calloc( 1, sizeof( backsql_db_conn ) ); dbc->ldap_cid = ldap_cid; rc = SQLAllocConnect( bi->sql_db_env, &dbc->dbh ); if ( !BACKSQL_SUCCESS( rc ) ) { - Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " - "SQLAllocConnect() failed:\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): " + "SQLAllocConnect() failed:\n", ldap_cid, 0, 0 ); backsql_PrintErrors( bi->sql_db_env, SQL_NULL_HDBC, SQL_NULL_HENV, rc ); return LDAP_UNAVAILABLE; @@ -342,9 +356,9 @@ backsql_open_db_conn( backsql_info *bi, unsigned long ldap_cid, backsql_db_conn (SQLCHAR*)bi->sql_dbuser, SQL_NTS, (SQLCHAR*)bi->sql_dbpasswd, SQL_NTS ); if ( rc != SQL_SUCCESS ) { - Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " - "SQLConnect() to database \"%s\" as user \"%s\" " - "%s:\n", bi->sql_dbname, bi->sql_dbuser, + Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): " + "SQLConnect() to database \"%s\" %s.\n", + ldap_cid, bi->sql_dbname, rc == SQL_SUCCESS_WITH_INFO ? "succeeded with info" : "failed" ); backsql_PrintErrors( bi->sql_db_env, dbc->dbh, SQL_NULL_HENV, rc ); @@ -371,28 +385,28 @@ backsql_open_db_conn( backsql_info *bi, unsigned long ldap_cid, backsql_db_conn if ( rc == SQL_SUCCESS ) { if ( strcmp( DBMSName, "TimesTen" ) == 0 || strcmp( DBMSName, "Front-Tier" ) == 0 ) { - Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " - "TimesTen database!\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): " + "TimesTen database!\n", ldap_cid, 0, 0 ); bi->sql_flags |= BSQLF_USE_REVERSE_DN; } } else { - Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " - "SQLGetInfo() failed:\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): " + "SQLGetInfo() failed.\n", ldap_cid, 0, 0 ); backsql_PrintErrors( bi->sql_db_env, dbc->dbh, SQL_NULL_HENV, rc ); return rc; } /* end TimesTen */ - Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(): " - "connected, adding to tree\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): " + "connected, adding to tree.\n", ldap_cid, 0, 0 ); ldap_pvt_thread_mutex_lock( &bi->sql_dbconn_mutex ); if ( avl_insert( &bi->sql_db_conns, dbc, backsql_cmp_connid, avl_dup_error ) ) { - Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " - "duplicate connection ID\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): " + "duplicate connection ID.\n", ldap_cid, 0, 0 ); return LDAP_OTHER; } ldap_pvt_thread_mutex_unlock( &bi->sql_dbconn_mutex ); - Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn()\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn(%lu)\n", ldap_cid, 0, 0 ); *pdbc = dbc; @@ -418,11 +432,14 @@ backsql_free_db_conn( Operation *op ) */ if ( conn != NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_free_db_conn(): " - "closing db connection\n", 0, 0, 0 ); - backsql_close_db_conn( conn ); + "closing db connection %lu (%p)\n", + op->o_connid, conn, 0 ); + backsql_close_db_conn( (void *)conn ); } + Debug( LDAP_DEBUG_TRACE, "<==backsql_free_db_conn()\n", 0, 0, 0 ); - return SQL_SUCCESS; + + return conn ? SQL_SUCCESS : SQL_ERROR; } int @@ -435,7 +452,7 @@ backsql_get_db_conn( Operation *op, SQLHDBC *dbh ) Debug( LDAP_DEBUG_TRACE, "==>backsql_get_db_conn()\n", 0, 0, 0 ); - assert( dbh ); + assert( dbh != NULL ); *dbh = SQL_NULL_HDBC; tmp.ldap_cid = op->o_connid; diff --git a/servers/slapd/back-sql/util.c b/servers/slapd/back-sql/util.c index c90823b73e..4bb276f0f2 100644 --- a/servers/slapd/back-sql/util.c +++ b/servers/slapd/back-sql/util.c @@ -71,7 +71,7 @@ backsql_strcat( struct berbuf *dest, ... ) ber_len_t cdlen, cslen, grow; char *cstr; - assert( dest ); + assert( dest != NULL ); assert( dest->bb_val.bv_val == NULL || dest->bb_val.bv_len == strlen( dest->bb_val.bv_val ) ); @@ -138,8 +138,8 @@ backsql_strfcat( struct berbuf *dest, const char *fmt, ... ) va_list strs; ber_len_t cdlen; - assert( dest ); - assert( fmt ); + assert( dest != NULL ); + assert( fmt != NULL ); assert( dest->bb_len == 0 || dest->bb_len > dest->bb_val.bv_len ); assert( dest->bb_val.bv_val == NULL || dest->bb_val.bv_len == strlen( dest->bb_val.bv_val ) ); @@ -225,7 +225,7 @@ backsql_strfcat( struct berbuf *dest, const char *fmt, ... ) #endif /* BACKSQL_TRACE */ } - assert( cstr ); + assert( cstr != NULL ); AC_MEMCPY( dest->bb_val.bv_val + cdlen, cstr, cslen + 1 ); cdlen += cslen; @@ -280,8 +280,8 @@ backsql_get_table_spec( backsql_info *bi, char **p ) char *s, *q; struct berbuf res = BB_NULL; - assert( p ); - assert( *p ); + assert( p != NULL ); + assert( *p != NULL ); s = *p; while ( **p && **p != ',' ) { @@ -397,8 +397,8 @@ backsql_split_pattern( #define SPLIT_CHAR '?' - assert( _pattern ); - assert( split_pattern ); + assert( _pattern != NULL ); + assert( split_pattern != NULL ); pattern = ch_strdup( _pattern ); @@ -457,7 +457,7 @@ backsql_prepare_pattern( int i; struct berbuf bb = BB_NULL; - assert( res ); + assert( res != NULL ); for ( i = 0; values[i].bv_val; i++ ) { if ( split_pattern[i].bv_val == NULL ) { @@ -496,9 +496,9 @@ backsql_entryUUID( /* entryUUID is generated as "%08x-%04x-%04x-0000-eaddrXXX" * with eid_oc_id as %08x and hi and lo eid_id as %04x-%04x */ - assert( bi ); - assert( id ); - assert( entryUUID ); + assert( bi != NULL ); + assert( id != NULL ); + assert( entryUUID != NULL ); #ifdef BACKSQL_ARBITRARY_KEY snprintf( uuidbuf, sizeof( uuidbuf ), diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 9e352079cd..e100b60022 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -37,15 +37,6 @@ #include "lutil.h" #include "lber_pvt.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" - -static void init_group_pblock( Operation *op, Entry *target, - Entry *e, struct berval *op_ndn, AttributeDescription *group_at ); -static int call_group_preop_plugins( Operation *op ); -static void call_group_postop_plugins( Operation *op ); -#endif /* LDAP_SLAPI */ - /* * If a module is configured as dynamic, its header should not * get included into slapd. While this is a general rule and does @@ -99,7 +90,7 @@ int backend_init(void) } for( bi=slap_binfo; bi->bi_type != NULL; bi++,nBackendInfo++ ) { - assert( bi->bi_init ); + assert( bi->bi_init != 0 ); rc = bi->bi_init( bi ); @@ -202,7 +193,7 @@ int backend_startup_one(Backend *be) { int rc = 0; - assert( be ); + assert( be != NULL ); be->be_pending_csn_list = (struct be_pcl *) ch_calloc( 1, sizeof( struct be_pcl )); @@ -331,7 +322,6 @@ int backend_num( Backend *be ) int backend_shutdown( Backend *be ) { - int i; int rc = 0; BackendInfo *bi; @@ -392,9 +382,11 @@ int backend_shutdown( Backend *be ) return 0; } -void backend_destroy_one( BackendDB *bd ) +void backend_destroy_one( BackendDB *bd, int dynamic ) { - LDAP_STAILQ_REMOVE(&backendDB, bd, slap_backend_db, be_next ); + if ( dynamic ) { + LDAP_STAILQ_REMOVE(&backendDB, bd, slap_backend_db, be_next ); + } if ( bd->be_syncinfo ) { syncinfo_free( bd->be_syncinfo ); @@ -411,6 +403,7 @@ void backend_destroy_one( BackendDB *bd ) csne = LDAP_TAILQ_NEXT( csne, ce_csn_link ); ch_free( tmp_csne ); } + ch_free( bd->be_pending_csn_list ); } if ( bd->bd_info->bi_db_destroy ) { @@ -428,18 +421,31 @@ void backend_destroy_one( BackendDB *bd ) free( bd->be_rootpw.bv_val ); } acl_destroy( bd->be_acl, frontendDB->be_acl ); - free( bd ); + limits_destroy( bd->be_limits ); + if ( bd->be_replogfile ) { + ch_free( bd->be_replogfile ); + } + destroy_replica_info( bd ); + if ( !BER_BVISNULL( &bd->be_update_ndn ) ) { + ch_free( bd->be_update_ndn.bv_val ); + } + if ( bd->be_update_refs ) { + ber_bvarray_free( bd->be_update_refs ); + } + + if ( dynamic ) { + free( bd ); + } } int backend_destroy(void) { - int i; BackendDB *bd; BackendInfo *bi; /* destroy each backend database */ while (( bd = LDAP_STAILQ_FIRST(&backendDB))) { - backend_destroy_one( bd ); + backend_destroy_one( bd, 1 ); } /* destroy each backend type */ @@ -470,6 +476,9 @@ int backend_destroy(void) free( bd->be_rootpw.bv_val ); } acl_destroy( bd->be_acl, frontendDB->be_acl ); + + assert( bd->be_replogfile == NULL ); + assert( bd->be_replica == NULL ); } return 0; @@ -540,7 +549,6 @@ void be_db_close( void ) { BackendDB *be; - int i; LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) { if ( be->bd_info->bi_db_close ) { @@ -560,7 +568,7 @@ select_backend( int manageDSAit, int noSubs ) { - int i, j; + int j; ber_len_t len, dnlen = dn->bv_len; Backend *be, *b2 = NULL; @@ -726,45 +734,13 @@ be_entry_release_rw( int backend_unbind( Operation *op, SlapReply *rs ) { - int i = 0; BackendDB *be; LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) { -#if defined( LDAP_SLAPI ) - if ( op->o_pb ) { - int rc; - if ( i == 0 ) slapi_int_pblock_set_operation( op->o_pb, op ); - slapi_pblock_set( op->o_pb, SLAPI_BACKEND, (void *)be ); - rc = slapi_int_call_plugins( be, - SLAPI_PLUGIN_PRE_UNBIND_FN, (Slapi_PBlock *)op->o_pb ); - if ( rc < 0 ) { - /* - * A preoperation plugin failure will abort the - * entire operation. - */ - Debug(LDAP_DEBUG_TRACE, - "do_bind: Unbind preoperation plugin failed\n", - 0, 0, 0); - return 0; - } - } -#endif /* defined( LDAP_SLAPI ) */ - if ( be->be_unbind ) { op->o_bd = be; be->be_unbind( op, rs ); } - -#if defined( LDAP_SLAPI ) - if ( op->o_pb != NULL && slapi_int_call_plugins( be, - SLAPI_PLUGIN_POST_UNBIND_FN, (Slapi_PBlock *)op->o_pb ) < 0 ) - { - Debug(LDAP_DEBUG_TRACE, - "do_unbind: Unbind postoperation plugins failed\n", - 0, 0, 0); - } -#endif /* defined( LDAP_SLAPI ) */ - i++; } return 0; @@ -1221,7 +1197,7 @@ be_entry_get_rw( } int -backend_group( +fe_acl_group( Operation *op, Entry *target, struct berval *gr_ndn, @@ -1235,8 +1211,6 @@ backend_group( GroupAssertion *g; Backend *be = op->o_bd; - if ( op->o_abandon ) return SLAPD_ABANDON; - op->o_bd = select_backend( gr_ndn, 0, 0 ); for ( g = op->o_groups; g; g = g->ga_next ) { @@ -1262,17 +1236,6 @@ backend_group( rc = be_entry_get_rw( op, gr_ndn, group_oc, group_at, 0, &e ); } if ( e ) { -#ifdef LDAP_SLAPI - if ( op->o_pb != NULL ) { - init_group_pblock( op, target, e, op_ndn, group_at ); - - rc = call_group_preop_plugins( op ); - if ( rc == LDAP_SUCCESS ) { - goto done; - } - } -#endif /* LDAP_SLAPI */ - a = attr_find( e->e_attrs, group_at ); if ( a ) { /* If the attribute is a subtype of labeledURI, treat this as @@ -1382,10 +1345,6 @@ loopit: rc = LDAP_NO_SUCH_OBJECT; } -#ifdef LDAP_SLAPI - if ( op->o_pb ) call_group_postop_plugins( op ); -#endif /* LDAP_SLAPI */ - if ( op->o_tag != LDAP_REQ_BIND && !op->o_do_not_cache ) { g = op->o_tmpalloc( sizeof( GroupAssertion ) + gr_ndn->bv_len, op->o_tmpmemctx ); @@ -1403,60 +1362,33 @@ done: return rc; } -#ifdef LDAP_SLAPI -static int backend_compute_output_attr(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e) +int +backend_group( + Operation *op, + Entry *target, + struct berval *gr_ndn, + struct berval *op_ndn, + ObjectClass *group_oc, + AttributeDescription *group_at ) { - BerVarray v; - int rc; - BerVarray *vals = (BerVarray *)c->cac_private; - Operation *op = NULL; - int i, j; - - slapi_pblock_get( c->cac_pb, SLAPI_OPERATION, &op ); - if ( op == NULL ) { - return 1; - } + int rc; + BackendDB *be_orig; - if ( op->o_conn && access_allowed( op, - e, a->a_desc, NULL, ACL_AUTH, - &c->cac_acl_state ) == 0 ) { - return 1; + if ( op->o_abandon ) { + return SLAPD_ABANDON; } - for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) ; - - v = op->o_tmpalloc( sizeof(struct berval) * (i+1), - op->o_tmpmemctx ); - for ( i = 0, j = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ) { - if ( op->o_conn && access_allowed( op, - e, a->a_desc, - &a->a_nvals[i], - ACL_AUTH, &c->cac_acl_state ) == 0 ) { - continue; - } - ber_dupbv_x( &v[j], - &a->a_nvals[i], op->o_tmpmemctx ); - if ( !BER_BVISNULL( &v[j] ) ) { - j++; - } - } - - if ( j == 0 ) { - op->o_tmpfree( v, op->o_tmpmemctx ); - *vals = NULL; - rc = 1; - } else { - BER_BVZERO( &v[j] ); - *vals = v; - rc = 0; - } + be_orig = op->o_bd; + op->o_bd = frontendDB; + rc = frontendDB->be_group( op, target, gr_ndn, + op_ndn, group_oc, group_at ); + op->o_bd = be_orig; return rc; } -#endif /* LDAP_SLAPI */ int -backend_attribute( +fe_acl_attribute( Operation *op, Entry *target, struct berval *edn, @@ -1551,29 +1483,6 @@ backend_attribute( rc = LDAP_SUCCESS; } } -#ifdef LDAP_SLAPI - else if ( op->o_pb ) { - /* try any computed attributes */ - computed_attr_context ctx; - - slapi_int_pblock_set_operation( op->o_pb, op ); - - ctx.cac_pb = op->o_pb; - ctx.cac_attrs = NULL; - ctx.cac_userattrs = 0; - ctx.cac_opattrs = 0; - ctx.cac_acl_state = acl_state; - ctx.cac_private = (void *)vals; - - rc = compute_evaluator( &ctx, entry_at->ad_cname.bv_val, e, backend_compute_output_attr ); - if ( rc == 1 ) { - rc = LDAP_INSUFFICIENT_ACCESS; - - } else { - rc = LDAP_SUCCESS; - } - } -#endif /* LDAP_SLAPI */ freeit: if ( e != target ) { be_entry_release_r( op, e ); } @@ -1586,20 +1495,26 @@ freeit: if ( e != target ) { return rc; } -#ifdef LDAP_SLAPI -static int backend_compute_output_attr_access(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e) +int +backend_attribute( + Operation *op, + Entry *target, + struct berval *edn, + AttributeDescription *entry_at, + BerVarray *vals, + slap_access_t access ) { - struct berval *nval = (struct berval *)c->cac_private; - Operation *op = NULL; + int rc; + BackendDB *be_orig; - slapi_pblock_get( c->cac_pb, SLAPI_OPERATION, &op ); - if ( op == NULL ) { - return 1; - } + be_orig = op->o_bd; + op->o_bd = frontendDB; + rc = frontendDB->be_attribute( op, target, edn, + entry_at, vals, access ); + op->o_bd = be_orig; - return access_allowed( op, e, a->a_desc, nval, ACL_AUTH, NULL ) == 0; + return rc; } -#endif /* LDAP_SLAPI */ int backend_access( @@ -1616,9 +1531,9 @@ backend_access( Backend *be = op->o_bd; /* pedantic */ - assert( op ); - assert( op->o_conn ); - assert( edn ); + assert( op != NULL ); + assert( op->o_conn != NULL ); + assert( edn != NULL ); assert( access > ACL_NONE ); op->o_bd = select_backend( edn, 0, 0 ); @@ -1689,28 +1604,6 @@ backend_access( } rc = LDAP_SUCCESS; } -#ifdef LDAP_SLAPI - else if ( op->o_pb ) { - /* try any computed attributes */ - computed_attr_context ctx; - - slapi_int_pblock_set_operation( op->o_pb, op ); - - ctx.cac_pb = op->o_pb; - ctx.cac_attrs = NULL; - ctx.cac_userattrs = 0; - ctx.cac_opattrs = 0; - ctx.cac_private = (void *)nval; - - rc = compute_evaluator( &ctx, entry_at->ad_cname.bv_val, e, backend_compute_output_attr_access ); - if ( rc == 1 ) { - rc = LDAP_INSUFFICIENT_ACCESS; - - } else { - rc = LDAP_SUCCESS; - } - } -#endif /* LDAP_SLAPI */ } freeit: if ( e != target ) { be_entry_release_r( op, e ); @@ -1724,13 +1617,14 @@ freeit: if ( e != target ) { return rc; } -int backend_operational( +int +fe_aux_operational( Operation *op, SlapReply *rs ) { - Attribute **ap; - int rc = 0; - BackendDB *be_orig; + Attribute **ap; + int rc = 0; + BackendDB *be_orig; for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) /* just count them */ ; @@ -1754,59 +1648,35 @@ int backend_operational( ap = &(*ap)->a_next; } - /* Let the overlays have a chance at this */ - be_orig = op->o_bd; - if ( SLAP_ISOVERLAY( be_orig ) ) - op->o_bd = select_backend( be_orig->be_nsuffix, 0, 0 ); - - if ( ( SLAP_OPATTRS( rs->sr_attr_flags ) || rs->sr_attrs ) && - op->o_bd && op->o_bd->be_operational != NULL ) + if ( op->o_bd != NULL ) { - rc = op->o_bd->be_operational( op, rs ); + /* Let the overlays have a chance at this */ + be_orig = op->o_bd; + op->o_bd = select_backend( &op->o_req_ndn, 0, 0 ); + if ( op->o_bd != frontendDB && + ( SLAP_OPATTRS( rs->sr_attr_flags ) || rs->sr_attrs ) && + op->o_bd != NULL && op->o_bd->be_operational != NULL ) + { + rc = op->o_bd->be_operational( op, rs ); + } + op->o_bd = be_orig; } - op->o_bd = be_orig; return rc; } -#ifdef LDAP_SLAPI -static void init_group_pblock( Operation *op, Entry *target, - Entry *e, struct berval *op_ndn, AttributeDescription *group_at ) -{ - slapi_int_pblock_set_operation( op->o_pb, op ); - - slapi_pblock_set( op->o_pb, - SLAPI_X_GROUP_ENTRY, (void *)e ); - slapi_pblock_set( op->o_pb, - SLAPI_X_GROUP_OPERATION_DN, (void *)op_ndn->bv_val ); - slapi_pblock_set( op->o_pb, - SLAPI_X_GROUP_ATTRIBUTE, (void *)group_at->ad_cname.bv_val ); - slapi_pblock_set( op->o_pb, - SLAPI_X_GROUP_TARGET_ENTRY, (void *)target ); -} - -static int call_group_preop_plugins( Operation *op ) +int backend_operational( Operation *op, SlapReply *rs ) { int rc; + BackendDB *be_orig; - rc = slapi_int_call_plugins( op->o_bd, - SLAPI_X_PLUGIN_PRE_GROUP_FN, op->o_pb ); - if ( rc < 0 ) { - if (( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, - (void *)&rc ) != 0 ) || rc == LDAP_SUCCESS ) - { - rc = LDAP_NO_SUCH_ATTRIBUTE; - } - } else { - rc = LDAP_SUCCESS; - } + /* Moved this into the frontend so global overlays are called */ - return rc; -} + be_orig = op->o_bd; + op->o_bd = frontendDB; + rc = frontendDB->be_operational( op, rs ); + op->o_bd = be_orig; -static void call_group_postop_plugins( Operation *op ) -{ - (void) slapi_int_call_plugins( op->o_bd, SLAPI_X_PLUGIN_POST_GROUP_FN, op->o_pb ); + return rc; } -#endif /* LDAP_SLAPI */ diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c index 90c395a40f..8260f29a6d 100644 --- a/servers/slapd/backover.c +++ b/servers/slapd/backover.c @@ -29,7 +29,12 @@ static slap_overinst *overlays; -enum db_which { db_open = 0, db_close, db_destroy }; +enum db_which { + db_open = 0, + db_close, + db_destroy, + db_last +}; static int over_db_func( @@ -74,7 +79,6 @@ over_db_config( BackendInfo *bi_orig = be->bd_info; struct ConfigOCs *be_cf_ocs = be->be_cf_ocs; ConfigArgs ca = {0}; - ConfigTable *ct; int rc = 0; if ( oi->oi_orig->bi_db_config ) { @@ -299,31 +303,149 @@ over_access_allowed( return rc; } -#endif /* SLAP_OVERLAY_ACCESS */ -enum op_which { - op_bind = 0, - op_unbind, - op_search, - op_compare, - op_modify, - op_modrdn, - op_add, - op_delete, - op_abandon, - op_cancel, - op_extended, - op_aux_operational, - op_aux_chk_referrals, - op_aux_chk_controls, - op_last -}; +static int +over_acl_group( + Operation *op, + Entry *e, + struct berval *gr_ndn, + struct berval *op_ndn, + ObjectClass *group_oc, + AttributeDescription *group_at ) +{ + slap_overinfo *oi; + slap_overinst *on; + BackendInfo *bi = op->o_bd->bd_info; + BackendDB *be = op->o_bd, db; + int rc = SLAP_CB_CONTINUE; + + /* FIXME: used to happen for instance during abandon + * when global overlays are used... */ + assert( op->o_bd != NULL ); + + oi = op->o_bd->bd_info->bi_private; + on = oi->oi_list; + + for ( ; on; on = on->on_next ) { + if ( on->on_bi.bi_acl_group ) { + /* NOTE: do not copy the structure until required */ + if ( !SLAP_ISOVERLAY( op->o_bd ) ) { + db = *op->o_bd; + db.be_flags |= SLAP_DBFLAG_OVERLAY; + op->o_bd = &db; + } + + op->o_bd->bd_info = (BackendInfo *)on; + rc = on->on_bi.bi_acl_group( op, e, + gr_ndn, op_ndn, group_oc, group_at ); + if ( rc != SLAP_CB_CONTINUE ) break; + } + } + + if ( rc == SLAP_CB_CONTINUE ) { + BI_acl_group *bi_acl_group; + + /* if the database structure was changed, o_bd points to a + * copy of the structure; put the original bd_info in place */ + if ( SLAP_ISOVERLAY( op->o_bd ) ) { + op->o_bd->bd_info = oi->oi_orig; + } + + if ( oi->oi_orig->bi_acl_group ) { + bi_acl_group = oi->oi_orig->bi_acl_group; + } else { + bi_acl_group = backend_group; + } + + rc = bi_acl_group( op, e, + gr_ndn, op_ndn, group_oc, group_at ); + } + /* should not fall thru this far without anything happening... */ + if ( rc == SLAP_CB_CONTINUE ) { + /* access not allowed */ + rc = 0; + } + + op->o_bd = be; + op->o_bd->bd_info = bi; + + return rc; +} + +static int +over_acl_attribute( + Operation *op, + Entry *target, + struct berval *entry_ndn, + AttributeDescription *entry_at, + BerVarray *vals, + slap_access_t access ) +{ + slap_overinfo *oi; + slap_overinst *on; + BackendInfo *bi = op->o_bd->bd_info; + BackendDB *be = op->o_bd, db; + int rc = SLAP_CB_CONTINUE; + + /* FIXME: used to happen for instance during abandon + * when global overlays are used... */ + assert( op->o_bd != NULL ); + + oi = op->o_bd->bd_info->bi_private; + on = oi->oi_list; + + for ( ; on; on = on->on_next ) { + if ( on->on_bi.bi_acl_attribute ) { + /* NOTE: do not copy the structure until required */ + if ( !SLAP_ISOVERLAY( op->o_bd ) ) { + db = *op->o_bd; + db.be_flags |= SLAP_DBFLAG_OVERLAY; + op->o_bd = &db; + } + + op->o_bd->bd_info = (BackendInfo *)on; + rc = on->on_bi.bi_acl_attribute( op, target, + entry_ndn, entry_at, vals, access ); + if ( rc != SLAP_CB_CONTINUE ) break; + } + } + + if ( rc == SLAP_CB_CONTINUE ) { + BI_acl_attribute *bi_acl_attribute; + + /* if the database structure was changed, o_bd points to a + * copy of the structure; put the original bd_info in place */ + if ( SLAP_ISOVERLAY( op->o_bd ) ) { + op->o_bd->bd_info = oi->oi_orig; + } + + if ( oi->oi_orig->bi_acl_attribute ) { + bi_acl_attribute = oi->oi_orig->bi_acl_attribute; + } else { + bi_acl_attribute = backend_attribute; + } + + rc = bi_acl_attribute( op, target, + entry_ndn, entry_at, vals, access ); + } + /* should not fall thru this far without anything happening... */ + if ( rc == SLAP_CB_CONTINUE ) { + /* access not allowed */ + rc = 0; + } + + op->o_bd = be; + op->o_bd->bd_info = bi; + + return rc; +} +#endif /* SLAP_OVERLAY_ACCESS */ /* * default return code in case of missing backend function * and overlay stack returning SLAP_CB_CONTINUE */ -static int op_rc[] = { +static int op_rc[ op_last ] = { LDAP_UNWILLING_TO_PERFORM, /* bind */ LDAP_UNWILLING_TO_PERFORM, /* unbind */ LDAP_UNWILLING_TO_PERFORM, /* search */ @@ -340,36 +462,17 @@ static int op_rc[] = { SLAP_CB_CONTINUE /* aux_chk_controls; pass to frontend */ }; -static int -over_op_func( +int overlay_op_walk( Operation *op, SlapReply *rs, - enum op_which which + slap_operation_t which, + slap_overinfo *oi, + slap_overinst *on ) { - slap_overinfo *oi; - slap_overinst *on; BI_op_bind **func; - BackendDB *be = op->o_bd, db; - slap_callback cb = {NULL, over_back_response, NULL, NULL}; int rc = SLAP_CB_CONTINUE; - /* FIXME: used to happen for instance during abandon - * when global overlays are used... */ - assert( op->o_bd != NULL ); - - oi = op->o_bd->bd_info->bi_private; - on = oi->oi_list; - - if ( !SLAP_ISOVERLAY( op->o_bd )) { - db = *op->o_bd; - db.be_flags |= SLAP_DBFLAG_OVERLAY; - op->o_bd = &db; - } - cb.sc_next = op->o_callback; - cb.sc_private = oi; - op->o_callback = &cb; - for (; on; on=on->on_next ) { func = &on->on_bi.bi_op_bind; if ( func[which] ) { @@ -394,14 +497,48 @@ over_op_func( */ if ( rc == LDAP_UNWILLING_TO_PERFORM ) { slap_callback *sc_next; - for ( ; op->o_callback && op->o_callback != cb.sc_next; - op->o_callback = sc_next ) { + for ( ; op->o_callback && op->o_callback->sc_response != + over_back_response; op->o_callback = sc_next ) { sc_next = op->o_callback->sc_next; if ( op->o_callback->sc_cleanup ) { op->o_callback->sc_cleanup( op, rs ); } } } + return rc; +} + +static int +over_op_func( + Operation *op, + SlapReply *rs, + slap_operation_t which +) +{ + slap_overinfo *oi; + slap_overinst *on; + BackendDB *be = op->o_bd, db; + slap_callback cb = {NULL, over_back_response, NULL, NULL}; + int rc = SLAP_CB_CONTINUE; + + /* FIXME: used to happen for instance during abandon + * when global overlays are used... */ + assert( op->o_bd != NULL ); + + oi = op->o_bd->bd_info->bi_private; + on = oi->oi_list; + + if ( !SLAP_ISOVERLAY( op->o_bd )) { + db = *op->o_bd; + db.be_flags |= SLAP_DBFLAG_OVERLAY; + op->o_bd = &db; + } + cb.sc_next = op->o_callback; + cb.sc_private = oi; + op->o_callback = &cb; + + rc = overlay_op_walk( op, rs, which, oi, on ); + op->o_bd = be; op->o_callback = cb.sc_next; return rc; @@ -493,7 +630,8 @@ over_aux_chk_controls( Operation *op, SlapReply *rs ) enum conn_which { conn_init = 0, - conn_destroy + conn_destroy, + conn_last }; static int @@ -601,7 +739,7 @@ overlay_find( const char *over_type ) { slap_overinst *on = overlays; - assert( over_type ); + assert( over_type != NULL ); for ( ; on; on = on->on_next ) { if ( strcmp( on->on_bi.bi_type, over_type ) == 0 ) { @@ -636,7 +774,7 @@ overlay_is_inst( BackendDB *be, const char *over_type ) { slap_overinst *on; - assert( be ); + assert( be != NULL ); if ( !overlay_is_over( be ) ) { return 0; @@ -773,8 +911,10 @@ overlay_config( BackendDB *be, const char *ov ) bi->bi_chk_controls = over_aux_chk_controls; #ifdef SLAP_OVERLAY_ACCESS - /* this has a specific arglist */ + /* these have specific arglists */ bi->bi_access_allowed = over_access_allowed; + bi->bi_acl_group = over_acl_group; + bi->bi_acl_attribute = over_acl_attribute; #endif /* SLAP_OVERLAY_ACCESS */ bi->bi_connection_init = over_connection_init; diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 91c8659765..d050122be2 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -32,6 +32,7 @@ #include "slapi/slapi.h" #endif +#include #include #include "config.h" @@ -78,7 +79,9 @@ static int replicationInterval; static char *passwd_salt; static char *logfileName; +#ifdef SLAP_AUTH_REWRITE static BerVarray authz_rewrites; +#endif static struct berval cfdir; @@ -86,7 +89,7 @@ static struct berval cfdir; static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay, *cfAd_include; -static ConfigFile cf_prv, *cfn = &cf_prv; +static ConfigFile *cfn; static Avlnode *CfOcTree; @@ -103,7 +106,6 @@ static ConfigDriver config_sizelimit; static ConfigDriver config_timelimit; static ConfigDriver config_overlay; static ConfigDriver config_suffix; -static ConfigDriver config_deref_depth; static ConfigDriver config_rootdn; static ConfigDriver config_rootpw; static ConfigDriver config_restrict; @@ -571,20 +573,25 @@ static ConfigTable config_back_cf_table[] = { static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase, cfAddBackend, cfAddModule, cfAddOverlay; +/* NOTE: be careful when defining array members + * that can be conditionally compiled */ #define CFOC_GLOBAL cf_ocs[1] #define CFOC_SCHEMA cf_ocs[2] #define CFOC_BACKEND cf_ocs[3] #define CFOC_DATABASE cf_ocs[4] #define CFOC_OVERLAY cf_ocs[5] #define CFOC_INCLUDE cf_ocs[6] -#define CFOC_MODULE cf_ocs[7] +#define CFOC_FRONTEND cf_ocs[7] +#ifdef SLAPD_MODULES +#define CFOC_MODULE cf_ocs[8] +#endif /* SLAPD_MODULES */ static ConfigOCs cf_ocs[] = { - { "( OLcfgGlOc:1 " + { "( OLcfgGlOc:0 " "NAME 'olcConfig' " "DESC 'OpenLDAP configuration object' " "ABSTRACT SUP top )", Cft_Abstract, NULL }, - { "( OLcfgGlOc:2 " + { "( OLcfgGlOc:1 " "NAME 'olcGlobal' " "DESC 'OpenLDAP Global configuration options' " "SUP olcConfig STRUCTURAL " @@ -600,7 +607,7 @@ static ConfigOCs cf_ocs[] = { "olcPluginLogFile $ olcReadOnly $ olcReferral $ " "olcReplicaPidFile $ olcReplicaArgsFile $ olcReplicationInterval $ " "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ " - "olcRootDSE $ olcRootPW $ " + "olcRootDSE $ " "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ " "olcSecurity $ olcSizeLimit $ " "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ olcSrvtab $ " @@ -610,19 +617,19 @@ static ConfigOCs cf_ocs[] = { "olcTLSRandFile $ olcTLSVerifyClient $ " "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ " "olcDitContentRules ) )", Cft_Global }, - { "( OLcfgGlOc:3 " + { "( OLcfgGlOc:2 " "NAME 'olcSchemaConfig' " "DESC 'OpenLDAP schema object' " "SUP olcConfig STRUCTURAL " "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ " "olcObjectClasses $ olcDitContentRules ) )", Cft_Schema, NULL, cfAddSchema }, - { "( OLcfgGlOc:4 " + { "( OLcfgGlOc:3 " "NAME 'olcBackendConfig' " "DESC 'OpenLDAP Backend-specific options' " "SUP olcConfig STRUCTURAL " "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend }, - { "( OLcfgGlOc:5 " + { "( OLcfgGlOc:4 " "NAME 'olcDatabaseConfig' " "DESC 'OpenLDAP Database-specific options' " "SUP olcConfig STRUCTURAL " @@ -633,18 +640,28 @@ static ConfigOCs cf_ocs[] = { "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ " "olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )", Cft_Database, NULL, cfAddDatabase }, - { "( OLcfgGlOc:6 " + { "( OLcfgGlOc:5 " "NAME 'olcOverlayConfig' " "DESC 'OpenLDAP Overlay-specific options' " "SUP olcConfig STRUCTURAL " "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay }, - { "( OLcfgGlOc:7 " + { "( OLcfgGlOc:6 " "NAME 'olcIncludeFile' " "DESC 'OpenLDAP configuration include file' " "SUP olcConfig STRUCTURAL " "MUST olcInclude " "MAY ( cn $ olcRootDSE ) )", Cft_Include, NULL, cfAddInclude }, + /* This should be STRUCTURAL like all the other database classes, but + * that would mean inheriting all of the olcDatabaseConfig attributes, + * which causes them to be merged twice in config_build_entry. + */ + { "( OLcfgGlOc:7 " + "NAME 'olcFrontendConfig' " + "DESC 'OpenLDAP frontend configuration' " + "AUXILIARY " + "MAY olcDefaultSearchBase )", + Cft_Database, NULL, NULL }, #ifdef SLAPD_MODULES { "( OLcfgGlOc:8 " "NAME 'olcModuleList' " @@ -1295,8 +1312,6 @@ config_cfdir(ConfigArgs *c) { static int config_search_base(ConfigArgs *c) { - struct berval dn; - if(c->op == SLAP_CONFIG_EMIT) { int rc = 1; if (!BER_BVISEMPTY(&default_search_base)) { @@ -1530,7 +1545,7 @@ config_overlay(ConfigArgs *c) { /* log error */ Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: (optional) %s overlay \"%s\" configuration failed" SLAPD_CONF_UNKNOWN_IGNORED ".\n", - c->log, c->be == frontendDB ? "global " : "", c->argv[1][1]); + c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]); #ifdef SLAPD_CONF_UNKNOWN_BAILOUT return 1; #endif /* SLAPD_CONF_UNKNOWN_BAILOUT */ @@ -1546,13 +1561,55 @@ config_overlay(ConfigArgs *c) { } static int -config_suffix(ConfigArgs *c) { +config_suffix(ConfigArgs *c) +{ Backend *tbe; struct berval pdn, ndn; - int rc; + char *notallowed = NULL; + + if ( c->be == frontendDB ) { + notallowed = "frontend"; + + } else if ( SLAP_MONITOR(c->be) ) { + notallowed = "monitor"; + + } else if ( SLAP_CONFIG(c->be) ) { + notallowed = "config"; + } + + if ( notallowed != NULL ) { + char buf[ SLAP_TEXT_BUFLEN ] = { '\0' }; + + switch ( c->op ) { + case LDAP_MOD_ADD: + case LDAP_MOD_DELETE: + case LDAP_MOD_REPLACE: + case LDAP_MOD_INCREMENT: + case SLAP_CONFIG_ADD: + if ( !BER_BVISNULL( &c->value_dn ) ) { + snprintf( buf, sizeof( buf ), "<%s> ", + c->value_dn.bv_val ); + } + + Debug(LDAP_DEBUG_ANY, + "%s: suffix %snot allowed in %s database.\n", + c->log, buf, notallowed ); + break; + + case SLAP_CONFIG_EMIT: + /* don't complain when emitting... */ + break; + + default: + /* FIXME: don't know what values may be valid; + * please remove assertion, or add legal values + * to either block */ + assert( 0 ); + break; + } - if (c->be == frontendDB || SLAP_MONITOR(c->be) || - SLAP_CONFIG(c->be)) return 1; + return 1; + } if (c->op == SLAP_CONFIG_EMIT) { if ( c->be->be_suffix == NULL @@ -1581,6 +1638,7 @@ config_suffix(ConfigArgs *c) { } return 0; } + #ifdef SLAPD_MONITOR_DN if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) { sprintf( c->msg, "<%s> DN is reserved for monitoring slapd", @@ -1651,16 +1709,12 @@ config_rootdn(ConfigArgs *c) { static int config_rootpw(ConfigArgs *c) { Backend *tbe; - /* config_add_internal sets c->be = frontendDB. While the cn=config - * rootpw is technically inside a backend, we expose it in the - * global entry, and need to point to it properly here. - */ - if (c->be == frontendDB) - c->be = LDAP_STAILQ_FIRST(&backendDB); if (c->op == SLAP_CONFIG_EMIT) { if (!BER_BVISEMPTY(&c->be->be_rootpw)) { - ber_dupbv( &c->value_bv, &c->be->be_rootpw); + /* don't copy, because "rootpw" is marked + * as CFG_BERVAL */ + c->value_bv = c->be->be_rootpw; return 0; } return 1; @@ -1833,11 +1887,12 @@ config_requires(ConfigArgs *c) { return(0); } +static slap_verbmasks *loglevel_ops; + static int -config_loglevel(ConfigArgs *c) { - int i; - char *next; - slap_verbmasks loglevel_ops[] = { +loglevel_init( void ) +{ + slap_verbmasks lo[] = { { BER_BVC("Any"), -1 }, { BER_BVC("Trace"), LDAP_DEBUG_TRACE }, { BER_BVC("Packets"), LDAP_DEBUG_PACKETS }, @@ -1857,6 +1912,68 @@ config_loglevel(ConfigArgs *c) { { BER_BVNULL, 0 } }; + return slap_verbmasks_init( &loglevel_ops, lo ); +} + +static void +loglevel_destroy( void ) +{ + if ( loglevel_ops ) { + (void)slap_verbmasks_destroy( loglevel_ops ); + } + loglevel_ops = NULL; +} + +static slap_mask_t loglevel_ignore[] = { -1, 0 }; + +int +slap_loglevel_register( slap_mask_t m, struct berval *s ) +{ + int rc; + + if ( loglevel_ops == NULL ) { + loglevel_init(); + } + + rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore ); + + if ( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n", + m, s->bv_val, 0 ); + } + + return rc; +} + +int +str2loglevel( const char *s, int *l ) +{ + int i; + + if ( loglevel_ops == NULL ) { + loglevel_init(); + } + + i = verb_to_mask( s, loglevel_ops ); + + if ( BER_BVISNULL( &loglevel_ops[ i ].word) ) { + return -1; + } + + *l = loglevel_ops[ i ].mask; + + return 0; +} + +static int +config_loglevel(ConfigArgs *c) { + int i; + char *next; + + if ( loglevel_ops == NULL ) { + loglevel_init(); + } + if (c->op == SLAP_CONFIG_EMIT) { return mask_to_verbs( loglevel_ops, ldap_syslog, &c->rvalue_vals ); } else if ( c->op == LDAP_MOD_DELETE ) { @@ -1874,7 +1991,7 @@ config_loglevel(ConfigArgs *c) { for( i=1; i < c->argc; i++ ) { int level; - if ( isdigit( c->argv[i][0] ) ) { + if ( isdigit( c->argv[i][0] ) || c->argv[i][0] == '-' ) { level = strtol( c->argv[i], &next, 10 ); if ( next == NULL || next[0] != '\0' ) { sprintf( c->msg, "<%s> unable to parse level", c->argv[0] ); @@ -1883,14 +2000,12 @@ config_loglevel(ConfigArgs *c) { return( 1 ); } } else { - int j = verb_to_mask(c->argv[i], loglevel_ops); - if(BER_BVISNULL(&loglevel_ops[j].word)) { + if ( str2loglevel( c->argv[i], &level ) ) { sprintf( c->msg, "<%s> unknown level", c->argv[0] ); Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n", c->log, c->msg, c->argv[i]); return( 1 ); } - level = loglevel_ops[j].mask; } ldap_syslog |= level; } @@ -2018,7 +2133,7 @@ replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv ) { int len; char *ptr; - struct berval bc = {0}; + struct berval bc = BER_BVNULL; char numbuf[32]; len = sprintf(numbuf, IFMT, i ); @@ -2110,6 +2225,7 @@ config_replica(ConfigArgs *c) { return(1); } if(!ludp->lud_host) { + ldap_free_urldesc(ludp); sprintf( c->msg, "<%s> invalid uri - missing hostname", c->argv[0] ); Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 ); @@ -2183,8 +2299,6 @@ config_replica(ConfigArgs *c) { static int config_updatedn(ConfigArgs *c) { - struct berval dn; - int rc; if (c->op == SLAP_CONFIG_EMIT) { if (!BER_BVISEMPTY(&c->be->be_update_ndn)) { value_add_one(&c->rvalue_vals, &c->be->be_update_ndn); @@ -2194,7 +2308,7 @@ config_updatedn(ConfigArgs *c) { return 1; } else if ( c->op == LDAP_MOD_DELETE ) { ch_free( c->be->be_update_ndn.bv_val ); - c->be->be_update_ndn.bv_val = NULL; + BER_BVZERO( &c->be->be_update_ndn ); SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW); return 0; } @@ -2205,17 +2319,13 @@ config_updatedn(ConfigArgs *c) { return(1); } - ber_str2bv(c->argv[1], 0, 0, &dn); - - rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL); - - if(rc != LDAP_SUCCESS) { - sprintf( c->msg, "<%s> invalid DN %d (%s)", c->argv[0], - rc, ldap_err2string(rc)); - Debug(LDAP_DEBUG_ANY, "%s: %s\n", - c->log, c->msg, 0 ); - return(1); + ber_memfree_x( c->value_dn.bv_val, NULL ); + if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) { + ber_memfree_x( c->be->be_update_ndn.bv_val, NULL ); } + c->be->be_update_ndn = c->value_ndn; + BER_BVZERO( &c->value_dn ); + BER_BVZERO( &c->value_ndn ); SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW); return(0); @@ -2264,7 +2374,7 @@ config_updateref(ConfigArgs *c) { static int config_include(ConfigArgs *c) { - unsigned long savelineno = c->lineno; + int savelineno = c->lineno; int rc; ConfigFile *cf; ConfigFile *cfsave = cfn; @@ -2520,6 +2630,8 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) { op->o_bd = &cfb->cb_db; rc = op->o_bd->be_search( op, &rs ); + + slap_sl_mem_destroy( NULL, op->o_tmpmemctx ); } cfb->cb_use_ldif = 1; @@ -2609,7 +2721,7 @@ read_config(const char *fname, const char *dir) { rc = read_config_file(cfname, 0, NULL, config_back_cf_table); if ( rc == 0 ) - ber_str2bv( cfname, 0, 1, &cf_prv.c_file ); + ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file ); /* If we got this far and failed, it may be a serious problem. In server * mode, we should never come to this. However, it may be alright if we're @@ -2827,8 +2939,13 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e, return LDAP_NAMING_VIOLATION; gotindex = 1; index = atoi(ptr1+1); - if ( index < 0 ) - return LDAP_NAMING_VIOLATION; + if ( index < 0 ) { + /* Special case, we allow -1 for the frontendDB */ + if ( index != -1 || ce_type != Cft_Database || + strncmp( ptr2+1, "frontend,", STRLENOF("frontend,") )) + + return LDAP_NAMING_VIOLATION; + } } /* count related kids */ @@ -2959,10 +3076,7 @@ cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca ) if ( ca->lineno ) return LDAP_COMPARE_TRUE; - if ( p->ce_type == Cft_Global ) - cfn = &cf_prv; - else - cfn = p->ce_private; + cfn = p->ce_private; ca->private = cfn; return LDAP_SUCCESS; } @@ -2974,7 +3088,7 @@ cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca ) /* This entry is hardcoded, don't re-parse it */ if ( p->ce_type == Cft_Global ) { - cfn = &cf_prv; + cfn = p->ce_private; ca->private = cfn; return LDAP_COMPARE_TRUE; } @@ -3030,7 +3144,7 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs, i CfEntryInfo *ce, *last; ConfigOCs **colst; Attribute *a, *oc_at; - int i, j, nocs, rc = 0; + int i, nocs, rc = 0; struct berval pdn; ConfigTable *ct; char *ptr; @@ -3074,7 +3188,7 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs, i */ rc = LDAP_CONSTRAINT_VIOLATION; if ( colst[0]->co_type == Cft_Global && !last ) { - cfn = &cf_prv; + cfn = cfb->cb_config; ca->private = cfn; ca->be = frontendDB; /* just to get past check_vals */ rc = LDAP_SUCCESS; @@ -3200,7 +3314,8 @@ ok: leave: if ( rc ) { if ( (colst[0]->co_type == Cft_Database) && ca->be ) { - backend_destroy_one( ca->be ); + if ( ca->be != frontendDB ) + backend_destroy_one( ca->be, 1 ); } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) { overlay_destroy_one( ca->be, (slap_overinst *)ca->bi ); } @@ -3218,7 +3333,6 @@ static int config_back_add( Operation *op, SlapReply *rs ) { CfBackInfo *cfb; - CfEntryInfo *ce, *last; int renumber; ConfigArgs ca; @@ -3271,7 +3385,6 @@ static int config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs, ConfigArgs *ca ) { - CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private; int rc = LDAP_UNWILLING_TO_PERFORM; Modifications *ml; Entry *e = ce->ce_entry; @@ -3305,8 +3418,6 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs, int *idx = NULL; if ( ct && ( ct->arg_type & ARG_NO_DELETE )) { rc = LDAP_OTHER; - snprintf( ca->msg, sizeof(ca->msg), - "<%s> cannot be deleted" ); snprintf(ca->msg, sizeof(ca->msg), "cannot delete %s", ml->sml_desc->ad_cname.bv_val ); goto out; @@ -3402,7 +3513,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs, if(rc == LDAP_SUCCESS) { /* check that the entry still obeys the schema */ - rc = entry_schema_check(op->o_bd, e, NULL, 0, + rc = entry_schema_check(op, e, NULL, 0, &rs->sr_text, ca->msg, sizeof(ca->msg) ); } if ( rc == LDAP_SUCCESS ) { @@ -3626,7 +3737,6 @@ config_back_search( Operation *op, SlapReply *rs ) { CfBackInfo *cfb; CfEntryInfo *ce, *last; - int rc; if ( !be_isroot( op ) ) { rs->sr_err = LDAP_INSUFFICIENT_ACCESS; @@ -3861,12 +3971,10 @@ config_back_db_open( BackendDB *be ) CfBackInfo *cfb = be->be_private; struct berval rdn; Entry *e, *parent; - CfEntryInfo *ce, *ceparent, *ceprev; - int i, rc; + CfEntryInfo *ce, *ceparent; + int i; BackendInfo *bi; - BackendDB *bptr; ConfigArgs c; - ConfigTable *ct; Connection conn = {0}; char opbuf[OPERATION_BUFFER_SIZE]; Operation *op; @@ -3949,25 +4057,22 @@ config_back_db_open( BackendDB *be ) } /* Create database nodes... */ - i = -1; - LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) { + frontendDB->be_cf_ocs = &CFOC_FRONTEND; + LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB); + for ( i = -1, be = frontendDB ; be; + i++, be = LDAP_STAILQ_NEXT( be, be_next )) { slap_overinfo *oi = NULL; - i++; - if ( i == 0 ) { - bptr = frontendDB; - } else { - bptr = be; - } - if ( overlay_is_over( bptr )) { - oi = bptr->bd_info->bi_private; + + if ( overlay_is_over( be )) { + oi = be->bd_info->bi_private; bi = oi->oi_orig; } else { - bi = bptr->bd_info; + bi = be->bd_info; } rdn.bv_val = c.log; rdn.bv_len = sprintf(rdn.bv_val, "%s=" IFMT "%s", cfAd_database->ad_cname.bv_val, i, bi->bi_type); - c.be = bptr; + c.be = be; c.bi = bi; e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE, be->be_cf_ocs ); @@ -3984,7 +4089,7 @@ config_back_db_open( BackendDB *be ) rdn.bv_val = c.log; rdn.bv_len = sprintf(rdn.bv_val, "%s=" IFMT "%s", cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type ); - c.be = bptr; + c.be = be; c.bi = &on->on_bi; oe = config_build_entry( op, &rs, ce, &c, &rdn, &CFOC_OVERLAY, c.bi->bi_cf_ocs ); @@ -3993,25 +4098,93 @@ config_back_db_open( BackendDB *be ) } } } + if ( op ) + slap_sl_mem_destroy( NULL, op->o_tmpmemctx ); + + return 0; +} + +static void +cfb_free_cffile( ConfigFile *cf ) +{ + ConfigFile *next; + + for (; cf; cf=next) { + next = cf->c_sibs; + if ( cf->c_kids ) + cfb_free_cffile( cf->c_kids ); + ch_free( cf->c_file.bv_val ); + ber_bvarray_free( cf->c_dseFiles ); + ch_free( cf ); + } +} + +static void +cfb_free_entries( CfEntryInfo *ce ) +{ + CfEntryInfo *next; + + for (; ce; ce=next) { + next = ce->ce_sibs; + if ( ce->ce_kids ) + cfb_free_entries( ce->ce_kids ); + ce->ce_entry->e_private = NULL; + entry_free( ce->ce_entry ); + ch_free( ce ); + } +} + +static int +config_back_db_close( BackendDB *be ) +{ + CfBackInfo *cfb = be->be_private; + + cfb_free_entries( cfb->cb_root ); + cfb->cb_root = NULL; + + if ( cfb->cb_db.bd_info ) { + backend_shutdown( &cfb->cb_db ); + } return 0; } static int -config_back_db_destroy( Backend *be ) +config_back_db_destroy( BackendDB *be ) { + CfBackInfo *cfb = be->be_private; + + cfb_free_cffile( cfb->cb_config ); + + ch_free( cfdir.bv_val ); + + avl_free( CfOcTree, NULL ); + + if ( cfb->cb_db.bd_info ) { + cfb->cb_db.be_suffix = NULL; + cfb->cb_db.be_nsuffix = NULL; + BER_BVZERO( &cfb->cb_db.be_rootdn ); + BER_BVZERO( &cfb->cb_db.be_rootndn ); + + backend_destroy_one( &cfb->cb_db, 0 ); + } + free( be->be_private ); + + loglevel_destroy(); + return 0; } static int -config_back_db_init( Backend *be ) +config_back_db_init( BackendDB *be ) { struct berval dn; CfBackInfo *cfb; cfb = ch_calloc( 1, sizeof(CfBackInfo)); - cfb->cb_config = &cf_prv; + cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile)); + cfn = cfb->cb_config; be->be_private = cfb; ber_dupbv( &be->be_rootdn, &config_rdn ); @@ -4166,7 +4339,7 @@ config_back_initialize( BackendInfo *bi ) bi->bi_db_init = config_back_db_init; bi->bi_db_config = 0; bi->bi_db_open = config_back_db_open; - bi->bi_db_close = 0; + bi->bi_db_close = config_back_db_close; bi->bi_db_destroy = config_back_db_destroy; bi->bi_op_bind = config_back_bind; diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 6dac6e2a6b..73699edf1d 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -32,10 +32,6 @@ #include #include "slap.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif - int do_bind( @@ -327,27 +323,6 @@ fe_op_bind( Operation *op, SlapReply *rs ) op->o_conn->c_sasl_bind_in_progress = 0; } -#ifdef LDAP_SLAPI -#define pb op->o_pb - /* - * Normally post-operation plugins are called only after the - * backend operation. Because the front-end performs SASL - * binds on behalf of the backend, we'll make a special - * exception to call the post-operation plugins after a - * SASL bind. - */ - if ( pb ) { - slapi_int_pblock_set_operation( pb, op ); - slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)op->o_req_dn.bv_val ); - slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method ); - slapi_pblock_set( pb, - SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred ); - slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) ); - (void) slapi_int_call_plugins( op->o_bd, - SLAPI_PLUGIN_POST_BIND_FN, pb ); - } -#endif /* LDAP_SLAPI */ - ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex ); goto cleanup; @@ -476,84 +451,6 @@ fe_op_bind( Operation *op, SlapReply *rs ) goto cleanup; } -#ifdef LDAP_SLAPI - if ( pb ) { - int rc; - slapi_int_pblock_set_operation( pb, op ); - slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)op->o_req_dn.bv_val ); - slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method ); - slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred ); - slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) ); - slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) ); - - rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb ); - - Debug(LDAP_DEBUG_TRACE, - "do_bind: Bind preoperation plugin returned %d.\n", - rs->sr_err, 0, 0); - - switch ( rc ) { - case SLAPI_BIND_SUCCESS: - /* Continue with backend processing */ - break; - case SLAPI_BIND_FAIL: - /* Failure, server sends result */ - rs->sr_err = LDAP_INVALID_CREDENTIALS; - send_ldap_result( op, rs ); - goto cleanup; - break; - case SLAPI_BIND_ANONYMOUS: - /* SLAPI_BIND_ANONYMOUS is undocumented XXX */ - default: - /* Authoritative, plugin sent result, or no plugins called. */ - if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, - (void *)&rs->sr_err) != 0 ) - { - rs->sr_err = LDAP_OTHER; - } - - BER_BVZERO( &op->orb_edn ); - - if ( rs->sr_err == LDAP_SUCCESS ) { - slapi_pblock_get( pb, SLAPI_CONN_DN, - (void *)&op->orb_edn.bv_val ); - if ( BER_BVISNULL( &op->orb_edn ) ) { - if ( rc == 1 ) { - /* No plugins were called; continue. */ - break; - } - } else { - op->orb_edn.bv_len = strlen( op->orb_edn.bv_val ); - } - rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn, - &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); - ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); - ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn); - ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn); - op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); - BER_BVZERO( &op->o_req_dn ); - op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); - BER_BVZERO( &op->o_req_ndn ); - if ( !BER_BVISEMPTY( &op->o_conn->c_dn ) ) { - ber_len_t max = sockbuf_max_incoming_auth; - ber_sockbuf_ctrl( op->o_conn->c_sb, - LBER_SB_OPT_SET_MAX_INCOMING, &max ); - } - /* log authorization identity */ - Statslog( LDAP_DEBUG_STATS, - "%s BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n", - op->o_log_prefix, - BER_BVISNULL( &op->o_conn->c_dn ) - ? "" : op->o_conn->c_dn.bv_val, - mech.bv_val, 0, 0 ); - ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex ); - } - goto cleanup; - break; - } - } -#endif /* LDAP_SLAPI */ - if( op->o_bd->be_bind ) { rs->sr_err = (op->o_bd->be_bind)( op, rs ); @@ -604,16 +501,6 @@ fe_op_bind( Operation *op, SlapReply *rs ) "operation not supported within naming context" ); } -#ifdef LDAP_SLAPI - if ( pb != NULL && - slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 ) - { - Debug(LDAP_DEBUG_TRACE, - "do_bind: Bind postoperation plugins failed.\n", - 0, 0, 0); - } -#endif /* LDAP_SLAPI */ - cleanup:; return rs->sr_err; } diff --git a/servers/slapd/cancel.c b/servers/slapd/cancel.c index 141229b874..c1b288c6d5 100644 --- a/servers/slapd/cancel.c +++ b/servers/slapd/cancel.c @@ -34,7 +34,6 @@ int cancel_extop( Operation *op, SlapReply *rs ) int rc; int opid; BerElement *ber; - int i; assert( ber_bvcmp( &slap_EXOP_CANCEL, &op->ore_reqoid ) == 0 ); diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index d43af1c016..e7cc311f27 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -30,9 +30,6 @@ #include #include "slap.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif static int compare_entry( Operation *op, @@ -123,7 +120,7 @@ do_compare( cleanup:; op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); - if ( ava.aa_value.bv_val ) { + if ( !BER_BVISNULL( &ava.aa_value ) ) { op->o_tmpfree( ava.aa_value.bv_val, op->o_tmpmemctx ); } @@ -240,35 +237,6 @@ fe_op_compare( Operation *op, SlapReply *rs ) op->o_log_prefix, op->o_req_dn.bv_val, ava.aa_desc->ad_cname.bv_val, 0, 0 ); -#if defined( LDAP_SLAPI ) -#define pb op->o_pb - if ( pb ) { - slapi_int_pblock_set_operation( pb, op ); - slapi_pblock_set( pb, SLAPI_COMPARE_TARGET, (void *)op->o_req_dn.bv_val ); - slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit ); - slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)ava.aa_desc->ad_cname.bv_val ); - slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&ava.aa_value ); - - rs->sr_err = slapi_int_call_plugins( op->o_bd, - SLAPI_PLUGIN_PRE_COMPARE_FN, pb ); - if ( rs->sr_err < 0 ) { - /* - * A preoperation plugin failure will abort the - * entire operation. - */ - Debug(LDAP_DEBUG_TRACE, - "do_compare: compare preoperation plugin failed\n", - 0, 0, 0); - if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, - (void *)&rs->sr_err ) != 0 ) || rs->sr_err == LDAP_SUCCESS ) - { - rs->sr_err = LDAP_OTHER; - } - goto cleanup; - } - } -#endif /* defined( LDAP_SLAPI ) */ - op->orc_ava = &ava; if ( ava.aa_desc == slap_schema.si_ad_entryDN ) { send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, @@ -395,15 +363,6 @@ fe_op_compare( Operation *op, SlapReply *rs ) } } -#if defined( LDAP_SLAPI ) - if ( pb != NULL && slapi_int_call_plugins( op->o_bd, - SLAPI_PLUGIN_POST_COMPARE_FN, pb ) < 0 ) - { - Debug(LDAP_DEBUG_TRACE, - "do_compare: compare postoperation plugins failed\n", 0, 0, 0 ); - } -#endif /* defined( LDAP_SLAPI ) */ - cleanup:; return rs->sr_err; } diff --git a/servers/slapd/component.c b/servers/slapd/component.c index 7633af36de..01c30d67ca 100644 --- a/servers/slapd/component.c +++ b/servers/slapd/component.c @@ -99,7 +99,7 @@ componentFilterMatch ( { ComponentSyntaxInfo *csi_attr = (ComponentSyntaxInfo*)value; MatchingRuleAssertion * ma = (MatchingRuleAssertion*)assertedValue; - int num_attr, rc, i; + int rc; if ( !mr || !ma->ma_cf ) return LDAP_INAPPROPRIATE_MATCHING; @@ -154,8 +154,6 @@ allComponentsMatch( static int slapd_ber2cav( struct berval* bv, ComponentAssertionValue* cav ) { - int len; - cav->cav_ptr = cav->cav_buf = bv->bv_val; cav->cav_end = bv->bv_val + bv->bv_len; @@ -165,11 +163,9 @@ slapd_ber2cav( struct berval* bv, ComponentAssertionValue* cav ) ComponentReference* dup_comp_ref ( Operation* op, ComponentReference* cr ) { - int rc, count = 0; ComponentReference* dup_cr; ComponentId* ci_curr; ComponentId** ci_temp; - ber_int_t type; dup_cr = op->o_tmpalloc( sizeof( ComponentReference ), op->o_tmpmemctx ); @@ -234,7 +230,6 @@ dup_comp_filter_item ( ComponentAssertion* in_ca, ComponentAssertion** out_ca ) { - ComponentAssertion* ca; int len; if ( !in_ca->ca_comp_ref ) return SLAPD_DISCONNECT; @@ -301,9 +296,7 @@ dup_comp_filter ( int get_aliased_filter_aa ( Operation* op, AttributeAssertion* a_assert, AttributeAliasing* aa, const char** text ) { - int rc; struct berval assert_bv; - ComponentAssertion* ca; Debug( LDAP_DEBUG_FILTER, "get_aliased_filter\n", 0, 0, 0 ); @@ -324,9 +317,7 @@ get_aliased_filter( Operation* op, MatchingRuleAssertion* ma, AttributeAliasing* aa, const char** text ) { - int rc; struct berval assert_bv; - ComponentAssertion* ca; Debug( LDAP_DEBUG_FILTER, "get_aliased_filter\n", 0, 0, 0 ); @@ -911,7 +902,7 @@ strip_cav_str( ComponentAssertionValue* cav, char* str) /* * TAG : "item", "and", "or", "not" */ -static int +static ber_tag_t strip_cav_tag( ComponentAssertionValue* cav ) { @@ -956,7 +947,6 @@ get_item( Operation *op, ComponentAssertionValue* cav, ComponentAssertion** ca, { int rc; ComponentAssertion* _ca; - struct berval t_bv; struct berval value; MatchingRule* mr; @@ -1268,7 +1258,7 @@ test_comp_filter_item( ComponentSyntaxInfo *csi_attr, ComponentAssertion *ca ) { - int rc, len; + int rc; void *attr_nm, *assert_nm; if ( strcmp(ca->ca_ma_rule->smr_mrule.mr_oid, diff --git a/servers/slapd/config.c b/servers/slapd/config.c index acf465c2fd..40be0f7ba5 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -34,6 +34,10 @@ #include #include +#include +#include +#include + #include "slap.h" #ifdef LDAP_SLAPI #include "slapi/slapi.h" @@ -78,9 +82,6 @@ static int fp_parse_line(ConfigArgs *c); static char *strtok_quote(char *line, char *sep, char **quote_ptr); -int read_config_file(const char *fname, int depth, ConfigArgs *cf, - ConfigTable *cft ); - ConfigArgs * new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv ) { @@ -135,9 +136,19 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) { return(ARG_BAD_CONF); } if(Conf->max_args && (c->argc > Conf->max_args)) { - sprintf( c->msg, "<%s> extra cruft after <%s> ignored", + char *ignored = " ignored"; + + sprintf( c->msg, "<%s> extra cruft after <%s>", c->argv[0], Conf->what ); - Debug(LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 ); + +#ifdef LDAP_DEVEL + ignored = ""; +#endif /* LDAP_DEVEL */ + Debug(LDAP_DEBUG_CONFIG, "%s: %s%s.\n", + c->log, c->msg, ignored ); +#ifdef LDAP_DEVEL + return(ARG_BAD_CONF); +#endif /* LDAP_DEVEL */ } if((arg_type & ARG_DB) && !c->be) { sprintf( c->msg, "<%s> only allowed within database declaration", @@ -241,7 +252,7 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) { int config_set_vals(ConfigTable *Conf, ConfigArgs *c) { int rc, arg_type; - void *ptr; + void *ptr = NULL; arg_type = Conf->arg_type; if(arg_type & ARG_MAGIC) { @@ -416,6 +427,8 @@ init_config_attrs(ConfigTable *ct) { const char *err; for (i=0; ct[i].name; i++ ) { + int freeit = 0; + if ( !ct[i].attribute ) continue; at = ldap_str2attributetype( ct[i].attribute, &code, &err, LDAP_SCHEMA_ALLOW_ALL ); @@ -424,19 +437,29 @@ init_config_attrs(ConfigTable *ct) { ct[i].attribute, ldap_scherr2str(code), err ); return code; } + code = at_add( at, 0, NULL, &err ); - if ( code && code != SLAP_SCHERR_ATTR_DUP ) { - fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n", - ct[i].attribute, scherr2str(code), err ); - return code; + if ( code ) { + if ( code == SLAP_SCHERR_ATTR_DUP ) { + freeit = 1; + + } else { + fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s, %s\n", + ct[i].attribute, scherr2str(code), err ); + return code; + } } code = slap_str2ad( at->at_names[0], &ct[i].ad, &err ); + if ( freeit ) { + ldap_attributetype_free( at ); + } else { + ldap_memfree( at ); + } if ( code ) { fprintf( stderr, "init_config_attrs: AttributeType \"%s\": %s\n", ct[i].attribute, err ); return code; } - ldap_memfree( at ); } return 0; @@ -552,6 +575,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) ConfigTable *ct; ConfigArgs *c; int rc; + struct stat s; c = ch_calloc( 1, sizeof( ConfigArgs ) ); if ( c == NULL ) { @@ -570,6 +594,22 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) c->fname = fname; init_config_argv( c ); + if ( stat( fname, &s ) != 0 ) { + ldap_syslog = 1; + Debug(LDAP_DEBUG_ANY, + "could not stat config file \"%s\": %s (%d)\n", + fname, strerror(errno), errno); + return(1); + } + + if ( !S_ISREG( s.st_mode ) ) { + ldap_syslog = 1; + Debug(LDAP_DEBUG_ANY, + "regular file expected, got \"%s\"\n", + fname, 0, 0 ); + return(1); + } + fp = fopen( fname, "r" ); if ( fp == NULL ) { ldap_syslog = 1; @@ -591,7 +631,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) continue; } - snprintf( c->log, sizeof( c->log ), "%s: line %lu", + snprintf( c->log, sizeof( c->log ), "%s: line %d", c->fname, c->lineno ); c->argc = 0; @@ -772,6 +812,94 @@ mask_to_verbs(slap_verbmasks *v, slap_mask_t m, BerVarray *bva) { return 0; } +int +slap_verbmasks_init( slap_verbmasks **vp, slap_verbmasks *v ) +{ + int i; + + assert( *vp == NULL ); + + for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) + ; + + *vp = ch_calloc( i + 1, sizeof( slap_verbmasks ) ); + + for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) { + ber_dupbv( &(*vp)[ i ].word, &v[ i ].word ); + *((slap_mask_t *)&(*vp)[ i ].mask) = v[ i ].mask; + } + + BER_BVZERO( &(*vp)[ i ].word ); + + return 0; +} + +int +slap_verbmasks_destroy( slap_verbmasks *v ) +{ + int i; + + assert( v != NULL ); + + for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) { + ch_free( v[ i ].word.bv_val ); + } + + ch_free( v ); + + return 0; +} + +int +slap_verbmasks_append( + slap_verbmasks **vp, + slap_mask_t m, + struct berval *v, + slap_mask_t *ignore ) +{ + int i; + + if ( !m ) { + return LDAP_OPERATIONS_ERROR; + } + + for ( i = 0; !BER_BVISNULL( &(*vp)[ i ].word ); i++ ) { + if ( !(*vp)[ i ].mask ) continue; + + if ( ignore != NULL ) { + int j; + + for ( j = 0; ignore[ j ] != 0; j++ ) { + if ( (*vp)[ i ].mask == ignore[ j ] ) { + goto check_next; + } + } + } + + if ( ( m & (*vp)[ i ].mask ) == (*vp)[ i ].mask ) { + if ( ber_bvstrcasecmp( v, &(*vp)[ i ].word ) == 0 ) { + /* already set; ignore */ + return LDAP_SUCCESS; + } + /* conflicts */ + return LDAP_TYPE_OR_VALUE_EXISTS; + } + + if ( m & (*vp)[ i ].mask ) { + /* conflicts */ + return LDAP_CONSTRAINT_VIOLATION; + } +check_next:; + } + + *vp = ch_realloc( *vp, sizeof( slap_verbmasks ) * ( i + 2 ) ); + ber_dupbv( &(*vp)[ i ].word, v ); + *((slap_mask_t *)&(*vp)[ i ].mask) = m; + BER_BVZERO( &(*vp)[ i + 1 ].word ); + + return LDAP_SUCCESS; +} + int enum_to_verb(slap_verbmasks *v, slap_mask_t m, struct berval *bv) { int i; @@ -847,7 +975,7 @@ int bindconf_parse( const char *word, slap_bindconf *bc ) { break; case 'd': - assert( tab->aux ); + assert( tab->aux != NULL ); iptr = (int *)((char *)bc + tab->off); rc = 1; @@ -900,7 +1028,7 @@ int bindconf_unparse( slap_bindconf *bc, struct berval *bv ) { break; case 'd': - assert( tab->aux ); + assert( tab->aux != NULL ); iptr = (int *)((char *)bc + tab->off); for ( i = 0; !BER_BVISNULL( &tab->aux[i].word ); i++ ) { @@ -1083,30 +1211,39 @@ static int fp_parse_line(ConfigArgs *c) { char *token; - char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' }; + static char *const hide[] = { + "rootpw", "replica", "syncrepl", /* in slapd */ + "acl-bind", "acl-method", "idassert-bind", /* in back-ldap */ + "acl-passwd", "bindpw", /* in back- */ + "pseudorootpw", /* in back-meta */ + "dbpasswd", /* in back-sql */ + NULL + }; char *quote_ptr; - int i; + int i = (int)(sizeof(hide)/sizeof(hide[0])) - 1; c->tline = ch_strdup(c->line); token = strtok_quote(c->tline, " \t", "e_ptr); if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break; if(quote_ptr) *quote_ptr = ' '; - Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, + Debug(LDAP_DEBUG_CONFIG, "line %d (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : ""); if(quote_ptr) *quote_ptr = '\0'; - for(; token; token = strtok_quote(NULL, " \t", "e_ptr)) { - if(c->argc == c->argv_size - 1) { + for(;; token = strtok_quote(NULL, " \t", "e_ptr)) { + if(c->argc >= c->argv_size) { char **tmp; tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv)); if(!tmp) { - Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0); + Debug(LDAP_DEBUG_ANY, "line %d: out of memory\n", c->lineno, 0, 0); return -1; } c->argv = tmp; c->argv_size += ARGS_STEP; } + if(token == NULL) + break; c->argv[c->argc++] = token; } c->argv[c->argc] = NULL; diff --git a/servers/slapd/config.h b/servers/slapd/config.h index 5ddd7552c0..3dc2592803 100644 --- a/servers/slapd/config.h +++ b/servers/slapd/config.h @@ -109,7 +109,7 @@ typedef struct config_args_s { char *line; char *tline; const char *fname; - unsigned long lineno; + int lineno; char log[MAXPATHLEN + STRLENOF(": line 18446744073709551615") + 1]; char msg[SLAP_TEXT_BUFLEN]; int depth; @@ -154,8 +154,18 @@ typedef struct config_args_s { #define value_ndn values.v_dn.vdn_ndn int config_register_schema(ConfigTable *ct, ConfigOCs *co); +int config_del_vals(ConfigTable *cf, ConfigArgs *c); int config_get_vals(ConfigTable *ct, ConfigArgs *c); int config_add_vals(ConfigTable *ct, ConfigArgs *c); + +void init_config_argv( ConfigArgs *c ); +int init_config_attrs(ConfigTable *ct); +int init_config_ocs( ConfigOCs *ocs ); +int config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx); +int config_parse_add(ConfigTable *ct, ConfigArgs *c); +int read_config_file(const char *fname, int depth, ConfigArgs *cf, + ConfigTable *cft ); + ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c); Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent, ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra ); diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 036f7ae0e1..56c02c2f7a 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -598,21 +598,21 @@ void connection2anonymous( Connection *c ) ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); } - if(c->c_authmech.bv_val != NULL ) { - free(c->c_authmech.bv_val); + if ( !BER_BVISNULL( &c->c_authmech ) ) { + ch_free(c->c_authmech.bv_val); } BER_BVZERO( &c->c_authmech ); - if(c->c_dn.bv_val != NULL) { - free(c->c_dn.bv_val); + if ( !BER_BVISNULL( &c->c_dn ) ) { + ch_free(c->c_dn.bv_val); } BER_BVZERO( &c->c_dn ); - if(c->c_ndn.bv_val != NULL) { - free(c->c_ndn.bv_val); + if ( !BER_BVISNULL( &c->c_ndn ) ) { + ch_free(c->c_ndn.bv_val); } BER_BVZERO( &c->c_ndn ); - if(c->c_sasl_authz_dn.bv_val != NULL) { - free(c->c_sasl_authz_dn.bv_val); + if ( !BER_BVISNULL( &c->c_sasl_authz_dn ) ) { + ber_memfree_x( c->c_sasl_authz_dn.bv_val, NULL ); } BER_BVZERO( &c->c_sasl_authz_dn ); diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index a3c686312c..383b945e00 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -32,7 +32,9 @@ static SLAP_CTRL_PARSE_FN parseProxyAuthz; static SLAP_CTRL_PARSE_FN parseManageDIT; #endif static SLAP_CTRL_PARSE_FN parseManageDSAit; +#ifdef LDAP_CONTROL_MODIFY_INCREMENT static SLAP_CTRL_PARSE_FN parseModifyIncrement; +#endif static SLAP_CTRL_PARSE_FN parseNoOp; static SLAP_CTRL_PARSE_FN parsePagedResults; #ifdef LDAP_DEVEL @@ -253,7 +255,6 @@ int slap_controls_init( void ) { int i, rc; - struct slap_control *sc; rc = LDAP_SUCCESS; @@ -326,10 +327,9 @@ int get_supported_controls(char ***ctrloidsp, slap_mask_t **ctrlmasks) { - int i, n; + int n; char **oids; slap_mask_t *masks; - int rc; struct slap_control *sc; n = 0; @@ -441,6 +441,95 @@ void slap_free_ctrls( op->o_tmpfree( ctrls, op->o_tmpmemctx ); } +int slap_parse_ctrl( + Operation *op, + SlapReply *rs, + LDAPControl *control, + const char **text ) +{ + struct slap_control *sc; + + sc = find_ctrl( control->ldctl_oid ); + if( sc != NULL ) { + /* recognized control */ + slap_mask_t tagmask; + switch( op->o_tag ) { + case LDAP_REQ_ADD: + tagmask = SLAP_CTRL_ADD; + break; + case LDAP_REQ_BIND: + tagmask = SLAP_CTRL_BIND; + break; + case LDAP_REQ_COMPARE: + tagmask = SLAP_CTRL_COMPARE; + break; + case LDAP_REQ_DELETE: + tagmask = SLAP_CTRL_DELETE; + break; + case LDAP_REQ_MODIFY: + tagmask = SLAP_CTRL_MODIFY; + break; + case LDAP_REQ_RENAME: + tagmask = SLAP_CTRL_RENAME; + break; + case LDAP_REQ_SEARCH: + tagmask = SLAP_CTRL_SEARCH; + break; + case LDAP_REQ_UNBIND: + tagmask = SLAP_CTRL_UNBIND; + break; + case LDAP_REQ_ABANDON: + tagmask = SLAP_CTRL_ABANDON; + break; + case LDAP_REQ_EXTENDED: + tagmask=~0L; + assert( op->ore_reqoid.bv_val != NULL ); + if( sc->sc_extendedops != NULL ) { + int i; + for( i=0; sc->sc_extendedops[i] != NULL; i++ ) { + if( strcmp( op->ore_reqoid.bv_val, + sc->sc_extendedops[i] ) == 0 ) + { + tagmask=0L; + break; + } + } + } + break; + default: + *text = "controls internal error"; + return LDAP_OTHER; + } + + if (( sc->sc_mask & tagmask ) == tagmask ) { + /* available extension */ + int rc; + + if( !sc->sc_parse ) { + *text = "not yet implemented"; + return LDAP_OTHER; + } + + rc = sc->sc_parse( op, rs, control ); + if ( rc ) { + assert( rc != LDAP_UNAVAILABLE_CRITICAL_EXTENSION ); + return rc; + } + + } else if( control->ldctl_iscritical ) { + /* unavailable CRITICAL control */ + *text = "critical extension is unavailable"; + return LDAP_UNAVAILABLE_CRITICAL_EXTENSION; + } + } else if( control->ldctl_iscritical ) { + /* unrecognized CRITICAL control */ + *text = "critical extension is not recognized"; + return LDAP_UNAVAILABLE_CRITICAL_EXTENSION; + } + + return LDAP_SUCCESS; +} + int get_ctrls( Operation *op, SlapReply *rs, @@ -451,7 +540,6 @@ int get_ctrls( ber_len_t len; char *opaque; BerElement *ber = op->o_ber; - struct slap_control *sc; struct berval bv; len = ber_pvt_ber_remaining(ber); @@ -591,90 +679,10 @@ int get_ctrls( "=> get_ctrls: oid=\"%s\" (%scritical)\n", c->ldctl_oid, c->ldctl_iscritical ? "" : "non", 0 ); - sc = find_ctrl( c->ldctl_oid ); - if( sc != NULL ) { - /* recognized control */ - slap_mask_t tagmask; - switch( op->o_tag ) { - case LDAP_REQ_ADD: - tagmask = SLAP_CTRL_ADD; - break; - case LDAP_REQ_BIND: - tagmask = SLAP_CTRL_BIND; - break; - case LDAP_REQ_COMPARE: - tagmask = SLAP_CTRL_COMPARE; - break; - case LDAP_REQ_DELETE: - tagmask = SLAP_CTRL_DELETE; - break; - case LDAP_REQ_MODIFY: - tagmask = SLAP_CTRL_MODIFY; - break; - case LDAP_REQ_RENAME: - tagmask = SLAP_CTRL_RENAME; - break; - case LDAP_REQ_SEARCH: - tagmask = SLAP_CTRL_SEARCH; - break; - case LDAP_REQ_UNBIND: - tagmask = SLAP_CTRL_UNBIND; - break; - case LDAP_REQ_ABANDON: - tagmask = SLAP_CTRL_ABANDON; - break; - case LDAP_REQ_EXTENDED: - tagmask=~0L; - assert( op->ore_reqoid.bv_val != NULL ); - if( sc->sc_extendedops != NULL ) { - int i; - for( i=0; sc->sc_extendedops[i] != NULL; i++ ) { - if( strcmp( op->ore_reqoid.bv_val, - sc->sc_extendedops[i] ) == 0 ) - { - tagmask=0L; - break; - } - } - } - break; - default: - rs->sr_err = LDAP_OTHER; - rs->sr_text = "controls internal error"; - goto return_results; - } - - if (( sc->sc_mask & tagmask ) == tagmask ) { - /* available extension */ - int rc; - - if( !sc->sc_parse ) { - rs->sr_err = LDAP_OTHER; - rs->sr_text = "not yet implemented"; - goto return_results; - } - - rc = sc->sc_parse( op, rs, c ); - if ( rc ) { - assert( rc != LDAP_UNAVAILABLE_CRITICAL_EXTENSION ); - rs->sr_err = rc; - goto return_results; - } - - } else if( c->ldctl_iscritical ) { - /* unavailable CRITICAL control */ - rs->sr_err = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; - rs->sr_text = "critical extension is unavailable"; - goto return_results; - } - - } else if( c->ldctl_iscritical ) { - /* unrecognized CRITICAL control */ - rs->sr_err = LDAP_UNAVAILABLE_CRITICAL_EXTENSION; - rs->sr_text = "critical extension is not recognized"; + rs->sr_err = slap_parse_ctrl( op, rs, c, &rs->sr_text ); + if ( rs->sr_err != LDAP_SUCCESS ) { goto return_results; } -next_ctrl:; } return_results: @@ -695,6 +703,7 @@ return_results: return rs->sr_err; } +#ifdef LDAP_CONTROL_MODIFY_INCREMENT static int parseModifyIncrement ( Operation *op, SlapReply *rs, @@ -720,6 +729,7 @@ static int parseModifyIncrement ( return LDAP_SUCCESS; } +#endif #ifdef LDAP_DEVEL static int parseManageDIT ( @@ -1026,7 +1036,6 @@ static int parseAssert ( { BerElement *ber; struct berval fstr = BER_BVNULL; - const char *err_msg = ""; if ( op->o_assert != SLAP_CONTROL_NONE ) { rs->sr_text = "assert control specified multiple times"; @@ -1192,14 +1201,13 @@ static int parsePostRead ( return LDAP_SUCCESS; } -int parseValuesReturnFilter ( +static int parseValuesReturnFilter ( Operation *op, SlapReply *rs, LDAPControl *ctrl ) { BerElement *ber; struct berval fstr = BER_BVNULL; - const char *err_msg = ""; if ( op->o_valuesreturnfilter != SLAP_CONTROL_NONE ) { rs->sr_text = "valuesReturnFilter control specified multiple times"; diff --git a/servers/slapd/cr.c b/servers/slapd/cr.c index a1c6005e93..107f2dba83 100644 --- a/servers/slapd/cr.c +++ b/servers/slapd/cr.c @@ -127,8 +127,8 @@ cr_insert( cir->cir_name.bv_len = strlen( scr->scr_oid ); cir->cir_cr = scr; - assert( cir->cir_name.bv_val ); - assert( cir->cir_cr ); + assert( cir->cir_name.bv_val != NULL ); + assert( cir->cir_cr != NULL ); if ( avl_insert( &cr_index, (caddr_t) cir, cr_index_cmp, avl_dup_error ) ) @@ -150,8 +150,8 @@ cr_insert( cir->cir_name.bv_len = strlen( *names ); cir->cir_cr = scr; - assert( cir->cir_name.bv_val ); - assert( cir->cir_cr ); + assert( cir->cir_name.bv_val != NULL ); + assert( cir->cir_cr != NULL ); if ( avl_insert( &cr_index, (caddr_t) cir, cr_index_cmp, avl_dup_error ) ) @@ -412,7 +412,7 @@ cr_unparse( BerVarray *res, ContentRule *start, ContentRule *end, int sys ) ContentRule *cr; int i, num; struct berval bv, *bva = NULL, idx; - char ibuf[32], *ptr; + char ibuf[32]; if ( !start ) start = LDAP_STAILQ_FIRST( &cr_list ); diff --git a/servers/slapd/ctxcsn.c b/servers/slapd/ctxcsn.c index 408ee66838..6d29007b58 100644 --- a/servers/slapd/ctxcsn.c +++ b/servers/slapd/ctxcsn.c @@ -37,7 +37,6 @@ slap_get_commit_csn( ) { struct slap_csn_entry *csne, *committed_csne = NULL; - int i = 0; if ( maxcsn ) { BER_BVZERO( maxcsn ); @@ -125,7 +124,6 @@ slap_create_context_csn_entry( struct berval *context_csn ) { Entry* e; - int rc; struct berval bv; diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 6abea22fc2..0bdea4dd9e 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -206,7 +206,7 @@ static struct slap_daemon { #define SLAP_EVENT_FD(i) SLAP_EV_PTRFD(revents[i].data.ptr) #define SLAP_SOCK_SET_MUTE(s) SLAP_SOCK_CLR_READ(s) #define SLAP_SOCK_CLR_MUTE(s) SLAP_SOCK_SET_READ(s) -#define SLAP_SOCK_IS_MUTE(s) !SLAP_SOCK_IS_READ(s) +#define SLAP_SOCK_IS_MUTE(s) (!SLAP_SOCK_IS_READ(s)) #define SLAP_SOCK_SET_INIT \ slap_daemon.sd_epolls = ch_malloc(sizeof(struct epoll_event) * dtblsize * 2); \ @@ -301,7 +301,7 @@ static struct slap_daemon { #define SLAP_SOCK_SET_MUTE(s) FD_CLR(s, &readfds) #define SLAP_SOCK_CLR_MUTE(s) FD_SET(s, &readfds) -#define SLAP_SOCK_IS_MUTE(s) FD_ISSET(s, &readfds) +#define SLAP_SOCK_IS_MUTE(s) (!FD_ISSET(s, &readfds)) #endif @@ -558,9 +558,9 @@ static int get_url_perms( { int i; - assert( exts ); - assert( perms ); - assert( crit ); + assert( exts != NULL ); + assert( perms != NULL ); + assert( crit != NULL ); *crit = 0; for ( i = 0; exts[ i ]; i++ ) { @@ -1005,16 +1005,6 @@ static int slap_open_listener( #ifdef LDAP_PF_LOCAL case AF_LOCAL: { char *addr = ((struct sockaddr_un *)*sal)->sun_path; -#if 0 /* don't muck with socket perms */ - if ( chmod( addr, l.sl_perms ) < 0 && crit ) { - int err = sock_errno(); - Debug( LDAP_DEBUG_ANY, "daemon: fchmod(%ld) failed errno=%d (%s)", - (long) l.sl_sd, err, sock_errstr(err) ); - tcp_close( l.sl_sd ); - slap_free_listener_addresses(psal); - return -1; - } -#endif l.sl_name.bv_len = strlen(addr) + sizeof("PATH=") - 1; l.sl_name.bv_val = ber_memalloc( l.sl_name.bv_len + 1 ); snprintf( l.sl_name.bv_val, l.sl_name.bv_len + 1, @@ -1768,8 +1758,6 @@ slapd_daemon_task( if ( !SLAP_EVENT_IS_READ( slap_listeners[l]->sl_sd )) continue; - ns--; - rc = slapd_handle_listener(slap_listeners[l]); #ifdef LDAP_CONNECTIONLESS @@ -1777,6 +1765,8 @@ slapd_daemon_task( if ( rc ) continue; #endif + ns--; + /* Don't need to look at this in the data loops */ SLAP_EVENT_CLR_READ( slap_listeners[l]->sl_sd ); SLAP_EVENT_CLR_WRITE( slap_listeners[l]->sl_sd ); @@ -2063,7 +2053,7 @@ int slapd_daemon( void ) } -int sockinit(void) +static int sockinit(void) { #if defined( HAVE_WINSOCK2 ) WORD wVersionRequested; @@ -2104,7 +2094,7 @@ int sockinit(void) return 0; } -int sockdestroy(void) +static int sockdestroy(void) { #if defined( HAVE_WINSOCK2 ) || defined( HAVE_WINSOCK ) WSACleanup(); diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 40a87c07f3..51bb8d7902 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -34,10 +34,6 @@ #include "lutil.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif - int do_delete( Operation *op, @@ -156,33 +152,6 @@ fe_op_delete( Operation *op, SlapReply *rs ) goto cleanup; } -#if defined( LDAP_SLAPI ) -#define pb op->o_pb - if ( pb ) { - slapi_int_pblock_set_operation( pb, op ); - slapi_pblock_set( pb, SLAPI_DELETE_TARGET, (void *)op->o_req_dn.bv_val ); - slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit ); - - rs->sr_err = slapi_int_call_plugins( op->o_bd, - SLAPI_PLUGIN_PRE_DELETE_FN, pb ); - if ( rs->sr_err < 0 ) { - /* - * A preoperation plugin failure will abort the - * entire operation. - */ - Debug (LDAP_DEBUG_TRACE, "do_delete: " - "delete preoperation plugin failed.\n", 0, 0, 0); - if ( ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, - (void *)&rs->sr_err ) != 0 ) || - rs->sr_err == LDAP_SUCCESS ) - { - rs->sr_err = LDAP_OTHER; - } - goto cleanup; - } - } -#endif /* defined( LDAP_SLAPI ) */ - /* * do the delete if 1 && (2 || 3) * 1) there is a delete function implemented in this backend; @@ -235,7 +204,7 @@ fe_op_delete( Operation *op, SlapReply *rs ) { op->o_delete_glue_parent = 0; if ( !be_issuffix( op->o_bd, &op->o_req_ndn )) { - slap_callback cb = { NULL }; + slap_callback cb = { NULL, NULL, NULL, NULL }; cb.sc_response = slap_null_cb; dnParent( &op->o_req_ndn, &pdn ); op->o_req_dn = pdn; @@ -281,16 +250,6 @@ fe_op_delete( Operation *op, SlapReply *rs ) "operation not supported within namingContext" ); } -#if defined( LDAP_SLAPI ) - if ( pb != NULL && slapi_int_call_plugins( op->o_bd, - SLAPI_PLUGIN_POST_DELETE_FN, pb ) < 0) - { - Debug(LDAP_DEBUG_TRACE, - "do_delete: delete postoperation plugins failed\n", - 0, 0, 0 ); - } -#endif /* defined( LDAP_SLAPI ) */ - cleanup:; return rs->sr_err; } diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 5da22ac6a4..24bc185ff5 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -59,14 +59,14 @@ LDAPRDN_validate( LDAPRDN rdn ) int iAVA; int rc; - assert( rdn ); + assert( rdn != NULL ); for ( iAVA = 0; rdn[ iAVA ]; iAVA++ ) { LDAPAVA *ava = rdn[ iAVA ]; AttributeDescription *ad; slap_syntax_validate_func *validate = NULL; - assert( ava ); + assert( ava != NULL ); if ( ( ad = AVA_PRIVATE( ava ) ) == NULL ) { const char *text = NULL; @@ -112,20 +112,20 @@ LDAPDN_validate( LDAPDN dn ) int iRDN; int rc; - assert( dn ); + assert( dn != NULL ); for ( iRDN = 0; dn[ iRDN ]; iRDN++ ) { LDAPRDN rdn = dn[ iRDN ]; int iAVA; - assert( rdn ); + assert( rdn != NULL ); for ( iAVA = 0; rdn[ iAVA ]; iAVA++ ) { LDAPAVA *ava = rdn[ iAVA ]; AttributeDescription *ad; slap_syntax_validate_func *validate = NULL; - assert( ava ); + assert( ava != NULL ); if ( ( ad = AVA_PRIVATE( ava ) ) == NULL ) { const char *text = NULL; @@ -173,7 +173,7 @@ dnValidate( int rc; LDAPDN dn = NULL; - assert( in ); + assert( in != NULL ); if ( in->bv_len == 0 ) { return LDAP_SUCCESS; @@ -211,7 +211,7 @@ rdnValidate( LDAPRDN rdn; char* p; - assert( in ); + assert( in != NULL ); if ( in->bv_len == 0 ) { return LDAP_SUCCESS; @@ -261,14 +261,14 @@ AVA_Sort( LDAPRDN rdn, int iAVA ) int i; LDAPAVA *ava_in = rdn[ iAVA ]; - assert( rdn ); - assert( ava_in ); + assert( rdn != NULL ); + assert( ava_in != NULL ); for ( i = 0; i < iAVA; i++ ) { LDAPAVA *ava = rdn[ i ]; int a, j; - assert( ava ); + assert( ava != NULL ); a = strcmp( ava_in->la_attr.bv_val, ava->la_attr.bv_val ); @@ -337,7 +337,7 @@ LDAPRDN_rewrite( LDAPRDN rdn, unsigned flags, void *ctx ) struct berval bv = BER_BVNULL; int do_sort = 0; - assert( ava ); + assert( ava != NULL ); if ( ( ad = AVA_PRIVATE( ava ) ) == NULL ) { const char *text = NULL; @@ -444,13 +444,13 @@ LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx ) int iRDN; int rc; - assert( dn ); + assert( dn != NULL ); for ( iRDN = 0; dn[ iRDN ]; iRDN++ ) { LDAPRDN rdn = dn[ iRDN ]; int iAVA; - assert( rdn ); + assert( rdn != NULL ); for ( iAVA = 0; rdn[ iAVA ]; iAVA++ ) { LDAPAVA *ava = rdn[ iAVA ]; @@ -462,7 +462,7 @@ LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx ) struct berval bv = BER_BVNULL; int do_sort = 0; - assert( ava ); + assert( ava != NULL ); if ( ( ad = AVA_PRIVATE( ava ) ) == NULL ) { const char *text = NULL; @@ -570,8 +570,8 @@ dnNormalize( struct berval *out, void *ctx) { - assert( val ); - assert( out ); + assert( val != NULL ); + assert( out != NULL ); Debug( LDAP_DEBUG_TRACE, ">>> dnNormalize: <%s>\n", val->bv_val, 0, 0 ); @@ -626,8 +626,8 @@ rdnNormalize( struct berval *out, void *ctx) { - assert( val ); - assert( out ); + assert( val != NULL ); + assert( out != NULL ); Debug( LDAP_DEBUG_TRACE, ">>> dnNormalize: <%s>\n", val->bv_val, 0, 0 ); if ( val->bv_len != 0 ) { @@ -682,8 +682,8 @@ dnPretty( struct berval *out, void *ctx) { - assert( val ); - assert( out ); + assert( val != NULL ); + assert( out != NULL ); Debug( LDAP_DEBUG_TRACE, ">>> dnPretty: <%s>\n", val->bv_val, 0, 0 ); @@ -739,8 +739,8 @@ rdnPretty( struct berval *out, void *ctx) { - assert( val ); - assert( out ); + assert( val != NULL ); + assert( out != NULL ); Debug( LDAP_DEBUG_TRACE, ">>> dnPretty: <%s>\n", val->bv_val, 0, 0 ); @@ -800,8 +800,8 @@ dnPrettyNormalDN( int flags, void *ctx ) { - assert( val ); - assert( dn ); + assert( val != NULL ); + assert( dn != NULL ); Debug( LDAP_DEBUG_TRACE, ">>> dn%sDN: <%s>\n", flags == SLAP_LDAPDN_PRETTY ? "Pretty" : "Normal", @@ -854,9 +854,9 @@ dnPrettyNormal( { Debug( LDAP_DEBUG_TRACE, ">>> dnPrettyNormal: <%s>\n", val->bv_val, 0, 0 ); - assert( val ); - assert( pretty ); - assert( normal ); + assert( val != NULL ); + assert( pretty != NULL ); + assert( normal != NULL ); if ( val->bv_len == 0 ) { ber_dupbv_x( pretty, val, ctx ); @@ -940,9 +940,9 @@ dnMatch( int match; struct berval *asserted = (struct berval *) assertedValue; - assert( matchp ); - assert( value ); - assert( assertedValue ); + assert( matchp != NULL ); + assert( value != NULL ); + assert( assertedValue != NULL ); assert( !BER_BVISNULL( value ) ); assert( !BER_BVISNULL( asserted ) ); @@ -975,9 +975,9 @@ dnRelativeMatch( int match; struct berval *asserted = (struct berval *) assertedValue; - assert( matchp ); - assert( value ); - assert( assertedValue ); + assert( matchp != NULL ); + assert( value != NULL ); + assert( assertedValue != NULL ); assert( !BER_BVISNULL( value ) ); assert( !BER_BVISNULL( asserted ) ); @@ -1074,9 +1074,9 @@ rdnMatch( int match; struct berval *asserted = (struct berval *) assertedValue; - assert( matchp ); - assert( value ); - assert( assertedValue ); + assert( matchp != NULL ); + assert( value != NULL ); + assert( assertedValue != NULL ); match = value->bv_len - asserted->bv_len; @@ -1165,8 +1165,8 @@ dnExtractRdn( const char *p; int rc; - assert( dn ); - assert( rdn ); + assert( dn != NULL ); + assert( rdn != NULL ); if( dn->bv_len == 0 ) { return LDAP_OTHER; @@ -1194,7 +1194,7 @@ dn_rdnlen( { const char *p; - assert( dn_in ); + assert( dn_in != NULL ); if ( dn_in == NULL ) { return 0; @@ -1319,8 +1319,8 @@ dnIsSuffix( { int d = dn->bv_len - suffix->bv_len; - assert( dn ); - assert( suffix ); + assert( dn != NULL ); + assert( suffix != NULL ); /* empty suffix matches any dn */ if ( suffix->bv_len == 0 ) { diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index e83ed0000d..9441de24e6 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -36,8 +36,8 @@ #include "slap.h" #include "ldif.h" -static unsigned char *ebuf; /* buf returned by entry2str */ -static unsigned char *ecur; /* pointer to end of currently used ebuf */ +static char *ebuf; /* buf returned by entry2str */ +static char *ecur; /* pointer to end of currently used ebuf */ static int emaxsize;/* max size of ebuf */ /* @@ -70,7 +70,6 @@ str2entry2( char *s, int checkvals ) { int rc; Entry *e; - struct berval *nvalsp; struct berval *type, *vals, *nvals; char *freeval; AttributeDescription *ad, *ad_prev; @@ -231,6 +230,7 @@ str2entry2( char *s, int checkvals ) int j, k; atail->a_next = (Attribute *) ch_malloc( sizeof(Attribute) ); atail = atail->a_next; + atail->a_flags = 0; atail->a_desc = ad_prev; atail->a_vals = ch_malloc( (attr_cnt + 1) * sizeof(struct berval)); if( ad_prev->ad_type->sat_equality && @@ -347,7 +347,7 @@ fail: while ( ecur + (n) > ebuf + emaxsize ) { \ ptrdiff_t offset; \ offset = (int) (ecur - ebuf); \ - ebuf = (unsigned char *) ch_realloc( (char *) ebuf, \ + ebuf = ch_realloc( ebuf, \ emaxsize + GRABSIZE ); \ emaxsize += GRABSIZE; \ ecur = ebuf + offset; \ @@ -379,7 +379,7 @@ entry2str( /* put "dn: " */ tmplen = e->e_name.bv_len; MAKE_SPACE( LDIF_SIZE_NEEDED( 2, tmplen )); - ldif_sput( (char **) &ecur, LDIF_PUT_VALUE, "dn", e->e_dn, tmplen ); + ldif_sput( &ecur, LDIF_PUT_VALUE, "dn", e->e_dn, tmplen ); } /* put the attributes */ @@ -389,7 +389,7 @@ entry2str( bv = &a->a_vals[i]; tmplen = a->a_desc->ad_cname.bv_len; MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len )); - ldif_sput( (char **) &ecur, LDIF_PUT_VALUE, + ldif_sput( &ecur, LDIF_PUT_VALUE, a->a_desc->ad_cname.bv_val, bv->bv_val, bv->bv_len ); } @@ -398,7 +398,7 @@ entry2str( *ecur = '\0'; *len = ecur - ebuf; - return( (char *) ebuf ); + return( ebuf ); } void diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index 6d3237cae4..36c42e446e 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -39,10 +39,6 @@ #include "slap.h" #include "lber_pvt.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif - #define UNSUPPORTED_EXOP "unsupported extended operation" @@ -194,25 +190,11 @@ fe_extended( Operation *op, SlapReply *rs ) struct extop_list *ext = NULL; struct berval reqdata = BER_BVNULL; -#if defined(LDAP_SLAPI) - Slapi_PBlock *pb = op->o_pb; - SLAPI_FUNC funcAddr = NULL; - int extop_rc; - int msg_sent = FALSE; -#endif /* defined(LDAP_SLAPI) */ - if (op->ore_reqdata) { reqdata = *op->ore_reqdata; } -#ifdef LDAP_SLAPI - /* NS-SLAPI extended operation */ - slapi_int_get_extop_plugin( &op->ore_reqoid, &funcAddr ); - - if( !funcAddr && !(ext = find_extop(supp_ext_list, &op->ore_reqoid ))) -#else if( !(ext = find_extop(supp_ext_list, &op->ore_reqoid ))) -#endif { Debug( LDAP_DEBUG_ANY, "do_extended: unsupported operation \"%s\"\n", op->ore_reqoid.bv_val, 0 ,0 ); @@ -226,68 +208,6 @@ fe_extended( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n", op->ore_reqoid.bv_val, 0 ,0 ); -#if defined(LDAP_SLAPI) - if ( funcAddr != NULL ) { - rs->sr_err = slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_OID, - (void *)op->ore_reqoid.bv_val); - if ( rs->sr_err != LDAP_SUCCESS ) { - rs->sr_err = LDAP_OTHER; - goto done; - } - - rs->sr_err = slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_VALUE, - (void *)&reqdata); - if ( rs->sr_err != LDAP_SUCCESS ) { - rs->sr_err = LDAP_OTHER; - goto done; - } - - rs->sr_err = slapi_int_pblock_set_operation( pb, op ); - if ( rs->sr_err != LDAP_SUCCESS ) { - rs->sr_err = LDAP_OTHER; - goto done; - } - - extop_rc = (*funcAddr)( pb ); - if ( extop_rc == SLAPI_PLUGIN_EXTENDED_SENT_RESULT ) { - msg_sent = TRUE; - - } else if ( extop_rc == SLAPI_PLUGIN_EXTENDED_NOT_HANDLED ) { - rs->sr_err = LDAP_PROTOCOL_ERROR; - rs->sr_text = UNSUPPORTED_EXOP; - - } else { - rs->sr_err = slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID, - &rs->sr_rspoid); - if ( rs->sr_err != LDAP_SUCCESS ) { - goto done2; - } - - rs->sr_err = slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, - &rs->sr_rspdata); - if ( rs->sr_err != LDAP_SUCCESS ) { - goto done2; - } - - rs->sr_err = extop_rc; - send_ldap_extended( op, rs ); - msg_sent = TRUE; - } - -done2:; - if ( rs->sr_err != LDAP_SUCCESS && msg_sent == FALSE ) { - send_ldap_result( op, rs ); - } - - if ( rs->sr_rspoid != NULL ) { - ch_free( (char *)rs->sr_rspoid ); - } - - if ( rs->sr_rspdata != NULL ) { - ber_bvfree( rs->sr_rspdata ); - } - } else -#endif /* defined( LDAP_SLAPI ) */ { /* start of OpenLDAP extended operation */ rs->sr_err = (ext->ext_main)( op, rs ); @@ -302,6 +222,8 @@ done2:; } } + if ( op->o_bd == NULL ) + op->o_bd = frontendDB; send_ldap_extended( op, rs ); if ( rs->sr_ref != default_referral ) { diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 0d7527c0eb..8ea1ad2ff0 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -779,8 +779,8 @@ filter_escape_value_x( void *ctx ) { ber_len_t i; - assert( in ); - assert( out ); + assert( in != NULL ); + assert( out != NULL ); i = in->bv_len * 3 + 1; out->bv_val = ctx ? slap_sl_malloc( i, ctx ) : ch_malloc( i ); diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index b201fd469d..34b8bc784f 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -444,7 +444,7 @@ static int test_mra_filter( int ret; const char *text; - assert( ad ); + assert( ad != NULL ); if ( mra->ma_desc ) { /* have a mra type? check for subtype */ @@ -588,7 +588,7 @@ test_ava_filter( } mr = slap_schema.si_ad_entryDN->ad_type->sat_equality; - assert( mr ); + assert( mr != NULL ); rc = value_match( &match, slap_schema.si_ad_entryDN, mr, SLAP_MR_EXT, &e->e_nname, &ava->aa_value, &text ); diff --git a/servers/slapd/frontend.c b/servers/slapd/frontend.c index befc06c766..20e16613e3 100644 --- a/servers/slapd/frontend.c +++ b/servers/slapd/frontend.c @@ -38,10 +38,6 @@ #include "ldap_rq.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif - static BackendInfo slap_frontendInfo; static BackendDB slap_frontendDB; BackendDB *frontendDB; @@ -118,6 +114,16 @@ frontend_init( void ) frontendDB->bd_info->bi_op_modrdn = fe_op_modrdn; frontendDB->bd_info->bi_op_search = fe_op_search; frontendDB->bd_info->bi_extended = fe_extended; + frontendDB->bd_info->bi_operational = fe_aux_operational; +#if 0 + frontendDB->bd_info->bi_entry_get_rw = fe_entry_get_rw; + frontendDB->bd_info->bi_entry_release_rw = fe_entry_release_rw; +#endif +#ifdef SLAP_OVERLAY_ACCESS + frontendDB->bd_info->bi_access_allowed = fe_access_allowed; + frontendDB->bd_info->bi_acl_group = fe_acl_group; + frontendDB->bd_info->bi_acl_attribute = fe_acl_attribute; +#endif /* SLAP_OVERLAY_ACCESS */ #if 0 /* FIXME: is this too early? */ diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 510f58b0d0..b8e676056a 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -178,7 +178,7 @@ int slap_startup( Backend *be ) if( rc == 0 ) { Slapi_PBlock *pb = slapi_pblock_new(); - if ( slapi_int_call_plugins( NULL, SLAPI_PLUGIN_START_FN, pb ) < 0 ) { + if ( slapi_int_call_plugins( frontendDB, SLAPI_PLUGIN_START_FN, pb ) < 0 ) { rc = -1; } slapi_pblock_destroy( pb ); @@ -204,7 +204,7 @@ int slap_shutdown( Backend *be ) #ifdef LDAP_SLAPI pb = slapi_pblock_new(); - (void) slapi_int_call_plugins( NULL, SLAPI_PLUGIN_CLOSE_FN, pb ); + (void) slapi_int_call_plugins( frontendDB, SLAPI_PLUGIN_CLOSE_FN, pb ); slapi_pblock_destroy( pb ); #endif /* LDAP_SLAPI */ diff --git a/servers/slapd/ldapsync.c b/servers/slapd/ldapsync.c index 5ecf2590f7..9d335860df 100644 --- a/servers/slapd/ldapsync.c +++ b/servers/slapd/ldapsync.c @@ -86,7 +86,8 @@ slap_sync_cookie_free( int slap_parse_sync_cookie( - struct sync_cookie *cookie + struct sync_cookie *cookie, + void *memctx ) { char *csn_ptr; @@ -94,17 +95,33 @@ slap_parse_sync_cookie( int csn_str_len; int valid = 0; char *rid_ptr; - char *rid_str; char *cval; if ( cookie == NULL ) return -1; + cookie->rid = -1; + if (( rid_ptr = strstr( cookie->octet_str.bv_val, "rid=" )) != NULL ) { + if ( (cval = strchr( rid_ptr, ',' )) != NULL ) { + *cval = '\0'; + } + cookie->rid = atoi( rid_ptr + sizeof("rid=") - 1 ); + if ( cval != NULL ) { + *cval = ','; + } + } else { + return -1; + } + while (( csn_ptr = strstr( cookie->octet_str.bv_val, "csn=" )) != NULL ) { AttributeDescription *ad = slap_schema.si_ad_modifyTimestamp; slap_syntax_validate_func *validate; struct berval stamp; + /* This only happens when called from main */ + if ( ad == NULL ) + break; + csn_str = csn_ptr + STRLENOF("csn="); cval = strchr( csn_str, ',' ); if ( cval ) @@ -125,22 +142,11 @@ slap_parse_sync_cookie( break; } if ( valid ) { - ber_str2bv( csn_str, csn_str_len, 1, &cookie->ctxcsn ); + ber_str2bv_x( csn_str, csn_str_len, 1, &cookie->ctxcsn, memctx ); } else { BER_BVZERO( &cookie->ctxcsn ); } - if (( rid_ptr = strstr( cookie->octet_str.bv_val, "rid=" )) != NULL ) { - rid_str = SLAP_STRNDUP( rid_ptr, - SLAP_SYNC_RID_SIZE + sizeof("rid=") - 1 ); - if ( (cval = strchr( rid_str, ',' )) != NULL ) { - *cval = '\0'; - } - cookie->rid = atoi( rid_str + sizeof("rid=") - 1 ); - ch_free( rid_str ); - } else { - cookie->rid = -1; - } return 0; } @@ -176,9 +182,7 @@ slap_dup_sync_cookie( struct sync_cookie *src ) { - int i; struct sync_cookie *new; - struct berval tmp_bv; if ( src == NULL ) return NULL; diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 2c4106e79a..691a116366 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -72,8 +72,8 @@ limits_get( { struct slap_limits **lm; - assert( op ); - assert( limit ); + assert( op != NULL ); + assert( limit != NULL ); Debug( LDAP_DEBUG_TRACE, "==> limits_get: %s dn=\"%s\"\n", op->o_log_prefix, @@ -93,7 +93,7 @@ limits_get( switch ( style ) { case SLAP_LIMITS_EXACT: - if ( ndn->bv_len == 0 ) { + if ( BER_BVISEMPTY( ndn ) ) { break; } @@ -130,7 +130,7 @@ limits_get( case SLAP_LIMITS_CHILDREN: { size_t d; - if ( ndn->bv_len == 0 ) { + if ( BER_BVISEMPTY( ndn ) ) { break; } @@ -147,7 +147,7 @@ limits_get( } } else { /* check for unescaped rdn separator */ - if ( !DN_SEPARATOR( ndn->bv_val[d-1] ) ) { + if ( !DN_SEPARATOR( ndn->bv_val[d - 1] ) ) { break; } } @@ -180,7 +180,7 @@ limits_get( } case SLAP_LIMITS_REGEX: - if ( ndn->bv_len == 0 ) { + if ( BER_BVISEMPTY( ndn ) ) { break; } if ( regexec( &lm[0]->lm_regex, ndn->bv_val, @@ -194,7 +194,7 @@ limits_get( break; case SLAP_LIMITS_ANONYMOUS: - if ( ndn->bv_len == 0 ) { + if ( BER_BVISEMPTY( ndn ) ) { Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=%s\n", limits2str( style ), 0, 0 ); *limit = &lm[0]->lm_limits; @@ -203,7 +203,7 @@ limits_get( break; case SLAP_LIMITS_USERS: - if ( ndn->bv_len != 0 ) { + if ( !BER_BVISEMPTY( ndn ) ) { *limit = &lm[0]->lm_limits; Debug( LDAP_DEBUG_TRACE, "<== limits_get: type=DN match=%s\n", limits2str( style ), 0, 0 ); @@ -238,8 +238,8 @@ limits_add( struct slap_limits *lm; unsigned type, style; - assert( be ); - assert( limit ); + assert( be != NULL ); + assert( limit != NULL ); type = flags & SLAP_LIMITS_TYPE_MASK; style = flags & SLAP_LIMITS_MASK; @@ -271,8 +271,8 @@ limits_add( { int rc; struct berval bv; - bv.bv_val = (char *) pattern; - bv.bv_len = strlen( pattern ); + + ber_str2bv( pattern, 0, 0, &bv ); rc = dnNormalize( 0, NULL, NULL, &bv, &lm->lm_pat, NULL ); if ( rc != LDAP_SUCCESS ) { @@ -297,15 +297,14 @@ limits_add( case SLAP_LIMITS_USERS: case SLAP_LIMITS_ANY: lm->lm_flags = style | type; - lm->lm_pat.bv_val = NULL; - lm->lm_pat.bv_len = 0; + BER_BVZERO( &lm->lm_pat ); break; } switch ( type ) { case SLAP_LIMITS_TYPE_GROUP: - assert( group_oc ); - assert( group_ad ); + assert( group_oc != NULL ); + assert( group_ad != NULL ); lm->lm_group_oc = group_oc; lm->lm_group_ad = group_ad; break; @@ -342,7 +341,7 @@ limits_parse( ObjectClass *group_oc = NULL; AttributeDescription *group_ad = NULL; - assert( be ); + assert( be != NULL ); if ( argc < 3 ) { Debug( LDAP_DEBUG_ANY, @@ -637,8 +636,8 @@ limits_parse_one( struct slap_limits_set *limit ) { - assert( arg ); - assert( limit ); + assert( arg != NULL ); + assert( limit != NULL ); if ( strncasecmp( arg, "time", STRLENOF( "time" ) ) == 0 ) { arg += STRLENOF( "time" ); @@ -1075,8 +1074,8 @@ t_hard: int limits_check( Operation *op, SlapReply *rs ) { - assert( op ); - assert( rs ); + assert( op != NULL ); + assert( rs != NULL ); /* FIXME: should this be always true? */ assert( op->o_tag == LDAP_REQ_SEARCH); @@ -1319,3 +1318,37 @@ limits_check( Operation *op, SlapReply *rs ) return 0; } +void +limits_destroy( + struct slap_limits **lm ) +{ + int i; + + if ( lm == NULL ) { + return; + } + + for ( i = 0; lm[ i ]; i++ ) { + switch ( lm[ i ]->lm_flags & SLAP_LIMITS_MASK ) { + case SLAP_LIMITS_REGEX: + regfree( &lm[ i ]->lm_regex ); + break; + + case SLAP_LIMITS_EXACT: + case SLAP_LIMITS_ONE: + case SLAP_LIMITS_SUBTREE: + case SLAP_LIMITS_CHILDREN: + if ( !BER_BVISNULL( &lm[ i ]->lm_pat ) ) { + ch_free( lm[ i ]->lm_pat.bv_val ); + } + break; + + default: + break; + } + + ch_free( lm[ i ] ); + } + + ch_free( lm ); +} diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 98857b275d..02becaa502 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -181,7 +182,7 @@ struct option_helper { const char *oh_usage; } option_helpers[] = { { BER_BVC("slp"), slapd_opt_slp, NULL, "slp[={on|off}] enable/disable SLP" }, - { BER_BVNULL } + { BER_BVNULL, 0, NULL, NULL } }; static void @@ -361,7 +362,17 @@ int main( int argc, char **argv ) scp = (struct sync_cookie *) ch_calloc( 1, sizeof( struct sync_cookie )); ber_str2bv( optarg, 0, 1, &scp->octet_str ); - slap_parse_sync_cookie( scp ); + + /* This only parses out the rid at this point */ + slap_parse_sync_cookie( scp, NULL ); + + if ( scp->rid == -1 ) { + Debug( LDAP_DEBUG_ANY, + "main: invalid cookie \"%s\"\n", + optarg, 0, 0 ); + slap_sync_cookie_free( scp, 1 ); + goto destroy; + } LDAP_STAILQ_FOREACH( scp_entry, &slap_sync_cookie, sc_next ) { if ( scp->rid == scp_entry->rid ) { @@ -378,7 +389,21 @@ int main( int argc, char **argv ) case 'd': /* set debug level and 'do not detach' flag */ no_detach = 1; #ifdef LDAP_DEBUG - slap_debug |= atoi( optarg ); + if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) ) + { + int level; + + if ( str2loglevel( optarg, &level ) ) { + fprintf( stderr, + "unrecognized log level " + "\"%s\"\n", optarg ); + goto destroy; + } + + slap_debug |= level; + } else { + slap_debug |= atoi( optarg ); + } #else if ( atoi( optarg ) != 0 ) fputs( "must compile with LDAP_DEBUG for debugging\n", @@ -609,16 +634,6 @@ unhandled_option:; (void) ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &rc ); #endif -#ifdef LDAP_SLAPI - if ( slapi_int_initialize() != 0 ) { - Debug( LDAP_DEBUG_ANY, - "slapi initialization error\n", - 0, 0, 0 ); - - goto destroy; - } -#endif /* LDAP_SLAPI */ - if ( frontend_init() ) { goto destroy; } @@ -844,6 +859,13 @@ stop: config_destroy(); + if ( configfile ) + ch_free( configfile ); + if ( configdir ) + ch_free( configdir ); + if ( urls ) + ch_free( urls ); + #ifdef CSRIMALLOC mal_dumpleaktrace( leakfile ); #endif diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 89a7b4f8cd..becbd71310 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -32,9 +32,6 @@ #include #include "slap.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif #include "lutil.h" @@ -207,7 +204,7 @@ cleanup: op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); - if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist ); + if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist, 1 ); return rs->sr_err; } @@ -221,11 +218,7 @@ fe_op_modify( Operation *op, SlapReply *rs ) int manageDSAit; Modifications *modlist = op->orm_modlist; Modifications **modtail = &modlist; -#ifdef LDAP_SLAPI - LDAPMod **modv = NULL; -#endif int increment = op->orm_increment; - int rc = 0; BackendDB *op_be; char textbuf[ SLAP_TEXT_BUFLEN ]; size_t textlen = sizeof( textbuf ); @@ -366,61 +359,6 @@ fe_op_modify( Operation *op, SlapReply *rs ) "modify/increment not supported in context" ); } -#if defined( LDAP_SLAPI ) -#define pb op->o_pb - if ( pb ) { - slapi_int_pblock_set_operation( pb, op ); - slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)op->o_req_dn.bv_val ); - slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit ); - modv = slapi_int_modifications2ldapmods( &modlist ); - slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv ); - - rs->sr_err = slapi_int_call_plugins( op->o_bd, - SLAPI_PLUGIN_PRE_MODIFY_FN, pb ); - - /* - * It's possible that the preoperation plugin changed the - * modification array, so we need to convert it back to - * a Modification list. - * - * Calling slapi_int_modifications2ldapmods() destroyed modlist so - * we don't need to free it. - */ - slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv ); - modlist = slapi_int_ldapmods2modifications( modv ); - - if ( rs->sr_err < 0 ) { - /* - * A preoperation plugin failure will abort the - * entire operation. - */ - Debug(LDAP_DEBUG_TRACE, - "do_modify: modify preoperation plugin failed.\n", - 0, 0, 0); - if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, - (void *)&rs->sr_err ) != 0 ) || rs->sr_err == LDAP_SUCCESS ) - { - rs->sr_err = LDAP_OTHER; - } - slapi_int_free_ldapmods( modv ); - modv = NULL; - goto cleanup; - } - } - - /* - * NB: it is valid for the plugin to return no modifications - * (for example, a plugin might store some attributes elsewhere - * and remove them from the modification list; if only those - * attribute types were included in the modification request, - * then slapi_int_ldapmods2modifications() above will return - * NULL). - * - * However, the post-operation plugin should still be - * called. - */ -#endif /* defined( LDAP_SLAPI ) */ - /* * do the modify if 1 && (2 || 3) * 1) there is a modify function implemented in this backend; @@ -511,20 +449,7 @@ fe_op_modify( Operation *op, SlapReply *rs ) "operation not supported within namingContext" ); } -#if defined( LDAP_SLAPI ) - if ( pb != NULL && slapi_int_call_plugins( op->o_bd, - SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) - { - Debug(LDAP_DEBUG_TRACE, - "do_modify: modify postoperation plugins failed.\n", 0, 0, 0); - } -#endif /* defined( LDAP_SLAPI ) */ - cleanup:; -#if defined( LDAP_SLAPI ) - if ( modv != NULL ) slapi_int_free_ldapmods( modv ); -#endif - return rs->sr_err; } @@ -600,6 +525,34 @@ slap_mods_no_user_mod_check( return LDAP_SUCCESS; } +int +slap_mods_no_repl_user_mod_check( + Operation *op, + Modifications *ml, + const char **text, + char *textbuf, + size_t textlen ) +{ + Modifications *mods; + Modifications *modp; + + for ( mods = ml; mods != NULL; mods = mods->sml_next ) { + assert( mods->sml_op == LDAP_MOD_ADD ); + + /* check doesn't already appear */ + for ( modp = ml; modp != NULL; modp = modp->sml_next ) { + if ( mods->sml_desc == modp->sml_desc && mods != modp ) { + snprintf( textbuf, textlen, + "attribute '%s' provided more than once", + mods->sml_desc->ad_cname.bv_val ); + return LDAP_TYPE_OR_VALUE_EXISTS; + } + } + } + + return LDAP_SUCCESS; +} + /* * Do basic attribute type checking and syntax validation. */ @@ -616,13 +569,14 @@ int slap_mods_check( AttributeDescription *ad = NULL; /* convert to attribute description */ - rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text ); - - if( rc != LDAP_SUCCESS ) { - snprintf( textbuf, textlen, "%s: %s", - ml->sml_type.bv_val, *text ); - *text = textbuf; - return rc; + if ( ml->sml_desc == NULL ) { + rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text ); + if( rc != LDAP_SUCCESS ) { + snprintf( textbuf, textlen, "%s: %s", + ml->sml_type.bv_val, *text ); + *text = textbuf; + return rc; + } } ad = ml->sml_desc; @@ -911,13 +865,13 @@ int slap_mods_opattrs( ber_dupbv( &mod->sml_values[0], &tmpval ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; - assert( mod->sml_values[0].bv_val ); + assert( mod->sml_values[0].bv_val != NULL ); mod->sml_nvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_nvalues[0], &tmpval ); mod->sml_nvalues[1].bv_len = 0; mod->sml_nvalues[1].bv_val = NULL; - assert( mod->sml_nvalues[0].bv_val ); + assert( mod->sml_nvalues[0].bv_val != NULL ); *modtail = mod; modtail = &mod->sml_next; } @@ -938,7 +892,7 @@ int slap_mods_opattrs( ber_dupbv( &mod->sml_values[0], &tmpval ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; - assert( mod->sml_values[0].bv_val ); + assert( mod->sml_values[0].bv_val != NULL ); mod->sml_nvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); (*mod->sml_desc->ad_type->sat_equality->smr_normalize)( @@ -961,13 +915,13 @@ int slap_mods_opattrs( ber_dupbv( &mod->sml_values[0], &name ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; - assert( mod->sml_values[0].bv_val ); + assert( mod->sml_values[0].bv_val != NULL ); mod->sml_nvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_nvalues[0], &nname ); mod->sml_nvalues[1].bv_len = 0; mod->sml_nvalues[1].bv_val = NULL; - assert( mod->sml_nvalues[0].bv_val ); + assert( mod->sml_nvalues[0].bv_val != NULL ); *modtail = mod; modtail = &mod->sml_next; @@ -981,7 +935,7 @@ int slap_mods_opattrs( ber_dupbv( &mod->sml_values[0], ×tamp ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; - assert( mod->sml_values[0].bv_val ); + assert( mod->sml_values[0].bv_val != NULL ); mod->sml_nvalues = NULL; *modtail = mod; modtail = &mod->sml_next; @@ -998,7 +952,7 @@ int slap_mods_opattrs( ber_dupbv( &mod->sml_values[0], &csn ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; - assert( mod->sml_values[0].bv_val ); + assert( mod->sml_values[0].bv_val != NULL ); mod->sml_nvalues = NULL; *modtail = mod; modtail = &mod->sml_next; @@ -1012,13 +966,13 @@ int slap_mods_opattrs( ber_dupbv( &mod->sml_values[0], &name ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; - assert( mod->sml_values[0].bv_val ); + assert( mod->sml_values[0].bv_val != NULL ); mod->sml_nvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_nvalues[0], &nname ); mod->sml_nvalues[1].bv_len = 0; mod->sml_nvalues[1].bv_val = NULL; - assert( mod->sml_nvalues[0].bv_val ); + assert( mod->sml_nvalues[0].bv_val != NULL ); *modtail = mod; modtail = &mod->sml_next; @@ -1031,7 +985,7 @@ int slap_mods_opattrs( ber_dupbv( &mod->sml_values[0], ×tamp ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; - assert( mod->sml_values[0].bv_val ); + assert( mod->sml_values[0].bv_val != NULL ); mod->sml_nvalues = NULL; *modtail = mod; modtail = &mod->sml_next; diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index c2ceab26bb..f54f714103 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -39,9 +39,6 @@ #include #include "slap.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif int do_modrdn( @@ -285,34 +282,6 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) } } -#if defined( LDAP_SLAPI ) -#define pb op->o_pb - if ( pb ) { - slapi_int_pblock_set_operation( pb, op ); - slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)op->o_req_dn.bv_val ); - slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)op->orr_newrdn.bv_val ); - slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, - (void *)op->orr_newSup->bv_val ); - slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)op->orr_deleteoldrdn); - slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit ); - - rs->sr_err = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_MODRDN_FN, pb ); - if ( rs->sr_err < 0 ) { - /* - * A preoperation plugin failure will abort the - * entire operation. - */ - Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn preoperation plugin " - "failed.\n", 0, 0, 0); - if ( ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) || - rs->sr_err == LDAP_SUCCESS ) { - rs->sr_err = LDAP_OTHER; - } - goto cleanup; - } - } -#endif /* defined( LDAP_SLAPI ) */ - /* * do the modrdn if 1 && (2 || 3) * 1) there is a modrdn function implemented in this backend; @@ -403,13 +372,6 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) "operation not supported within namingContext" ); } -#if defined( LDAP_SLAPI ) - if ( pb != NULL && slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) < 0 ) { - Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn postoperation plugins " - "failed.\n", 0, 0, 0); - } -#endif /* defined( LDAP_SLAPI ) */ - cleanup:; return rs->sr_err; } diff --git a/servers/slapd/mods.c b/servers/slapd/mods.c index 3ba189856a..4be7849f2d 100644 --- a/servers/slapd/mods.c +++ b/servers/slapd/mods.c @@ -90,7 +90,7 @@ modify_add_values( for ( p = i = 0; !BER_BVISNULL( &mod->sm_values[i] ); i++ ) { int match; - assert( a->a_vals[0].bv_val ); + assert( a->a_vals[0].bv_val != NULL ); for ( j = 0; !BER_BVISNULL( &a->a_vals[j] ); j++ ) { if ( mod->sm_nvalues ) { rc = ordered_value_match( &match, mod->sm_desc, mr, @@ -245,7 +245,7 @@ modify_delete_vindex( } if( mod->sm_nvalues ) { - assert( a->a_nvals ); + assert( a->a_nvals != NULL ); rc = ordered_value_match( &match, a->a_desc, mr, SLAP_MR_EQUALITY | SLAP_MR_VALUE_OF_ASSERTION_SYNTAX | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH @@ -432,14 +432,16 @@ slap_mod_free( void slap_mods_free( - Modifications *ml ) + Modifications *ml, + int freevals ) { Modifications *next; for ( ; ml != NULL; ml = next ) { next = ml->sml_next; - slap_mod_free( &ml->sml_mod, 0 ); + if ( freevals ) + slap_mod_free( &ml->sml_mod, 0 ); free( ml ); } } diff --git a/servers/slapd/mra.c b/servers/slapd/mra.c index 9337c39d1b..e72298feb9 100644 --- a/servers/slapd/mra.c +++ b/servers/slapd/mra.c @@ -57,13 +57,11 @@ get_mra( struct berval type = BER_BVNULL; struct berval value = BER_BVNULL; struct berval rule_text = BER_BVNULL; - MatchingRuleAssertion ma; + MatchingRuleAssertion ma = { 0 }; #ifdef LDAP_COMP_MATCH AttributeAliasing* aa = NULL; #endif - memset( &ma, 0, sizeof ma); - rtag = ber_scanf( ber, "{t" /*"}"*/, &tag ); if( rtag == LBER_ERROR ) { diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index cd381f1bf3..a721a35d6f 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -385,6 +385,7 @@ oc_destroy( void ) if (o->soc_sups) ldap_memfree(o->soc_sups); if (o->soc_required) ldap_memfree(o->soc_required); if (o->soc_allowed) ldap_memfree(o->soc_allowed); + if (o->soc_oidmacro) ldap_memfree(o->soc_oidmacro); ldap_objectclass_free((LDAPObjectClass *)o); } @@ -462,8 +463,8 @@ oc_insert( oir->oir_name.bv_len = strlen( soc->soc_oid ); oir->oir_oc = soc; - assert( oir->oir_name.bv_val ); - assert( oir->oir_oc ); + assert( oir->oir_name.bv_val != NULL ); + assert( oir->oir_oc != NULL ); if ( avl_insert( &oc_index, (caddr_t) oir, oc_index_cmp, avl_dup_error ) ) @@ -493,8 +494,8 @@ oc_insert( oir->oir_name.bv_len = strlen( *names ); oir->oir_oc = soc; - assert( oir->oir_name.bv_val ); - assert( oir->oir_oc ); + assert( oir->oir_name.bv_val != NULL ); + assert( oir->oir_oc != NULL ); if ( avl_insert( &oc_index, (caddr_t) oir, oc_index_cmp, avl_dup_error ) ) @@ -604,7 +605,7 @@ oc_unparse( BerVarray *res, ObjectClass *start, ObjectClass *end, int sys ) ObjectClass *oc; int i, num; struct berval bv, *bva = NULL, idx; - char ibuf[32], *ptr; + char ibuf[32]; if ( !start ) start = LDAP_STAILQ_FIRST( &oc_list ); diff --git a/servers/slapd/oidm.c b/servers/slapd/oidm.c index 25407644a4..3c93c3ef41 100644 --- a/servers/slapd/oidm.c +++ b/servers/slapd/oidm.c @@ -119,9 +119,9 @@ usage: fprintf( stderr, "\tObjectIdentifier \n"); return 1; } - om = (OidMacro *) SLAP_MALLOC( sizeof(OidMacro) ); + om = (OidMacro *) SLAP_CALLOC( sizeof(OidMacro), 1 ); if( om == NULL ) { - Debug( LDAP_DEBUG_ANY, "parse_oidm: SLAP_MALLOC failed", 0, 0, 0 ); + Debug( LDAP_DEBUG_ANY, "parse_oidm: SLAP_CALLOC failed", 0, 0, 0 ); return 1; } @@ -156,7 +156,7 @@ void oidm_unparse( BerVarray *res, OidMacro *start, OidMacro *end, int sys ) { OidMacro *om; int i, j, num; - struct berval bv, *bva = NULL, idx; + struct berval *bva = NULL, idx; char ibuf[32], *ptr; if ( !start ) diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index b6a4ae0e54..f8ecf3b920 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -63,21 +63,19 @@ void slap_op_destroy(void) void slap_op_free( Operation *op ) { - struct berval slap_empty_bv_dup; - assert( LDAP_STAILQ_NEXT(op, o_next) == NULL ); if ( op->o_ber != NULL ) { ber_free( op->o_ber, 1 ); } if ( !BER_BVISNULL( &op->o_dn ) ) { - free( op->o_dn.bv_val ); + ch_free( op->o_dn.bv_val ); } if ( !BER_BVISNULL( &op->o_ndn ) ) { - free( op->o_ndn.bv_val ); + ch_free( op->o_ndn.bv_val ); } if ( !BER_BVISNULL( &op->o_authmech ) ) { - free( op->o_authmech.bv_val ); + ch_free( op->o_authmech.bv_val ); } if ( op->o_ctrls != NULL ) { slap_free_ctrls( op, op->o_ctrls ); @@ -99,8 +97,7 @@ slap_op_free( Operation *op ) } #if defined( LDAP_SLAPI ) - if ( op->o_pb != NULL ) { - slapi_pblock_destroy( (Slapi_PBlock *)op->o_pb ); + if ( slapi_plugins_used ) { slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op ); } #endif /* defined( LDAP_SLAPI ) */ @@ -124,7 +121,6 @@ slap_op_alloc( ) { Operation *op; - struct berval slap_empty_bv_dup; ldap_pvt_thread_mutex_lock( &slap_op_mutex ); if ((op = LDAP_STAILQ_FIRST( &slap_free_ops ))) { @@ -155,7 +151,6 @@ slap_op_alloc( #if defined( LDAP_SLAPI ) if ( slapi_plugins_used ) { - op->o_pb = slapi_pblock_new(); slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION, op ); } #endif /* defined( LDAP_SLAPI ) */ diff --git a/servers/slapd/operational.c b/servers/slapd/operational.c index 9aec4402b3..cbc149421c 100644 --- a/servers/slapd/operational.c +++ b/servers/slapd/operational.c @@ -53,7 +53,7 @@ slap_operational_entryDN( Entry *e ) { Attribute *a; - assert( e ); + assert( e != NULL ); assert( !BER_BVISNULL( &e->e_name ) ); assert( !BER_BVISNULL( &e->e_nname ) ); diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c index c17996f706..b9e390722c 100644 --- a/servers/slapd/overlays/accesslog.c +++ b/servers/slapd/overlays/accesslog.c @@ -43,11 +43,13 @@ #define LOG_OP_UNBIND 0x080 #define LOG_OP_ABANDON 0x100 #define LOG_OP_EXTENDED 0x200 +#define LOG_OP_UNKNOWN 0x400 #define LOG_OP_WRITES (LOG_OP_ADD|LOG_OP_DELETE|LOG_OP_MODIFY|LOG_OP_MODRDN) #define LOG_OP_READS (LOG_OP_COMPARE|LOG_OP_SEARCH) #define LOG_OP_SESSION (LOG_OP_BIND|LOG_OP_UNBIND|LOG_OP_ABANDON) -#define LOG_OP_ALL (LOG_OP_READS|LOG_OP_WRITES|LOG_OP_SESSION|LOG_OP_EXTENDED) +#define LOG_OP_ALL (LOG_OP_READS|LOG_OP_WRITES|LOG_OP_SESSION| \ + LOG_OP_EXTENDED|LOG_OP_UNKNOWN) typedef struct log_info { BackendDB *li_db; @@ -109,6 +111,7 @@ static slap_verbmasks logops[] = { { BER_BVC("unbind"), LOG_OP_UNBIND }, { BER_BVC("abandon"), LOG_OP_ABANDON }, { BER_BVC("extended"), LOG_OP_EXTENDED }, + { BER_BVC("unknown"), LOG_OP_UNKNOWN }, { BER_BVNULL, 0 } }; @@ -126,6 +129,7 @@ enum { LOG_EN_UNBIND, LOG_EN_ABANDON, LOG_EN_EXTENDED, + LOG_EN_UNKNOWN, LOG_EN__COUNT }; @@ -142,7 +146,10 @@ static AttributeDescription *ad_reqDN, *ad_reqStart, *ad_reqEnd, *ad_reqType, *ad_reqNewSuperior, *ad_reqDeleteOldRDN, *ad_reqMod, *ad_reqScope, *ad_reqFilter, *ad_reqAttr, *ad_reqEntries, *ad_reqSizeLimit, *ad_reqTimeLimit, *ad_reqAttrsOnly, *ad_reqData, - *ad_reqId, *ad_reqMessage, *ad_oldest; + *ad_reqId, *ad_reqMessage; +#if 0 +static AttributeDescription *ad_oldest; +#endif static struct { char *at; @@ -338,7 +345,6 @@ static struct { static int log_age_parse(char *agestr) { - char *ptr; int t1, t2; int gotdays = 0; @@ -723,6 +729,8 @@ static int accesslog_response(Operation *op, SlapReply *rs) { case LDAP_REQ_SEARCH: logop = LOG_EN_SEARCH; break; case LDAP_REQ_BIND: logop = LOG_EN_BIND; break; case LDAP_REQ_EXTENDED: logop = LOG_EN_EXTENDED; break; + default: /* unknown operation type */ + logop = LOG_EN_UNKNOWN; break; } /* Unbind and Abandon never reach here */ lo = logops+logop+EN_OFFSET; @@ -810,16 +818,22 @@ static int accesslog_response(Operation *op, SlapReply *rs) { if ( m->sml_values ) { for (b=m->sml_values; !BER_BVISNULL( b ); b++,i++) { char c_op; - vals[i].bv_len = a->a_desc->ad_cname.bv_len + b->bv_len +3; + vals[i].bv_len = m->sml_desc->ad_cname.bv_len + b->bv_len +3; vals[i].bv_val = ch_malloc( vals[i].bv_len+1 ); ptr = lutil_strcopy( vals[i].bv_val, - a->a_desc->ad_cname.bv_val ); + m->sml_desc->ad_cname.bv_val ); *ptr++ = ':'; switch( m->sml_op ) { case LDAP_MOD_ADD: c_op = '+'; break; case LDAP_MOD_DELETE: c_op = '-'; break; case LDAP_MOD_REPLACE: c_op = '='; break; case LDAP_MOD_INCREMENT: c_op = '#'; break; + + /* unknown op. there shouldn't be any of these. we + * don't know what to do with it, but we shouldn't just + * ignore it. + */ + default: c_op = '?'; break; } *ptr++ = c_op; *ptr++ = ' '; @@ -827,7 +841,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) { vals[i].bv_val[vals[i].bv_len] = '\0'; } } else if ( m->sml_op == LDAP_MOD_DELETE ) { - vals[i].bv_len = a->a_desc->ad_cname.bv_len + 2; + vals[i].bv_len = m->sml_desc->ad_cname.bv_len + 2; vals[i].bv_val = ch_malloc( vals[i].bv_len+1 ); ptr = lutil_strcopy( vals[i].bv_val, a->a_desc->ad_cname.bv_val ); @@ -916,6 +930,10 @@ static int accesslog_response(Operation *op, SlapReply *rs) { attr_merge_one( e, ad_reqData, op->ore_reqdata, NULL ); } break; + + case LOG_EN_UNKNOWN: + /* we don't know its parameters, don't add any */ + break; } op2.o_hdr = op->o_hdr; diff --git a/servers/slapd/overlays/dynlist.c b/servers/slapd/overlays/dynlist.c index 3615ab16df..e28d7315bc 100644 --- a/servers/slapd/overlays/dynlist.c +++ b/servers/slapd/overlays/dynlist.c @@ -87,8 +87,8 @@ dynlist_make_filter( Operation *op, struct berval *oldf, struct berval *newf ) char *ptr; - assert( oldf ); - assert( newf ); + assert( oldf != NULL ); + assert( newf != NULL ); assert( !BER_BVISNULL( oldf ) ); assert( !BER_BVISEMPTY( oldf ) ); @@ -289,7 +289,7 @@ dynlist_send_entry( Operation *op, SlapReply *rs ) SlapReply r = { REP_SEARCH }; struct berval *url; Entry *e; - int e_flags; + slap_mask_t e_flags; int opattrs, userattrs; dynlist_sc_t dlc = { 0 }; diff --git a/servers/slapd/overlays/glue.c b/servers/slapd/overlays/glue.c index 6e4e0836a1..74fee3f652 100644 --- a/servers/slapd/overlays/glue.c +++ b/servers/slapd/overlays/glue.c @@ -69,7 +69,7 @@ glue_back_select ( int i; for (i = 0; igi_nodes; i++) { - assert( gi->gi_n[i].gn_be->be_nsuffix ); + assert( gi->gi_n[i].gn_be->be_nsuffix != NULL ); if (dnIsSuffix(dn, &gi->gi_n[i].gn_be->be_nsuffix[0])) { return gi->gi_n[i].gn_be; @@ -153,22 +153,14 @@ glue_op_response ( Operation *op, SlapReply *rs ) return 0; } -enum glue_which { - op_modify = 0, - op_modrdn, - op_add, - op_delete -}; - static int glue_op_func ( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; - glueinfo *gi = (glueinfo *)on->on_bi.bi_private; BackendDB *b0 = op->o_bd; BackendInfo *bi0 = op->o_bd->bd_info; BI_op_modify **func; - enum glue_which which; + slap_operation_t which; int rc; op->o_bd = glue_back_select (b0, &op->o_req_ndn); @@ -181,7 +173,7 @@ glue_op_func ( Operation *op, SlapReply *rs ) case LDAP_REQ_MODRDN: which = op_modrdn; break; } - func = &op->o_bd->bd_info->bi_op_modify; + func = &op->o_bd->bd_info->bi_op_bind; if ( func[which] ) rc = func[which]( op, rs ); else @@ -196,7 +188,6 @@ static int glue_chk_referrals ( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; - glueinfo *gi = (glueinfo *)on->on_bi.bi_private; BackendDB *b0 = op->o_bd; BackendInfo *bi0 = op->o_bd->bd_info; int rc; @@ -218,7 +209,6 @@ static int glue_chk_controls ( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; - glueinfo *gi = (glueinfo *)on->on_bi.bi_private; BackendDB *b0 = op->o_bd; BackendInfo *bi0 = op->o_bd->bd_info; int rc = SLAP_CB_CONTINUE; @@ -341,8 +331,8 @@ glue_op_search ( Operation *op, SlapReply *rs ) } op->o_bd = btmp; - assert( op->o_bd->be_suffix ); - assert( op->o_bd->be_nsuffix ); + assert( op->o_bd->be_suffix != NULL ); + assert( op->o_bd->be_nsuffix != NULL ); if (scope0 == LDAP_SCOPE_ONELEVEL && dn_match(pdn, &ndn)) @@ -526,10 +516,8 @@ glue_close ( BackendInfo *bi ) { - slap_overinst *on = glue_tool_inst( bi ); - glueinfo *gi = on->on_bi.bi_private; static int glueClosed = 0; - int i, rc = 0; + int rc = 0; if (glueClosed) return 0; @@ -654,7 +642,7 @@ glue_tool_entry_put ( ) { BackendDB *be, b2; - int rc = NOID; + int rc = -1; b2 = *b0; b2.bd_info = (BackendInfo *)glue_tool_inst( b0->bd_info ); @@ -800,10 +788,9 @@ glue_db_config( SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE; if ( strcasecmp( argv[0], "glue-sub" ) == 0 ) { - int i, async = 0, advertise = 0; - BackendDB *b2; - struct berval bv, dn; - gluenode *gn; + int i, async = 0, advertise = 0; + BackendDB *b2; + struct berval bv, dn = BER_BVNULL; if ( argc < 2 ) { fprintf( stderr, "%s: line %d: too few arguments in " @@ -828,6 +815,7 @@ glue_db_config( return -1; } b2 = select_backend( &dn, 0, 1 ); + ber_memfree( dn.bv_val ); if ( !b2 ) { fprintf( stderr, "%s: line %d: unknown suffix \"%s\"\n", fname, lineno, argv[1] ); diff --git a/servers/slapd/overlays/lastmod.c b/servers/slapd/overlays/lastmod.c index 8a9996708f..07e06eb0d2 100644 --- a/servers/slapd/overlays/lastmod.c +++ b/servers/slapd/overlays/lastmod.c @@ -283,7 +283,6 @@ lastmod_op_func( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private; - unsigned i; Modifications *ml; if ( dn_match( &op->o_req_ndn, &lmi->lmi_e->e_nname ) ) { @@ -692,7 +691,6 @@ lastmod_response( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private; - unsigned int i; /* don't record failed operations */ switch ( rs->sr_err ) { @@ -730,7 +728,6 @@ lastmod_response( Operation *op, SlapReply *rs ) } ldap_pvt_thread_mutex_unlock( &lmi->lmi_entry_mutex ); -process:; (void)lastmod_update( op, rs ); return SLAP_CB_CONTINUE; diff --git a/servers/slapd/overlays/overlays.c b/servers/slapd/overlays/overlays.c index 6c3b81ad09..7a2e66c66a 100644 --- a/servers/slapd/overlays/overlays.c +++ b/servers/slapd/overlays/overlays.c @@ -23,6 +23,9 @@ #include "slap.h" +#if SLAPD_OVER_ACCESSLOG == SLAPD_MOD_STATIC +extern int accesslog_init(); +#endif #if SLAPD_OVER_DENYOP == SLAPD_MOD_STATIC extern int denyop_init(); #endif @@ -67,6 +70,9 @@ static struct { char *name; int (*func)(); } funcs[] = { +#if SLAPD_OVER_ACCESSLOG == SLAPD_MOD_STATIC + { "Access Log", accesslog_init }, +#endif #if SLAPD_OVER_DENYOP == SLAPD_MOD_STATIC { "Deny Operation", denyop_init }, #endif diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 5d2d1247e2..78549fbe26 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -186,7 +186,7 @@ merge_entry( op->o_tag = LDAP_REQ_MODIFY; op->orm_modlist = modlist; op->o_bd->be_modify( op, &sreply ); - slap_mods_free( modlist ); + slap_mods_free( modlist, 1 ); } else if ( rc == LDAP_REFERRAL || rc == LDAP_NO_SUCH_OBJECT ) { syncrepl_add_glue( op, e ); @@ -1609,7 +1609,7 @@ static ConfigTable pccfg[] = { "DESC 'Filter template, attrset, and cache TTL' " "SYNTAX OMsDirectoryString )", NULL, NULL }, { "response-callback", "head|tail(default)", - 2, 2, 0, ARG_MAGIC|ARG_STRING|PC_RESP, pc_cf_gen, + 2, 2, 0, ARG_MAGIC|PC_RESP, pc_cf_gen, "( OLcfgOvAt:2.4 NAME 'olcProxyResponseCB' " "DESC 'Response callback position in overlay stack' " "SYNTAX OMsDirectoryString )", NULL, NULL }, @@ -1733,11 +1733,9 @@ pc_cf_gen( ConfigArgs *c ) break; case PC_RESP: if ( cm->response_cb == PCACHE_RESPONSE_CB_HEAD ) { - bv.bv_val = "head"; - bv.bv_len = STRLENOF("head"); + BER_BVSTR( &bv, "head" ); } else { - bv.bv_val = "tail"; - bv.bv_len = STRLENOF("tail"); + BER_BVSTR( &bv, "tail" ); } value_add_one( &c->rvalue_vals, &bv ); break; @@ -2026,17 +2024,24 @@ proxy_cache_destroy( slap_overinst *on = (slap_overinst *)be->bd_info; cache_manager *cm = on->on_bi.bi_private; query_manager *qm = cm->qm; - int rc = 0; - if ( cm->db.bd_info->bi_db_destroy ) { - rc = cm->db.bd_info->bi_db_destroy( &cm->db ); - } - ldap_pvt_thread_mutex_destroy(&qm->lru_mutex); - ldap_pvt_thread_mutex_destroy(&cm->cache_mutex); - ldap_pvt_thread_mutex_destroy(&cm->remove_mutex); + /* cleanup stuff inherited from the original database... */ + cm->db.be_suffix = NULL; + cm->db.be_nsuffix = NULL; + BER_BVZERO( &cm->db.be_rootdn ); + BER_BVZERO( &cm->db.be_rootndn ); + BER_BVZERO( &cm->db.be_rootpw ); + /* FIXME: there might be more... */ + + backend_destroy_one( &cm->db, 0 ); + + ldap_pvt_thread_mutex_destroy( &qm->lru_mutex ); + ldap_pvt_thread_mutex_destroy( &cm->cache_mutex ); + ldap_pvt_thread_mutex_destroy( &cm->remove_mutex ); free( qm ); free( cm ); - return rc; + + return 0; } static slap_overinst proxy_cache; diff --git a/servers/slapd/overlays/ppolicy.c b/servers/slapd/overlays/ppolicy.c index 4b29520517..64daabd22c 100644 --- a/servers/slapd/overlays/ppolicy.c +++ b/servers/slapd/overlays/ppolicy.c @@ -211,10 +211,8 @@ account_locked( Operation *op, Entry *e, PassPolicy *pp, Modifications **mod ) { Attribute *la; - int rc; - Entry *de; - assert(mod); + assert(mod != NULL); if ( (la = attr_find( e->e_attrs, ad_pwdAccountLockedTime )) != NULL ) { BerVarray vals = la->a_nvals; @@ -225,7 +223,6 @@ account_locked( Operation *op, Entry *e, */ if (vals[0].bv_val != NULL) { time_t then, now; - struct berval bv; Modifications *m; if (!pp->pwdLockoutDuration) @@ -310,12 +307,11 @@ ppolicy_get( Operation *op, Entry *e, PassPolicy *pp ) pp_info *pi = on->on_bi.bi_private; Attribute *a; BerVarray vals; - int i, rc, nent; + int rc; Entry *pe = NULL; - AttributeDescription *oca = slap_schema.si_ad_objectClass; +#if 0 const char *text; - AttributeDescription *ad; - struct berval bv; +#endif memset( pp, 0, sizeof(PassPolicy) ); @@ -432,7 +428,6 @@ check_password_quality( struct berval *cred, PassPolicy *pp, LDAPPasswordPolicyE { int rc = LDAP_SUCCESS, ok = LDAP_SUCCESS; char *ptr = cred->bv_val; - char *modpath; struct berval sch; assert( cred != NULL ); @@ -681,10 +676,9 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs ) slap_overinst *on = ppb->on; Modifications *mod = ppb->mod, *m; int pwExpired = 0; - int ngut = -1, warn = -1, age, rc, i; + int ngut = -1, warn = -1, age, rc; Attribute *a; - time_t now, then, pwtime = (time_t)-1; - const char *txt; + time_t now, pwtime = (time_t)-1; char nowstr[ LDAP_LUTIL_GENTIME_BUFSIZE ]; struct berval timestamp; BackendInfo *bi = op->o_bd->bd_info; @@ -925,7 +919,7 @@ locked: op2.o_ndn = op->o_bd->be_rootndn; op2.o_bd->bd_info = (BackendInfo *)on->on_info; rc = op->o_bd->be_modify( &op2, &r2 ); - slap_mods_free( mod ); + slap_mods_free( mod, 1 ); } if ( ppb->send_ctrl ) { @@ -953,7 +947,7 @@ ppolicy_bind( Operation *op, SlapReply *rs ) /* Root bypasses policy */ if ( !be_isroot_dn( op->o_bd, &op->o_req_ndn )) { Entry *e; - int i, rc; + int rc; ppbind *ppb; slap_callback *cb; @@ -1017,7 +1011,7 @@ ppolicy_restrict( SlapReply *rs ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; - int i, send_ctrl = 0; + int send_ctrl = 0; /* Did we receive a password policy request control? */ if ( op->o_ctrlflag[ppolicy_cid] ) { @@ -1052,7 +1046,6 @@ ppolicy_add( slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; pp_info *pi = on->on_bi.bi_private; PassPolicy pp; - int pw; Attribute *pa; const char *txt; @@ -1071,7 +1064,7 @@ ppolicy_add( ppolicy_get( op, op->ora_e, &pp ); if (pp.pwdCheckQuality > 0 && !be_isroot( op )) { struct berval *bv = &(pa->a_vals[0]); - int rc, i, send_ctrl = 0; + int rc, send_ctrl = 0; LDAPPasswordPolicyError pErr = PP_noError; /* Did we receive a password policy request control? */ @@ -1149,7 +1142,7 @@ ppolicy_modify( Operation *op, SlapReply *rs ) hsize = 0; PassPolicy pp; Modifications *mods = NULL, *modtail, *ml, *delmod, *addmod; - Attribute *pa, *ha, *ra, at; + Attribute *pa, *ha, at; const char *txt; pw_hist *tl = NULL, *p; int zapReset, send_ctrl = 0; @@ -1271,7 +1264,6 @@ ppolicy_modify( Operation *op, SlapReply *rs ) if (pp.pwdInHistory > 0 && (ha = attr_find( e->e_attrs, ad_pwdHistory ))) { struct berval oldpw; time_t oldtime; - char *oid; for(i=0; ha->a_nvals[i].bv_val; i++) { rc = parse_pwdhistory( &(ha->a_nvals[i]), NULL, @@ -1438,7 +1430,6 @@ do_modify: struct berval timestamp; char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; time_t now = slap_get_time(); - Attribute *ga; /* * keep the necessary pwd.. operational attributes @@ -1458,7 +1449,7 @@ do_modify: ber_dupbv( &mods->sml_values[0], ×tamp ); mods->sml_values[1].bv_len = 0; mods->sml_values[1].bv_val = NULL; - assert( mods->sml_values[0].bv_val ); + assert( mods->sml_values[0].bv_val != NULL ); } else { mods->sml_op = LDAP_MOD_DELETE; mods->sml_values = NULL; diff --git a/servers/slapd/overlays/refint.c b/servers/slapd/overlays/refint.c index a233fec070..41e1cbc9cf 100644 --- a/servers/slapd/overlays/refint.c +++ b/servers/slapd/overlays/refint.c @@ -570,7 +570,7 @@ refint_response( rc = nop.o_bd->be_search(&nop, &nrs); ch_free( nop.ors_filterstr.bv_val ); - while ( fptr = ftop.f_or ) { + while ( (fptr = ftop.f_or) != NULL ) { ftop.f_or = fptr->f_next; ch_free( fptr ); } @@ -653,7 +653,7 @@ done: for(dp = dd.mods; dp; dp = dd.mods) { dd.mods = dp->next; ch_free(dp->dn.bv_val); - slap_mods_free(dp->mm); + slap_mods_free(dp->mm, 1); } dd.mods = NULL; diff --git a/servers/slapd/overlays/retcode.c b/servers/slapd/overlays/retcode.c new file mode 100644 index 0000000000..5788ccf7b8 --- /dev/null +++ b/servers/slapd/overlays/retcode.c @@ -0,0 +1,1143 @@ +/* retcode.c - customizable response for client testing purposes */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 2005 The OpenLDAP Foundation. + * Portions Copyright 2005 Pierangelo Masarati + * 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 + * . + */ +/* ACKNOWLEDGEMENTS: + * This work was initially developed by Pierangelo Masarati for inclusion + * in OpenLDAP Software. + */ + +#include "portable.h" + +#ifdef SLAPD_OVER_RETCODE + +#include + +#include +#include +#include +#include + +#include "slap.h" +#include "lutil.h" + +static slap_overinst retcode; + +static AttributeDescription *ad_errCode; +static AttributeDescription *ad_errText; +static AttributeDescription *ad_errOp; +static AttributeDescription *ad_errSleepTime; +static ObjectClass *oc_errObject; + +typedef enum retcode_op_e { + SN_DG_OP_NONE = 0x0000, + SN_DG_OP_ADD = 0x0001, + SN_DG_OP_BIND = 0x0002, + SN_DG_OP_COMPARE = 0x0004, + SN_DG_OP_DELETE = 0x0008, + SN_DG_OP_MODIFY = 0x0010, + SN_DG_OP_RENAME = 0x0020, + SN_DG_OP_SEARCH = 0x0040, + SN_DG_EXTENDED = 0x0080, + SN_DG_OP_AUTH = SN_DG_OP_BIND, + SN_DG_OP_READ = (SN_DG_OP_COMPARE|SN_DG_OP_SEARCH), + SN_DG_OP_WRITE = (SN_DG_OP_ADD|SN_DG_OP_DELETE|SN_DG_OP_MODIFY|SN_DG_OP_RENAME), + SN_DG_OP_ALL = (SN_DG_OP_AUTH|SN_DG_OP_READ|SN_DG_OP_WRITE|SN_DG_EXTENDED) +} retcode_op_e; + +typedef struct retcode_item_t { + struct berval rdi_dn; + struct berval rdi_ndn; + struct berval rdi_text; + int rdi_err; + BerVarray rdi_ref; + int rdi_sleeptime; + Entry rdi_e; + slap_mask_t rdi_mask; + struct retcode_item_t *rdi_next; +} retcode_item_t; + +typedef struct retcode_t { + struct berval rd_pdn; + struct berval rd_npdn; + + retcode_item_t *rd_item; + + unsigned rd_flags; +#define RETCODE_FNONE 0x00 +#define RETCODE_FINDIR 0x01 +#define RETCODE_INDIR( rd ) ( (rd)->rd_flags & RETCODE_FINDIR ) +} retcode_t; + +static int +retcode_entry_response( Operation *op, SlapReply *rs, Entry *e ); + +static int +retcode_cleanup_cb( Operation *op, SlapReply *rs ) +{ + rs->sr_matched = NULL; + rs->sr_text = NULL; + + if ( rs->sr_ref != NULL ) { + ber_bvarray_free( rs->sr_ref ); + rs->sr_ref = NULL; + } + + ch_free( op->o_callback ); + op->o_callback = NULL; + + return SLAP_CB_CONTINUE; +} + +static int +retcode_send_onelevel( Operation *op, SlapReply *rs ) +{ + slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; + retcode_t *rd = (retcode_t *)on->on_bi.bi_private; + + retcode_item_t *rdi; + + for ( rdi = rd->rd_item; rdi != NULL; rdi = rdi->rdi_next ) { + int rc; + + if ( op->o_abandon ) { + return rs->sr_err = SLAPD_ABANDON; + } + + rs->sr_err = test_filter( op, &rdi->rdi_e, op->ors_filter ); + if ( rs->sr_err == LDAP_COMPARE_TRUE ) { + if ( op->ors_slimit == rs->sr_nentries ) { + rs->sr_err = LDAP_SIZELIMIT_EXCEEDED; + goto done; + } + + /* safe default */ + rs->sr_attrs = op->ors_attrs; + rs->sr_operational_attrs = NULL; + rs->sr_ctrls = NULL; + rs->sr_flags = 0; + rs->sr_err = LDAP_SUCCESS; + rs->sr_entry = &rdi->rdi_e; + + rc = send_search_entry( op, rs ); + + switch ( rc ) { + case 0: /* entry sent ok */ + break; + case 1: /* entry not sent */ + break; + case -1: /* connection closed */ + rs->sr_entry = NULL; + rs->sr_err = LDAP_OTHER; + goto done; + } + } + rs->sr_err = LDAP_SUCCESS; + } + +done:; + + send_ldap_result( op, rs ); + + return rs->sr_err; +} + +static int +retcode_op_add( Operation *op, SlapReply *rs ) +{ + return retcode_entry_response( op, rs, op->ora_e ); +} + +typedef struct retcode_cb_t { + unsigned rdc_flags; + ber_tag_t rdc_tag; +} retcode_cb_t; + +static int +retcode_cb_response( Operation *op, SlapReply *rs ) +{ + retcode_cb_t *rdc = (retcode_cb_t *)op->o_callback->sc_private; + + if ( rs->sr_type == REP_SEARCH ) { + ber_tag_t o_tag = op->o_tag; + int rc; + + op->o_tag = rdc->rdc_tag; + rc = retcode_entry_response( op, rs, rs->sr_entry ); + op->o_tag = o_tag; + + return rc; + } + + if ( rs->sr_err == LDAP_SUCCESS ) { + rdc->rdc_flags = SLAP_CB_CONTINUE; + return 0; + } + + return SLAP_CB_CONTINUE; +} + +static int +retcode_op_internal( Operation *op, SlapReply *rs ) +{ + slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; + + Operation op2 = *op; + SlapReply rs2 = { 0 }; + BackendDB db = *op->o_bd; + slap_callback sc = { 0 }; + retcode_cb_t rdc; + + int rc; + + op2.o_tag = LDAP_REQ_SEARCH; + op2.ors_scope = LDAP_SCOPE_BASE; + op2.ors_deref = LDAP_DEREF_NEVER; + op2.ors_tlimit = SLAP_NO_LIMIT; + op2.ors_slimit = SLAP_NO_LIMIT; + op2.ors_limit = NULL; + op2.ors_attrsonly = 0; + op2.ors_attrs = slap_anlist_all_attributes; + + ber_str2bv_x( "(objectClass=errObject)", STRLENOF( "(objectClass=errObject)" ), + 1, &op2.ors_filterstr, op2.o_tmpmemctx ); + op2.ors_filter = str2filter_x( &op2, op2.ors_filterstr.bv_val ); + + db.bd_info = on->on_info->oi_orig; + op2.o_bd = &db; + + rdc.rdc_flags = RETCODE_FINDIR; + rdc.rdc_tag = op->o_tag; + sc.sc_response = retcode_cb_response; + sc.sc_private = &rdc; + op2.o_callback = ≻ + + rc = op2.o_bd->be_search( &op2, &rs2 ); + + filter_free_x( &op2, op2.ors_filter ); + ber_memfree_x( op2.ors_filterstr.bv_val, op2.o_tmpmemctx ); + + if ( rdc.rdc_flags == SLAP_CB_CONTINUE ) { + return SLAP_CB_CONTINUE; + } + + return rc; +} + +static int +retcode_op_func( Operation *op, SlapReply *rs ) +{ + slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; + retcode_t *rd = (retcode_t *)on->on_bi.bi_private; + + retcode_item_t *rdi; + struct berval nrdn, npdn; + + slap_callback *cb = NULL; + + if ( !dnIsSuffix( &op->o_req_ndn, &rd->rd_npdn ) ) { + if ( RETCODE_INDIR( rd ) ) { + switch ( op->o_tag ) { + case LDAP_REQ_ADD: + return retcode_op_add( op, rs ); + + case LDAP_REQ_BIND: + if ( be_isroot_pw( op ) ) { + return SLAP_CB_CONTINUE; + } + /* fallthru */ + + case LDAP_REQ_MODIFY: + case LDAP_REQ_DELETE: + case LDAP_REQ_MODRDN: + case LDAP_REQ_COMPARE: + case LDAP_REQ_SEARCH: + return retcode_op_internal( op, rs ); + } + } + + return SLAP_CB_CONTINUE; + } + + if ( op->o_tag == LDAP_REQ_SEARCH + && op->ors_scope != LDAP_SCOPE_BASE + && op->o_req_ndn.bv_len == rd->rd_npdn.bv_len ) + { + return retcode_send_onelevel( op, rs ); + } + + dnParent( &op->o_req_ndn, &npdn ); + if ( npdn.bv_len != rd->rd_npdn.bv_len ) { + rs->sr_err = LDAP_NO_SUCH_OBJECT; + rs->sr_matched = rd->rd_pdn.bv_val; + send_ldap_result( op, rs ); + rs->sr_matched = NULL; + return rs->sr_err; + } + + dnRdn( &op->o_req_ndn, &nrdn ); + + for ( rdi = rd->rd_item; rdi != NULL; rdi = rdi->rdi_next ) { + struct berval rdi_nrdn; + + dnRdn( &rdi->rdi_ndn, &rdi_nrdn ); + if ( dn_match( &nrdn, &rdi_nrdn ) ) { + break; + } + } + + if ( rdi != NULL && rdi->rdi_mask != SN_DG_OP_ALL ) { + retcode_op_e o_tag = SN_DG_OP_NONE; + + switch ( op->o_tag ) { + case LDAP_REQ_ADD: + o_tag = SN_DG_OP_ADD; + break; + + case LDAP_REQ_BIND: + o_tag = SN_DG_OP_BIND; + break; + + case LDAP_REQ_COMPARE: + o_tag = SN_DG_OP_COMPARE; + break; + + case LDAP_REQ_DELETE: + o_tag = SN_DG_OP_DELETE; + break; + + case LDAP_REQ_MODIFY: + o_tag = SN_DG_OP_MODIFY; + break; + + case LDAP_REQ_MODRDN: + o_tag = SN_DG_OP_RENAME; + break; + + case LDAP_REQ_SEARCH: + o_tag = SN_DG_OP_SEARCH; + break; + + case LDAP_REQ_EXTENDED: + o_tag = SN_DG_EXTENDED; + break; + + default: + /* Should not happen */ + break; + } + + if ( !( o_tag & rdi->rdi_mask ) ) { + return SLAP_CB_CONTINUE; + } + } + + if ( rdi == NULL ) { + rs->sr_matched = rd->rd_pdn.bv_val; + rs->sr_err = LDAP_NO_SUCH_OBJECT; + rs->sr_text = "retcode not found"; + + } else { + rs->sr_err = rdi->rdi_err; + rs->sr_text = rdi->rdi_text.bv_val; + + /* FIXME: we only honor the rdi_ref field in case rdi_err + * is LDAP_REFERRAL otherwise send_ldap_result() bails out */ + if ( rs->sr_err == LDAP_REFERRAL ) { + BerVarray ref; + + if ( rdi->rdi_ref != NULL ) { + ref = rdi->rdi_ref; + } else { + ref = default_referral; + } + + if ( ref != NULL ) { + rs->sr_ref = referral_rewrite( ref, + NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); + + } else { + rs->sr_err = LDAP_OTHER; + rs->sr_text = "bad referral object"; + } + } + + if ( rdi->rdi_sleeptime > 0 ) { + sleep( rdi->rdi_sleeptime ); + } + } + + switch ( op->o_tag ) { + case LDAP_REQ_EXTENDED: + if ( rdi == NULL ) { + break; + } + cb = ( slap_callback * )ch_malloc( sizeof( slap_callback ) ); + memset( cb, 0, sizeof( slap_callback ) ); + cb->sc_cleanup = retcode_cleanup_cb; + op->o_callback = cb; + break; + + default: + send_ldap_result( op, rs ); + if ( rs->sr_ref != NULL ) { + ber_bvarray_free( rs->sr_ref ); + } + rs->sr_matched = NULL; + rs->sr_text = NULL; + break; + } + + return rs->sr_err; +} + +static int +retcode_op2str( ber_tag_t op, struct berval *bv ) +{ + switch ( op ) { + case LDAP_REQ_BIND: + BER_BVSTR( bv, "bind" ); + return 0; + case LDAP_REQ_ADD: + BER_BVSTR( bv, "add" ); + return 0; + case LDAP_REQ_DELETE: + BER_BVSTR( bv, "delete" ); + return 0; + case LDAP_REQ_MODRDN: + BER_BVSTR( bv, "modrdn" ); + return 0; + case LDAP_REQ_MODIFY: + BER_BVSTR( bv, "modify" ); + return 0; + case LDAP_REQ_COMPARE: + BER_BVSTR( bv, "compare" ); + return 0; + case LDAP_REQ_SEARCH: + BER_BVSTR( bv, "search" ); + return 0; + case LDAP_REQ_EXTENDED: + BER_BVSTR( bv, "extended" ); + return 0; + } + return -1; +} + +static int +retcode_entry_response( Operation *op, SlapReply *rs, Entry *e ) +{ + slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; + + Attribute *a; + int err; + char *next; + + if ( get_manageDSAit( op ) ) { + return SLAP_CB_CONTINUE; + } + + if ( !is_entry_objectclass( e, oc_errObject, 0 ) ) { + return SLAP_CB_CONTINUE; + } + + /* operation */ + a = attr_find( e->e_attrs, ad_errOp ); + if ( a != NULL ) { + int i, + gotit = 0; + struct berval bv = BER_BVNULL; + + (void)retcode_op2str( op->o_tag, &bv ); + + if ( BER_BVISNULL( &bv ) ) { + return SLAP_CB_CONTINUE; + } + + for ( i = 0; !BER_BVISNULL( &a->a_nvals[ i ] ); i++ ) { + if ( bvmatch( &a->a_nvals[ i ], &bv ) ) { + gotit = 1; + break; + } + } + + if ( !gotit ) { + return SLAP_CB_CONTINUE; + } + } + + /* error code */ + a = attr_find( e->e_attrs, ad_errCode ); + if ( a == NULL ) { + return SLAP_CB_CONTINUE; + } + err = strtol( a->a_nvals[ 0 ].bv_val, &next, 0 ); + if ( next == a->a_nvals[ 0 ].bv_val || next[ 0 ] != '\0' ) { + return SLAP_CB_CONTINUE; + } + rs->sr_err = err; + + /* sleep time */ + a = attr_find( e->e_attrs, ad_errSleepTime ); + if ( a != NULL ) { + int sleepTime; + + sleepTime = strtoul( a->a_nvals[ 0 ].bv_val, &next, 0 ); + if ( next != a->a_nvals[ 0 ].bv_val && next[ 0 ] == '\0' ) { + sleep( sleepTime ); + } + } + + if ( rs->sr_err != LDAP_SUCCESS ) { + BackendDB db = *op->o_bd; + void *o_callback = op->o_callback; + + /* message text */ + a = attr_find( e->e_attrs, ad_errText ); + if ( a != NULL ) { + rs->sr_text = a->a_vals[ 0 ].bv_val; + } + + db.bd_info = on->on_info->oi_orig; + op->o_bd = &db; + op->o_callback = NULL; + + /* referral */ + if ( rs->sr_err == LDAP_REFERRAL ) { + BerVarray refs = default_referral; + + a = attr_find( e->e_attrs, slap_schema.si_ad_ref ); + if ( a != NULL ) { + refs = a->a_vals; + } + rs->sr_ref = referral_rewrite( refs, + NULL, &op->o_req_dn, op->oq_search.rs_scope ); + + send_search_reference( op, rs ); + ber_bvarray_free( rs->sr_ref ); + rs->sr_ref = NULL; + + } else { + send_ldap_result( op, rs ); + } + + rs->sr_text = NULL; + op->o_callback = o_callback; + } + + if ( rs->sr_err != LDAP_SUCCESS ) { + op->o_abandon = 1; + return rs->sr_err; + } + + return SLAP_CB_CONTINUE; +} + +static int +retcode_response( Operation *op, SlapReply *rs ) +{ + slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; + retcode_t *rd = (retcode_t *)on->on_bi.bi_private; + + if ( rs->sr_type != REP_SEARCH || !RETCODE_INDIR( rd ) ) { + return SLAP_CB_CONTINUE; + } + + return retcode_entry_response( op, rs, rs->sr_entry ); +} + +static int +retcode_db_init( BackendDB *be ) +{ + slap_overinst *on = (slap_overinst *)be->bd_info; + retcode_t *rd; + + rd = (retcode_t *)ch_malloc( sizeof( retcode_t ) ); + memset( rd, 0, sizeof( retcode_t ) ); + + on->on_bi.bi_private = (void *)rd; + + return 0; +} + +static int +retcode_db_config( + BackendDB *be, + const char *fname, + int lineno, + int argc, + char **argv ) +{ + slap_overinst *on = (slap_overinst *)be->bd_info; + retcode_t *rd = (retcode_t *)on->on_bi.bi_private; + + char *argv0 = argv[ 0 ] + STRLENOF( "retcode-" ); + + if ( strncasecmp( argv[ 0 ], "retcode-", STRLENOF( "retcode-" ) ) != 0 ) { + return SLAP_CONF_UNKNOWN; + } + + if ( strcasecmp( argv0, "parent" ) == 0 ) { + struct berval dn; + int rc; + + if ( argc != 2 ) { + fprintf( stderr, "%s: line %d: retcode: " + "\"retcode-parent \": missing \n", + fname, lineno ); + return 1; + } + + if ( !BER_BVISNULL( &rd->rd_pdn ) ) { + fprintf( stderr, "%s: line %d: retcode: " + "parent already defined.\n", fname, lineno ); + return 1; + } + + ber_str2bv( argv[ 1 ], 0, 0, &dn ); + + rc = dnPrettyNormal( NULL, &dn, &rd->rd_pdn, &rd->rd_npdn, NULL ); + if ( rc != LDAP_SUCCESS ) { + fprintf( stderr, "%s: line %d: retcode: " + "unable to normalize parent DN \"%s\": %d\n", + fname, lineno, argv[ 1 ], rc ); + return 1; + } + + } else if ( strcasecmp( argv0, "item" ) == 0 ) { + retcode_item_t rdi = { BER_BVNULL }, **rdip; + struct berval bv, rdn, nrdn; + int rc; + char *next = NULL; + + if ( argc < 3 ) { + fprintf( stderr, "%s: line %d: retcode: " + "\"retcode-item []\": " + "missing args\n", + fname, lineno ); + return 1; + } + + ber_str2bv( argv[ 1 ], 0, 0, &bv ); + + rc = dnPrettyNormal( NULL, &bv, &rdn, &nrdn, NULL ); + if ( rc != LDAP_SUCCESS ) { + fprintf( stderr, "%s: line %d: retcode: " + "unable to normalize RDN \"%s\": %d\n", + fname, lineno, argv[ 1 ], rc ); + return 1; + } + + if ( !dnIsOneLevelRDN( &nrdn ) ) { + fprintf( stderr, "%s: line %d: retcode: " + "value \"%s\" is not a RDN\n", + fname, lineno, argv[ 1 ] ); + return 1; + } + + if ( BER_BVISNULL( &rd->rd_npdn ) ) { + /* FIXME: we use the database suffix */ + if ( be->be_nsuffix == NULL ) { + fprintf( stderr, "%s: line %d: retcode: " + "either \"retcode-parent\" " + "or \"suffix\" must be defined.\n", + fname, lineno ); + return 1; + } + + ber_dupbv( &rd->rd_pdn, &be->be_suffix[ 0 ] ); + ber_dupbv( &rd->rd_npdn, &be->be_nsuffix[ 0 ] ); + } + + build_new_dn( &rdi.rdi_dn, &rd->rd_pdn, &rdn, NULL ); + build_new_dn( &rdi.rdi_ndn, &rd->rd_npdn, &nrdn, NULL ); + + ch_free( rdn.bv_val ); + ch_free( nrdn.bv_val ); + + rdi.rdi_err = strtol( argv[ 2 ], &next, 0 ); + if ( next == argv[ 2 ] || next[ 0 ] != '\0' ) { + fprintf( stderr, "%s: line %d: retcode: " + "unable to parse return code \"%s\"\n", + fname, lineno, argv[ 2 ] ); + return 1; + } + + rdi.rdi_mask = SN_DG_OP_ALL; + + if ( argc > 3 ) { + int i; + + for ( i = 3; i < argc; i++ ) { + if ( strncasecmp( argv[ i ], "op=", STRLENOF( "op=" ) ) == 0 ) + { + char **ops; + int j; + + ops = ldap_str2charray( &argv[ i ][ STRLENOF( "op=" ) ], "," ); + assert( ops != NULL ); + + rdi.rdi_mask = SN_DG_OP_NONE; + + for ( j = 0; ops[ j ] != NULL; j++ ) { + if ( strcasecmp( ops[ j ], "add" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_ADD; + + } else if ( strcasecmp( ops[ j ], "bind" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_BIND; + + } else if ( strcasecmp( ops[ j ], "compare" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_COMPARE; + + } else if ( strcasecmp( ops[ j ], "add" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_DELETE; + + } else if ( strcasecmp( ops[ j ], "modify" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_MODIFY; + + } else if ( strcasecmp( ops[ j ], "rename" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_RENAME; + + } else if ( strcasecmp( ops[ j ], "search" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_SEARCH; + + } else if ( strcasecmp( ops[ j ], "extended" ) == 0 ) { + rdi.rdi_mask |= SN_DG_EXTENDED; + + } else if ( strcasecmp( ops[ j ], "auth" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_AUTH; + + } else if ( strcasecmp( ops[ j ], "read" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_READ; + + } else if ( strcasecmp( ops[ j ], "write" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_WRITE; + + } else if ( strcasecmp( ops[ j ], "all" ) == 0 ) { + rdi.rdi_mask |= SN_DG_OP_ALL; + + } else { + fprintf( stderr, "retcode: unknown op \"%s\"\n", + ops[ j ] ); + return 1; + } + } + + ldap_charray_free( ops ); + + } else if ( strncasecmp( argv[ i ], "text=", STRLENOF( "text=" ) ) == 0 ) + { + if ( !BER_BVISNULL( &rdi.rdi_text ) ) { + fprintf( stderr, "%s: line %d: retcode: " + "\"text\" already provided.\n", + fname, lineno ); + return 1; + } + ber_str2bv( &argv[ i ][ STRLENOF( "text=" ) ], 0, 1, &rdi.rdi_text ); + + } else if ( strncasecmp( argv[ i ], "ref=", STRLENOF( "ref=" ) ) == 0 ) + { + char **refs; + int j; + + if ( rdi.rdi_ref != NULL ) { + fprintf( stderr, "%s: line %d: retcode: " + "\"ref\" already provided.\n", + fname, lineno ); + return 1; + } + + if ( rdi.rdi_err != LDAP_REFERRAL ) { + fprintf( stderr, "%s: line %d: retcode: " + "providing \"ref\"\n" + "\talong with a non-referral " + "resultCode may cause slapd failures\n" + "\trelated to internal checks.\n", + fname, lineno ); + } + + refs = ldap_str2charray( &argv[ i ][ STRLENOF( "ref=" ) ], " " ); + assert( refs != NULL ); + + for ( j = 0; refs[ j ] != NULL; j++ ) { + struct berval bv; + + ber_str2bv( refs[ j ], 0, 1, &bv ); + ber_bvarray_add( &rdi.rdi_ref, &bv ); + } + + ldap_charray_free( refs ); + + } else if ( strncasecmp( argv[ i ], "sleeptime=", STRLENOF( "sleeptime=" ) ) == 0 ) + { + char *next; + if ( rdi.rdi_sleeptime != 0 ) { + fprintf( stderr, "%s: line %d: retcode: " + "\"sleeptime\" already provided.\n", + fname, lineno ); + return 1; + } + + rdi.rdi_sleeptime = strtol( &argv[ i ][ STRLENOF( "sleeptime=" ) ], &next, 10 ); + if ( next == argv[ i ] || next[ 0 ] != '\0' ) { + fprintf( stderr, "%s: line %d: retcode: " + "unable to parse \"sleeptime=%s\".\n", + fname, lineno, &argv[ i ][ STRLENOF( "sleeptime=" ) ] ); + return 1; + } + + } else { + fprintf( stderr, "%s: line %d: retcode: " + "unknown option \"%s\".\n", + fname, lineno, argv[ i ] ); + return 1; + } + } + } + + for ( rdip = &rd->rd_item; *rdip; rdip = &(*rdip)->rdi_next ) + /* go to last */ ; + + + *rdip = ( retcode_item_t * )ch_malloc( sizeof( retcode_item_t ) ); + *(*rdip) = rdi; + + } else if ( strcasecmp( argv0, "indir" ) == 0 ) { + rd->rd_flags |= RETCODE_FINDIR; + + } else { + return SLAP_CONF_UNKNOWN; + } + + return 0; +} + +static int +retcode_db_open( BackendDB *be ) +{ + slap_overinst *on = (slap_overinst *)be->bd_info; + retcode_t *rd = (retcode_t *)on->on_bi.bi_private; + + retcode_item_t *rdi; + + for ( rdi = rd->rd_item; rdi; rdi = rdi->rdi_next ) { + LDAPRDN rdn = NULL; + int rc, j; + char* p; + struct berval val[ 3 ]; + char buf[ SLAP_TEXT_BUFLEN ]; + + /* DN */ + rdi->rdi_e.e_name = rdi->rdi_dn; + rdi->rdi_e.e_nname = rdi->rdi_ndn; + + /* objectClass */ + val[ 0 ] = oc_errObject->soc_cname; + val[ 1 ] = slap_schema.si_oc_extensibleObject->soc_cname; + BER_BVZERO( &val[ 2 ] ); + + attr_merge( &rdi->rdi_e, slap_schema.si_ad_objectClass, val, NULL ); + + /* RDN avas */ + rc = ldap_bv2rdn( &rdi->rdi_dn, &rdn, (char **) &p, + LDAP_DN_FORMAT_LDAP ); + + assert( rc == LDAP_SUCCESS ); + + for ( j = 0; rdn[ j ]; j++ ) { + LDAPAVA *ava = rdn[ j ]; + AttributeDescription *ad = NULL; + const char *text; + + rc = slap_bv2ad( &ava->la_attr, &ad, &text ); + assert( rc == LDAP_SUCCESS ); + + attr_merge_normalize_one( &rdi->rdi_e, ad, + &ava->la_value, NULL ); + } + + ldap_rdnfree( rdn ); + + /* error code */ + snprintf( buf, sizeof( buf ), "%d", rdi->rdi_err ); + ber_str2bv( buf, 0, 0, &val[ 0 ] ); + + attr_merge_one( &rdi->rdi_e, ad_errCode, &val[ 0 ], NULL ); + + if ( rdi->rdi_ref != NULL ) { + attr_merge_normalize( &rdi->rdi_e, slap_schema.si_ad_ref, + rdi->rdi_ref, NULL ); + } + + /* text */ + if ( !BER_BVISNULL( &rdi->rdi_text ) ) { + val[ 0 ] = rdi->rdi_text; + + attr_merge_normalize_one( &rdi->rdi_e, ad_errText, &val[ 0 ], NULL ); + } + + /* sleep time */ + if ( rdi->rdi_sleeptime > 0 ) { + snprintf( buf, sizeof( buf ), "%d", rdi->rdi_sleeptime ); + ber_str2bv( buf, 0, 0, &val[ 0 ] ); + + attr_merge_one( &rdi->rdi_e, ad_errSleepTime, &val[ 0 ], NULL ); + } + + /* operations */ + if ( rdi->rdi_mask & SN_DG_OP_ADD ) { + BER_BVSTR( &val[ 0 ], "add" ); + attr_merge_normalize_one( &rdi->rdi_e, ad_errOp, &val[ 0 ], NULL ); + } + + if ( rdi->rdi_mask & SN_DG_OP_BIND ) { + BER_BVSTR( &val[ 0 ], "bind" ); + attr_merge_normalize_one( &rdi->rdi_e, ad_errOp, &val[ 0 ], NULL ); + } + + if ( rdi->rdi_mask & SN_DG_OP_COMPARE ) { + BER_BVSTR( &val[ 0 ], "compare" ); + attr_merge_normalize_one( &rdi->rdi_e, ad_errOp, &val[ 0 ], NULL ); + } + + if ( rdi->rdi_mask & SN_DG_OP_DELETE ) { + BER_BVSTR( &val[ 0 ], "delete" ); + attr_merge_normalize_one( &rdi->rdi_e, ad_errOp, &val[ 0 ], NULL ); + } + + if ( rdi->rdi_mask & SN_DG_EXTENDED ) { + BER_BVSTR( &val[ 0 ], "extended" ); + attr_merge_normalize_one( &rdi->rdi_e, ad_errOp, &val[ 0 ], NULL ); + } + + if ( rdi->rdi_mask & SN_DG_OP_MODIFY ) { + BER_BVSTR( &val[ 0 ], "modify" ); + attr_merge_normalize_one( &rdi->rdi_e, ad_errOp, &val[ 0 ], NULL ); + } + + if ( rdi->rdi_mask & SN_DG_OP_RENAME ) { + BER_BVSTR( &val[ 0 ], "rename" ); + attr_merge_normalize_one( &rdi->rdi_e, ad_errOp, &val[ 0 ], NULL ); + } + + if ( rdi->rdi_mask & SN_DG_OP_SEARCH ) { + BER_BVSTR( &val[ 0 ], "search" ); + attr_merge_normalize_one( &rdi->rdi_e, ad_errOp, &val[ 0 ], NULL ); + } + } + + return 0; +} + +static int +retcode_db_destroy( BackendDB *be ) +{ + slap_overinst *on = (slap_overinst *)be->bd_info; + retcode_t *rd = (retcode_t *)on->on_bi.bi_private; + + if ( rd ) { + retcode_item_t *rdi, *next; + + for ( rdi = rd->rd_item; rdi != NULL; rdi = next ) { + ber_memfree( rdi->rdi_dn.bv_val ); + ber_memfree( rdi->rdi_ndn.bv_val ); + + if ( !BER_BVISNULL( &rdi->rdi_text ) ) { + ber_memfree( rdi->rdi_text.bv_val ); + } + + BER_BVZERO( &rdi->rdi_e.e_name ); + BER_BVZERO( &rdi->rdi_e.e_nname ); + + entry_clean( &rdi->rdi_e ); + + next = rdi->rdi_next; + + ch_free( rdi ); + } + + ber_memfree( rd ); + } + + return 0; +} + +#if SLAPD_OVER_RETCODE == SLAPD_MOD_DYNAMIC +static +#endif /* SLAPD_OVER_RETCODE == SLAPD_MOD_DYNAMIC */ +int +retcode_init( void ) +{ + int i, code; + const char *err; + + static struct { + char *name; + char *desc; + AttributeDescription **ad; + } retcode_at[] = { + { "errCode", "( 1.3.6.1.4.1.4203.666.11.4.1.1 " + "NAME ( 'errCode' ) " + "DESC 'LDAP error code' " + "EQUALITY integerMatch " + "ORDERING integerOrderingMatch " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 " + "SINGLE-VALUE )", + &ad_errCode }, + { "errOp", "( 1.3.6.1.4.1.4203.666.11.4.1.2 " + "NAME ( 'errOp' ) " + "DESC 'Operations the errObject applies to' " + "EQUALITY caseIgnoreMatch " + "SUBSTR caseIgnoreSubstringsMatch " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )", + &ad_errOp}, + { "errText", "( 1.3.6.1.4.1.4203.666.11.4.1.3 " + "NAME ( 'errText' ) " + "DESC 'LDAP error textual description' " + "EQUALITY caseIgnoreMatch " + "SUBSTR caseIgnoreSubstringsMatch " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " + "SINGLE-VALUE )", + &ad_errText }, + { "errSleepTime", "( 1.3.6.1.4.1.4203.666.11.4.1.4 " + "NAME ( 'errSleepTime' ) " + "DESC 'Time to wait before returning the error' " + "EQUALITY integerMatch " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 " + "SINGLE-VALUE )", + &ad_errSleepTime }, + { NULL } + }; + + static struct { + char *name; + char *desc; + ObjectClass **oc; + } retcode_oc[] = { + { "errObject", "( 1.3.6.1.4.1.4203.666.11.4.3.1 " + "NAME ( 'errObject' ) " + "SUP top STRUCTURAL " + "MUST ( errCode ) " + "MAY ( " + "cn " + "$ description " + "$ errOp " + "$ errText " + "$ errSleepTime " + ") )", + &oc_errObject }, + { NULL } + }; + + + for ( i = 0; retcode_at[ i ].name != NULL; i++ ) { + LDAPAttributeType *at; + + at = ldap_str2attributetype( retcode_at[ i ].desc, + &code, &err, LDAP_SCHEMA_ALLOW_ALL ); + if ( !at ) { + fprintf( stderr, "retcode: " + "AttributeType load failed: %s %s\n", + ldap_scherr2str( code ), err ); + return code; + } + +#if LDAP_VENDOR_VERSION_MINOR == X || LDAP_VENDOR_VERSION_MINOR > 2 + code = at_add( at, 0, NULL, &err ); +#else + code = at_add( at, &err ); +#endif + ldap_memfree( at ); + if ( code != LDAP_SUCCESS ) { + fprintf( stderr, "retcode: " + "AttributeType load failed: %s %s\n", + scherr2str( code ), err ); + return code; + } + + code = slap_str2ad( retcode_at[ i ].name, + retcode_at[ i ].ad, &err ); + if ( code != LDAP_SUCCESS ) { + fprintf( stderr, "retcode: unable to find " + "AttributeDescription \"%s\": %d (%s)\n", + retcode_at[ i ].name, code, err ); + return 1; + } + } + + for ( i = 0; retcode_oc[ i ].name != NULL; i++ ) { + LDAPObjectClass *oc; + + oc = ldap_str2objectclass( retcode_oc[ i ].desc, + &code, &err, LDAP_SCHEMA_ALLOW_ALL ); + if ( !oc ) { + fprintf( stderr, "retcode: " + "ObjectClass load failed: %s %s\n", + ldap_scherr2str( code ), err ); + return code; + } + +#if LDAP_VENDOR_VERSION_MINOR == X || LDAP_VENDOR_VERSION_MINOR > 2 + code = oc_add( oc, 0, NULL, &err ); +#else + code = oc_add( oc, &err ); +#endif + ldap_memfree(oc); + if ( code != LDAP_SUCCESS ) { + fprintf( stderr, "retcode: " + "ObjectClass load failed: %s %s\n", + scherr2str( code ), err ); + return code; + } + + *retcode_oc[ i ].oc = oc_find( retcode_oc[ i ].name ); + if ( *retcode_oc[ i ].oc == NULL ) { + fprintf( stderr, "retcode: unable to find " + "objectClass \"%s\"\n", + retcode_oc[ i ].name ); + return 1; + } + } + + retcode.on_bi.bi_type = "retcode"; + + retcode.on_bi.bi_db_init = retcode_db_init; + retcode.on_bi.bi_db_config = retcode_db_config; + retcode.on_bi.bi_db_open = retcode_db_open; + retcode.on_bi.bi_db_destroy = retcode_db_destroy; + + retcode.on_bi.bi_op_add = retcode_op_func; + retcode.on_bi.bi_op_bind = retcode_op_func; + retcode.on_bi.bi_op_compare = retcode_op_func; + retcode.on_bi.bi_op_delete = retcode_op_func; + retcode.on_bi.bi_op_modify = retcode_op_func; + retcode.on_bi.bi_op_modrdn = retcode_op_func; + retcode.on_bi.bi_op_search = retcode_op_func; + + retcode.on_bi.bi_extended = retcode_op_func; + + retcode.on_response = retcode_response; + + return overlay_register( &retcode ); +} + +#if SLAPD_OVER_RETCODE == SLAPD_MOD_DYNAMIC +int +init_module( int argc, char *argv[] ) +{ + return retcode_init(); +} +#endif /* SLAPD_OVER_RETCODE == SLAPD_MOD_DYNAMIC */ + +#endif /* SLAPD_OVER_RETCODE */ diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index e485b06348..ebe9815438 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -111,11 +111,8 @@ rwm_op_add( Operation *op, SlapReply *rs ) } if ( olddn != op->o_req_dn.bv_val ) { - ch_free( op->ora_e->e_name.bv_val ); - ch_free( op->ora_e->e_nname.bv_val ); - - ber_dupbv( &op->ora_e->e_name, &op->o_req_dn ); - ber_dupbv( &op->ora_e->e_nname, &op->o_req_ndn ); + ber_bvreplace( &op->ora_e->e_name, &op->o_req_dn ); + ber_bvreplace( &op->ora_e->e_nname, &op->o_req_ndn ); } /* Count number of attributes in entry */ @@ -207,7 +204,7 @@ rwm_op_add( Operation *op, SlapReply *rs ) } if ( mapping != NULL ) { - assert( mapping->m_dst_ad ); + assert( mapping->m_dst_ad != NULL ); (*ap)->a_desc = mapping->m_dst_ad; } } @@ -258,8 +255,6 @@ static int rwm_op_bind( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; - struct ldaprwmap *rwmap = - (struct ldaprwmap *)on->on_bi.bi_private; int rc; #ifdef ENABLE_REWRITE @@ -327,8 +322,7 @@ rwm_op_compare( Operation *op, SlapReply *rs ) return -1; } else if ( mapped_vals[0].bv_val != op->orc_ava->aa_value.bv_val ) { - free( op->orc_ava->aa_value.bv_val ); - op->orc_ava->aa_value = mapped_vals[0]; + ber_bvreplace_x( &op->orc_ava->aa_value, &mapped_vals[0], op->o_tmpmemctx ); } mapped_at = op->orc_ava->aa_desc->ad_cname; @@ -346,7 +340,7 @@ rwm_op_compare( Operation *op, SlapReply *rs ) } } else { - assert( mapping->m_dst_ad ); + assert( mapping->m_dst_ad != NULL ); ad = mapping->m_dst_ad; } @@ -373,7 +367,14 @@ rwm_op_compare( Operation *op, SlapReply *rs ) return -1; } - op->orc_ava->aa_value = mapped_vals[0]; + if ( mapped_vals[ 0 ].bv_val != op->orc_ava->aa_value.bv_val ) { + /* NOTE: if we get here, rwm_dnattr_rewrite() + * already freed the old value, so now + * it's invalid */ + ber_dupbv_x( &op->orc_ava->aa_value, &mapped_vals[0], + op->o_tmpmemctx ); + ber_memfree_x( mapped_vals[ 0 ].bv_val, NULL ); + } } op->orc_ava->aa_desc = ad; } @@ -526,7 +527,7 @@ rwm_op_modify( Operation *op, SlapReply *rs ) next_mod:; if ( mapping != NULL ) { /* use new attribute description */ - assert( mapping->m_dst_ad ); + assert( mapping->m_dst_ad != NULL ); (*mlp)->sml_desc = mapping->m_dst_ad; } @@ -934,8 +935,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN ) * the value is replaced by * ch_alloc'ed memory */ - ch_free( bv[0].bv_val ); - ber_dupbv( &bv[0], &mapped ); + ber_bvreplace( &bv[0], &mapped ); } } @@ -974,7 +974,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN ) if ( mapping != NULL ) { /* rewrite the attribute description */ - assert( mapping->m_dst_ad ); + assert( mapping->m_dst_ad != NULL ); (*ap)->a_desc = mapping->m_dst_ad; } @@ -1000,13 +1000,13 @@ rwm_send_entry( Operation *op, SlapReply *rs ) (struct ldaprwmap *)on->on_bi.bi_private; Entry *e = NULL; - int flags; + slap_mask_t flags; struct berval dn = BER_BVNULL, ndn = BER_BVNULL; dncookie dc; int rc; - assert( rs->sr_entry ); + assert( rs->sr_entry != NULL ); /* * Rewrite the dn of the result, if needed @@ -1421,9 +1421,11 @@ rwm_db_init( slap_overinst *on = (slap_overinst *) be->bd_info; struct ldapmapping *mapping = NULL; struct ldaprwmap *rwmap; +#ifdef ENABLE_REWRITE + char *rargv[ 3 ]; +#endif /* ENABLE_REWRITE */ - rwmap = (struct ldaprwmap *)ch_malloc(sizeof(struct ldaprwmap)); - memset(rwmap, 0, sizeof(struct ldaprwmap)); + rwmap = (struct ldaprwmap *)ch_calloc( 1, sizeof( struct ldaprwmap ) ); #ifdef ENABLE_REWRITE rwmap->rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT ); @@ -1432,22 +1434,17 @@ rwm_db_init( return -1; } - { - char *rargv[3]; - - /* this rewriteContext by default must be null; - * rules can be added if required */ - rargv[ 0 ] = "rewriteContext"; - rargv[ 1 ] = "searchFilter"; - rargv[ 2 ] = NULL; - rewrite_parse( rwmap->rwm_rw, "", 1, 2, rargv ); - - rargv[ 0 ] = "rewriteContext"; - rargv[ 1 ] = "default"; - rargv[ 2 ] = NULL; - rewrite_parse( rwmap->rwm_rw, "", 2, 2, rargv ); - } - + /* this rewriteContext by default must be null; + * rules can be added if required */ + rargv[ 0 ] = "rewriteContext"; + rargv[ 1 ] = "searchFilter"; + rargv[ 2 ] = NULL; + rewrite_parse( rwmap->rwm_rw, "", 1, 2, rargv ); + + rargv[ 0 ] = "rewriteContext"; + rargv[ 1 ] = "default"; + rargv[ 2 ] = NULL; + rewrite_parse( rwmap->rwm_rw, "", 2, 2, rargv ); #endif /* ENABLE_REWRITE */ if ( rwm_map_init( &rwmap->rwm_oc, &mapping ) != LDAP_SUCCESS || @@ -1487,6 +1484,8 @@ rwm_db_destroy( avl_free( rwmap->rwm_oc.map, rwm_mapping_free ); avl_free( rwmap->rwm_at.remap, NULL ); avl_free( rwmap->rwm_at.map, rwm_mapping_free ); + + ch_free( rwmap ); } return rc; diff --git a/servers/slapd/overlays/rwmdn.c b/servers/slapd/overlays/rwmdn.c index 8b26b9818a..5cdf0522ee 100644 --- a/servers/slapd/overlays/rwmdn.c +++ b/servers/slapd/overlays/rwmdn.c @@ -159,9 +159,9 @@ rwm_dn_massage( struct berval mdn; static char *dmy = ""; - assert( dc ); - assert( in ); - assert( dn ); + assert( dc != NULL ); + assert( in != NULL ); + assert( dn != NULL ); rc = rewrite_session( dc->rwmap->rwm_rw, dc->ctx, ( in->bv_val ? in->bv_val : dmy ), @@ -221,9 +221,9 @@ rwm_dn_massage( int i, src, dst; struct berval tmpin; - assert( dc ); - assert( in ); - assert( dn ); + assert( dc != NULL ); + assert( in != NULL ); + assert( dn != NULL ); BER_BVZERO( dn ); diff --git a/servers/slapd/overlays/rwmmap.c b/servers/slapd/overlays/rwmmap.c index c201744ae0..4c573f3b42 100644 --- a/servers/slapd/overlays/rwmmap.c +++ b/servers/slapd/overlays/rwmmap.c @@ -71,7 +71,7 @@ rwm_map_init( struct ldapmap *lm, struct ldapmapping **m ) const char *text; int rc; - assert( m ); + assert( m != NULL ); *m = NULL; @@ -82,19 +82,21 @@ rwm_map_init( struct ldapmap *lm, struct ldapmapping **m ) } /* FIXME: I don't think this is needed any more... */ - rc = slap_str2ad( "objectClass", &mapping->m_src_ad, &text ); + rc = slap_str2ad( "objectClass", &mapping[0].m_src_ad, &text ); if ( rc != LDAP_SUCCESS ) { return rc; } - mapping->m_dst_ad = mapping->m_src_ad; - ber_dupbv( &mapping->m_dst, &mapping->m_src_ad->ad_cname ); - ber_dupbv( &mapping->m_dst, &mapping->m_src ); + mapping[0].m_dst_ad = mapping[0].m_src_ad; + ber_dupbv( &mapping[0].m_src, &mapping[0].m_src_ad->ad_cname ); + ber_dupbv( &mapping[0].m_dst, &mapping[0].m_src ); - mapping[1].m_src = mapping->m_src; - mapping[1].m_dst = mapping->m_dst; + mapping[1].m_src = mapping[0].m_src; + mapping[1].m_dst = mapping[0].m_dst; + mapping[1].m_src_ad = mapping[0].m_src_ad; + mapping[1].m_dst_ad = mapping[1].m_src_ad; - avl_insert( &lm->map, (caddr_t)mapping, + avl_insert( &lm->map, (caddr_t)&mapping[0], rwm_mapping_cmp, rwm_mapping_dup ); avl_insert( &lm->remap, (caddr_t)&mapping[1], rwm_mapping_cmp, rwm_mapping_dup ); @@ -110,7 +112,7 @@ rwm_mapping( struct ldapmap *map, struct berval *s, struct ldapmapping **m, int Avlnode *tree; struct ldapmapping fmapping; - assert( m ); + assert( m != NULL ); if ( remap == RWM_REMAP ) { tree = map->remap; @@ -163,7 +165,7 @@ rwm_map_attrnames( { int i, j; - assert( anp ); + assert( anp != NULL ); *anp = NULL; @@ -456,7 +458,10 @@ rwm_int_filter_map_rewrite( /* better than nothing... */ ber_bvtrue = BER_BVC( "(objectClass=*)" ), ber_bvtf_true = BER_BVC( "(&)" ), +#if 0 + /* no longer needed; preserved for completeness */ ber_bvundefined = BER_BVC( "(?=undefined)" ), +#endif ber_bverror = BER_BVC( "(?=error)" ), ber_bvunknown = BER_BVC( "(?=unknown)" ), ber_bvnone = BER_BVC( "(?=none)" ); @@ -791,7 +796,7 @@ rwm_referral_rewrite( struct berval dn = BER_BVNULL, ndn = BER_BVNULL; - assert( a_vals ); + assert( a_vals != NULL ); /* * Rewrite the dn if needed diff --git a/servers/slapd/overlays/seqmod.c b/servers/slapd/overlays/seqmod.c index be2efda0f1..18f5ded5d7 100644 --- a/servers/slapd/overlays/seqmod.c +++ b/servers/slapd/overlays/seqmod.c @@ -61,7 +61,7 @@ seqmod_op_cleanup( Operation *op, SlapReply *rs ) /* This op is done, remove it */ ldap_pvt_thread_mutex_lock( &sm->sm_mutex ); av = avl_find2( sm->sm_mods, &mtdummy, sm_avl_cmp ); - assert(av); + assert(av != NULL); mt = av->avl_data; diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index a8c6398243..bc8d940615 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -159,8 +159,6 @@ syncprov_state_ctrl( { Attribute* a; int ret; - int res; - const char *text = NULL; BerElementBuffer berbuf; BerElement *ber = (BerElement *)&berbuf; @@ -402,7 +400,6 @@ syncprov_findbase( Operation *op, fbase_cookie *fc ) { opcookie *opc = op->o_callback->sc_private; slap_overinst *on = opc->son; - syncprov_info_t *si = on->on_bi.bi_private; slap_callback cb = {0}; Operation fop; @@ -746,7 +743,6 @@ static int syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, Entry **e, int mode, int queue ) { slap_overinst *on = opc->son; - syncprov_info_t *si = on->on_bi.bi_private; SlapReply rs = { REP_SEARCH }; LDAPControl *ctrls[2]; @@ -1184,10 +1180,10 @@ syncprov_add_slog( Operation *op, struct berval *csn ) se->se_tag = op->o_tag; se->se_uuid.bv_val = (char *)(se+1); - se->se_csn.bv_val = se->se_uuid.bv_val + opc->suuid.bv_len + 1; AC_MEMCPY( se->se_uuid.bv_val, opc->suuid.bv_val, opc->suuid.bv_len ); se->se_uuid.bv_len = opc->suuid.bv_len; + se->se_csn.bv_val = se->se_uuid.bv_val + opc->suuid.bv_len; AC_MEMCPY( se->se_csn.bv_val, csn->bv_val, csn->bv_len ); se->se_csn.bv_val[csn->bv_len] = '\0'; se->se_csn.bv_len = csn->bv_len; @@ -1231,7 +1227,6 @@ syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl, struct berval *oldcsn, struct berval *ctxcsn ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; - syncprov_info_t *si = on->on_bi.bi_private; slog_entry *se; int i, j, ndel, num, nmods, mmods; BerVarray uuids; @@ -1692,18 +1687,16 @@ syncprov_search_response( Operation *op, SlapReply *rs ) { searchstate *ss = op->o_callback->sc_private; slap_overinst *on = ss->ss_on; - syncprov_info_t *si = on->on_bi.bi_private; sync_control *srs = op->o_controls[slap_cids.sc_LDAPsync]; if ( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF ) { - int i; /* If we got a referral without a referral object, there's * something missing that we cannot replicate. Just ignore it. * The consumer will abort because we didn't send the expected * control. */ if ( !rs->sr_entry ) { - assert( rs->sr_entry ); + assert( rs->sr_entry != NULL ); Debug( LDAP_DEBUG_ANY, "bogus referral in context\n",0,0,0 ); return SLAP_CB_CONTINUE; } @@ -2293,7 +2286,8 @@ static int syncprov_parseCtrl ( LDAPControl *ctrl ) { ber_tag_t tag; - BerElement *ber; + BerElementBuffer berbuf; + BerElement *ber = (BerElement *)&berbuf; ber_int_t mode; ber_len_t len; struct berval cookie = BER_BVNULL; @@ -2327,11 +2321,7 @@ static int syncprov_parseCtrl ( * } */ - ber = ber_init( &ctrl->ldctl_value ); - if( ber == NULL ) { - rs->sr_text = "internal error"; - return LDAP_OTHER; - } + ber_init2( ber, &ctrl->ldctl_value, 0 ); if ( (tag = ber_scanf( ber, "{i" /*}*/, &mode )) == LBER_ERROR ) { rs->sr_text = "Sync control : mode decoding error"; @@ -2353,7 +2343,7 @@ static int syncprov_parseCtrl ( tag = ber_peek_tag( ber, &len ); if ( tag == LDAP_TAG_SYNC_COOKIE ) { - if (( ber_scanf( ber, /*{*/ "o", &cookie )) == LBER_ERROR ) { + if (( ber_scanf( ber, /*{*/ "m", &cookie )) == LBER_ERROR ) { rs->sr_text = "Sync control : cookie decoding error"; return LDAP_PROTOCOL_ERROR; } @@ -2371,14 +2361,16 @@ static int syncprov_parseCtrl ( sr = op->o_tmpcalloc( 1, sizeof(struct sync_control), op->o_tmpmemctx ); sr->sr_rhint = rhint; if (!BER_BVISNULL(&cookie)) { - ber_dupbv( &sr->sr_state.octet_str, &cookie ); - slap_parse_sync_cookie( &sr->sr_state ); + ber_dupbv_x( &sr->sr_state.octet_str, &cookie, op->o_tmpmemctx ); + slap_parse_sync_cookie( &sr->sr_state, op->o_tmpmemctx ); + if ( sr->sr_state.rid == -1 ) { + rs->sr_text = "Sync control : cookie parsing error"; + return LDAP_PROTOCOL_ERROR; + } } op->o_controls[slap_cids.sc_LDAPsync] = sr; - (void) ber_free( ber, 1 ); - op->o_sync = ctrl->ldctl_iscritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL; diff --git a/servers/slapd/overlays/translucent.c b/servers/slapd/overlays/translucent.c index ba948e6193..85724d5f50 100644 --- a/servers/slapd/overlays/translucent.c +++ b/servers/slapd/overlays/translucent.c @@ -221,7 +221,6 @@ static int translucent_modify(Operation *op, SlapReply *rs) { slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; overlay_stack *ov = on->on_bi.bi_private; - translucent_configuration *cf = ov->config; void *private = op->o_bd->be_private; Entry ne, *e, *re = NULL; Attribute *a, *ax; @@ -291,7 +290,7 @@ static int translucent_modify(Operation *op, SlapReply *rs) { mm = m; m = m->sml_next; mm->sml_next = NULL; /* hack */ - slap_mods_free(mm); + slap_mods_free(mm, 1); if(m) continue; } m->sml_op = LDAP_MOD_ADD; @@ -393,11 +392,9 @@ static int translucent_compare(Operation *op, SlapReply *rs) { slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; overlay_stack *ov = on->on_bi.bi_private; void *private = op->o_bd->be_private; - translucent_configuration *cf = ov->config; AttributeAssertion *ava = op->orc_ava; - Attribute *a, *an, *ra, *as = NULL; - Entry *e, *ee, *re; + Entry *e; int rc; Debug(LDAP_DEBUG_TRACE, "==> translucent_compare: <%s> %s:%s\n", @@ -440,9 +437,8 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) { slap_overinst *on; Entry *e, *re = NULL; Attribute *a, *ax, *an, *as = NULL; - BerVarray b, bx; void *private; - int i, rc, size; + int rc; if(!op || !rs || rs->sr_type != REP_SEARCH || !rs->sr_entry) return(SLAP_CB_CONTINUE); @@ -525,7 +521,6 @@ static int translucent_search(Operation *op, SlapReply *rs) { slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; slap_callback cb = { NULL, NULL, NULL, NULL }; overlay_stack *ov = on->on_bi.bi_private; - translucent_configuration *cf = ov->config; void *private = op->o_bd->be_private; int rc; @@ -708,7 +703,6 @@ static int translucent_open(BackendDB *be) { static int translucent_close(BackendDB *be) { slap_overinst *on = (slap_overinst *) be->bd_info; overlay_stack *ov = on->on_bi.bi_private; - translucent_configuration *cf = ov->config; void *private = be->be_private; int rc; diff --git a/servers/slapd/overlays/unique.c b/servers/slapd/overlays/unique.c index 79e7db9403..3ea3741a99 100644 --- a/servers/slapd/overlays/unique.c +++ b/servers/slapd/overlays/unique.c @@ -506,7 +506,7 @@ static int unique_modrdn( Operation nop = *op; char *key, *kp; - int i, rc, ks = 16; /* a handful of extra bytes */ + int i, ks = 16; /* a handful of extra bytes */ LDAPRDN newrdn; struct berval bv[2]; diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index db44ffe17a..738d9add84 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -243,7 +243,7 @@ int passwd_extop( op->o_tag = LDAP_REQ_EXTENDED; op->o_callback = sc; } - slap_mods_free( qpw->rs_mods ); + slap_mods_free( qpw->rs_mods, 1 ); if ( rsp ) { free( qpw->rs_new.bv_val ); } @@ -470,7 +470,7 @@ slap_passwd_hash_type( new->bv_len = 0; new->bv_val = NULL; - assert( hash ); + assert( hash != NULL ); lutil_passwd_hash( cred , hash, new, text ); } diff --git a/servers/slapd/phonetic.c b/servers/slapd/phonetic.c index ae35892417..4b52ad9378 100644 --- a/servers/slapd/phonetic.c +++ b/servers/slapd/phonetic.c @@ -43,6 +43,7 @@ ispunct((unsigned char) (x)) || \ isdigit((unsigned char) (x)) || (x) == '\0') +#if 0 static char * first_word( char *s ) { @@ -98,6 +99,7 @@ word_dup( char *w ) return( ret ); } +#endif /* 0 */ #ifndef MAXPHONEMELEN #define MAXPHONEMELEN 4 diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index b457ea2b04..5ad9092de7 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -157,7 +157,7 @@ LDAP_SLAPD_V( AttributeName * ) slap_anlist_all_attributes; * add.c */ LDAP_SLAPD_F (int) slap_mods2entry LDAP_P(( Modifications *mods, Entry **e, - int repl_user, int dup, const char **text, char *textbuf, size_t textlen )); + int initial, int dup, const char **text, char *textbuf, size_t textlen )); LDAP_SLAPD_F (int) slap_entry2mods LDAP_P(( Entry *e, Modifications **mods, const char **text, @@ -206,6 +206,10 @@ LDAP_SLAPD_F (void) at_unparse LDAP_P(( LDAP_SLAPD_F (void) attr_free LDAP_P(( Attribute *a )); LDAP_SLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a )); +#ifdef LDAP_COMP_MATCH +LDAP_SLAPD_F (void) comp_tree_free LDAP_P(( Attribute *a )); +#endif + #define attr_mergeit( e, d, v ) attr_merge( e, d, v, NULL /* FIXME */ ) #define attr_mergeit_one( e, d, v ) attr_merge_one( e, d, v, NULL /* FIXME */ ) @@ -260,7 +264,7 @@ LDAP_SLAPD_F (int) backend_startup_one LDAP_P((Backend *be)); LDAP_SLAPD_F (int) backend_sync LDAP_P((Backend *be)); LDAP_SLAPD_F (int) backend_shutdown LDAP_P((Backend *be)); LDAP_SLAPD_F (int) backend_destroy LDAP_P((void)); -LDAP_SLAPD_F (void) backend_destroy_one LDAP_P((BackendDB *bd)); +LDAP_SLAPD_F (void) backend_destroy_one LDAP_P((BackendDB *bd, int dynamic)); LDAP_SLAPD_F (BackendInfo *) backend_info LDAP_P(( const char *type )); LDAP_SLAPD_F (BackendDB *) backend_db_init LDAP_P(( const char *type )); @@ -338,17 +342,9 @@ LDAP_SLAPD_F (int) backend_operational LDAP_P(( LDAP_SLAPD_V(BackendInfo) slap_binfo[]; -/* - * backglue.c - */ - -LDAP_SLAPD_F (int) glue_back_initialize( BackendInfo *bi ); -LDAP_SLAPD_F (int) glue_sub_init( void ); - /* * backover.c */ - LDAP_SLAPD_F (int) overlay_register LDAP_P(( slap_overinst *on )); LDAP_SLAPD_F (int) overlay_config LDAP_P(( BackendDB *be, const char *ov )); LDAP_SLAPD_F (void) overlay_destroy_one LDAP_P(( @@ -361,6 +357,18 @@ LDAP_SLAPD_F (int) overlay_is_inst LDAP_P(( BackendDB *be, const char *name )); LDAP_SLAPD_F (int) overlay_register_control LDAP_P(( BackendDB *be, const char *oid )); +LDAP_SLAPD_F (int) overlay_op_walk LDAP_P(( + Operation *op, + SlapReply *rs, + slap_operation_t which, + slap_overinfo *oi, + slap_overinst *on )); + +/* + * bconfig.c + */ +LDAP_SLAPD_F (int) slap_loglevel_register LDAP_P (( slap_mask_t m, struct berval *s )); +LDAP_SLAPD_F (int) str2loglevel LDAP_P(( const char *s, int *l )); /* * ch_malloc.c @@ -381,17 +389,48 @@ LDAP_SLAPD_F (void) ch_free LDAP_P(( void * )); * component.c */ #ifdef LDAP_COMP_MATCH +struct comp_attribute_aliasing; + LDAP_SLAPD_F (int) test_comp_filter_entry LDAP_P(( Operation* op, Entry* e, MatchingRuleAssertion* mr)); +LDAP_SLAPD_F (int) dup_comp_filter LDAP_P(( + Operation* op, + struct berval *bv, + ComponentFilter *in_f, + ComponentFilter **out_f )); + +LDAP_SLAPD_F (int) get_aliased_filter_aa LDAP_P(( + Operation* op, + AttributeAssertion* a_assert, + struct comp_attribute_aliasing* aa, + const char** text )); + +LDAP_SLAPD_F (int) get_aliased_filter LDAP_P(( + Operation* op, + MatchingRuleAssertion* ma, + struct comp_attribute_aliasing* aa, + const char** text )); + LDAP_SLAPD_F (int) get_comp_filter LDAP_P(( Operation* op, BerValue* bv, ComponentFilter** filt, const char **text )); +LDAP_SLAPD_F (int) insert_component_reference LDAP_P(( + ComponentReference *cr, + ComponentReference** cr_list )); + +LDAP_SLAPD_F (int) is_component_reference LDAP_P(( + char *attr )); + +LDAP_SLAPD_F (int) extract_component_reference LDAP_P(( + char* attr, + ComponentReference** cr )); + LDAP_SLAPD_F (int) componentFilterMatch LDAP_P(( int *matchp, slap_mask_t flags, @@ -415,6 +454,10 @@ LDAP_SLAPD_F (int) allComponentsMatch LDAP_P(( MatchingRule *mr, struct berval *value, void *assertedValue )); + +LDAP_SLAPD_F (ComponentReference*) dup_comp_ref LDAP_P(( + Operation *op, + ComponentReference *cr )); LDAP_SLAPD_F (int) componentFilterValidate LDAP_P(( Syntax *syntax, @@ -424,6 +467,12 @@ LDAP_SLAPD_F (int) allComponentsValidate LDAP_P(( Syntax *syntax, struct berval* bv )); +LDAP_SLAPD_F (void) component_free LDAP_P(( + ComponentFilter *f )); + +LDAP_SLAPD_F (void) free_ComponentData LDAP_P(( + Attribute *a )); + LDAP_SLAPD_V (test_membership_func*) is_aliased_attribute; LDAP_SLAPD_V (free_component_func*) component_destructor; @@ -446,6 +495,11 @@ LDAP_SLAPD_V( struct slap_control_ids ) slap_cids; LDAP_SLAPD_F (void) slap_free_ctrls LDAP_P(( Operation *op, LDAPControl **ctrls )); +LDAP_SLAPD_F (int) slap_parse_ctrl LDAP_P(( + Operation *op, + SlapReply *rs, + LDAPControl *control, + const char **text )); LDAP_SLAPD_F (int) get_ctrls LDAP_P(( Operation *op, SlapReply *rs, @@ -481,6 +535,10 @@ LDAP_SLAPD_F (int) mask_to_verbs LDAP_P(( slap_verbmasks *v, slap_mask_t m, BerVarray *bva )); LDAP_SLAPD_F (int) enum_to_verb LDAP_P(( slap_verbmasks *v, slap_mask_t m, struct berval *bv )); +LDAP_SLAPD_F (int) slap_verbmasks_init LDAP_P(( slap_verbmasks **vp, slap_verbmasks *v )); +LDAP_SLAPD_F (int) slap_verbmasks_destroy LDAP_P(( slap_verbmasks *v )); +LDAP_SLAPD_F (int) slap_verbmasks_append LDAP_P(( slap_verbmasks **vp, + slap_mask_t m, struct berval *v, slap_mask_t *ignore )); LDAP_SLAPD_F (int) bindconf_parse LDAP_P(( const char *word, slap_bindconf *bc )); LDAP_SLAPD_F (int) bindconf_unparse LDAP_P(( @@ -832,7 +890,7 @@ LDAP_SLAPD_F (void) slap_compose_sync_cookie LDAP_P(( LDAP_SLAPD_F (void) slap_sync_cookie_free LDAP_P(( struct sync_cookie *, int free_cookie )); LDAP_SLAPD_F (int) slap_parse_sync_cookie LDAP_P(( - struct sync_cookie * )); + struct sync_cookie *, void *memctx )); LDAP_SLAPD_F (int) slap_init_sync_cookie_ctxcsn LDAP_P(( struct sync_cookie * )); LDAP_SLAPD_F (struct sync_cookie *) slap_dup_sync_cookie LDAP_P(( @@ -857,6 +915,7 @@ LDAP_SLAPD_F (void) limits_unparse_one LDAP_P(( struct slap_limits_set *limit, int which, struct berval *bv )); LDAP_SLAPD_F (void) limits_unparse LDAP_P(( struct slap_limits *limit, struct berval *bv )); +LDAP_SLAPD_F (void) limits_destroy LDAP_P(( struct slap_limits **lm )); /* * lock.c @@ -899,6 +958,13 @@ LDAP_SLAPD_F( int ) slap_mods_no_user_mod_check( const char **text, char *textbuf, size_t textlen ); +LDAP_SLAPD_F ( int ) slap_mods_no_repl_user_mod_check( + Operation *op, + Modifications *ml, + const char **text, + char *textbuf, + size_t textlen ); + LDAP_SLAPD_F( int ) slap_mods_check( Modifications *ml, const char **text, @@ -941,7 +1007,7 @@ LDAP_SLAPD_F( int ) modify_increment_values( Entry *e, const char **text, char *textbuf, size_t textlen ); LDAP_SLAPD_F( void ) slap_mod_free( Modification *mod, int freeit ); -LDAP_SLAPD_F( void ) slap_mods_free( Modifications *mods ); +LDAP_SLAPD_F( void ) slap_mods_free( Modifications *mods, int freevals ); LDAP_SLAPD_F( void ) slap_modlist_free( LDAPModList *ml ); /* @@ -1163,6 +1229,7 @@ LDAP_SLAPD_F (int) get_alias_dn LDAP_P(( */ LDAP_SLAPD_F (int) add_replica_info LDAP_P(( Backend *be, const char *uri, const char *host )); +LDAP_SLAPD_F (int) destroy_replica_info LDAP_P (( Backend *be )); LDAP_SLAPD_F (int) add_replica_suffix LDAP_P(( Backend *be, int nr, const char *suffix )); LDAP_SLAPD_F (int) add_replica_attrs LDAP_P(( Backend *be, @@ -1292,7 +1359,7 @@ LDAP_SLAPD_F( int ) structural_class( char *textbuf, size_t textlen ); LDAP_SLAPD_F( int ) entry_schema_check( - Backend *be, + Operation *op, Entry *e, Attribute *attrs, int manage, @@ -1578,10 +1645,33 @@ LDAP_SLAPD_F (int) fe_op_delete LDAP_P((Operation *op, SlapReply *rs)); LDAP_SLAPD_F (int) fe_op_modify LDAP_P((Operation *op, SlapReply *rs)); LDAP_SLAPD_F (int) fe_op_modrdn LDAP_P((Operation *op, SlapReply *rs)); LDAP_SLAPD_F (int) fe_op_search LDAP_P((Operation *op, SlapReply *rs)); +LDAP_SLAPD_F (int) fe_aux_operational LDAP_P((Operation *op, SlapReply *rs)); #if 0 LDAP_SLAPD_F (int) fe_op_unbind LDAP_P((Operation *op, SlapReply *rs)); #endif LDAP_SLAPD_F (int) fe_extended LDAP_P((Operation *op, SlapReply *rs)); +LDAP_SLAPD_F (int) fe_acl_group LDAP_P(( + Operation *op, + Entry *target, + struct berval *gr_ndn, + struct berval *op_ndn, + ObjectClass *group_oc, + AttributeDescription *group_at )); +LDAP_SLAPD_F (int) fe_acl_attribute LDAP_P(( + Operation *op, + Entry *target, + struct berval *edn, + AttributeDescription *entry_at, + BerVarray *vals, + slap_access_t access )); +LDAP_SLAPD_F (int) fe_access_allowed LDAP_P(( + Operation *op, + Entry *e, + AttributeDescription *desc, + struct berval *val, + slap_access_t access, + AccessControlState *state, + slap_mask_t *maskp )); /* NOTE: this macro assumes that bv has been allocated * by ber_* malloc functions or is { 0L, NULL } */ @@ -1622,15 +1712,20 @@ LDAP_SLAPD_F (int) fe_extended LDAP_P((Operation *op, SlapReply *rs)); (bv)->bv_len = len; \ } while ( 0 ) #else /* ! HAVE_BIGNUM && ! HAVE_GMP */ +#ifdef HAVE_LONG_LONG +#define UI2BV_FORMAT "%llu" +#else /* ! HAVE_LONG_LONG */ +#define UI2BV_FORMAT "%lu" +#endif /* ! HAVE_LONG_LONG */ #define UI2BVX(bv,ui,ctx) \ do { \ char buf[] = "+9223372036854775807L"; \ ber_len_t len; \ - snprintf( buf, sizeof( buf ), "%lu", (ui) ); \ - len = strlen( buf ); \ + len = snprintf( buf, sizeof( buf ), UI2BV_FORMAT, (ui) ); \ if ( len > (bv)->bv_len ) { \ (bv)->bv_val = ber_memrealloc_x( (bv)->bv_val, len + 1, (ctx) ); \ } \ + (bv)->bv_len = len; \ AC_MEMCPY( (bv)->bv_val, buf, len + 1 ); \ } while ( 0 ) #endif /* ! HAVE_GMP */ diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index 255607117e..8931915219 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -41,15 +41,14 @@ int add_replica_info( - Backend *be, - const char *uri, - const char *host -) + Backend *be, + const char *uri, + const char *host ) { int i = 0; - assert( be ); - assert( host ); + assert( be != NULL ); + assert( host != NULL ); if ( be->be_replica != NULL ) { for ( ; be->be_replica[ i ] != NULL; i++ ); @@ -69,6 +68,45 @@ add_replica_info( return( i ); } +int +destroy_replica_info( + Backend *be ) +{ + int i = 0; + + assert( be != NULL ); + + if ( be->be_replica == NULL ) { + return 0; + } + + for ( ; be->be_replica[ i ] != NULL; i++ ) { + + ch_free( (char *)be->be_replica[ i ]->ri_uri ); + + ber_bvarray_free( be->be_replica[ i ]->ri_nsuffix ); + + if ( be->be_replica[ i ]->ri_attrs ) { + AttributeName *an = be->be_replica[ i ]->ri_attrs; + int j; + + for ( j = 0; !BER_BVISNULL( &an[ j ].an_name ); j++ ) + { + ch_free( an[ j ].an_name.bv_val ); + } + ch_free( an ); + } + + bindconf_free( &be->be_replica[ i ]->ri_bindconf ); + + ch_free( be->be_replica[ i ] ); + } + + ch_free( be->be_replica ); + + return 0; +} + int add_replica_suffix( Backend *be, @@ -126,8 +164,6 @@ replog1( struct slap_replica_info *ri, Operation *op, FILE *fp, long now); void replog( Operation *op ) { - Modifications *ml = NULL; - Attribute *a = NULL; FILE *fp, *lfp; int i; /* undef NO_LOG_WHEN_NO_REPLICAS */ @@ -278,7 +314,7 @@ replog1( case LDAP_REQ_MODIFY: for ( ml = op->orm_modlist; ml != NULL; ml = ml->sml_next ) { - char *did, *type = ml->sml_desc->ad_cname.bv_val; + char *did = NULL, *type = ml->sml_desc->ad_cname.bv_val; switch ( ml->sml_op ) { case LDAP_MOD_ADD: did = "add"; break; diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 97c5cf3857..081eae7b0e 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -37,10 +37,6 @@ #include "slap.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" -#endif - const struct berval slap_dummy_bv = BER_BVNULL; int slap_null_cb( Operation *op, SlapReply *rs ) @@ -50,7 +46,7 @@ int slap_null_cb( Operation *op, SlapReply *rs ) int slap_freeself_cb( Operation *op, SlapReply *rs ) { - assert( op->o_callback ); + assert( op->o_callback != NULL ); op->o_tmpfree( op->o_callback, op->o_tmpmemctx ); op->o_callback = NULL; @@ -246,36 +242,16 @@ static int send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c ) { int rc; -#ifdef LDAP_SLAPI - LDAPControl **sctrls = NULL; - - /* - * Retrieve any additional controls that may be set by the - * plugin. - */ - - if ( o->o_pb && - slapi_pblock_get( o->o_pb, SLAPI_RESCONTROLS, &sctrls ) != 0 ) - { - sctrls = NULL; - } - if ( c == NULL && sctrls == NULL ) return 0; -#else - if( c == NULL ) return 0; -#endif /* LDAP_SLAPI */ + if( c == NULL ) + return 0; rc = ber_printf( ber, "t{"/*}*/, LDAP_TAG_CONTROLS ); if( rc == -1 ) return rc; -#ifdef LDAP_SLAPI - if ( c != NULL ) -#endif /* LDAP_SLAPI */ - { - for( ; *c != NULL; c++) { - rc = send_ldap_control( ber, *c ); - if( rc == -1 ) return rc; - } + for( ; *c != NULL; c++) { + rc = send_ldap_control( ber, *c ); + if( rc == -1 ) return rc; } #ifdef LDAP_DEVEL @@ -293,7 +269,7 @@ send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c ) ber_printf( sber, "{i}", LDAP_UNWILLING_TO_PERFORM ); if( ber_flatten2( ber, &sorted.ldctl_value, 0 ) == -1 ) { - return LBER_ERROR; + return -1; } (void) ber_free_buf( ber ); @@ -303,15 +279,6 @@ send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c ) } #endif -#ifdef LDAP_SLAPI - if ( sctrls != NULL ) { - for ( c = sctrls; *c != NULL; c++ ) { - rc = send_ldap_control( ber, *c ); - if( rc == -1 ) return rc; - } - } -#endif /* LDAP_SLAPI */ - rc = ber_printf( ber, /*{*/"N}" ); return rc; @@ -476,15 +443,6 @@ send_ldap_response( goto cleanup; } -#ifdef LDAP_SLAPI - if ( op->o_pb ) { - slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, - (void *)rs->sr_matched ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text ); - } -#endif /* LDAP_SLAPI */ - ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex ); ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 ); ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes ); @@ -611,26 +569,6 @@ slap_send_ldap_result( Operation *op, SlapReply *rs ) } } -#ifdef LDAP_SLAPI - /* - * Call pre-result plugins. To avoid infinite recursion plugins - * should just set SLAPI_RESULT_CODE rather than sending a - * result if they wish to change the result. - */ - if ( op->o_callback == NULL && op->o_pb != NULL ) { - slapi_int_pblock_set_operation( op->o_pb, op ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, - (void *)rs->sr_err ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, - (void *)rs->sr_text ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, - (void *)rs->sr_matched ); - - (void) slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, - op->o_pb ); - } -#endif /* LDAP_SLAPI */ - if ( op->o_protocol < LDAP_VERSION3 ) { tmp = v2ref( rs->sr_ref, rs->sr_text ); rs->sr_text = tmp; @@ -719,11 +657,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) char *edn; int userattrs; AccessControlState acl_state = ACL_STATE_INIT; -#ifdef LDAP_SLAPI - /* Support for computed attribute plugins */ - computed_attr_context ctx; - AttributeName *anp; -#endif + int attrsonly; AttributeDescription *ad_entry = slap_schema.si_ad_entry; /* a_flags: array of flags telling if the i-th element will be @@ -756,7 +690,8 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) *sc_next = op->o_callback; rc = SLAP_CB_CONTINUE; - for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) { + for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next ) + { sc_next = op->o_callback->sc_next; if ( op->o_callback->sc_response ) { rc = op->o_callback->sc_response( op, rs ); @@ -776,6 +711,8 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) op->o_connid, rs->sr_entry->e_name.bv_val, op->ors_attrsonly ? " (attrsOnly)" : "" ); + attrsonly = op->ors_attrsonly; + if ( !access_allowed( op, rs->sr_entry, ad_entry, NULL, ACL_READ, NULL )) { Debug( LDAP_DEBUG_ACL, "send_search_entry: conn %lu access to entry (%s) not allowed\n", @@ -794,7 +731,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) struct berval bv; bv.bv_len = entry_flatsize( rs->sr_entry, 0 ); - bv.bv_val = op->o_tmpalloc(bv.bv_len, op->o_tmpmemctx ); + bv.bv_val = op->o_tmpalloc( bv.bv_len, op->o_tmpmemctx ); ber_init2( ber, &bv, LBER_USE_DER ); ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx ); @@ -906,7 +843,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) } } - if ( op->ors_attrsonly ) { + if ( attrsonly ) { if ( ! access_allowed( op, rs->sr_entry, desc, NULL, ACL_READ, &acl_state ) ) { @@ -1085,7 +1022,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) goto error_return; } - if ( ! op->ors_attrsonly ) { + if ( ! attrsonly ) { for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) { if ( ! access_allowed( op, rs->sr_entry, desc, &a->a_vals[i], ACL_READ, &acl_state ) ) @@ -1126,46 +1063,6 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) } } -#ifdef LDAP_SLAPI - /* - * First, setup the computed attribute context that is - * passed to all plugins. - */ - if ( op->o_pb ) { - ctx.cac_pb = op->o_pb; - ctx.cac_attrs = rs->sr_attrs; - ctx.cac_attrsonly = op->ors_attrsonly; - ctx.cac_userattrs = userattrs; - ctx.cac_opattrs = rs->sr_attr_flags; - ctx.cac_acl_state = acl_state; - ctx.cac_private = (void *)ber; - - /* - * For each client requested attribute, call the plugins. - */ - if ( rs->sr_attrs != NULL ) { - for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) { - rc = compute_evaluator( &ctx, anp->an_name.bv_val, - rs->sr_entry, slapi_int_compute_output_ber ); - if ( rc == 1 ) break; - } - } else { - /* - * Technically we shouldn't be returning operational attributes - * when the user requested only user attributes. We'll let the - * plugin decide whether to be naughty or not. - */ - rc = compute_evaluator( &ctx, "*", - rs->sr_entry, slapi_int_compute_output_ber ); - } - if ( rc == 1 ) { - if ( op->o_res_ber == NULL ) ber_free_buf( ber ); - send_ldap_error( op, rs, LDAP_OTHER, "computed attribute error" ); - goto error_return; - } - } -#endif /* LDAP_SLAPI */ - /* free e_flags */ if ( e_flags ) { slap_sl_free( e_flags, op->o_tmpmemctx ); @@ -1535,6 +1432,7 @@ int slap_read_controls( myop = *op; myop.o_bd = NULL; myop.o_res_ber = ber; + myop.o_callback = NULL; rc = slap_send_search_entry( &myop, rs ); if( rc ) return rc; @@ -1546,7 +1444,7 @@ int slap_read_controls( c.ldctl_oid = oid->bv_val; c.ldctl_iscritical = 0; - if ( ctrl == NULL ) { + if ( *ctrl == NULL ) { /* first try */ *ctrl = (LDAPControl *) slap_sl_calloc( 1, sizeof(LDAPControl), NULL ); } else { diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 64389ccd17..628ddea77c 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -52,8 +52,10 @@ root_dse_info( const char **text ) { Entry *e; - struct berval val, *bv; - struct berval nval; + struct berval val; +#ifdef LDAP_SLAPI + struct berval *bv; +#endif int i, j; char ** supportedSASLMechanisms; BackendDB *be; @@ -64,8 +66,10 @@ root_dse_info( = slap_schema.si_ad_objectClass; AttributeDescription *ad_namingContexts = slap_schema.si_ad_namingContexts; +#ifdef LDAP_SLAPI AttributeDescription *ad_supportedExtension = slap_schema.si_ad_supportedExtension; +#endif AttributeDescription *ad_supportedLDAPVersion = slap_schema.si_ad_supportedLDAPVersion; AttributeDescription *ad_supportedSASLMechanisms diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index 52701bab78..e92780132f 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -147,7 +147,7 @@ slap_sasl_log( static const char *slap_propnames[] = { "*slapConn", "*slapAuthcDN", "*slapAuthzDN", NULL }; -static Filter generic_filter = { LDAP_FILTER_PRESENT }; +static Filter generic_filter = { LDAP_FILTER_PRESENT, { 0 }, NULL }; static struct berval generic_filterstr = BER_BVC("(objectclass=*)"); #define PROP_CONN 0 @@ -439,7 +439,7 @@ slap_auxprop_store( } } } - slap_mods_free( modlist ); + slap_mods_free( modlist, 1 ); return rc != LDAP_SUCCESS ? SASL_FAIL : SASL_OK; } #endif /* SASL_VERSION_FULL >= 2.1.16 */ @@ -609,7 +609,7 @@ slap_sasl_authorize( { Connection *conn = (Connection *)context; struct propval auxvals[3]; - struct berval authcDN, authzDN=BER_BVNULL; + struct berval authcDN, authzDN = BER_BVNULL; int rc; /* Simple Binds don't support proxy authorization, ignore it */ @@ -654,7 +654,17 @@ slap_sasl_authorize( return SASL_NOAUTHZ; } - conn->c_sasl_authz_dn = authzDN; + /* FIXME: we need yet another dup because slap_sasl_getdn() + * is using the bind operation slab */ + if ( conn->c_sasl_bindop ) { + ber_dupbv( &conn->c_sasl_authz_dn, &authzDN ); + slap_sl_free( authzDN.bv_val, + conn->c_sasl_bindop->o_tmpmemctx ); + + } else { + conn->c_sasl_authz_dn = authzDN; + } + ok: if (conn->c_sasl_bindop) { Statslog( LDAP_DEBUG_STATS, @@ -678,7 +688,7 @@ slap_sasl_authorize( const char **user, const char **errstr) { - struct berval authcDN, authzDN; + struct berval authcDN, authzDN = BER_BVNULL; int rc; Connection *conn = context; char *realm; @@ -732,7 +742,7 @@ slap_sasl_authorize( return SASL_NOAUTHZ; } - rc = slap_sasl_authorized(conn->c_sasl_bindop, &authcDN, &authzDN ); + rc = slap_sasl_authorized( conn->c_sasl_bindop, &authcDN, &authzDN ); if( rc ) { Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " "proxy authorization disallowed (%d)\n", @@ -742,7 +752,17 @@ slap_sasl_authorize( ch_free( authzDN.bv_val ); return SASL_NOAUTHZ; } - conn->c_sasl_authz_dn = authzDN; + + /* FIXME: we need yet another dup because slap_sasl_getdn() + * is using the bind operation slab */ + if ( conn->c_sasl_bindop ) { + ber_dupbv( &conn->c_sasl_authz_dn, &authzDN ); + slap_sl_free( authzDN.bv_val, + conn->c_sasl_bindop->o_tmpmemctx ); + + } else { + conn->c_sasl_authz_dn = authzDN; + } ok: Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: " @@ -750,7 +770,7 @@ ok: (long) (conn ? conn->c_connid : -1), authzDN.bv_val ? authzDN.bv_val : "", 0 ); - if (conn->c_sasl_bindop) { + if ( conn->c_sasl_bindop ) { Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu BIND authcid=\"%s\" authzid=\"%s\"\n", conn->c_connid, conn->c_sasl_bindop->o_opid, @@ -1522,8 +1542,8 @@ int slap_sasl_getdn( Connection *conn, Operation *op, struct berval *id, int rc, is_dn = SET_NONE, do_norm = 1; struct berval dn2, *mech; - assert( conn ); - assert( id ); + assert( conn != NULL ); + assert( id != NULL ); Debug( LDAP_DEBUG_ARGS, "slap_sasl_getdn: conn %lu id=%s [len=%lu]\n", conn->c_connid, @@ -1534,6 +1554,7 @@ int slap_sasl_getdn( Connection *conn, Operation *op, struct berval *id, if ( !op ) { op = conn->c_sasl_bindop; } + assert( op != NULL ); BER_BVZERO( dn ); @@ -1647,13 +1668,16 @@ int slap_sasl_getdn( Connection *conn, Operation *op, struct berval *id, irdn++; DN[ irdn ] = NULL; - rc = ldap_dn2bv_x( DN, dn, LDAP_DN_FORMAT_LDAPV3, op->o_tmpmemctx ); + rc = ldap_dn2bv_x( DN, dn, LDAP_DN_FORMAT_LDAPV3, + op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { BER_BVZERO( dn ); return rc; } - Debug( LDAP_DEBUG_TRACE, "slap_sasl_getdn: u:id converted to %s\n", dn->bv_val,0,0 ); + Debug( LDAP_DEBUG_TRACE, + "slap_sasl_getdn: u:id converted to %s\n", + dn->bv_val, 0, 0 ); } else { @@ -1683,7 +1707,8 @@ int slap_sasl_getdn( Connection *conn, Operation *op, struct berval *id, if( !BER_BVISNULL( &dn2 ) ) { slap_sl_free( dn->bv_val, op->o_tmpmemctx ); *dn = dn2; - Debug( LDAP_DEBUG_TRACE, "getdn: dn:id converted to %s\n", + Debug( LDAP_DEBUG_TRACE, + "slap_sasl_getdn: dn:id converted to %s\n", dn->bv_val, 0, 0 ); } diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index 001c0ecdb0..b3885374fe 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -94,8 +94,8 @@ static const char *policy_txt[] = { static int authz_policy = SASL_AUTHZ_NONE; -static -int slap_sasl_match( Operation *opx, struct berval *rule, +static int +slap_sasl_match( Operation *opx, struct berval *rule, struct berval *assertDN, struct berval *authc ); int slap_sasl_setpolicy( const char *arg ) @@ -131,11 +131,11 @@ int slap_parse_user( struct berval *id, struct berval *user, { char u; - assert( id ); + assert( id != NULL ); assert( !BER_BVISNULL( id ) ); - assert( user ); - assert( realm ); - assert( mech ); + assert( user != NULL ); + assert( realm != NULL ); + assert( mech != NULL ); u = id->bv_val[ 0 ]; @@ -222,6 +222,7 @@ static int slap_parseURI( Operation *op, struct berval *uri, "slap_parseURI: parsing %s\n", uri->bv_val, 0, 0 ); rc = LDAP_PROTOCOL_ERROR; + /* * dn[.]: * ::= {exact|regex|children|subtree|onelevel} @@ -380,11 +381,11 @@ is_dn: bv.bv_len = uri->bv_len - (bv.bv_val - uri->bv_val); } else { group_oc.bv_len = group_dn.bv_val - group_oc.bv_val; - BER_BVSTR( &member_at, "member" ); + BER_BVSTR( &member_at, SLAPD_GROUP_ATTR ); } } else { - BER_BVSTR( &group_oc, "groupOfNames" ); + BER_BVSTR( &group_oc, SLAPD_GROUP_CLASS ); } group_dn.bv_val++; group_dn.bv_len = uri->bv_len - ( group_dn.bv_val - uri->bv_val ); @@ -435,7 +436,8 @@ is_dn: bv.bv_len = uri->bv_len - (bv.bv_val - uri->bv_val); /* * must be ldap:/// */ - return LDAP_PROTOCOL_ERROR; + rc = LDAP_PROTOCOL_ERROR; + goto done; } break; @@ -445,12 +447,14 @@ is_dn: bv.bv_len = uri->bv_len - (bv.bv_val - uri->bv_val); * * NOTE: must pass DN normalization */ + ldap_free_urldesc( ludp ); bv.bv_val = uri->bv_val; *scope = LDAP_X_SCOPE_EXACT; goto is_dn; default: - return LDAP_PROTOCOL_ERROR; + rc = LDAP_PROTOCOL_ERROR; + goto done; } if ( ( ludp->lud_host && *ludp->lud_host ) @@ -494,6 +498,7 @@ done: return( rc ); } +#ifndef SLAP_AUTH_REWRITE static int slap_sasl_rx_off(char *rep, int *off) { const char *c; @@ -527,6 +532,7 @@ static int slap_sasl_rx_off(char *rep, int *off) off[n] = -1; return( LDAP_SUCCESS ); } +#endif /* ! SLAP_AUTH_REWRITE */ #ifdef SLAP_AUTH_REWRITE int slap_sasl_rewrite_config( @@ -644,7 +650,6 @@ int slap_sasl_regexp_config( const char *match, const char *replace ) void slap_sasl_regexp_unparse( BerVarray *out ) { int i; - struct berval bv; BerVarray bva = NULL; char ibuf[32], *ptr; struct berval idx; @@ -670,6 +675,7 @@ void slap_sasl_regexp_unparse( BerVarray *out ) *out = bva; } +#ifndef SLAP_AUTH_REWRITE /* Perform replacement on regexp matches */ static void slap_sasl_rx_exp( const char *rep, @@ -721,6 +727,7 @@ static void slap_sasl_rx_exp( out->bv_val[insert] = '\0'; } +#endif /* ! SLAP_AUTH_REWRITE */ /* Take the passed in SASL name and attempt to convert it into an LDAP URI to find the matching LDAP entry, using the pattern matching @@ -882,8 +889,8 @@ slap_sasl_matches( Operation *op, BerVarray rules, * The assertDN should not have the dn: prefix */ -static -int slap_sasl_match( Operation *opx, struct berval *rule, +static int +slap_sasl_match( Operation *opx, struct berval *rule, struct berval *assertDN, struct berval *authc ) { int rc; @@ -1102,7 +1109,7 @@ slap_sasl_check_authz( Operation *op, AttributeDescription *ad, struct berval *authc ) { - int i, rc; + int rc; BerVarray vals = NULL; Debug( LDAP_DEBUG_TRACE, @@ -1133,8 +1140,12 @@ COMPLETE: * an internal search must be done, and if that search returns exactly one * entry, return the DN of that one entry. */ -void slap_sasl2dn( Operation *opx, - struct berval *saslname, struct berval *sasldn, int flags ) +void +slap_sasl2dn( + Operation *opx, + struct berval *saslname, + struct berval *sasldn, + int flags ) { int rc; slap_callback cb = { NULL, sasl_sc_sasl2dn, NULL, NULL }; diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index c2f0970ff9..7dd42ddf07 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -103,7 +103,7 @@ schema_info( Entry **entry, const char **text ) } nvals[0].bv_val = strchr( frontendDB->be_schemandn.bv_val, '=' ); - assert( nvals[0].bv_val ); + assert( nvals[0].bv_val != NULL ); nvals[0].bv_val++; nvals[0].bv_len = frontendDB->be_schemandn.bv_len - (nvals[0].bv_val - frontendDB->be_schemandn.bv_val); diff --git a/servers/slapd/schema/core.schema b/servers/slapd/schema/core.schema index a06aefa5d6..f8671b2d6f 100644 --- a/servers/slapd/schema/core.schema +++ b/servers/slapd/schema/core.schema @@ -524,8 +524,8 @@ objectclass ( 2.5.6.23 NAME 'deltaCRL' objectclass ( 1.3.6.1.4.1.250.3.15 NAME 'labeledURIObject' DESC 'RFC2079: object that contains the URI attribute type' - MAY ( labeledURI ) - SUP top AUXILIARY ) + SUP top AUXILIARY + MAY ( labeledURI ) ) # # Derived from RFC 1274, but with new "short names" diff --git a/servers/slapd/schema/cosine.schema b/servers/slapd/schema/cosine.schema index d97a5c1b87..b89e79f018 100644 --- a/servers/slapd/schema/cosine.schema +++ b/servers/slapd/schema/cosine.schema @@ -373,8 +373,8 @@ attributetype ( 0.9.2342.19200300.100.1.15 NAME 'documentLocation' # ::= {pilotAttributeType 20} # attributetype ( 0.9.2342.19200300.100.1.20 - DESC 'RFC1274: home telephone number' NAME ( 'homePhone' 'homeTelephoneNumber' ) + DESC 'RFC1274: home telephone number' EQUALITY telephoneNumberMatch SUBSTR telephoneNumberSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 ) diff --git a/servers/slapd/schema/nis.schema b/servers/slapd/schema/nis.schema index 0f07b96213..d2c3798b41 100644 --- a/servers/slapd/schema/nis.schema +++ b/servers/slapd/schema/nis.schema @@ -156,67 +156,80 @@ attributetype ( 1.3.6.1.1.1.1.27 NAME 'nisMapEntry' # Object Class Definitions -objectclass ( 1.3.6.1.1.1.2.0 NAME 'posixAccount' SUP top AUXILIARY +objectclass ( 1.3.6.1.1.1.2.0 NAME 'posixAccount' DESC 'Abstraction of an account with POSIX attributes' + SUP top AUXILIARY MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory ) MAY ( userPassword $ loginShell $ gecos $ description ) ) -objectclass ( 1.3.6.1.1.1.2.1 NAME 'shadowAccount' SUP top AUXILIARY +objectclass ( 1.3.6.1.1.1.2.1 NAME 'shadowAccount' DESC 'Additional attributes for shadow passwords' + SUP top AUXILIARY MUST uid MAY ( userPassword $ shadowLastChange $ shadowMin $ shadowMax $ shadowWarning $ shadowInactive $ shadowExpire $ shadowFlag $ description ) ) -objectclass ( 1.3.6.1.1.1.2.2 NAME 'posixGroup' SUP top STRUCTURAL +objectclass ( 1.3.6.1.1.1.2.2 NAME 'posixGroup' DESC 'Abstraction of a group of accounts' + SUP top AUXILIARY MUST ( cn $ gidNumber ) MAY ( userPassword $ memberUid $ description ) ) -objectclass ( 1.3.6.1.1.1.2.3 NAME 'ipService' SUP top STRUCTURAL +objectclass ( 1.3.6.1.1.1.2.3 NAME 'ipService' DESC 'Abstraction an Internet Protocol service' + SUP top STRUCTURAL MUST ( cn $ ipServicePort $ ipServiceProtocol ) MAY ( description ) ) -objectclass ( 1.3.6.1.1.1.2.4 NAME 'ipProtocol' SUP top STRUCTURAL +objectclass ( 1.3.6.1.1.1.2.4 NAME 'ipProtocol' DESC 'Abstraction of an IP protocol' + SUP top STRUCTURAL MUST ( cn $ ipProtocolNumber $ description ) MAY description ) -objectclass ( 1.3.6.1.1.1.2.5 NAME 'oncRpc' SUP top STRUCTURAL +objectclass ( 1.3.6.1.1.1.2.5 NAME 'oncRpc' DESC 'Abstraction of an ONC/RPC binding' + SUP top STRUCTURAL MUST ( cn $ oncRpcNumber $ description ) MAY description ) -objectclass ( 1.3.6.1.1.1.2.6 NAME 'ipHost' SUP top AUXILIARY +objectclass ( 1.3.6.1.1.1.2.6 NAME 'ipHost' DESC 'Abstraction of a host, an IP device' + SUP top AUXILIARY MUST ( cn $ ipHostNumber ) MAY ( l $ description $ manager ) ) -objectclass ( 1.3.6.1.1.1.2.7 NAME 'ipNetwork' SUP top STRUCTURAL +objectclass ( 1.3.6.1.1.1.2.7 NAME 'ipNetwork' DESC 'Abstraction of an IP network' + SUP top STRUCTURAL MUST ( cn $ ipNetworkNumber ) MAY ( ipNetmaskNumber $ l $ description $ manager ) ) -objectclass ( 1.3.6.1.1.1.2.8 NAME 'nisNetgroup' SUP top STRUCTURAL +objectclass ( 1.3.6.1.1.1.2.8 NAME 'nisNetgroup' DESC 'Abstraction of a netgroup' + SUP top STRUCTURAL MUST cn MAY ( nisNetgroupTriple $ memberNisNetgroup $ description ) ) -objectclass ( 1.3.6.1.1.1.2.9 NAME 'nisMap' SUP top STRUCTURAL +objectclass ( 1.3.6.1.1.1.2.9 NAME 'nisMap' DESC 'A generic abstraction of a NIS map' + SUP top STRUCTURAL MUST nisMapName MAY description ) -objectclass ( 1.3.6.1.1.1.2.10 NAME 'nisObject' SUP top STRUCTURAL +objectclass ( 1.3.6.1.1.1.2.10 NAME 'nisObject' DESC 'An entry in a NIS map' + SUP top STRUCTURAL MUST ( cn $ nisMapEntry $ nisMapName ) MAY description ) -objectclass ( 1.3.6.1.1.1.2.11 NAME 'ieee802Device' SUP top AUXILIARY +objectclass ( 1.3.6.1.1.1.2.11 NAME 'ieee802Device' DESC 'A device with a MAC address' + SUP top AUXILIARY MAY macAddress ) -objectclass ( 1.3.6.1.1.1.2.12 NAME 'bootableDevice' SUP top AUXILIARY +objectclass ( 1.3.6.1.1.1.2.12 NAME 'bootableDevice' DESC 'A device with boot parameters' + SUP top AUXILIARY MAY ( bootFile $ bootParameter ) ) diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 1d47ff4365..7a8ace4e48 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -43,7 +43,7 @@ static int entry_naming_check( int entry_schema_check( - Backend *be, + Operation *op, Entry *e, Attribute *oldattrs, int manage, @@ -64,7 +64,11 @@ entry_schema_check( int subentry = is_entry_subentry( e ); int collectiveSubentry = 0; - if ( SLAP_NO_SCHEMA_CHECK( be )) { + if ( SLAP_NO_SCHEMA_CHECK( op->o_bd )) { + return LDAP_SUCCESS; + } + + if ( get_no_schema_check( op ) ) { return LDAP_SUCCESS; } @@ -79,12 +83,12 @@ entry_schema_check( const char *type = a->a_desc->ad_cname.bv_val; /* there should be at least one value */ - assert( a->a_vals ); + assert( a->a_vals != NULL ); assert( a->a_vals[0].bv_val != NULL ); if( a->a_desc->ad_type->sat_check ) { int rc = (a->a_desc->ad_type->sat_check)( - be, e, a, text, textbuf, textlen ); + op->o_bd, e, a, text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { return rc; } @@ -308,7 +312,7 @@ entry_schema_check( } if ( oc->soc_check ) { - int rc = (oc->soc_check)( be, e, oc, + int rc = (oc->soc_check)( op->o_bd, e, oc, text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { return rc; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 0ce73bb9b3..6c7fb42a69 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -404,7 +404,7 @@ octetStringSubstringsIndexer( BerVarray *keysp, void *ctx ) { - ber_len_t i, j, len, nkeys; + ber_len_t i, nkeys; size_t slen, mlen; BerVarray keys; @@ -521,7 +521,7 @@ octetStringSubstringsFilter ( { SubstringsAssertion *sa; char pre; - ber_len_t len, max, nkeys = 0; + ber_len_t nkeys = 0; size_t slen, mlen, klen; BerVarray keys; HASH_CONTEXT HASHcontext; @@ -892,8 +892,8 @@ nameUIDPretty( struct berval *out, void *ctx ) { - assert( val ); - assert( out ); + assert( val != NULL ); + assert( out != NULL ); Debug( LDAP_DEBUG_TRACE, ">>> nameUIDPretty: <%s>\n", val->bv_val, 0, 0 ); @@ -2362,7 +2362,6 @@ serialNumberAndIssuerValidate( struct berval *in ) { int rc; - int state; ber_len_t n; struct berval sn, i; if( in->bv_len < 3 ) return LDAP_INVALID_SYNTAX; @@ -2396,12 +2395,11 @@ serialNumberAndIssuerPretty( void *ctx ) { int rc; - int state; ber_len_t n; struct berval sn, i, newi; - assert( val ); - assert( out ); + assert( val != NULL ); + assert( out != NULL ); Debug( LDAP_DEBUG_TRACE, ">>> serialNumberAndIssuerPretty: <%s>\n", val->bv_val, 0, 0 ); @@ -2436,13 +2434,14 @@ serialNumberAndIssuerPretty( out->bv_len = sn.bv_len + newi.bv_len + 1; out->bv_val = slap_sl_realloc( newi.bv_val, out->bv_len + 1, ctx ); - if( BER_BVISNULL( out ) ) { + if( out->bv_val == NULL ) { + out->bv_len = 0; slap_sl_free( newi.bv_val, ctx ); return LDAP_OTHER; } /* push issuer over */ - AC_MEMCPY( &out->bv_val[sn.bv_len+1], newi.bv_val, newi.bv_len ); + AC_MEMCPY( &out->bv_val[sn.bv_len+1], out->bv_val, newi.bv_len ); /* insert sn and "$" */ AC_MEMCPY( out->bv_val, sn.bv_val, sn.bv_len ); out->bv_val[sn.bv_len] = '$'; @@ -2471,12 +2470,11 @@ serialNumberAndIssuerNormalize( void *ctx ) { int rc; - int state; ber_len_t n; struct berval sn, i, newi; - assert( val ); - assert( out ); + assert( val != NULL ); + assert( out != NULL ); Debug( LDAP_DEBUG_TRACE, ">>> serialNumberAndIssuerNormalize: <%s>\n", val->bv_val, 0, 0 ); @@ -2513,13 +2511,14 @@ serialNumberAndIssuerNormalize( out->bv_len = sn.bv_len + newi.bv_len + 1; out->bv_val = slap_sl_realloc( newi.bv_val, out->bv_len + 1, ctx ); - if( BER_BVISNULL( out ) ) { + if( out->bv_val == NULL ) { + out->bv_len = 0; slap_sl_free( newi.bv_val, ctx ); return LDAP_OTHER; } /* push issuer over */ - AC_MEMCPY( &out->bv_val[sn.bv_len+1], newi.bv_val, newi.bv_len ); + AC_MEMCPY( &out->bv_val[sn.bv_len+1], out->bv_val, newi.bv_len ); /* insert sn and "$" */ AC_MEMCPY( out->bv_val, sn.bv_val, sn.bv_len ); out->bv_val[sn.bv_len] = '$'; @@ -2900,7 +2899,6 @@ int generalizedTimeIndexer( void *ctx ) { int i, j; - size_t slen, mlen; BerVarray keys; char tmp[5]; BerValue bvtmp; /* 40 bit index */ diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index e6d66910ca..50e99c12b4 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -297,8 +297,8 @@ static int objectSubClassIndexer( ocvalues[noc] = sup->soc_cname; - assert( ocvalues[noc].bv_val ); - assert( ocvalues[noc].bv_len ); + assert( ocvalues[noc].bv_val != NULL ); + assert( ocvalues[noc].bv_len != 0 ); noc++; @@ -321,7 +321,9 @@ static ObjectClassSchemaCheckFN rootDseObjectClass; static ObjectClassSchemaCheckFN aliasObjectClass; static ObjectClassSchemaCheckFN referralObjectClass; static ObjectClassSchemaCheckFN subentryObjectClass; +#ifdef LDAP_DYNAMIC_OBJECTS static ObjectClassSchemaCheckFN dynamicObjectClass; +#endif static struct slap_schema_oc_map { char *ssom_name; @@ -417,7 +419,9 @@ static AttributeTypeSchemaCheckFN aliasAttribute; static AttributeTypeSchemaCheckFN referralAttribute; static AttributeTypeSchemaCheckFN subentryAttribute; static AttributeTypeSchemaCheckFN administrativeRoleAttribute; +#ifdef LDAP_DYNAMIC_OBJECTS static AttributeTypeSchemaCheckFN dynamicAttribute; +#endif static struct slap_schema_ad_map { char *ssam_name; @@ -1231,6 +1235,7 @@ slap_schema_load( void ) mr->smr_filter = ad_map[i].ssam_mr_filter; } + /* FIXME: no-one will free this at exit */ (*adp)->ad_type->sat_equality = mr; } } @@ -1400,6 +1405,7 @@ static int subentryObjectClass ( return LDAP_SUCCESS; } +#ifdef LDAP_DYNAMIC_OBJECTS static int dynamicObjectClass ( Backend *be, Entry *e, @@ -1418,6 +1424,7 @@ static int dynamicObjectClass ( return LDAP_SUCCESS; } +#endif /* LDAP_DYNAMIC_OBJECTS */ static int rootDseAttribute ( Backend *be, @@ -1540,6 +1547,7 @@ static int administrativeRoleAttribute ( return LDAP_OBJECT_CLASS_VIOLATION; } +#ifdef LDAP_DYNAMIC_OBJECTS static int dynamicAttribute ( Backend *be, Entry *e, @@ -1565,3 +1573,4 @@ static int dynamicAttribute ( return LDAP_SUCCESS; } +#endif /* LDAP_DYNAMIC_OBJECTS */ diff --git a/servers/slapd/search.c b/servers/slapd/search.c index a162b20068..b83b2d165d 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -33,15 +33,6 @@ #include "lutil.h" #include "slap.h" -#ifdef LDAP_SLAPI -#include "slapi/slapi.h" - -static void init_search_pblock( Operation *op, char **attrs, int managedsait ); -static int call_search_preop_plugins( Operation *op ); -static int call_search_rewrite_plugins( Operation *op ); -static void call_search_postop_plugins( Operation *op ); -#endif /* LDAPI_SLAPI */ - int do_search( Operation *op, /* info about the op to which we're responding */ @@ -247,9 +238,6 @@ fe_op_search( Operation *op, SlapReply *rs ) { int manageDSAit; int be_manageDSAit; -#ifdef LDAP_SLAPI - char **attrs = NULL; -#endif manageDSAit = get_manageDSAit( op ); @@ -270,15 +258,6 @@ fe_op_search( Operation *op, SlapReply *rs ) goto return_results; } -#ifdef LDAP_SLAPI - if ( op->o_pb ) { - attrs = anlist2charray_x( op->ors_attrs, 0, op->o_tmpmemctx ); - init_search_pblock( op, attrs, manageDSAit ); - rs->sr_err = call_search_preop_plugins( op ); - if ( rs->sr_err ) break; - call_search_rewrite_plugins( op ); - } -#endif /* LDAP_SLAPI */ rs->sr_err = root_dse_info( op->o_conn, &entry, &rs->sr_text ); } else if ( bvmatch( &op->o_req_ndn, &frontendDB->be_schemandn ) ) { @@ -288,23 +267,11 @@ fe_op_search( Operation *op, SlapReply *rs ) goto return_results; } -#ifdef LDAP_SLAPI - if ( op->o_pb ) { - attrs = anlist2charray_x( op->ors_attrs, 0, op->o_tmpmemctx ); - init_search_pblock( op, attrs, manageDSAit ); - rs->sr_err = call_search_preop_plugins( op ); - if ( rs->sr_err ) break; - call_search_rewrite_plugins( op ); - } -#endif /* LDAP_SLAPI */ rs->sr_err = schema_info( &entry, &rs->sr_text ); } if( rs->sr_err != LDAP_SUCCESS ) { send_ldap_result( op, rs ); -#ifdef LDAP_SLAPI - if ( op->o_pb ) call_search_postop_plugins( op ); -#endif /* LDAP_SLAPI */ goto return_results; } else if ( entry != NULL ) { @@ -322,9 +289,6 @@ fe_op_search( Operation *op, SlapReply *rs ) rs->sr_err = LDAP_SUCCESS; send_ldap_result( op, rs ); -#ifdef LDAP_SLAPI - if ( op->o_pb ) call_search_postop_plugins( op ); -#endif /* LDAP_SLAPI */ goto return_results; } break; @@ -374,19 +338,6 @@ fe_op_search( Operation *op, SlapReply *rs ) goto return_results; } -#ifdef LDAP_SLAPI - if ( op->o_pb ) { - attrs = anlist2charray_x( op->ors_attrs, 0, op->o_tmpmemctx ); - init_search_pblock( op, attrs, manageDSAit ); - rs->sr_err = call_search_preop_plugins( op ); - if ( rs->sr_err != LDAP_SUCCESS ) { - goto return_results; - } - - call_search_rewrite_plugins( op ); - } -#endif /* LDAP_SLAPI */ - /* actually do the search and send the result(s) */ if ( op->o_bd->be_search ) { if ( limits_check( op, rs ) == 0 ) { @@ -399,115 +350,7 @@ fe_op_search( Operation *op, SlapReply *rs ) "operation not supported within namingContext" ); } -#ifdef LDAP_SLAPI - if ( op->o_pb ) call_search_postop_plugins( op ); -#endif /* LDAP_SLAPI */ - -#ifdef LDAP_SLAPI - if( attrs != NULL) op->o_tmpfree( attrs, op->o_tmpmemctx ); -#endif /* LDAP_SLAPI */ - return_results:; return rs->sr_err; } -#ifdef LDAP_SLAPI - -static void init_search_pblock( Operation *op, - char **attrs, int managedsait ) -{ - slapi_int_pblock_set_operation( op->o_pb, op ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TARGET, (void *)op->o_req_dn.bv_val ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SCOPE, (void *)op->ors_scope ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_DEREF, (void *)op->ors_deref ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SIZELIMIT, (void *)op->ors_slimit ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TIMELIMIT, (void *)op->ors_tlimit ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_FILTER, (void *)op->ors_filter ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_STRFILTER, (void *)op->ors_filterstr.bv_val ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_ATTRS, (void *)attrs ); - slapi_pblock_set( op->o_pb, SLAPI_SEARCH_ATTRSONLY, (void *)op->ors_attrsonly ); - slapi_pblock_set( op->o_pb, SLAPI_MANAGEDSAIT, (void *)managedsait ); -} - -static int call_search_preop_plugins( Operation *op ) -{ - int rc; - - rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_SEARCH_FN, op->o_pb ); - if ( rc < 0 ) { - /* - * A preoperation plugin failure will abort the - * entire operation. - */ - Debug(LDAP_DEBUG_TRACE, "call_search_preop_plugins: search preoperation plugin " - "returned %d.\n", rc, 0, 0); - if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 ) || - rc == LDAP_SUCCESS ) { - rc = LDAP_OTHER; - } - } else { - rc = LDAP_SUCCESS; - } - - return rc; -} - -static int call_search_rewrite_plugins( Operation *op ) -{ - if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, op->o_pb ) == 0 ) { - int rc; - - /* - * The plugin can set the SLAPI_SEARCH_FILTER. - * SLAPI_SEARCH_STRFILER is not normative. - */ - slapi_pblock_get( op->o_pb, SLAPI_SEARCH_FILTER, (void *)&op->ors_filter ); - op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx ); - filter2bv_x( op, op->ors_filter, &op->ors_filterstr ); - - /* - * Also permit other search parameters to be reset. One thing - * this doesn't (yet) deal with is plugins that change a root - * DSE search to a non-root DSE search... - */ - slapi_pblock_get( op->o_pb, SLAPI_SEARCH_TARGET, (void **)&op->o_req_dn.bv_val ); - op->o_req_dn.bv_len = strlen( op->o_req_dn.bv_val ); - - if( !BER_BVISNULL( &op->o_req_ndn ) ) { - slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx ); - } - rc = dnNormalize( 0, NULL, NULL, &op->o_req_dn, &op->o_req_ndn, - op->o_tmpmemctx ); - if ( rc != LDAP_SUCCESS ) { - return rc; - } - - slapi_pblock_get( op->o_pb, SLAPI_SEARCH_SCOPE, (void **)&op->ors_scope ); - slapi_pblock_get( op->o_pb, SLAPI_SEARCH_DEREF, (void **)&op->ors_deref ); - - Debug( LDAP_DEBUG_ARGS, " after compute_rewrite_search filter: %s\n", - !BER_BVISEMPTY( &op->ors_filterstr ) ? op->ors_filterstr.bv_val : "empty", 0, 0 ); - } - - return LDAP_SUCCESS; -} - -static void call_search_postop_plugins( Operation *op ) -{ - if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_SEARCH_FN, op->o_pb ) < 0 ) { - Debug(LDAP_DEBUG_TRACE, "call_search_postop_plugins: search postoperation plugins " - "failed.\n", 0, 0, 0); - } -} - -void slapi_int_dummy(void) -{ - /* - * XXX slapi_search_internal() was no getting pulled - * in; all manner of linker flags failed to link it. - * FIXME - */ - slapi_search_internal( NULL, 0, NULL, NULL, NULL, 0 ); -} -#endif /* LDAP_SLAPI */ - diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c index 1f6bd267f5..e5d78627dd 100644 --- a/servers/slapd/sl_malloc.c +++ b/servers/slapd/sl_malloc.c @@ -95,18 +95,20 @@ slap_sl_mem_create( void *ctx ) { - struct slab_heap *sh = NULL; + struct slab_heap *sh; ber_len_t size_shift; int pad = 2*sizeof(int)-1, pad_shift; int order = -1, order_start = -1, order_end = -1; - int i, k; + int i; struct slab_object *so; #ifdef NO_THREADS sh = slheap; #else + void *sh_tmp = NULL; ldap_pvt_thread_pool_getkey( - ctx, (void *)slap_sl_mem_init, (void **)&sh, NULL ); + ctx, (void *)slap_sl_mem_init, &sh_tmp, NULL ); + sh = sh_tmp; #endif /* round up to doubleword boundary */ @@ -247,7 +249,7 @@ slap_sl_malloc( struct slab_object *so_new, *so_left, *so_right; ber_len_t *ptr, *new; unsigned long diff; - int i, j, k; + int i, j; /* ber_set_option calls us like this */ if (!ctx) return ber_memalloc_x(size, NULL); @@ -347,12 +349,8 @@ void * slap_sl_realloc(void *ptr, ber_len_t size, void *ctx) { struct slab_heap *sh = ctx; - int size_shift; - int pad = 2*sizeof(int)-1, pad_shift; - int order_start = -1, order = -1; - struct slab_object *so; + int pad = 2*sizeof(int) -1; ber_len_t *p = (ber_len_t *)ptr, *new; - unsigned long diff; if (ptr == NULL) return slap_sl_malloc(size, ctx); @@ -420,7 +418,7 @@ slap_sl_free(void *ptr, void *ctx) int order_start = -1, order = -1; struct slab_object *so; unsigned long diff; - int i, k, inserted = 0; + int i, inserted = 0; if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) { ber_memfree_x(ptr, NULL); @@ -479,7 +477,7 @@ slap_sl_free(void *ptr, void *ctx) Debug(LDAP_DEBUG_TRACE, "slap_sl_free: " "free object not found while bit is clear.\n", 0, 0, 0); - assert(so); + assert(so != NULL); } } else { @@ -529,7 +527,7 @@ slap_sl_free(void *ptr, void *ctx) Debug(LDAP_DEBUG_TRACE, "slap_sl_free: " "free object not found while bit is clear.\n", 0, 0, 0 ); - assert( so ); + assert(so != NULL); } } else { @@ -553,8 +551,8 @@ slap_sl_free(void *ptr, void *ctx) void * slap_sl_context( void *ptr ) { - struct slab_heap *sh = NULL; - void *ctx; + struct slab_heap *sh; + void *ctx, *sh_tmp; if ( slapMode & SLAP_TOOL_MODE ) return NULL; @@ -563,8 +561,10 @@ slap_sl_context( void *ptr ) #else ctx = ldap_pvt_thread_pool_context(); - ldap_pvt_thread_pool_getkey(ctx, (void *)slap_sl_mem_init, - (void **)&sh, NULL); + sh_tmp = NULL; + ldap_pvt_thread_pool_getkey( + ctx, (void *)slap_sl_mem_init, &sh_tmp, NULL); + sh = sh_tmp; #endif if (sh && ptr >= sh->sh_base && ptr <= sh->sh_end) { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index a3c11195d8..7d97375c36 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -76,6 +76,10 @@ LDAP_BEGIN_DECL #endif #endif +#if defined(LDAP_SLAPI) && !defined(SLAP_OVERLAY_ACCESS) +#define SLAP_OVERLAY_ACCESS +#endif + /* * ITS#3705: bail out if unknown config directives appear in slapd.conf */ @@ -1985,6 +1989,12 @@ typedef int (BI_has_subordinates) LDAP_P(( struct slap_op *op, typedef int (BI_access_allowed) LDAP_P(( struct slap_op *op, Entry *e, AttributeDescription *desc, struct berval *val, slap_access_t access, AccessControlState *state, slap_mask_t *maskp )); +typedef int (BI_acl_group) LDAP_P(( struct slap_op *op, Entry *target, + struct berval *gr_ndn, struct berval *op_ndn, + ObjectClass *group_oc, AttributeDescription *group_at )); +typedef int (BI_acl_attribute) LDAP_P(( struct slap_op *op, Entry *target, + struct berval *entry_ndn, AttributeDescription *entry_at, + BerVarray *vals, slap_access_t access )); #endif /* SLAP_OVERLAY_ACCESS */ typedef int (BI_connection_init) LDAP_P(( BackendDB *bd, @@ -2087,6 +2097,8 @@ struct slap_backend_info { BI_has_subordinates *bi_has_subordinates; #ifdef SLAP_OVERLAY_ACCESS BI_access_allowed *bi_access_allowed; + BI_acl_group *bi_acl_group; + BI_acl_attribute *bi_acl_attribute; #endif /* SLAP_OVERLAY_ACCESS */ BI_connection_init *bi_connection_init; @@ -2169,6 +2181,24 @@ typedef struct slap_callback { struct slap_overinfo; +typedef enum slap_operation_e { + op_bind = 0, + op_unbind, + op_search, + op_compare, + op_modify, + op_modrdn, + op_add, + op_delete, + op_abandon, + op_cancel, + op_extended, + op_aux_operational, + op_aux_chk_referrals, + op_aux_chk_controls, + op_last +} slap_operation_t; + typedef struct slap_overinst { BackendInfo on_bi; slap_response *on_response; @@ -2262,7 +2292,6 @@ typedef struct slap_op_header { char oh_log_prefix[sizeof("conn=18446744073709551615 op=18446744073709551615")]; #ifdef LDAP_SLAPI - void *oh_pb; /* NS-SLAPI plugin */ void *oh_extensions; /* NS-SLAPI plugin */ #endif } Opheader; @@ -2287,11 +2316,6 @@ typedef struct slap_op { #define o_log_prefix o_hdr->oh_log_prefix -#ifdef LDAP_SLAPI -#define o_pb o_hdr->oh_pb -#define o_extensions o_hdr->oh_extensions -#endif - ber_tag_t o_tag; /* tag of the request */ time_t o_time; /* time op was initiated */ int o_tincr; /* counter for multiple ops with same o_time */ @@ -2371,6 +2395,8 @@ typedef struct slap_op { char o_nocaching; char o_delete_glue_parent; + char o_no_schema_check; +#define get_no_schema_check(op) ((op)->o_no_schema_check) #define SLAP_CONTROL_NONE 0 #define SLAP_CONTROL_IGNORED 1 diff --git a/servers/slapd/slapadd.c b/servers/slapd/slapadd.c index fec476894d..e4190eac3b 100644 --- a/servers/slapd/slapadd.c +++ b/servers/slapd/slapadd.c @@ -63,10 +63,15 @@ slapadd( int argc, char **argv ) ID ctxcsn_id, id; int ret; struct berval bvtext; - int i, checkvals; - struct berval mc; + int checkvals; + char opbuf[OPERATION_BUFFER_SIZE]; + Operation *op; + slap_tool_init( progname, SLAPADD, argc, argv ); + memset( opbuf, 0, sizeof(opbuf) ); + op = (Operation *)opbuf; + if( !be->be_entry_open || !be->be_entry_close || !be->be_entry_put ) @@ -182,7 +187,9 @@ slapadd( int argc, char **argv ) } /* check schema */ - rc = entry_schema_check( be, e, NULL, manage, + op->o_bd = be; + + rc = entry_schema_check( op, e, NULL, manage, &text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { @@ -302,19 +309,15 @@ slapadd( int argc, char **argv ) if( continuemode ) continue; break; } - } - - if ( verbose ) { - if ( dryrun ) { - fprintf( stderr, "added: \"%s\"\n", - e->e_dn ); - } else { + if ( verbose ) fprintf( stderr, "added: \"%s\" (%08lx)\n", e->e_dn, (long) id ); - } + } else { + if ( verbose ) + fprintf( stderr, "added: \"%s\"\n", + e->e_dn ); } -done:; entry_free( e ); } diff --git a/servers/slapd/slapi/Makefile.in b/servers/slapd/slapi/Makefile.in index c2b9a594d2..d431d0cee3 100644 --- a/servers/slapd/slapi/Makefile.in +++ b/servers/slapd/slapi/Makefile.in @@ -24,9 +24,9 @@ NT_OBJS = nt_err.lo LIB_DEFS = -DSLAPI_LIBRARY -SRCS= plugin.c slapi_pblock.c slapi_utils.c printmsg.c slapi_ops.c slapi_ext.c \ +SRCS= plugin.c slapi_pblock.c slapi_utils.c printmsg.c slapi_ops.c slapi_dn.c slapi_ext.c slapi_overlay.c \ $(@PLAT@_SRCS) -OBJS= plugin.lo slapi_pblock.lo slapi_utils.lo printmsg.lo slapi_ops.lo slapi_ext.lo \ +OBJS= plugin.lo slapi_pblock.lo slapi_utils.lo printmsg.lo slapi_ops.lo slapi_dn.lo slapi_ext.lo slapi_overlay.lo \ $(@PLAT@_SRCS) XSRCS= version.c diff --git a/servers/slapd/slapi/TODO b/servers/slapd/slapi/TODO index ea50430773..8916488119 100644 --- a/servers/slapd/slapi/TODO +++ b/servers/slapd/slapi/TODO @@ -10,7 +10,7 @@ - This is a very tough task: try to implement a sandbox to execute plugins in, trap deadly signals and possibly disable unsafe plugins without crashing slapd (fork from inside thread? trap signals - and longjump to next plugin execution? Brrr). + and longjump to next plugin execution? Brrr). --- $OpenLDAP$ diff --git a/servers/slapd/slapi/ibm_pblock_params.h b/servers/slapd/slapi/ibm_pblock_params.h deleted file mode 100644 index 460e03cea4..0000000000 --- a/servers/slapd/slapi/ibm_pblock_params.h +++ /dev/null @@ -1,77 +0,0 @@ -/* $OpenLDAP$ */ -/* This work is part of OpenLDAP Software . - * - * Copyright 2002-2005 The OpenLDAP Foundation. - * Portions Copyright 1997,2002-2003 IBM Corporation. - * 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 - * . - */ -/* ACKNOWLEDGEMENTS: - * This work was initially developed by IBM Corporation for use in - * IBM products and subsequently ported to OpenLDAP Software by - * Steve Omrani. - */ - -#ifndef _ibm_pblock_params_H -#define _ibm_pblock_params_H - -#define FIRST_PARAM -1 -#define LAST_IBM_PARAM -48 -#define NETSCAPE_RESERVED(p) (p >= 280) && (p <= 299) -#define IBM_RESERVED(p) (p >= LAST_IBM_PARAM) && (p <= FIRST_PARAM) - -#define SLAPI_IBM_THREAD_CONTROL (FIRST_PARAM - 1) -#define SLAPI_IBM_PBLOCK (FIRST_PARAM - 2) -#define SLAPI_IBM_CONNECTION_PTR (FIRST_PARAM - 3) -#define SLAPI_IBM_BACKENDS (FIRST_PARAM - 4) -#define SLAPI_PRE_BIND_ALL (FIRST_PARAM - 5) -#define SLAPI_POST_BIND_ALL (FIRST_PARAM - 6) -#define SLAPI_IBM_ADMIN_DN (FIRST_PARAM - 7) -#define SLAPI_CONFIG_STATE (FIRST_PARAM - 8) -#define SLAPI_PLUGIN_DB_REGISTER_SERVICE_FN (FIRST_PARAM - 9) -#define SLAPI_PLUGIN_DB_INSERT_REPL_ENTRIES_FN (FIRST_PARAM - 10) -#define SLAPI_PLUGIN_DB_GET_REPL_ENTRIES_FN (FIRST_PARAM - 11) -#define SLAPI_PLUGIN_DB_REPLICA_DONE_FN (FIRST_PARAM - 12) -#define SLAPI_PLUGIN_DB_INIT_REPL_LIST_FN (FIRST_PARAM - 13) -#define SLAPI_PLUGIN_DB_THREAD_INITIALIZE_FN (FIRST_PARAM - 14) -#define SLAPI_PLUGIN_DB_THREAD_TERMINATE_FN (FIRST_PARAM - 15) -#define SLAPI_PLUGIN_DB_SCHEMA_MODIFY_ATTRTYPE_FN (FIRST_PARAM - 16) -#define SLAPI_PLUGIN_DB_SCHEMA_MODIFY_OBJCLASS_FN (FIRST_PARAM - 17) -#define SLAPI_PLUGIN_DB_INIT_FN (FIRST_PARAM - 18) -#define SLAPI_IBM_EXTENDED_OPS (FIRST_PARAM - 19) -#define SLAPI_IBM_CONTROLS (FIRST_PARAM - 20) -#define SLAPI_IBM_SASLMECHANISMS (FIRST_PARAM - 21) -#define SLAPI_IBM_BROADCAST_BE (FIRST_PARAM - 22) -#define SLAPI_IBM_NOTIFY_BIND_FN (FIRST_PARAM - 23) -#define SLAPI_IBM_SECRET (FIRST_PARAM - 24) -#define SLAPI_IBM_CL_START_FN (FIRST_PARAM - 25) -#define SLAPI_IBM_REPLICATE (FIRST_PARAM - 26) -#define SLAPI_IBM_CL_CLASS (FIRST_PARAM - 27) -#define SLAPI_IBM_CL_SUFFIX (FIRST_PARAM - 28) -#define SLAPI_IBM_CL_MAX_ENTRIES (FIRST_PARAM - 29) -#define SLAPI_IBM_CONNINFO (FIRST_PARAM - 30) -#define SLAPI_IBM_CL_FIRST_ENTRY (FIRST_PARAM - 31) -#define SLAPI_IBM_CL_LAST_ENTRY (FIRST_PARAM - 32) -#define SLAPI_IBM_CONN_DN_ALT (FIRST_PARAM - 33) -#define SLAPI_IBM_GSSAPI_CONTEXT (FIRST_PARAM - 34) -#define SLAPI_IBM_ADD_ENTRY (FIRST_PARAM - 35) -#define SLAPI_IBM_DELETE_ENTRY (FIRST_PARAM - 36) -#define SLAPI_IBM_MODIFY_ENTRY (FIRST_PARAM - 37) -#define SLAPI_IBM_MODIFY_MODS (FIRST_PARAM - 38) -#define SLAPI_IBM_MODRDN_ENTRY (FIRST_PARAM - 39) -#define SLAPI_IBM_MODRDN_NEWDN (FIRST_PARAM - 40) -#define SLAPI_IBM_EVENT_ENABLED (FIRST_PARAM - 41) -#define SLAPI_IBM_EVENT_MAXREG (FIRST_PARAM - 42) -#define SLAPI_IBM_EVENT_REGPERCONN (FIRST_PARAM - 43) -#define SLAPI_IBM_EVENT_CURREG (FIRST_PARAM - 44) -#define SLAPI_IBM_EVENT_SENTREG (FIRST_PARAM - 45) -#define SLAPI_IBM_CONN_DN_ORIG (FIRST_PARAM - 46) -#define SLAPI_PLUGIN_DB_DELETE_PROGRESS_FN (FIRST_PARAM - 47) -#endif /* _ibm_pblock_params_H */ diff --git a/servers/slapd/slapi/plugin.c b/servers/slapd/slapi/plugin.c index 6ebe041408..88ecb4c83c 100644 --- a/servers/slapd/slapi/plugin.c +++ b/servers/slapd/slapi/plugin.c @@ -36,8 +36,6 @@ static int slapi_int_load_plugin( Slapi_PBlock *, const char *, const char *, in /* pointer to link list of extended objects */ static ExtendedOp *pGExtendedOps = NULL; -/* global plugins not associated with a specific backend */ -static Slapi_PBlock *pGPlugins = NULL; /********************************************************************* * Function Name: plugin_pblock_new @@ -72,9 +70,9 @@ plugin_pblock_new( Slapi_PluginDesc *pPluginDesc = NULL; lt_dlhandle hdLoadHandle; int rc; - char **av2 = NULL, **ppPluginArgv; - char *path = argv[2]; - char *initfunc = argv[3]; + char **av2 = NULL, **ppPluginArgv; + char *path = argv[2]; + char *initfunc = argv[3]; pPlugin = slapi_pblock_new(); if ( pPlugin == NULL ) { @@ -82,18 +80,11 @@ plugin_pblock_new( goto done; } - rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)type ); - if ( rc != 0 ) { - goto done; - } - - rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGC, (void *)argc ); - if ( rc != 0 ) { - goto done; - } + slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)&type ); + slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGC, (void *)&argc ); av2 = ldap_charray_dup( argv ); - if ( !av2 ) { + if ( av2 == NULL ) { rc = LDAP_NO_MEMORY; goto done; } @@ -103,17 +94,11 @@ plugin_pblock_new( } else { ppPluginArgv = NULL; } - rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGV, (void *)ppPluginArgv ); - if ( rc != 0 ) { - goto done; - } - rc = slapi_pblock_set( pPlugin, SLAPI_X_CONFIG_ARGV, (void *)av2 ); - if ( rc != 0 ) { - goto done; - } + slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGV, (void *)ppPluginArgv ); + slapi_pblock_set( pPlugin, SLAPI_X_CONFIG_ARGV, (void *)av2 ); - rc = slapi_int_load_plugin( pPlugin, path, initfunc, TRUE, NULL, &hdLoadHandle ); + rc = slapi_int_load_plugin( pPlugin, path, initfunc, 1, NULL, &hdLoadHandle ); if ( rc != 0 ) { goto done; } @@ -132,7 +117,7 @@ done: if ( rc != 0 && pPlugin != NULL ) { slapi_pblock_destroy( pPlugin ); pPlugin = NULL; - if ( av2 ) { + if ( av2 != NULL ) { ldap_charray_free( av2 ); } } @@ -161,37 +146,27 @@ slapi_int_register_plugin( Backend *be, Slapi_PBlock *pPB ) { - Slapi_PBlock *pTmpPB; - Slapi_PBlock *pSavePB; - int rc = LDAP_SUCCESS; + Slapi_PBlock *pTmpPB; + Slapi_PBlock *pSavePB; + int rc = LDAP_SUCCESS; - pTmpPB = ( be == NULL ) ? pGPlugins : (Slapi_PBlock *)(be->be_pb); + assert( be != NULL ); + pTmpPB = SLAPI_BACKEND_PBLOCK( be ); if ( pTmpPB == NULL ) { - if ( be != NULL ) - be->be_pb = (void *)pPB; - else - pGPlugins = pPB; + SLAPI_BACKEND_PBLOCK( be ) = pPB; } else { while ( pTmpPB != NULL && rc == LDAP_SUCCESS ) { pSavePB = pTmpPB; - rc = slapi_pblock_get( pTmpPB, SLAPI_IBM_PBLOCK, - &pTmpPB ); - if ( rc != LDAP_SUCCESS ) { - rc = LDAP_OTHER; - } + rc = slapi_pblock_get( pTmpPB, SLAPI_IBM_PBLOCK, &pTmpPB ); } if ( rc == LDAP_SUCCESS ) { - rc = slapi_pblock_set( pSavePB, SLAPI_IBM_PBLOCK, - (void *)pPB ); - if ( rc != LDAP_SUCCESS ) { - rc = LDAP_OTHER; - } + rc = slapi_pblock_set( pSavePB, SLAPI_IBM_PBLOCK, (void *)pPB ); } } - return rc; + return ( rc != LDAP_SUCCESS ) ? LDAP_OTHER : LDAP_SUCCESS; } /********************************************************************* @@ -223,51 +198,25 @@ slapi_int_get_plugins( int numPB = 0; int rc = LDAP_SUCCESS; - assert( ppFuncPtrs ); - - /* - * First, count the plugins associated with a specific - * backend. - */ - if ( be != NULL ) { - pCurrentPB = (Slapi_PBlock *)be->be_pb; - - while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) { - rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr ); - if ( rc == LDAP_SUCCESS ) { - if ( FuncPtr != NULL ) { - numPB++; - } - rc = slapi_pblock_get( pCurrentPB, - SLAPI_IBM_PBLOCK, &pCurrentPB ); - } - } - } + assert( ppFuncPtrs != NULL ); - if ( rc != LDAP_SUCCESS ) { + if ( be == NULL ) { goto done; } - /* - * Then, count the global plugins. - */ - pCurrentPB = pGPlugins; + pCurrentPB = SLAPI_BACKEND_PBLOCK( be ); - while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) { + while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) { rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr ); if ( rc == LDAP_SUCCESS ) { if ( FuncPtr != NULL ) { numPB++; } rc = slapi_pblock_get( pCurrentPB, - SLAPI_IBM_PBLOCK, &pCurrentPB ); + SLAPI_IBM_PBLOCK, &pCurrentPB ); } } - if ( rc != LDAP_SUCCESS ) { - goto done; - } - if ( numPB == 0 ) { *ppFuncPtrs = NULL; rc = LDAP_SUCCESS; @@ -285,23 +234,7 @@ slapi_int_get_plugins( goto done; } - if ( be != NULL ) { - pCurrentPB = (Slapi_PBlock *)be->be_pb; - - while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) { - rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr ); - if ( rc == LDAP_SUCCESS ) { - if ( FuncPtr != NULL ) { - *pTmpFuncPtr = FuncPtr; - pTmpFuncPtr++; - } - rc = slapi_pblock_get( pCurrentPB, - SLAPI_IBM_PBLOCK, &pCurrentPB ); - } - } - } - - pCurrentPB = pGPlugins; + pCurrentPB = SLAPI_BACKEND_PBLOCK( be ); while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) { rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr ); @@ -314,7 +247,9 @@ slapi_int_get_plugins( SLAPI_IBM_PBLOCK, &pCurrentPB ); } } - *pTmpFuncPtr = NULL ; + + *pTmpFuncPtr = NULL; + done: if ( rc != LDAP_SUCCESS && *ppFuncPtrs != NULL ) { @@ -338,14 +273,12 @@ createExtendedOp() { ExtendedOp *ret; - ret = (ExtendedOp *)ch_malloc(sizeof(ExtendedOp)); - if ( ret != NULL ) { - ret->ext_oid.bv_val = NULL; - ret->ext_oid.bv_len = 0; - ret->ext_func = NULL; - ret->ext_be = NULL; - ret->ext_next = NULL; - } + ret = (ExtendedOp *)slapi_ch_malloc(sizeof(ExtendedOp)); + ret->ext_oid.bv_val = NULL; + ret->ext_oid.bv_len = 0; + ret->ext_func = NULL; + ret->ext_be = NULL; + ret->ext_next = NULL; return ret; } @@ -610,7 +543,7 @@ slapi_int_load_plugin( int rc = LDAP_SUCCESS; SLAPI_FUNC fpInitFunc = NULL; - assert( pLdHandle ); + assert( pLdHandle != NULL ); if ( lt_dlinit() ) { return LDAP_LOCAL_ERROR; @@ -619,16 +552,20 @@ slapi_int_load_plugin( /* load in the module */ *pLdHandle = lt_dlopen( path ); if ( *pLdHandle == NULL ) { + fprintf( stderr, "failed to load plugin %s: %s\n", + path, lt_dlerror() ); return LDAP_LOCAL_ERROR; } fpInitFunc = (SLAPI_FUNC)lt_dlsym( *pLdHandle, initfunc ); if ( fpInitFunc == NULL ) { + fprintf( stderr, "failed to find symbol %s in plugin %s: %s\n", + initfunc, path, lt_dlerror() ); lt_dlclose( *pLdHandle ); return LDAP_LOCAL_ERROR; } - if ( doInit == TRUE ) { + if ( doInit ) { rc = ( *fpInitFunc )( pPlugin ); if ( rc != LDAP_SUCCESS ) { lt_dlclose( *pLdHandle ); @@ -665,12 +602,6 @@ slapi_int_call_plugins( } for ( pGetPlugin = tmpPlugin ; *pGetPlugin != NULL; pGetPlugin++ ) { - /* - * FIXME: we should provide here a sort of sandbox, - * to protect from plugin faults; e.g. trap signals - * and longjump here, marking the plugin as unsafe for - * later executions ... - */ rc = (*pGetPlugin)(pPB); /* @@ -711,6 +642,14 @@ slapi_int_read_config( fname, lineno ); return 1; } + + /* automatically instantiate overlay if necessary */ + if ( !slapi_over_is_inst( be ) ) { + if ( slapi_over_config( be ) != 0 ) { + fprintf( stderr, "Failed to instantiate SLAPI overlay\n"); + return -1; + } + } if ( strcasecmp( argv[1], "preoperation" ) == 0 ) { iType = SLAPI_PLUGIN_PREOPERATION; @@ -768,15 +707,21 @@ slapi_int_plugin_unparse( ) { Slapi_PBlock *pp; - int i, j, rc; + int i, j; char **argv, ibuf[32], *ptr; struct berval idx, bv; *out = NULL; idx.bv_val = ibuf; i = 0; - for ( pp=be->be_pb; pp; slapi_pblock_get( pp, SLAPI_IBM_PBLOCK, &pp ) ) { + + for ( pp = SLAPI_BACKEND_PBLOCK( be ); + pp != NULL; + slapi_pblock_get( pp, SLAPI_IBM_PBLOCK, &pp ) ) + { slapi_pblock_get( pp, SLAPI_X_CONFIG_ARGV, &argv ); + if ( argv == NULL ) /* could be dynamic plugin */ + continue; idx.bv_len = sprintf( idx.bv_val, "{%d}", i ); bv.bv_len = idx.bv_len; for (j=1; argv[j]; j++) { @@ -793,30 +738,3 @@ slapi_int_plugin_unparse( } } -int -slapi_int_initialize(void) -{ - if ( ldap_pvt_thread_mutex_init( &slapi_hn_mutex ) ) { - return -1; - } - - if ( ldap_pvt_thread_mutex_init( &slapi_time_mutex ) ) { - return -1; - } - - if ( ldap_pvt_thread_mutex_init( &slapi_printmessage_mutex ) ) { - return -1; - } - - slapi_log_file = ch_strdup( LDAP_RUNDIR LDAP_DIRSEP "errors" ); - if ( slapi_log_file == NULL ) { - return -1; - } - - if ( slapi_int_init_object_extensions() != 0 ) { - return -1; - } - - return 0; -} - diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index c21e1afc81..0728af5bcb 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -25,318 +25,65 @@ LDAP_BEGIN_DECL -/* - * Was: slapi_utils.h - */ - -extern int slapi_log_error( int severity, char *subsystem, char *fmt, ... ); -extern Slapi_Entry *slapi_str2entry( char *s, int flags ); -extern char *slapi_entry2str( Slapi_Entry *e, int *len ); -extern int slapi_entry_attr_merge( Slapi_Entry *e, char *type, struct berval **vals ); -extern int slapi_entry_attr_find( Slapi_Entry *e, char *type, Slapi_Attr **attr ); -extern char *slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type ); -extern int slapi_entry_attr_delete( Slapi_Entry *e, char *type ); -extern int slapi_entry_attr_get_int( const Slapi_Entry *e, const char *type ); -extern long slapi_entry_attr_get_long( const Slapi_Entry *e, const char *type ); -extern unsigned int slapi_entry_attr_get_uint( const Slapi_Entry *e, const char *type ); -extern unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry *e, const char *type ); -extern int slapi_entry_attr_hasvalue( Slapi_Entry *e, const char *type, const char *value ); -extern int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); -extern void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value); -extern void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l); -extern void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l); -extern void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l); -extern void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l); -extern int slapi_is_rootdse( const char *dn ); -extern int slapi_entry_has_children(const Slapi_Entry *e); -size_t slapi_entry_size(Slapi_Entry *e); -extern int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); -extern int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); -extern int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs); -extern int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); -extern int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); -extern int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); -extern int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value); -extern int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value); -extern int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value); -extern int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr ); -extern int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr ); -extern const char *slapi_entry_get_uniqueid( const Slapi_Entry *e ); -extern void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid ); -extern int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e ); -extern int slapi_entry_rdn_values_present( const Slapi_Entry *e ); -extern int slapi_entry_add_rdn_values( Slapi_Entry *e ); - -extern char *slapi_entry_get_dn( Slapi_Entry *e ); -extern int slapi_x_entry_get_id( Slapi_Entry *e ); -extern void slapi_entry_set_dn( Slapi_Entry *e, char *dn ); -extern Slapi_Entry *slapi_entry_dup( Slapi_Entry *e ); -extern Slapi_Entry *slapi_entry_alloc(); -extern void slapi_entry_free( Slapi_Entry *e ); -extern int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals ); - -/* DS 5.x SLAPI */ -extern int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr, - struct berval *val, int access ); -extern int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, - char **errbuf ); -extern Slapi_Attr *slapi_attr_new( void ); -extern Slapi_Attr *slapi_attr_init( Slapi_Attr *a, const char *type ); -extern void slapi_attr_free( Slapi_Attr **a ); -extern Slapi_Attr *slapi_attr_dup( const Slapi_Attr *attr ); -extern int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v ); -extern int slapi_attr_type2plugin( const char *type, void **pi ); -extern int slapi_attr_get_type( const Slapi_Attr *attr, char **type ); -extern int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp ); -extern int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags ); -extern int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag ); -extern int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1, - const struct berval *v2 ); -extern int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v ); -#if 0 -#define SLAPI_TYPE_CMP_EXACT 0 -#define SLAPI_TYPE_CMP_BASE 1 -#define SLAPI_TYPE_CMP_SUBTYPE 2 -#endif -extern int slapi_attr_type_cmp( const char *t1, const char *t2, int opt ); -extern int slapi_attr_types_equivalent( const char *t1, const char *t2 ); -extern int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v ); -extern int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v ); -extern int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues ); -extern int slapi_attr_get_valueset( const Slapi_Attr *a, Slapi_ValueSet **vs ); -extern int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals ); -extern char *slapi_attr_syntax_normalize( const char *s ); - -extern Slapi_Value *slapi_value_new( void ); -extern Slapi_Value *slapi_value_new_berval(const struct berval *bval); -extern Slapi_Value *slapi_value_new_value(const Slapi_Value *v); -extern Slapi_Value *slapi_value_new_string(const char *s); -extern Slapi_Value *slapi_value_init(Slapi_Value *v); -extern Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval); -extern Slapi_Value *slapi_value_init_string(Slapi_Value *v,const char *s); -extern Slapi_Value *slapi_value_dup(const Slapi_Value *v); -extern void slapi_value_free(Slapi_Value **value); -extern const struct berval *slapi_value_get_berval( const Slapi_Value *value ); -extern Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval ); -extern Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom); -extern Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len); -extern int slapi_value_set_string(Slapi_Value *value, const char *strVal); -extern int slapi_value_set_int(Slapi_Value *value, int intVal); -extern const char*slapi_value_get_string(const Slapi_Value *value); -extern int slapi_value_get_int(const Slapi_Value *value); -extern unsigned int slapi_value_get_uint(const Slapi_Value *value); -extern long slapi_value_get_long(const Slapi_Value *value); -extern unsigned long slapi_value_get_ulong(const Slapi_Value *value); -extern size_t slapi_value_get_length(const Slapi_Value *value); -extern int slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value *v2); - -extern Slapi_ValueSet *slapi_valueset_new( void ); -extern void slapi_valueset_free(Slapi_ValueSet *vs); -extern void slapi_valueset_init(Slapi_ValueSet *vs); -extern void slapi_valueset_done(Slapi_ValueSet *vs); -extern void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval); -extern int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v ); -extern int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v); -extern int slapi_valueset_count( const Slapi_ValueSet *vs); -extern void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2); - -extern Slapi_Mutex *slapi_new_mutex( void ); -extern void slapi_destroy_mutex( Slapi_Mutex *mutex ); -extern void slapi_lock_mutex( Slapi_Mutex *mutex ); -extern int slapi_unlock_mutex( Slapi_Mutex *mutex ); -extern Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex ); -extern void slapi_destroy_condvar( Slapi_CondVar *cvar ); -extern int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout ); -extern int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all ); - -extern LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared ); -extern void slapi_ldap_unbind( LDAP *ld ); - -extern char *slapi_ch_malloc( unsigned long size ); -extern void slapi_ch_free( void **ptr ); -extern void slapi_ch_free_string( char **s ); -extern char *slapi_ch_calloc( unsigned long nelem, unsigned long size ); -extern char *slapi_ch_realloc( char *block, unsigned long size ); -extern char *slapi_ch_strdup( char *s ); -extern void slapi_ch_array_free( char **arrayp ); -extern struct berval *slapi_ch_bvdup(const struct berval *v); -extern struct berval **slapi_ch_bvecdup(const struct berval **v); - -/* - * FIXME: these two were missing, but widely used in a couple of .c files - */ -extern size_t slapi_strlen(char *s ); -#define slapi_ch_stlen(s) slapi_strlen(s) -/* - * end of FIXME - */ -extern char *slapi_dn_normalize( char *dn ); -extern char *slapi_dn_normalize_case( char *dn ); -extern char * slapi_esc_dn_normalize( char *dn ); -extern char * slapi_esc_dn_normalize_case( char *dn ); -extern int slapi_dn_isroot( Slapi_PBlock *pb, char *dn ); -extern int slapi_dn_issuffix( char *dn, char *suffix ); -char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn ); -char *slapi_dn_parent( const char *dn ); -int slapi_dn_isparent( const char *parentdn, const char *childdn ); -extern char *slapi_dn_ignore_case( char *dn ); -extern char *slapi_get_hostname(); -extern void slapi_register_supported_saslmechanism( char *mechanism ); -extern void slapi_send_ldap_result( Slapi_PBlock *pb, int err, - char *matched, char *text, int nentries, struct berval **urls ); -extern int slapi_send_ldap_extended_response(Connection *conn, Operation *op, - int errornum, char *respName, struct berval *response); -extern int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e, - LDAPControl **ectrls, char **attrs, int attrsonly ); -extern int slapi_send_ldap_search_reference( Slapi_PBlock *pb, Slapi_Entry *e, - struct berval **references, LDAPControl **ectrls, struct berval **v2refs ); - -extern void slapi_register_supported_control(char *controloid, - unsigned long controlops); -extern int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp); -extern int slapi_control_present( LDAPControl **controls, char *oid, - struct berval **val, int *iscritical); -extern LDAPControl *slapi_dup_control(LDAPControl *control); -extern void slapi_register_supported_saslmechanism(char *mechanism); -extern char **slapi_get_supported_saslmechanisms(); -extern char **slapi_get_supported_extended_ops(void); -extern int checkControlHonored(LDAPControl **controls, char *pControlOid, - unsigned long operation, int *isHonored ); -extern void slapi_broadcast_be(int funcType, Slapi_PBlock *pPB); -extern Slapi_Filter *slapi_str2filter( char *str ); -extern Slapi_Filter *slapi_filter_dup( Slapi_Filter *f ); -extern void slapi_filter_free( Slapi_Filter *f, int recurse ); -extern int slapi_filter_get_choice( Slapi_Filter *f); -extern int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval ); -extern Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f ); -extern Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev ); -extern int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type ); -extern int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial, - char ***any, char **final ); -extern Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2); -extern int slapi_x_filter_append( int choice, Slapi_Filter **pContainingFilter, - Slapi_Filter **pNextFilter, Slapi_Filter *filterToAppend ); -extern int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, - int verify_access ); -extern int slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code ); -extern int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f); -extern void slapi_free_search_results_internal(Slapi_PBlock *pb); -extern int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL); -extern int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort); -extern int slapi_get_num_be(char *type); -extern unsigned long slapi_timer_current_time(); -extern unsigned long slapi_timer_get_time(char *label); -extern void slapi_timer_elapsed_time(char *label,unsigned long start); -extern int slapi_audit_init_header( Connection *conn, Operation *op, - Audit_record **arp, void **audit_op_str, - int audit_op, int audit_ext_op, int audit_op_str_len); -extern int slapi_audit_send_record( Slapi_PBlock *pb, Connection *conn, - Operation *op, int rc); - -extern int slapi_int_pblock_set_operation( Slapi_PBlock *pb, Operation *op ); - -extern LDAPMod **slapi_int_modifications2ldapmods(Modifications **); -extern Modifications *slapi_int_ldapmods2modifications(LDAPMod **); -extern void slapi_int_free_ldapmods(LDAPMod **); - -extern int slapi_compute_add_evaluator(slapi_compute_callback_t function); -extern int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function); -extern int compute_rewrite_search_filter(Slapi_PBlock *pb); -extern int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn); -extern int slapi_int_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e); -extern int slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb); - -extern int slapi_int_access_allowed(Operation *op, Entry *entry, AttributeDescription *desc, struct berval *val, slap_access_t access, AccessControlState *state); - -extern int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); - -extern ldap_pvt_thread_mutex_t slapi_hn_mutex; -extern ldap_pvt_thread_mutex_t slapi_time_mutex; -extern ldap_pvt_thread_mutex_t slapi_printmessage_mutex; -extern char *slapi_log_file; -extern int slapi_log_level; - - -/* - * Was: slapi_pblock.h - */ - -extern Slapi_PBlock *slapi_pblock_new( void ); -extern void slapi_pblock_destroy( Slapi_PBlock* ); -extern int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value ); -extern int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value ); -extern void slapi_pblock_check_params( Slapi_PBlock *pb, int flag ); -extern int slapi_pblock_delete_param( Slapi_PBlock *p, int param ); -extern void slapi_pblock_clear( Slapi_PBlock *pb ); - -/* - * OpenLDAP extensions - */ -extern int slapi_int_pblock_get_first( Backend *be, Slapi_PBlock **pb ); -extern int slapi_int_pblock_get_next( Slapi_PBlock **pb ); - - -/* - * Was: plugin.h - */ - -extern int slapi_int_register_plugin(Backend *be, Slapi_PBlock *pPB); -extern int slapi_int_call_plugins(Backend *be, int funcType, Slapi_PBlock * pPB); -extern int slapi_int_get_plugins(Backend *be, int functype, SLAPI_FUNC **ppFuncPtrs); -extern int slapi_int_register_extop(Backend *pBE, ExtendedOp **opList, Slapi_PBlock *pPB); -extern int slapi_int_get_extop_plugin(struct berval *reqoid, SLAPI_FUNC *pFuncAddr ); -extern int slapi_int_read_config(Backend *be, const char *fname, int lineno, - int argc, char **argv ); -extern void slapi_int_plugin_unparse(Backend *be, BerVarray *out ); -extern int slapi_int_initialize(void); - - -/* - * Was: slapi_ops.h - */ - -extern Slapi_PBlock *slapi_search_internal( char *base, int scope, char *filter, - LDAPControl **controls, char **attrs, int attrsonly ); -extern Slapi_PBlock *slapi_modify_internal( char *dn, LDAPMod **mods, - LDAPControl **controls, int log_change ); -extern Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e, - LDAPControl **controls, int log_change ); -extern Slapi_PBlock *slapi_add_internal( char * dn, LDAPMod **attrs, - LDAPControl **controls, int log_changes ); -extern Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e, - LDAPControl **controls, int log_change ); -extern Slapi_PBlock *slapi_delete_internal( char * dn, LDAPControl **controls, - int log_change ); -extern Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn, - int deloldrdn, LDAPControl **controls, int log_change); -extern char **slapi_get_supported_extended_ops(void); -extern struct berval *slapi_int_get_supported_extop( int ); -extern Connection *slapi_int_init_connection(char *DN, int OpType); -extern void slapi_int_connection_destroy( Connection **pConn ); - -/* - * Was: slapi_cl.h - */ - -extern void slapi_register_changelog_suffix(char *suffix); -extern char **slapi_get_changelog_suffixes(); -extern void slapi_update_changelog_counters(long curNum, long numEntries); -extern char *slapi_get_cl_firstNum(); -extern char *slapi_get_cl_lastNum(); -extern int slapi_add_to_changelog(Slapi_Entry *ent, char *suffix, - char *chNum, Operation* op); -extern int slapi_delete_changelog(char *dn, char *suffix, - char *chNum, Operation* op); -extern int slapi_modify_changelog(char *dn, LDAPMod *mods,char *suffix, - char *chNum, Operation* op); -extern int slapi_modifyrdn_changelog(char *olddn, char *newRdn, int delRdn, - char *suffix, char *chNum, Operation* op); -extern Backend * slapi_cl_get_be(char *dn); - -int slapi_int_init_object_extensions(void); -int slapi_int_free_object_extensions(int objecttype, void *object); -int slapi_int_create_object_extensions(int objecttype, void *object); -int slapi_int_clear_object_extensions(int objecttype, void *object); +/* slapi_utils.c */ +LDAP_SLAPI_F (LDAPMod **) slapi_int_modifications2ldapmods LDAP_P(( Modifications * )); +LDAP_SLAPI_F (Modifications *) slapi_int_ldapmods2modifications LDAP_P(( LDAPMod ** )); +LDAP_SLAPI_F (int) slapi_int_count_controls LDAP_P(( LDAPControl **ctrls )); +LDAP_SLAPI_F (char **) slapi_get_supported_extended_ops LDAP_P((void)); +LDAP_SLAPI_F (int) slapi_int_access_allowed LDAP_P((Operation *op, Entry *entry, AttributeDescription *desc, struct berval *val, slap_access_t access, AccessControlState *state )); + +/* slapi_ops.c */ +LDAP_SLAPI_F (int) slapi_int_response LDAP_P(( Slapi_Operation *op, SlapReply *rs )); +LDAP_SLAPI_F (void) slapi_int_connection_init_pb LDAP_P(( Slapi_PBlock *pb, ber_tag_t OpType )); +LDAP_SLAPI_F (void) slapi_int_connection_done_pb LDAP_P(( Slapi_PBlock *pb )); + +/* slapi_pblock.c */ +LDAP_SLAPI_F (int) slapi_pblock_delete_param LDAP_P(( Slapi_PBlock *p, int param )); +LDAP_SLAPI_F (void) slapi_pblock_clear LDAP_P(( Slapi_PBlock *pb )); + +LDAP_SLAPI_F (int) slapi_int_pblock_get_first LDAP_P(( Backend *be, Slapi_PBlock **pb )); +LDAP_SLAPI_F (int) slapi_int_pblock_get_next LDAP_P(( Slapi_PBlock **pb )); + +#define PBLOCK_ASSERT_CONN( _pb ) do { \ + assert( (_pb) != NULL ); \ + assert( (_pb)->pb_conn != NULL ); \ + } while (0) + +#define PBLOCK_ASSERT_OP( _pb, _tag ) do { \ + PBLOCK_ASSERT_CONN( _pb ); \ + assert( (_pb)->pb_op != NULL ); \ + assert( (_pb)->pb_rs != NULL ); \ + if ( _tag != 0 ) \ + assert( (_pb)->pb_op->o_tag == (_tag)); \ + } while (0) + +#define PBLOCK_ASSERT_INTOP( _pb, _tag ) do { \ + PBLOCK_ASSERT_OP( _pb, _tag ); \ + assert( (_pb)->pb_intop ); \ + assert( (_pb)->pb_op == (Operation *)pb->pb_conn->c_pending_ops.stqh_first ); \ + } while (0) + +/* plugin.c */ +LDAP_SLAPI_F (int) slapi_int_register_plugin LDAP_P((Backend *be, Slapi_PBlock *pPB)); +LDAP_SLAPI_F (int) slapi_int_call_plugins LDAP_P((Backend *be, int funcType, Slapi_PBlock * pPB)); +LDAP_SLAPI_F (int) slapi_int_get_plugins LDAP_P((Backend *be, int functype, SLAPI_FUNC **ppFuncPtrs)); +LDAP_SLAPI_F (int) slapi_int_register_extop LDAP_P((Backend *pBE, ExtendedOp **opList, Slapi_PBlock *pPB)); +LDAP_SLAPI_F (int) slapi_int_get_extop_plugin LDAP_P((struct berval *reqoid, SLAPI_FUNC *pFuncAddr )); +LDAP_SLAPI_F (struct berval *) slapi_int_get_supported_extop LDAP_P(( int )); +LDAP_SLAPI_F (int) slapi_int_read_config LDAP_P((Backend *be, const char *fname, int lineno, + int argc, char **argv )); +LDAP_SLAPI_F (void) slapi_int_plugin_unparse LDAP_P((Backend *be, BerVarray *out )); +LDAP_SLAPI_F (int) slapi_int_initialize LDAP_P((void)); + +/* slapi_ext.c */ +LDAP_SLAPI_F (int) slapi_int_init_object_extensions LDAP_P((void)); +LDAP_SLAPI_F (int) slapi_int_free_object_extensions LDAP_P((int objecttype, void *object)); +LDAP_SLAPI_F (int) slapi_int_create_object_extensions LDAP_P((int objecttype, void *object)); +LDAP_SLAPI_F (int) slapi_int_clear_object_extensions LDAP_P((int objecttype, void *object)); + +/* slapi_overlay.c */ +LDAP_SLAPI_F (int) slapi_over_is_inst LDAP_P((BackendDB *)); +LDAP_SLAPI_F (int) slapi_over_config LDAP_P((BackendDB *)); LDAP_END_DECL diff --git a/servers/slapd/slapi/slapi.h b/servers/slapd/slapi/slapi.h index 45c8aea68f..94f59226bc 100644 --- a/servers/slapd/slapi/slapi.h +++ b/servers/slapd/slapi/slapi.h @@ -25,8 +25,6 @@ #ifndef _SLAPI_H #define _SLAPI_H -#include "ibm_pblock_params.h" - LDAP_BEGIN_DECL /* @@ -35,7 +33,7 @@ LDAP_BEGIN_DECL #define slapi_entry slap_entry #define slapi_attr slap_attr #define slapi_value berval -#define slapi_valueset berval* +#define slapi_valueset berval * #define slapi_filter slap_filter LDAP_END_DECL @@ -44,38 +42,14 @@ LDAP_END_DECL LDAP_BEGIN_DECL -/* - * Was: slapi_common.h - */ - -/* a little naif ... */ -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#if 0 /* unused (yet?) */ -#define dn_normalize_case dn_normalize -#define SLAPD_NO_MEMORY 7 -#define ANYBODY_STRING "CN=ANYBODY" - -extern int slap_debug; - -extern int dn_check(char *, int *); +#define SLAPI_OVERLAY_NAME "slapi" -typedef struct strlist { - char *string; - struct strlist *next; -} StrList; -#endif +#define SLAPI_OPERATION_PBLOCK(_op) ((_op)->o_callback->sc_private) +#define SLAPI_CONNECTION_PBLOCK(_conn) ((_conn)->c_pb); +#define SLAPI_BACKEND_PBLOCK(_be) ((_be)->be_pb) -/* - * Was: slapi_utils.h - */ -typedef struct _Audit_record Audit_record; +#define SLAPI_OPERATION_EXTENSIONS(_op) ((_op)->o_hdr->oh_extensions) +#define SLAPI_CONNECTION_EXTENSIONS(_conn) ((_conn)->c_extensions) #define SLAPI_CONTROL_MANAGEDSAIT_OID LDAP_CONTROL_MANAGEDSAIT #define SLAPI_CONTROL_SORTEDSEARCH_OID LDAP_CONTROL_SORTREQUEST @@ -83,11 +57,6 @@ typedef struct _Audit_record Audit_record; typedef int (*SLAPI_FUNC)( Slapi_PBlock *pb ); -#if 0 /* unused (yet?) */ -#define DOMAIN "Domain" -#define TCPIPPATH "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters" -#endif - typedef struct _slapi_control { int s_ctrl_num; char **s_ctrl_oids; @@ -103,15 +72,9 @@ typedef struct _ExtendedOp { /* Computed attribute support */ struct _computed_attr_context { - /* slap_send_search_entry() argblock */ Slapi_PBlock *cac_pb; - AttributeName *cac_attrs; - int cac_attrsonly : 1; - int cac_userattrs : 1; - int cac_opattrs : 1; - AccessControlState cac_acl_state; - /* private data */ - void *cac_private; + Operation *cac_op; + void *cac_private; }; /* for slapi_attr_type_cmp() */ @@ -125,6 +88,18 @@ typedef enum slapi_extension_e { SLAPI_X_EXT_MAX = 2 } slapi_extension_t; +struct slapi_dn { + unsigned char flag; + struct berval dn; + struct berval ndn; +}; + +struct slapi_rdn { + unsigned char flag; + struct berval bv; + LDAPRDN rdn; +}; + /* * Was: slapi_pblock.h */ @@ -143,12 +118,24 @@ typedef enum slapi_pblock_class_e { #define PBLOCK_ERROR (-1) #define PBLOCK_MAX_PARAMS 100 +union slapi_pblock_value { + int pv_integer; + long pv_long_integer; + void *pv_pointer; + int (*pv_function_pointer)(); +}; + struct slapi_pblock { - ldap_pvt_thread_mutex_t pblockMutex; - int ckParams; - int numParams; - int curParams[PBLOCK_MAX_PARAMS]; - void *curVals[PBLOCK_MAX_PARAMS]; + ldap_pvt_thread_mutex_t pb_mutex; + int pb_nParams; + int pb_params[PBLOCK_MAX_PARAMS]; + union slapi_pblock_value pb_values[PBLOCK_MAX_PARAMS]; + /* native types */ + Connection *pb_conn; + Operation *pb_op; + SlapReply *pb_rs; + int pb_intop; + char pb_textbuf[ SLAP_TEXT_BUFLEN ]; }; #endif /* !NO_PBLOCK_CLASS */ @@ -157,355 +144,24 @@ struct slapi_pblock { * Was: plugin.h */ -#define SLAPI_PLUGIN_IS_POST_FN(x) ((x) >= SLAPI_PLUGIN_POST_BIND_FN && (x) <= SLAPI_PLUGIN_POST_RESULT_FN) - -/* - * Was: slapi_cl.h - */ - -#if 0 -#define TIME_SIZE 20 -#define OBJECTCLASS "objectclass" -#define TOP "top" -#define CHANGE_TIME "changetime" -#define CHANGE_TYPE "changetype" -#define CHANGE_TARGETDN "targetdn" -#define CHANGES "changes" -#define CHANGE_NUMBER "changenumber" -/* - * FIXME: I get complaints like "ADD" being redefined - first definition - * being in "/usr/include/arpa/nameser.h:552" - */ -#undef ADD -#define ADD "add: " -#define ADDLEN 5 -#define DEL "delete: " -#define DELLEN 8 -#define REPLACE "replace: " -#define REPLEN 9 -#define MOD "modify" -#define MODRDN "modrdn" -#define CHANGE_LOGENTRY "changelogentry" -#define IBM_CHANGE_LOGENTRY "ibm-changelog" -#define CL_NEWRDN "newrdn" -#define CL_DELRDN "deleteoldrdn" -#define CHANGE_INITIATOR "ibm-changeInitiatorsName" - -extern void slapi_register_changelog_suffix(char *suffix); -extern char **slapi_get_changelog_suffixes(); -extern void slapi_update_changelog_counters(long curNum, long numEntries); -extern char *slapi_get_cl_firstNum(); -extern char *slapi_get_cl_lastNum(); -extern int slapi_add_to_changelog(Slapi_Entry *ent, char *suffix, char *chNum, Operation* op); -extern int slapi_delete_changelog(char *dn, char *suffix, char *chNum, Operation* op); -extern int slapi_modify_changelog(char *dn,LDAPMod *mods,char *suffix, char *chNum, Operation* op); -extern int slapi_modifyrdn_changelog(char *olddn, char *newRdn, int delRdn, char *suffix, char *chNum, Operation* op); -extern Backend * slapi_cl_get_be(char *dn); -#endif - +#define SLAPI_PLUGIN_IS_POST_FN(x) ((x) >= SLAPI_PLUGIN_POST_BIND_FN && (x) <= SLAPI_PLUGIN_BE_POST_DELETE_FN) -/* - * Attribute flags returned by slapi_attr_get_flags() - */ -#define SLAPI_ATTR_FLAG_SINGLE 0x0001 -#define SLAPI_ATTR_FLAG_OPATTR 0x0002 -#define SLAPI_ATTR_FLAG_READONLY 0x0004 -#define SLAPI_ATTR_FLAG_STD_ATTR SLAPI_ATTR_FLAG_READONLY -#define SLAPI_ATTR_FLAG_OBSOLETE 0x0040 -#define SLAPI_ATTR_FLAG_COLLECTIVE 0x0080 -#define SLAPI_ATTR_FLAG_NOUSERMOD 0x0100 - -/* - * ACL levels - */ -#define SLAPI_ACL_COMPARE 0x01 -#define SLAPI_ACL_SEARCH 0x02 -#define SLAPI_ACL_READ 0x04 -#define SLAPI_ACL_WRITE 0x08 -#define SLAPI_ACL_DELETE 0x10 -#define SLAPI_ACL_ADD 0x20 -#define SLAPI_ACL_SELF 0x40 -#define SLAPI_ACL_PROXY 0x80 -#define SLAPI_ACL_ALL 0x7f - -/* - * Plugin types universally supported by SLAPI - * implementations - */ -#define SLAPI_PLUGIN_DATABASE 1 -#define SLAPI_PLUGIN_EXTENDEDOP 2 -#define SLAPI_PLUGIN_PREOPERATION 3 -#define SLAPI_PLUGIN_POSTOPERATION 4 -#define SLAPI_PLUGIN_MATCHINGRULE 5 -#define SLAPI_PLUGIN_SYNTAX 6 -/* XXX this is SLAPI_PLUGIN_ACL in SunDS */ -#define SLAPI_PLUGIN_AUDIT 7 -/* - * The following plugin types are reserved for future - * Sun ONE DS compatability. - */ -#define SLAPI_PLUGIN_BEPREOPERATION 8 -#define SLAPI_PLUGIN_BEPOSTOPERATION 9 -#define SLAPI_PLUGIN_ENTRY 10 -#define SLAPI_PLUGIN_TYPE_OBJECT 11 -#define SLAPI_PLUGIN_INTERNAL_PREOPERATION 12 -#define SLAPI_PLUGIN_INTERNAL_POSTOPERATION 13 -#define SLAPI_PLUGIN_PWD_STORAGE_SCHEME 14 -#define SLAPI_PLUGIN_VATTR_SP 15 -#define SLAPI_PLUGIN_REVER_PWD_STORAGE_SCHEME 16 - -#define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1 -#define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2 - -#define SLAPI_BIND_SUCCESS 0 -#define SLAPI_BIND_FAIL 2 -#define SLAPI_BIND_ANONYMOUS 3 - -#define SLAPI_BACKEND 130 -#define SLAPI_CONNECTION 131 -#define SLAPI_OPERATION 132 -#define SLAPI_REQUESTOR_ISROOT 133 -#define SLAPI_BE_MONITORDN 134 -#define SLAPI_BE_TYPE 135 -#define SLAPI_BE_READONLY 136 -#define SLAPI_BE_LASTMOD 137 -#define SLAPI_OPERATION_PARAMETERS 138 -#define SLAPI_CONN_ID 139 - -#define SLAPI_OPINITIATED_TIME 140 -#define SLAPI_REQUESTOR_DN 141 -#define SLAPI_REQUESTOR_ISUPDATEDN 142 -#define SLAPI_IS_REPLICATED_OPERATION SLAPI_REQUESTOR_ISUPDATEDN -#define SLAPI_CONN_DN 143 -#define SLAPI_CONN_AUTHTYPE 144 -#define SLAPI_CONN_CLIENTIP 145 -#define SLAPI_CONN_SERVERIP 146 -#define SLAPI_X_CONN_CLIENTPATH 1300 -#define SLAPI_X_CONN_SERVERPATH 1301 -#define SLAPI_X_CONN_IS_UDP 1302 -#define SLAPI_X_CONN_SSF 1303 -#define SLAPI_X_CONN_SASL_CONTEXT 1304 - -#define SLAPI_X_CONFIG_ARGV 1400 - -#define SLAPD_AUTH_NONE "none" -#define SLAPD_AUTH_SIMPLE "simple" -#define SLAPD_AUTH_SSL "SSL" -#define SLAPD_AUTH_SASL "SASL " - -#define SLAPI_PLUGIN 3 -#define SLAPI_PLUGIN_PRIVATE 4 -#define SLAPI_PLUGIN_TYPE 5 -#define SLAPI_PLUGIN_ARGV 6 -#define SLAPI_PLUGIN_ARGC 7 -#define SLAPI_PLUGIN_VERSION 8 - -#define SLAPI_PLUGIN_OPRETURN 9 -#define SLAPI_PLUGIN_OBJECT 10 -#define SLAPI_PLUGIN_DESTROY_FN 11 - -#define SLAPI_PLUGIN_DESCRIPTION 12 - -#define SLAPI_PLUGIN_INTOP_RESULT 15 -#define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16 -#define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17 - -#define SLAPI_PLUGIN_DB_BIND_FN 200 -#define SLAPI_PLUGIN_DB_UNBIND_FN 201 -#define SLAPI_PLUGIN_DB_SEARCH_FN 202 -#define SLAPI_PLUGIN_DB_COMPARE_FN 203 -#define SLAPI_PLUGIN_DB_MODIFY_FN 204 -#define SLAPI_PLUGIN_DB_MODRDN_FN 205 -#define SLAPI_PLUGIN_DB_ADD_FN 206 -#define SLAPI_PLUGIN_DB_DELETE_FN 207 -#define SLAPI_PLUGIN_DB_ABANDON_FN 208 -#define SLAPI_PLUGIN_DB_CONFIG_FN 209 -#define SLAPI_PLUGIN_CLOSE_FN 210 -#define SLAPI_PLUGIN_DB_FLUSH_FN 211 -#define SLAPI_PLUGIN_START_FN 212 -#define SLAPI_PLUGIN_DB_SEQ_FN 213 -#define SLAPI_PLUGIN_DB_ENTRY_FN 214 -#define SLAPI_PLUGIN_DB_REFERRAL_FN 215 -#define SLAPI_PLUGIN_DB_RESULT_FN 216 -#define SLAPI_PLUGIN_DB_LDIF2DB_FN 217 -#define SLAPI_PLUGIN_DB_DB2LDIF_FN 218 -#define SLAPI_PLUGIN_DB_BEGIN_FN 219 -#define SLAPI_PLUGIN_DB_COMMIT_FN 220 -#define SLAPI_PLUGIN_DB_ABORT_FN 221 -#define SLAPI_PLUGIN_DB_ARCHIVE2DB_FN 222 -#define SLAPI_PLUGIN_DB_DB2ARCHIVE_FN 223 -#define SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN 224 -#define SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN 225 -#define SLAPI_PLUGIN_DB_SIZE_FN 226 -#define SLAPI_PLUGIN_DB_TEST_FN 227 -#define SLAPI_PLUGIN_DB_NO_ACL 250 - -#define SLAPI_PLUGIN_EXT_OP_FN 300 -#define SLAPI_PLUGIN_EXT_OP_OIDLIST 301 -#define SLAPI_PLUGIN_PRE_BIND_FN 401 -#define SLAPI_PLUGIN_PRE_UNBIND_FN 402 -#define SLAPI_PLUGIN_PRE_SEARCH_FN 403 -#define SLAPI_PLUGIN_PRE_COMPARE_FN 404 -#define SLAPI_PLUGIN_PRE_MODIFY_FN 405 -#define SLAPI_PLUGIN_PRE_MODRDN_FN 406 -#define SLAPI_PLUGIN_PRE_ADD_FN 407 -#define SLAPI_PLUGIN_PRE_DELETE_FN 408 -#define SLAPI_PLUGIN_PRE_ABANDON_FN 409 -#define SLAPI_PLUGIN_PRE_ENTRY_FN 410 -#define SLAPI_PLUGIN_PRE_REFERRAL_FN 411 -#define SLAPI_PLUGIN_PRE_RESULT_FN 412 -#define SLAPI_PLUGIN_POST_BIND_FN 501 -#define SLAPI_PLUGIN_POST_UNBIND_FN 502 -#define SLAPI_PLUGIN_POST_SEARCH_FN 503 -#define SLAPI_PLUGIN_POST_COMPARE_FN 504 -#define SLAPI_PLUGIN_POST_MODIFY_FN 505 -#define SLAPI_PLUGIN_POST_MODRDN_FN 506 -#define SLAPI_PLUGIN_POST_ADD_FN 507 -#define SLAPI_PLUGIN_POST_DELETE_FN 508 -#define SLAPI_PLUGIN_POST_ABANDON_FN 509 -#define SLAPI_PLUGIN_POST_ENTRY_FN 510 -#define SLAPI_PLUGIN_POST_REFERRAL_FN 511 -#define SLAPI_PLUGIN_POST_RESULT_FN 512 - -#define SLAPI_OPERATION_TYPE 590 - -#define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600 -#define SLAPI_PLUGIN_MR_INDEXER_CREATE_FN 601 -#define SLAPI_PLUGIN_MR_FILTER_MATCH_FN 602 -#define SLAPI_PLUGIN_MR_FILTER_INDEX_FN 603 -#define SLAPI_PLUGIN_MR_FILTER_RESET_FN 604 -#define SLAPI_PLUGIN_MR_INDEX_FN 605 -#define SLAPI_PLUGIN_MR_OID 610 -#define SLAPI_PLUGIN_MR_TYPE 611 -#define SLAPI_PLUGIN_MR_VALUE 612 -#define SLAPI_PLUGIN_MR_VALUES 613 -#define SLAPI_PLUGIN_MR_KEYS 614 -#define SLAPI_PLUGIN_MR_FILTER_REUSABLE 615 -#define SLAPI_PLUGIN_MR_QUERY_OPERATOR 616 -#define SLAPI_PLUGIN_MR_USAGE 617 - -#define SLAPI_OP_LESS 1 -#define SLAPI_OP_LESS_OR_EQUAL 2 -#define SLAPI_OP_EQUAL 3 -#define SLAPI_OP_GREATER_OR_EQUAL 4 -#define SLAPI_OP_GREATER 5 -#define SLAPI_OP_SUBSTRING 6 - -#define SLAPI_PLUGIN_MR_USAGE_INDEX 0 -#define SLAPI_PLUGIN_MR_USAGE_SORT 1 - -#define SLAPI_MATCHINGRULE_NAME 1 -#define SLAPI_MATCHINGRULE_OID 2 -#define SLAPI_MATCHINGRULE_DESC 3 -#define SLAPI_MATCHINGRULE_SYNTAX 4 -#define SLAPI_MATCHINGRULE_OBSOLETE 5 - -#define SLAPI_PLUGIN_SYNTAX_FILTER_AVA 700 -#define SLAPI_PLUGIN_SYNTAX_FILTER_SUB 701 -#define SLAPI_PLUGIN_SYNTAX_VALUES2KEYS 702 -#define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA 703 -#define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB 704 -#define SLAPI_PLUGIN_SYNTAX_NAMES 705 -#define SLAPI_PLUGIN_SYNTAX_OID 706 -#define SLAPI_PLUGIN_SYNTAX_FLAGS 707 -#define SLAPI_PLUGIN_SYNTAX_COMPARE 708 - -#define SLAPI_PLUGIN_ACL_INIT 730 -#define SLAPI_PLUGIN_ACL_SYNTAX_CHECK 731 -#define SLAPI_PLUGIN_ACL_ALLOW_ACCESS 732 -#define SLAPI_PLUGIN_ACL_MODS_ALLOWED 733 -#define SLAPI_PLUGIN_ACL_MODS_UPDATE 734 - -#define SLAPI_OPERATION_AUTHTYPE 741 -#define SLAPI_OPERATION_ID 742 -#define SLAPI_CONN_CERT 743 -#define SLAPI_CONN_AUTHMETHOD 746 - -#define SLAPI_RESULT_CODE 881 -#define SLAPI_RESULT_TEXT 882 -#define SLAPI_RESULT_MATCHED 883 - -#define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1 -#define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2 - -#define SLAPI_PLUGIN_AUDIT_DATA 1100 -#define SLAPI_PLUGIN_AUDIT_FN 1101 - -/* DS 5.x Computed Attribute Callbacks (not exposed) */ -#define SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN 1200 -#define SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN 1201 - -#define SLAPI_X_PLUGIN_PRE_GROUP_FN 1202 -#define SLAPI_X_PLUGIN_POST_GROUP_FN 1203 - -/* backend_group extension */ -#define SLAPI_X_GROUP_ENTRY 1250 /* e */ -#define SLAPI_X_GROUP_ATTRIBUTE 1251 /* group_at */ -#define SLAPI_X_GROUP_OPERATION_DN 1252 /* op_ndn */ -#define SLAPI_X_GROUP_TARGET_ENTRY 1253 /* target */ - -#define SLAPI_MANAGEDSAIT 1000 - -#define SLAPI_CONFIG_FILENAME 40 -#define SLAPI_CONFIG_LINENO 41 -#define SLAPI_CONFIG_ARGC 42 -#define SLAPI_CONFIG_ARGV 43 - -#define SLAPI_TARGET_DN 50 -#define SLAPI_REQCONTROLS 51 +#define SLAPI_IBM_PBLOCK -3 #define SLAPI_ENTRY_PRE_OP 52 #define SLAPI_ENTRY_POST_OP 53 -#define SLAPI_RESCONTROLS 55 /* This is the spelling in the SunOne 5.2 docs */ #define SLAPI_RES_CONTROLS SLAPI_RESCONTROLS -#define SLAPI_ADD_RESCONTROL 56 - -#define SLAPI_ADD_TARGET SLAPI_TARGET_DN -#define SLAPI_ADD_ENTRY 60 - -#define SLAPI_BIND_TARGET SLAPI_TARGET_DN -#define SLAPI_BIND_METHOD 70 -#define SLAPI_BIND_CREDENTIALS 71 -#define SLAPI_BIND_SASLMECHANISM 72 -#define SLAPI_BIND_RET_SASLCREDS 73 - -#define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN -#define SLAPI_COMPARE_TYPE 80 -#define SLAPI_COMPARE_VALUE 81 - -#define SLAPI_DELETE_TARGET SLAPI_TARGET_DN - -#define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN -#define SLAPI_MODIFY_MODS 90 - -#define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN -#define SLAPI_MODRDN_NEWRDN 100 -#define SLAPI_MODRDN_DELOLDRDN 101 -#define SLAPI_MODRDN_NEWSUPERIOR 102 - -#define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN -#define SLAPI_SEARCH_SCOPE 110 -#define SLAPI_SEARCH_DEREF 111 -#define SLAPI_SEARCH_SIZELIMIT 112 -#define SLAPI_SEARCH_TIMELIMIT 113 -#define SLAPI_SEARCH_FILTER 114 -#define SLAPI_SEARCH_STRFILTER 115 -#define SLAPI_SEARCH_ATTRS 116 -#define SLAPI_SEARCH_ATTRSONLY 117 #define SLAPI_ABANDON_MSGID 120 +#define SLAPI_OPERATION_PARAMETERS 138 + #define SLAPI_SEQ_TYPE 150 #define SLAPI_SEQ_ATTRNAME 151 #define SLAPI_SEQ_VAL 152 -#define SLAPI_EXT_OP_REQ_OID 160 -#define SLAPI_EXT_OP_REQ_VALUE 161 -#define SLAPI_EXT_OP_RET_OID 162 -#define SLAPI_EXT_OP_RET_VALUE 163 - #define SLAPI_MR_FILTER_ENTRY 170 #define SLAPI_MR_FILTER_TYPE 171 #define SLAPI_MR_FILTER_VALUE 172 @@ -517,50 +173,31 @@ extern Backend * slapi_cl_get_be(char *dn); #define SLAPI_DB2LDIF_PRINTKEY 183 -#define SLAPI_PARENT_TXN 190 -#define SLAPI_TXN 191 - -#define SLAPI_SEARCH_RESULT_SET 193 -#define SLAPI_SEARCH_RESULT_ENTRY 194 -#define SLAPI_NENTRIES 195 -#define SLAPI_SEARCH_REFERRALS 196 - #define SLAPI_CHANGENUMBER 197 #define SLAPI_LOG_OPERATION 198 #define SLAPI_DBSIZE 199 -#define SLAPI_LOG_FATAL 0 -#define SLAPI_LOG_TRACE 1 -#define SLAPI_LOG_PACKETS 2 -#define SLAPI_LOG_ARGS 3 -#define SLAPI_LOG_CONNS 4 -#define SLAPI_LOG_BER 5 -#define SLAPI_LOG_FILTER 6 -#define SLAPI_LOG_CONFIG 7 -#define SLAPI_LOG_ACL 8 -#define SLAPI_LOG_SHELL 9 -#define SLAPI_LOG_PARSE 10 -#define SLAPI_LOG_HOUSE 11 -#define SLAPI_LOG_REPL 12 -#define SLAPI_LOG_CACHE 13 -#define SLAPI_LOG_PLUGIN 14 - -#define SLAPI_OPERATION_BIND 0x00000001L -#define SLAPI_OPERATION_UNBIND 0x00000002L -#define SLAPI_OPERATION_SEARCH 0x00000004L -#define SLAPI_OPERATION_MODIFY 0x00000008L -#define SLAPI_OPERATION_ADD 0x00000010L -#define SLAPI_OPERATION_DELETE 0x00000020L -#define SLAPI_OPERATION_MODDN 0x00000040L -#define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN -#define SLAPI_OPERATION_COMPARE 0x00000080L -#define SLAPI_OPERATION_ABANDON 0x00000100L -#define SLAPI_OPERATION_EXTENDED 0x00000200L -#define SLAPI_OPERATION_ANY 0xFFFFFFFFL -#define SLAPI_OPERATION_NONE 0x00000000L +#define SLAPI_PLUGIN_DB_TEST_FN 227 +#define SLAPI_PLUGIN_DB_NO_ACL 250 -LDAP_END_DECL +/* OpenLDAP private parametrs */ +#define SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN 1200 +#define SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN 1201 + +#define SLAPI_X_CONFIG_ARGV 1400 +#define SLAPI_X_INTOP_FLAGS 1401 +#define SLAPI_X_INTOP_RESULT_CALLBACK 1402 +#define SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK 1403 +#define SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK 1404 +#define SLAPI_X_INTOP_CALLBACK_DATA 1405 +#define SLAPI_X_OLD_RESCONTROLS 1406 + +LDAP_SLAPI_V (ldap_pvt_thread_mutex_t) slapi_hn_mutex; +LDAP_SLAPI_V (ldap_pvt_thread_mutex_t) slapi_time_mutex; +LDAP_SLAPI_V (ldap_pvt_thread_mutex_t) slapi_printmessage_mutex; +LDAP_SLAPI_V (char *) slapi_log_file; +LDAP_SLAPI_V (int) slapi_log_level; #include "proto-slapi.h" diff --git a/servers/slapd/slapi/slapi_dn.c b/servers/slapd/slapi/slapi_dn.c new file mode 100644 index 0000000000..4cb4b361a0 --- /dev/null +++ b/servers/slapd/slapi/slapi_dn.c @@ -0,0 +1,665 @@ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 2005 The OpenLDAP Foundation. + * 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 + * . + */ +/* ACKNOWLEDGEMENTS: + * This work was initially developed by Luke Howard for inclusion + * in OpenLDAP Software. + */ + +#include "portable.h" + +#include +#include +#include +#include +#include + +#include +#include + +#ifdef LDAP_SLAPI +#define FLAG_DN 0x1 +#define FLAG_NDN 0x2 + +void slapi_sdn_init( Slapi_DN *sdn ) +{ + sdn->flag = 0; + BER_BVZERO( &sdn->dn ); + BER_BVZERO( &sdn->ndn ); +} + +Slapi_DN *slapi_sdn_new( void ) +{ + Slapi_DN *sdn; + + sdn = (Slapi_DN *)slapi_ch_malloc( sizeof(*sdn )); + slapi_sdn_init( sdn ); + + return sdn; +} + +void slapi_sdn_done( Slapi_DN *sdn ) +{ + if ( sdn == NULL ) + return; + + if ( sdn->flag & FLAG_DN ) { + slapi_ch_free_string( &sdn->dn.bv_val ); + } + if ( sdn->flag & FLAG_NDN ) { + slapi_ch_free_string( &sdn->ndn.bv_val ); + } + + slapi_sdn_init( sdn ); +} + +void slapi_sdn_free( Slapi_DN **sdn ) +{ + slapi_sdn_done( *sdn ); + slapi_ch_free( (void **)sdn ); +} + +const char *slapi_sdn_get_dn( const Slapi_DN *sdn ) +{ + if ( !BER_BVISNULL( &sdn->dn ) ) + return sdn->dn.bv_val; + else + return sdn->ndn.bv_val; +} + +const char *slapi_sdn_get_ndn( const Slapi_DN *sdn ) +{ + if ( BER_BVISNULL( &sdn->ndn ) ) { + dnNormalize( 0, NULL, NULL, + (struct berval *)&sdn->dn, (struct berval *)&sdn->ndn, NULL ); + ((Slapi_DN *)sdn)->flag |= FLAG_NDN; + } + + return sdn->ndn.bv_val; +} + +Slapi_DN *slapi_sdn_new_dn_byval( const char *dn ) +{ + Slapi_DN *sdn; + + sdn = slapi_sdn_new(); + return slapi_sdn_set_dn_byval( sdn, dn ); +} + +Slapi_DN *slapi_sdn_new_ndn_byval( const char *ndn ) +{ + Slapi_DN *sdn; + + sdn = slapi_sdn_new(); + return slapi_sdn_set_ndn_byval( sdn, ndn ); +} + +Slapi_DN *slapi_sdn_new_dn_byref( const char *dn ) +{ + Slapi_DN *sdn; + + sdn = slapi_sdn_new(); + return slapi_sdn_set_dn_byref( sdn, dn ); +} + +Slapi_DN *slapi_sdn_new_ndn_byref( const char *ndn ) +{ + Slapi_DN *sdn; + + sdn = slapi_sdn_new(); + return slapi_sdn_set_ndn_byref( sdn, ndn ); +} + +Slapi_DN *slapi_sdn_new_dn_passin( const char *dn ) +{ + Slapi_DN *sdn; + + sdn = slapi_sdn_new(); + return slapi_sdn_set_dn_passin( sdn, dn ); +} + +Slapi_DN *slapi_sdn_set_dn_byval( Slapi_DN *sdn, const char *dn ) +{ + if ( sdn == NULL ) { + return NULL; + } + + slapi_sdn_done( sdn ); + if ( dn != NULL ) { + sdn->dn.bv_val = slapi_ch_strdup( dn ); + sdn->dn.bv_len = strlen( dn ); + } + sdn->flag |= FLAG_DN; + + return sdn; +} + +Slapi_DN *slapi_sdn_set_dn_byref( Slapi_DN *sdn, const char *dn ) +{ + if ( sdn == NULL ) + return NULL; + + slapi_sdn_done( sdn ); + if ( dn != NULL ) { + sdn->dn.bv_val = (char *)dn; + sdn->dn.bv_len = strlen( dn ); + } + + return sdn; +} + +Slapi_DN *slapi_sdn_set_dn_passin( Slapi_DN *sdn, const char *dn ) +{ + if ( sdn == NULL ) + return NULL; + + slapi_sdn_set_dn_byref( sdn, dn ); + sdn->flag |= FLAG_DN; + + return sdn; +} + +Slapi_DN *slapi_sdn_set_ndn_byval( Slapi_DN *sdn, const char *ndn ) +{ + if ( sdn == NULL ) { + return NULL; + } + + slapi_sdn_done( sdn ); + if ( ndn != NULL ) { + sdn->ndn.bv_val = slapi_ch_strdup( ndn ); + sdn->ndn.bv_len = strlen( ndn ); + } + sdn->flag |= FLAG_NDN; + + return sdn; +} + +Slapi_DN *slapi_sdn_set_ndn_byref( Slapi_DN *sdn, const char *ndn ) +{ + if ( sdn == NULL ) + return NULL; + + slapi_sdn_done( sdn ); + if ( ndn != NULL ) { + sdn->ndn.bv_val = (char *)ndn; + sdn->ndn.bv_len = strlen( ndn ); + } + + return sdn; +} + +Slapi_DN *slapi_sdn_set_ndn_passin( Slapi_DN *sdn, const char *ndn ) +{ + if ( sdn == NULL ) + return NULL; + + slapi_sdn_set_ndn_byref( sdn, ndn ); + sdn->flag |= FLAG_NDN; + + return sdn; +} + +void slapi_sdn_get_parent( const Slapi_DN *sdn, Slapi_DN *sdn_parent ) +{ + struct berval parent_dn; + + dnParent( (struct berval *)&sdn->dn, &parent_dn ); + + slapi_sdn_set_dn_byval( sdn_parent, parent_dn.bv_val ); +} + +void slapi_sdn_get_backend_parent( const Slapi_DN *sdn, + Slapi_DN *sdn_parent, + const Slapi_Backend *backend ) +{ + slapi_sdn_get_ndn( sdn ); + + if ( backend == NULL || + be_issuffix( (Slapi_Backend *)backend, (struct berval *)&sdn->ndn ) == 0 ) { + slapi_sdn_get_parent( sdn, sdn_parent ); + } + +} + +Slapi_DN * slapi_sdn_dup( const Slapi_DN *sdn ) +{ + Slapi_DN *new_sdn; + + new_sdn = slapi_sdn_new(); + slapi_sdn_copy( sdn, new_sdn ); + + return new_sdn; +} + +void slapi_sdn_copy( const Slapi_DN *from, Slapi_DN *to ) +{ + slapi_sdn_set_dn_byval( to, from->dn.bv_val ); +} + +int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 ) +{ + int match = -1; + + slapi_sdn_get_ndn( sdn1 ); + slapi_sdn_get_ndn( sdn2 ); + + dnMatch( &match, 0, slap_schema.si_syn_distinguishedName, NULL, + (struct berval *)&sdn1->ndn, (void *)&sdn2->ndn ); + + return match; +} + +int slapi_sdn_isempty( const Slapi_DN *sdn) +{ + return ( BER_BVISEMPTY( &sdn->dn ) ); +} + +int slapi_sdn_issuffix( const Slapi_DN *sdn, const Slapi_DN *suffix_sdn ) +{ + slapi_sdn_get_ndn( sdn ); + slapi_sdn_get_ndn( suffix_sdn ); + + return dnIsSuffix( &sdn->ndn, &suffix_sdn->ndn ); +} + +int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child ) +{ + Slapi_DN child_parent; + + slapi_sdn_get_ndn( child ); + + slapi_sdn_init( &child_parent ); + dnParent( (struct berval *)&child->ndn, &child_parent.ndn ); + + return ( slapi_sdn_compare( parent, &child_parent ) == 0 ); +} + +int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child ) +{ + Slapi_DN child_grandparent; + + slapi_sdn_get_ndn( child ); + + slapi_sdn_init( &child_grandparent ); + dnParent( (struct berval *)&child->ndn, &child_grandparent.ndn ); + if ( child_grandparent.ndn.bv_len == 0 ) { + return 0; + } + + dnParent( &child_grandparent.ndn, &child_grandparent.ndn ); + + return ( slapi_sdn_compare( parent, &child_grandparent ) == 0 ); +} + +int slapi_sdn_get_ndn_len( const Slapi_DN *sdn ) +{ + slapi_sdn_get_ndn( sdn ); + + return sdn->ndn.bv_len; +} + +int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope ) +{ + int rc; + + switch ( scope ) { + case LDAP_SCOPE_BASE: + rc = ( slapi_sdn_compare( dn, base ) == 0 ); + break; + case LDAP_SCOPE_ONELEVEL: + rc = slapi_sdn_isparent( base, dn ); + break; + case LDAP_SCOPE_SUBTREE: + rc = slapi_sdn_issuffix( dn, base ); + break; + default: + rc = 0; + break; + } + + return rc; +} + +void slapi_rdn_init( Slapi_RDN *rdn ) +{ + rdn->flag = 0; + BER_BVZERO( &rdn->bv ); + rdn->rdn = NULL; +} + +Slapi_RDN *slapi_rdn_new( void ) +{ + Slapi_RDN *rdn; + + rdn = (Slapi_RDN *)slapi_ch_malloc( sizeof(*rdn )); + slapi_rdn_init( rdn ); + + return rdn; +} + +Slapi_RDN *slapi_rdn_new_dn( const char *dn ) +{ + Slapi_RDN *rdn; + + rdn = slapi_rdn_new(); + slapi_rdn_init_dn( rdn, dn ); + return rdn; +} + +Slapi_RDN *slapi_rdn_new_sdn( const Slapi_DN *sdn ) +{ + return slapi_rdn_new_dn( slapi_sdn_get_dn( sdn ) ); +} + +Slapi_RDN *slapi_rdn_new_rdn( const Slapi_RDN *fromrdn ) +{ + return slapi_rdn_new_dn( fromrdn->bv.bv_val ); +} + +void slapi_rdn_init_dn( Slapi_RDN *rdn, const char *dn ) +{ + slapi_rdn_init( rdn ); + slapi_rdn_set_dn( rdn, dn ); +} + +void slapi_rdn_init_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn ) +{ + slapi_rdn_init( rdn ); + slapi_rdn_set_sdn( rdn, sdn ); +} + +void slapi_rdn_init_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn ) +{ + slapi_rdn_init( rdn ); + slapi_rdn_set_rdn( rdn, fromrdn ); +} + +void slapi_rdn_set_dn( Slapi_RDN *rdn, const char *dn ) +{ + struct berval bv; + + slapi_rdn_done( rdn ); + + BER_BVZERO( &bv ); + + if ( dn != NULL ) { + bv.bv_val = (char *)dn; + bv.bv_len = strlen( dn ); + } + + dnExtractRdn( &bv, &rdn->bv, NULL ); + rdn->flag |= FLAG_DN; +} + +void slapi_rdn_set_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn ) +{ + return slapi_rdn_set_dn( rdn, slapi_sdn_get_dn( sdn ) ); +} + +void slapi_rdn_set_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn ) +{ + return slapi_rdn_set_dn( rdn, fromrdn->bv.bv_val ); +} + +void slapi_rdn_free( Slapi_RDN **rdn ) +{ + slapi_rdn_done( *rdn ); + slapi_ch_free( (void **)rdn ); +} + +void slapi_rdn_done( Slapi_RDN *rdn ) +{ + if ( rdn->rdn != NULL ) { + ldap_rdnfree( rdn->rdn ); + rdn->rdn = NULL; + } + slapi_ch_free_string( &rdn->bv.bv_val ); + slapi_rdn_init( rdn ); +} + +const char *slapi_rdn_get_rdn( const Slapi_RDN *rdn ) +{ + return rdn->bv.bv_val; +} + +static int slapi_int_rdn_explode( Slapi_RDN *rdn ) +{ + char *next; + + if ( rdn->rdn != NULL ) { + return LDAP_SUCCESS; + } + + return ldap_bv2rdn( &rdn->bv, &rdn->rdn, &next, LDAP_DN_FORMAT_LDAP ); +} + +static int slapi_int_rdn_implode( Slapi_RDN *rdn ) +{ + struct berval bv; + int rc; + + if ( rdn->rdn == NULL ) { + return LDAP_SUCCESS; + } + + rc = ldap_rdn2bv( rdn->rdn, &bv, LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY ); + if ( rc != LDAP_SUCCESS ) { + return rc; + } + + slapi_ch_free_string( &rdn->bv.bv_val ); + rdn->bv = bv; + + return 0; +} + +int slapi_rdn_get_num_components( Slapi_RDN *rdn ) +{ + int i; + + if ( slapi_int_rdn_explode( rdn ) != LDAP_SUCCESS ) + return 0; + + for ( i = 0; rdn->rdn[i] != NULL; i++ ) + ; + + return i; +} + +int slapi_rdn_get_first( Slapi_RDN *rdn, char **type, char **value ) +{ + return slapi_rdn_get_next( rdn, 0, type, value ); +} + +int slapi_rdn_get_next( Slapi_RDN *rdn, int index, char **type, char **value ) +{ + slapi_int_rdn_explode( rdn ); + + if ( rdn->rdn == NULL || rdn->rdn[index] == NULL ) + return -1; + + *type = rdn->rdn[index]->la_attr.bv_val; + *value = rdn->rdn[index]->la_value.bv_val; + + return index + 1; +} + +int slapi_rdn_get_index( Slapi_RDN *rdn, const char *type, const char *value, size_t length ) +{ + int i, match; + struct berval bv; + AttributeDescription *ad = NULL; + const char *text; + + slapi_int_rdn_explode( rdn ); + + if ( slap_str2ad( type, &ad, &text ) != LDAP_SUCCESS ) { + return -1; + } + + bv.bv_val = (char *)value; + bv.bv_len = length; + + for ( i = 0; rdn->rdn[i] != NULL; i++ ) { + if ( !slapi_attr_types_equivalent( ad->ad_cname.bv_val, type )) + continue; + + if ( value_match( &match, ad, ad->ad_type->sat_equality, 0, + &rdn->rdn[i]->la_value, (void *)&bv, &text ) != LDAP_SUCCESS ) + match = -1; + + if ( match == 0 ) + return i; + } + + return -1; +} + +int slapi_rdn_get_index_attr( Slapi_RDN *rdn, const char *type, char **value ) +{ + int i; + + for ( i = 0; rdn->rdn[i] != NULL; i++ ) { + if ( slapi_attr_types_equivalent( rdn->rdn[i]->la_attr.bv_val, type ) ) { + *value = rdn->rdn[i]->la_value.bv_val; + return i; + } + } + + return -1; +} + +int slapi_rdn_contains( Slapi_RDN *rdn, const char *type, const char *value, size_t length ) +{ + return ( slapi_rdn_get_index( rdn, type, value, length ) != -1 ); +} + +int slapi_rdn_contains_attr( Slapi_RDN *rdn, const char *type, char **value ) +{ + return ( slapi_rdn_get_index_attr( rdn, type, value ) != -1 ); +} + +int slapi_rdn_compare( Slapi_RDN *rdn1, Slapi_RDN *rdn2 ) +{ + struct berval nrdn1 = BER_BVNULL; + struct berval nrdn2 = BER_BVNULL; + int match; + + rdnNormalize( 0, NULL, NULL, (struct berval *)&rdn1->bv, &nrdn1, NULL ); + rdnNormalize( 0, NULL, NULL, (struct berval *)&rdn2->bv, &nrdn2, NULL ); + + if ( rdnMatch( &match, 0, NULL, NULL, &nrdn1, (void *)&nrdn2 ) != LDAP_SUCCESS) { + match = -1; + } + + return match; +} + +int slapi_rdn_isempty( const Slapi_RDN *rdn ) +{ + return ( BER_BVISEMPTY( &rdn->bv ) ); +} + +int slapi_rdn_add( Slapi_RDN *rdn, const char *type, const char *value ) +{ + char *s; + size_t len; + + len = strlen(type) + 1 + strlen( value ); + if ( !BER_BVISEMPTY( &rdn->bv ) ) { + len += 1 + rdn->bv.bv_len; + } + + s = slapi_ch_malloc( len + 1 ); + + if ( BER_BVISEMPTY( &rdn->bv ) ) { + snprintf( s, len + 1, "%s=%s", type, value ); + } else { + snprintf( s, len + 1, "%s=%s+%s", type, value, rdn->bv.bv_val ); + } + + slapi_rdn_done( rdn ); + + rdn->bv.bv_len = len; + rdn->bv.bv_val = s; + + return 1; +} + +int slapi_rdn_remove_index( Slapi_RDN *rdn, int atindex ) +{ + int count, i; + + count = slapi_rdn_get_num_components( rdn ); + + if ( atindex < 0 || atindex >= count ) + return 0; + + if ( rdn->rdn == NULL ) + return 0; + + slapi_ch_free_string( &rdn->rdn[atindex]->la_attr.bv_val ); + slapi_ch_free_string( &rdn->rdn[atindex]->la_value.bv_val ); + + for ( i = atindex; i < count; i++ ) { + rdn->rdn[i] = rdn->rdn[i + 1]; + } + + if ( slapi_int_rdn_implode( rdn ) != LDAP_SUCCESS ) + return 0; + + return 1; +} + +int slapi_rdn_remove( Slapi_RDN *rdn, const char *type, const char *value, size_t length ) +{ + int index = slapi_rdn_get_index( rdn, type, value, length ); + + return slapi_rdn_remove_index( rdn, index ); +} + +int slapi_rdn_remove_attr( Slapi_RDN *rdn, const char *type ) +{ + char *value; + int index = slapi_rdn_get_index_attr( rdn, type, &value ); + + return slapi_rdn_remove_index( rdn, index ); +} + +Slapi_DN *slapi_sdn_add_rdn( Slapi_DN *sdn, const Slapi_RDN *rdn ) +{ + struct berval bv; + + build_new_dn( &bv, &sdn->dn, (struct berval *)&rdn->bv, NULL ); + + slapi_sdn_done( sdn ); + sdn->dn = bv; + + return sdn; +} + +Slapi_DN *slapi_sdn_set_parent( Slapi_DN *sdn, const Slapi_DN *parentdn ) +{ + Slapi_RDN rdn; + + slapi_rdn_init_sdn( &rdn, sdn ); + slapi_sdn_set_dn_byref( sdn, slapi_sdn_get_dn( parentdn ) ); + slapi_sdn_add_rdn( sdn, &rdn ); + slapi_rdn_done( &rdn ); + + return sdn; +} + +#endif /* LDAP_SLAPI */ diff --git a/servers/slapd/slapi/slapi_ext.c b/servers/slapd/slapi/slapi_ext.c index cb1d66e0ec..87a7db15c4 100644 --- a/servers/slapd/slapi/slapi_ext.c +++ b/servers/slapd/slapi/slapi_ext.c @@ -30,10 +30,11 @@ #include #include +#ifdef LDAP_SLAPI + #include #include -#ifdef LDAP_SLAPI /* * Object extensions * @@ -65,7 +66,7 @@ static int get_extension_block(int objecttype, void *object, struct slapi_extens *parent = NULL; break; case SLAPI_X_EXT_OPERATION: - *eblock = ((Operation *)object)->o_extensions; + *eblock = ((Operation *)object)->o_hdr->oh_extensions; *parent = ((Operation *)object)->o_conn; break; default: @@ -130,11 +131,9 @@ static void free_extension(struct slapi_extension_block *eblock, int objecttype, eblock->extensions[extensionhandle] = NULL; } } -#endif /* LDAP_SLAPI */ void *slapi_get_object_extension(int objecttype, void *object, int extensionhandle) { -#ifdef LDAP_SLAPI struct slapi_extension_block *eblock; void *parent; @@ -147,14 +146,10 @@ void *slapi_get_object_extension(int objecttype, void *object, int extensionhand } return NULL; -#else - return NULL; -#endif /* LDAP_SLAPI */ } void slapi_set_object_extension(int objecttype, void *object, int extensionhandle, void *extension) { -#ifdef LDAP_SLAPI struct slapi_extension_block *eblock; void *parent; @@ -169,7 +164,6 @@ void slapi_set_object_extension(int objecttype, void *object, int extensionhandl /* constructed by caller */ eblock->extensions[extensionhandle] = extension; } -#endif /* LDAP_SLAPI */ } int slapi_register_object_extension( @@ -180,7 +174,6 @@ int slapi_register_object_extension( int *objecttype, int *extensionhandle) { -#ifdef LDAP_SLAPI int rc; slapi_extension_t type; struct slapi_registered_extension *re; @@ -228,15 +221,11 @@ int slapi_register_object_extension( ldap_pvt_thread_mutex_unlock( ®istered_extensions.mutex ); return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_int_create_object_extensions(int objecttype, void *object) { -#ifdef LDAP_SLAPI - int i, rc; + int i; struct slapi_extension_block *eblock; void **peblock; void *parent; @@ -247,7 +236,7 @@ int slapi_int_create_object_extensions(int objecttype, void *object) parent = NULL; break; case SLAPI_X_EXT_OPERATION: - peblock = &(((Operation *)object)->o_extensions); + peblock = &(((Operation *)object)->o_hdr->oh_extensions); parent = ((Operation *)object)->o_conn; break; default: @@ -281,15 +270,11 @@ int slapi_int_create_object_extensions(int objecttype, void *object) *peblock = eblock; return 0; -#else - return -1; -#endif } int slapi_int_free_object_extensions(int objecttype, void *object) { -#ifdef LDAP_SLAPI - int i, rc; + int i; struct slapi_extension_block *eblock; void **peblock; void *parent; @@ -300,7 +285,7 @@ int slapi_int_free_object_extensions(int objecttype, void *object) parent = NULL; break; case SLAPI_X_EXT_OPERATION: - peblock = &(((Operation *)object)->o_extensions); + peblock = &(((Operation *)object)->o_hdr->oh_extensions); parent = ((Operation *)object)->o_conn; break; default: @@ -321,16 +306,12 @@ int slapi_int_free_object_extensions(int objecttype, void *object) slapi_ch_free( peblock ); return 0; -#else - return -1; -#endif } /* for reusable object types */ int slapi_int_clear_object_extensions(int objecttype, void *object) { -#ifdef LDAP_SLAPI - int i, rc; + int i; struct slapi_extension_block *eblock; void *parent; @@ -352,14 +333,10 @@ int slapi_int_clear_object_extensions(int objecttype, void *object) } return 0; -#else - return -1; -#endif } int slapi_int_init_object_extensions(void) { -#ifdef LDAP_SLAPI memset( ®istered_extensions, 0, sizeof( registered_extensions ) ); if ( ldap_pvt_thread_mutex_init( ®istered_extensions.mutex ) != 0 ) { @@ -367,7 +344,6 @@ int slapi_int_init_object_extensions(void) } return 0; -#else - return -1; -#endif } + +#endif /* LDAP_SLAPI */ diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index 5e85fe80b8..3820f57af2 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -31,169 +31,216 @@ #include #include -/* - * use a fake listener when faking a connection, - * so it can be used in ACLs - */ -static struct slap_listener slap_unknown_listener = { - BER_BVC("unknown"), /* FIXME: use a URI form? (e.g. slapi://) */ - BER_BVC("UNKNOWN") +#ifdef LDAP_SLAPI + +static struct slap_listener slapi_listener = { + BER_BVC("slapi://"), + BER_BVC("slapi://") }; -static void -internal_result_v3( +static LDAPControl ** +slapi_int_dup_controls( LDAPControl **controls ) +{ + LDAPControl **c; + size_t i; + + if ( controls == NULL ) + return NULL; + + for ( i = 0; controls[i] != NULL; i++ ) + ; + + c = (LDAPControl **) slapi_ch_calloc( i + 1, sizeof(LDAPControl *) ); + + for ( i = 0; controls[i] != NULL; i++ ) { + c[i] = slapi_dup_control( controls[i] ); + } + + return c; +} + +static int +slapi_int_result( Operation *op, SlapReply *rs ) { -#ifdef notdef - /* XXX needs review after internal API change */ - /* rs->sr_nentries appears to always be 0 */ - if (op->o_tag == LDAP_REQ_SEARCH) - slapi_pblock_set( (Slapi_PBlock *)op->o_pb, - SLAPI_NENTRIES, (void *)rs->sr_nentries ); -#endif - - return; + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + plugin_result_callback prc = NULL; + void *callback_data = NULL; + LDAPControl **ctrls = NULL; + + assert( pb != NULL ); + + slapi_pblock_get( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc ); + slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data ); + + /* we need to duplicate controls because they might go out of scope */ + ctrls = slapi_int_dup_controls( rs->sr_ctrls ); + slapi_pblock_set( pb, SLAPI_RESCONTROLS, ctrls ); + + if ( prc != NULL ) { + (*prc)( rs->sr_err, callback_data ); + } + + return rs->sr_err; } static int -internal_search_entry( +slapi_int_search_entry( Operation *op, SlapReply *rs ) { - int nentries = 0, len = 0, i = 0; - Slapi_Entry **head = NULL, **tp; - Slapi_Entry *entry; + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + plugin_search_entry_callback psec = NULL; + void *callback_data = NULL; + int rc = LDAP_SUCCESS; - entry = slapi_entry_dup( rs->sr_entry ); - if ( entry == NULL ) { - return 1; + assert( pb != NULL ); + + slapi_pblock_get( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void **)&psec ); + slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data ); + + if ( psec != NULL ) { + rc = (*psec)( rs->sr_entry, callback_data ); } - slapi_pblock_get( (Slapi_PBlock *)op->o_pb, - SLAPI_NENTRIES, &nentries ); - slapi_pblock_get( (Slapi_PBlock *)op->o_pb, - SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head ); - - i = nentries + 1; - if ( nentries == 0 ) { - tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) ); - if ( tp == NULL ) { - slapi_entry_free( entry ); - return 1; - } + return rc; +} - tp[ 0 ] = entry; - } else { - tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head, - sizeof(Slapi_Entry *) * ( i + 1 ) ); - if ( tp == NULL ) { - slapi_entry_free( entry ); - return 1; +static int +slapi_int_search_reference( + Operation *op, + SlapReply *rs ) +{ + int i, rc = LDAP_SUCCESS; + plugin_referral_entry_callback prec = NULL; + void *callback_data = NULL; + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + + assert( pb != NULL ); + + slapi_pblock_get( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void **)&prec ); + slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data ); + + if ( prec != NULL ) { + for ( i = 0; rs->sr_ref[i].bv_val != NULL; i++ ) { + rc = (*prec)( rs->sr_ref[i].bv_val, callback_data ); + if ( rc != LDAP_SUCCESS ) { + break; + } } - tp[ i - 1 ] = entry; } - tp[ i ] = NULL; - - slapi_pblock_set( (Slapi_PBlock *)op->o_pb, - SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp ); - slapi_pblock_set( (Slapi_PBlock *)op->o_pb, - SLAPI_NENTRIES, (void *)i ); - return LDAP_SUCCESS; + return rc; } -static void -internal_result_ext( - Operation *op, - SlapReply *sr ) +int +slapi_int_response( Slapi_Operation *op, SlapReply *rs ) { - return; + int rc; + + switch ( rs->sr_type ) { + case REP_RESULT: + rc = slapi_int_result( op, rs ); + break; + case REP_SEARCH: + rc = slapi_int_search_entry( op, rs ); + break; + case REP_SEARCHREF: + rc = slapi_int_search_reference( op, rs ); + break; + default: + rc = LDAP_OTHER; + break; + } + + assert( rc != SLAP_CB_CONTINUE ); /* never try to send a wire response */ + + return rc; } static int -internal_search_reference( - Operation *op, - SlapReply *sr ) +slapi_int_get_ctrls( Slapi_PBlock *pb ) { - return LDAP_SUCCESS; -} + LDAPControl **c; + int rc = LDAP_SUCCESS; -Connection * -slapi_int_init_connection( - char *DN, - int OpType ) -{ - Connection *pConn; - ber_len_t max = sockbuf_max_incoming; - - pConn = (Connection *) slapi_ch_calloc(1, sizeof(Connection)); - if (pConn == NULL) { - return (Connection *)NULL; + if ( pb->pb_op->o_ctrls != NULL ) { + for ( c = pb->pb_op->o_ctrls; *c != NULL; c++ ) { + rc = slap_parse_ctrl( pb->pb_op, pb->pb_rs, *c, &pb->pb_rs->sr_text ); + if ( rc != LDAP_SUCCESS ) + break; + } } - LDAP_STAILQ_INIT( &pConn->c_pending_ops ); + return rc; +} - pConn->c_pending_ops.stqh_first = - (Operation *) slapi_ch_calloc( 1, sizeof(Operation) ); - if ( pConn->c_pending_ops.stqh_first == NULL ) { - slapi_ch_free( (void **)&pConn ); - return (Connection *)NULL; - } +void +slapi_int_connection_init_pb( Slapi_PBlock *pb, ber_tag_t tag ) +{ + Connection *conn; + Operation *op; + ber_len_t max = sockbuf_max_incoming; - pConn->c_pending_ops.stqh_first->o_pb = - (Slapi_PBlock *) slapi_pblock_new(); - if ( pConn->c_pending_ops.stqh_first->o_pb == NULL ) { - slapi_ch_free( (void **)&pConn->c_pending_ops.stqh_first ); - slapi_ch_free( (void **)&pConn ); - return (Connection *)NULL; - } + conn = (Connection *) slapi_ch_calloc( 1, sizeof(Connection) ); - /* connection object */ - pConn->c_authmech.bv_val = NULL; - pConn->c_authmech.bv_len = 0; - pConn->c_dn.bv_val = NULL; - pConn->c_dn.bv_len = 0; - pConn->c_ndn.bv_val = NULL; - pConn->c_ndn.bv_len = 0; + LDAP_STAILQ_INIT( &conn->c_pending_ops ); - pConn->c_listener = &slap_unknown_listener; - ber_dupbv( &pConn->c_peer_domain, (struct berval *)&slap_unknown_bv ); - ber_dupbv( &pConn->c_peer_name, (struct berval *)&slap_unknown_bv ); + op = (Operation *) slapi_ch_calloc( 1, OPERATION_BUFFER_SIZE ); + op->o_hdr = (Opheader *)(op + 1); + op->o_controls = (void **)(op->o_hdr + 1); - LDAP_STAILQ_INIT( &pConn->c_ops ); + op->o_callback = (slap_callback *) slapi_ch_calloc( 1, sizeof(slap_callback) ); + op->o_callback->sc_response = slapi_int_response; + op->o_callback->sc_cleanup = NULL; + op->o_callback->sc_private = pb; + op->o_callback->sc_next = NULL; - pConn->c_sasl_bind_mech.bv_val = NULL; - pConn->c_sasl_bind_mech.bv_len = 0; - pConn->c_sasl_authctx = NULL; - pConn->c_sasl_sockctx = NULL; - pConn->c_sasl_extra = NULL; + conn->c_pending_ops.stqh_first = op; - pConn->c_sb = ber_sockbuf_alloc( ); + /* connection object authorization information */ + conn->c_authtype = LDAP_AUTH_NONE; + BER_BVZERO( &conn->c_authmech ); + BER_BVZERO( &conn->c_dn ); + BER_BVZERO( &conn->c_ndn ); - ber_sockbuf_ctrl( pConn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); + conn->c_listener = &slapi_listener; + ber_dupbv( &conn->c_peer_domain, (struct berval *)&slap_unknown_bv ); + ber_dupbv( &conn->c_peer_name, (struct berval *)&slap_unknown_bv ); - pConn->c_currentber = NULL; + LDAP_STAILQ_INIT( &conn->c_ops ); + + BER_BVZERO( &conn->c_sasl_bind_mech ); + conn->c_sasl_authctx = NULL; + conn->c_sasl_sockctx = NULL; + conn->c_sasl_extra = NULL; + + conn->c_sb = ber_sockbuf_alloc(); + + ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); + + conn->c_currentber = NULL; /* should check status of thread calls */ - ldap_pvt_thread_mutex_init( &pConn->c_mutex ); - ldap_pvt_thread_mutex_init( &pConn->c_write_mutex ); - ldap_pvt_thread_cond_init( &pConn->c_write_cv ); + ldap_pvt_thread_mutex_init( &conn->c_mutex ); + ldap_pvt_thread_mutex_init( &conn->c_write_mutex ); + ldap_pvt_thread_cond_init( &conn->c_write_cv ); - ldap_pvt_thread_mutex_lock( &pConn->c_mutex ); + ldap_pvt_thread_mutex_lock( &conn->c_mutex ); - pConn->c_n_ops_received = 0; - pConn->c_n_ops_executing = 0; - pConn->c_n_ops_pending = 0; - pConn->c_n_ops_completed = 0; + conn->c_n_ops_received = 0; + conn->c_n_ops_executing = 0; + conn->c_n_ops_pending = 0; + conn->c_n_ops_completed = 0; - pConn->c_n_get = 0; - pConn->c_n_read = 0; - pConn->c_n_write = 0; + conn->c_n_get = 0; + conn->c_n_read = 0; + conn->c_n_write = 0; - pConn->c_protocol = LDAP_VERSION3; + conn->c_protocol = LDAP_VERSION3; - pConn->c_activitytime = pConn->c_starttime = slap_get_time(); + conn->c_activitytime = conn->c_starttime = slap_get_time(); /* * A real connection ID is required, because syncrepl associates @@ -201,675 +248,506 @@ slapi_int_init_connection( * Setting a fake connection ID will cause slap_get_commit_csn() * to return a stale value. */ - connection_assign_nextid( pConn ); + connection_assign_nextid( conn ); - pConn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */ - pConn->c_struct_state = 0x02; /* SLAP_C_USED */ + conn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */ + conn->c_struct_state = 0x02; /* SLAP_C_USED */ - pConn->c_ssf = pConn->c_transport_ssf = 0; - pConn->c_tls_ssf = 0; + conn->c_ssf = conn->c_transport_ssf = 0; + conn->c_tls_ssf = 0; - backend_connection_init( pConn ); + backend_connection_init( conn ); - pConn->c_send_ldap_result = internal_result_v3; - pConn->c_send_search_entry = internal_search_entry; - pConn->c_send_ldap_extended = internal_result_ext; - pConn->c_send_search_reference = internal_search_reference; + conn->c_send_ldap_result = slap_send_ldap_result; + conn->c_send_search_entry = slap_send_search_entry; + conn->c_send_ldap_extended = slap_send_ldap_extended; + conn->c_send_search_reference = slap_send_search_reference; /* operation object */ - pConn->c_pending_ops.stqh_first->o_tag = OpType; - pConn->c_pending_ops.stqh_first->o_protocol = LDAP_VERSION3; - pConn->c_pending_ops.stqh_first->o_authmech.bv_val = NULL; - pConn->c_pending_ops.stqh_first->o_authmech.bv_len = 0; - pConn->c_pending_ops.stqh_first->o_time = slap_get_time(); - pConn->c_pending_ops.stqh_first->o_do_not_cache = 1; - pConn->c_pending_ops.stqh_first->o_threadctx = ldap_pvt_thread_pool_context(); - pConn->c_pending_ops.stqh_first->o_tmpmemctx = NULL; - pConn->c_pending_ops.stqh_first->o_tmpmfuncs = &ch_mfuncs; - pConn->c_pending_ops.stqh_first->o_conn = pConn; - pConn->c_pending_ops.stqh_first->o_connid = pConn->c_connid; - - ldap_pvt_thread_mutex_unlock( &pConn->c_mutex ); - - return pConn; + op->o_tag = tag; + op->o_protocol = LDAP_VERSION3; + BER_BVZERO( &op->o_authmech ); + op->o_time = slap_get_time(); + op->o_do_not_cache = 1; + op->o_threadctx = ldap_pvt_thread_pool_context(); + op->o_tmpmemctx = NULL; + op->o_tmpmfuncs = &ch_mfuncs; + op->o_conn = conn; + op->o_connid = conn->c_connid; + op->o_bd = frontendDB; + + /* extensions */ + slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION, op ); + slapi_int_create_object_extensions( SLAPI_X_EXT_CONNECTION, conn ); + + pb->pb_rs = (SlapReply *)slapi_ch_calloc( 1, sizeof(SlapReply) ); + pb->pb_op = op; + pb->pb_conn = conn; + pb->pb_intop = 1; + + ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); } -void slapi_int_connection_destroy( Connection **pConn ) +static void +slapi_int_set_operation_dn( Slapi_PBlock *pb ) { - Connection *conn = *pConn; - Operation *op; - - if ( pConn == NULL ) { - return; - } - - op = (Operation *)conn->c_pending_ops.stqh_first; - - slap_graduate_commit_csn( op ); - - if ( op->o_req_dn.bv_val != NULL ) { - slapi_ch_free( (void **)&op->o_req_dn.bv_val ); - } - if ( op->o_req_ndn.bv_val != NULL ) { - slapi_ch_free( (void **)&op->o_req_ndn.bv_val ); - } - - if ( conn->c_sb != NULL ) { - ber_sockbuf_free( conn->c_sb ); - } - if ( op != NULL ) { - slapi_ch_free( (void **)&op ); + Backend *be; + Operation *op = pb->pb_op; + + if ( BER_BVISNULL( &op->o_ndn ) ) { + /* set to root DN */ + be = select_backend( &op->o_req_ndn, get_manageDSAit( op ), 1 ); + if ( be != NULL ) { + ber_dupbv( &op->o_dn, &be->be_rootdn ); + ber_dupbv( &op->o_ndn, &be->be_rootndn ); + } } - slapi_ch_free( (void **)pConn ); } -/* - * Function : values2obj - * Convert an array of strings into a BerVarray. - * the strings. - */ -static int -values2obj_copy( - char **ppValue, - BerVarray *bvobj ) +void +slapi_int_connection_done_pb( Slapi_PBlock *pb ) { - int i; - BerVarray tmpberval; + Connection *conn; + Operation *op; - if ( ppValue == NULL ) { - *bvobj = NULL; - return LDAP_SUCCESS; + PBLOCK_ASSERT_INTOP( pb, 0 ); + + conn = pb->pb_conn; + op = pb->pb_op; + + /* free allocated DNs */ + if ( !BER_BVISNULL( &op->o_dn ) ) + op->o_tmpfree( op->o_dn.bv_val, op->o_tmpmemctx ); + if ( !BER_BVISNULL( &op->o_ndn ) ) + op->o_tmpfree( op->o_ndn.bv_val, op->o_tmpmemctx ); + + if ( !BER_BVISNULL( &op->o_req_dn ) ) + op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); + if ( !BER_BVISNULL( &op->o_req_ndn ) ) + op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); + + switch ( op->o_tag ) { + case LDAP_REQ_MODRDN: + if ( !BER_BVISNULL( &op->orr_newrdn )) + op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx ); + if ( !BER_BVISNULL( &op->orr_nnewrdn )) + op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx ); + if ( op->orr_newSup != NULL ) { + assert( !BER_BVISNULL( op->orr_newSup ) ); + op->o_tmpfree( op->orr_newSup->bv_val, op->o_tmpmemctx ); + op->o_tmpfree( op->orr_newSup, op->o_tmpmemctx ); + } + if ( op->orr_nnewSup != NULL ) { + assert( !BER_BVISNULL( op->orr_nnewSup ) ); + op->o_tmpfree( op->orr_nnewSup->bv_val, op->o_tmpmemctx ); + op->o_tmpfree( op->orr_nnewSup, op->o_tmpmemctx ); + } + break; + case LDAP_REQ_ADD: + slap_mods_free( op->ora_modlist, 0 ); + break; + case LDAP_REQ_MODIFY: + slap_mods_free( op->orm_modlist, 1 ); + break; + case LDAP_REQ_SEARCH: + if ( op->ors_attrs != NULL ) { + op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx ); + op->ors_attrs = NULL; + } + break; + default: + break; } - for ( i = 0; ppValue[i] != NULL; i++ ) - ; /* EMPTY */ + slapi_ch_free_string( &conn->c_authmech.bv_val ); + slapi_ch_free_string( &conn->c_dn.bv_val ); + slapi_ch_free_string( &conn->c_ndn.bv_val ); + slapi_ch_free_string( &conn->c_peer_domain.bv_val ); + slapi_ch_free_string( &conn->c_peer_name.bv_val ); - tmpberval = (BerVarray)slapi_ch_malloc( (i+1) * (sizeof(struct berval)) ); - if ( tmpberval == NULL ) { - return LDAP_NO_MEMORY; - } - for ( i = 0; ppValue[i] != NULL; i++ ) { - size_t len = strlen( ppValue[i] ); - - tmpberval[i].bv_val = slapi_ch_malloc( len + 1 ); - AC_MEMCPY( tmpberval[i].bv_val, ppValue[i], len + 1 ); - tmpberval[i].bv_len = len; + if ( conn->c_sb != NULL ) { + ber_sockbuf_free( conn->c_sb ); } - tmpberval[i].bv_val = NULL; - tmpberval[i].bv_len = 0; - *bvobj = tmpberval; + slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op ); + slapi_int_free_object_extensions( SLAPI_X_EXT_CONNECTION, conn ); - return LDAP_SUCCESS; + slapi_ch_free( (void **)&pb->pb_op->o_callback ); + slapi_ch_free( (void **)&pb->pb_op ); + slapi_ch_free( (void **)&pb->pb_conn ); + slapi_ch_free( (void **)&pb->pb_rs ); } static int -bvptr2obj_copy( - struct berval **bvptr, - BerVarray *bvobj ) +slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which ) { - int i; - BerVarray tmpberval; + BI_op_bind **func; + SlapReply *rs = pb->pb_rs; + int rc; + + PBLOCK_ASSERT_INTOP( pb, 0 ); - if ( bvptr == NULL ) { - *bvobj = NULL; - return LDAP_SUCCESS; + rc = slapi_int_get_ctrls( pb ); + if ( rc != LDAP_SUCCESS ) { + rs->sr_err = rc; + return rc; } - for ( i = 0; bvptr[i] != NULL; i++ ) - ; /* EMPTY */ + pb->pb_op->o_bd = frontendDB; + func = &frontendDB->be_bind; - tmpberval = (BerVarray)slapi_ch_malloc( (i + 1) * sizeof(struct berval)); - if ( tmpberval == NULL ) { - return LDAP_NO_MEMORY; - } + return func[which]( pb->pb_op, pb->pb_rs ); +} - for ( i = 0; bvptr[i] != NULL; i++ ) { - tmpberval[i].bv_val = slapi_ch_malloc( bvptr[i]->bv_len ); - tmpberval[i].bv_len = bvptr[i]->bv_len; - AC_MEMCPY( tmpberval[i].bv_val, bvptr[i]->bv_val, bvptr[i]->bv_len ); +int +slapi_delete_internal_pb( Slapi_PBlock *pb ) +{ + if ( pb == NULL ) { + return -1; } - tmpberval[i].bv_val = NULL; - tmpberval[i].bv_len = 0; + PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_DELETE ); - *bvobj = tmpberval; + slapi_int_func_internal_pb( pb, op_delete ); + slap_graduate_commit_csn( pb->pb_op ); - return LDAP_SUCCESS; + return 0; } -/* - * Function : slapi_int_ldapmod_to_entry - * convert a dn plus an array of LDAPMod struct ptrs to an entry structure - * with a link list of the correspondent attributes. - * Return value : LDAP_SUCCESS - * LDAP_NO_MEMORY - * LDAP_OTHER -*/ -static Entry * -slapi_int_ldapmod_to_entry( - Connection *pConn, - char *ldn, - LDAPMod **mods ) +int +slapi_add_internal_pb( Slapi_PBlock *pb ) { - struct berval dn = BER_BVNULL; - Entry *pEntry=NULL; - LDAPMod *pMod; - struct berval *bv; - Operation *op; + SlapReply *rs; + Slapi_Entry *entry_orig = NULL; - Modifications *modlist = NULL; - Modifications **modtail = &modlist; - Modifications tmp; - - int rc = LDAP_SUCCESS; - int i; + if ( pb == NULL ) { + return -1; + } - const char *text = NULL; + PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_ADD ); - op = (Operation *)pConn->c_pending_ops.stqh_first; + rs = pb->pb_rs; - pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) ); - if ( pEntry == NULL) { - rc = LDAP_NO_MEMORY; - goto cleanup; - } + entry_orig = pb->pb_op->ora_e; + pb->pb_op->ora_e = NULL; - dn.bv_val = slapi_ch_strdup(ldn); - dn.bv_len = strlen(ldn); + /* + * The caller can specify a new entry, or a target DN and set + * of modifications, but not both. + */ + if ( entry_orig != NULL ) { + if ( pb->pb_op->ora_modlist != NULL || !BER_BVISNULL( &pb->pb_op->o_req_ndn )) { + rs->sr_err = LDAP_PARAM_ERROR; + goto cleanup; + } - rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname, NULL ); - if ( rc != LDAP_SUCCESS ) { + assert( BER_BVISNULL( &pb->pb_op->o_req_dn ) ); /* shouldn't get set */ + ber_dupbv( &pb->pb_op->o_req_dn, &entry_orig->e_name ); + ber_dupbv( &pb->pb_op->o_req_ndn, &entry_orig->e_nname ); + } else if ( pb->pb_op->ora_modlist == NULL || BER_BVISNULL( &pb->pb_op->o_req_ndn )) { + rs->sr_err = LDAP_PARAM_ERROR; goto cleanup; } - if ( rc == LDAP_SUCCESS ) { - for ( i = 0, pMod = mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod = mods[++i]) { - Modifications *mod; - - if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) { - /* - * Convert an array of pointers to bervals to - * an array of bervals. Note that we need to copy the - * values too, as the slap_mods_check() will free the - * original values after prettying; the modifications - * being passed in may not have been allocated on the - * heap. - */ - rc = bvptr2obj_copy( pMod->mod_bvalues, &bv ); - if ( rc != LDAP_SUCCESS ) goto cleanup; - tmp.sml_type.bv_val = pMod->mod_type; - tmp.sml_type.bv_len = strlen( pMod->mod_type ); - tmp.sml_values = bv; - tmp.sml_nvalues = NULL; - - mod = (Modifications *) ch_malloc( sizeof(Modifications) ); - - mod->sml_op = LDAP_MOD_ADD; - mod->sml_flags = 0; - mod->sml_next = NULL; - mod->sml_desc = NULL; - mod->sml_type = tmp.sml_type; - mod->sml_values = tmp.sml_values; - mod->sml_nvalues = tmp.sml_nvalues; - - *modtail = mod; - modtail = &mod->sml_next; - - } else { - /* attr values are in string format, need to be converted */ - /* to an array of bervals */ - if ( pMod->mod_values == NULL ) { - rc = LDAP_OTHER; - } else { - rc = values2obj_copy( pMod->mod_values, &bv ); - if ( rc != LDAP_SUCCESS ) goto cleanup; - tmp.sml_type.bv_val = pMod->mod_type; - tmp.sml_type.bv_len = strlen( pMod->mod_type ); - tmp.sml_values = bv; - tmp.sml_nvalues = NULL; - - mod = (Modifications *) ch_malloc( sizeof(Modifications) ); - - mod->sml_op = LDAP_MOD_ADD; - mod->sml_flags = 0; - mod->sml_next = NULL; - mod->sml_desc = NULL; - mod->sml_type = tmp.sml_type; - mod->sml_values = tmp.sml_values; - mod->sml_nvalues = tmp.sml_nvalues; - - *modtail = mod; - modtail = &mod->sml_next; - } - } - } /* for each LDAPMod */ - } + pb->pb_op->ora_e = (Entry *)slapi_ch_calloc( 1, sizeof(Entry) ); + ber_dupbv( &pb->pb_op->ora_e->e_name, &pb->pb_op->o_req_dn ); + ber_dupbv( &pb->pb_op->ora_e->e_nname, &pb->pb_op->o_req_ndn ); + + if ( entry_orig != NULL ) { + assert( pb->pb_op->ora_modlist == NULL ); - op->o_bd = select_backend( &pEntry->e_nname, 0, 0 ); - if ( op->o_bd == NULL ) { - rc = LDAP_PARTIAL_RESULTS; + rs->sr_err = slap_entry2mods( entry_orig, &pb->pb_op->ora_modlist, + &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ) ); + if ( rs->sr_err != LDAP_SUCCESS ) { + goto cleanup; + } } else { - int repl_user = be_isupdate_dn( op->o_bd, &op->o_bd->be_rootdn ); - if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { - int update = !BER_BVISNULL( &op->o_bd->be_update_ndn ); - char textbuf[ SLAP_TEXT_BUFLEN ]; - size_t textlen = sizeof( textbuf ); - - rc = slap_mods_check( modlist, &text, - textbuf, textlen, NULL ); - if ( rc != LDAP_SUCCESS) { - goto cleanup; - } + assert( pb->pb_op->ora_modlist != NULL ); + } - if ( !update ) { - rc = slap_mods_no_user_mod_check( op, modlist, - &text, textbuf, textlen ); - if ( rc != LDAP_SUCCESS) { - goto cleanup; - } - } + rs->sr_err = slap_mods_check( pb->pb_op->ora_modlist, &rs->sr_text, + pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL ); + if ( rs->sr_err != LDAP_SUCCESS ) { + goto cleanup; + } - if ( !repl_user ) { - rc = slap_mods_opattrs( op, modlist, modtail, - &text, textbuf, textlen, 1 ); - if ( rc != LDAP_SUCCESS) { - goto cleanup; - } - } + /* Duplicate the values, because we may call slapi_entry_free() */ + rs->sr_err = slap_mods2entry( pb->pb_op->ora_modlist, &pb->pb_op->ora_e, + 1, 0, &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ) ); + if ( rs->sr_err != LDAP_SUCCESS ) { + goto cleanup; + } - rc = slap_mods2entry( modlist, &pEntry, repl_user, - 0, &text, textbuf, textlen ); - if (rc != LDAP_SUCCESS) { - goto cleanup; - } + if ( slapi_int_func_internal_pb( pb, op_add ) == 0 ) { + if ( pb->pb_op->ora_e != NULL && pb->pb_op->o_private != NULL ) { + BackendDB *bd = pb->pb_op->o_bd; - } else { - rc = LDAP_REFERRAL; + pb->pb_op->o_bd = (BackendDB *)pb->pb_op->o_private; + pb->pb_op->o_private = NULL; + be_entry_release_w( pb->pb_op, pb->pb_op->ora_e ); + pb->pb_op->ora_e = NULL; + pb->pb_op->o_bd = bd; + pb->pb_op->o_private = NULL; } } -cleanup:; - if ( dn.bv_val ) - slapi_ch_free( (void **)&dn.bv_val ); - if ( modlist != NULL ) - slap_mods_free( modlist ); - if ( rc != LDAP_SUCCESS ) { - if ( pEntry != NULL ) { - slapi_entry_free( pEntry ); - } - pEntry = NULL; +cleanup: + slap_graduate_commit_csn( pb->pb_op ); + + if ( pb->pb_op->ora_e != NULL ) { + slapi_entry_free( pb->pb_op->ora_e ); + pb->pb_op->ora_e = NULL; + } + if ( entry_orig != NULL ) { + pb->pb_op->ora_e = entry_orig; + slap_mods_free( pb->pb_op->ora_modlist, 1 ); + pb->pb_op->ora_modlist = NULL; } - return( pEntry ); + return 0; } -/* Function : slapi_delete_internal - * - * Description : Plugin functions call this routine to delete an entry - * in the backend directly - * Return values : LDAP_SUCCESS - * LDAP_PARAM_ERROR - * LDAP_NO_MEMORY - * LDAP_OTHER - * LDAP_UNWILLING_TO_PERFORM -*/ -Slapi_PBlock * -slapi_delete_internal( - char *ldn, - LDAPControl **controls, - int log_change ) +int +slapi_modrdn_internal_pb( Slapi_PBlock *pb ) { -#ifdef LDAP_SLAPI - Connection *pConn = NULL; - Operation *op = NULL; - Slapi_PBlock *pPB = NULL; - SlapReply rs = { REP_RESULT }; - struct berval dn = BER_BVNULL; - - int manageDsaIt = SLAP_CONTROL_NONE; - int isCritical; - - if ( ldn == NULL ) { - rs.sr_err = LDAP_PARAM_ERROR; - goto cleanup; + if ( pb == NULL ) { + return -1; } - pConn = slapi_int_init_connection( NULL, LDAP_REQ_DELETE ); - if (pConn == NULL) { - rs.sr_err = LDAP_NO_MEMORY; - goto cleanup; - } + PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODRDN ); - op = (Operation *)pConn->c_pending_ops.stqh_first; - pPB = (Slapi_PBlock *)op->o_pb; - op->o_ctrls = controls; - - dn.bv_val = slapi_ch_strdup(ldn); - dn.bv_len = strlen(ldn); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); - if ( rs.sr_err != LDAP_SUCCESS ) - goto cleanup; - - if ( slapi_control_present( controls, - SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical) ) { - manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL; - } - - op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 ); - if ( op->o_bd == NULL ) { - rs.sr_err = LDAP_PARTIAL_RESULTS; + if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) { + pb->pb_rs->sr_err = LDAP_UNWILLING_TO_PERFORM; goto cleanup; } - op->o_dn = pConn->c_dn = op->o_bd->be_rootdn; - op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn; - - if ( op->o_bd->be_delete ) { - int repl_user = be_isupdate( op ); - if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { - slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; - if ( log_change ) op->o_callback = &cb; - if ( (*op->o_bd->be_delete)( op, &rs ) ) { - rs.sr_err = LDAP_OTHER; - } - } else { - rs.sr_err = LDAP_REFERRAL; - } - } else { - rs.sr_err = LDAP_UNWILLING_TO_PERFORM; - } + slapi_int_func_internal_pb( pb, op_modrdn ); cleanup: - if ( pPB != NULL ) { - slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err ); - } - if ( dn.bv_val ) { - slapi_ch_free( (void **)&dn.bv_val ); - } - - slapi_int_connection_destroy( &pConn ); + slap_graduate_commit_csn( pb->pb_op ); - return pPB; -#else - return NULL; -#endif /* LDAP_SLAPI */ + return 0; } -#ifdef LDAP_SLAPI -static Slapi_PBlock * -slapi_int_add_entry_locked( - Connection *pConn, - Slapi_Entry **e, - LDAPControl **controls, - int log_changes ) +int +slapi_modify_internal_pb( Slapi_PBlock *pb ) { - Operation *op = NULL; - Slapi_PBlock *pPB = NULL; + SlapReply *rs; - int manageDsaIt = SLAP_CONTROL_NONE; - int isCritical; - SlapReply rs = { REP_RESULT }; - - if ( *e == NULL ) { - rs.sr_err = LDAP_PARAM_ERROR; - goto cleanup; + if ( pb == NULL ) { + return -1; } - if ( slapi_control_present( controls, LDAP_CONTROL_MANAGEDSAIT, - NULL, &isCritical ) ) { - manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL; - } + PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODIFY ); - op = (Operation *)pConn->c_pending_ops.stqh_first; - pPB = (Slapi_PBlock *)op->o_pb; - op->o_ctrls = controls; + rs = pb->pb_rs; - op->o_bd = select_backend( &((*e)->e_nname), manageDsaIt, 1 ); - if ( op->o_bd == NULL ) { - rs.sr_err = LDAP_PARTIAL_RESULTS; + if ( pb->pb_op->orm_modlist == NULL ) { + rs->sr_err = LDAP_PARAM_ERROR; goto cleanup; } - op->o_dn = pConn->c_dn = op->o_bd->be_rootdn; - op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn; - op->oq_add.rs_e = *e; - - if ( op->o_bd->be_add ) { - int repl_user = be_isupdate( op ); - if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { - slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; - if ( log_changes ) op->o_callback = &cb; - if ( (*op->o_bd->be_add)( op, &rs ) == 0 ) { - be_entry_release_w( op, *e ); - *e = NULL; - } - } else { - rs.sr_err = LDAP_REFERRAL; - } - } else { - rs.sr_err = LDAP_UNWILLING_TO_PERFORM; - } - -cleanup: - if ( pPB != NULL ) { - slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err ); + if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) { + rs->sr_err = LDAP_UNWILLING_TO_PERFORM; + goto cleanup; } - return( pPB ); -} -#endif /* LDAP_SLAPI */ + rs->sr_err = slap_mods_check( pb->pb_op->orm_modlist, + &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL ); + if ( rs->sr_err != LDAP_SUCCESS ) { + goto cleanup; + } -Slapi_PBlock * -slapi_add_entry_internal( - Slapi_Entry *e, - LDAPControl **controls, - int log_changes ) -{ -#ifdef LDAP_SLAPI - Slapi_PBlock *pb = NULL; - Slapi_Entry *entry = NULL; - Connection *pConn = NULL; + slapi_int_func_internal_pb( pb, op_modify ); - pConn = slapi_int_init_connection( NULL, LDAP_REQ_ADD ); - if ( pConn == NULL ) { - return NULL; - } - - /* - * We make a copy to avoid an entry that may be freed later - * by the caller being placed in the cache. - */ - entry = slapi_entry_dup( e ); - pb = slapi_int_add_entry_locked( pConn, &entry, controls, log_changes ); - if ( entry != NULL ) { - slapi_entry_free( entry ); - } - - slapi_int_connection_destroy( &pConn ); +cleanup: + slap_graduate_commit_csn( pb->pb_op ); - return pb; -#else - return NULL; -#endif + return 0; } -Slapi_PBlock * -slapi_add_internal( - char *dn, - LDAPMod **mods, - LDAPControl **controls, - int log_changes ) +static int +slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data ) { -#ifdef LDAP_SLAPI - LDAPMod *pMod = NULL; - Connection *pConn = NULL; - Slapi_PBlock *pb = NULL; - Entry *pEntry = NULL; - int i, rc = LDAP_SUCCESS; - - if ( mods == NULL || *mods == NULL || dn == NULL || *dn == '\0' ) { - rc = LDAP_PARAM_ERROR ; - } + int nentries = 0, i = 0; + Slapi_Entry **head = NULL, **tp; + Slapi_PBlock *pb = (Slapi_PBlock *)callback_data; - if ( rc == LDAP_SUCCESS ) { - for ( i = 0, pMod = mods[0]; pMod != NULL; pMod = mods[++i] ) { - if ( (pMod->mod_op & LDAP_MOD_OP ) != LDAP_MOD_ADD ) { - rc = LDAP_OTHER; - break; - } - } + PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH ); + + entry = slapi_entry_dup( entry ); + if ( entry == NULL ) { + return LDAP_NO_MEMORY; } - if ( rc == LDAP_SUCCESS ) { - pConn = slapi_int_init_connection( NULL, LDAP_REQ_ADD ); - if ( pConn != NULL ) { - pEntry = slapi_int_ldapmod_to_entry( pConn, dn, mods ); - if ( pEntry == NULL ) { - rc = LDAP_OTHER; - } + slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries ); + slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head ); + + i = nentries + 1; + if ( nentries == 0 ) { + tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) ); + if ( tp == NULL ) { + slapi_entry_free( entry ); + return LDAP_NO_MEMORY; } - } - if ( rc != LDAP_SUCCESS ) { - pb = slapi_pblock_new(); - slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc ); + tp[0] = entry; } else { - pb = slapi_int_add_entry_locked( pConn, &pEntry, controls, log_changes ); - } - - if ( pEntry != NULL ) { - slapi_entry_free( pEntry ); + tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head, + sizeof(Slapi_Entry *) * ( i + 1 ) ); + if ( tp == NULL ) { + slapi_entry_free( entry ); + return LDAP_NO_MEMORY; + } + tp[i - 1] = entry; } + tp[i] = NULL; + + slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp ); + slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)&i ); - slapi_int_connection_destroy( &pConn ); - - return pb; -#else - return NULL; -#endif /* LDAP_SLAPI */ + return LDAP_SUCCESS; } -/* Function : slapi_modrdn_internal - * - * Description : Plugin functions call this routine to modify the rdn - * of an entry in the backend directly - * Return values : LDAP_SUCCESS - * LDAP_PARAM_ERROR - * LDAP_NO_MEMORY - * LDAP_OTHER - * LDAP_UNWILLING_TO_PERFORM - * - * NOTE: This function does not support the "newSuperior" option from LDAP V3. - */ -Slapi_PBlock * -slapi_modrdn_internal( - char *olddn, - char *lnewrdn, - int deloldrdn, - LDAPControl **controls, - int log_change ) +int +slapi_search_internal_pb( Slapi_PBlock *pb ) { -#ifdef LDAP_SLAPI - struct berval dn = BER_BVNULL; - struct berval newrdn = BER_BVNULL; - Connection *pConn = NULL; - Operation *op = NULL; - Slapi_PBlock *pPB = NULL; - int manageDsaIt = SLAP_CONTROL_NONE; - int isCritical; - SlapReply rs = { REP_RESULT }; - - pConn = slapi_int_init_connection( NULL, LDAP_REQ_MODRDN ); - if ( pConn == NULL) { - rs.sr_err = LDAP_NO_MEMORY; - goto cleanup; - } + return slapi_search_internal_callback_pb( pb, + (void *)pb, + NULL, + slapi_int_search_entry_callback, + NULL ); +} - op = (Operation *)pConn->c_pending_ops.stqh_first; - pPB = (Slapi_PBlock *)op->o_pb; - op->o_ctrls = controls; +int +slapi_search_internal_callback_pb( Slapi_PBlock *pb, + void *callback_data, + plugin_result_callback prc, + plugin_search_entry_callback psec, + plugin_referral_entry_callback prec ) +{ + int free_filter = 0; + SlapReply *rs; - if ( slapi_control_present( controls, - SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) { - manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL; + if ( pb == NULL ) { + return -1; } - op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 ); - if ( op->o_bd == NULL ) { - rs.sr_err = LDAP_PARTIAL_RESULTS; - goto cleanup; - } + PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH ); - op->o_dn = pConn->c_dn = op->o_bd->be_rootdn; - op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn; + rs = pb->pb_rs; - dn.bv_val = slapi_ch_strdup( olddn ); - dn.bv_len = strlen( olddn ); + /* search callback and arguments */ + slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc ); + slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec ); + slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec ); + slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data ); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); - if ( rs.sr_err != LDAP_SUCCESS ) { + if ( BER_BVISEMPTY( &pb->pb_op->ors_filterstr )) { + rs->sr_err = LDAP_PARAM_ERROR; goto cleanup; } - if ( op->o_req_dn.bv_len == 0 ) { - rs.sr_err = LDAP_UNWILLING_TO_PERFORM; - goto cleanup; + if ( pb->pb_op->ors_filter == NULL ) { + pb->pb_op->ors_filter = slapi_str2filter( pb->pb_op->ors_filterstr.bv_val ); + if ( pb->pb_op->ors_filter == NULL ) { + rs->sr_err = LDAP_PROTOCOL_ERROR; + goto cleanup; + } + + free_filter = 1; } - newrdn.bv_val = slapi_ch_strdup( lnewrdn ); - newrdn.bv_len = strlen( lnewrdn ); + slapi_int_func_internal_pb( pb, op_search ); - rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn, NULL ); - if ( rs.sr_err != LDAP_SUCCESS ) { - goto cleanup; +cleanup: + if ( free_filter ) { + slapi_filter_free( pb->pb_op->ors_filter, 1 ); + pb->pb_op->ors_filter = NULL; } - if ( rdn_validate( &op->oq_modrdn.rs_nnewrdn ) != LDAP_SUCCESS ) { - goto cleanup; - } + slapi_pblock_delete_param( pb, SLAPI_X_INTOP_RESULT_CALLBACK ); + slapi_pblock_delete_param( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK ); + slapi_pblock_delete_param( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK ); + slapi_pblock_delete_param( pb, SLAPI_X_INTOP_CALLBACK_DATA ); - op->oq_modrdn.rs_newSup = NULL; - op->oq_modrdn.rs_nnewSup = NULL; - op->oq_modrdn.rs_deleteoldrdn = deloldrdn; - - if ( op->o_bd->be_modrdn ) { - int repl_user = be_isupdate( op ); - if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { - slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; - if ( log_change ) op->o_callback = &cb; - if ( (*op->o_bd->be_modrdn)( op, &rs ) ) { - rs.sr_err = LDAP_OTHER; - } - } else { - rs.sr_err = LDAP_REFERRAL; - } - } else { - rs.sr_err = LDAP_UNWILLING_TO_PERFORM; - } + return 0; +} -cleanup: +/* Wrappers for old API */ + +void +slapi_search_internal_set_pb( Slapi_PBlock *pb, + const char *base, + int scope, + const char *filter, + char **attrs, + int attrsonly, + LDAPControl **controls, + const char *uniqueid, + Slapi_ComponentId *plugin_identity, + int operation_flags ) +{ + int no_limit = SLAP_NO_LIMIT; + int deref = LDAP_DEREF_NEVER; + + slapi_int_connection_init_pb( pb, LDAP_REQ_SEARCH ); + slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base ); + slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)&scope ); + slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, (void *)0 ); + slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter ); + slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs ); + slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)&attrsonly ); + slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls ); + slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid ); + slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity ); + slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags ); + slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)&deref ); + slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)&no_limit ); + slapi_pblock_set( pb, SLAPI_SEARCH_TIMELIMIT, (void *)&no_limit ); + + slapi_int_set_operation_dn( pb ); +} - if ( pPB != NULL ) { - slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err ); - } - - if ( dn.bv_val ) - slapi_ch_free( (void **)&dn.bv_val ); +Slapi_PBlock * +slapi_search_internal( + char *ldn, + int scope, + char *filStr, + LDAPControl **controls, + char **attrs, + int attrsonly ) +{ + Slapi_PBlock *pb; - if ( newrdn.bv_val ) - slapi_ch_free( (void **)&newrdn.bv_val ); - if ( op->oq_modrdn.rs_newrdn.bv_val ) - slapi_ch_free( (void **)&op->oq_modrdn.rs_newrdn.bv_val ); - if ( op->oq_modrdn.rs_nnewrdn.bv_val ) - slapi_ch_free( (void **)&op->oq_modrdn.rs_nnewrdn.bv_val ); + pb = slapi_pblock_new(); - slapi_int_connection_destroy( &pConn ); + slapi_search_internal_set_pb( pb, ldn, scope, filStr, + attrs, attrsonly, + controls, NULL, NULL, 0 ); - return pPB; -#else - return NULL; -#endif /* LDAP_SLAPI */ + slapi_search_internal_pb( pb ); + + return pb; +} + +void +slapi_modify_internal_set_pb( Slapi_PBlock *pb, + const char *dn, + LDAPMod **mods, + LDAPControl **controls, + const char *uniqueid, + Slapi_ComponentId *plugin_identity, + int operation_flags ) +{ + slapi_int_connection_init_pb( pb, LDAP_REQ_MODIFY ); + slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn ); + slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods ); + slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls ); + slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid ); + slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity ); + slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags ); + slapi_int_set_operation_dn( pb ); } /* Function : slapi_modify_internal @@ -889,378 +767,184 @@ slapi_modify_internal( LDAPControl **controls, int log_change ) { -#ifdef LDAP_SLAPI - int i; - Connection *pConn = NULL; - Operation *op = NULL; - Slapi_PBlock *pPB = NULL; - - struct berval dn = BER_BVNULL; + Slapi_PBlock *pb; - int manageDsaIt = SLAP_CONTROL_NONE; - int isCritical; - struct berval *bv; - LDAPMod *pMod; + pb = slapi_pblock_new(); - Modifications *modlist = NULL; - Modifications **modtail = &modlist; - Modifications tmp; - - SlapReply rs = { REP_RESULT }; - - if ( mods == NULL || *mods == NULL || ldn == NULL ) { - rs.sr_err = LDAP_PARAM_ERROR ; - goto cleanup; - } - - pConn = slapi_int_init_connection( NULL, LDAP_REQ_MODIFY ); - if ( pConn == NULL ) { - rs.sr_err = LDAP_NO_MEMORY; - goto cleanup; - } + slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL, 0 ); + slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change ); + slapi_modify_internal_pb( pb ); - op = (Operation *)pConn->c_pending_ops.stqh_first; - pPB = (Slapi_PBlock *)op->o_pb; - op->o_ctrls = controls; + return pb; +} - dn.bv_val = slapi_ch_strdup( ldn ); - dn.bv_len = strlen( ldn ); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); - if ( rs.sr_err != LDAP_SUCCESS ) { - goto cleanup; - } +int +slapi_add_internal_set_pb( Slapi_PBlock *pb, + const char *dn, + LDAPMod **attrs, + LDAPControl **controls, + Slapi_ComponentId *plugin_identity, + int operation_flags ) +{ + slapi_int_connection_init_pb( pb, LDAP_REQ_ADD ); + slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn ); + slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs ); + slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls ); + slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity ); + slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags ); + slapi_int_set_operation_dn( pb ); + + return 0; +} - if ( slapi_control_present( controls, - SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) { - manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL; - } +Slapi_PBlock * +slapi_add_internal( + char * dn, + LDAPMod **attrs, + LDAPControl **controls, + int log_change ) +{ + Slapi_PBlock *pb; - op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 ); - if ( op->o_bd == NULL ) { - rs.sr_err = LDAP_PARTIAL_RESULTS; - goto cleanup; - } - - op->o_dn = pConn->c_dn = op->o_bd->be_rootdn; - op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn; - - for ( i = 0, pMod = mods[0]; - rs.sr_err == LDAP_SUCCESS && pMod != NULL; - pMod = mods[++i] ) - { - Modifications *mod; - - if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) { - /* - * attr values are in berval format - * convert an array of pointers to bervals - * to an array of bervals - */ - rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv ); - if ( rs.sr_err != LDAP_SUCCESS ) - goto cleanup; - tmp.sml_type.bv_val = pMod->mod_type; - tmp.sml_type.bv_len = strlen( pMod->mod_type ); - tmp.sml_values = bv; - tmp.sml_nvalues = NULL; - - mod = (Modifications *)ch_malloc( sizeof(Modifications) ); - - mod->sml_op = pMod->mod_op & LDAP_MOD_OP; - mod->sml_flags = 0; - mod->sml_next = NULL; - mod->sml_desc = NULL; - mod->sml_type = tmp.sml_type; - mod->sml_values = tmp.sml_values; - mod->sml_nvalues = tmp.sml_nvalues; - } else { - rs.sr_err = values2obj_copy( pMod->mod_values, &bv ); - if ( rs.sr_err != LDAP_SUCCESS ) - goto cleanup; - tmp.sml_type.bv_val = pMod->mod_type; - tmp.sml_type.bv_len = strlen( pMod->mod_type ); - tmp.sml_values = bv; - tmp.sml_nvalues = NULL; - - mod = (Modifications *) ch_malloc( sizeof(Modifications) ); - - mod->sml_op = pMod->mod_op & LDAP_MOD_OP; - mod->sml_flags = 0; - mod->sml_next = NULL; - mod->sml_desc = NULL; - mod->sml_type = tmp.sml_type; - mod->sml_values = tmp.sml_values; - mod->sml_nvalues = tmp.sml_nvalues; - } - *modtail = mod; - modtail = &mod->sml_next; + pb = slapi_pblock_new(); - switch( pMod->mod_op & LDAP_MOD_OP ) { - case LDAP_MOD_ADD: - if ( mod->sml_values == NULL ) { - rs.sr_err = LDAP_PROTOCOL_ERROR; - goto cleanup; - } + slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL, 0); + slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change ); + slapi_add_internal_pb( pb ); - /* fall through */ - case LDAP_MOD_DELETE: - case LDAP_MOD_REPLACE: - case LDAP_MOD_INCREMENT: - break; + return pb; +} - default: - rs.sr_err = LDAP_PROTOCOL_ERROR; - goto cleanup; - } - } - *modtail = NULL; +void +slapi_add_entry_internal_set_pb( Slapi_PBlock *pb, + Slapi_Entry *e, + LDAPControl **controls, + Slapi_ComponentId *plugin_identity, + int operation_flags ) +{ + slapi_int_connection_init_pb( pb, LDAP_REQ_ADD ); + slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e ); + slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls ); + slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity ); + slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags ); + slapi_int_set_operation_dn( pb ); +} - if ( op->o_req_ndn.bv_len == 0 ) { - rs.sr_err = LDAP_UNWILLING_TO_PERFORM; - goto cleanup; - } +Slapi_PBlock * +slapi_add_entry_internal( + Slapi_Entry *e, + LDAPControl **controls, + int log_change ) +{ + Slapi_PBlock *pb; - op->oq_modify.rs_modlist = modlist; - - if ( op->o_bd->be_modify ) { - int repl_user = be_isupdate( op ); - if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { - int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn ); - const char *text = NULL; - char textbuf[ SLAP_TEXT_BUFLEN ]; - size_t textlen = sizeof( textbuf ); - slap_callback cb = { NULL, slap_replog_cb, NULL, NULL }; - - rs.sr_err = slap_mods_check( modlist, - &text, textbuf, textlen, NULL ); - if ( rs.sr_err != LDAP_SUCCESS ) { - goto cleanup; - } + pb = slapi_pblock_new(); - if ( !update ) { - rs.sr_err = slap_mods_no_user_mod_check( op, modlist, - &text, textbuf, textlen ); - if ( rs.sr_err != LDAP_SUCCESS ) { - goto cleanup; - } - } + slapi_add_entry_internal_set_pb( pb, e, controls, NULL, 0 ); + slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change ); + slapi_add_internal_pb( pb ); - if ( !repl_user ) { - rs.sr_err = slap_mods_opattrs( op, modlist, - modtail, &text, textbuf, - textlen, 1 ); - if ( rs.sr_err != LDAP_SUCCESS ) { - goto cleanup; - } - } - if ( log_change ) op->o_callback = &cb; - if ( (*op->o_bd->be_modify)( op, &rs ) ) { - rs.sr_err = LDAP_OTHER; - } - } else { - rs.sr_err = LDAP_REFERRAL; - } - } else { - rs.sr_err = LDAP_UNWILLING_TO_PERFORM; - } + return pb; +} -cleanup: +void +slapi_rename_internal_set_pb( Slapi_PBlock *pb, + const char *olddn, + const char *newrdn, + const char *newsuperior, + int deloldrdn, + LDAPControl **controls, + const char *uniqueid, + Slapi_ComponentId *plugin_identity, + int operation_flags ) +{ + slapi_int_connection_init_pb( pb, LDAP_REQ_MODRDN ); + slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn ); + slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn ); + slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior ); + slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)&deloldrdn ); + slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls ); + slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid ); + slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity ); + slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags ); + slapi_int_set_operation_dn( pb ); +} - if ( pPB != NULL ) - slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err ); +/* Function : slapi_modrdn_internal + * + * Description : Plugin functions call this routine to modify the rdn + * of an entry in the backend directly + * Return values : LDAP_SUCCESS + * LDAP_PARAM_ERROR + * LDAP_NO_MEMORY + * LDAP_OTHER + * LDAP_UNWILLING_TO_PERFORM + * + * NOTE: This function does not support the "newSuperior" option from LDAP V3. + */ +Slapi_PBlock * +slapi_modrdn_internal( + char *olddn, + char *lnewrdn, + int deloldrdn, + LDAPControl **controls, + int log_change ) +{ + Slapi_PBlock *pb; - if ( dn.bv_val ) - slapi_ch_free( (void **)&dn.bv_val ); + pb = slapi_pblock_new (); - if ( modlist != NULL ) - slap_mods_free( modlist ); + slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL, + deloldrdn, controls, NULL, NULL, 0 ); + slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change ); + slapi_modrdn_internal_pb( pb ); - slapi_int_connection_destroy( &pConn ); + return pb; +} - return pPB; -#else - return NULL; -#endif /* LDAP_SLAPI */ +void +slapi_delete_internal_set_pb( Slapi_PBlock *pb, + const char *dn, + LDAPControl **controls, + const char *uniqueid, + Slapi_ComponentId *plugin_identity, + int operation_flags ) +{ + slapi_int_connection_init_pb( pb, LDAP_REQ_DELETE ); + slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn ); + slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls ); + slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid ); + slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity ); + slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags ); + slapi_int_set_operation_dn( pb ); } +/* Function : slapi_delete_internal + * + * Description : Plugin functions call this routine to delete an entry + * in the backend directly + * Return values : LDAP_SUCCESS + * LDAP_PARAM_ERROR + * LDAP_NO_MEMORY + * LDAP_OTHER + * LDAP_UNWILLING_TO_PERFORM +*/ Slapi_PBlock * -slapi_search_internal( +slapi_delete_internal( char *ldn, - int scope, - char *filStr, LDAPControl **controls, - char **attrs, - int attrsonly ) -{ -#ifdef LDAP_SLAPI - Connection *c; - Operation *op = NULL; - Slapi_PBlock *pPB = NULL; - struct berval dn = BER_BVNULL; - Filter *filter=NULL; - struct berval fstr = BER_BVNULL; - AttributeName *an = NULL; - const char *text = NULL; - - int manageDsaIt = SLAP_CONTROL_NONE; - int isCritical; - int i; - - SlapReply rs = { REP_RESULT }; - - c = slapi_int_init_connection( NULL, LDAP_REQ_SEARCH ); - if ( c == NULL ) { - rs.sr_err = LDAP_NO_MEMORY; - goto cleanup; - } - - op = (Operation *)c->c_pending_ops.stqh_first; - pPB = (Slapi_PBlock *)op->o_pb; - op->o_ctrls = controls; - - if ( ldn != NULL ) { - dn.bv_val = slapi_ch_strdup(ldn); - dn.bv_len = strlen(ldn); - } - - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); - if ( rs.sr_err != LDAP_SUCCESS ) { - goto cleanup; - } - - if ( scope != LDAP_SCOPE_BASE && - scope != LDAP_SCOPE_ONELEVEL && - scope != LDAP_SCOPE_SUBTREE ) { - rs.sr_err = LDAP_PROTOCOL_ERROR; - goto cleanup; - } - - filter = slapi_str2filter(filStr); - if ( filter == NULL ) { - rs.sr_err = LDAP_PROTOCOL_ERROR; - goto cleanup; - } - - filter2bv( filter, &fstr ); - - for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) { - ; /* count the number of attributes */ - } - - if (i > 0) { - an = (AttributeName *)slapi_ch_calloc( (i + 1), sizeof(AttributeName) ); - for (i = 0; attrs[i] != 0; i++) { - an[i].an_desc = NULL; - an[i].an_oc = NULL; - an[i].an_oc_exclude = 0; - an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]); - an[i].an_name.bv_len = strlen(attrs[i]); - slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text ); - } - an[i].an_name.bv_val = NULL; - } - - memset( &rs, 0, sizeof(rs) ); - rs.sr_type = REP_RESULT; - rs.sr_err = LDAP_SUCCESS; - rs.sr_entry = NULL; /* paranoia */ - - if ( scope == LDAP_SCOPE_BASE ) { - rs.sr_entry = NULL; - - if ( op->o_req_ndn.bv_len == 0 ) { - rs.sr_err = root_dse_info( c, &rs.sr_entry, &rs.sr_text ); - } - - if( rs.sr_err != LDAP_SUCCESS ) { - send_ldap_result( op, &rs ); - goto cleanup; - } else if ( rs.sr_entry != NULL ) { - rs.sr_err = test_filter( op, rs.sr_entry, filter ); - - if ( rs.sr_err == LDAP_COMPARE_TRUE ) { - rs.sr_type = REP_SEARCH; - rs.sr_err = LDAP_SUCCESS; - rs.sr_attrs = an; - rs.sr_operational_attrs = NULL; - rs.sr_flags = REP_ENTRY_MODIFIABLE; - - send_search_entry( op, &rs ); - } - - entry_free( rs.sr_entry ); - - rs.sr_type = REP_RESULT; - rs.sr_err = LDAP_SUCCESS; - - send_ldap_result( op, &rs ); - - goto cleanup; - } - } - - if ( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) { - slapi_ch_free( (void **)&op->o_req_dn.bv_val ); - slapi_ch_free( (void **)&op->o_req_ndn.bv_val ); - - ber_dupbv( &op->o_req_dn, &default_search_base ); - ber_dupbv( &op->o_req_ndn, &default_search_nbase ); - } - - if ( slapi_control_present( controls, - LDAP_CONTROL_MANAGEDSAIT, NULL, &isCritical ) ) { - manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL; - } - - op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 ); - if ( op->o_bd == NULL ) { - if ( manageDsaIt > SLAP_CONTROL_NONE ) { - rs.sr_err = LDAP_NO_SUCH_OBJECT; - } else { - rs.sr_err = LDAP_PARTIAL_RESULTS; - } - goto cleanup; - } - - op->o_dn = c->c_dn = op->o_bd->be_rootdn; - op->o_ndn = c->c_ndn = op->o_bd->be_rootndn; - - op->oq_search.rs_scope = scope; - op->oq_search.rs_deref = 0; - op->oq_search.rs_slimit = SLAP_NO_LIMIT; - op->oq_search.rs_tlimit = SLAP_NO_LIMIT; - op->oq_search.rs_attrsonly = attrsonly; - op->oq_search.rs_attrs = an; - op->oq_search.rs_filter = filter; - op->oq_search.rs_filterstr = fstr; - - if ( op->o_bd->be_search ) { - if ( (*op->o_bd->be_search)( op, &rs ) != 0 ) { - rs.sr_err = LDAP_OTHER; - } - } else { - rs.sr_err = LDAP_UNWILLING_TO_PERFORM; - } - -cleanup: + int log_change ) +{ + Slapi_PBlock *pb; - if ( pPB != NULL ) - slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err ); + pb = slapi_pblock_new(); - if ( dn.bv_val ) - slapi_ch_free( (void **)&dn.bv_val ); - if ( filter ) - slapi_filter_free( filter, 1 ); - if ( fstr.bv_val ) - slapi_ch_free( (void **)&fstr.bv_val ); - if ( an != NULL ) - slapi_ch_free( (void **)&an ); + slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL, 0 ); + slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change ); + slapi_delete_internal_pb( pb ); - slapi_int_connection_destroy( &c ); + return pb; +} - return pPB; -#else - return NULL; #endif /* LDAP_SLAPI */ -} diff --git a/servers/slapd/slapi/slapi_overlay.c b/servers/slapd/slapi/slapi_overlay.c new file mode 100644 index 0000000000..9670898f4e --- /dev/null +++ b/servers/slapd/slapi/slapi_overlay.c @@ -0,0 +1,899 @@ +/* slapi_overlay.c - SLAPI overlay */ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 2001-2005 The OpenLDAP Foundation. + * 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 + * . + */ +/* ACKNOWLEDGEMENTS: + * This work was initially developed by Luke Howard for inclusion + * in OpenLDAP Software. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "slapi.h" + +#ifdef LDAP_SLAPI + +static slap_overinst slapi; +static int slapi_over_initialized = 0; + +static int slapi_over_response( Operation *op, SlapReply *rs ); +static int slapi_over_cleanup( Operation *op, SlapReply *rs ); + +static Slapi_PBlock * +slapi_over_pblock_new( Operation *op, SlapReply *rs ) +{ + Slapi_PBlock *pb; + + pb = slapi_pblock_new(); + pb->pb_op = op; + pb->pb_conn = op->o_conn; + pb->pb_rs = rs; + pb->pb_intop = 0; + + PBLOCK_ASSERT_OP( pb, op->o_tag ); + + return pb; +} + +static int +slapi_op_internal_p( Operation *op, SlapReply *rs, slap_callback *cb ) +{ + int internal_op = 0; + Slapi_PBlock *pb = NULL; + slap_callback *pcb; + + /* + * Abstraction violating check for SLAPI internal operations + * allows pblock to remain consistent when invoking internal + * op plugins + */ + for ( pcb = op->o_callback; pcb != NULL; pcb = pcb->sc_next ) { + if ( pcb->sc_response == slapi_int_response ) { + pb = (Slapi_PBlock *)pcb->sc_private; + PBLOCK_ASSERT_INTOP( pb, 0 ); + internal_op = 1; + break; + } + } + + if ( cb != NULL ) { + if ( pb == NULL ) { + pb = slapi_over_pblock_new( op, rs ); + } + + cb->sc_response = slapi_over_response; + cb->sc_cleanup = slapi_over_cleanup; + cb->sc_private = pb; + cb->sc_next = op->o_callback; + op->o_callback = cb; + } + + return internal_op; +} + +static int +slapi_over_compute_output( + computed_attr_context *c, + Slapi_Attr *attribute, + Slapi_Entry *entry +) +{ + Attribute **a; + AttributeDescription *desc; + SlapReply *rs = (SlapReply *)c->cac_private; + + if ( c == NULL || attribute == NULL || entry == NULL ) { + return 0; + } + + assert( rs->sr_entry == entry ); + + desc = attribute->a_desc; + + if ( rs->sr_attrs == NULL ) { + /* All attrs request, skip operational attributes */ + if ( is_at_operational( desc->ad_type ) ) { + return 0; + } + } else { + /* Specific attributes requested */ + if ( is_at_operational( desc->ad_type ) ) { + if ( !SLAP_OPATTRS( rs->sr_attr_flags ) && + !ad_inlist( desc, rs->sr_attrs ) ) { + return 0; + } + } else { + if ( !SLAP_USERATTRS( rs->sr_attr_flags ) && + !ad_inlist( desc, rs->sr_attrs ) ) { + return 0; + } + } + } + + /* XXX perhaps we should check for existing attributes and merge */ + for ( a = &rs->sr_operational_attrs; *a != NULL; a = &(*a)->a_next ) + ; + + *a = slapi_attr_dup( attribute ); + + return 0; +} + +static int +slapi_over_aux_operational( Operation *op, SlapReply *rs ) +{ + /* Support for computed attribute plugins */ + computed_attr_context ctx; + AttributeName *anp; + + if ( slapi_op_internal_p( op, rs, NULL ) ) { + return SLAP_CB_CONTINUE; + } + + ctx.cac_pb = slapi_over_pblock_new( op, rs ); + ctx.cac_op = op; + ctx.cac_private = rs; + + if ( rs->sr_entry != NULL ) { + /* + * For each client requested attribute, call the plugins. + */ + if ( rs->sr_attrs != NULL ) { + for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) { + if ( compute_evaluator( &ctx, anp->an_name.bv_val, + rs->sr_entry, slapi_over_compute_output ) == 1 ) { + break; + } + } + } else { + /* + * Technically we shouldn't be returning operational attributes + * when the user requested only user attributes. We'll let the + * plugin decide whether to be naughty or not. + */ + compute_evaluator( &ctx, "*", rs->sr_entry, slapi_over_compute_output ); + } + } + + slapi_pblock_destroy( ctx.cac_pb ); + + return SLAP_CB_CONTINUE; +} + +/* + * We need this function to call frontendDB (global) plugins before + * database plugins, if we are invoked by a slap_callback. + */ +static int +slapi_over_call_plugins( Slapi_PBlock *pb, int type ) +{ + int rc = 1; /* means no plugins called */ + Operation *op; + + PBLOCK_ASSERT_OP( pb, 0 ); + op = pb->pb_op; + + if ( op->o_bd != frontendDB ) { + rc = slapi_int_call_plugins( frontendDB, type, pb ); + } + if ( rc >= 0 ) { + rc = slapi_int_call_plugins( op->o_bd, type, pb ); + } + + return rc; +} + +static int +slapi_over_search( Operation *op, SlapReply *rs, int type ) +{ + int rc; + Slapi_PBlock *pb; + + assert( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF ); + + /* create a new pblock to not trample on result controls */ + pb = slapi_over_pblock_new( op, rs ); + + rc = slapi_over_call_plugins( pb, type ); + if ( rc >= 0 ) /* 1 means no plugins called */ + rc = SLAP_CB_CONTINUE; + else + rc = LDAP_SUCCESS; /* confusing: don't abort, but don't send */ + + slapi_pblock_destroy(pb); + + return rc; +} + +/* + * Call pre- and post-result plugins + */ +static int +slapi_over_result( Operation *op, SlapReply *rs, int type ) +{ + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + + assert( rs->sr_type == REP_RESULT ); + + slapi_over_call_plugins( pb, type ); + + return SLAP_CB_CONTINUE; +} + + +static int +slapi_op_bind_callback( Operation *op, SlapReply *rs, int prc ) +{ + switch ( prc ) { + case SLAPI_BIND_SUCCESS: + /* Continue with backend processing */ + break; + case SLAPI_BIND_FAIL: + /* Failure, frontend (that's us) sends result */ + rs->sr_err = LDAP_INVALID_CREDENTIALS; + send_ldap_result( op, rs ); + return rs->sr_err; + break; + case SLAPI_BIND_ANONYMOUS: /* undocumented */ + default: /* plugin sent result or no plugins called */ + BER_BVZERO( &op->orb_edn ); + + if ( rs->sr_err == LDAP_SUCCESS ) { + /* + * Plugin will have called slapi_pblock_set(LDAP_CONN_DN) which + * will have set conn->c_dn and conn->c_ndn + */ + if ( BER_BVISNULL( &op->o_conn->c_ndn ) && prc == 1 ) { + /* No plugins were called; continue processing */ + return LDAP_SUCCESS; + } + ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); + if ( !BER_BVISEMPTY( &op->o_conn->c_ndn ) ) { + ber_len_t max = sockbuf_max_incoming_auth; + ber_sockbuf_ctrl( op->o_conn->c_sb, + LBER_SB_OPT_SET_MAX_INCOMING, &max ); + } + ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex ); + + /* log authorization identity */ + Statslog( LDAP_DEBUG_STATS, + "%s BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n", + op->o_log_prefix, + BER_BVISNULL( &op->o_conn->c_dn ) + ? "" : op->o_conn->c_dn.bv_val, + op->orb_tmp_mech.bv_val, 0, 0 ); + + return -1; + } + break; + } + + return rs->sr_err; +} + +static int +slapi_op_search_callback( Operation *op, SlapReply *rs, int prc ) +{ + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + + /* check preoperation result code */ + if ( prc < 0 ) { + return rs->sr_err; + } + + rs->sr_err = LDAP_SUCCESS; + + if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb ) == 0 ) { + /* + * The plugin can set the SLAPI_SEARCH_FILTER. + * SLAPI_SEARCH_STRFILER is not normative. + */ + op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx ); + filter2bv_x( op, op->ors_filter, &op->ors_filterstr ); + } + + return LDAP_SUCCESS; +} + +struct slapi_op_info { + int soi_preop; /* preoperation plugin parameter */ + int soi_postop; /* postoperation plugin parameter */ + int soi_internal_preop; /* internal preoperation plugin parameter */ + int soi_internal_postop; /* internal postoperation plugin parameter */ + int (*soi_callback)(Operation *, SlapReply *, int); /* preoperation result handler */ +} slapi_op_dispatch_table[] = { + { + SLAPI_PLUGIN_PRE_BIND_FN, + SLAPI_PLUGIN_POST_BIND_FN, + 0, + 0, + slapi_op_bind_callback + }, + { + SLAPI_PLUGIN_PRE_UNBIND_FN, + SLAPI_PLUGIN_POST_UNBIND_FN, + 0, + 0, + NULL + }, + { + SLAPI_PLUGIN_PRE_SEARCH_FN, + SLAPI_PLUGIN_POST_SEARCH_FN, + 0, + 0, + slapi_op_search_callback + }, + { + SLAPI_PLUGIN_PRE_COMPARE_FN, + SLAPI_PLUGIN_POST_COMPARE_FN, + 0, + 0, + NULL + }, + { + SLAPI_PLUGIN_PRE_MODIFY_FN, + SLAPI_PLUGIN_POST_MODIFY_FN, + SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN, + SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN, + NULL + }, + { + SLAPI_PLUGIN_PRE_MODRDN_FN, + SLAPI_PLUGIN_POST_MODRDN_FN, + SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN, + SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN, + NULL + }, + { + SLAPI_PLUGIN_PRE_ADD_FN, + SLAPI_PLUGIN_POST_ADD_FN, + SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN, + SLAPI_PLUGIN_INTERNAL_POST_ADD_FN, + NULL + }, + { + SLAPI_PLUGIN_PRE_DELETE_FN, + SLAPI_PLUGIN_POST_DELETE_FN, + SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN, + SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN, + NULL + }, + { + SLAPI_PLUGIN_PRE_ABANDON_FN, + SLAPI_PLUGIN_POST_ABANDON_FN, + 0, + 0, + NULL + }, + { + 0, + 0, + 0, + 0, + NULL + } +}; + +slap_operation_t +slapi_tag2op( ber_tag_t tag ) +{ + slap_operation_t op; + + switch ( tag ) { + case LDAP_REQ_BIND: + op = op_bind; + break; + case LDAP_REQ_ADD: + op = op_add; + break; + case LDAP_REQ_DELETE: + op = op_delete; + break; + case LDAP_REQ_MODRDN: + op = op_modrdn; + break; + case LDAP_REQ_MODIFY: + op = op_modify; + break; + case LDAP_REQ_COMPARE: + op = op_compare; + break; + case LDAP_REQ_SEARCH: + op = op_search; + break; + case LDAP_REQ_UNBIND: + op = op_unbind; + break; + default: + op = op_last; + break; + } + + return op; +} + +/* Add SLAPI_RESCONTROLS to rs->sr_ctrls, with care, because + * rs->sr_ctrls could be allocated on the stack */ +static int +slapi_over_merge_controls( Operation *op, SlapReply *rs ) +{ + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + LDAPControl **ctrls = NULL; + LDAPControl **slapi_ctrls = NULL; + size_t n_slapi_ctrls = 0; + size_t n_rs_ctrls = 0; + size_t i; + + slapi_pblock_get( pb, SLAPI_RESCONTROLS, (void **)&slapi_ctrls ); + + n_slapi_ctrls = slapi_int_count_controls( slapi_ctrls ); + n_rs_ctrls = slapi_int_count_controls( rs->sr_ctrls ); + + slapi_pblock_set( pb, SLAPI_X_OLD_RESCONTROLS, (void *)rs->sr_ctrls ); + + if ( n_slapi_ctrls == 0 ) + return LDAP_SUCCESS; /* no SLAPI controls */ + + ctrls = (LDAPControl **) op->o_tmpalloc( + ( n_slapi_ctrls + n_rs_ctrls + 1 ) * sizeof(LDAPControl *), + op->o_tmpmemctx ); + + for ( i = 0; i < n_slapi_ctrls; i++ ) { + ctrls[i] = slapi_ctrls[i]; + } + if ( rs->sr_ctrls != NULL ) { + for ( i = 0; i < n_rs_ctrls; i++ ) { + ctrls[n_slapi_ctrls + i] = rs->sr_ctrls[i]; + } + } + ctrls[n_slapi_ctrls + n_rs_ctrls] = NULL; + + rs->sr_ctrls = ctrls; + + return LDAP_SUCCESS; +} + +static int +slapi_over_unmerge_controls( Operation *op, SlapReply *rs ) +{ + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + LDAPControl **rs_ctrls = NULL; + + slapi_pblock_get( pb, SLAPI_X_OLD_RESCONTROLS, (void **)&rs_ctrls ); + + if ( rs->sr_ctrls == NULL || rs->sr_ctrls == rs_ctrls ) { + /* no copying done */ + return LDAP_SUCCESS; + } + + op->o_tmpfree( rs->sr_ctrls, op->o_tmpmemctx ); + rs->sr_ctrls = rs_ctrls; + + return LDAP_SUCCESS; +} + +static int +slapi_over_response( Operation *op, SlapReply *rs ) +{ + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + int rc = SLAP_CB_CONTINUE; + + if ( pb->pb_intop == 0 ) { + switch ( rs->sr_type ) { + case REP_RESULT: + rc = slapi_over_result( op, rs, SLAPI_PLUGIN_PRE_RESULT_FN ); + break; + case REP_SEARCH: + rc = slapi_over_search( op, rs, SLAPI_PLUGIN_PRE_ENTRY_FN ); + break; + case REP_SEARCHREF: + rc = slapi_over_search( op, rs, SLAPI_PLUGIN_PRE_REFERRAL_FN ); + break; + default: + break; + } + } + + slapi_over_merge_controls( op, rs ); + + return rc; +} + +static int +slapi_over_cleanup( Operation *op, SlapReply *rs ) +{ + Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op ); + int rc = SLAP_CB_CONTINUE; + + slapi_over_unmerge_controls( op, rs ); + + if ( pb->pb_intop == 0 ) { + switch ( rs->sr_type ) { + case REP_RESULT: + rc = slapi_over_result( op, rs, SLAPI_PLUGIN_POST_RESULT_FN ); + break; + case REP_SEARCH: + rc = slapi_over_search( op, rs, SLAPI_PLUGIN_POST_ENTRY_FN ); + break; + case REP_SEARCHREF: + rc = slapi_over_search( op, rs, SLAPI_PLUGIN_POST_REFERRAL_FN ); + break; + default: + break; + } + } + + return rc; +} + +static int +slapi_op_func( Operation *op, SlapReply *rs ) +{ + Slapi_PBlock *pb; + slap_operation_t which; + struct slapi_op_info *opinfo; + int rc; + slap_overinfo *oi; + slap_overinst *on; + slap_callback cb; + int internal_op; + int preop_type, postop_type; + BackendDB *be; + + if ( !slapi_plugins_used ) + return SLAP_CB_CONTINUE; + + /* + * Find the SLAPI operation information for this LDAP + * operation; this will contain the preop and postop + * plugin types, as well as optional callbacks for + * setting up the SLAPI environment. + */ + which = slapi_tag2op( op->o_tag ); + if ( which >= op_last ) { + /* invalid operation, but let someone else deal with it */ + return SLAP_CB_CONTINUE; + } + + opinfo = &slapi_op_dispatch_table[which]; + if ( opinfo == NULL ) { + /* no SLAPI plugin types for this operation */ + return SLAP_CB_CONTINUE; + } + + internal_op = slapi_op_internal_p( op, rs, &cb ); + + if ( internal_op ) { + preop_type = opinfo->soi_internal_preop; + postop_type = opinfo->soi_internal_postop; + } else { + preop_type = opinfo->soi_preop; + postop_type = opinfo->soi_postop; + } + + if ( preop_type == 0 ) { + /* no SLAPI plugin types for this operation */ + pb = NULL; + rc = SLAP_CB_CONTINUE; + goto cleanup; + } + + pb = SLAPI_OPERATION_PBLOCK( op ); + + /* cache backend so we call correct postop plugins */ + be = pb->pb_op->o_bd; + + rc = slapi_int_call_plugins( be, preop_type, pb ); + + /* + * soi_callback is responsible for examining the result code + * of the preoperation plugin and determining whether to + * abort. This is needed because of special SLAPI behaviour + e with bind preoperation plugins. + * + * The soi_callback function is also used to reset any values + * returned from the preoperation plugin before calling the + * backend (for the success case). + */ + if ( opinfo->soi_callback == NULL ) { + /* default behaviour is preop plugin can abort operation */ + if ( rc < 0 ) { + rc = rs->sr_err; + goto cleanup; + } + } else { + rc = (opinfo->soi_callback)( op, rs, rc ); + if ( rc ) + goto cleanup; + } + + /* + * Call actual backend (or next overlay in stack). We need to + * do this rather than returning SLAP_CB_CONTINUE and calling + * postoperation plugins in a response handler to match the + * behaviour of SLAPI in OpenLDAP 2.2, where postoperation + * plugins are called after the backend has completely + * finished processing the operation. + */ + on = (slap_overinst *)op->o_bd->bd_info; + oi = on->on_info; + + rc = overlay_op_walk( op, rs, which, oi, on->on_next ); + + /* + * Call postoperation plugins + */ + slapi_int_call_plugins( be, postop_type, pb ); + +cleanup: + if ( !internal_op ) { + slapi_pblock_destroy(pb); + cb.sc_private = NULL; + } + + op->o_callback = cb.sc_next; + + return rc; +} + +static int +slapi_over_extended( Operation *op, SlapReply *rs ) +{ + Slapi_PBlock *pb; + SLAPI_FUNC callback; + int rc; + int internal_op; + slap_callback cb; + + slapi_int_get_extop_plugin( &op->ore_reqoid, &callback ); + if ( callback == NULL ) { + return SLAP_CB_CONTINUE; + } + + internal_op = slapi_op_internal_p( op, rs, &cb ); + if ( internal_op ) { + return SLAP_CB_CONTINUE; + } + + pb = SLAPI_OPERATION_PBLOCK( op ); + + rc = (*callback)( pb ); + if ( rc == SLAPI_PLUGIN_EXTENDED_SENT_RESULT ) { + goto cleanup; + } else if ( rc == SLAPI_PLUGIN_EXTENDED_NOT_HANDLED ) { + rc = SLAP_CB_CONTINUE; + goto cleanup; + } + + assert( rs->sr_rspoid != NULL ); + + send_ldap_extended( op, rs ); + +#if 0 + slapi_ch_free_string( (char **)&rs->sr_rspoid ); +#endif + + if ( rs->sr_rspdata != NULL ) + ber_bvfree( rs->sr_rspdata ); + + rc = rs->sr_err; + +cleanup: + slapi_pblock_destroy( pb ); + op->o_callback = cb.sc_next; + + return rc; +} + +static int +slapi_over_access_allowed( + Operation *op, + Entry *e, + AttributeDescription *desc, + struct berval *val, + slap_access_t access, + AccessControlState *state, + slap_mask_t *maskp ) +{ + int rc; + Slapi_PBlock *pb; + slap_callback cb; + int internal_op; + SlapReply rs = { REP_RESULT }; + + internal_op = slapi_op_internal_p( op, &rs, &cb ); + + cb.sc_response = NULL; + cb.sc_cleanup = NULL; + + pb = SLAPI_OPERATION_PBLOCK( op ); + + rc = slapi_int_access_allowed( op, e, desc, val, access, state ); + if ( rc ) { + rc = SLAP_CB_CONTINUE; + } + + if ( !internal_op ) { + slapi_pblock_destroy( pb ); + } + + op->o_callback = cb.sc_next; + + return rc; +} + +static int +slapi_over_acl_group( + Operation *op, + Entry *target, + struct berval *gr_ndn, + struct berval *op_ndn, + ObjectClass *group_oc, + AttributeDescription *group_at ) +{ + Slapi_Entry *e; + int rc; + Slapi_PBlock *pb; + BackendDB *be = op->o_bd; + GroupAssertion *g; + SlapReply rs = { REP_RESULT }; + + op->o_bd = select_backend( gr_ndn, 0, 0 ); + + for ( g = op->o_groups; g; g = g->ga_next ) { + if ( g->ga_be != op->o_bd || g->ga_oc != group_oc || + g->ga_at != group_at || g->ga_len != gr_ndn->bv_len ) + { + continue; + } + if ( strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0 ) { + break; + } + } + if ( g != NULL ) { + rc = g->ga_res; + goto done; + } + + if ( target != NULL && dn_match( &target->e_nname, gr_ndn ) ) { + e = target; + rc = 0; + } else { + rc = be_entry_get_rw( op, gr_ndn, group_oc, group_at, 0, &e ); + } + if ( e != NULL ) { + int internal_op; + slap_callback cb; + + internal_op = slapi_op_internal_p( op, &rs, &cb ); + + cb.sc_response = NULL; + cb.sc_cleanup = NULL; + + pb = SLAPI_OPERATION_PBLOCK( op ); + + slapi_pblock_set( pb, SLAPI_X_GROUP_ENTRY, (void *)e ); + slapi_pblock_set( pb, SLAPI_X_GROUP_OPERATION_DN, (void *)op_ndn->bv_val ); + slapi_pblock_set( pb, SLAPI_X_GROUP_ATTRIBUTE, (void *)group_at->ad_cname.bv_val ); + slapi_pblock_set( pb, SLAPI_X_GROUP_TARGET_ENTRY, (void *)target ); + + rc = slapi_over_call_plugins( pb, SLAPI_X_PLUGIN_PRE_GROUP_FN ); + if ( rc >= 0 ) /* 1 means no plugins called */ + rc = SLAP_CB_CONTINUE; + else + rc = pb->pb_rs->sr_err; + + slapi_pblock_delete_param( pb, SLAPI_X_GROUP_ENTRY ); + slapi_pblock_delete_param( pb, SLAPI_X_GROUP_OPERATION_DN ); + slapi_pblock_delete_param( pb, SLAPI_X_GROUP_ATTRIBUTE ); + slapi_pblock_delete_param( pb, SLAPI_X_GROUP_TARGET_ENTRY ); + + if ( !internal_op ) + slapi_pblock_destroy( pb ); + + if ( e != target ) { + be_entry_release_r( op, e ); + } + + op->o_callback = cb.sc_next; + } else { + rc = LDAP_NO_SUCH_OBJECT; /* return SLAP_CB_CONTINUE for correctness? */ + } + + if ( op->o_tag != LDAP_REQ_BIND && !op->o_do_not_cache && + rc != SLAP_CB_CONTINUE ) { + g = op->o_tmpalloc( sizeof( GroupAssertion ) + gr_ndn->bv_len, + op->o_tmpmemctx ); + g->ga_be = op->o_bd; + g->ga_oc = group_oc; + g->ga_at = group_at; + g->ga_res = rc; + g->ga_len = gr_ndn->bv_len; + strcpy( g->ga_ndn, gr_ndn->bv_val ); + g->ga_next = op->o_groups; + op->o_groups = g; + } + /* + * XXX don't call POST_GROUP_FN, I have no idea what the point of + * that plugin function was anyway + */ +done: + op->o_bd = be; + return rc; +} + +static int +slapi_over_init() +{ + memset( &slapi, 0, sizeof(slapi) ); + + slapi.on_bi.bi_type = SLAPI_OVERLAY_NAME; + + slapi.on_bi.bi_op_bind = slapi_op_func; + slapi.on_bi.bi_op_unbind = slapi_op_func; + slapi.on_bi.bi_op_search = slapi_op_func; + slapi.on_bi.bi_op_compare = slapi_op_func; + slapi.on_bi.bi_op_modify = slapi_op_func; + slapi.on_bi.bi_op_modrdn = slapi_op_func; + slapi.on_bi.bi_op_add = slapi_op_func; + slapi.on_bi.bi_op_delete = slapi_op_func; + slapi.on_bi.bi_op_abandon = slapi_op_func; + slapi.on_bi.bi_op_cancel = slapi_op_func; + + slapi.on_bi.bi_extended = slapi_over_extended; + slapi.on_bi.bi_access_allowed = slapi_over_access_allowed; + slapi.on_bi.bi_operational = slapi_over_aux_operational; + slapi.on_bi.bi_acl_group = slapi_over_acl_group; + + return overlay_register( &slapi ); +} + +int slapi_over_is_inst( BackendDB *be ) +{ + return overlay_is_inst( be, SLAPI_OVERLAY_NAME ); +} + +int slapi_over_config( BackendDB *be ) +{ + if ( slapi_over_initialized == 0 ) { + int rc; + + /* do global initializaiton */ + ldap_pvt_thread_mutex_init( &slapi_hn_mutex ); + ldap_pvt_thread_mutex_init( &slapi_time_mutex ); + ldap_pvt_thread_mutex_init( &slapi_printmessage_mutex ); + + slapi_log_file = slapi_ch_strdup( LDAP_RUNDIR LDAP_DIRSEP "errors" ); + + rc = slapi_int_init_object_extensions(); + if ( rc != 0 ) + return rc; + + rc = slapi_over_init(); + if ( rc != 0 ) + return rc; + + slapi_over_initialized = 1; + } + + return overlay_config( be, SLAPI_OVERLAY_NAME ); +} + +#endif /* LDAP_SLAPI */ diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index 6dcbe7b536..1b4e5dab56 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -24,13 +24,26 @@ #include #include +#ifdef LDAP_SLAPI + +/* some parameters require a valid connection and operation */ +#define PBLOCK_LOCK_CONN( _pb ) do { \ + ldap_pvt_thread_mutex_lock( &(_pb)->pb_conn->c_mutex ); \ + } while (0) + +#define PBLOCK_UNLOCK_CONN( _pb ) do { \ + ldap_pvt_thread_mutex_unlock( &(_pb)->pb_conn->c_mutex ); \ + } while (0) + +/* some parameters are only settable for internal operations */ +#define PBLOCK_VALIDATE_IS_INTOP( _pb ) do { if ( (_pb)->pb_intop == 0 ) break; } while ( 0 ) + static slapi_pblock_class_t -getPBlockClass( int param ) +pblock_get_param_class( int param ) { switch ( param ) { case SLAPI_PLUGIN_TYPE: case SLAPI_PLUGIN_ARGC: - case SLAPI_PLUGIN_VERSION: case SLAPI_PLUGIN_OPRETURN: case SLAPI_PLUGIN_INTOP_RESULT: case SLAPI_CONFIG_LINENO: @@ -51,18 +64,13 @@ getPBlockClass( int param ) case SLAPI_DB2LDIF_PRINTKEY: case SLAPI_LDIF2DB_REMOVEDUPVALS: case SLAPI_MANAGEDSAIT: - case SLAPI_IBM_BROADCAST_BE: - case SLAPI_IBM_REPLICATE: - case SLAPI_IBM_CL_MAX_ENTRIES: - case SLAPI_IBM_CL_FIRST_ENTRY: - case SLAPI_IBM_CL_LAST_ENTRY: - case SLAPI_IBM_EVENT_ENABLED: - case SLAPI_IBM_EVENT_MAXREG: - case SLAPI_IBM_EVENT_REGPERCONN: - case SLAPI_REQUESTOR_ISUPDATEDN: + case SLAPI_X_MANAGEDIT: + case SLAPI_X_OPERATION_NO_SCHEMA_CHECK: + case SLAPI_IS_REPLICATED_OPERATION: case SLAPI_X_CONN_IS_UDP: case SLAPI_X_CONN_SSF: case SLAPI_RESULT_CODE: + case SLAPI_LOG_OPERATION: return PBLOCK_CLASS_INTEGER; break; @@ -70,10 +78,10 @@ getPBlockClass( int param ) case SLAPI_OPERATION_ID: case SLAPI_OPINITIATED_TIME: case SLAPI_ABANDON_MSGID: + case SLAPI_X_OPERATION_DELETE_GLUE_PARENT: return PBLOCK_CLASS_LONG_INTEGER; break; - case SLAPI_PLUGIN_DB_INIT_FN: case SLAPI_PLUGIN_DESTROY_FN: case SLAPI_PLUGIN_DB_BIND_FN: case SLAPI_PLUGIN_DB_UNBIND_FN: @@ -118,6 +126,14 @@ getPBlockClass( int param ) case SLAPI_PLUGIN_PRE_ENTRY_FN: case SLAPI_PLUGIN_PRE_REFERRAL_FN: case SLAPI_PLUGIN_PRE_RESULT_FN: + case SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN: + case SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN: + case SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN: + case SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN: + case SLAPI_PLUGIN_BE_PRE_ADD_FN: + case SLAPI_PLUGIN_BE_PRE_MODIFY_FN: + case SLAPI_PLUGIN_BE_PRE_MODRDN_FN: + case SLAPI_PLUGIN_BE_PRE_DELETE_FN: case SLAPI_PLUGIN_POST_BIND_FN: case SLAPI_PLUGIN_POST_UNBIND_FN: case SLAPI_PLUGIN_POST_SEARCH_FN: @@ -130,6 +146,14 @@ getPBlockClass( int param ) case SLAPI_PLUGIN_POST_ENTRY_FN: case SLAPI_PLUGIN_POST_REFERRAL_FN: case SLAPI_PLUGIN_POST_RESULT_FN: + case SLAPI_PLUGIN_INTERNAL_POST_ADD_FN: + case SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN: + case SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN: + case SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN: + case SLAPI_PLUGIN_BE_POST_ADD_FN: + case SLAPI_PLUGIN_BE_POST_MODIFY_FN: + case SLAPI_PLUGIN_BE_POST_MODRDN_FN: + case SLAPI_PLUGIN_BE_POST_DELETE_FN: case SLAPI_PLUGIN_MR_FILTER_CREATE_FN: case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN: case SLAPI_PLUGIN_MR_FILTER_MATCH_FN: @@ -164,9 +188,11 @@ getPBlockClass( int param ) case SLAPI_X_CONN_SERVERPATH: case SLAPI_X_CONN_SASL_CONTEXT: case SLAPI_X_CONFIG_ARGV: - case SLAPI_IBM_CONN_DN_ALT: - case SLAPI_IBM_CONN_DN_ORIG: - case SLAPI_IBM_GSSAPI_CONTEXT: + case SLAPI_X_INTOP_FLAGS: + case SLAPI_X_INTOP_RESULT_CALLBACK: + case SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK: + case SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK: + case SLAPI_X_INTOP_CALLBACK_DATA: case SLAPI_PLUGIN_MR_OID: case SLAPI_PLUGIN_MR_TYPE: case SLAPI_PLUGIN_MR_VALUE: @@ -177,6 +203,7 @@ getPBlockClass( int param ) case SLAPI_PLUGIN_ARGV: case SLAPI_PLUGIN_OBJECT: case SLAPI_PLUGIN_DESCRIPTION: + case SLAPI_PLUGIN_IDENTITY: case SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES: case SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS: case SLAPI_PLUGIN_MR_FILTER_REUSABLE: @@ -196,13 +223,21 @@ getPBlockClass( int param ) case SLAPI_PLUGIN_SYNTAX_COMPARE: case SLAPI_CONFIG_FILENAME: case SLAPI_CONFIG_ARGV: + case SLAPI_TARGET_ADDRESS: + case SLAPI_TARGET_UNIQUEID: case SLAPI_TARGET_DN: case SLAPI_REQCONTROLS: case SLAPI_ENTRY_PRE_OP: case SLAPI_ENTRY_POST_OP: case SLAPI_RESCONTROLS: + case SLAPI_X_OLD_RESCONTROLS: case SLAPI_ADD_RESCONTROL: + case SLAPI_CONTROLS_ARG: case SLAPI_ADD_ENTRY: + case SLAPI_ADD_EXISTING_DN_ENTRY: + case SLAPI_ADD_PARENT_ENTRY: + case SLAPI_ADD_PARENT_UNIQUEID: + case SLAPI_ADD_EXISTING_UNIQUEID_ENTRY: case SLAPI_BIND_CREDENTIALS: case SLAPI_BIND_SASLMECHANISM: case SLAPI_BIND_RET_SASLCREDS: @@ -211,6 +246,10 @@ getPBlockClass( int param ) case SLAPI_MODIFY_MODS: case SLAPI_MODRDN_NEWRDN: case SLAPI_MODRDN_NEWSUPERIOR: + case SLAPI_MODRDN_PARENT_ENTRY: + case SLAPI_MODRDN_NEWPARENT_ENTRY: + case SLAPI_MODRDN_TARGET_ENTRY: + case SLAPI_MODRDN_NEWSUPERIOR_ADDRESS: case SLAPI_SEARCH_FILTER: case SLAPI_SEARCH_STRFILTER: case SLAPI_SEARCH_ATTRS: @@ -232,7 +271,6 @@ getPBlockClass( int param ) case SLAPI_SEARCH_RESULT_SET: case SLAPI_SEARCH_RESULT_ENTRY: case SLAPI_SEARCH_REFERRALS: - case SLAPI_LOG_OPERATION: case SLAPI_RESULT_TEXT: case SLAPI_RESULT_MATCHED: case SLAPI_X_GROUP_ENTRY: @@ -241,6 +279,7 @@ getPBlockClass( int param ) case SLAPI_X_GROUP_TARGET_ENTRY: case SLAPI_PLUGIN_AUDIT_DATA: case SLAPI_IBM_PBLOCK: + case SLAPI_PLUGIN_VERSION: return PBLOCK_CLASS_POINTER; break; default: @@ -251,55 +290,57 @@ getPBlockClass( int param ) } static void -Lock( Slapi_PBlock *pb ) +pblock_lock( Slapi_PBlock *pb ) { - ldap_pvt_thread_mutex_lock(&pb->pblockMutex); + ldap_pvt_thread_mutex_lock(&pb->pb_mutex); } static void -unLock( Slapi_PBlock *pb ) +pblock_unlock( Slapi_PBlock *pb ) { - ldap_pvt_thread_mutex_unlock(&pb->pblockMutex); + ldap_pvt_thread_mutex_unlock(&pb->pb_mutex); } static int -get( Slapi_PBlock *pb, int param, void **val ) +pblock_get_default( Slapi_PBlock *pb, int param, void **value ) { int i; slapi_pblock_class_t pbClass; - pbClass = getPBlockClass( param ); + pbClass = pblock_get_param_class( param ); if ( pbClass == PBLOCK_CLASS_INVALID ) { return PBLOCK_ERROR; } - Lock( pb ); - switch ( pbClass ) { case PBLOCK_CLASS_INTEGER: - *((int *)val) = 0; + *((int *)value) = 0; break; case PBLOCK_CLASS_LONG_INTEGER: - *((long *)val) = 0L; + *((long *)value) = 0L; break; case PBLOCK_CLASS_POINTER: case PBLOCK_CLASS_FUNCTION_POINTER: - *val = NULL; + *value = NULL; break; + case PBLOCK_CLASS_INVALID: + return PBLOCK_ERROR; } - for ( i = 0; i < pb->numParams; i++ ) { - if ( pb->curParams[i] == param ) { + for ( i = 0; i < pb->pb_nParams; i++ ) { + if ( pb->pb_params[i] == param ) { switch ( pbClass ) { case PBLOCK_CLASS_INTEGER: - *((int *)val) = (int)pb->curVals[i]; + *((int *)value) = pb->pb_values[i].pv_integer; break; case PBLOCK_CLASS_LONG_INTEGER: - *((long *)val) = (long)pb->curVals[i]; + *((long *)value) = pb->pb_values[i].pv_long_integer; break; case PBLOCK_CLASS_POINTER: + *value = pb->pb_values[i].pv_pointer; + break; case PBLOCK_CLASS_FUNCTION_POINTER: - *val = pb->curVals[i]; + *value = pb->pb_values[i].pv_function_pointer; break; default: break; @@ -307,256 +348,989 @@ get( Slapi_PBlock *pb, int param, void **val ) break; } } - unLock( pb ); + return PBLOCK_SUCCESS; } +static char * +pblock_get_authtype( AuthorizationInformation *authz, int is_tls ) +{ + char *authType; + + switch ( authz->sai_method ) { + case LDAP_AUTH_SASL: + authType = SLAPD_AUTH_SASL; + break; + case LDAP_AUTH_SIMPLE: + authType = SLAPD_AUTH_SIMPLE; + break; + case LDAP_AUTH_NONE: + authType = SLAPD_AUTH_NONE; + break; + default: + authType = NULL; + break; + } + + if ( is_tls && authType == NULL ) { + authType = SLAPD_AUTH_SSL; + } + + return authType; +} + static int -set( Slapi_PBlock *pb, int param, void *val ) +pblock_set_default( Slapi_PBlock *pb, int param, void *value ) { -#if defined(LDAP_SLAPI) - int i, freeit; - int addcon = 0; slapi_pblock_class_t pbClass; + size_t i; - pbClass = getPBlockClass( param ); + pbClass = pblock_get_param_class( param ); if ( pbClass == PBLOCK_CLASS_INVALID ) { return PBLOCK_ERROR; } - Lock( pb ); + if ( pb->pb_nParams == PBLOCK_MAX_PARAMS ) { + return PBLOCK_ERROR; + } - if ( pb->numParams == PBLOCK_MAX_PARAMS ) { - unLock( pb ); - return PBLOCK_ERROR; + for ( i = 0; i < pb->pb_nParams; i++ ) { + if ( pb->pb_params[i] == param ) + break; + } + if ( i >= pb->pb_nParams ) { + pb->pb_params[i] = param; + pb->pb_nParams++; } - if ( param == SLAPI_ADD_RESCONTROL ) { - addcon = 1; - param = SLAPI_RES_CONTROLS; + switch ( pbClass ) { + case PBLOCK_CLASS_INTEGER: + pb->pb_values[i].pv_integer = (*((int *)value)); + break; + case PBLOCK_CLASS_LONG_INTEGER: + pb->pb_values[i].pv_long_integer = (*((long *)value)); + break; + case PBLOCK_CLASS_POINTER: + pb->pb_values[i].pv_pointer = value; + break; + case PBLOCK_CLASS_FUNCTION_POINTER: + pb->pb_values[i].pv_function_pointer = value; + break; + default: + break; } + return PBLOCK_SUCCESS; +} + +static int +pblock_be_call( Slapi_PBlock *pb, int (*bep)(Operation *) ) +{ + BackendDB *be_orig; + Operation *op; + int rc; + + PBLOCK_ASSERT_OP( pb, 0 ); + op = pb->pb_op; + + be_orig = op->o_bd; + op->o_bd = select_backend( &op->o_req_ndn, 0, 0 ); + rc = (*bep)( op ); + op->o_bd = be_orig; + + return rc; +} + +static int +pblock_get( Slapi_PBlock *pb, int param, void **value ) +{ + int rc = PBLOCK_SUCCESS; + + pblock_lock( pb ); + switch ( param ) { - case SLAPI_CONN_DN: - case SLAPI_CONN_AUTHMETHOD: - case SLAPI_IBM_CONN_DN_ALT: - case SLAPI_IBM_CONN_DN_ORIG: + case SLAPI_OPERATION: + *value = pb->pb_op; + break; + case SLAPI_OPINITIATED_TIME: + PBLOCK_ASSERT_OP( pb, 0 ); + *((long *)value) = pb->pb_op->o_time; + break; + case SLAPI_OPERATION_ID: + PBLOCK_ASSERT_OP( pb, 0 ); + *((long *)value) = pb->pb_op->o_opid; + break; + case SLAPI_OPERATION_TYPE: + PBLOCK_ASSERT_OP( pb, 0 ); + *((ber_tag_t *)value) = pb->pb_op->o_tag; + break; + case SLAPI_X_OPERATION_DELETE_GLUE_PARENT: + PBLOCK_ASSERT_OP( pb, 0 ); + *((ber_tag_t *)value) = pb->pb_op->o_delete_glue_parent; + break; + case SLAPI_X_OPERATION_NO_SCHEMA_CHECK: + PBLOCK_ASSERT_OP( pb, 0 ); + *((int *)value) = get_no_schema_check( pb->pb_op ); + break; + case SLAPI_REQCONTROLS: + PBLOCK_ASSERT_OP( pb, 0 ); + *((LDAPControl ***)value) = pb->pb_op->o_ctrls; + break; + case SLAPI_REQUESTOR_DN: + PBLOCK_ASSERT_OP( pb, 0 ); + *((char **)value) = pb->pb_op->o_dn.bv_val; + break; + case SLAPI_MANAGEDSAIT: + PBLOCK_ASSERT_OP( pb, 0 ); + *((int *)value) = get_manageDSAit( pb->pb_op ); + break; + case SLAPI_X_MANAGEDIT: + PBLOCK_ASSERT_OP( pb, 0 ); + *((int *)value) = get_manageDIT( pb->pb_op ); + break; + case SLAPI_BACKEND: + PBLOCK_ASSERT_OP( pb, 0 ); + *((BackendDB **)value) = select_backend( &pb->pb_op->o_req_ndn, 0, 0 ); + break; + case SLAPI_BE_TYPE: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_bd != NULL ) + *((char **)value) = pb->pb_op->o_bd->bd_info->bi_type; + else + *value = NULL; + break; + case SLAPI_CONNECTION: + *value = pb->pb_conn; + break; + case SLAPI_X_CONN_SSF: + PBLOCK_ASSERT_OP( pb, 0 ); + *((slap_ssf_t *)value) = pb->pb_conn->c_ssf; + break; + case SLAPI_X_CONN_SASL_CONTEXT: + PBLOCK_ASSERT_CONN( pb ); + if ( pb->pb_conn->c_sasl_authctx != NULL ) + *value = pb->pb_conn->c_sasl_authctx; + else + *value = pb->pb_conn->c_sasl_sockctx; + break; + case SLAPI_TARGET_DN: + PBLOCK_ASSERT_OP( pb, 0 ); + *((char **)value) = pb->pb_op->o_req_dn.bv_val; + break; + case SLAPI_REQUESTOR_ISROOT: + *((int *)value) = pblock_be_call( pb, be_isroot ); + break; + case SLAPI_IS_REPLICATED_OPERATION: + *((int *)value) = pblock_be_call( pb, be_slurp_update ); + break; + case SLAPI_CONN_AUTHTYPE: + case SLAPI_CONN_AUTHMETHOD: /* XXX should return SASL mech */ + PBLOCK_ASSERT_CONN( pb ); + *((char **)value) = pblock_get_authtype( &pb->pb_conn->c_authz, +#ifdef HAVE_TLS + pb->pb_conn->c_is_tls +#else + 0 +#endif + ); + break; + case SLAPI_X_CONN_IS_UDP: + PBLOCK_ASSERT_CONN( pb ); +#ifdef LDAP_CONNECTIONLESS + *((int *)value) = pb->pb_conn->c_is_udp; +#else + *((int *)value) = 0; +#endif + break; + case SLAPI_CONN_ID: + PBLOCK_ASSERT_CONN( pb ); + *((long *)value) = pb->pb_conn->c_connid; + break; + case SLAPI_CONN_DN: + PBLOCK_ASSERT_CONN( pb ); + *((char **)value) = pb->pb_conn->c_dn.bv_val; + break; + case SLAPI_CONN_CLIENTIP: + PBLOCK_ASSERT_CONN( pb ); + if ( strncmp( pb->pb_conn->c_peer_name.bv_val, "IP=", 3 ) == 0 ) + *((char **)value) = &pb->pb_conn->c_peer_name.bv_val[3]; + else + *value = NULL; + break; + case SLAPI_X_CONN_CLIENTPATH: + PBLOCK_ASSERT_CONN( pb ); + if ( strncmp( pb->pb_conn->c_peer_name.bv_val, "PATH=", 3 ) == 0 ) + *((char **)value) = &pb->pb_conn->c_peer_name.bv_val[5]; + else + *value = NULL; + break; + case SLAPI_CONN_SERVERIP: + PBLOCK_ASSERT_CONN( pb ); + if ( strncmp( pb->pb_conn->c_peer_name.bv_val, "IP=", 3 ) == 0 ) + *((char **)value) = &pb->pb_conn->c_sock_name.bv_val[3]; + else + *value = NULL; + break; + case SLAPI_X_CONN_SERVERPATH: + PBLOCK_ASSERT_CONN( pb ); + if ( strncmp( pb->pb_conn->c_peer_name.bv_val, "PATH=", 3 ) == 0 ) + *((char **)value) = &pb->pb_conn->c_sock_name.bv_val[5]; + else + *value = NULL; + break; + case SLAPI_RESULT_CODE: + case SLAPI_PLUGIN_INTOP_RESULT: + PBLOCK_ASSERT_OP( pb, 0 ); + *((int *)value) = pb->pb_rs->sr_err; + break; case SLAPI_RESULT_TEXT: + PBLOCK_ASSERT_OP( pb, 0 ); + *((const char **)value) = pb->pb_rs->sr_text; + break; case SLAPI_RESULT_MATCHED: - freeit = 1; + PBLOCK_ASSERT_OP( pb, 0 ); + *((const char **)value) = pb->pb_rs->sr_matched; + break; + case SLAPI_ADD_ENTRY: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_ADD ) + *((Slapi_Entry **)value) = pb->pb_op->ora_e; + else + *value = NULL; + break; + case SLAPI_MODIFY_MODS: { + LDAPMod **mods = NULL; + + pblock_get_default( pb, param, (void **)&mods ); + if ( mods == NULL && pb->pb_intop == 0 ) { + if ( pb->pb_op->o_tag != LDAP_REQ_MODIFY ) { + rc = PBLOCK_ERROR; + break; + } + mods = slapi_int_modifications2ldapmods( pb->pb_op->orm_modlist ); + pblock_set_default( pb, param, (void *)mods ); + } + *((LDAPMod ***)value) = mods; + break; + } + case SLAPI_MODRDN_NEWRDN: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN ) + *((char **)value) = pb->pb_op->orr_newrdn.bv_val; + else + *value = NULL; + break; + case SLAPI_MODRDN_NEWSUPERIOR: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN && pb->pb_op->orr_newSup != NULL ) + *((char **)value) = pb->pb_op->orr_newSup->bv_val; + else + *value = NULL; + break; + case SLAPI_MODRDN_DELOLDRDN: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN ) + *((int *)value) = pb->pb_op->orr_deleteoldrdn; + else + *((int *)value) = 0; + break; + case SLAPI_SEARCH_SCOPE: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + *((int *)value) = pb->pb_op->ors_scope; + else + *((int *)value) = 0; + break; + case SLAPI_SEARCH_DEREF: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + *((int *)value) = pb->pb_op->ors_deref; + else + *((int *)value) = 0; + break; + case SLAPI_SEARCH_SIZELIMIT: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + *((int *)value) = pb->pb_op->ors_slimit; + else + *((int *)value) = 0; + break; + case SLAPI_SEARCH_TIMELIMIT: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + *((int *)value) = pb->pb_op->ors_tlimit; + else + *((int *)value) = 0; + break; + case SLAPI_SEARCH_FILTER: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + *((Slapi_Filter **)value) = pb->pb_op->ors_filter; + else + *((Slapi_Filter **)value) = NULL; + break; + case SLAPI_SEARCH_STRFILTER: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + *((char **)value) = pb->pb_op->ors_filterstr.bv_val; + else + *((char **)value) = NULL; + break; + case SLAPI_SEARCH_ATTRS: { + char **attrs = NULL; + + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag != LDAP_REQ_SEARCH ) { + rc = PBLOCK_ERROR; + break; + } + pblock_get_default( pb, param, (void **)&attrs ); + if ( attrs == NULL && pb->pb_intop == 0 ) { + attrs = anlist2charray_x( pb->pb_op->ors_attrs, 0, pb->pb_op->o_tmpmemctx ); + pblock_set_default( pb, param, (void *)attrs ); + } + *((char ***)value) = attrs; + break; + } + case SLAPI_SEARCH_ATTRSONLY: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + *((int *)value) = pb->pb_op->ors_attrsonly; + else + *((int *)value) = 0; + break; + case SLAPI_SEARCH_RESULT_ENTRY: + PBLOCK_ASSERT_OP( pb, 0 ); + *((Slapi_Entry **)value) = pb->pb_rs->sr_entry; + break; + case SLAPI_BIND_RET_SASLCREDS: + PBLOCK_ASSERT_OP( pb, 0 ); + *((struct berval **)value) = pb->pb_rs->sr_sasldata; + break; + case SLAPI_EXT_OP_REQ_OID: + *((const char **)value) = pb->pb_op->ore_reqoid.bv_val; + break; + case SLAPI_EXT_OP_REQ_VALUE: + *((struct berval **)value) = pb->pb_op->ore_reqdata; + break; + case SLAPI_EXT_OP_RET_OID: + PBLOCK_ASSERT_OP( pb, 0 ); + *((const char **)value) = pb->pb_rs->sr_rspoid; + break; + case SLAPI_EXT_OP_RET_VALUE: + PBLOCK_ASSERT_OP( pb, 0 ); + *((struct berval **)value) = pb->pb_rs->sr_rspdata; + break; + case SLAPI_BIND_METHOD: + if ( pb->pb_op->o_tag == LDAP_REQ_BIND ) + *((int *)value) = pb->pb_op->orb_method; + else + *((int *)value) = 0; + break; + case SLAPI_BIND_CREDENTIALS: + if ( pb->pb_op->o_tag == LDAP_REQ_BIND ) + *((struct berval **)value) = &pb->pb_op->orb_cred; + else + *value = NULL; + break; + case SLAPI_COMPARE_TYPE: + if ( pb->pb_op->o_tag == LDAP_REQ_COMPARE ) + *((char **)value) = pb->pb_op->orc_ava->aa_desc->ad_cname.bv_val; + else + *value = NULL; + break; + case SLAPI_COMPARE_VALUE: + if ( pb->pb_op->o_tag == LDAP_REQ_COMPARE ) + *((struct berval **)value) = &pb->pb_op->orc_ava->aa_value; + else + *value = NULL; + break; + case SLAPI_ABANDON_MSGID: + if ( pb->pb_op->o_tag == LDAP_REQ_ABANDON ) + *((int *)value) = pb->pb_op->orn_msgid; + else + *((int *)value) = 0; break; default: - freeit = 0; + rc = pblock_get_default( pb, param, value ); break; } - for( i = 0; i < pb->numParams; i++ ) { - if ( pb->curParams[i] == param ) { + + pblock_unlock( pb ); + + return rc; +} + +static int +pblock_add_control( Slapi_PBlock *pb, LDAPControl *control ) +{ + LDAPControl **controls = NULL; + size_t i; + + pblock_get_default( pb, SLAPI_RESCONTROLS, (void **)&controls ); + + if ( controls != NULL ) { + for ( i = 0; controls[i] != NULL; i++ ) + ; + } else { + i = 0; + } + + controls = (LDAPControl **)slapi_ch_realloc( (char *)controls, + ( i + 2 ) * sizeof(LDAPControl *)); + controls[i++] = slapi_dup_control( control ); + controls[i] = NULL; + + return pblock_set_default( pb, SLAPI_RESCONTROLS, (void *)controls ); +} + +static int +pblock_set_dn( void *value, struct berval *dn, struct berval *ndn, void *memctx ) +{ + struct berval bv; + + if ( !BER_BVISNULL( dn )) { + slap_sl_free( dn->bv_val, memctx ); + BER_BVZERO( dn ); + } + if ( !BER_BVISNULL( ndn )) { + slap_sl_free( ndn->bv_val, memctx ); + BER_BVZERO( ndn ); + } + + bv.bv_val = (char *)value; + bv.bv_len = ( value != NULL ) ? strlen( bv.bv_val ) : 0; + + return dnPrettyNormal( NULL, &bv, dn, ndn, memctx ); +} + +static int +pblock_set( Slapi_PBlock *pb, int param, void *value ) +{ + int rc = PBLOCK_SUCCESS; + + pblock_lock( pb ); + + switch ( param ) { + case SLAPI_OPERATION: + pb->pb_op = (Operation *)value; + break; + case SLAPI_OPINITIATED_TIME: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_time = *((long *)value); + break; + case SLAPI_OPERATION_ID: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_opid = *((long *)value); + break; + case SLAPI_OPERATION_TYPE: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_tag = *((ber_tag_t *)value); + break; + case SLAPI_X_OPERATION_DELETE_GLUE_PARENT: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_delete_glue_parent = *((int *)value); + break; + case SLAPI_X_OPERATION_NO_SCHEMA_CHECK: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_no_schema_check = *((int *)value); + break; + case SLAPI_REQCONTROLS: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_ctrls = (LDAPControl **)value; + break; + case SLAPI_RESCONTROLS: { + LDAPControl **ctrls = NULL; + + pblock_get_default( pb, param, (void **)&ctrls ); + if ( ctrls != NULL ) { + /* free old ones first */ + ldap_controls_free( ctrls ); + } + rc = pblock_set_default( pb, param, value ); + break; + } + case SLAPI_ADD_RESCONTROL: + PBLOCK_ASSERT_OP( pb, 0 ); + rc = pblock_add_control( pb, (LDAPControl *)value ); + break; + case SLAPI_REQUESTOR_DN: + PBLOCK_ASSERT_OP( pb, 0 ); + rc = pblock_set_dn( value, &pb->pb_op->o_dn, &pb->pb_op->o_ndn, pb->pb_op->o_tmpmemctx ); + break; + case SLAPI_MANAGEDSAIT: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_managedsait = *((int *)value); + break; + case SLAPI_X_MANAGEDIT: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_managedit = *((int *)value); + break; + case SLAPI_BACKEND: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_op->o_bd = (BackendDB *)value; + break; + case SLAPI_CONNECTION: + pb->pb_conn = (Connection *)value; + break; + case SLAPI_X_CONN_SSF: + PBLOCK_ASSERT_CONN( pb ); + PBLOCK_LOCK_CONN( pb ); + pb->pb_conn->c_ssf = (slap_ssf_t)value; + PBLOCK_UNLOCK_CONN( pb ); + break; + case SLAPI_X_CONN_SASL_CONTEXT: + PBLOCK_ASSERT_CONN( pb ); + PBLOCK_LOCK_CONN( pb ); + pb->pb_conn->c_sasl_authctx = value; + PBLOCK_UNLOCK_CONN( pb ); + break; + case SLAPI_TARGET_DN: + PBLOCK_ASSERT_OP( pb, 0 ); + rc = pblock_set_dn( value, &pb->pb_op->o_req_dn, &pb->pb_op->o_req_ndn, pb->pb_op->o_tmpmemctx ); + break; + case SLAPI_CONN_ID: + PBLOCK_ASSERT_CONN( pb ); + PBLOCK_LOCK_CONN( pb ); + pb->pb_conn->c_connid = *((long *)value); + PBLOCK_UNLOCK_CONN( pb ); + break; + case SLAPI_CONN_DN: + PBLOCK_ASSERT_CONN( pb ); + PBLOCK_LOCK_CONN( pb ); + rc = pblock_set_dn( value, &pb->pb_conn->c_dn, &pb->pb_conn->c_ndn, NULL ); + PBLOCK_UNLOCK_CONN( pb ); + break; + case SLAPI_RESULT_CODE: + case SLAPI_PLUGIN_INTOP_RESULT: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_rs->sr_err = *((int *)value); + break; + case SLAPI_RESULT_TEXT: + PBLOCK_ASSERT_OP( pb, 0 ); + snprintf( pb->pb_textbuf, sizeof( pb->pb_textbuf ), "%s", (char *)value ); + pb->pb_rs->sr_text = pb->pb_textbuf; + break; + case SLAPI_RESULT_MATCHED: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_rs->sr_matched = (char *)value; /* XXX should dup? */ + break; + case SLAPI_ADD_ENTRY: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_ADD ) + pb->pb_op->ora_e = (Slapi_Entry *)value; + else + rc = PBLOCK_ERROR; + break; + case SLAPI_MODIFY_MODS: { + Modifications **mlp; + Modifications *newmods; + + PBLOCK_ASSERT_OP( pb, 0 ); + rc = pblock_set_default( pb, param, value ); + if ( rc != PBLOCK_SUCCESS ) { + break; + } + + if ( pb->pb_op->o_tag == LDAP_REQ_MODIFY ) { + mlp = &pb->pb_op->orm_modlist; + } else if ( pb->pb_op->o_tag == LDAP_REQ_ADD ) { + mlp = &pb->pb_op->ora_modlist; + } else { break; } + + newmods = slapi_int_ldapmods2modifications( (LDAPMod **)value ); + if ( newmods != NULL ) { + slap_mods_free( *mlp, 1 ); + *mlp = newmods; + } + break; } + case SLAPI_MODRDN_NEWRDN: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN ) { + rc = pblock_set_dn( value, &pb->pb_op->orr_newrdn, &pb->pb_op->orr_nnewrdn, pb->pb_op->o_tmpmemctx ); + if ( rc == LDAP_SUCCESS ) + rc = rdn_validate( &pb->pb_op->orr_nnewrdn ); + } else { + rc = PBLOCK_ERROR; + } + break; + case SLAPI_MODRDN_NEWSUPERIOR: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN ) { + if ( value == NULL ) { + if ( pb->pb_op->orr_newSup != NULL ) { + pb->pb_op->o_tmpfree( pb->pb_op->orr_newSup, pb->pb_op->o_tmpmemctx ); + BER_BVZERO( pb->pb_op->orr_newSup ); + pb->pb_op->orr_newSup = NULL; + } + if ( pb->pb_op->orr_newSup != NULL ) { + pb->pb_op->o_tmpfree( pb->pb_op->orr_nnewSup, pb->pb_op->o_tmpmemctx ); + BER_BVZERO( pb->pb_op->orr_nnewSup ); + pb->pb_op->orr_nnewSup = NULL; + } + } else { + if ( pb->pb_op->orr_newSup == NULL ) { + pb->pb_op->orr_newSup = (struct berval *)pb->pb_op->o_tmpalloc( + sizeof(struct berval), pb->pb_op->o_tmpmemctx ); + BER_BVZERO( pb->pb_op->orr_newSup ); + } + if ( pb->pb_op->orr_nnewSup == NULL ) { + pb->pb_op->orr_nnewSup = (struct berval *)pb->pb_op->o_tmpalloc( + sizeof(struct berval), pb->pb_op->o_tmpmemctx ); + BER_BVZERO( pb->pb_op->orr_nnewSup ); + } + rc = pblock_set_dn( value, pb->pb_op->orr_newSup, pb->pb_op->orr_nnewSup, pb->pb_op->o_tmpmemctx ); + } + } else { + rc = PBLOCK_ERROR; + } + break; + case SLAPI_MODRDN_DELOLDRDN: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN ) + pb->pb_op->orr_deleteoldrdn = *((int *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_SEARCH_SCOPE: { + int scope = *((int *)value); - if ( i >= pb->numParams ) { - pb->curParams[i] = param; - pb->numParams++; + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) { + switch ( *((int *)value) ) { + case LDAP_SCOPE_BASE: + case LDAP_SCOPE_ONELEVEL: + case LDAP_SCOPE_SUBTREE: +#ifdef LDAP_SCOPE_SUBORDINATE + case LDAP_SCOPE_SUBORDINATE: +#endif + pb->pb_op->ors_scope = scope; + break; + default: + rc = PBLOCK_ERROR; + break; + } + } else { + rc = PBLOCK_ERROR; + } + break; + } + case SLAPI_SEARCH_DEREF: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + pb->pb_op->ors_deref = *((int *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_SEARCH_SIZELIMIT: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + pb->pb_op->ors_slimit = *((int *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_SEARCH_TIMELIMIT: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + pb->pb_op->ors_tlimit = *((int *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_SEARCH_FILTER: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + pb->pb_op->ors_filter = (Slapi_Filter *)value; + else + rc = PBLOCK_ERROR; + break; + case SLAPI_SEARCH_STRFILTER: + PBLOCK_ASSERT_OP( pb, 0 ); + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) { + pb->pb_op->ors_filterstr.bv_val = (char *)value; + pb->pb_op->ors_filterstr.bv_len = strlen((char *)value); + } else { + rc = PBLOCK_ERROR; + } + break; + case SLAPI_SEARCH_ATTRS: { + AttributeName *an = NULL; + size_t i = 0; + char **attrs = (char **)value; + + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + + if ( pb->pb_op->o_tag != LDAP_REQ_SEARCH ) { + rc = PBLOCK_ERROR; + break; + } + /* also set mapped attrs */ + rc = pblock_set_default( pb, param, value ); + if ( rc != PBLOCK_SUCCESS ) { + break; + } + if ( pb->pb_op->ors_attrs != NULL ) { + pb->pb_op->o_tmpfree( pb->pb_op->ors_attrs, pb->pb_op->o_tmpmemctx ); + pb->pb_op->ors_attrs = NULL; + } + if ( attrs != NULL ) { + for ( i = 0; attrs[i] != NULL; i++ ) + ; + } + if ( i ) { + an = (AttributeName *)pb->pb_op->o_tmpalloc( (i + 1) * + sizeof(AttributeName), pb->pb_op->o_tmpmemctx ); + for ( i = 0; attrs[i] != NULL; i++ ) { + an[i].an_desc = NULL; + an[i].an_oc = NULL; + an[i].an_oc_exclude = 0; + an[i].an_name.bv_val = attrs[i]; + an[i].an_name.bv_len = strlen( attrs[i] ); + slap_bv2ad( &an[i].an_name, &an[i].an_desc, &pb->pb_rs->sr_text ); + } + an[i].an_name.bv_val = NULL; + an[i].an_name.bv_len = 0; + } + pb->pb_op->ors_attrs = an; + break; } - if ( addcon ) { - LDAPControl **ctrls = pb->curVals[i]; - int j; + case SLAPI_SEARCH_ATTRSONLY: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + pb->pb_op->ors_attrsonly = *((int *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_SEARCH_RESULT_ENTRY: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_rs->sr_entry = (Slapi_Entry *)value; + break; + case SLAPI_BIND_RET_SASLCREDS: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_rs->sr_sasldata = (struct berval *)value; + break; + case SLAPI_EXT_OP_REQ_OID: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); - if ( ctrls ) { - for (j=0; ctrls[j]; j++); - ctrls = ch_realloc( ctrls, (j+2)*sizeof(LDAPControl *) ); + if ( pb->pb_op->o_tag == LDAP_REQ_EXTENDED ) { + pb->pb_op->ore_reqoid.bv_val = (char *)value; + pb->pb_op->ore_reqoid.bv_len = strlen((char *)value); } else { - ctrls = ch_malloc( 2 * sizeof(LDAPControl *) ); - j = 0; + rc = PBLOCK_ERROR; } - ctrls[j] = val; - ctrls[j+1] = NULL; - pb->curVals[i] = ctrls; - } else { - if ( freeit ) ch_free( pb->curVals[i] ); - pb->curVals[i] = val; + break; + case SLAPI_EXT_OP_REQ_VALUE: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + + if ( pb->pb_op->o_tag == LDAP_REQ_EXTENDED ) + pb->pb_op->ore_reqdata = (struct berval *)value; + else + rc = PBLOCK_ERROR; + break; + case SLAPI_EXT_OP_RET_OID: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_rs->sr_rspoid = (char *)value; + break; + case SLAPI_EXT_OP_RET_VALUE: + PBLOCK_ASSERT_OP( pb, 0 ); + pb->pb_rs->sr_rspdata = (struct berval *)value; + break; + case SLAPI_BIND_METHOD: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + + if ( pb->pb_op->o_tag == LDAP_REQ_BIND ) + pb->pb_op->orb_method = *((int *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_BIND_CREDENTIALS: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + + if ( pb->pb_op->o_tag == LDAP_REQ_BIND ) + pb->pb_op->orb_cred = *((struct berval *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_COMPARE_TYPE: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + + if ( pb->pb_op->o_tag == LDAP_REQ_COMPARE ) { + const char *text; + + pb->pb_op->orc_ava->aa_desc = NULL; + rc = slap_str2ad( (char *)value, &pb->pb_op->orc_ava->aa_desc, &text ); + } else { + rc = PBLOCK_ERROR; + } + break; + case SLAPI_COMPARE_VALUE: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + + if ( pb->pb_op->o_tag == LDAP_REQ_COMPARE ) + pb->pb_op->orc_ava->aa_value = *((struct berval *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_ABANDON_MSGID: + PBLOCK_ASSERT_OP( pb, 0 ); + PBLOCK_VALIDATE_IS_INTOP( pb ); + + if ( pb->pb_op->o_tag == LDAP_REQ_ABANDON) + pb->pb_op->orn_msgid = *((int *)value); + else + rc = PBLOCK_ERROR; + break; + case SLAPI_REQUESTOR_ISROOT: + case SLAPI_IS_REPLICATED_OPERATION: + case SLAPI_CONN_AUTHTYPE: + case SLAPI_CONN_AUTHMETHOD: + case SLAPI_X_CONN_IS_UDP: + case SLAPI_CONN_CLIENTIP: + case SLAPI_X_CONN_CLIENTPATH: + case SLAPI_CONN_SERVERIP: + case SLAPI_X_CONN_SERVERPATH: + /* These parameters cannot be set */ + rc = PBLOCK_ERROR; + break; + default: + rc = pblock_set_default( pb, param, value ); + break; } - unLock( pb ); - return PBLOCK_SUCCESS; -#endif /* LDAP_SLAPI */ - return PBLOCK_ERROR; -} + pblock_unlock( pb ); -static void -clearPB( Slapi_PBlock *pb ) -{ - pb->numParams = 1; + return rc; } static void -checkParams( Slapi_PBlock *pb, int flag ) +pblock_clear( Slapi_PBlock *pb ) { - pb->ckParams = flag; + pb->pb_nParams = 1; } static int -deleteParam( Slapi_PBlock *p, int param ) +pblock_delete_param( Slapi_PBlock *p, int param ) { int i; - Lock(p); - for ( i = 0; i < p->numParams; i++ ) { - if ( p->curParams[i] == param ) { + pblock_lock(p); + + for ( i = 0; i < p->pb_nParams; i++ ) { + if ( p->pb_params[i] == param ) { break; } } - if (i >= p->numParams ) { - unLock( p ); + if (i >= p->pb_nParams ) { + pblock_unlock( p ); return PBLOCK_ERROR; } - if ( p->numParams > 1 ) { - p->curParams[i] = p->curParams[p->numParams]; - p->curVals[i] = p->curVals[p->numParams]; + + /* move last parameter to index of deleted parameter */ + if ( p->pb_nParams > 1 ) { + p->pb_params[i] = p->pb_params[p->pb_nParams - 1]; + p->pb_values[i] = p->pb_values[p->pb_nParams - 1]; } - p->numParams--; - unLock( p ); + p->pb_nParams--; + + pblock_unlock( p ); + return PBLOCK_SUCCESS; } Slapi_PBlock * -slapi_pblock_new() +slapi_pblock_new(void) { -#if defined(LDAP_SLAPI) Slapi_PBlock *pb; - pb = (Slapi_PBlock *) ch_malloc(sizeof(Slapi_PBlock)); + pb = (Slapi_PBlock *) ch_calloc( 1, sizeof(Slapi_PBlock) ); if ( pb != NULL ) { - pb->ckParams = TRUE; - ldap_pvt_thread_mutex_init( &pb->pblockMutex ); - memset( pb->curParams, 0, sizeof(pb->curParams) ); - memset( pb->curVals, 0, sizeof(pb->curVals) ); - pb->curParams[0] = SLAPI_IBM_PBLOCK; - pb->curVals[0] = NULL; - pb->numParams = 1; + ldap_pvt_thread_mutex_init( &pb->pb_mutex ); + + pb->pb_params[0] = SLAPI_IBM_PBLOCK; + pb->pb_values[0].pv_pointer = NULL; + pb->pb_nParams = 1; + pb->pb_conn = NULL; + pb->pb_op = NULL; + pb->pb_rs = NULL; + pb->pb_intop = 0; } return pb; -#endif /* LDAP_SLAPI */ - return NULL; } -void -slapi_pblock_destroy( Slapi_PBlock* pb ) +static void +pblock_destroy( Slapi_PBlock *pb ) { -#if defined(LDAP_SLAPI) - char *str = NULL; - LDAPControl **rescontrols = NULL; - - get( pb, SLAPI_CONN_DN,(void **)&str ); - if ( str != NULL ) { - ch_free( str ); - str = NULL; - } + LDAPControl **controls = NULL; + LDAPMod **mods = NULL; + char **attrs = NULL; - get( pb, SLAPI_CONN_AUTHMETHOD, (void **)&str ); - if ( str != NULL ) { - ch_free( str ); - str = NULL; - } + assert( pb != NULL ); - get( pb, SLAPI_IBM_CONN_DN_ALT, (void **)&str ); - if ( str != NULL ) { - ch_free( str ); - str = NULL; + pblock_get_default( pb, SLAPI_RESCONTROLS, (void **)&controls ); + if ( controls != NULL ) { + ldap_controls_free( controls ); } - get( pb, SLAPI_IBM_CONN_DN_ORIG, (void **)&str ); - if ( str != NULL ) { - ch_free( str ); - } + if ( pb->pb_intop ) { + slapi_int_connection_done_pb( pb ); + } else { + pblock_get_default( pb, SLAPI_MODIFY_MODS, (void **)&mods ); + ldap_mods_free( mods, 1 ); - get( pb, SLAPI_RESULT_TEXT, (void **)&str ); - if ( str != NULL ) { - ch_free( str ); - str = NULL; + pblock_get_default( pb, SLAPI_SEARCH_ATTRS, (void **)&attrs ); + if ( attrs != NULL ) + pb->pb_op->o_tmpfree( attrs, pb->pb_op->o_tmpmemctx ); } - get( pb, SLAPI_RESULT_MATCHED, (void **)&str ); - if ( str != NULL ) { - ch_free( str ); - str = NULL; - } + ldap_pvt_thread_mutex_destroy( &pb->pb_mutex ); + slapi_ch_free( (void **)&pb ); +} - get( pb, SLAPI_RESCONTROLS, (void **)&rescontrols ); - if ( rescontrols != NULL ) { - ldap_controls_free( rescontrols ); - rescontrols = NULL; +void +slapi_pblock_destroy( Slapi_PBlock *pb ) +{ + if ( pb != NULL ) { + pblock_destroy( pb ); } - - ldap_pvt_thread_mutex_destroy( &pb->pblockMutex ); - - ch_free( pb ); -#endif /* LDAP_SLAPI */ } int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value ) { -#if defined(LDAP_SLAPI) - return get( pb, arg, (void **)value ); -#endif /* LDAP_SLAPI */ - return PBLOCK_ERROR; + return pblock_get( pb, arg, (void **)value ); } int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value ) { -#if defined(LDAP_SLAPI) - void *pTmp = NULL; - - switch ( arg ) { - case SLAPI_CONN_DN: - case SLAPI_CONN_AUTHMETHOD: - case SLAPI_IBM_CONN_DN_ALT: - case SLAPI_IBM_CONN_DN_ORIG: - case SLAPI_RESULT_TEXT: - case SLAPI_RESULT_MATCHED: - if ( value != NULL ) { - pTmp = (void *)slapi_ch_strdup((char *)value); - if ( pTmp == NULL ) { - return LDAP_NO_MEMORY; - } - } - break; - default: - pTmp = value; - break; - } - return set( pb, arg, pTmp ); -#endif /* LDAP_SLAPI */ - return LDAP_NO_MEMORY; + return pblock_set( pb, arg, value ); } void slapi_pblock_clear( Slapi_PBlock *pb ) { -#if defined(LDAP_SLAPI) - clearPB( pb ); -#endif /* LDAP_SLAPI */ + pblock_clear( pb ); } int slapi_pblock_delete_param( Slapi_PBlock *p, int param ) { -#if defined(LDAP_SLAPI) - return deleteParam( p, param ); -#endif /* LDAP_SLAPI */ - return PBLOCK_ERROR; -} - -void -slapi_pblock_check_params( Slapi_PBlock *pb, int flag ) -{ -#if defined(LDAP_SLAPI) - checkParams( pb, flag ); -#endif /* LDAP_SLAPI */ + return pblock_delete_param( p, param ); } /* @@ -565,13 +1339,9 @@ slapi_pblock_check_params( Slapi_PBlock *pb, int flag ) int slapi_int_pblock_get_first( Backend *be, Slapi_PBlock **pb ) { -#if defined(LDAP_SLAPI) - assert( pb ); - *pb = (Slapi_PBlock *)be->be_pb; + assert( pb != NULL ); + *pb = SLAPI_BACKEND_PBLOCK( be ); return (*pb == NULL ? LDAP_OTHER : LDAP_SUCCESS); -#else /* LDAP_SLAPI */ - return LDAP_OTHER; -#endif /* LDAP_SLAPI */ } /* @@ -580,11 +1350,9 @@ slapi_int_pblock_get_first( Backend *be, Slapi_PBlock **pb ) int slapi_int_pblock_get_next( Slapi_PBlock **pb ) { -#if defined(LDAP_SLAPI) - assert( pb ); + assert( pb != NULL ); return slapi_pblock_get( *pb, SLAPI_IBM_PBLOCK, pb ); -#else /* LDAP_SLAPI */ - return LDAP_OTHER; -#endif /* LDAP_SLAPI */ } +#endif /* LDAP_SLAPI */ + diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 6689fb41b7..3e1d1149ba 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -32,6 +32,8 @@ #include +#ifdef LDAP_SLAPI + /* * server start time (should we use a struct timeval also in slapd? */ @@ -48,7 +50,6 @@ struct slapi_condvar { ldap_pvt_thread_mutex_t mutex; }; -#ifdef LDAP_SLAPI static int checkBVString(const struct berval *bv) { int i; @@ -62,7 +63,6 @@ static int checkBVString(const struct berval *bv) return 1; } -#endif /* LDAP_SLAPI */ /* * This function converts an array of pointers to berval objects to @@ -110,20 +110,7 @@ slapi_str2entry( char *s, int flags ) { -#ifdef LDAP_SLAPI - Slapi_Entry *e = NULL; - char *pTmpS; - - pTmpS = slapi_ch_strdup( s ); - if ( pTmpS != NULL ) { - e = str2entry( pTmpS ); - slapi_ch_free( (void **)&pTmpS ); - } - - return e; -#else - return NULL; -#endif /* LDAP_SLAPI */ + return str2entry( s ); } char * @@ -131,37 +118,49 @@ slapi_entry2str( Slapi_Entry *e, int *len ) { -#ifdef LDAP_SLAPI - char *ret; + char *ret = NULL; + char *s; ldap_pvt_thread_mutex_lock( &entry2str_mutex ); - ret = entry2str( e, len ); + s = entry2str( e, len ); + if ( s != NULL ) + ret = slapi_ch_strdup( s ); ldap_pvt_thread_mutex_unlock( &entry2str_mutex ); return ret; -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } char * slapi_entry_get_dn( Slapi_Entry *e ) { -#ifdef LDAP_SLAPI return e->e_name.bv_val; -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } int slapi_x_entry_get_id( Slapi_Entry *e ) { -#ifdef LDAP_SLAPI return e->e_id; -#else - return NOID; -#endif /* LDAP_SLAPI */ +} + +static int +slapi_int_dn_pretty( struct berval *in, struct berval *out ) +{ + Syntax *syntax = slap_schema.si_syn_distinguishedName; + + assert( syntax != NULL ); + + return (syntax->ssyn_pretty)( syntax, in, out, NULL ); +} + +static int +slapi_int_dn_normalize( struct berval *in, struct berval *out ) +{ + MatchingRule *mr = slap_schema.si_mr_distinguishedNameMatch; + Syntax *syntax = slap_schema.si_syn_distinguishedName; + + assert( mr != NULL ); + + return (mr->smr_normalize)( 0, syntax, mr, in, out, NULL ); } void @@ -169,24 +168,19 @@ slapi_entry_set_dn( Slapi_Entry *e, char *ldn ) { -#ifdef LDAP_SLAPI struct berval dn = BER_BVNULL; dn.bv_val = ldn; dn.bv_len = strlen( ldn ); - dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname, NULL ); -#endif /* LDAP_SLAPI */ + slapi_int_dn_pretty( &dn, &e->e_name ); + slapi_int_dn_normalize( &dn, &e->e_nname ); } Slapi_Entry * slapi_entry_dup( Slapi_Entry *e ) { -#ifdef LDAP_SLAPI return entry_dup( e ); -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } int @@ -194,7 +188,6 @@ slapi_entry_attr_delete( Slapi_Entry *e, char *type ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; @@ -207,27 +200,19 @@ slapi_entry_attr_delete( } else { return -1; /* something went wrong */ } -#else /* LDAP_SLAPI */ - return -1; -#endif /* LDAP_SLAPI */ } Slapi_Entry * slapi_entry_alloc( void ) { -#ifdef LDAP_SLAPI return (Slapi_Entry *)slapi_ch_calloc( 1, sizeof(Slapi_Entry) ); -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } void slapi_entry_free( Slapi_Entry *e ) { -#ifdef LDAP_SLAPI - entry_free( e ); -#endif /* LDAP_SLAPI */ + if ( e != NULL ) + entry_free( e ); } int @@ -236,18 +221,17 @@ slapi_entry_attr_merge( char *type, struct berval **vals ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; BerVarray bv; int rc; - rc = bvptr2obj( vals, &bv ); + rc = slap_str2ad( type, &ad, &text ); if ( rc != LDAP_SUCCESS ) { return -1; } - rc = slap_str2ad( type, &ad, &text ); + rc = bvptr2obj( vals, &bv ); if ( rc != LDAP_SUCCESS ) { return -1; } @@ -256,9 +240,6 @@ slapi_entry_attr_merge( ch_free( bv ); return rc; -#else /* LDAP_SLAPI */ - return -1; -#endif /* LDAP_SLAPI */ } int @@ -267,7 +248,6 @@ slapi_entry_attr_find( char *type, Slapi_Attr **attr ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -283,15 +263,11 @@ slapi_entry_attr_find( } return 0; -#else /* LDAP_SLAPI */ - return -1; -#endif /* LDAP_SLAPI */ } char * slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -312,20 +288,16 @@ slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type ) p = slapi_value_get_string( &attr->a_vals[0] ); if ( p != NULL ) { - return slapi_ch_strdup( (char *)p ); + return slapi_ch_strdup( p ); } } return NULL; -#else - return -1; -#endif } int slapi_entry_attr_get_int( const Slapi_Entry *e, const char *type ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -342,15 +314,11 @@ slapi_entry_attr_get_int( const Slapi_Entry *e, const char *type ) } return slapi_value_get_int( attr->a_vals ); -#else - return 0; -#endif } long slapi_entry_attr_get_long( const Slapi_Entry *e, const char *type ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -367,15 +335,11 @@ slapi_entry_attr_get_long( const Slapi_Entry *e, const char *type ) } return slapi_value_get_long( attr->a_vals ); -#else - return 0; -#endif } unsigned int slapi_entry_attr_get_uint( const Slapi_Entry *e, const char *type ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -392,15 +356,11 @@ slapi_entry_attr_get_uint( const Slapi_Entry *e, const char *type ) } return slapi_value_get_uint( attr->a_vals ); -#else - return 0; -#endif } unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry *e, const char *type ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -417,15 +377,11 @@ slapi_entry_attr_get_ulong( const Slapi_Entry *e, const char *type ) } return slapi_value_get_ulong( attr->a_vals ); -#else - return 0; -#endif } int slapi_entry_attr_hasvalue( Slapi_Entry *e, const char *type, const char *value ) { -#ifdef LDAP_SLAPI struct berval bv; AttributeDescription *ad = NULL; const char *text; @@ -446,15 +402,11 @@ slapi_entry_attr_hasvalue( Slapi_Entry *e, const char *type, const char *value ) bv.bv_len = strlen( value ); return ( slapi_attr_value_find( attr, &bv ) != -1 ); -#else - return 0; -#endif } void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -471,90 +423,69 @@ slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value bv.bv_len = strlen(value); attr_merge_normalize_one( e, ad, &bv, NULL ); } -#endif /* LDAP_SLAPI */ } void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l) { -#ifdef LDAP_SLAPI char buf[64]; snprintf( buf, sizeof( buf ), "%d", l ); slapi_entry_attr_set_charptr( e, type, buf ); -#endif /* LDAP_SLAPI */ } void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l) { -#ifdef LDAP_SLAPI char buf[64]; snprintf( buf, sizeof( buf ), "%u", l ); slapi_entry_attr_set_charptr( e, type, buf ); -#endif /* LDAP_SLAPI */ } void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l) { -#ifdef LDAP_SLAPI char buf[64]; snprintf( buf, sizeof( buf ), "%ld", l ); slapi_entry_attr_set_charptr( e, type, buf ); -#endif /* LDAP_SLAPI */ } void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l) { -#ifdef LDAP_SLAPI char buf[64]; snprintf( buf, sizeof( buf ), "%lu", l ); slapi_entry_attr_set_charptr( e, type, buf ); -#endif /* LDAP_SLAPI */ } int slapi_is_rootdse( const char *dn ) { -#ifdef LDAP_SLAPI return ( dn == NULL || dn[0] == '\0' ); -#else - return 0; -#endif } int -slapi_entry_has_children(const Slapi_Entry *e) +slapi_entry_has_children( const Slapi_Entry *e ) { -#ifdef LDAP_SLAPI - Connection *pConn; - Operation *op; + Slapi_PBlock *pb; int hasSubordinates = 0; - pConn = slapi_int_init_connection( NULL, LDAP_REQ_SEARCH ); - if ( pConn == NULL ) { - return 0; - } + pb = slapi_pblock_new(); + slapi_int_connection_init_pb( pb, LDAP_REQ_SEARCH ); - op = (Operation *)pConn->c_pending_ops.stqh_first; - op->o_bd = select_backend( (struct berval *)&e->e_nname, 0, 0 ); - if ( op->o_bd == NULL ) { - return 0; - } + slapi_pblock_set( pb, SLAPI_TARGET_DN, slapi_entry_get_dn( (Entry *)e ) ); - op->o_bd->be_has_subordinates( op, (Entry *)e, &hasSubordinates ); + pb->pb_op->o_bd = select_backend( (struct berval *)&e->e_nname, 0, 0 ); + if ( pb->pb_op->o_bd != NULL ) { + pb->pb_op->o_bd->be_has_subordinates( pb->pb_op, (Entry *)e, &hasSubordinates ); + } - slapi_int_connection_destroy( &pConn ); + slapi_pblock_destroy( pb ); return ( hasSubordinates == LDAP_COMPARE_TRUE ); -#else - return 0; -#endif } /* @@ -566,7 +497,6 @@ slapi_entry_has_children(const Slapi_Entry *e) */ size_t slapi_entry_size(Slapi_Entry *e) { -#ifdef LDAP_SLAPI size_t size; Attribute *a; int i; @@ -581,9 +511,6 @@ size_t slapi_entry_size(Slapi_Entry *e) size -= (size % 1024); return size; -#else - return 0; -#endif /* LDAP_SLAPI */ } /* @@ -597,7 +524,6 @@ size_t slapi_entry_size(Slapi_Entry *e) int slapi_entry_add_values( Slapi_Entry *e, const char *type, struct berval **vals ) { -#ifdef LDAP_SLAPI Modification mod; const char *text; int rc; @@ -630,28 +556,20 @@ slapi_entry_add_values( Slapi_Entry *e, const char *type, struct berval **vals ) rc = modify_add_values( e, &mod, 0, &text, textbuf, sizeof(textbuf) ); - ch_free( mod.sm_values ); + slapi_ch_free( (void **)&mod.sm_values ); return (rc == LDAP_SUCCESS) ? LDAP_SUCCESS : LDAP_CONSTRAINT_VIOLATION; -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ) { -#ifdef LDAP_SLAPI return slapi_entry_add_values( e, type, vals ); -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -662,15 +580,11 @@ slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs) } return attr_merge_normalize( e, ad, *vs, NULL ); -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_delete_values( Slapi_Entry *e, const char *type, struct berval **vals ) { -#ifdef LDAP_SLAPI Modification mod; const char *text; int rc; @@ -693,7 +607,7 @@ slapi_entry_delete_values( Slapi_Entry *e, const char *type, struct berval **val } if ( vals[0] == NULL ) { - /* SLAPI doco says LDAP_OPERATIONS_ERROR but LDAP_OTHER is better */ + /* SLAPI doco says LDApb_opERATIONS_ERROR but LDAP_OTHER is better */ return attr_delete( &e->e_attrs, mod.sm_desc ) ? LDAP_OTHER : LDAP_SUCCESS; } @@ -705,38 +619,26 @@ slapi_entry_delete_values( Slapi_Entry *e, const char *type, struct berval **val rc = modify_delete_values( e, &mod, 0, &text, textbuf, sizeof(textbuf) ); - ch_free( mod.sm_values ); + slapi_ch_free( (void **)&mod.sm_values ); return rc; -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ) { -#ifdef LDAP_SLAPI return slapi_entry_delete_values( e, type, vals ); -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ) { -#ifdef LDAP_SLAPI return slapi_entry_attr_merge( e, (char *)type, vals ); -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; int rc; const char *text; @@ -752,30 +654,22 @@ slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value } return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value) { -#ifdef LDAP_SLAPI Slapi_Value val; val.bv_val = (char *)value; val.bv_len = strlen( value ); return slapi_entry_add_value( e, type, &val ); -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value) { -#ifdef LDAP_SLAPI Slapi_Value *vals[2]; Slapi_Value val; @@ -785,26 +679,17 @@ slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value) vals[1] = NULL; return slapi_entry_delete_values_sv( e, type, vals ); -#else - return -1; -#endif /* LDAP_SLAPI */ } - int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ) { -#ifdef LDAP_SLAPI return slapi_entry_attr_merge( e, (char *)type, vals ); -#else - return -1; -#endif } int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr ) { -#ifdef LDAP_SLAPI if ( e == NULL ) { return -1; } @@ -812,15 +697,11 @@ slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr ) *attr = e->e_attrs; return ( *attr != NULL ) ? 0 : -1; -#else - return -1; -#endif } int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr ) { -#ifdef LDAP_SLAPI if ( e == NULL ) { return -1; } @@ -832,15 +713,11 @@ slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr ** *attr = prevattr->a_next; return ( *attr != NULL ) ? 0 : -1; -#else - return -1; -#endif } int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; int rc; @@ -865,9 +742,6 @@ slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **val } return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ } /* @@ -879,7 +753,6 @@ slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals ) { -#ifdef LDAP_SLAPI int i, j; struct berval **bv; @@ -900,15 +773,11 @@ slapi_attr_get_values( *vals = (struct berval **)bv; return 0; -#else /* LDAP_SLAPI */ - return -1; -#endif /* LDAP_SLAPI */ } char * slapi_dn_normalize( char *dn ) { -#ifdef LDAP_SLAPI struct berval bdn; struct berval pdn; @@ -917,20 +786,16 @@ slapi_dn_normalize( char *dn ) bdn.bv_val = dn; bdn.bv_len = strlen( dn ); - if ( dnPretty( NULL, &bdn, &pdn, NULL ) != LDAP_SUCCESS ) { + if ( slapi_int_dn_pretty( &bdn, &pdn ) != LDAP_SUCCESS ) { return NULL; } return pdn.bv_val; -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } char * slapi_dn_normalize_case( char *dn ) { -#ifdef LDAP_SLAPI struct berval bdn; struct berval ndn; @@ -939,14 +804,11 @@ slapi_dn_normalize_case( char *dn ) bdn.bv_val = dn; bdn.bv_len = strlen( dn ); - if ( dnNormalize( 0, NULL, NULL, &bdn, &ndn, NULL ) != LDAP_SUCCESS ) { + if ( slapi_int_dn_normalize( &bdn, &ndn ) != LDAP_SUCCESS ) { return NULL; } return ndn.bv_val; -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } int @@ -954,7 +816,6 @@ slapi_dn_issuffix( char *dn, char *suffix ) { -#ifdef LDAP_SLAPI struct berval bdn, ndn; struct berval bsuffix, nsuffix; int rc; @@ -985,9 +846,6 @@ slapi_dn_issuffix( slapi_ch_free( (void **)&nsuffix.bv_val ); return rc; -#else /* LDAP_SLAPI */ - return 0; -#endif /* LDAP_SLAPI */ } int @@ -995,7 +853,6 @@ slapi_dn_isparent( const char *parentdn, const char *childdn ) { -#ifdef LDAP_SLAPI struct berval assertedParentDN, normalizedAssertedParentDN; struct berval childDN, normalizedChildDN; struct berval normalizedParentDN; @@ -1035,9 +892,6 @@ slapi_dn_isparent( slapi_ch_free( (void **)&normalizedChildDN.bv_val ); return ( match == 0 ); -#else - return 0; -#endif /* LDAP_SLAPI */ } /* @@ -1047,9 +901,9 @@ slapi_dn_isparent( char * slapi_dn_parent( const char *_dn ) { -#ifdef LDAP_SLAPI struct berval dn, prettyDN; struct berval parentDN; + char *ret; if ( _dn == NULL ) { return NULL; @@ -1068,16 +922,36 @@ slapi_dn_parent( const char *_dn ) dnParent( &prettyDN, &parentDN ); /* in-place */ - slapi_ch_free( (void **)&prettyDN.bv_val ); - if ( parentDN.bv_len == 0 ) { + slapi_ch_free_string( &prettyDN.bv_val ); return NULL; } - return slapi_ch_strdup( parentDN.bv_val ); -#else - return NULL; -#endif /* LDAP_SLAPI */ + ret = slapi_ch_strdup( parentDN.bv_val ); + slapi_ch_free_string( &prettyDN.bv_val ); + + return ret; +} + +int slapi_dn_isbesuffix( Slapi_PBlock *pb, char *ldn ) +{ + struct berval ndn; + Backend *be; + + if ( slapi_is_rootdse( ldn ) ) { + return 0; + } + + /* according to spec should already be normalized */ + ndn.bv_len = strlen( ldn ); + ndn.bv_val = ldn; + + be = select_backend( &pb->pb_op->o_req_ndn, 0, 0 ); + if ( be == NULL ) { + return 0; + } + + return be_issuffix( be, &ndn ); } /* @@ -1085,85 +959,75 @@ slapi_dn_parent( const char *_dn ) * an empty string, if the DN has no parent, or if the * DN is the suffix of the backend database */ -char *slapi_dn_beparent( Slapi_PBlock *pb, const char *_dn ) +char *slapi_dn_beparent( Slapi_PBlock *pb, const char *ldn ) { -#ifdef LDAP_SLAPI Backend *be; struct berval dn, prettyDN; struct berval normalizedDN, parentDN; + char *parent = NULL; - if ( slapi_pblock_get( pb, SLAPI_BACKEND, (void **)&be ) != 0 ) - be = NULL; + if ( pb == NULL ) { + return NULL; + } - dn.bv_val = (char *)_dn; - dn.bv_len = strlen( _dn ); + PBLOCK_ASSERT_OP( pb, 0 ); - if ( dnPrettyNormal( NULL, &dn, &prettyDN, &normalizedDN, NULL ) != LDAP_SUCCESS ) { + if ( slapi_is_rootdse( ldn ) ) { return NULL; } - if ( be != NULL && be_issuffix( be, &normalizedDN ) ) { - slapi_ch_free( (void **)&prettyDN.bv_val ); - slapi_ch_free( (void **)&normalizedDN.bv_val ); + dn.bv_val = (char *)ldn; + dn.bv_len = strlen( ldn ); + + if ( dnPrettyNormal( NULL, &dn, &prettyDN, &normalizedDN, NULL ) != LDAP_SUCCESS ) { return NULL; } - dnParent( &prettyDN, &parentDN ); + be = select_backend( &pb->pb_op->o_req_ndn, 0, 0 ); - slapi_ch_free( (void **)&prettyDN.bv_val ); - slapi_ch_free( (void **)&normalizedDN.bv_val ); + if ( be == NULL || be_issuffix( be, &normalizedDN ) == 0 ) { + dnParent( &prettyDN, &parentDN ); - if ( parentDN.bv_len == 0 ) { - return NULL; + if ( parentDN.bv_len != 0 ) + parent = slapi_ch_strdup( parentDN.bv_val ); } - return slapi_ch_strdup( parentDN.bv_val ); -#else - return NULL; -#endif /* LDAP_SLAPI */ + slapi_ch_free_string( &prettyDN.bv_val ); + slapi_ch_free_string( &normalizedDN.bv_val ); + + return parent; } char * slapi_dn_ignore_case( char *dn ) { -#ifdef LDAP_SLAPI return slapi_dn_normalize_case( dn ); -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } char * slapi_ch_malloc( unsigned long size ) { -#ifdef LDAP_SLAPI return ch_malloc( size ); -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } void slapi_ch_free( void **ptr ) { -#ifdef LDAP_SLAPI + if ( ptr == NULL || *ptr == NULL ) + return; ch_free( *ptr ); *ptr = NULL; -#endif /* LDAP_SLAPI */ } void slapi_ch_free_string( char **ptr ) { -#ifdef LDAP_SLAPI slapi_ch_free( (void **)ptr ); -#endif /* LDAP_SLAPI */ } void slapi_ch_array_free( char **arrayp ) { -#ifdef LDAP_SLAPI char **p; if ( arrayp != NULL ) { @@ -1172,13 +1036,11 @@ slapi_ch_array_free( char **arrayp ) } slapi_ch_free( (void **)&arrayp ); } -#endif } struct berval * slapi_ch_bvdup(const struct berval *v) { -#ifdef LDAP_SLAPI struct berval *bv; bv = (struct berval *) slapi_ch_malloc( sizeof(struct berval) ); @@ -1187,15 +1049,11 @@ slapi_ch_bvdup(const struct berval *v) AC_MEMCPY( bv->bv_val, v->bv_val, bv->bv_len ); return bv; -#else - return NULL; -#endif } struct berval ** slapi_ch_bvecdup(const struct berval **v) { -#ifdef LDAP_SLAPI int i; struct berval **rv; @@ -1214,9 +1072,6 @@ slapi_ch_bvecdup(const struct berval **v) rv[i] = NULL; return rv; -#else - return NULL; -#endif } char * @@ -1224,11 +1079,7 @@ slapi_ch_calloc( unsigned long nelem, unsigned long size ) { -#ifdef LDAP_SLAPI return ch_calloc( nelem, size ); -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } char * @@ -1236,31 +1087,19 @@ slapi_ch_realloc( char *block, unsigned long size ) { -#ifdef LDAP_SLAPI return ch_realloc( block, size ); -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } char * -slapi_ch_strdup( char *s ) +slapi_ch_strdup( const char *s ) { -#ifdef LDAP_SLAPI - return ch_strdup( (const char *)s ); -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ + return ch_strdup( s ); } size_t -slapi_ch_stlen( char *s ) +slapi_ch_stlen( const char *s ) { -#ifdef LDAP_SLAPI - return strlen( (const char *)s ); -#else /* LDAP_SLAPI */ - return 0; -#endif /* LDAP_SLAPI */ + return strlen( s ); } int @@ -1270,7 +1109,6 @@ slapi_control_present( struct berval **val, int *iscritical ) { -#ifdef LDAP_SLAPI int i; int rc = 0; @@ -1289,30 +1127,6 @@ slapi_control_present( rc = 1; if ( controls[i]->ldctl_value.bv_len != 0 ) { - /* - * FIXME: according to 6.1 specification, - * "The val output parameter is set - * to point into the controls array. - * A copy of the control value is - * not made." - */ -#if 0 - struct berval *pTmpBval; - - pTmpBval = (struct berval *)slapi_ch_malloc( sizeof(struct berval)); - if ( pTmpBval == NULL ) { - rc = 0; - } else { - pTmpBval->bv_len = controls[i]->ldctl_value.bv_len; - pTmpBval->bv_val = controls[i]->ldctl_value.bv_val; - if ( val ) { - *val = pTmpBval; - } else { - slapi_ch_free( (void **)&pTmpBval ); - rc = 0; - } - } -#endif /* 0 */ if ( val ) { *val = &controls[i]->ldctl_value; } @@ -1326,12 +1140,8 @@ slapi_control_present( } return rc; -#else /* LDAP_SLAPI */ - return 0; -#endif /* LDAP_SLAPI */ } -#ifdef LDAP_SLAPI static void slapControlMask2SlapiControlOp(slap_mask_t slap_mask, unsigned long *slapi_mask) @@ -1412,20 +1222,17 @@ slapi_int_parse_control( return LDAP_SUCCESS; } -#endif /* LDAP_SLAPI */ void slapi_register_supported_control( char *controloid, unsigned long controlops ) { -#ifdef LDAP_SLAPI slap_mask_t controlmask; slapiControlOp2SlapControlMask( controlops, &controlmask ); register_supported_control( controloid, controlmask, NULL, slapi_int_parse_control, NULL ); -#endif /* LDAP_SLAPI */ } int @@ -1433,7 +1240,6 @@ slapi_get_supported_controls( char ***ctrloidsp, unsigned long **ctrlopsp ) { -#ifdef LDAP_SLAPI int i, rc; rc = get_supported_controls( ctrloidsp, (slap_mask_t **)ctrlopsp ); @@ -1447,15 +1253,11 @@ slapi_get_supported_controls( } return LDAP_SUCCESS; -#else /* LDAP_SLAPI */ - return 1; -#endif /* LDAP_SLAPI */ } LDAPControl * slapi_dup_control( LDAPControl *ctrl ) { -#ifdef LDAP_SLAPI LDAPControl *ret; ret = (LDAPControl *)slapi_ch_malloc( sizeof(*ret) ); @@ -1464,39 +1266,29 @@ slapi_dup_control( LDAPControl *ctrl ) ret->ldctl_iscritical = ctrl->ldctl_iscritical; return ret; -#else - return NULL; -#endif /* LDAP_SLAPI */ } void slapi_register_supported_saslmechanism( char *mechanism ) { -#ifdef LDAP_SLAPI /* FIXME -- can not add saslmechanism to OpenLDAP dynamically */ slapi_log_error( SLAPI_LOG_FATAL, "slapi_register_supported_saslmechanism", "OpenLDAP does not support dynamic registration of SASL mechanisms\n" ); -#endif /* LDAP_SLAPI */ } char ** slapi_get_supported_saslmechanisms( void ) { -#ifdef LDAP_SLAPI /* FIXME -- can not get the saslmechanism without a connection. */ slapi_log_error( SLAPI_LOG_FATAL, "slapi_get_supported_saslmechanisms", "can not get the SASL mechanism list " "without a connection\n" ); return NULL; -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } char ** slapi_get_supported_extended_ops( void ) { -#ifdef LDAP_SLAPI int i, j, k; char **ppExtOpOID = NULL; int numExtOps = 0; @@ -1535,9 +1327,6 @@ slapi_get_supported_extended_ops( void ) ppExtOpOID[ i + k ] = NULL; return ppExtOpOID; -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } void @@ -1549,43 +1338,27 @@ slapi_send_ldap_result( int nentries, struct berval **urls ) { -#ifdef LDAP_SLAPI - Operation *op; - struct berval *s; - char *extOID = NULL; - struct berval *extValue = NULL; - int rc; - SlapReply rs = { REP_RESULT }; + SlapReply *rs; - slapi_pblock_get( pb, SLAPI_OPERATION, &op ); + PBLOCK_ASSERT_OP( pb, 0 ); - rs.sr_err = err; - rs.sr_matched = matched; - rs.sr_text = text; - rs.sr_ref = NULL; - rs.sr_ctrls = NULL; + rs = pb->pb_rs; - slapi_pblock_get( pb, SLAPI_RESCONTROLS, &rs.sr_ctrls ); + rs->sr_err = err; + rs->sr_matched = matched; + rs->sr_text = text; + rs->sr_ref = NULL; if ( err == LDAP_SASL_BIND_IN_PROGRESS ) { - slapi_pblock_get( pb, SLAPI_BIND_RET_SASLCREDS, (void *) &rs.sr_sasldata ); - send_ldap_sasl( op, &rs ); - return; - } + send_ldap_sasl( pb->pb_op, rs ); + } else if ( rs->sr_rspoid != NULL ) { + send_ldap_extended( pb->pb_op, rs ); + } else { + if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH ) + rs->sr_nentries = nentries; - slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID, &extOID ); - if ( extOID != NULL ) { - rs.sr_rspoid = extOID; - slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, &rs.sr_rspdata ); - send_ldap_extended( op, &rs ); - return; + send_ldap_result( pb->pb_op, rs ); } - - if (op->o_tag == LDAP_REQ_SEARCH) - rs.sr_nentries = nentries; - - send_ldap_result( op, &rs ); -#endif /* LDAP_SLAPI */ } int @@ -1596,29 +1369,31 @@ slapi_send_ldap_search_entry( char **attrs, int attrsonly ) { -#ifdef LDAP_SLAPI - Operation *pOp; - SlapReply rs = { REP_RESULT }; - int i; - AttributeName *an = NULL; - const char *text; + SlapReply rs = { REP_SEARCH }; + int i = 0; + AttributeName *an = NULL; + const char *text; + int rc; + + assert( pb->pb_op != NULL ); if ( attrs != NULL ) { for ( i = 0; attrs[ i ] != NULL; i++ ) { ; /* empty */ } - } else { - i = 0; } - if ( i > 0 ) { - an = (AttributeName *) ch_malloc( (i+1) * sizeof(AttributeName) ); + if ( i ) { + an = (AttributeName *) slapi_ch_malloc( (i+1) * sizeof(AttributeName) ); for ( i = 0; attrs[i] != NULL; i++ ) { - an[i].an_name.bv_val = ch_strdup( attrs[i] ); + an[i].an_name.bv_val = attrs[i]; an[i].an_name.bv_len = strlen( attrs[i] ); an[i].an_desc = NULL; - if( slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text ) != LDAP_SUCCESS) + rs.sr_err = slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text ); + if ( rs.sr_err != LDAP_SUCCESS) { + slapi_ch_free( (void **)&an ); return -1; + } } an[i].an_name.bv_len = 0; an[i].an_name.bv_val = NULL; @@ -1635,14 +1410,11 @@ slapi_send_ldap_search_entry( rs.sr_v2ref = NULL; rs.sr_flags = 0; - if ( slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp ) != 0 ) { - return LDAP_OTHER; - } + rc = send_search_entry( pb->pb_op, &rs ); - return send_search_entry( pOp, &rs ); -#else /* LDAP_SLAPI */ - return -1; -#endif /* LDAP_SLAPI */ + slapi_ch_free( (void **)&an ); + + return rc; } int @@ -1654,8 +1426,6 @@ slapi_send_ldap_search_reference( struct berval **v2refs ) { -#ifdef LDAP_SLAPI - Operation *pOp; SlapReply rs = { REP_SEARCHREF }; int rc; @@ -1683,32 +1453,18 @@ slapi_send_ldap_search_reference( rs.sr_v2ref = NULL; } - if ( slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp ) != 0 ) { - return LDAP_OTHER; - } - - rc = send_search_reference( pOp, &rs ); - - if ( rs.sr_ref != NULL ) - slapi_ch_free( (void **)&rs.sr_ref ); + rc = send_search_reference( pb->pb_op, &rs ); - if ( rs.sr_v2ref != NULL ) - slapi_ch_free( (void **)&rs.sr_v2ref ); + slapi_ch_free( (void **)&rs.sr_ref ); + slapi_ch_free( (void **)&rs.sr_v2ref ); return rc; -#else - return -1; -#endif /* LDAP_SLAPI */ } Slapi_Filter * slapi_str2filter( char *str ) { -#ifdef LDAP_SLAPI return str2filter( str ); -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } void @@ -1716,15 +1472,12 @@ slapi_filter_free( Slapi_Filter *f, int recurse ) { -#ifdef LDAP_SLAPI filter_free( f ); -#endif /* LDAP_SLAPI */ } Slapi_Filter * slapi_filter_dup( Slapi_Filter *filter ) { -#ifdef LDAP_SLAPI Filter *f; f = (Filter *) slapi_ch_malloc( sizeof(Filter) ); @@ -1796,15 +1549,11 @@ slapi_filter_dup( Slapi_Filter *filter ) } return f; -#else - return NULL; -#endif /* LDAP_SLAPI */ } int slapi_filter_get_choice( Slapi_Filter *f ) { -#ifdef LDAP_SLAPI int rc; if ( f != NULL ) { @@ -1814,9 +1563,6 @@ slapi_filter_get_choice( Slapi_Filter *f ) } return rc; -#else /* LDAP_SLAPI */ - return -1; /* invalid filter type */ -#endif /* LDAP_SLAPI */ } int @@ -1825,7 +1571,6 @@ slapi_filter_get_ava( char **type, struct berval **bval ) { -#ifdef LDAP_SLAPI int ftype; int rc = LDAP_SUCCESS; @@ -1851,15 +1596,11 @@ slapi_filter_get_ava( } return rc; -#else /* LDAP_SLAPI */ - return -1; -#endif /* LDAP_SLAPI */ } Slapi_Filter * slapi_filter_list_first( Slapi_Filter *f ) { -#ifdef LDAP_SLAPI int ftype; if ( f == NULL ) { @@ -1874,9 +1615,6 @@ slapi_filter_list_first( Slapi_Filter *f ) } else { return NULL; } -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } Slapi_Filter * @@ -1884,7 +1622,6 @@ slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev ) { -#ifdef LDAP_SLAPI int ftype; if ( f == NULL ) { @@ -1900,15 +1637,11 @@ slapi_filter_list_next( } return NULL; -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type ) { -#ifdef LDAP_SLAPI if ( f == NULL ) { return -1; } @@ -1936,16 +1669,51 @@ slapi_filter_get_attribute_type( Slapi_Filter *f, char **type ) } return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ +} + +int +slapi_x_filter_set_attribute_type( Slapi_Filter *f, const char *type ) +{ + AttributeDescription **adp, *ad = NULL; + const char *text; + int rc; + + if ( f == NULL ) { + return -1; + } + + switch ( f->f_choice ) { + case LDAP_FILTER_GE: + case LDAP_FILTER_LE: + case LDAP_FILTER_EQUALITY: + case LDAP_FILTER_APPROX: + adp = &f->f_av_desc; + break; + case LDAP_FILTER_SUBSTRINGS: + adp = &f->f_sub_desc; + break; + case LDAP_FILTER_PRESENT: + adp = &f->f_desc; + break; + case LDAP_FILTER_EXT: + adp = &f->f_mr_desc; + break; + default: + /* Complex filters need not apply. */ + return -1; + } + + rc = slap_str2ad( type, &ad, &text ); + if ( rc == LDAP_SUCCESS ) + *adp = ad; + + return ( rc == LDAP_SUCCESS ) ? 0 : -1; } int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial, char ***any, char **final ) { -#ifdef LDAP_SLAPI int i; if ( f->f_choice != LDAP_FILTER_SUBSTRINGS ) { @@ -1974,15 +1742,11 @@ slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial, *final = f->f_sub_final.bv_val ? slapi_ch_strdup(f->f_sub_final.bv_val) : NULL; return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ } Slapi_Filter * slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2 ) { -#ifdef LDAP_SLAPI Slapi_Filter *f = NULL; if ( ftype == LDAP_FILTER_AND || @@ -1997,9 +1761,6 @@ slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2 ) } return f; -#else - return NULL; -#endif /* LDAP_SLAPI */ } int @@ -2008,7 +1769,6 @@ slapi_x_filter_append( int ftype, Slapi_Filter **pNextFilter, Slapi_Filter *filterToAppend ) { -#ifdef LDAP_SLAPI if ( ftype == LDAP_FILTER_AND || ftype == LDAP_FILTER_OR || ftype == LDAP_FILTER_NOT ) @@ -2029,7 +1789,6 @@ slapi_x_filter_append( int ftype, return 0; } -#endif /* LDAP_SLAPI */ return -1; } @@ -2037,7 +1796,6 @@ int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, int verify_access ) { -#ifdef LDAP_SLAPI Operation *op; int rc; @@ -2047,13 +1805,13 @@ slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, } if ( verify_access ) { - rc = slapi_pblock_get(pb, SLAPI_OPERATION, (void *)&op); - if ( rc != 0 ) { + op = pb->pb_op; + if ( op == NULL ) return LDAP_PARAM_ERROR; - } } else { op = NULL; } + /* * According to acl.c it is safe to call test_filter() with * NULL arguments... @@ -2075,25 +1833,17 @@ slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, } return rc; -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f) { -#ifdef LDAP_SLAPI return slapi_filter_test( NULL, e, f, 0 ); -#else - return -1; -#endif } int slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code ) { -#ifdef LDAP_SLAPI switch ( f->f_choice ) { case LDAP_FILTER_AND: case LDAP_FILTER_NOT: @@ -2133,37 +1883,6 @@ slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_c } return -1; -#else - *error_code = SLAPI_FILTER_UNKNOWN_FILTER_TYPE; - return -1; -#endif /* LDAP_SLAPI */ -} - -int -slapi_send_ldap_extended_response( - Connection *conn, - Operation *op, - int errornum, - char *respName, - struct berval *response ) -{ -#ifdef LDAP_SLAPI - SlapReply rs; - - rs.sr_err = errornum; - rs.sr_matched = NULL; - rs.sr_text = NULL; - rs.sr_ref = NULL; - rs.sr_ctrls = NULL; - rs.sr_rspoid = respName; - rs.sr_rspdata = response; - - send_ldap_extended( op, &rs ); - - return LDAP_SUCCESS; -#else /* LDAP_SLAPI */ - return -1; -#endif /* LDAP_SLAPI */ } int @@ -2171,14 +1890,10 @@ slapi_pw_find( struct berval **vals, struct berval *v ) { -#ifdef LDAP_SLAPI /* * FIXME: what's the point? */ return 1; -#else /* LDAP_SLAPI */ - return 1; -#endif /* LDAP_SLAPI */ } #define MAX_HOSTNAME 512 @@ -2186,7 +1901,6 @@ slapi_pw_find( char * slapi_get_hostname( void ) { -#ifdef LDAP_SLAPI char *hn = NULL; static int been_here = 0; static char *static_hn = NULL; @@ -2223,9 +1937,6 @@ slapi_get_hostname( void ) hn = ch_strdup( static_hn ); return hn; -#else /* LDAP_SLAPI */ - return NULL; -#endif /* LDAP_SLAPI */ } /* @@ -2240,7 +1951,6 @@ slapi_log_error( char *fmt, ... ) { -#ifdef LDAP_SLAPI int rc = LDAP_SUCCESS; va_list arglist; @@ -2249,16 +1959,12 @@ slapi_log_error( va_end( arglist ); return rc; -#else /* LDAP_SLAPI */ - return -1; -#endif /* LDAP_SLAPI */ } unsigned long slapi_timer_current_time( void ) { -#ifdef LDAP_SLAPI static int first_time = 1; #if !defined (_WIN32) struct timeval now; @@ -2295,9 +2001,6 @@ slapi_timer_current_time( void ) QueryPerformanceCounter( &now ); return (1000000*(now.QuadPart-base_time.QuadPart))/performance_freq.QuadPart; #endif /* _WIN32 */ -#else /* LDAP_SLAPI */ - return 0; -#endif /* LDAP_SLAPI */ } /* @@ -2306,13 +2009,9 @@ slapi_timer_current_time( void ) unsigned long slapi_timer_get_time( char *label ) { -#ifdef LDAP_SLAPI unsigned long start = slapi_timer_current_time(); printf("%10ld %10d usec %s\n", start, 0, label); return start; -#else /* LDAP_SLAPI */ - return 0; -#endif /* LDAP_SLAPI */ } /* @@ -2323,348 +2022,101 @@ slapi_timer_elapsed_time( char *label, unsigned long start ) { -#ifdef LDAP_SLAPI unsigned long stop = slapi_timer_current_time(); printf ("%10ld %10ld usec %s\n", stop, stop - start, label); -#endif /* LDAP_SLAPI */ } void slapi_free_search_results_internal( Slapi_PBlock *pb ) { -#ifdef LDAP_SLAPI Slapi_Entry **entries; int k = 0, nEnt = 0; slapi_pblock_get( pb, SLAPI_NENTRIES, &nEnt ); slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries ); - if ( nEnt == 0 ) { - return; - } - - if ( entries == NULL ) { + if ( nEnt == 0 || entries == NULL ) { return; } - + for ( k = 0; k < nEnt; k++ ) { slapi_entry_free( entries[k] ); + entries[k] = NULL; } slapi_ch_free( (void **)&entries ); -#endif /* LDAP_SLAPI */ } -#ifdef LDAP_SLAPI -/* - * Internal API to prime a Slapi_PBlock with a Backend. - */ -static int slapi_int_pblock_set_backend( Slapi_PBlock *pb, Backend *be ) +int slapi_is_connection_ssl( Slapi_PBlock *pb, int *isSSL ) { - int rc; - - rc = slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be ); - if ( rc != LDAP_SUCCESS ) - return rc; - - if ( be != NULL ) { - rc = slapi_pblock_set( pb, SLAPI_BE_TYPE, (void *)be->bd_info->bi_type ); - if ( rc != LDAP_SUCCESS ) - return rc; - } + if ( pb == NULL ) + return LDAP_PARAM_ERROR; + + if ( pb->pb_conn == NULL ) + return LDAP_PARAM_ERROR; + +#ifdef HAVE_TLS + *isSSL = pb->pb_conn->c_is_tls; +#else + *isSSL = 0; +#endif return LDAP_SUCCESS; } /* - * If oldStyle is TRUE, then a value suitable for setting to - * the deprecated SLAPI_CONN_AUTHTYPE value is returned - * (pointer to static storage). - * - * If oldStyle is FALSE, then a value suitable for setting to - * the new SLAPI_CONN_AUTHMETHOD will be returned, which is - * a pointer to allocated memory and will include the SASL - * mechanism (if any). + * DS 5.x compatability API follow */ -static char *Authorization2AuthType( AuthorizationInformation *authz, int is_tls, int oldStyle ) + +int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags ) { - size_t len; - char *authType; + AttributeType *at; - switch ( authz->sai_method ) { - case LDAP_AUTH_SASL: - if ( oldStyle ) { - authType = SLAPD_AUTH_SASL; - } else { - len = sizeof(SLAPD_AUTH_SASL) + authz->sai_mech.bv_len; - authType = slapi_ch_malloc( len ); - snprintf( authType, len, "%s%s", SLAPD_AUTH_SASL, authz->sai_mech.bv_val ); - } - break; - case LDAP_AUTH_SIMPLE: - authType = oldStyle ? SLAPD_AUTH_SIMPLE : slapi_ch_strdup( SLAPD_AUTH_SIMPLE ); - break; - case LDAP_AUTH_NONE: - authType = oldStyle ? SLAPD_AUTH_NONE : slapi_ch_strdup( SLAPD_AUTH_NONE ); - break; - default: - authType = NULL; - break; - } - if ( is_tls && authType == NULL ) { - authType = oldStyle ? SLAPD_AUTH_SSL : slapi_ch_strdup( SLAPD_AUTH_SSL ); - } + if ( attr == NULL ) + return LDAP_PARAM_ERROR; + + at = attr->a_desc->ad_type; + + *flags = SLAPI_ATTR_FLAG_STD_ATTR; + + if ( is_at_single_value( at ) ) + *flags |= SLAPI_ATTR_FLAG_SINGLE; + if ( is_at_operational( at ) ) + *flags |= SLAPI_ATTR_FLAG_OPATTR; + if ( is_at_obsolete( at ) ) + *flags |= SLAPI_ATTR_FLAG_OBSOLETE; + if ( is_at_collective( at ) ) + *flags |= SLAPI_ATTR_FLAG_COLLECTIVE; + if ( is_at_no_user_mod( at ) ) + *flags |= SLAPI_ATTR_FLAG_NOUSERMOD; - return authType; + return LDAP_SUCCESS; } -/* - * Internal API to prime a Slapi_PBlock with a Connection. - */ -static int slapi_int_pblock_set_connection( Slapi_PBlock *pb, Connection *conn ) +int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag ) { - char *connAuthType; - int rc; - - rc = slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn ); - if ( rc != LDAP_SUCCESS ) - return rc; + unsigned long flags; - if ( strncmp( conn->c_peer_name.bv_val, "IP=", 3 ) == 0 ) { - rc = slapi_pblock_set( pb, SLAPI_CONN_CLIENTIP, (void *)&conn->c_peer_name.bv_val[3] ); - if ( rc != LDAP_SUCCESS ) - return rc; - } else if ( strncmp( conn->c_peer_name.bv_val, "PATH=", 5 ) == 0 ) { - rc = slapi_pblock_set( pb, SLAPI_X_CONN_CLIENTPATH, (void *)&conn->c_peer_name.bv_val[5] ); - if ( rc != LDAP_SUCCESS ) - return rc; - } + if ( slapi_attr_get_flags( attr, &flags ) != 0 ) + return 0; + return (flags & flag) ? 1 : 0; +} - if ( strncmp( conn->c_sock_name.bv_val, "IP=", 3 ) == 0 ) { - rc = slapi_pblock_set( pb, SLAPI_CONN_SERVERIP, (void *)&conn->c_sock_name.bv_val[3] ); - if ( rc != LDAP_SUCCESS ) - return rc; - } else if ( strncmp( conn->c_sock_name.bv_val, "PATH=", 5 ) == 0 ) { - rc = slapi_pblock_set( pb, SLAPI_X_CONN_SERVERPATH, (void *)&conn->c_sock_name.bv_val[5] ); - if ( rc != LDAP_SUCCESS ) - return rc; - } +Slapi_Attr *slapi_attr_new( void ) +{ + Attribute *ad; -#ifdef LDAP_CONNECTIONLESS - rc = slapi_pblock_set( pb, SLAPI_X_CONN_IS_UDP, (void *)conn->c_is_udp ); - if ( rc != LDAP_SUCCESS ) - return rc; -#endif + ad = (Attribute *)slapi_ch_calloc( 1, sizeof(*ad) ); - rc = slapi_pblock_set( pb, SLAPI_CONN_ID, (void *)conn->c_connid ); - if ( rc != LDAP_SUCCESS ) - return rc; + return ad; +} - /* Returns pointer to static string */ - connAuthType = Authorization2AuthType( &conn->c_authz, -#ifdef HAVE_TLS - conn->c_is_tls, -#else - 0, -#endif - 1 ); - if ( connAuthType != NULL ) { - rc = slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, (void *)connAuthType); - if ( rc != LDAP_SUCCESS ) - return rc; - } +Slapi_Attr *slapi_attr_init( Slapi_Attr *a, const char *type ) +{ + const char *text; + AttributeDescription *ad = NULL; - /* Returns pointer to allocated string */ - connAuthType = Authorization2AuthType( &conn->c_authz, -#ifdef HAVE_TLS - conn->c_is_tls, -#else - 0, -#endif - 0 ); - if ( connAuthType != NULL ) { - rc = slapi_pblock_set(pb, SLAPI_CONN_AUTHMETHOD, (void *)connAuthType); - /* slapi_pblock_set dups this itself */ - slapi_ch_free( (void **)&connAuthType ); - if ( rc != LDAP_SUCCESS ) - return rc; - } - - if ( conn->c_authz.sai_dn.bv_val != NULL ) { - /* slapi_pblock_set dups this itself */ - rc = slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)conn->c_authz.sai_dn.bv_val); - if ( rc != LDAP_SUCCESS ) - return rc; - } - - rc = slapi_pblock_set(pb, SLAPI_X_CONN_SSF, (void *)conn->c_ssf); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_set(pb, SLAPI_X_CONN_SASL_CONTEXT, - ( conn->c_sasl_authctx != NULL ? conn->c_sasl_authctx : - conn->c_sasl_sockctx ) ); - if ( rc != LDAP_SUCCESS ) - return rc; - - return rc; -} -#endif /* LDAP_SLAPI */ - -/* - * Internal API to prime a Slapi_PBlock with an Operation. - */ -int slapi_int_pblock_set_operation( Slapi_PBlock *pb, Operation *op ) -{ -#ifdef LDAP_SLAPI - int isRoot = 0; - int isUpdateDn = 0; - int rc; - char *opAuthType; - - if ( op->o_bd != NULL ) { - isRoot = be_isroot( op ); - isUpdateDn = be_isupdate( op ); - } - - rc = slapi_int_pblock_set_backend( pb, op->o_bd ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_int_pblock_set_connection( pb, op->o_conn ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_set( pb, SLAPI_OPINITIATED_TIME, (void *)op->o_time ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_set( pb, SLAPI_OPERATION_ID, (void *)op->o_opid ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_set( pb, SLAPI_OPERATION_TYPE, (void *)op->o_tag ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_set( pb, SLAPI_REQUESTOR_ISUPDATEDN, (void *)isUpdateDn ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls ); - if ( rc != LDAP_SUCCESS) - return rc; - - rc = slapi_pblock_set( pb, SLAPI_REQUESTOR_DN, (void *)op->o_ndn.bv_val ); - if ( rc != LDAP_SUCCESS ) - return rc; - - rc = slapi_pblock_get( pb, SLAPI_CONN_AUTHMETHOD, (void *)&opAuthType ); - if ( rc == LDAP_SUCCESS && opAuthType != NULL ) { - /* Not quite sure what the point of this is. */ - rc = slapi_pblock_set( pb, SLAPI_OPERATION_AUTHTYPE, (void *)opAuthType ); - if ( rc != LDAP_SUCCESS ) - return rc; - } - - return LDAP_SUCCESS; -#else - return -1; -#endif -} - -int slapi_is_connection_ssl( Slapi_PBlock *pb, int *isSSL ) -{ -#ifdef LDAP_SLAPI - Connection *conn; - - slapi_pblock_get( pb, SLAPI_CONNECTION, &conn ); -#ifdef HAVE_TLS - *isSSL = conn->c_is_tls; -#else - *isSSL = 0; -#endif - - return LDAP_SUCCESS; -#else - return -1; -#endif /* LDAP_SLAPI */ -} - -/* - * DS 5.x compatability API follow - */ - -int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags ) -{ -#ifdef LDAP_SLAPI - AttributeType *at; - - if ( attr == NULL ) - return LDAP_PARAM_ERROR; - - at = attr->a_desc->ad_type; - - *flags = SLAPI_ATTR_FLAG_STD_ATTR; - - if ( is_at_single_value( at ) ) - *flags |= SLAPI_ATTR_FLAG_SINGLE; - if ( is_at_operational( at ) ) - *flags |= SLAPI_ATTR_FLAG_OPATTR; - if ( is_at_obsolete( at ) ) - *flags |= SLAPI_ATTR_FLAG_OBSOLETE; - if ( is_at_collective( at ) ) - *flags |= SLAPI_ATTR_FLAG_COLLECTIVE; - if ( is_at_no_user_mod( at ) ) - *flags |= SLAPI_ATTR_FLAG_NOUSERMOD; - - return LDAP_SUCCESS; -#else - return -1; -#endif /* LDAP_SLAPI */ -} - -int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag ) -{ -#ifdef LDAP_SLAPI - unsigned long flags; - - if ( slapi_attr_get_flags( attr, &flags ) != 0 ) - return 0; - return (flags & flag) ? 1 : 0; -#else - return 0; -#endif /* LDAP_SLAPI */ -} - -Slapi_Attr *slapi_attr_new( void ) -{ -#ifdef LDAP_SLAPI - Attribute *ad; - - ad = (Attribute *)slapi_ch_calloc( 1, sizeof(*ad) ); - - return ad; -#else - return NULL; -#endif -} - -Slapi_Attr *slapi_attr_init( Slapi_Attr *a, const char *type ) -{ -#ifdef LDAP_SLAPI - const char *text; - AttributeDescription *ad = NULL; - - if( slap_str2ad( type, &ad, &text ) != LDAP_SUCCESS ) { - return NULL; + if( slap_str2ad( type, &ad, &text ) != LDAP_SUCCESS ) { + return NULL; } a->a_desc = ad; @@ -2674,31 +2126,21 @@ Slapi_Attr *slapi_attr_init( Slapi_Attr *a, const char *type ) a->a_flags = 0; return a; -#else - return NULL; -#endif } void slapi_attr_free( Slapi_Attr **a ) { -#ifdef LDAP_SLAPI attr_free( *a ); *a = NULL; -#endif } Slapi_Attr *slapi_attr_dup( const Slapi_Attr *attr ) { -#ifdef LDAP_SLAPI return attr_dup( (Slapi_Attr *)attr ); -#else - return NULL; -#endif } int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v ) { -#ifdef LDAP_SLAPI struct berval nval; struct berval *nvalp; int rc; @@ -2731,9 +2173,6 @@ int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v ) } return rc; -#else - return -1; -#endif } int slapi_attr_type2plugin( const char *type, void **pi ) @@ -2745,7 +2184,6 @@ int slapi_attr_type2plugin( const char *type, void **pi ) int slapi_attr_get_type( const Slapi_Attr *attr, char **type ) { -#ifdef LDAP_SLAPI if ( attr == NULL ) { return LDAP_PARAM_ERROR; } @@ -2753,28 +2191,20 @@ int slapi_attr_get_type( const Slapi_Attr *attr, char **type ) *type = attr->a_desc->ad_cname.bv_val; return LDAP_SUCCESS; -#else - return -1; -#endif } int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp ) { -#ifdef LDAP_SLAPI if ( attr == NULL ) { return LDAP_PARAM_ERROR; } *oidp = attr->a_desc->ad_type->sat_oid; return LDAP_SUCCESS; -#else - return -1; -#endif } int slapi_attr_value_cmp( const Slapi_Attr *a, const struct berval *v1, const struct berval *v2 ) { -#ifdef LDAP_SLAPI MatchingRule *mr; int ret; int rc; @@ -2788,14 +2218,10 @@ int slapi_attr_value_cmp( const Slapi_Attr *a, const struct berval *v1, const st return -1; return ( ret == 0 ) ? 0 : -1; -#else - return -1; -#endif } int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v ) { -#ifdef LDAP_SLAPI MatchingRule *mr; struct berval *bv; int j; @@ -2817,13 +2243,11 @@ int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v ) return 0; } } -#endif /* LDAP_SLAPI */ return -1; } int slapi_attr_type_cmp( const char *t1, const char *t2, int opt ) { -#ifdef LDAP_SLAPI AttributeDescription *a1 = NULL; AttributeDescription *a2 = NULL; const char *text; @@ -2857,72 +2281,44 @@ int slapi_attr_type_cmp( const char *t1, const char *t2, int opt ) } return ret; -#else - return -1; -#endif } int slapi_attr_types_equivalent( const char *t1, const char *t2 ) { -#ifdef LDAP_SLAPI - return slapi_attr_type_cmp( t1, t2, SLAPI_TYPE_CMP_EXACT ); -#else - return -1; -#endif + return ( slapi_attr_type_cmp( t1, t2, SLAPI_TYPE_CMP_EXACT ) == 0 ); } int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v ) { -#ifdef LDAP_SLAPI return slapi_valueset_first_value( &a->a_vals, v ); -#else - return -1; -#endif } int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v ) { -#ifdef LDAP_SLAPI return slapi_valueset_next_value( &a->a_vals, hint, v ); -#else - return -1; -#endif } int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues ) { -#ifdef LDAP_SLAPI *numValues = slapi_valueset_count( &a->a_vals ); return 0; -#else - return -1; -#endif } int slapi_attr_get_valueset( const Slapi_Attr *a, Slapi_ValueSet **vs ) { -#ifdef LDAP_SLAPI *vs = &((Slapi_Attr *)a)->a_vals; return 0; -#else - return -1; -#endif } int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals ) { -#ifdef LDAP_SLAPI return slapi_attr_get_values( a, vals ); -#else - return -1; -#endif } char *slapi_attr_syntax_normalize( const char *s ) { -#ifdef LDAP_SLAPI AttributeDescription *ad = NULL; const char *text; @@ -2931,101 +2327,65 @@ char *slapi_attr_syntax_normalize( const char *s ) } return ad->ad_cname.bv_val; -#else - return -1; -#endif } Slapi_Value *slapi_value_new( void ) { -#ifdef LDAP_SLAPI struct berval *bv; bv = (struct berval *)slapi_ch_malloc( sizeof(*bv) ); return bv; -#else - return NULL; -#endif } Slapi_Value *slapi_value_new_berval(const struct berval *bval) { -#ifdef LDAP_SLAPI return ber_dupbv( NULL, (struct berval *)bval ); -#else - return NULL; -#endif } Slapi_Value *slapi_value_new_value(const Slapi_Value *v) { -#ifdef LDAP_SLAPI return slapi_value_new_berval( v ); -#else - return NULL; -#endif } Slapi_Value *slapi_value_new_string(const char *s) { -#ifdef LDAP_SLAPI struct berval bv; bv.bv_val = (char *)s; bv.bv_len = strlen( s ); return slapi_value_new_berval( &bv ); -#else - return NULL; -#endif } Slapi_Value *slapi_value_init(Slapi_Value *val) { -#ifdef LDAP_SLAPI val->bv_val = NULL; val->bv_len = 0; return val; -#else - return NULL; -#endif } Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval) { -#ifdef LDAP_SLAPI return ber_dupbv( v, bval ); -#else - return NULL; -#endif } Slapi_Value *slapi_value_init_string(Slapi_Value *v, const char *s) { -#ifdef LDAP_SLAPI - v->bv_val = slapi_ch_strdup( (char *)s ); + v->bv_val = slapi_ch_strdup( s ); v->bv_len = strlen( s ); return v; -#else - return NULL; -#endif } Slapi_Value *slapi_value_dup(const Slapi_Value *v) { -#ifdef LDAP_SLAPI return slapi_value_new_value( v ); -#else - return NULL; -#endif } void slapi_value_free(Slapi_Value **value) { -#ifdef LDAP_SLAPI if ( value == NULL ) { return; } @@ -3034,21 +2394,15 @@ void slapi_value_free(Slapi_Value **value) slapi_ch_free( (void **)&(*value)->bv_val ); slapi_ch_free( (void **)value ); } -#endif } const struct berval *slapi_value_get_berval( const Slapi_Value *value ) { -#ifdef LDAP_SLAPI return value; -#else - return NULL; -#endif } Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval ) { -#ifdef LDAP_SLAPI if ( value == NULL ) { return NULL; } @@ -3058,26 +2412,18 @@ Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bv slapi_value_init_berval( value, (struct berval *)bval ); return value; -#else - return NULL; -#endif } Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom) { -#ifdef LDAP_SLAPI if ( value == NULL ) { return NULL; } return slapi_value_set_berval( value, vfrom ); -#else - return NULL; -#endif } Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len) { -#ifdef LDAP_SLAPI if ( value == NULL ) { return NULL; } @@ -3089,141 +2435,97 @@ Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len) AC_MEMCPY( value->bv_val, val, len ); return value; -#else - return NULL; -#endif } int slapi_value_set_string(Slapi_Value *value, const char *strVal) { -#ifdef LDAP_SLAPI if ( value == NULL ) { return -1; } slapi_value_set( value, (void *)strVal, strlen( strVal ) ); return 0; -#else - return NULL; -#endif } int slapi_value_set_int(Slapi_Value *value, int intVal) { -#ifdef LDAP_SLAPI char buf[64]; snprintf( buf, sizeof( buf ), "%d", intVal ); return slapi_value_set_string( value, buf ); -#else - return -1; -#endif } const char *slapi_value_get_string(const Slapi_Value *value) { -#ifdef LDAP_SLAPI if ( value == NULL ) return NULL; if ( value->bv_val == NULL ) return NULL; if ( !checkBVString( value ) ) return NULL; return value->bv_val; -#else - return NULL; -#endif } int slapi_value_get_int(const Slapi_Value *value) { -#ifdef LDAP_SLAPI if ( value == NULL ) return 0; if ( value->bv_val == NULL ) return 0; if ( !checkBVString( value ) ) return 0; return (int)strtol( value->bv_val, NULL, 10 ); -#else - return NULL; -#endif } unsigned int slapi_value_get_uint(const Slapi_Value *value) { -#ifdef LDAP_SLAPI if ( value == NULL ) return 0; if ( value->bv_val == NULL ) return 0; if ( !checkBVString( value ) ) return 0; return (unsigned int)strtoul( value->bv_val, NULL, 10 ); -#else - return NULL; -#endif } long slapi_value_get_long(const Slapi_Value *value) { -#ifdef LDAP_SLAPI if ( value == NULL ) return 0; if ( value->bv_val == NULL ) return 0; if ( !checkBVString( value ) ) return 0; return strtol( value->bv_val, NULL, 10 ); -#else - return NULL; -#endif } unsigned long slapi_value_get_ulong(const Slapi_Value *value) { -#ifdef LDAP_SLAPI if ( value == NULL ) return 0; if ( value->bv_val == NULL ) return 0; if ( !checkBVString( value ) ) return 0; return strtoul( value->bv_val, NULL, 10 ); -#else - return NULL; -#endif } size_t slapi_value_get_length(const Slapi_Value *value) { -#ifdef LDAP_SLAPI if ( value == NULL ) return 0; return (size_t) value->bv_len; -#else - return 0; -#endif } int slapi_value_compare(const Slapi_Attr *a, const Slapi_Value *v1, const Slapi_Value *v2) { -#ifdef LDAP_SLAPI return slapi_attr_value_cmp( a, v1, v2 ); -#else - return -1; -#endif } /* A ValueSet is a container for a BerVarray. */ Slapi_ValueSet *slapi_valueset_new( void ) { -#ifdef LDAP_SLAPI Slapi_ValueSet *vs; vs = (Slapi_ValueSet *)slapi_ch_malloc( sizeof( *vs ) ); *vs = NULL; return vs; -#else - return NULL; -#endif } void slapi_valueset_free(Slapi_ValueSet *vs) { -#ifdef LDAP_SLAPI if ( vs != NULL ) { BerVarray vp = *vs; @@ -3232,23 +2534,19 @@ void slapi_valueset_free(Slapi_ValueSet *vs) *vs = NULL; } -#endif } void slapi_valueset_init(Slapi_ValueSet *vs) { -#ifdef LDAP_SLAPI if ( vs != NULL && *vs == NULL ) { *vs = (Slapi_ValueSet)slapi_ch_calloc( 1, sizeof(struct berval) ); (*vs)->bv_val = NULL; (*vs)->bv_len = 0; } -#endif } void slapi_valueset_done(Slapi_ValueSet *vs) { -#ifdef LDAP_SLAPI BerVarray vp; if ( vs == NULL ) @@ -3259,31 +2557,23 @@ void slapi_valueset_done(Slapi_ValueSet *vs) slapi_ch_free( (void **)&vp->bv_val ); } /* but don't free *vs or vs */ -#endif } void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval) { -#ifdef LDAP_SLAPI struct berval bv; ber_dupbv( &bv, (Slapi_Value *)addval ); ber_bvarray_add( vs, &bv ); -#endif } int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v ) { -#ifdef LDAP_SLAPI return slapi_valueset_next_value( vs, 0, v ); -#else - return -1; -#endif } int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v) { -#ifdef LDAP_SLAPI int i; BerVarray vp; @@ -3298,14 +2588,12 @@ int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v) return index + 1; } } -#endif return -1; } int slapi_valueset_count( const Slapi_ValueSet *vs ) { -#ifdef LDAP_SLAPI int i; BerVarray vp; @@ -3318,40 +2606,35 @@ int slapi_valueset_count( const Slapi_ValueSet *vs ) ; return i; -#else - return 0; -#endif } void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2) { -#ifdef LDAP_SLAPI BerVarray vp; for ( vp = *vs2; vp->bv_val != NULL; vp++ ) { slapi_valueset_add_value( vs1, vp ); } -#endif } int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr, struct berval *val, int access ) { -#ifdef LDAP_SLAPI - Backend *be; - Connection *conn; - Operation *op; - int ret; + int rc; slap_access_t slap_access; AttributeDescription *ad = NULL; const char *text; - ret = slap_str2ad( attr, &ad, &text ); - if ( ret != LDAP_SUCCESS ) { - return ret; + rc = slap_str2ad( attr, &ad, &text ); + if ( rc != LDAP_SUCCESS ) { + return rc; } + /* + * Whilst the SLAPI access types are arranged as a bitmask, the + * documentation indicates that they are to be used separately. + */ switch ( access & SLAPI_ACL_ALL ) { case SLAPI_ACL_COMPARE: slap_access = ACL_COMPARE; @@ -3363,122 +2646,89 @@ int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr, slap_access = ACL_READ; break; case SLAPI_ACL_WRITE: + slap_access = ACL_WRITE; + break; case SLAPI_ACL_DELETE: + slap_access = ACL_WDEL; + break; case SLAPI_ACL_ADD: - case SLAPI_ACL_SELF: - /* FIXME: handle ACL_WADD/ACL_WDEL */ - slap_access = ACL_WRITE; + slap_access = ACL_WADD; break; + case SLAPI_ACL_SELF: /* not documented */ + case SLAPI_ACL_PROXY: /* not documented */ default: return LDAP_INSUFFICIENT_ACCESS; break; } - if ( slapi_pblock_get( pb, SLAPI_BACKEND, (void *)&be ) != 0 ) { - return LDAP_PARAM_ERROR; - } + assert( pb->pb_op != NULL ); - if ( slapi_pblock_get( pb, SLAPI_CONNECTION, (void *)&conn ) != 0 ) { - return LDAP_PARAM_ERROR; - } - - if ( slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&op ) != 0 ) { - return LDAP_PARAM_ERROR; + if ( access_allowed( pb->pb_op, e, ad, val, slap_access, NULL ) ) { + return LDAP_SUCCESS; } - ret = access_allowed( op, e, ad, val, slap_access, NULL ); - - return ret ? LDAP_SUCCESS : LDAP_INSUFFICIENT_ACCESS; -#else - return LDAP_UNWILLING_TO_PERFORM; -#endif + return LDAP_INSUFFICIENT_ACCESS; } int slapi_acl_check_mods(Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char **errbuf) { -#ifdef LDAP_SLAPI - Operation *op; int rc = LDAP_SUCCESS; - Modifications *ml, *mp; + Modifications *ml; - if ( slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&op ) != 0 ) { + if ( pb == NULL || pb->pb_op == NULL ) return LDAP_PARAM_ERROR; - } ml = slapi_int_ldapmods2modifications( mods ); if ( ml == NULL ) { return LDAP_OTHER; } - for ( mp = ml; mp != NULL; mp = mp->sml_next ) { - rc = slap_bv2ad( &mp->sml_type, &mp->sml_desc, (const char **)errbuf ); - if ( rc != LDAP_SUCCESS ) { - break; - } - } - if ( rc == LDAP_SUCCESS ) { - rc = acl_check_modlist( op, e, ml ) ? LDAP_SUCCESS : LDAP_INSUFFICIENT_ACCESS; + rc = acl_check_modlist( pb->pb_op, e, ml ) ? LDAP_SUCCESS : LDAP_INSUFFICIENT_ACCESS; } - /* Careful when freeing the modlist because it has pointers into the mods array. */ - for ( ; ml != NULL; ml = mp ) { - mp = ml->sml_next; - - /* just free the containing array */ - slapi_ch_free( (void **)&ml->sml_values ); - slapi_ch_free( (void **)&ml ); - } + slap_mods_free( ml, 1 ); return rc; -#else - return LDAP_UNWILLING_TO_PERFORM; -#endif } /* * Synthesise an LDAPMod array from a Modifications list to pass - * to SLAPI. This synthesis is destructive and as such the - * Modifications list may not be used after calling this - * function. - * - * This function must also be called before slap_mods_check(). + * to SLAPI. */ -LDAPMod **slapi_int_modifications2ldapmods(Modifications **pmodlist) +LDAPMod **slapi_int_modifications2ldapmods( Modifications *modlist ) { -#ifdef LDAP_SLAPI - Modifications *ml, *modlist; + Modifications *ml; LDAPMod **mods, *modp; int i, j; - modlist = *pmodlist; - for( i = 0, ml = modlist; ml != NULL; i++, ml = ml->sml_next ) ; - mods = (LDAPMod **)ch_malloc( (i + 1) * sizeof(LDAPMod *) ); + mods = (LDAPMod **)slapi_ch_malloc( (i + 1) * sizeof(LDAPMod *) ); for( i = 0, ml = modlist; ml != NULL; ml = ml->sml_next ) { - mods[i] = (LDAPMod *)ch_malloc( sizeof(LDAPMod) ); + mods[i] = (LDAPMod *)slapi_ch_malloc( sizeof(LDAPMod) ); modp = mods[i]; modp->mod_op = ml->sml_op | LDAP_MOD_BVALUES; - - /* Take ownership of original type. */ - modp->mod_type = ml->sml_type.bv_val; - ml->sml_type.bv_val = NULL; + if ( BER_BVISNULL( &ml->sml_type ) ) { + /* may happen for internally generated mods */ + assert( ml->sml_desc != NULL ); + modp->mod_type = slapi_ch_strdup( ml->sml_desc->ad_cname.bv_val ); + } else { + modp->mod_type = slapi_ch_strdup( ml->sml_type.bv_val ); + BER_BVZERO( &ml->sml_type ); + } if ( ml->sml_values != NULL ) { for( j = 0; ml->sml_values[j].bv_val != NULL; j++ ) ; - modp->mod_bvalues = (struct berval **)ch_malloc( (j + 1) * + modp->mod_bvalues = (struct berval **)slapi_ch_malloc( (j + 1) * sizeof(struct berval *) ); for( j = 0; ml->sml_values[j].bv_val != NULL; j++ ) { - /* Take ownership of original values. */ - modp->mod_bvalues[j] = (struct berval *)ch_malloc( sizeof(struct berval) ); - modp->mod_bvalues[j]->bv_len = ml->sml_values[j].bv_len; - modp->mod_bvalues[j]->bv_val = ml->sml_values[j].bv_val; - ml->sml_values[j].bv_len = 0; - ml->sml_values[j].bv_val = NULL; + modp->mod_bvalues[j] = (struct berval *)slapi_ch_malloc( + sizeof(struct berval) ); + ber_dupbv( modp->mod_bvalues[j], &ml->sml_values[j] ); } modp->mod_bvalues[j] = NULL; } else { @@ -3489,227 +2739,99 @@ LDAPMod **slapi_int_modifications2ldapmods(Modifications **pmodlist) mods[i] = NULL; - slap_mods_free( modlist ); - *pmodlist = NULL; - return mods; -#else - return NULL; -#endif } /* * Convert a potentially modified array of LDAPMods back to a - * Modification list. - * - * The returned Modification list contains pointers into the - * LDAPMods array; the latter MUST be freed with - * slapi_int_free_ldapmods() (see below). + * Modification list. Unfortunately the values need to be + * duplicated because slap_mods_check() will try to free them + * before prettying (and we can't easily get out of calling + * slap_mods_check() because we need normalized values). */ -Modifications *slapi_int_ldapmods2modifications (LDAPMod **mods) +Modifications *slapi_int_ldapmods2modifications ( LDAPMod **mods ) { -#ifdef LDAP_SLAPI Modifications *modlist = NULL, **modtail; LDAPMod **modp; + char textbuf[SLAP_TEXT_BUFLEN]; + const char *text; - if ( mods == NULL ) { - return NULL; - } - - modtail = &modlist; - - for( modp = mods; *modp != NULL; modp++ ) { - Modifications *mod; - int i; - char **p; - struct berval **bvp; - - mod = (Modifications *) ch_malloc( sizeof(Modifications) ); - mod->sml_op = (*modp)->mod_op & (~LDAP_MOD_BVALUES); - mod->sml_flags = 0; - mod->sml_type.bv_val = (*modp)->mod_type; - mod->sml_type.bv_len = strlen( mod->sml_type.bv_val ); - mod->sml_desc = NULL; - mod->sml_next = NULL; - - if ( (*modp)->mod_op & LDAP_MOD_BVALUES ) { - for( i = 0, bvp = (*modp)->mod_bvalues; bvp != NULL && *bvp != NULL; bvp++, i++ ) - ; - } else { - for( i = 0, p = (*modp)->mod_values; p != NULL && *p != NULL; p++, i++ ) - ; - } - - if ( i == 0 ) { - mod->sml_values = NULL; - } else { - mod->sml_values = (BerVarray) ch_malloc( (i + 1) * sizeof(struct berval) ); - - /* NB: This implicitly trusts a plugin to return valid modifications. */ - if ( (*modp)->mod_op & LDAP_MOD_BVALUES ) { - for( i = 0, bvp = (*modp)->mod_bvalues; bvp != NULL && *bvp != NULL; bvp++, i++ ) { - mod->sml_values[i].bv_val = (*bvp)->bv_val; - mod->sml_values[i].bv_len = (*bvp)->bv_len; - } - } else { - for( i = 0, p = (*modp)->mod_values; p != NULL && *p != NULL; p++, i++ ) { - mod->sml_values[i].bv_val = *p; - mod->sml_values[i].bv_len = strlen( *p ); - } - } - mod->sml_values[i].bv_val = NULL; - mod->sml_values[i].bv_len = 0; - } - mod->sml_nvalues = NULL; - - *modtail = mod; - modtail = &mod->sml_next; - } - - return modlist; -#else - return NULL; -#endif -} - -/* - * This function only frees the parts of the mods array that - * are not shared with the Modification list that was created - * by slapi_int_ldapmods2modifications(). - * - */ -void slapi_int_free_ldapmods (LDAPMod **mods) -{ -#ifdef LDAP_SLAPI - int i, j; - - if (mods == NULL) - return; - - for ( i = 0; mods[i] != NULL; i++ ) { - /* - * Don't free values themselves; they're owned by the - * Modification list. Do free the containing array. - */ - if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) { - for ( j = 0; mods[i]->mod_values != NULL && mods[i]->mod_values[j] != NULL; j++ ) { - ch_free( mods[i]->mod_values[j] ); - } - ch_free( mods[i]->mod_values ); - } else { - ch_free( mods[i]->mod_values ); - } - /* Don't free type, for same reasons. */ - ch_free( mods[i] ); - } - ch_free( mods ); -#endif /* LDAP_SLAPI */ -} - -/* - * Sun ONE DS 5.x computed attribute support. Computed attributes - * allow for dynamically generated operational attributes, a very - * useful thing indeed. - */ - -/* - * Write the computed attribute to a BerElement. Complementary - * functions need to be defined for anything that replaces - * op->o_callback->sc_sendentry, if you wish to make computed - * attributes available to it. - */ -int slapi_int_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e) -{ -#ifdef LDAP_SLAPI - Operation *op = NULL; - BerElement *ber; - AttributeDescription *desc = NULL; - int rc; - int i; - - if ( c == NULL ) { - return 1; + if ( mods == NULL ) { + return NULL; } - if ( a == NULL ) { - return 1; - } + modtail = &modlist; - if ( e == NULL ) { - return 1; - } + for ( modp = mods; *modp != NULL; modp++ ) { + Modifications *mod; + LDAPMod *lmod = *modp; + int i; + const char *text; + AttributeDescription *ad = NULL; - rc = slapi_pblock_get( c->cac_pb, SLAPI_OPERATION, (void *)&op ); - if ( rc != 0 || op == NULL ) { - return rc; - } + if ( slap_str2ad( lmod->mod_type, &ad, &text ) != LDAP_SUCCESS ) { + continue; + } - ber = (BerElement *)c->cac_private; - desc = a->a_desc; + mod = (Modifications *) slapi_ch_malloc( sizeof(Modifications) ); + mod->sml_op = lmod->mod_op & ~(LDAP_MOD_BVALUES); + mod->sml_flags = 0; + mod->sml_type = ad->ad_cname; + mod->sml_desc = ad; + mod->sml_next = NULL; - if ( c->cac_attrs == NULL ) { - /* All attrs request, skip operational attributes */ - if ( is_at_operational( desc->ad_type ) ) { - return 0; - } - } else { - /* Specific attrs requested */ - if ( is_at_operational( desc->ad_type ) ) { - if ( !c->cac_opattrs && !ad_inlist( desc, c->cac_attrs ) ) { - return 0; + i = 0; + if ( lmod->mod_op & LDAP_MOD_BVALUES ) { + if ( lmod->mod_bvalues != NULL ) { + while ( lmod->mod_bvalues[i] != NULL ) + i++; } } else { - if ( !c->cac_userattrs && !ad_inlist( desc, c->cac_attrs ) ) { - return 0; + if ( lmod->mod_values != NULL ) { + while ( lmod->mod_values[i] != NULL ) + i++; } } - } - - if ( !access_allowed( op, e, desc, NULL, ACL_READ, &c->cac_acl_state) ) { - slapi_log_error( SLAPI_LOG_ACL, "slapi_int_compute_output_ber", - "acl: access to attribute %s not allowed\n", - desc->ad_cname.bv_val ); - return 0; - } - rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname ); - if (rc == -1 ) { - slapi_log_error( SLAPI_LOG_BER, "slapi_int_compute_output_ber", - "ber_printf failed\n"); - return 1; - } + if ( i == 0 ) { + mod->sml_values = NULL; + } else { + mod->sml_values = (BerVarray) slapi_ch_malloc( (i + 1) * sizeof(struct berval) ); - if ( !c->cac_attrsonly && a->a_vals != NULL ) { - for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) { - if ( !access_allowed( op, e, - desc, &a->a_vals[i], ACL_READ, &c->cac_acl_state)) { - slapi_log_error( SLAPI_LOG_ACL, "slapi_int_compute_output_ber", - "conn %lu " - "acl: access to %s, value %d not allowed\n", - op->o_connid, desc->ad_cname.bv_val, i ); - continue; - } - - if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) { - slapi_log_error( SLAPI_LOG_BER, "slapi_int_compute_output_ber", - "ber_printf failed\n"); - return 1; + /* NB: This implicitly trusts a plugin to return valid modifications. */ + if ( lmod->mod_op & LDAP_MOD_BVALUES ) { + for ( i = 0; lmod->mod_bvalues[i] != NULL; i++ ) { + ber_dupbv( &mod->sml_values[i], lmod->mod_bvalues[i] ); + } + } else { + for ( i = 0; lmod->mod_values[i] != NULL; i++ ) { + mod->sml_values[i].bv_val = slapi_ch_strdup( lmod->mod_values[i] ); + mod->sml_values[i].bv_len = strlen( lmod->mod_values[i] ); + } } + mod->sml_values[i].bv_val = NULL; + mod->sml_values[i].bv_len = 0; } + mod->sml_nvalues = NULL; + + *modtail = mod; + modtail = &mod->sml_next; } - if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) { - slapi_log_error( SLAPI_LOG_BER, "slapi_int_compute_output_ber", - "ber_printf failed\n" ); - return 1; + if ( slap_mods_check( modlist, &text, textbuf, sizeof( textbuf ), NULL ) != LDAP_SUCCESS ) { + slap_mods_free( modlist, 1 ); + modlist = NULL; } - return 0; -#else - return 1; -#endif + return modlist; } +/* + * Sun ONE DS 5.x computed attribute support. Computed attributes + * allow for dynamically generated operational attributes, a very + * useful thing indeed. + */ + /* * For some reason Sun don't use the normal plugin mechanism * registration path to register an "evaluator" function (an @@ -3721,9 +2843,9 @@ int slapi_int_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_ */ int slapi_compute_add_evaluator(slapi_compute_callback_t function) { -#ifdef LDAP_SLAPI Slapi_PBlock *pPlugin = NULL; int rc; + int type = SLAPI_PLUGIN_OBJECT; pPlugin = slapi_pblock_new(); if ( pPlugin == NULL ) { @@ -3731,7 +2853,7 @@ int slapi_compute_add_evaluator(slapi_compute_callback_t function) goto done; } - rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)SLAPI_PLUGIN_OBJECT ); + rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)&type ); if ( rc != LDAP_SUCCESS ) { goto done; } @@ -3741,7 +2863,7 @@ int slapi_compute_add_evaluator(slapi_compute_callback_t function) goto done; } - rc = slapi_int_register_plugin( NULL, pPlugin ); + rc = slapi_int_register_plugin( frontendDB, pPlugin ); if ( rc != 0 ) { rc = LDAP_OTHER; goto done; @@ -3756,9 +2878,6 @@ done: } return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ } /* @@ -3766,9 +2885,9 @@ done: */ int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function) { -#ifdef LDAP_SLAPI Slapi_PBlock *pPlugin = NULL; int rc; + int type = SLAPI_PLUGIN_OBJECT; pPlugin = slapi_pblock_new(); if ( pPlugin == NULL ) { @@ -3776,7 +2895,7 @@ int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function) goto done; } - rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)SLAPI_PLUGIN_OBJECT ); + rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)&type ); if ( rc != LDAP_SUCCESS ) { goto done; } @@ -3786,7 +2905,7 @@ int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function) goto done; } - rc = slapi_int_register_plugin( NULL, pPlugin ); + rc = slapi_int_register_plugin( frontendDB, pPlugin ); if ( rc != 0 ) { rc = LDAP_OTHER; goto done; @@ -3801,9 +2920,6 @@ done: } return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ } /* @@ -3811,11 +2927,10 @@ done: */ int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn) { -#ifdef LDAP_SLAPI int rc = 0; slapi_compute_callback_t *pGetPlugin, *tmpPlugin; - rc = slapi_int_get_plugins( NULL, SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN, (SLAPI_FUNC **)&tmpPlugin ); + rc = slapi_int_get_plugins( frontendDB, SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN, (SLAPI_FUNC **)&tmpPlugin ); if ( rc != LDAP_SUCCESS || tmpPlugin == NULL ) { /* Nothing to do; front-end should ignore. */ return 0; @@ -3836,35 +2951,24 @@ int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slap slapi_ch_free( (void **)&tmpPlugin ); return rc; -#else - return 1; -#endif /* LDAP_SLAPI */ } -int compute_rewrite_search_filter(Slapi_PBlock *pb) +int +compute_rewrite_search_filter( Slapi_PBlock *pb ) { -#ifdef LDAP_SLAPI - Backend *be; - int rc; - - rc = slapi_pblock_get( pb, SLAPI_BACKEND, (void *)&be ); - if ( rc != 0 ) { - return rc; - } + if ( pb == NULL || pb->pb_op == NULL ) + return LDAP_PARAM_ERROR; - return slapi_int_call_plugins( be, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb ); -#else - return -1; -#endif /* LDAP_SLAPI */ + return slapi_int_call_plugins( pb->pb_op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb ); } /* * New API to provide the plugin with access to the search * pblock. Have informed Sun DS team. */ -int slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb) +int +slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb) { -#ifdef LDAP_SLAPI if ( c == NULL ) return -1; @@ -3874,14 +2978,10 @@ int slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb) *pb = c->cac_pb; return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ } Slapi_Mutex *slapi_new_mutex( void ) { -#ifdef LDAP_SLAPI Slapi_Mutex *m; m = (Slapi_Mutex *)slapi_ch_malloc( sizeof(*m) ); @@ -3891,40 +2991,28 @@ Slapi_Mutex *slapi_new_mutex( void ) } return m; -#else - return NULL; -#endif } void slapi_destroy_mutex( Slapi_Mutex *mutex ) { -#ifdef LDAP_SLAPI if ( mutex != NULL ) { ldap_pvt_thread_mutex_destroy( &mutex->mutex ); slapi_ch_free( (void **)&mutex); } -#endif } void slapi_lock_mutex( Slapi_Mutex *mutex ) { -#ifdef LDAP_SLAPI ldap_pvt_thread_mutex_lock( &mutex->mutex ); -#endif } int slapi_unlock_mutex( Slapi_Mutex *mutex ) { -#ifdef LDAP_SLAPI return ldap_pvt_thread_mutex_unlock( &mutex->mutex ); -#else - return -1; -#endif } Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex ) { -#ifdef LDAP_SLAPI Slapi_CondVar *cv; if ( mutex == NULL ) { @@ -3937,41 +3025,30 @@ Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex ) return NULL; } - /* XXX struct copy */ cv->mutex = mutex->mutex; return cv; -#else - return NULL; -#endif } void slapi_destroy_condvar( Slapi_CondVar *cvar ) { -#ifdef LDAP_SLAPI if ( cvar != NULL ) { ldap_pvt_thread_cond_destroy( &cvar->cond ); slapi_ch_free( (void **)&cvar ); } -#endif } int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout ) { -#ifdef LDAP_SLAPI if ( cvar == NULL ) { return -1; } return ldap_pvt_thread_cond_wait( &cvar->cond, &cvar->mutex ); -#else - return -1; -#endif } int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all ) { -#ifdef LDAP_SLAPI if ( cvar == NULL ) { return -1; } @@ -3981,9 +3058,6 @@ int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all ) } return ldap_pvt_thread_cond_signal( &cvar->cond ); -#else - return -1; -#endif } int slapi_int_access_allowed( Operation *op, @@ -3993,28 +3067,34 @@ int slapi_int_access_allowed( Operation *op, slap_access_t access, AccessControlState *state ) { -#ifdef LDAP_SLAPI int rc, slap_access = 0; slapi_acl_callback_t *pGetPlugin, *tmpPlugin; + Slapi_PBlock *pb; - if ( op->o_pb == NULL ) { + pb = SLAPI_OPERATION_PBLOCK( op ); + if ( pb == NULL ) { /* internal operation */ return 1; } switch ( access ) { - case ACL_WRITE: - /* FIXME: handle ACL_WADD/ACL_WDEL */ - slap_access |= SLAPI_ACL_ADD | SLAPI_ACL_DELETE | SLAPI_ACL_WRITE; + case ACL_COMPARE: + slap_access |= SLAPI_ACL_COMPARE; + break; + case ACL_SEARCH: + slap_access |= SLAPI_ACL_SEARCH; break; case ACL_READ: slap_access |= SLAPI_ACL_READ; break; - case ACL_SEARCH: - slap_access |= SLAPI_ACL_SEARCH; + case ACL_WRITE: + slap_access |= SLAPI_ACL_WRITE; break; - case ACL_COMPARE: - slap_access = ACL_COMPARE; + case ACL_WDEL: + slap_access |= SLAPI_ACL_DELETE; + break; + case ACL_WADD: + slap_access |= SLAPI_ACL_ADD; break; default: break; @@ -4026,8 +3106,6 @@ int slapi_int_access_allowed( Operation *op, return 1; } - slapi_int_pblock_set_operation( op->o_pb, op ); - rc = 1; /* default allow policy */ for ( pGetPlugin = tmpPlugin; *pGetPlugin != NULL; pGetPlugin++ ) { @@ -4035,8 +3113,8 @@ int slapi_int_access_allowed( Operation *op, * 0 access denied * 1 access granted */ - rc = (*pGetPlugin)( op->o_pb, entry, desc->ad_cname.bv_val, - val, slap_access, (void *)state ); + rc = (*pGetPlugin)( pb, entry, desc->ad_cname.bv_val, + val, slap_access, (void *)state ); if ( rc == 0 ) { break; } @@ -4045,9 +3123,6 @@ int slapi_int_access_allowed( Operation *op, slapi_ch_free( (void **)&tmpPlugin ); return rc; -#else - return 1; -#endif /* LDAP_SLAPI */ } /* @@ -4055,7 +3130,6 @@ int slapi_int_access_allowed( Operation *op, */ int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv ) { -#ifdef LDAP_SLAPI LDAPRDN lrdn; LDAPAVA *ava; int rc; @@ -4083,14 +3157,10 @@ int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv ) ldap_rdnfree(lrdn); return 0; -#else - return -1; -#endif /* LDAP_SLAPI */ } char *slapi_dn_plus_rdn( const char *dn, const char *rdn ) { -#ifdef LDAP_SLAPI struct berval new_dn, parent_dn, newrdn; new_dn.bv_val = NULL; @@ -4104,35 +3174,32 @@ char *slapi_dn_plus_rdn( const char *dn, const char *rdn ) build_new_dn( &new_dn, &parent_dn, &newrdn, NULL ); return new_dn.bv_val; -#else - return NULL; -#endif /* LDAP_SLAPI */ } int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e ) { -#ifdef LDAP_SLAPI - Backend *be; + Backend *be_orig; const char *text; char textbuf[SLAP_TEXT_BUFLEN] = { '\0' }; size_t textlen = sizeof textbuf; - int rc; + int rc = LDAP_SUCCESS; - if ( slapi_pblock_get( pb, SLAPI_BACKEND, (void **)&be ) != 0 ) - return -1; + PBLOCK_ASSERT_OP( pb, 0 ); + + be_orig = pb->pb_op->o_bd; - rc = entry_schema_check( be, e, NULL, 0, - &text, textbuf, textlen ); + pb->pb_op->o_bd = select_backend( &e->e_nname, 0, 0 ); + if ( pb->pb_op->o_bd != NULL ) { + rc = entry_schema_check( pb->pb_op, e, NULL, 0, + &text, textbuf, textlen ); + } + pb->pb_op->o_bd = be_orig; return ( rc == LDAP_SUCCESS ) ? 0 : 1; -#else - return -1; -#endif /* LDAP_SLAPI */ } int slapi_entry_rdn_values_present( const Slapi_Entry *e ) { -#ifdef LDAP_SLAPI LDAPDN dn; int rc; int i = 0, match = 0; @@ -4158,14 +3225,10 @@ int slapi_entry_rdn_values_present( const Slapi_Entry *e ) ldap_dnfree( dn ); return ( i == match ); -#else - return 0; -#endif /* LDAP_SLAPI */ } int slapi_entry_add_rdn_values( Slapi_Entry *e ) { -#ifdef LDAP_SLAPI LDAPDN dn; int i, rc; @@ -4196,16 +3259,11 @@ int slapi_entry_add_rdn_values( Slapi_Entry *e ) ldap_dnfree( dn ); return LDAP_SUCCESS; -#else - return LDAP_OTHER; -#endif /* LDAP_SLAPI */ } const char *slapi_entry_get_uniqueid( const Slapi_Entry *e ) { -#ifdef LDAP_SLAPI Attribute *attr; - const char *uniqueid; attr = attr_find( e->e_attrs, slap_schema.si_ad_entryUUID ); if ( attr == NULL ) { @@ -4215,14 +3273,12 @@ const char *slapi_entry_get_uniqueid( const Slapi_Entry *e ) if ( attr->a_vals != NULL && attr->a_vals[0].bv_len != 0 ) { return slapi_value_get_string( &attr->a_vals[0] ); } -#endif /* LDAP_SLAPI */ return NULL; } void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid ) { -#ifdef LDAP_SLAPI struct berval bv; attr_delete ( &e->e_attrs, slap_schema.si_ad_entryUUID ); @@ -4230,12 +3286,10 @@ void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid ) bv.bv_val = uniqueid; bv.bv_len = strlen( uniqueid ); attr_merge_normalize_one( e, slap_schema.si_ad_entryUUID, &bv, NULL ); -#endif /* LDAP_SLAPI */ } LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared ) { -#ifdef LDAP_SLAPI LDAP *ld; char *url; size_t size; @@ -4261,29 +3315,186 @@ LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared ) slapi_ch_free_string( &url ); return ( rc == LDAP_SUCCESS ) ? ld : NULL; -#else - return NULL; -#endif /* LDAP_SLAPI */ } void slapi_ldap_unbind( LDAP *ld ) { -#ifdef LDAP_SLAPI - ldap_unbind( ld ); -#endif /* LDAP_SLAPI */ + ldap_unbind_ext_s( ld, NULL, NULL ); } int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ) { -#ifdef LDAP_SLAPI if ( be == NULL ) return LDAP_PARAM_ERROR; *flags = SLAP_DBFLAGS(be); return LDAP_SUCCESS; -#else - return -1; -#endif /* LDAP_SLAPI */ } +int +slapi_int_count_controls( LDAPControl **ctrls ) +{ + size_t i; + + if ( ctrls == NULL ) + return 0; + + for ( i = 0; ctrls[i] != NULL; i++ ) + ; + + return i; +} + +int +slapi_op_abandoned( Slapi_PBlock *pb ) +{ + if ( pb->pb_op == NULL ) + return 0; + + return ( pb->pb_op->o_abandon ); +} + +char * +slapi_op_type_to_string(unsigned long type) +{ + char *str; + + switch (type) { + case SLAPI_OPERATION_BIND: + str = "bind"; + break; + case SLAPI_OPERATION_UNBIND: + str = "unbind"; + break; + case SLAPI_OPERATION_SEARCH: + str = "search"; + break; + case SLAPI_OPERATION_MODIFY: + str = "modify"; + break; + case SLAPI_OPERATION_ADD: + str = "add"; + break; + case SLAPI_OPERATION_DELETE: + str = "delete"; + break; + case SLAPI_OPERATION_MODDN: + str = "modrdn"; + break; + case SLAPI_OPERATION_COMPARE: + str = "compare"; + break; + case SLAPI_OPERATION_ABANDON: + str = "abandon"; + break; + case SLAPI_OPERATION_EXTENDED: + str = "extended"; + break; + default: + str = "unknown operation type"; + break; + } + return str; +} + +unsigned long +slapi_op_get_type(Slapi_Operation * op) +{ + unsigned long type; + + switch ( op->o_tag ) { + case LDAP_REQ_BIND: + type = SLAPI_OPERATION_BIND; + break; + case LDAP_REQ_UNBIND: + type = SLAPI_OPERATION_UNBIND; + break; + case LDAP_REQ_SEARCH: + type = SLAPI_OPERATION_SEARCH; + break; + case LDAP_REQ_MODIFY: + type = SLAPI_OPERATION_MODIFY; + break; + case LDAP_REQ_ADD: + type = SLAPI_OPERATION_ADD; + break; + case LDAP_REQ_DELETE: + type = SLAPI_OPERATION_DELETE; + break; + case LDAP_REQ_MODRDN: + type = SLAPI_OPERATION_MODDN; + break; + case LDAP_REQ_COMPARE: + type = SLAPI_OPERATION_COMPARE; + break; + case LDAP_REQ_ABANDON: + type = SLAPI_OPERATION_ABANDON; + break; + case LDAP_REQ_EXTENDED: + type = SLAPI_OPERATION_EXTENDED; + break; + default: + type = SLAPI_OPERATION_NONE; + break; + } + return type; +} + +void slapi_be_set_readonly( Slapi_Backend *be, int readonly ) +{ + if ( be == NULL ) + return; + + if ( readonly ) + be->be_restrictops |= SLAP_RESTRICT_OP_WRITES; + else + be->be_restrictops &= ~(SLAP_RESTRICT_OP_WRITES); +} + +int slapi_be_get_readonly( Slapi_Backend *be ) +{ + if ( be == NULL ) + return 0; + + return ( (be->be_restrictops & SLAP_RESTRICT_OP_WRITES) == SLAP_RESTRICT_OP_WRITES ); +} + +const char *slapi_x_be_get_updatedn( Slapi_Backend *be ) +{ + if ( be == NULL ) + return NULL; + + return be->be_update_ndn.bv_val; +} + +Slapi_Backend *slapi_be_select( const Slapi_DN *sdn ) +{ + Slapi_Backend *be; + + slapi_sdn_get_ndn( sdn ); + + be = select_backend( (struct berval *)&sdn->ndn, 0, 0 ); + + return be; +} + +#if 0 +void +slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag) +{ +} + +void +slapi_operation_clear_flag(Slapi_Operation *op, unsigned long flag) +{ +} + +int +slapi_operation_is_flag_set(Slapi_Operation *op, unsigned long flag) +{ +} +#endif + +#endif /* LDAP_SLAPI */ + diff --git a/servers/slapd/starttls.c b/servers/slapd/starttls.c index e8170ad690..8864b03dd6 100644 --- a/servers/slapd/starttls.c +++ b/servers/slapd/starttls.c @@ -25,7 +25,6 @@ int starttls_extop ( Operation *op, SlapReply *rs ) { - void *ctx; int rc; if ( op->ore_reqdata != NULL ) { diff --git a/servers/slapd/str2filter.c b/servers/slapd/str2filter.c index b6aa778c6b..374ec60b2f 100644 --- a/servers/slapd/str2filter.c +++ b/servers/slapd/str2filter.c @@ -34,12 +34,6 @@ #include "slap.h" -#if 0 /* unused */ -static char *find_matching_paren( const char *s ); -#endif /* unused */ -static Filter *str2list( const char *str, long unsigned int ftype); -static Filter *str2simple( const char *str); -static int str2subvals( const char *val, Filter *f); Filter * str2filter_x( Operation *op, const char *str ) diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index f7efaf86fc..cba7f7e813 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -482,6 +482,8 @@ do_syncrep1( LDAP_STAILQ_REMOVE( &slap_sync_cookie, sc, sync_cookie, sc_next ); + /* ctxcsn wasn't parsed yet, do it now */ + slap_parse_sync_cookie( sc, op->o_tmpmemctx ); if ( BER_BVISNULL( &sc->ctxcsn ) ) { /* if cmdline cookie does not have ctxcsn */ /* component, set it to an initial value */ @@ -535,8 +537,8 @@ do_syncrep2( int syncstate; struct berval syncUUID = BER_BVNULL; - struct sync_cookie syncCookie = { 0 }; - struct sync_cookie syncCookie_req = { 0 }; + struct sync_cookie syncCookie = { BER_BVNULL }; + struct sync_cookie syncCookie_req = { BER_BVNULL }; struct berval cookie = BER_BVNULL; int rc, err, i; @@ -615,7 +617,7 @@ do_syncrep2( } if ( !BER_BVISNULL( &syncCookie.octet_str ) ) { - slap_parse_sync_cookie( &syncCookie ); + slap_parse_sync_cookie( &syncCookie, NULL ); } } if ( syncrepl_message_to_entry( si, op, msg, @@ -629,7 +631,7 @@ do_syncrep2( } ldap_controls_free( rctrls ); if ( modlist ) { - slap_mods_free( modlist ); + slap_mods_free( modlist, 1 ); } if ( rc_efree && entry ) { entry_free( entry ); @@ -660,7 +662,7 @@ do_syncrep2( } if ( !BER_BVISNULL( &syncCookie.octet_str ) ) { - slap_parse_sync_cookie( &syncCookie ); + slap_parse_sync_cookie( &syncCookie, NULL ); } } if ( ber_peek_tag( ber, &len ) == LDAP_TAG_REFRESHDELETES ) @@ -744,7 +746,7 @@ do_syncrep2( } if ( !BER_BVISNULL( &syncCookie.octet_str ) ) { - slap_parse_sync_cookie( &syncCookie ); + slap_parse_sync_cookie( &syncCookie, NULL ); } } if ( ber_peek_tag( ber, &len ) == @@ -771,7 +773,7 @@ do_syncrep2( } if ( !BER_BVISNULL( &syncCookie.octet_str ) ) { - slap_parse_sync_cookie( &syncCookie ); + slap_parse_sync_cookie( &syncCookie, NULL ); } } if ( ber_peek_tag( ber, &len ) == @@ -1022,7 +1024,7 @@ do_syncrepl( return NULL; } -int +static int syncrepl_message_to_entry( syncinfo_t *si, Operation *op, @@ -1193,7 +1195,7 @@ typedef struct dninfo { AttributeDescription **ads; } dninfo; -int +static int syncrepl_entry( syncinfo_t* si, Operation *op, @@ -1205,7 +1207,7 @@ syncrepl_entry( struct berval* syncCSN ) { Backend *be = op->o_bd; - slap_callback cb = { NULL }; + slap_callback cb = { NULL, NULL, NULL, NULL }; struct berval *syncuuid_bv = NULL; struct berval syncUUID_strrep = BER_BVNULL; struct berval uuid_bv = BER_BVNULL; @@ -1465,7 +1467,7 @@ retry_add:; op->o_tag = LDAP_REQ_MODIFY; - assert( *modlist ); + assert( *modlist != NULL ); /* Delete all the old attrs */ for ( i = 0; i < dni.attrs; i++ ) { @@ -1858,7 +1860,7 @@ syncrepl_add_glue( return; } -void +static void syncrepl_updateCookie( syncinfo_t *si, Operation *op, @@ -2072,7 +2074,7 @@ null_callback( return LDAP_SUCCESS; } -struct berval * +static struct berval * slap_uuidstr_from_normalized( struct berval* uuidstr, struct berval* normalized, @@ -2659,7 +2661,7 @@ syncrepl_unparse( syncinfo_t *si, struct berval *bv ) { struct berval bc; char buf[BUFSIZ*2], *ptr; - int i, len; + int i; bindconf_unparse( &si->si_bindconf, &bc ); ptr = buf; diff --git a/servers/slapd/value.c b/servers/slapd/value.c index ef5c8b571d..aab6b34bc8 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -312,7 +312,6 @@ ordered_value_sort( Attribute *a, int do_renumber ) int i, vals; int index = 0, noindex = 0, renumber = 0, gotnvals = 0; struct berval tmp; - char *ptr; if ( a->a_nvals && a->a_nvals != a->a_vals ) gotnvals = 1; @@ -386,6 +385,7 @@ ordered_value_sort( Attribute *a, int do_renumber ) if ( indexes[0] != 0 || indexes[vals-1] != vals-1 ) { renumber = 1; } + ch_free( indexes ); } else { renumber = 1; } diff --git a/servers/slapd/zn_malloc.c b/servers/slapd/zn_malloc.c index ff9a25bf5a..eb2f035de6 100644 --- a/servers/slapd/zn_malloc.c +++ b/servers/slapd/zn_malloc.c @@ -542,7 +542,7 @@ slap_zn_free(void *ptr, void *ctx) Debug(LDAP_DEBUG_ANY, "slap_zn_free: " "free object not found while bit is clear.\n", 0, 0, 0); - assert(zo); + assert(zo != NULL); } } else { @@ -604,7 +604,7 @@ slap_zn_free(void *ptr, void *ctx) Debug(LDAP_DEBUG_ANY, "slap_zn_free: " "free object not found while bit is clear.\n", 0, 0, 0 ); - assert( zo ); + assert(zo != NULL); } } else { diff --git a/servers/slurpd/ldap_op.c b/servers/slurpd/ldap_op.c index 16d719867a..b33a74a49a 100644 --- a/servers/slurpd/ldap_op.c +++ b/servers/slurpd/ldap_op.c @@ -321,7 +321,7 @@ op_ldap_modify( continue; } - assert( ldm ); + assert( ldm != NULL ); /* * We should have an attribute: value pair here. @@ -505,7 +505,7 @@ op_ldap_modrdn( } #endif /* LDAP_DEBUG */ - assert( newrdn ); + assert( newrdn != NULL ); /* Do the modrdn */ rc = ldap_rename2_s( ri->ri_ldp, re->re_dn, newrdn, newsup, drdnflag ); @@ -711,7 +711,7 @@ retry: } { /* set version 3 */ - int err, version = 3; + int err, version = LDAP_VERSION3; err = ldap_set_option(ri->ri_ldp, LDAP_OPT_PROTOCOL_VERSION, &version); diff --git a/servers/slurpd/re.c b/servers/slurpd/re.c index 05fd60743c..7a70948783 100644 --- a/servers/slurpd/re.c +++ b/servers/slurpd/re.c @@ -423,6 +423,7 @@ getchangetype( +#if 0 /* * Find the first line which is not a "replica:" line in buf. * Returns a pointer to the line. Returns NULL if there are @@ -448,6 +449,7 @@ skip_replica_lines( } } } +#endif /* 0 */ diff --git a/tests/data/acl.out.master b/tests/data/acl.out.master index 8b0134895e..db6c1fb015 100644 --- a/tests/data/acl.out.master +++ b/tests/data/acl.out.master @@ -21,18 +21,18 @@ facsimileTelephoneNumber: +1 313 555 4332 telephoneNumber: +1 313 555 0895 # Using ldapsearch to retrieve all the entries... -dn: ou=Add/Delete,dc=example,dc=com +dn: ou=Add & Delete,dc=example,dc=com objectClass: organizationalUnit -ou: Add/Delete +ou: Add & Delete -dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com objectClass: inetOrgPerson cn: Added by Bjorn (must succeed) sn: None description: this attribute value has been added __after__entry creation description: Bjorn will try to delete this attribute value (should fail) -dn: cn=Added by Bjorn (renamed by Jaj),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (renamed by Jaj),ou=Add & Delete,dc=example,dc=com objectClass: inetOrgPerson sn: None cn: Added by Bjorn (renamed by Jaj) diff --git a/tests/data/meta.out b/tests/data/meta.out index e44390989c..817440d020 100644 --- a/tests/data/meta.out +++ b/tests/data/meta.out @@ -427,7 +427,7 @@ pager: +1 313 555 2844 facsimileTelephoneNumber: +1 313 555 9700 telephoneNumber: +1 313 555 5331 -# refldap://:9010/cn=Somewhere,ou=Meta,dc=example,dc=com??sub +# refldap://localhost:9016/cn=Somewhere,ou=Meta,dc=example,dc=com??sub # searching base="o=Example,c=US"... dn: cn=Added Group,ou=Groups,o=Example,c=US @@ -890,7 +890,7 @@ pager: +1 313 555 2844 facsimileTelephoneNumber: +1 313 555 9700 telephoneNumber: +1 313 555 5331 -# refldap://:9010/cn=Somewhere,ou=Meta,dc=example,dc=com??sub +# refldap://localhost:9016/cn=Somewhere,ou=Meta,dc=example,dc=com??sub # base="o=Example,c=US"... dn: cn=Added Group,ou=Groups,o=Example,c=US @@ -1342,7 +1342,7 @@ dn: cn=Somewhere,ou=Meta,o=Example,c=US objectClass: referral objectClass: extensibleObject cn: Somewhere -ref: ldap://:9010 +ref: ldap://localhost:9016 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,o=Example,c=US objectClass: OpenLDAPperson @@ -1395,12 +1395,12 @@ seeAlso: cn=All Staff,ou=Groups,o=Example,c=US dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,o=Example,c=US seeAlso: cn=All Staff,ou=Groups,o=Example,c=US -# refldap://:9010/cn=Somewhere,ou=Meta,dc=example,dc=com??sub +# refldap://localhost:9016/cn=Somewhere,ou=Meta,dc=example,dc=com??sub # searching filter="(uid=example)" # attrs="uid" # base="o=Example,c=US"... -# refldap://:9010/cn=Somewhere,ou=Meta,dc=example,dc=com??sub +# refldap://localhost:9016/cn=Somewhere,ou=Meta,dc=example,dc=com??sub # searching filter="(member=cn=Another Added Group,ou=Groups,o=Example,c=US)" # attrs="member" @@ -1409,5 +1409,5 @@ dn: cn=Another Added Group,ou=Groups,o=Example,c=US member: cn=Added Group,ou=Groups,o=Example,c=US member: cn=Another Added Group,ou=Groups,o=Example,c=US -# refldap://:9010/cn=Somewhere,ou=Meta,dc=example,dc=com??sub +# refldap://localhost:9016/cn=Somewhere,ou=Meta,dc=example,dc=com??sub diff --git a/tests/data/metaconcurrency.out b/tests/data/metaconcurrency.out index ca8d796b8f..07fc3a6677 100644 --- a/tests/data/metaconcurrency.out +++ b/tests/data/metaconcurrency.out @@ -426,5 +426,5 @@ pager: +1 313 555 2844 facsimileTelephoneNumber: +1 313 555 9700 telephoneNumber: +1 313 555 5331 -# refldap://:9010/cn=Somewhere,ou=Meta,dc=example,dc=com??sub +# refldap://localhost:9016/cn=Somewhere,ou=Meta,dc=example,dc=com??sub diff --git a/tests/data/ppolicy.ldif b/tests/data/ppolicy.ldif index f20ca77ff5..578aa6107d 100644 --- a/tests/data/ppolicy.ldif +++ b/tests/data/ppolicy.ldif @@ -23,7 +23,7 @@ cn: Standard Policy pwdAttribute: 2.5.4.35 pwdLockoutDuration: 15 pwdInHistory: 6 -pwdCheckQuality: 1 +pwdCheckQuality: 2 pwdExpireWarning: 10 pwdMaxAge: 30 pwdMinLength: 5 diff --git a/tests/data/relay.out b/tests/data/relay.out index c88d78591d..ed7b8333c7 100644 --- a/tests/data/relay.out +++ b/tests/data/relay.out @@ -2052,7 +2052,7 @@ mail: auser@mail.alumni.example.com telephoneNumber: +49 1234-567-890 description: Just added in o=Beispiel,c=DE naming context -# refldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE??sub +# refldap://localhost:9012/ou=Referrals,o=Beispiel,c=DE??sub dn: cn=Added Group,ou=Groups,o=Example,c=US objectClass: groupOfNames @@ -2477,7 +2477,7 @@ mail: auser@mail.alumni.example.com telephoneNumber: +49 1234-567-890 description: Just added in o=Beispiel,c=DE naming context -# refldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE??sub +# refldap://localhost:9012/ou=Referrals,o=Beispiel,c=DE??sub dn: cn=Added Group,ou=Groups,o=Esempio,c=IT objectClass: groupOfUniqueNames @@ -2501,9 +2501,9 @@ objectClass: extensibleObject ou: Referrals description: Just added as ldap://localhost.localdomain:389/ou=Referrals,o=Bei spiel,c=DE -description: ...and modified as ldap://localhost:9010/ou=Referrals,o=Beispiel, +description: ...and modified as ldap://localhost:9012/ou=Referrals,o=Beispiel, c=DE -ref: ldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE +ref: ldap://localhost:9012/ou=Referrals,o=Beispiel,c=DE # base="o=Example,c=US"... dn: ou=Referrals,o=Example,c=US @@ -2512,9 +2512,9 @@ objectClass: extensibleObject ou: Referrals description: Just added as ldap://localhost.localdomain:389/ou=Referrals,o=Bei spiel,c=DE -description: ...and modified as ldap://localhost:9010/ou=Referrals,o=Beispiel, +description: ...and modified as ldap://localhost:9012/ou=Referrals,o=Beispiel, c=DE -ref: ldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE +ref: ldap://localhost:9012/ou=Referrals,o=Beispiel,c=DE # base="o=Esempio,c=IT"... dn: ou=Referrals,o=Esempio,c=IT @@ -2523,9 +2523,9 @@ objectClass: extensibleObject ou: Referrals description: Just added as ldap://localhost.localdomain:389/ou=Referrals,o=Bei spiel,c=DE -description: ...and modified as ldap://localhost:9010/ou=Referrals,o=Beispiel, +description: ...and modified as ldap://localhost:9012/ou=Referrals,o=Beispiel, c=DE -ref: ldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE +ref: ldap://localhost:9012/ou=Referrals,o=Beispiel,c=DE # searching filter="(seeAlso=cn=all staff,ou=Groups,o=Example,c=US)" # attrs="seeAlso" @@ -2564,7 +2564,7 @@ seeAlso: cn=Ursula Hampster,ou=Alumni Association,ou=People,o=Example,c=US dn: cn=Added User,ou=Alumni Association,ou=People,o=Example,c=US seeAlso: cn=All Staff,ou=Groups,o=Example,c=US -# refldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE??sub +# refldap://localhost:9012/ou=Referrals,o=Beispiel,c=DE??sub # searching filter="(uid=example)" # attrs="uid" @@ -2572,12 +2572,12 @@ seeAlso: cn=All Staff,ou=Groups,o=Example,c=US dn: o=Example,c=US uid: example -# refldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE??sub +# refldap://localhost:9012/ou=Referrals,o=Beispiel,c=DE??sub # searching filter="(member=cn=Another Added Group,ou=Groups,o=Example,c=US)" # attrs="member" # base="o=Example,c=US"... -# refldap://localhost:9010/ou=Referrals,o=Beispiel,c=DE??sub +# refldap://localhost:9012/ou=Referrals,o=Beispiel,c=DE??sub dn: cn=Another Added Group,ou=Groups,o=Example,c=US member: cn=Added Group,ou=Groups,o=Example,c=US diff --git a/tests/data/retcode.conf b/tests/data/retcode.conf new file mode 100644 index 0000000000..7a433db11e --- /dev/null +++ b/tests/data/retcode.conf @@ -0,0 +1,115 @@ +# slapo-retcode standard track response codes configuration example +# $Header$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2005 The OpenLDAP Foundation. +## 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 +## . +# +# From "ldap.h", revised as per + +retcode-item "cn=success" 0x00 + +retcode-item "cn=success w/ delay" 0x00 sleeptime=2 + +retcode-item "cn=operationsError" 0x01 +retcode-item "cn=protocolError" 0x02 +retcode-item "cn=timeLimitExceeded" 0x03 op=search +retcode-item "cn=sizeLimitExceeded" 0x04 op=search +retcode-item "cn=compareFalse" 0x05 op=compare +retcode-item "cn=compareTrue" 0x06 op=compare +retcode-item "cn=authMethodNotSupported" 0x07 +retcode-item "cn=strongAuthNotSupported" 0x07 text="same as authMethodNotSupported" +retcode-item "cn=strongAuthRequired" 0x08 +retcode-item "cn=strongerAuthRequired" 0x08 text="same as strongAuthRequired" +#retcode-item "cn=partialResults" 0x09 "LDAPv2+ (not LDAPv3)" + +retcode-item "cn=referral" 0x0a text="LDAPv3" +retcode-item "cn=adminLimitExceeded" 0x0b text="LDAPv3" +retcode-item "cn=unavailableCriticalExtension" 0x0c text="LDAPv3" +retcode-item "cn=confidentialityRequired" 0x0d text="LDAPv3" +retcode-item "cn=saslBindInProgress" 0x0e text="LDAPv3" + +# LDAP_ATTR_ERROR(n) LDAP_RANGE((n),0x10,0x15) /* 16-21 */ + +retcode-item "cn=noSuchAttribute" 0x10 +retcode-item "cn=undefinedAttributeType" 0x11 +retcode-item "cn=inappropriateMatching" 0x12 +retcode-item "cn=constraintViolation" 0x13 +retcode-item "cn=attributeOrValueExists" 0x14 +retcode-item "cn=invalidAttributeSyntax" 0x15 + +# LDAP_NAME_ERROR(n) LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */ + +retcode-item "cn=noSuchObject" 0x20 +retcode-item "cn=aliasProblem" 0x21 +retcode-item "cn=invalidDNSyntax" 0x22 +#retcode-item "cn=isLeaf" 0x23 text="not LDAPv3" +retcode-item "cn=aliasDereferencingProblem" 0x24 + +# LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x2F,0x32) /* 47-50 */ + +retcode-item "cn=proxyAuthzFailure" 0x2F text="LDAPv3 proxy authorization" +retcode-item "cn=inappropriateAuthentication" 0x30 +retcode-item "cn=invalidCredentials" 0x31 +retcode-item "cn=insufficientAccessRights" 0x32 + +# LDAP_SERVICE_ERROR(n) LDAP_RANGE((n),0x33,0x36) /* 51-54 */ + +retcode-item "cn=busy" 0x33 +retcode-item "cn=unavailable" 0x34 +retcode-item "cn=unwillingToPerform" 0x35 +retcode-item "cn=loopDetect" 0x36 + +# LDAP_UPDATE_ERROR(n) LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */ + +retcode-item "cn=namingViolation" 0x40 +retcode-item "cn=objectClassViolation" 0x41 +retcode-item "cn=notAllowedOnNonleaf" 0x42 +retcode-item "cn=notAllowedOnRDN" 0x43 +retcode-item "cn=entryAlreadyExists" 0x44 +retcode-item "cn=objectClassModsProhibited" 0x45 +retcode-item "cn=resultsTooLarge" 0x46 text="CLDAP" +retcode-item "cn=affectsMultipleDSAs" 0x47 text="LDAPv3" + +retcode-item "cn=other" 0x50 + +# /* LCUP operation codes (113-117) - not implemented */ +retcode-item "cn=cupResourcesExhausted" 0x71 +retcode-item "cn=cupSecurityViolation" 0x72 +retcode-item "cn=cupInvalidData" 0x73 +retcode-item "cn=cupUnsupportedScheme" 0x74 +retcode-item "cn=cupReloadRequired" 0x75 + +# /* Cancel operation codes (118-121) */ +retcode-item "cn=cancelled" 0x76 +retcode-item "cn=noSuchOperation" 0x77 +retcode-item "cn=tooLate" 0x78 +retcode-item "cn=cannotCancel" 0x79 + + +# /* Experimental result codes */ +# LDAP_E_ERROR(n) LDAP_RANGE((n),0x1000,0x3FFF) /* experimental */ +# LDAP_X_ERROR(n) LDAP_RANGE((n),0x4000,0xFFFF) /* private use */ + +# /* for the LDAP Sync operation */ +retcode-item "cn=syncRefreshRequired" 0x4100 + +# /* for the LDAP No-Op control */ +retcode-item "cn=noOperation" 0x410e + +# /* for the Assertion control */ +retcode-item "cn=assertionFailed" 0x410f + +# /* for the Chaining Behavior control (consecutive result codes requested; +# * see ) */ +retcode-item "cn=noReferralsFound" 0x4110 +retcode-item "cn=cannotChain" 0x4111 + diff --git a/tests/data/slapd-acl.conf b/tests/data/slapd-acl.conf index c56586bff1..f4c09dbf63 100644 --- a/tests/data/slapd-acl.conf +++ b/tests/data/slapd-acl.conf @@ -47,10 +47,12 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub #access to attr=objectclass dn.subtree="dc=example,dc=com" access to attr=objectclass @@ -95,7 +97,7 @@ access to dn.exact="cn=Alumni Assoc Staff,ou=Groups,dc=example,dc=com" access to filter="(name=X*Y*Z)" by * continue -access to dn.subtree="ou=Add/Delete,dc=example,dc=com" +access to dn.subtree="ou=Add & Delete,dc=example,dc=com" by dn.exact="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com" add by dn.exact="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com" delete by dn.exact="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com" write @@ -103,4 +105,4 @@ access to dn.subtree="ou=Add/Delete,dc=example,dc=com" # fall into global ACLs -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-cache-master.conf b/tests/data/slapd-cache-master.conf index 87476f20dd..0a0c6b5d1d 100644 --- a/tests/data/slapd-cache-master.conf +++ b/tests/data/slapd-cache-master.conf @@ -44,4 +44,4 @@ rootpw secret #ldbm#index objectClass eq #ldbm#index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-chain1.conf b/tests/data/slapd-chain1.conf index 786a87c91f..8a2a9f0e72 100644 --- a/tests/data/slapd-chain1.conf +++ b/tests/data/slapd-chain1.conf @@ -51,7 +51,11 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-chain2.conf b/tests/data/slapd-chain2.conf index 79d3411180..d37dc29422 100644 --- a/tests/data/slapd-chain2.conf +++ b/tests/data/slapd-chain2.conf @@ -44,8 +44,12 @@ suffix "dc=example,dc=com" directory ./testrun/db.2.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub # # uses the chain overlay as database specific; @@ -55,4 +59,4 @@ chain-uri @URI1@ chain-acl-authcDN "cn=Manager,dc=example,dc=com" chain-acl-passwd secret -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-component.conf b/tests/data/slapd-component.conf index ce988c8157..6be3f59a0f 100644 --- a/tests/data/slapd-component.conf +++ b/tests/data/slapd-component.conf @@ -42,7 +42,8 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq #bdb#index objectClass eq +#hdb#index objectClass eq +#ldbm#index objectClass eq -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-dn.conf b/tests/data/slapd-dn.conf index eb429ae8cb..b58fe4aa38 100644 --- a/tests/data/slapd-dn.conf +++ b/tests/data/slapd-dn.conf @@ -44,4 +44,4 @@ rootpw secret #ldbm#index objectClass eq #ldbm#index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-glue-ldap.conf b/tests/data/slapd-glue-ldap.conf new file mode 100644 index 0000000000..41220ab8d9 --- /dev/null +++ b/tests/data/slapd-glue-ldap.conf @@ -0,0 +1,76 @@ +# master slapd config -- for testing +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2005 The OpenLDAP Foundation. +## 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 +## . + +include ./schema/core.schema +include ./schema/cosine.schema +include ./schema/inetorgperson.schema +include ./schema/openldap.schema +include ./schema/nis.schema +include ./schema/ppolicy.schema +pidfile ./test-db/slapd.m.pid +argsfile ./test-db/slapd.m.args + +#mod#modulepath ../servers/slapd/back-@BACKEND@/ +#mod#moduleload back_@BACKEND@.la +#relaymod#modulepath ../servers/slapd/back-relay/ +#relaymod#moduleload back_relay.la +#ldapmod#modulepath ../servers/slapd/back-ldap/ +#ldapmod#moduleload back_ldap.la +#metamod#modulepath ../servers/slapd/back-meta/ +#metamod#moduleload back_meta.la +#monitormod#modulepath ../servers/slapd/back-monitor/ +#monitormod#moduleload back_monitor.la +#rwmmod#modulepath ../servers/slapd/overlays/ +#rwmmod#moduleload rwm.la + +overlay rwm +rwm-suffixmassage "o=Example,c=US" "dc=example,dc=com" + +####################################################################### +# database definitions +####################################################################### + +# remote +database ldap +suffix "ou=Meta,dc=example,dc=com" +uri "@URI2@" +rootdn "cn=Manager,dc=example,dc=com" +chase-referrals no +idassert-bind bindmethod=simple + binddn="cn=Manager,ou=Meta,dc=example,dc=com" + credentials="secret" + mode=none + flags=non-prescriptive +idassert-authzfrom "dn.exact:cn=Manager,dc=example,dc=com" + +# local +database ldap +suffix "dc=example,dc=com" +uri "@URI1@" +rootdn "cn=Manager,dc=example,dc=com" +rootpw secret +chase-referrals no +idassert-bind bindmethod=simple + binddn="cn=Manager,dc=example,dc=com" + credentials="secret" + mode=none + flags=non-prescriptive +idassert-authzfrom "dn.exact:cn=Manager,dc=example,dc=com" + + +overlay glue +glue-sub "ou=Meta,dc=example,dc=com" + +#monitor#database monitor diff --git a/tests/data/slapd-glue-syncrepl1.conf b/tests/data/slapd-glue-syncrepl1.conf index e088dcbef0..613d90d6c8 100644 --- a/tests/data/slapd-glue-syncrepl1.conf +++ b/tests/data/slapd-glue-syncrepl1.conf @@ -36,30 +36,38 @@ database @BACKEND@ suffix "ou=Information Technology Division,ou=People,dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager 1,dc=example,dc=com" +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#bdb#index entryUUID,entryCSN pres +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany +#hdb#index entryUUID,entryCSN pres #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany -#bdb#index entryUUID,entryCSN pres overlay syncprov database @BACKEND@ suffix "ou=Groups,dc=example,dc=com" directory ./testrun/db.1.b rootdn "cn=Manager 1,dc=example,dc=com" +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#bdb#index entryUUID,entryCSN pres +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany +#hdb#index entryUUID,entryCSN pres #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany -#bdb#index entryUUID,entryCSN pres syncrepl rid=1 provider=@URI2@ binddn="cn=Manager 2,dc=example,dc=com" @@ -81,14 +89,17 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.c rootdn "cn=Manager 1,dc=example,dc=com" rootpw secret +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany #overlay syncprov overlay glue glue-sub "ou=Information Technology Division,ou=People,dc=example,dc=com" diff --git a/tests/data/slapd-glue-syncrepl2.conf b/tests/data/slapd-glue-syncrepl2.conf index c3d45bd7f9..11042ae2a0 100644 --- a/tests/data/slapd-glue-syncrepl2.conf +++ b/tests/data/slapd-glue-syncrepl2.conf @@ -36,15 +36,19 @@ database @BACKEND@ suffix "ou=Information Technology Division,ou=People,dc=example,dc=com" directory ./testrun/db.2.a rootdn "cn=Manager 2,dc=example,dc=com" +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#bdb#index entryUUID,entryCSN pres +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany +#hdb#index entryUUID,entryCSN pres #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany -#bdb#index entryUUID,entryCSN pres syncrepl rid=2 provider=@URI1@ binddn="cn=Manager 1,dc=example,dc=com" @@ -64,15 +68,19 @@ database @BACKEND@ suffix "ou=Groups,dc=example,dc=com" directory ./testrun/db.2.b rootdn "cn=Manager 2,dc=example,dc=com" +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#bdb#index entryUUID,entryCSN pres +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany +#hdb#index entryUUID,entryCSN pres #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany -#bdb#index entryUUID,entryCSN pres overlay syncprov @@ -81,14 +89,17 @@ suffix "dc=example,dc=com" directory ./testrun/db.2.c rootdn "cn=Manager 2,dc=example,dc=com" rootpw secret +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany #overlay syncprov overlay glue glue-sub "ou=Information Technology Division,ou=People,dc=example,dc=com" diff --git a/tests/data/slapd-glue.conf b/tests/data/slapd-glue.conf index fe529c6d5e..69e9178c56 100644 --- a/tests/data/slapd-glue.conf +++ b/tests/data/slapd-glue.conf @@ -36,43 +36,52 @@ database @BACKEND@ suffix "ou=Information Technology Division,ou=People,dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager, dc=example,dc=com" +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany database @BACKEND@ suffix "ou=Groups,dc=example,dc=com" directory ./testrun/db.1.b rootdn "cn=Manager, dc=example,dc=com" +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany database @BACKEND@ suffix "dc=example,dc=com" directory ./testrun/db.1.c rootdn "cn=Manager, dc=example,dc=com" rootpw secret +#bdb#index objectclass eq +#bdb#index uid pres,eq,sub +#bdb#index cn,sn pres,eq,sub,subany +#hdb#index objectclass eq +#hdb#index uid pres,eq,sub +#hdb#index cn,sn pres,eq,sub,subany #ldbm#index objectclass eq #ldbm#index uid pres,eq,sub #ldbm#index cn,sn pres,eq,sub,subany #ldbm#dbnosync #ldbm#dbnolocking -#bdb#index objectclass eq -#bdb#index uid pres,eq,sub -#bdb#index cn,sn pres,eq,sub,subany overlay glue -glue-sub "ou=Information Technology Division,ou=People,dc=example,dc=com" -glue-sub "ou=Groups,dc=example,dc=com" +glue-sub "ou=Information Technology Division,ou=People,dc=example,dc=com" +glue-sub "ou=Groups,dc=example,dc=com" -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-idassert.conf b/tests/data/slapd-idassert.conf index 6ade32efd8..b9ecdc6535 100644 --- a/tests/data/slapd-idassert.conf +++ b/tests/data/slapd-idassert.conf @@ -63,8 +63,12 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub access to dn.exact="cn=Proxy,ou=Admin,dc=example,dc=com" attr=authzTo @@ -77,8 +81,12 @@ suffix "dc=example,dc=it" directory ./testrun/db.2.a rootdn "cn=Manager,dc=example,dc=it" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub database ldap suffix "o=Example,c=US" @@ -119,4 +127,4 @@ access to * by dn.exact="cn=Sandbox,ou=Admin,dc=example,dc=com" search by * none -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-ldapglue.conf b/tests/data/slapd-ldapglue.conf index a07599d676..e235aed4d8 100644 --- a/tests/data/slapd-ldapglue.conf +++ b/tests/data/slapd-ldapglue.conf @@ -55,7 +55,7 @@ suffix "ou=People,dc=example,dc=com" uri "@URI2@" # FIXME: doesn't work with authz=native #sasl#idassert-bind bindmethod=sasl authcid=proxy credentials=proxy @SASL_MECH@ mode=self -#nosasl#idassert-bind bindmethod=simple binddn"uid=proxy,ou=People,dc=example,dc=com" credentials=proxy mode=self +#nosasl#idassert-bind bindmethod=simple binddn="uid=proxy,ou=People,dc=example,dc=com" credentials=proxy mode=self # groups branch database ldap @@ -71,10 +71,14 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub -overlay glue -glue-sub ou=groups,dc=example,dc=com -glue-sub ou=people,dc=example,dc=com +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub +overlay glue +glue-sub "ou=groups,dc=example,dc=com" +glue-sub "ou=people,dc=example,dc=com" -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-ldapgluegroups.conf b/tests/data/slapd-ldapgluegroups.conf index ca0682ea89..a5f1f9f430 100644 --- a/tests/data/slapd-ldapgluegroups.conf +++ b/tests/data/slapd-ldapgluegroups.conf @@ -54,7 +54,11 @@ suffix "ou=Groups,dc=example,dc=com" directory ./testrun/db.3.a rootdn "cn=Manager,ou=Groups,dc=example,dc=com" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-ldapgluepeople.conf b/tests/data/slapd-ldapgluepeople.conf index 0f3f4fa6ad..a5a6d28ca8 100644 --- a/tests/data/slapd-ldapgluepeople.conf +++ b/tests/data/slapd-ldapgluepeople.conf @@ -55,7 +55,11 @@ suffix "ou=People,dc=example,dc=com" directory ./testrun/db.2.a rootdn "cn=Manager,ou=People,dc=example,dc=com" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-limits.conf b/tests/data/slapd-limits.conf index 6b51b12693..a38719392f 100644 --- a/tests/data/slapd-limits.conf +++ b/tests/data/slapd-limits.conf @@ -37,12 +37,12 @@ directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret # Need quality indices on "uid" to check "unchecked" limits... -#ldbm#index objectClass eq -#ldbm#index uid eq #bdb#index objectClass eq #bdb#index uid eq #hdb#index objectClass eq #hdb#index uid eq +#ldbm#index objectClass eq +#ldbm#index uid eq # Need extra limits for pagedResults on backends that support it... #bdb#limits dn.exact="cn=Unlimited User,ou=Paged Results Users,dc=example,dc=com" size=4 size.pr=unlimited @@ -67,4 +67,4 @@ limits dn.subtree="ou=Admin,dc=example,dc=com" size.soft=3 limits users size.soft=2 limits anonymous size.soft=1 -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-master.conf b/tests/data/slapd-master.conf index 2f5828ef66..f10ca6ff72 100644 --- a/tests/data/slapd-master.conf +++ b/tests/data/slapd-master.conf @@ -39,7 +39,8 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq #bdb#index objectClass eq +#hdb#index objectClass eq +#ldbm#index objectClass eq -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-meta.conf b/tests/data/slapd-meta.conf index 1eefd7cbd4..b451216aa7 100644 --- a/tests/data/slapd-meta.conf +++ b/tests/data/slapd-meta.conf @@ -44,7 +44,7 @@ suffix "o=Example,c=US" rootdn "cn=Manager,o=Example,c=US" rootpw secret chase-referrals no -#nretries forever +nretries forever #nretries 1000 # local diff --git a/tests/data/slapd-meta2.conf b/tests/data/slapd-meta2.conf index dc65690a0c..e4487a4a0e 100644 --- a/tests/data/slapd-meta2.conf +++ b/tests/data/slapd-meta2.conf @@ -45,6 +45,7 @@ directory ./testrun/db.2.a rootdn "cn=Manager,ou=Meta,dc=example,dc=com" rootpw secret #bdb#index objectClass eq +#hdb#index objectClass eq #ldbm#index objectClass eq #monitor#database monitor diff --git a/tests/data/slapd-ppolicy.conf b/tests/data/slapd-ppolicy.conf index f58e536ff5..bcfd5985dd 100644 --- a/tests/data/slapd-ppolicy.conf +++ b/tests/data/slapd-ppolicy.conf @@ -53,4 +53,4 @@ access to * by self write by * read -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-proxycache.conf b/tests/data/slapd-proxycache.conf index 1fac77c7d1..f739315e06 100644 --- a/tests/data/slapd-proxycache.conf +++ b/tests/data/slapd-proxycache.conf @@ -53,7 +53,7 @@ proxytemplate (mail=) 0 @CACHETTL@ #bdb#cachesize 20 #hdb#cachesize 20 #ldbm#cachesize 20 -directory ./testrun/db.2.a +directory ./testrun/db.2.a #bdb#index objectClass eq #bdb#index cn,sn,uid,mail pres,eq,sub #hdb#index objectClass eq @@ -61,4 +61,4 @@ directory ./testrun/db.2.a #ldbm#index objectClass eq #ldbm#index cn,sn,uid,mail pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-pw.conf b/tests/data/slapd-pw.conf index e03f205d17..b86c2281e1 100644 --- a/tests/data/slapd-pw.conf +++ b/tests/data/slapd-pw.conf @@ -57,4 +57,4 @@ access to * by self write by * read -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-ref-slave.conf b/tests/data/slapd-ref-slave.conf index c36847bf48..bdec8ae22e 100644 --- a/tests/data/slapd-ref-slave.conf +++ b/tests/data/slapd-ref-slave.conf @@ -42,9 +42,11 @@ suffix "o=University of Mich,c=US" directory ./testrun/db.2.a rootdn "cn=Manager,o=University of Mich,c=US" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-referrals.conf b/tests/data/slapd-referrals.conf index 3de976ff02..e3431ce342 100644 --- a/tests/data/slapd-referrals.conf +++ b/tests/data/slapd-referrals.conf @@ -36,7 +36,8 @@ suffix "c=us" directory ./testrun/db.1.a rootdn "cn=Manager,c=us" rootpw secret -#ldbm#index objectClass eq #bdb#index objectClass eq +#hdb#index objectClass eq +#ldbm#index objectClass eq -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-refint.conf b/tests/data/slapd-refint.conf index 3d80502799..54ff0a7ea3 100644 --- a/tests/data/slapd-refint.conf +++ b/tests/data/slapd-refint.conf @@ -39,10 +39,14 @@ suffix "o=refint" directory ./testrun/db.1.a rootdn "cn=Manager,o=refint" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub overlay refint refint_attributes manager secretary member -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-relay.conf b/tests/data/slapd-relay.conf index 3948c10966..f9ef67d7bf 100644 --- a/tests/data/slapd-relay.conf +++ b/tests/data/slapd-relay.conf @@ -44,7 +44,9 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -index objectClass eq +#bdb#index objectClass eq +#hdb#index objectClass eq +#ldbm#index objectClass eq database @RELAY@ suffix "o=Example,c=US" @@ -93,4 +95,4 @@ suffix "o=Beispiel,c=DE" #relay-meta#uri "@URI1@o=Beispiel,c=DE" #relay-meta#suffixmassage "o=Beispiel,c=DE" "dc=example,dc=com" -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-repl-master.conf b/tests/data/slapd-repl-master.conf index af4580d1f6..ff50863760 100644 --- a/tests/data/slapd-repl-master.conf +++ b/tests/data/slapd-repl-master.conf @@ -38,10 +38,12 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub replogfile ./testrun/slapd.1.replog @@ -50,4 +52,4 @@ replica host=localhost:@PORT2@ bindmethod=simple credentials=secret -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-repl-slave.conf b/tests/data/slapd-repl-slave.conf index 2de1bf49f2..b64c40be15 100644 --- a/tests/data/slapd-repl-slave.conf +++ b/tests/data/slapd-repl-slave.conf @@ -49,9 +49,11 @@ rootdn "cn=Replica,dc=example,dc=com" rootpw secret updatedn "cn=Replica,dc=example,dc=com" updateref @URI1@ -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub #monitor#database monitor diff --git a/tests/data/slapd-retcode.conf b/tests/data/slapd-retcode.conf new file mode 100644 index 0000000000..a83e88d317 --- /dev/null +++ b/tests/data/slapd-retcode.conf @@ -0,0 +1,54 @@ +# stand-alone slapd config -- for testing (with indexing) +# $Header$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2005 The OpenLDAP Foundation. +## 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 +## . + +include ./schema/core.schema +include ./schema/cosine.schema +include ./schema/inetorgperson.schema +include ./schema/openldap.schema +include ./schema/nis.schema +include ./testdata/test.schema + +# +pidfile ./testrun/slapd.1.pid +argsfile ./testrun/slapd.1.args + +#mod#modulepath ../servers/slapd/back-@BACKEND@/ +#mod#moduleload back_@BACKEND@.la +#monitormod#modulepath ../servers/slapd/back-monitor/ +#monitormod#moduleload back_monitor.la +#retcodemod#modulepath ../servers/slapd/overlays/ +#retcodemod#moduleload retcode.la + +####################################################################### +# database definitions +####################################################################### + +database @BACKEND@ +suffix "dc=example,dc=com" +directory ./testrun/db.1.a +rootdn "cn=Manager,dc=example,dc=com" +rootpw secret +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub + +overlay retcode +retcode-parent "ou=RetCodes,dc=example,dc=com" +include testdata/retcode.conf + +#monitor#database monitor diff --git a/tests/data/slapd-schema.conf b/tests/data/slapd-schema.conf index 5368b8da0d..3d41d0cc35 100644 --- a/tests/data/slapd-schema.conf +++ b/tests/data/slapd-schema.conf @@ -25,6 +25,7 @@ include ./schema/misc.schema include ./schema/nis.schema include ./schema/openldap.schema # +include ./schema/duaconf.schema include ./schema/dyngroup.schema include ./schema/ppolicy.schema @@ -47,12 +48,13 @@ rootdse ./testdata/rootdse.ldif database @BACKEND@ suffix "o=OpenLDAP Project,l=Internet" directory ./testrun/db.1.a -#ldbm#index objectClass eq #bdb#index objectClass eq +#hdb#index objectClass eq +#ldbm#index objectClass eq #database @BACKEND@ #suffix "dc=example,dc=com" #directory ./testrun/db.1.b #index objectClass eq -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-syncrepl-master.conf b/tests/data/slapd-syncrepl-master.conf index b4e93e47f0..ecbf760e8c 100644 --- a/tests/data/slapd-syncrepl-master.conf +++ b/tests/data/slapd-syncrepl-master.conf @@ -39,13 +39,16 @@ suffix "dc=example,dc=com" directory ./testrun/db.1.a rootdn "cn=Manager,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub #bdb#index entryUUID,entryCSN eq +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#hdb#index entryUUID,entryCSN eq +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub -overlay syncprov +overlay syncprov #syncprov-sessionlog 100 -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-syncrepl-slave-persist1.conf b/tests/data/slapd-syncrepl-slave-persist1.conf index c930f3c1c9..9caae200af 100644 --- a/tests/data/slapd-syncrepl-slave-persist1.conf +++ b/tests/data/slapd-syncrepl-slave-persist1.conf @@ -48,25 +48,27 @@ suffix "dc=example,dc=com" directory ./testrun/db.4.a rootdn "cn=Replica,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub # Don't change syncrepl spec yet -syncrepl rid=1 - provider=@URI1@ - binddn="cn=Manager,dc=example,dc=com" - bindmethod=simple - credentials=secret - searchbase="dc=example,dc=com" - filter="(objectClass=*)" - attrs="*,+" - schemachecking=off - scope=sub - type=refreshAndPersist +syncrepl rid=1 + provider=@URI1@ + binddn="cn=Manager,dc=example,dc=com" + bindmethod=simple + credentials=secret + searchbase="dc=example,dc=com" + filter="(objectClass=*)" + attrs="*,+" + schemachecking=off + scope=sub + type=refreshAndPersist updateref @URI1@ -overlay syncprov +overlay syncprov -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-syncrepl-slave-persist2.conf b/tests/data/slapd-syncrepl-slave-persist2.conf index 1f3f47c935..b49154fa73 100644 --- a/tests/data/slapd-syncrepl-slave-persist2.conf +++ b/tests/data/slapd-syncrepl-slave-persist2.conf @@ -25,23 +25,26 @@ suffix "dc=example,dc=com" directory ./testrun/db.5.a rootdn "cn=Replica,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub #bdb#index entryUUID,entryCSN eq +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#hdb#index entryUUID,entryCSN eq +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub # Don't change syncrepl spec yet -syncrepl rid=1 - provider=@URI4@ - binddn="cn=Replica,dc=example,dc=com" - bindmethod=simple - credentials=secret - searchbase="dc=example,dc=com" - filter="(objectClass=*)" - attrs="*" - schemachecking=off - scope=sub - type=refreshAndPersist +syncrepl rid=1 + provider=@URI4@ + binddn="cn=Replica,dc=example,dc=com" + bindmethod=simple + credentials=secret + searchbase="dc=example,dc=com" + filter="(objectClass=*)" + attrs="*" + schemachecking=off + scope=sub + type=refreshAndPersist -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-syncrepl-slave-persist3.conf b/tests/data/slapd-syncrepl-slave-persist3.conf index cb4576cc24..e0d6a63a09 100644 --- a/tests/data/slapd-syncrepl-slave-persist3.conf +++ b/tests/data/slapd-syncrepl-slave-persist3.conf @@ -37,23 +37,26 @@ suffix "dc=example,dc=com" directory ./testrun/db.6.a rootdn "cn=Replica,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub #bdb#index entryUUID,entryCSN eq +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#hdb#index entryUUID,entryCSN eq +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub # Don't change syncrepl spec yet -syncrepl rid=1 - provider=@URI1@ - binddn="cn=Manager,dc=example,dc=com" - bindmethod=simple - credentials=secret - searchbase="dc=example,dc=com" - filter="(objectClass=*)" - attrs="*" - schemachecking=off - scope=sub - type=refreshAndPersist +syncrepl rid=1 + provider=@URI1@ + binddn="cn=Manager,dc=example,dc=com" + bindmethod=simple + credentials=secret + searchbase="dc=example,dc=com" + filter="(objectClass=*)" + attrs="*" + schemachecking=off + scope=sub + type=refreshAndPersist -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-syncrepl-slave-refresh1.conf b/tests/data/slapd-syncrepl-slave-refresh1.conf index ddf424dfb3..35390ee6c5 100644 --- a/tests/data/slapd-syncrepl-slave-refresh1.conf +++ b/tests/data/slapd-syncrepl-slave-refresh1.conf @@ -39,31 +39,32 @@ suffix "dc=example,dc=com" directory ./testrun/db.2.a rootdn "cn=Replica,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub -#ldbm#index entryUUID eq #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub #bdb#index entryUUID,entryCSN eq +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#hdb#index entryUUID,entryCSN eq +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub +#ldbm#index entryUUID eq # Don't change syncrepl spec yet -syncrepl rid=1 - provider=@URI1@ - binddn="cn=Manager,dc=example,dc=com" - bindmethod=simple - credentials=secret - searchbase="dc=example,dc=com" - filter="(objectClass=*)" - attrs="*" - schemachecking=off - scope=sub - type=refreshOnly - interval=00:00:00:10 +syncrepl rid=1 + provider=@URI1@ + binddn="cn=Manager,dc=example,dc=com" + bindmethod=simple + credentials=secret + searchbase="dc=example,dc=com" + filter="(objectClass=*)" + attrs="*" + schemachecking=off + scope=sub + type=refreshOnly + interval=00:00:00:10 updateref @URI1@ -overlay syncprov +overlay syncprov syncprov-sessionlog 100 - - #monitor#database monitor diff --git a/tests/data/slapd-syncrepl-slave-refresh2.conf b/tests/data/slapd-syncrepl-slave-refresh2.conf index 780d2fde9a..ee3358f597 100644 --- a/tests/data/slapd-syncrepl-slave-refresh2.conf +++ b/tests/data/slapd-syncrepl-slave-refresh2.conf @@ -37,25 +37,28 @@ suffix "dc=example,dc=com" directory ./testrun/db.3.a rootdn "cn=Replica,dc=example,dc=com" rootpw secret -#ldbm#index objectClass eq -#ldbm#index cn,sn,uid pres,eq,sub -#ldbm#index entryUUID eq #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub #bdb#index entryUUID,entryCSN eq +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#hdb#index entryUUID,entryCSN eq +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub +#ldbm#index entryUUID eq # Don't change syncrepl spec yet -syncrepl rid=1 - provider=@URI2@ - binddn="cn=Replica,dc=example,dc=com" - bindmethod=simple - credentials=secret - searchbase="dc=example,dc=com" - filter="(objectClass=*)" - attrs="*" - schemachecking=off - scope=sub - type=refreshOnly - interval=00:00:00:10 +syncrepl rid=1 + provider=@URI2@ + binddn="cn=Replica,dc=example,dc=com" + bindmethod=simple + credentials=secret + searchbase="dc=example,dc=com" + filter="(objectClass=*)" + attrs="*" + schemachecking=off + scope=sub + type=refreshOnly + interval=00:00:00:10 -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-translucent-local.conf b/tests/data/slapd-translucent-local.conf index 3ba45516a7..5d7737e8b4 100644 --- a/tests/data/slapd-translucent-local.conf +++ b/tests/data/slapd-translucent-local.conf @@ -30,6 +30,8 @@ argsfile ./testrun/slapd.2.args #ldapmod#moduleload back_ldap.la #translucentmod#modulepath ../servers/slapd/overlays #translucentmod#moduleload translucent.la +#monitormod#modulepath ../servers/slapd/back-monitor +#monitormod#moduleload back_monitor.la ####################################################################### # database definitions @@ -42,8 +44,12 @@ suffix "o=translucent" directory ./testrun/db.2.a rootdn "o=translucent" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub overlay translucent translucent_no_glue diff --git a/tests/data/slapd-translucent-remote.conf b/tests/data/slapd-translucent-remote.conf index c3ebd41825..47c35a9e3b 100644 --- a/tests/data/slapd-translucent-remote.conf +++ b/tests/data/slapd-translucent-remote.conf @@ -26,6 +26,8 @@ argsfile ./testrun/slapd.1.args #mod#modulepath ../servers/slapd/back-@BACKEND@/:../servers/slapd/overlays #mod#moduleload back_@BACKEND@.la +#monitormod#modulepath ../servers/slapd/back-monitor +#monitormod#moduleload back_monitor.la ####################################################################### # database definitions @@ -38,6 +40,10 @@ suffix "o=translucent" directory ./testrun/db.1.a rootdn "o=translucent" rootpw secret -index objectClass eq -index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub diff --git a/tests/data/slapd-unique.conf b/tests/data/slapd-unique.conf index 8d16feb035..b2dcb474e5 100644 --- a/tests/data/slapd-unique.conf +++ b/tests/data/slapd-unique.conf @@ -50,4 +50,4 @@ overlay unique unique_ignore o cn sn ou objectClass unique_attributes employeeNumber -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd-whoami.conf b/tests/data/slapd-whoami.conf index c24b781629..7b64ed9571 100644 --- a/tests/data/slapd-whoami.conf +++ b/tests/data/slapd-whoami.conf @@ -64,4 +64,4 @@ rootpw secret #ldbm#index objectClass eq #ldbm#index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd.conf b/tests/data/slapd.conf index 2d3be6b33f..6523c4fae1 100644 --- a/tests/data/slapd.conf +++ b/tests/data/slapd.conf @@ -40,7 +40,9 @@ rootdn "cn=Manager,dc=example,dc=com" rootpw secret #bdb#index objectClass eq #bdb#index cn,sn,uid pres,eq,sub +#hdb#index objectClass eq +#hdb#index cn,sn,uid pres,eq,sub #ldbm#index objectClass eq #ldbm#index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/slapd2.conf b/tests/data/slapd2.conf index 3517cdc2db..8b992629d0 100644 --- a/tests/data/slapd2.conf +++ b/tests/data/slapd2.conf @@ -40,4 +40,4 @@ rootpw secret index objectClass eq index cn,sn,uid pres,eq,sub -#monitor#database monitor +#monitor#database monitor diff --git a/tests/data/sql-concurrency/do_add.1 b/tests/data/sql-concurrency/do_add.1 new file mode 100644 index 0000000000..e4ce2d69cb --- /dev/null +++ b/tests/data/sql-concurrency/do_add.1 @@ -0,0 +1,9 @@ +cn=James Jones 1,dc=example,dc=com +objectClass: inetOrgPerson +cn: James Jones 1 +givenName: James +sn: Jones 1 +userpassword:: amFq +telephoneNumber: +1 313 555 4772 +telephoneNumber: +1 313 555 4332 +telephoneNumber: +1 313 555 0895 diff --git a/tests/data/sql-concurrency/do_add.2 b/tests/data/sql-concurrency/do_add.2 new file mode 100644 index 0000000000..a60b619038 --- /dev/null +++ b/tests/data/sql-concurrency/do_add.2 @@ -0,0 +1,10 @@ +cn=James Jones 2,dc=example,dc=com +objectClass: inetOrgPerson +cn: James Jones 2 +givenName: James +sn: Jones 2 +userpassword:: amFq +telephoneNumber: +1 313 555 4772 +telephoneNumber: +1 313 555 3923 +telephoneNumber: +1 313 555 4332 +telephoneNumber: +1 313 555 0895 diff --git a/tests/data/sql-concurrency/do_add.3 b/tests/data/sql-concurrency/do_add.3 new file mode 100644 index 0000000000..b479513d1b --- /dev/null +++ b/tests/data/sql-concurrency/do_add.3 @@ -0,0 +1,10 @@ +cn=James Jones 3,dc=example,dc=com +objectClass: inetOrgPerson +cn: James Jones 3 +givenName: James +sn: Jones 3 +userpassword:: amFq +telephoneNumber: +1 313 555 4772 +telephoneNumber: +1 313 555 3923 +telephoneNumber: +1 313 555 4332 +telephoneNumber: +1 313 555 0895 diff --git a/tests/data/sql-concurrency/do_add.4 b/tests/data/sql-concurrency/do_add.4 new file mode 100644 index 0000000000..065897e8c8 --- /dev/null +++ b/tests/data/sql-concurrency/do_add.4 @@ -0,0 +1,10 @@ +cn=James Jones 4,dc=example,dc=com +objectClass: inetOrgPerson +cn: James Jones 4 +givenName: James +sn: Jones 4 +userpassword:: amFq +telephoneNumber: +1 313 555 4772 +telephoneNumber: +1 313 555 3923 +telephoneNumber: +1 313 555 4332 +telephoneNumber: +1 313 555 0895 diff --git a/tests/data/sql-concurrency/do_modrdn.0 b/tests/data/sql-concurrency/do_modrdn.0 new file mode 100644 index 0000000000..29a77aaf01 --- /dev/null +++ b/tests/data/sql-concurrency/do_modrdn.0 @@ -0,0 +1,2 @@ +cn=Mitya Kovalev,dc=example,dc=com +cn=Torvlobnor Puzdoy,dc=example,dc=com diff --git a/tests/data/sql-concurrency/do_read.0 b/tests/data/sql-concurrency/do_read.0 new file mode 100644 index 0000000000..250ddbec87 --- /dev/null +++ b/tests/data/sql-concurrency/do_read.0 @@ -0,0 +1,4 @@ +documentTitle=book1,dc=example,dc=com +dc=example,dc=com +cn=Akakiy Zinberstein,dc=example,dc=com +ou=Referral,dc=example,dc=com diff --git a/tests/data/sql-concurrency/do_search.0 b/tests/data/sql-concurrency/do_search.0 new file mode 100644 index 0000000000..1984ff1960 --- /dev/null +++ b/tests/data/sql-concurrency/do_search.0 @@ -0,0 +1,12 @@ +dc=example,dc=com +cn=Mitya Kovalev +cn=Akakiy Zinberstein,dc=example,dc=com +sn=Zinberstein +dc=example,dc=com +cn=James* +dc=example,dc=com +sn=* +dc=example,dc=com +cn=* +dc=example,dc=com +cn=James* diff --git a/tests/data/sql-read.out b/tests/data/sql-read.out index 1dd9386354..53fe8c059c 100644 --- a/tests/data/sql-read.out +++ b/tests/data/sql-read.out @@ -21,7 +21,7 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 -# refldap://localhost:9010/dc=example,dc=com??one +# refldap://localhost:9012/dc=example,dc=com??one dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -63,7 +63,7 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: dc=example,dc=com objectClass: organization @@ -115,7 +115,7 @@ dn: ou=Referral,dc=example,dc=com objectClass: referral objectClass: extensibleObject ou: Referral -ref: ldap://localhost:9010/ +ref: ldap://localhost:9012/ dn: dc=example,dc=com objectClass: organization @@ -149,7 +149,7 @@ givenName: Akakiy # Testing invalid filter... # Testing exact search... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -162,7 +162,7 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing substrings initial search... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -175,7 +175,7 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing substrings any search... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -188,7 +188,7 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing substrings final search... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -201,7 +201,7 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing approx search... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -214,7 +214,7 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing extensible filter search... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -227,7 +227,7 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing search for telephoneNumber... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -240,7 +240,7 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing AND search... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -260,7 +260,7 @@ o: Example dc: example # Testing OR search... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -325,7 +325,7 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: dc=example,dc=com objectClass: organization @@ -349,7 +349,7 @@ documentTitle: book2 documentAuthor: cn=Mitya Kovalev,dc=example,dc=com documentIdentifier: document 2 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com objectClass: inetOrgPerson @@ -415,7 +415,7 @@ o: Example dc: example # Testing hasSubordinates in filter... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: dc=example,dc=com objectClass: organization @@ -435,7 +435,7 @@ telephoneNumber: 222-3234 telephoneNumber: 332-2334 # Testing attribute inheritance in requested attributes... -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: cn=Mitya Kovalev,dc=example,dc=com cn: Mitya Kovalev @@ -449,7 +449,7 @@ objectClass: document dn: documentTitle=book2,dc=example,dc=com objectClass: document -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: dc=example,dc=com objectClass: organization @@ -479,7 +479,7 @@ subschemaSubentry: cn=Subschema hasSubordinates: FALSE entryUUID: 00000002-0000-0002-0000-000000000000 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub dn: dc=example,dc=com structuralObjectClass: organization diff --git a/tests/data/sql-write.out b/tests/data/sql-write.out index 4573653d2d..9fb7d5340f 100644 --- a/tests/data/sql-write.out +++ b/tests/data/sql-write.out @@ -44,7 +44,7 @@ seeAlso: documentTitle=book1,dc=example,dc=com givenName: Torvlobnor telephoneNumber: 545-4563 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub # Using ldapsearch to retrieve all the entries... dn: cn=Akakiy Zinberstein,dc=example,dc=com @@ -139,7 +139,7 @@ documentTitle: War and Peace documentAuthor: cn=Lev Tolstoij,dc=example,dc=com documentIdentifier: document 3 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub # Using ldapsearch to retrieve all the entries... dn: cn=Akakiy Zinberstein,dc=example,dc=com @@ -237,7 +237,7 @@ documentTitle: War and Peace documentAuthor: cn=Lev Tolstoij,dc=example,dc=com documentIdentifier: document 3 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub # Using ldapsearch to retrieve all the entries... dn: cn=Akakiy Zinberstein,dc=example,dc=com @@ -310,7 +310,7 @@ documentTitle: War and Peace documentAuthor: cn=Lev Tolstoij,dc=example,dc=com documentIdentifier: document 3 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub # Using ldapsearch to retrieve all the entries... dn: cn=Akakiy Zinberstein,dc=example,dc=com @@ -383,7 +383,7 @@ documentTitle: War and Peace documentAuthor: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com documentIdentifier: document 3 -# refldap://localhost:9010/dc=example,dc=com??sub +# refldap://localhost:9012/dc=example,dc=com??sub # Using ldapsearch to retrieve the modified entry... dn: ou=Referral,dc=example,dc=com diff --git a/tests/data/test-meta.ldif b/tests/data/test-meta.ldif index 39456f24bb..7b6ae334e4 100644 --- a/tests/data/test-meta.ldif +++ b/tests/data/test-meta.ldif @@ -20,5 +20,5 @@ dn: cn=Somewhere,ou=Meta,dc=example,dc=com objectClass: referral objectClass: extensibleObject cn: Somewhere -ref: ldap://:9010 +ref: ldap://localhost:9016 diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index 301f01f1cc..37e45ec19e 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -148,10 +148,12 @@ do_modify( char *uri, char *host, int port, char *manager, struct ldapmod mod; struct ldapmod *mods[2]; - char *values[2] = { value, NULL }; + char *values[2]; pid = getpid(); + values[0] = value; + values[1] = NULL; mod.mod_op = LDAP_MOD_ADD; mod.mod_type = attr; mod.mod_values = values; diff --git a/tests/run.in b/tests/run.in index 57adb1c587..f4a46d47ce 100644 --- a/tests/run.in +++ b/tests/run.in @@ -37,6 +37,7 @@ AC_glue=glue@BUILD_GLUE@ AC_pcache=pcache@BUILD_PROXYCACHE@ AC_ppolicy=ppolicy@BUILD_PPOLICY@ AC_refint=refint@BUILD_REFINT@ +AC_retcode=retcode@BUILD_RETCODE@ AC_translucent=translucent@BUILD_TRANSLUCENT@ AC_unique=unique@BUILD_UNIQUE@ AC_rwm=rwm@BUILD_RWM@ @@ -48,7 +49,7 @@ AC_WITH_TLS=@WITH_TLS@ AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@ export AC_bdb AC_hdb AC_ldap AC_ldbm AC_meta AC_monitor AC_relay AC_sql -export AC_glue AC_pcache AC_ppolicy AC_refint AC_unique AC_rwm AC_syncprov +export AC_glue AC_pcache AC_ppolicy AC_refint AC_retcode AC_rwm AC_unique AC_syncprov export AC_translucent AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED if test ! -x ../servers/slapd/slapd ; then diff --git a/tests/scripts/conf.sh b/tests/scripts/conf.sh index 06cbe31205..2eb536b29b 100755 --- a/tests/scripts/conf.sh +++ b/tests/scripts/conf.sh @@ -35,36 +35,37 @@ fi sed -e "s/@BACKEND@/${BACKEND}/" \ -e "s/^#${BACKEND}#//" \ -e "s/@RELAY@/${RELAY}/" \ - -e "s/^#relay-${RELAY}#//" \ + -e "s/^#relay-${RELAY}#//" \ -e "s/^#${BACKENDTYPE}#//" \ - -e "s/^#${AC_glue}#//" \ -e "s/^#${AC_ldap}#//" \ -e "s/^#${AC_meta}#//" \ -e "s/^#${AC_relay}#//" \ -e "s/^#${AC_sql}#//" \ -e "s/^#${RDBMS}#//" \ + -e "s/^#${AC_glue}#//" \ -e "s/^#${AC_pcache}#//" \ -e "s/^#${AC_ppolicy}#//" \ -e "s/^#${AC_refint}#//" \ + -e "s/^#${AC_retcode}#//" \ + -e "s/^#${AC_rwm}#//" \ -e "s/^#${AC_syncprov}#//" \ - -e "s/^#${AC_translucent}#//" \ + -e "s/^#${AC_translucent}#//" \ -e "s/^#${AC_unique}#//" \ - -e "s/^#${AC_rwm}#//" \ -e "s/^#${MON}#//" \ -e "s/^#${MONMOD}#//" \ -e "s/^#${SASL}#//" \ - -e "s;@URI1@;${URI1};" \ - -e "s;@URI2@;${URI2};" \ - -e "s;@URI3@;${URI3};" \ - -e "s;@URI4@;${URI4};" \ - -e "s;@URI5@;${URI5};" \ - -e "s;@URI6@;${URI6};" \ - -e "s;@PORT1@;${PORT1};" \ - -e "s;@PORT2@;${PORT2};" \ - -e "s;@PORT3@;${PORT3};" \ - -e "s;@PORT4@;${PORT4};" \ - -e "s;@PORT5@;${PORT5};" \ - -e "s;@PORT6@;${PORT6};" \ - -e "s/@SASL_MECH@/${SASL_MECH}/" \ + -e "s;@URI1@;${URI1};" \ + -e "s;@URI2@;${URI2};" \ + -e "s;@URI3@;${URI3};" \ + -e "s;@URI4@;${URI4};" \ + -e "s;@URI5@;${URI5};" \ + -e "s;@URI6@;${URI6};" \ + -e "s;@PORT1@;${PORT1};" \ + -e "s;@PORT2@;${PORT2};" \ + -e "s;@PORT3@;${PORT3};" \ + -e "s;@PORT4@;${PORT4};" \ + -e "s;@PORT5@;${PORT5};" \ + -e "s;@PORT6@;${PORT6};" \ + -e "s/@SASL_MECH@/${SASL_MECH}/" \ -e "s/@CACHETTL@/${CACHETTL}/" \ -e "s/@ENTRY_LIMIT@/${CACHE_ENTRY_LIMIT}/" diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index 2596181bbf..1741c291cc 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -24,6 +24,7 @@ GLUE=${AC_glue-glueno} PROXYCACHE=${AC_pcache-pcacheno} PPOLICY=${AC_ppolicy-ppolicyno} REFINT=${AC_refint-refintno} +RETCODE=${AC_retcode-retcodeno} RWM=${AC_rwm-rwmno} TRANSLUCENT=${AC_translucent-translucentno} UNIQUE=${AC_unique-uniqueno} @@ -48,6 +49,7 @@ DBDIR3=$TESTDIR/db.3.a DBDIR4=$TESTDIR/db.4.a DBDIR5=$TESTDIR/db.5.a DBDIR6=$TESTDIR/db.6.a +SQLCONCURRENCYDIR=$DATADIR/sql-concurrency CONF=$DATADIR/slapd.conf CONFTWO=$DATADIR/slapd2.conf @@ -72,6 +74,7 @@ REFSLAVECONF=$DATADIR/slapd-ref-slave.conf SCHEMACONF=$DATADIR/slapd-schema.conf GLUECONF=$DATADIR/slapd-glue.conf REFINTCONF=$DATADIR/slapd-refint.conf +RETCODECONF=$DATADIR/slapd-retcode.conf UNIQUECONF=$DATADIR/slapd-unique.conf LIMITSCONF=$DATADIR/slapd-limits.conf DNCONF=$DATADIR/slapd-dn.conf @@ -91,6 +94,7 @@ TRANSLUCENTLOCALCONF=$DATADIR/slapd-translucent-local.conf TRANSLUCENTREMOTECONF=$DATADIR/slapd-translucent-remote.conf METACONF=$DATADIR/slapd-meta.conf METACONF2=$DATADIR/slapd-meta2.conf +GLUELDAPCONF=$DATADIR/slapd-glue-ldap.conf CONF1=$TESTDIR/slapd.1.conf CONF2=$TESTDIR/slapd.2.conf @@ -191,6 +195,7 @@ BABSDN="cn=Barbara Jensen,ou=Information Technology DivisioN,OU=People,dc=exampl BJORNSDN="cn=Bjorn Jensen,ou=Information Technology DivisioN,OU=People,dc=example,dc=com" JAJDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com" REFINTDN="cn=Manager,o=refint" +RETCODEDN="ou=RetCodes,$BASEDN" UNIQUEDN="cn=Manager,o=unique" EMPTYDNDN="cn=Manager,c=US" TRANSLUCENTROOT="o=translucent" diff --git a/tests/scripts/relay b/tests/scripts/relay index 638d330b77..a6ae27a4ff 100755 --- a/tests/scripts/relay +++ b/tests/scripts/relay @@ -169,10 +169,10 @@ description: Just added as ldap://localhost.localdomain:389/ou=Referrals,$BASEDN dn: ou=Referrals,$BASEDN changetype: modify replace: ref -ref: ldap://localhost:9010/ou=Referrals,$BASEDN +ref: ldap://localhost:9012/ou=Referrals,$BASEDN - add: description -description: ...and modified as ldap://localhost:9010/ou=Referrals,$BASEDN +description: ...and modified as ldap://localhost:9012/ou=Referrals,$BASEDN - EOMODS diff --git a/tests/scripts/test006-acls b/tests/scripts/test006-acls index 20a367f6ac..e93dbe9638 100755 --- a/tests/scripts/test006-acls +++ b/tests/scripts/test006-acls @@ -13,6 +13,14 @@ ## top-level directory of the distribution or, alternatively, at ## . +case "$BACKEND" in +bdb|hdb|ldbm) + ;; +*) + echo "Test does not support $BACKEND backend" + exit 0 +esac + echo "running defines.sh" . $SRCDIR/scripts/defines.sh @@ -174,15 +182,15 @@ EOMODS6 $LDAPMODIFY -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \ $TESTOUT 2>&1 << EOMODS7 -dn: ou=Add/Delete,dc=example,dc=com +dn: ou=Add & Delete,dc=example,dc=com changetype: add objectClass: organizationalUnit -ou: Add/Delete +ou: Add & Delete EOMODS7 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \ $TESTOUT 2>&1 << EOMODS8 -dn: cn=Added by Babs (must fail),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Babs (must fail),ou=Add & Delete,dc=example,dc=com changetype: add objectClass: inetOrgPerson cn: Added by Babs (must fail) @@ -191,25 +199,25 @@ EOMODS8 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \ $TESTOUT 2>&1 << EOMODS9 -dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com changetype: add objectClass: inetOrgPerson cn: Added by Bjorn (must succeed) sn: None -dn: cn=Added by Bjorn (will be deleted),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com changetype: add objectClass: inetOrgPerson cn: Added by Bjorn (will be deleted) sn: None -dn: cn=Added by Bjorn (will be renamed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com changetype: add objectClass: inetOrgPerson cn: Added by Bjorn (will be renamed) sn: None -dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com changetype: modify add: description description: this attribute value has been added __after__entry creation @@ -220,13 +228,13 @@ EOMODS9 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \ $TESTOUT 2>&1 << EOMODS10 -dn: cn=Added by Bjorn (will be deleted),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com changetype: delete EOMODS10 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \ $TESTOUT 2>&1 << EOMODS11 -dn: cn=Added by Bjorn (will be renamed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com changetype: modrdn newrdn: cn=Added by Bjorn (renamed by Bjorn) deleteoldrdn: 1 @@ -234,7 +242,7 @@ EOMODS11 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \ $TESTOUT 2>&1 << EOMODS12 -dn: cn=Added by Bjorn (will be renamed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com changetype: modrdn newrdn: cn=Added by Bjorn (renamed by Babs) deleteoldrdn: 1 @@ -242,7 +250,7 @@ EOMODS12 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \ $TESTOUT 2>&1 << EOMODS13 -dn: cn=Added by Bjorn (will be renamed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com changetype: modrdn newrdn: cn=Added by Bjorn (renamed by Jaj) deleteoldrdn: 1 @@ -250,7 +258,7 @@ EOMODS13 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \ $TESTOUT 2>&1 << EOMODS14 -dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com changetype: modify delete: description description: Bjorn will try to delete this attribute value (should fail) @@ -259,10 +267,10 @@ EOMODS14 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \ $TESTOUT 2>&1 << EOMODS15 -dn: cn=Added by Bjorn (will be deleted),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com changetype: delete -dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com +dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com changetype: modify delete: description description: this attribute value will be deleted by Babs (must succeed) diff --git a/tests/scripts/test020-proxycache b/tests/scripts/test020-proxycache index 98e98c4b38..797d828802 100755 --- a/tests/scripts/test020-proxycache +++ b/tests/scripts/test020-proxycache @@ -28,6 +28,11 @@ if test $BACKLDAP = "ldapno" ; then exit 0 fi +if test "x$LVL" = "x0" ; then + echo "test020 needs a minimal log level; setting to LDAP_DEBUG_NONE..." + LVL=2048 +fi + mkdir -p $TESTDIR $DBDIR1 $DBDIR2 # Test proxy caching: diff --git a/tests/scripts/test022-ppolicy b/tests/scripts/test022-ppolicy index 21cfed803f..3a3b3ded3a 100755 --- a/tests/scripts/test022-ppolicy +++ b/tests/scripts/test022-ppolicy @@ -311,6 +311,32 @@ if test $COUNT != 1 ; then exit 1 fi +echo "Testing hashed length requirement..." + +$LDAPMODIFY -h $LOCALHOST -p $PORT1 -D "$USER" -w failexpect > \ + $TESTOUT 2>&1 << EOMODS +dn: $USER +changetype: modify +delete: userPassword +userPassword: failexpect +- +add: userPassword +userPassword: {MD5}xxxxxx + +EOMODS +RC=$? +if test $RC = 0 ; then + echo "Hashed length requirement test failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi +COUNT=`grep "Password fails quality" $TESTOUT | wc -l` +if test $COUNT != 1 ; then + echo "Hashed length requirement test failed" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + test $KILLSERVERS != no && kill -HUP $KILLPIDS echo ">>>>> Test succeeded" diff --git a/tests/scripts/test030-relay b/tests/scripts/test030-relay index 656cc616f9..4d8f50438d 100755 --- a/tests/scripts/test030-relay +++ b/tests/scripts/test030-relay @@ -17,7 +17,7 @@ echo "running defines.sh" . $SRCDIR/scripts/defines.sh if test $RWM = rwmno ; then - echo "Rewrite/remap overlay not available, test skipped" + echo "rwm (Rewrite/remap) overlay not available, test skipped" exit 0 fi diff --git a/tests/scripts/test033-glue-syncrepl b/tests/scripts/test033-glue-syncrepl new file mode 100755 index 0000000000..75b876cf16 --- /dev/null +++ b/tests/scripts/test033-glue-syncrepl @@ -0,0 +1,114 @@ +#! /bin/sh +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2005 The OpenLDAP Foundation. +## 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 +## . + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +if test $GLUE = glueno; then + echo "Backend glue overlay not available, test skipped" + exit 0 +fi + +mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C + +echo "Running slapadd to build glued slapd databases..." +. $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1 +$SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1 +RC=$? +if test $RC != 0 ; then + echo "slapadd failed ($RC)!" + exit $RC +fi + +mv $DBDIR1B $DBDIR2B +mkdir $DBDIR2A $DBDIR1B +cp -pr $DBDIR1C $DBDIR2C + +echo "Starting slapd 1 on TCP/IP port $PORT1..." +. $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF1 > $CONF1 +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +echo "Using ldapsearch to check that slapd 1 is running..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ + '(objectclass=*)' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + +echo "Starting slapd 2 on TCP/IP port $PORT2..." +. $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2 +$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$KILLPIDS $PID" + +echo "Using ldapsearch to check that slapd 2 is running..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \ + '(objectclass=*)' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + +echo "Waiting 15 seconds for shadow subtrees to sync..." +sleep 15 + +for P in $PORT1 $PORT2 ; do + echo "Using ldapsearch to read all the entries from port $P..." + $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \ + -S "" '(objectclass=*)' > $SEARCHOUT 2>&1 + RC=$? + + if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + echo "Filtering ldapsearch results..." + . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + echo "Filtering original ldif used to create database..." + . $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT + echo "Comparing filter output..." + $CMP $SEARCHFLT $LDIFFLT > $CMPOUT + + if test $? != 0 ; then + echo "comparison failed - database was not created correctly" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 + fi +done + +test $KILLSERVERS != no && kill -HUP $KILLPIDS + +echo ">>>>> Test succeeded" +exit 0 diff --git a/tests/scripts/test037-manage b/tests/scripts/test037-manage new file mode 100755 index 0000000000..11cf238d42 --- /dev/null +++ b/tests/scripts/test037-manage @@ -0,0 +1,199 @@ +#! /bin/sh +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2005 The OpenLDAP Foundation. +## 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 +## . + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +mkdir -p $TESTDIR $DBDIR1 + +echo "Running slapadd to build slapd database..." +. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1 +$SLAPADD -f $CONF1 -l $LDIFORDERED +RC=$? +if test $RC != 0 ; then + echo "slapadd failed ($RC)!" + exit $RC +fi + +echo "Starting slapd on TCP/IP port $PORT1..." +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +echo "Testing slapd Manage operations..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +# ITS#3898: #ifndef LDAP_DEVEL, the control is not available +MANAGEDITOID="1.3.6.1.4.1.4203.666.5.12" +case `$LDAPSEARCH -s base -b "" -h $LOCALHOST -p $PORT1 \ + '(supportedControl:objectIdentifierMatch:='${MANAGEDITOID}')' \ + supportedControl | grep "supportedControl: ${MANAGEDITOID}"` in +"supportedControl: ${MANAGEDITOID}") + ;; +*) + echo "The \"manageDIT\" control appears to be unsupported; test disabled" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 0 + ;; +esac + +echo "Testing modify, add, and delete..." +$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ + -e \!manageDIT > \ + $TESTOUT 2>&1 << EOMODS +version: 1 +# +# Working Tests +# + +# +# ObjectClass tests +# + +dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, + dc=com +# add obsolete auxiliary objectclass +changetype: modify +add: objectClass +objectClass: obsoletePerson + +dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, + dc=com +# add obsolete attribute +changetype: modify +add: testObsolete +testObsolete: TRUE + +# +# create/modify timestamp test +# + +dn: ou=Groups,dc=example,dc=com +# change creatorsName +changetype: modify +replace: creatorsName +creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com + +dn: cn=ITD Staff,ou=Groups,dc=example,dc=com +# change modifiersName +changetype: modify +replace: modifiersName +modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com + +EOMODS + +RC=$? +if test $RC != 0 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing modify, add, and delete..." +$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ + -e \!manageDIT > \ + $TESTOUT 2>&1 << EOMODS +version: 1 +# +# Non-working tests +# + +dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, + dc=com +# update structural object class of entry via objectClass replace +changetype: modify +replace: objectClass +objectClass: obsoletePerson +- +replace: structuralObjectClass +structuralObjectClass: testPerson + +dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com +# update structural object class of entry via objectClass add +changetype: modify +add: objectClass +objectClass: testPerson +- +replace: structuralObjectClass +structuralObjectClass: testPerson + +dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com +# update structural object class of entry via objectClass delete/add +changetype: modify +delete: objectClass +objectClass: OpenLDAPperson +- +add: objectClass +objectClass: testPerson +- +delete: structuralObjectClass +- +add: structuralObjectClass +structuralObjectClass: testPerson + +EOMODS + +RC=$? +if test $RC != 0 ; then + echo "ldapmodify failed ($RC)! IGNORED" +# test $KILLSERVERS != no && kill -HUP $KILLPIDS +# exit $RC +fi + +echo "Using ldapsearch to retrieve all the entries..." +$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ + 'objectClass=*' '*' creatorsName modifiersName > $SEARCHOUT 2>&1 +RC=$? +test $KILLSERVERS != no && kill -HUP $KILLPIDS +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + exit $RC +fi + +LDIF=$MANAGEOUT + +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT +echo "Filtering original ldif used to create database..." +. $LDIFFILTER < $LDIF > $LDIFFLT +echo "Comparing filter output..." +$CMP $SEARCHFLT $LDIFFLT > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - manage operations did not complete correctly" + exit 1 +fi + +echo ">>>>> Test succeeded" +exit 0 diff --git a/tests/scripts/test038-retcode b/tests/scripts/test038-retcode new file mode 100755 index 0000000000..9a626383ab --- /dev/null +++ b/tests/scripts/test038-retcode @@ -0,0 +1,107 @@ +#! /bin/sh +# $Header$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2005 The OpenLDAP Foundation. +## 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 +## . + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +if test $RETCODE = retcodeno; then + echo "Retcode overlay not available, test skipped" + exit 0 +fi + +mkdir -p $TESTDIR $DBDIR1 + +echo "Running slapadd to build slapd database..." +. $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF +$SLAPADD -f $ADDCONF -l $LDIFORDERED +RC=$? +if test $RC != 0 ; then + echo "slapadd failed ($RC)!" + exit $RC +fi + +echo "Running slapindex to index slapd database..." +. $CONFFILTER $BACKEND $MONITORDB < $RETCODECONF > $CONF1 +$SLAPINDEX -f $CONF1 +RC=$? +if test $RC != 0 ; then + echo "warning: slapindex failed ($RC)" + echo " assuming no indexing support" +fi + +echo "Starting slapd on TCP/IP port $PORT1..." +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +echo "Testing slapd searching..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ + '(objectclass=*)' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing search for timelimitExceeded..." +$LDAPSEARCH -b "cn=timelimitExceeded,ou=RetCodes,$BASEDN" \ + -h $LOCALHOST -p $PORT1 '(objectClass=*)' >> $TESTOUT 2>&1 +RC=$? +if test $RC != 3 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing modify for unwillingToPerform..." +$LDAPMODIFY -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS +dn: cn=unwillingToPerform,ou=RetCodes,$BASEDN +changetype: delete +EOMODS +RC=$? +if test $RC != 53 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing compare for success after sleep (2 s)..." +$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \ + "cn=Success w/ Delay,ou=RetCodes,$BASEDN" "cn:foo" >> $TESTOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapcompare failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +test $KILLSERVERS != no && kill -HUP $KILLPIDS + +echo ">>>>> Test succeeded" +exit 0 diff --git a/tests/scripts/test039-glue-ldap-concurrency b/tests/scripts/test039-glue-ldap-concurrency new file mode 100755 index 0000000000..d0d89afc30 --- /dev/null +++ b/tests/scripts/test039-glue-ldap-concurrency @@ -0,0 +1,199 @@ +#! /bin/sh +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2005 The OpenLDAP Foundation. +## 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 +## . + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +echo "" + +if test $BACKLDAP = ldapno ; then + echo "ldap backend not available, test skipped" + exit 0 +fi + +if test $GLUE = "glueno" ; then + echo "glue overlay not available, test skipped" + exit 0 +fi + +if test $RWM = rwmno ; then + echo "rwm (rewrite/remap) overlay not available, test skipped" + exit 0 +fi + +rm -rf $TESTDIR + +mkdir -p $TESTDIR $DBDIR1 $DBDIR2 + +echo "Starting slapd on TCP/IP port $PORT1..." +. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1 +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +echo "Using ldapsearch to check that slapd is running..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Using ldapadd to populate the database..." +$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \ + $LDIFORDERED > $TESTOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapadd failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Starting slapd on TCP/IP port $PORT2..." +. $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2 +$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$KILLPIDS $PID" + +echo "Using ldapsearch to check that slapd is running..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Using ldapadd to populate the database..." +$LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \ + $LDIFMETA >> $TESTOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapadd failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Starting slapd on TCP/IP port $PORT3..." +. $CONFFILTER $BACKEND $MONITORDB < $GLUELDAPCONF > $CONF3 +$SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$KILLPIDS $PID" + +echo "Using ldapsearch to check that slapd is running..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +cat /dev/null > $SEARCHOUT + +mkdir -p $TESTDIR/$DATADIR +METABASEDN="o=Example,c=US" +for f in $DATADIR/do_* ; do + sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f +done + +# add a read that matches only the local database, but selects +# also the remote as candidate; this should be removed to compare +# execution times with test008... +for f in $TESTDIR/$DATADIR/do_read.* ; do + echo "ou=Meta,$METABASEDN" >> $f +done + +# add a read that matches a referral in the local database only, +# but selects also the remote as candidate; this should be removed +# to compare execution times with test008... +for f in $TESTDIR/$DATADIR/do_read.* ; do + echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f +done + +echo "Using tester for concurrent server access..." +$SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 -D "cn=Manager,$METABASEDN" -w $PASSWD -l 50 # -r 20 +RC=$? + +if test $RC != 0 ; then + echo "slapd-tester failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Using ldapsearch to retrieve all the entries..." +$LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \ + '(objectClass=*)' > $SEARCHOUT 2>&1 +RC=$? + +test $KILLSERVERS != no && kill -HUP $KILLPIDS + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + exit $RC +fi + +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT +echo "Filtering original ldif used to create database..." +. $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT +echo "Comparing filter output..." +$CMP $SEARCHFLT $LDIFFLT > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - meta search/modification didn't succeed" + exit 1 +fi + +echo ">>>>> Test succeeded" +exit 0 + -- 2.39.5