From 183a03cc2bf3c383b50dad3e4dd831ab3a32df6e Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 10 Sep 1999 22:25:02 +0000 Subject: [PATCH] Merge in all devel changes since 2.0-alpha2. Move OPENLDAP_REL_ENG_2_MP forward. --- Makefile.in | 30 + acconfig.h | 89 ++ acinclude.m4 | 8 + aclocal.m4 | 695 +++++++++ build/db.2.x.README | 29 + build/dir.mk | 1 + build/info.mk | 10 + build/install-sh | 255 +++ build/lib-shared.mk | 25 + build/lib-static.mk | 16 + build/lib.mk | 35 + build/man.mk | 1 + build/mkdep | 128 +- build/mkrelease | 1 + build/mkversion | 58 + build/mod.mk | 1 + build/openldap.m4 | 23 + build/rules.mk | 1 + build/srv.mk | 1 + build/top.mk | 1 + build/version | 2 +- clients/Makefile.in | 7 + clients/fax500/Makefile.in | 2 + clients/fax500/fax500.h | 11 + clients/fax500/faxtotpc.c | 41 +- clients/fax500/main.c | 3 +- clients/fax500/rp500.c | 1 + clients/finger/Makefile.in | 2 + clients/finger/main.c | 1 + clients/gopher/Makefile.in | 1 + clients/gopher/go500.c | 5 +- clients/gopher/go500gw.c | 5 +- clients/mail500/Makefile.in | 2 + clients/mail500/main.c | 7 +- clients/rcpt500/Makefile.in | 2 + clients/rcpt500/cmds.c | 5 +- clients/rcpt500/help.c | 21 +- clients/rcpt500/main.c | 1 + clients/rcpt500/query.c | 1 + clients/rcpt500/rcpt500.h | 32 +- clients/tools/Makefile.in | 1 + clients/tools/ldapdelete.c | 7 +- clients/tools/ldapmodify.c | 6 +- clients/tools/ldapmodrdn.c | 5 +- clients/tools/ldappasswd.c | 27 +- clients/tools/ldapsearch.c | 8 +- clients/ud/Makefile.in | 2 + clients/ud/auth.c | 16 +- clients/ud/edit.c | 1 + clients/ud/find.c | 125 +- clients/ud/globals.c | 35 +- clients/ud/group.c | 1 + clients/ud/help.c | 1 + clients/ud/main.c | 1 + clients/ud/mod.c | 1 + clients/ud/print.c | 143 +- clients/ud/string_to_key.c | 1 + clients/ud/ud.h | 167 +- clients/ud/util.c | 1 + configure | 1551 +++++++++++-------- configure.in | 88 +- doc/Makefile.in | 7 + doc/man/man5/ldap.conf.5 | 86 + doc/man/man8/slapd.8 | 111 +- doc/man/man8/slurpd.8 | 15 +- include/Makefile.in | 1 + include/ac/alloca.h | 36 + include/ac/assert.h | 1 + include/ac/bytes.h | 66 + include/ac/ctype.h | 29 + include/ac/dirent.h | 33 + include/ac/errno.h | 41 + include/ac/krb.h | 31 + include/ac/regex.h | 36 + include/ac/setproctitle.h | 29 + include/ac/signal.h | 65 + include/ac/socket.h | 41 +- include/ac/stdarg.h | 24 + include/ac/stdlib.h | 1 + include/ac/string.h | 79 + include/ac/sysexits.h | 21 + include/ac/syslog.h | 33 + include/ac/termios.h | 46 + include/ac/time.h | 28 + include/ac/unistd.h | 65 + include/ac/wait.h | 52 + include/avl.h | 86 +- include/disptmpl.h | 195 ++- include/getopt-compat.h | 32 + include/lber.h | 1 + include/lber_pvt.h | 38 + include/lber_types.h.in | 31 + include/lber_types.nt | 44 + include/ldap.h | 46 +- include/ldap_cdefs.h | 78 + include/ldap_config.h.in | 56 + include/ldap_config.nt | 59 + include/ldap_defaults.h | 221 +++ include/ldap_features.h.in | 56 + include/ldap_features.nt | 56 + include/ldap_log.h | 83 + include/ldap_pvt.h | 37 + include/ldap_pvt_thread.h | 308 ++++ include/ldap_schema.h | 3 +- include/ldbm.h | 1 + include/ldif.h | 2 +- include/lutil.h | 6 + include/lutil_lockf.h | 30 + include/lutil_md5.h | 66 + include/lutil_sha1.h | 69 + include/portable.h.in | 26 +- include/portable.nt | 759 +++++++++ include/setup.dsp | 100 ++ include/setup.mak | 23 +- include/srchpref.h | 59 +- include/sysexits-compat.h | 10 + libraries/Makefile.in | 8 + libraries/libavl/Makefile.in | 18 + libraries/libavl/avl.c | 1 + libraries/libavl/testavl.c | 1 + libraries/liblber/Makefile.in | 35 + libraries/liblber/assert.c | 1 + libraries/liblber/bprint.c | 219 ++- libraries/liblber/decode.c | 25 +- libraries/liblber/dtest.c | 1 + libraries/liblber/encode.c | 25 +- libraries/liblber/etest.c | 201 ++- libraries/liblber/idtest.c | 1 + libraries/liblber/io.c | 749 ++++----- libraries/liblber/lber-int.h | 1 + libraries/liblber/memory.c | 320 ++++ libraries/liblber/options.c | 143 ++ libraries/liblber/sockbuf.c | 26 +- libraries/libldap/Makefile.in | 5 +- libraries/libldap/abandon.c | 190 ++- libraries/libldap/add.c | 160 +- libraries/libldap/addentry.c | 41 +- libraries/libldap/apitest.c | 1 + libraries/libldap/bind.c | 96 +- libraries/libldap/cache.c | 285 ++-- libraries/libldap/charray.c | 219 +++ libraries/libldap/charset.c | 141 +- libraries/libldap/cldap.c | 303 ++-- libraries/libldap/compare.c | 159 +- libraries/libldap/controls.c | 359 +++++ libraries/libldap/delete.c | 132 +- libraries/libldap/digest.c | 1 + libraries/libldap/disptmpl.c | 195 ++- libraries/libldap/dn.c | 339 ++++ libraries/libldap/dsparse.c | 77 +- libraries/libldap/error.c | 1 + libraries/libldap/extended.c | 267 ++++ libraries/libldap/free.c | 117 +- libraries/libldap/friendly.c | 73 +- libraries/libldap/getattr.c | 62 +- libraries/libldap/getdn.c | 181 ++- libraries/libldap/getdxbyname.c | 3 +- libraries/libldap/getentry.c | 137 +- libraries/libldap/getfilter.c | 7 +- libraries/libldap/getvalues.c | 98 +- libraries/libldap/init.c | 1 + libraries/libldap/kbind.c | 141 +- libraries/libldap/ldap-int.h | 4 +- libraries/libldap/ldap.conf | 17 + libraries/libldap/ldapfilter.conf | 18 +- libraries/libldap/ldapsearchprefs.conf | 1 + libraries/libldap/ldaptemplates.conf | 1 + libraries/libldap/libldap.dsp | 365 +++++ libraries/libldap/messages.c | 66 + libraries/libldap/modify.c | 125 +- libraries/libldap/modrdn.c | 240 ++- libraries/libldap/open.c | 1 + libraries/libldap/options.c | 1 + libraries/libldap/os-ip.c | 5 +- libraries/libldap/print.c | 60 + libraries/libldap/references.c | 157 ++ libraries/libldap/request.c | 1 + libraries/libldap/result.c | 581 ++++--- libraries/libldap/sasl.c | 334 ++++ libraries/libldap/sbind.c | 116 +- libraries/libldap/schema.c | 6 +- libraries/libldap/search.c | 58 +- libraries/libldap/sort.c | 84 +- libraries/libldap/srchpref.c | 142 +- libraries/libldap/string.c | 133 ++ libraries/libldap/test.c | 1 + libraries/libldap/tls.c | 19 +- libraries/libldap/tmplout.c | 1 + libraries/libldap/tmpltest.c | 1 + libraries/libldap/ufn.c | 112 +- libraries/libldap/unbind.c | 1 + libraries/libldap/url.c | 1 + libraries/libldap/util-int.c | 372 +++++ libraries/libldap_r/Makefile.in | 9 +- libraries/libldap_r/rdwr.c | 262 ++++ libraries/libldap_r/thr_cthreads.c | 1 + libraries/libldap_r/thr_lwp.c | 363 +++++ libraries/libldap_r/thr_nt.c | 151 ++ libraries/libldap_r/thr_posix.c | 205 +++ libraries/libldap_r/thr_pth.c | 143 ++ libraries/libldap_r/thr_sleep.c | 57 + libraries/libldap_r/thr_stub.c | 135 ++ libraries/libldap_r/thr_thr.c | 151 ++ libraries/libldbm/Makefile.in | 18 + libraries/libldbm/ldbm.c | 13 +- libraries/libldif/Makefile.in | 1 + libraries/libldif/fetch.c | 4 +- libraries/libldif/line64.c | 17 +- libraries/liblutil/Makefile.in | 5 +- libraries/liblutil/base64.c | 1 + libraries/liblutil/debug.c | 3 +- libraries/liblutil/detach.c | 1 + libraries/liblutil/getopt.c | 1 + libraries/liblutil/getpass.c | 1 + libraries/liblutil/liblutil.dsp | 4 + libraries/liblutil/lockf.c | 114 ++ libraries/liblutil/md5.c | 1 + libraries/liblutil/memcmp.c | 20 + libraries/liblutil/nt_err.c | 108 ++ libraries/liblutil/ntservice.c | 1 + libraries/liblutil/passwd.c | 1 + libraries/liblutil/setproctitle.c | 73 + libraries/liblutil/sha1.c | 1 + libraries/liblutil/sockpair.c | 62 + libraries/liblutil/tempnam.c | 46 + libraries/liblutil/utils.c | 1 + servers/Makefile.in | 1 + servers/slapd/Makefile.in | 1 + servers/slapd/abandon.c | 3 +- servers/slapd/acl.c | 388 ++++- servers/slapd/aclparse.c | 66 +- servers/slapd/add.c | 10 + servers/slapd/attr.c | 17 +- servers/slapd/ava.c | 1 + servers/slapd/back-bdb2/Makefile.in | 2 + servers/slapd/back-bdb2/abandon.c | 47 + servers/slapd/back-bdb2/add.c | 3 +- servers/slapd/back-bdb2/alias.c | 285 ++++ servers/slapd/back-bdb2/attr.c | 174 +++ servers/slapd/back-bdb2/back-bdb2.h | 1 + servers/slapd/back-bdb2/bind.c | 347 +++++ servers/slapd/back-bdb2/cache.c | 590 +++++++ servers/slapd/back-bdb2/close.c | 1 + servers/slapd/back-bdb2/compare.c | 136 ++ servers/slapd/back-bdb2/config.c | 202 +++ servers/slapd/back-bdb2/dbcache.c | 2 +- servers/slapd/back-bdb2/delete.c | 3 +- servers/slapd/back-bdb2/dn2id.c | 49 +- servers/slapd/back-bdb2/entry.c | 30 + servers/slapd/back-bdb2/external.h | 9 +- servers/slapd/back-bdb2/filterindex.c | 1 + servers/slapd/back-bdb2/group.c | 182 +++ servers/slapd/back-bdb2/id2children.c | 1 + servers/slapd/back-bdb2/id2entry.c | 1 + servers/slapd/back-bdb2/idl.c | 19 +- servers/slapd/back-bdb2/index.c | 1 + servers/slapd/back-bdb2/init.c | 1 + servers/slapd/back-bdb2/kerberos.c | 49 + servers/slapd/back-bdb2/modify.c | 1 + servers/slapd/back-bdb2/modrdn.c | 510 ++++++ servers/slapd/back-bdb2/nextid.c | 1 + servers/slapd/back-bdb2/porter.c | 1 + servers/slapd/back-bdb2/proto-back-bdb2.h | 16 +- servers/slapd/back-bdb2/search.c | 1 + servers/slapd/back-bdb2/startup.c | 260 ++++ servers/slapd/back-bdb2/timing.c | 70 + servers/slapd/back-bdb2/tools.c | 3 +- servers/slapd/back-bdb2/txn.c | 1 + servers/slapd/back-bdb2/txn.h | 2 +- servers/slapd/back-bdb2/unbind.c | 39 + servers/slapd/back-ldap/Makefile.in | 2 + servers/slapd/back-ldap/add.c | 79 + servers/slapd/back-ldap/back-ldap.h | 58 + servers/slapd/back-ldap/bind.c | 122 ++ servers/slapd/back-ldap/compare.c | 59 + servers/slapd/back-ldap/config.c | 74 + servers/slapd/back-ldap/delete.c | 58 + servers/slapd/back-ldap/external.h | 56 + servers/slapd/back-ldap/init.c | 1 + servers/slapd/back-ldap/modify.c | 71 + servers/slapd/back-ldap/modrdn.c | 66 + servers/slapd/back-ldap/search.c | 179 +++ servers/slapd/back-ldap/unbind.c | 62 + servers/slapd/back-ldbm/Makefile.in | 2 + servers/slapd/back-ldbm/abandon.c | 1 + servers/slapd/back-ldbm/add.c | 3 +- servers/slapd/back-ldbm/alias.c | 286 ++++ servers/slapd/back-ldbm/attr.c | 3 +- servers/slapd/back-ldbm/back-ldbm.h | 1 + servers/slapd/back-ldbm/bind.c | 1 + servers/slapd/back-ldbm/cache.c | 5 +- servers/slapd/back-ldbm/close.c | 1 + servers/slapd/back-ldbm/compare.c | 1 + servers/slapd/back-ldbm/config.c | 3 +- servers/slapd/back-ldbm/dbcache.c | 2 +- servers/slapd/back-ldbm/delete.c | 9 +- servers/slapd/back-ldbm/dn2id.c | 59 +- servers/slapd/back-ldbm/entry.c | 1 + servers/slapd/back-ldbm/external.h | 7 +- servers/slapd/back-ldbm/filterindex.c | 1 + servers/slapd/back-ldbm/group.c | 13 +- servers/slapd/back-ldbm/id2children.c | 1 + servers/slapd/back-ldbm/id2entry.c | 1 + servers/slapd/back-ldbm/idl.c | 25 +- servers/slapd/back-ldbm/index.c | 1 + servers/slapd/back-ldbm/init.c | 1 + servers/slapd/back-ldbm/kerberos.c | 1 + servers/slapd/back-ldbm/modify.c | 1 + servers/slapd/back-ldbm/modrdn.c | 88 +- servers/slapd/back-ldbm/nextid.c | 2 +- servers/slapd/back-ldbm/proto-back-ldbm.h | 18 +- servers/slapd/back-ldbm/search.c | 5 +- servers/slapd/back-ldbm/startup.c | 4 +- servers/slapd/back-ldbm/tools.c | 3 +- servers/slapd/back-ldbm/unbind.c | 1 + servers/slapd/back-passwd/Makefile.in | 2 + servers/slapd/back-passwd/config.c | 27 +- servers/slapd/back-passwd/external.h | 20 + servers/slapd/back-passwd/init.c | 1 + servers/slapd/back-passwd/search.c | 275 +++- servers/slapd/back-perl/Makefile.in | 1 + servers/slapd/back-perl/add.c | 1 + servers/slapd/back-perl/bind.c | 82 + servers/slapd/back-perl/close.c | 65 + servers/slapd/back-perl/compare.c | 85 + servers/slapd/back-perl/config.c | 3 +- servers/slapd/back-perl/delete.c | 74 + servers/slapd/back-perl/external.h | 53 + servers/slapd/back-perl/init.c | 1 + servers/slapd/back-perl/modify.c | 108 ++ servers/slapd/back-perl/modrdn.c | 97 ++ servers/slapd/back-perl/perl_back.h | 23 + servers/slapd/back-perl/search.c | 125 ++ servers/slapd/back-perl/unbind.c | 41 + servers/slapd/back-shell/Makefile.in | 2 + servers/slapd/back-shell/abandon.c | 40 +- servers/slapd/back-shell/add.c | 3 +- servers/slapd/back-shell/bind.c | 32 +- servers/slapd/back-shell/compare.c | 27 +- servers/slapd/back-shell/config.c | 41 +- servers/slapd/back-shell/delete.c | 27 +- servers/slapd/back-shell/external.h | 56 + servers/slapd/back-shell/fork.c | 1 + servers/slapd/back-shell/init.c | 1 + servers/slapd/back-shell/modify.c | 46 +- servers/slapd/back-shell/modrdn.c | 46 +- servers/slapd/back-shell/result.c | 1 + servers/slapd/back-shell/search.c | 33 +- servers/slapd/back-shell/shell.h | 33 + servers/slapd/back-shell/unbind.c | 35 +- servers/slapd/back-tcl/Makefile.in | 1 + servers/slapd/back-tcl/external.h | 58 + servers/slapd/back-tcl/tcl_abandon.c | 58 + servers/slapd/back-tcl/tcl_add.c | 3 +- servers/slapd/back-tcl/tcl_back.h | 64 + servers/slapd/back-tcl/tcl_bind.c | 3 +- servers/slapd/back-tcl/tcl_close.c | 82 + servers/slapd/back-tcl/tcl_compare.c | 3 +- servers/slapd/back-tcl/tcl_config.c | 182 +++ servers/slapd/back-tcl/tcl_delete.c | 3 +- servers/slapd/back-tcl/tcl_init.c | 3 +- servers/slapd/back-tcl/tcl_modify.c | 3 +- servers/slapd/back-tcl/tcl_modrdn.c | 3 +- servers/slapd/back-tcl/tcl_search.c | 3 +- servers/slapd/back-tcl/tcl_unbind.c | 57 + servers/slapd/back-tcl/tcl_util.c | 3 +- servers/slapd/backend.c | 30 +- servers/slapd/bind.c | 4 +- servers/slapd/ch_malloc.c | 1 + servers/slapd/charray.c | 10 +- servers/slapd/compare.c | 1 + servers/slapd/config.c | 15 +- servers/slapd/configinfo.c | 2 +- servers/slapd/connection.c | 17 +- servers/slapd/controls.c | 1 + servers/slapd/daemon.c | 253 ++- servers/slapd/delete.c | 10 + servers/slapd/dn.c | 51 +- servers/slapd/entry.c | 1 + servers/slapd/extended.c | 113 ++ servers/slapd/filter.c | 1 + servers/slapd/filterentry.c | 25 +- servers/slapd/init.c | 1 + servers/slapd/lock.c | 3 +- servers/slapd/main.c | 60 +- servers/slapd/modify.c | 24 +- servers/slapd/modrdn.c | 26 +- servers/slapd/module.c | 1 + servers/slapd/monitor.c | 2 +- servers/slapd/nt_svc.c | 89 ++ servers/slapd/operation.c | 3 +- servers/slapd/phonetic.c | 1 + servers/slapd/proto-slap.h | 91 +- servers/slapd/repl.c | 1 + servers/slapd/result.c | 51 +- servers/slapd/root_dse.c | 2 +- servers/slapd/sasl.c | 1 + servers/slapd/schema.c | 65 +- servers/slapd/schema/core.schema | 2 + servers/slapd/schema/internet_mail.at.conf | 71 + servers/slapd/schema/internet_mail.oc.conf | 50 + servers/slapd/schema/misc.schema | 1 + servers/slapd/schema/nadf.schema | 178 +++ servers/slapd/schema/nis.at.conf | 297 ++++ servers/slapd/schema/nis.oc.conf | 244 +++ servers/slapd/schema/nis.schema | 232 +++ servers/slapd/schema/others_nis.at.conf | 283 ++++ servers/slapd/schema/others_nis.oc.conf | 137 ++ servers/slapd/schema/pilot.schema | 2 + servers/slapd/schemaparse.c | 22 +- servers/slapd/search.c | 3 +- servers/slapd/shell-backends/Makefile.in | 22 + servers/slapd/shell-backends/passwd-shell.c | 1 + servers/slapd/shell-backends/passwd-shell.h | 1 + servers/slapd/shell-backends/pwd-Version.c | 1 + servers/slapd/shell-backends/shellutil.c | 17 +- servers/slapd/shell-backends/shellutil.h | 18 +- servers/slapd/slap.h | 17 +- servers/slapd/slapd.at.conf | 2 + servers/slapd/slapd.conf | 25 +- servers/slapd/slapd.oc.conf | 2 + servers/slapd/str2filter.c | 22 +- servers/slapd/suffixalias.c | 75 + servers/slapd/tools/Makefile.in | 1 + servers/slapd/tools/centipede.c | 12 +- servers/slapd/tools/chlog2replog.c | 1 + servers/slapd/tools/edb2ldif.c | 1 + servers/slapd/tools/ldapsyntax.c | 1 + servers/slapd/tools/ldapsyntax.h | 17 +- servers/slapd/tools/ldbmtest.c | 2 +- servers/slapd/tools/ldif.c | 6 +- servers/slapd/tools/mimic.c | 11 +- servers/slapd/tools/sizecount.c | 5 +- servers/slapd/tools/slapadd.c | 4 +- servers/slapd/tools/slapcat.c | 1 + servers/slapd/tools/slapcommon.c | 1 + servers/slapd/tools/slapcommon.h | 2 +- servers/slapd/tools/slapindex.c | 22 +- servers/slapd/unbind.c | 1 + servers/slapd/user.c | 9 +- servers/slapd/value.c | 6 +- servers/slurpd/Makefile.in | 1 + servers/slurpd/admin.c | 11 +- servers/slurpd/args.c | 51 +- servers/slurpd/ch_malloc.c | 1 + servers/slurpd/config.c | 1 + servers/slurpd/fm.c | 108 +- servers/slurpd/globals.c | 2 + servers/slurpd/globals.h | 25 +- servers/slurpd/ldap_op.c | 6 + servers/slurpd/lock.c | 58 +- servers/slurpd/main.c | 11 +- servers/slurpd/proto-slurp.h | 7 +- servers/slurpd/re.c | 23 +- servers/slurpd/reject.c | 19 +- servers/slurpd/replica.c | 26 +- servers/slurpd/replog.c | 67 +- servers/slurpd/ri.c | 53 +- servers/slurpd/rq.c | 48 +- servers/slurpd/sanity.c | 18 +- servers/slurpd/slurp.h | 1 + servers/slurpd/st.c | 51 +- tests/Makefile.in | 1 + tests/data/acl.out.master | 11 - tests/data/modify.out.master | 11 - tests/data/modrdn.out.master | 11 - tests/data/modrdn.out.master.0 | 11 - tests/data/search.out.master | 10 - tests/data/slapd-acl.conf | 26 +- tests/data/slapd-bdb2-acl.conf | 50 + tests/data/slapd-bdb2-master.conf | 26 + tests/data/slapd-bdb2-nis-master.conf | 42 + tests/data/slapd-bdb2-ref-slave.conf | 29 + tests/data/slapd-bdb2-repl-master.conf | 34 + tests/data/slapd-bdb2-repl-slave.conf | 32 + tests/data/slapd-master.conf | 6 +- tests/data/slapd-nis-master.conf | 38 + tests/data/slapd-passwd.conf | 19 + tests/data/slapd-ref-slave.conf | 26 + tests/data/slapd-repl-master.conf | 7 +- tests/data/slapd-repl-slave.conf | 12 +- tests/data/slapd.at.conf | 2 + tests/data/slapd.oc.conf | 23 +- tests/data/test-ordered.ldif | 11 - tests/data/test.ldif | 11 - tests/progs/Makefile.in | 3 +- tests/progs/slapd-addel.c | 5 + tests/progs/slapd-read.c | 5 + tests/progs/slapd-search.c | 5 + tests/progs/slapd-tester.c | 5 + tests/scripts/acfilter.sh | 6 + tests/scripts/all | 1 + tests/scripts/defines.sh | 3 + tests/scripts/makeldbm.sh | 7 +- tests/scripts/passwd-search | 109 ++ tests/scripts/startup_nis_ldap_server.sh | 8 +- tests/scripts/test001-ldif2ldbm | 67 - tests/scripts/test002-populate | 1 + tests/scripts/test003-search | 5 +- tests/scripts/test004-modify | 5 +- tests/scripts/test005-modrdn | 31 +- tests/scripts/test006-acls | 5 +- tests/scripts/test007-replication | 1 + tests/scripts/test008-concurrency | 7 +- tests/scripts/test009-referral | 5 +- 505 files changed, 24132 insertions(+), 4846 deletions(-) create mode 100644 Makefile.in create mode 100644 acconfig.h create mode 100644 acinclude.m4 create mode 100644 aclocal.m4 create mode 100644 build/db.2.x.README create mode 100644 build/info.mk create mode 100755 build/install-sh create mode 100644 build/lib-shared.mk create mode 100644 build/lib-static.mk create mode 100644 build/lib.mk create mode 100755 build/mkversion create mode 100644 clients/Makefile.in create mode 100644 clients/fax500/fax500.h create mode 100644 doc/Makefile.in create mode 100644 doc/man/man5/ldap.conf.5 create mode 100644 include/ac/alloca.h create mode 100644 include/ac/bytes.h create mode 100644 include/ac/ctype.h create mode 100644 include/ac/dirent.h create mode 100644 include/ac/errno.h create mode 100644 include/ac/krb.h create mode 100644 include/ac/regex.h create mode 100644 include/ac/setproctitle.h create mode 100644 include/ac/signal.h create mode 100644 include/ac/stdarg.h create mode 100644 include/ac/string.h create mode 100644 include/ac/sysexits.h create mode 100644 include/ac/syslog.h create mode 100644 include/ac/termios.h create mode 100644 include/ac/time.h create mode 100644 include/ac/unistd.h create mode 100644 include/ac/wait.h create mode 100644 include/getopt-compat.h create mode 100644 include/lber_pvt.h create mode 100644 include/lber_types.h.in create mode 100644 include/lber_types.nt create mode 100644 include/ldap_cdefs.h create mode 100644 include/ldap_config.h.in create mode 100644 include/ldap_config.nt create mode 100644 include/ldap_defaults.h create mode 100644 include/ldap_features.h.in create mode 100644 include/ldap_features.nt create mode 100644 include/ldap_log.h create mode 100644 include/ldap_pvt_thread.h create mode 100644 include/lutil_lockf.h create mode 100644 include/lutil_md5.h create mode 100644 include/lutil_sha1.h create mode 100644 include/portable.nt create mode 100644 include/setup.dsp create mode 100644 libraries/Makefile.in create mode 100644 libraries/libavl/Makefile.in create mode 100644 libraries/liblber/Makefile.in create mode 100644 libraries/liblber/memory.c create mode 100644 libraries/liblber/options.c create mode 100644 libraries/libldap/charray.c create mode 100644 libraries/libldap/controls.c create mode 100644 libraries/libldap/dn.c create mode 100644 libraries/libldap/extended.c create mode 100644 libraries/libldap/ldap.conf create mode 100644 libraries/libldap/libldap.dsp create mode 100644 libraries/libldap/messages.c create mode 100644 libraries/libldap/print.c create mode 100644 libraries/libldap/references.c create mode 100644 libraries/libldap/sasl.c create mode 100644 libraries/libldap/string.c create mode 100644 libraries/libldap/util-int.c create mode 100644 libraries/libldap_r/rdwr.c create mode 100644 libraries/libldap_r/thr_lwp.c create mode 100644 libraries/libldap_r/thr_nt.c create mode 100644 libraries/libldap_r/thr_posix.c create mode 100644 libraries/libldap_r/thr_pth.c create mode 100644 libraries/libldap_r/thr_sleep.c create mode 100644 libraries/libldap_r/thr_stub.c create mode 100644 libraries/libldap_r/thr_thr.c create mode 100644 libraries/libldbm/Makefile.in create mode 100644 libraries/liblutil/lockf.c create mode 100644 libraries/liblutil/memcmp.c create mode 100644 libraries/liblutil/nt_err.c create mode 100644 libraries/liblutil/setproctitle.c create mode 100644 libraries/liblutil/sockpair.c create mode 100644 libraries/liblutil/tempnam.c create mode 100644 servers/slapd/back-bdb2/abandon.c create mode 100644 servers/slapd/back-bdb2/alias.c create mode 100644 servers/slapd/back-bdb2/attr.c create mode 100644 servers/slapd/back-bdb2/bind.c create mode 100644 servers/slapd/back-bdb2/cache.c create mode 100644 servers/slapd/back-bdb2/compare.c create mode 100644 servers/slapd/back-bdb2/config.c create mode 100644 servers/slapd/back-bdb2/entry.c create mode 100644 servers/slapd/back-bdb2/group.c create mode 100644 servers/slapd/back-bdb2/kerberos.c create mode 100644 servers/slapd/back-bdb2/modrdn.c create mode 100644 servers/slapd/back-bdb2/startup.c create mode 100644 servers/slapd/back-bdb2/timing.c create mode 100644 servers/slapd/back-bdb2/unbind.c create mode 100644 servers/slapd/back-ldap/add.c create mode 100644 servers/slapd/back-ldap/back-ldap.h create mode 100644 servers/slapd/back-ldap/bind.c create mode 100644 servers/slapd/back-ldap/compare.c create mode 100644 servers/slapd/back-ldap/config.c create mode 100644 servers/slapd/back-ldap/delete.c create mode 100644 servers/slapd/back-ldap/external.h create mode 100644 servers/slapd/back-ldap/modify.c create mode 100644 servers/slapd/back-ldap/modrdn.c create mode 100644 servers/slapd/back-ldap/search.c create mode 100644 servers/slapd/back-ldap/unbind.c create mode 100644 servers/slapd/back-ldbm/alias.c create mode 100644 servers/slapd/back-passwd/external.h create mode 100644 servers/slapd/back-perl/bind.c create mode 100644 servers/slapd/back-perl/close.c create mode 100644 servers/slapd/back-perl/compare.c create mode 100644 servers/slapd/back-perl/delete.c create mode 100644 servers/slapd/back-perl/external.h create mode 100644 servers/slapd/back-perl/modify.c create mode 100644 servers/slapd/back-perl/modrdn.c create mode 100644 servers/slapd/back-perl/perl_back.h create mode 100644 servers/slapd/back-perl/search.c create mode 100644 servers/slapd/back-perl/unbind.c create mode 100644 servers/slapd/back-shell/external.h create mode 100644 servers/slapd/back-tcl/external.h create mode 100644 servers/slapd/back-tcl/tcl_abandon.c create mode 100644 servers/slapd/back-tcl/tcl_back.h create mode 100644 servers/slapd/back-tcl/tcl_close.c create mode 100644 servers/slapd/back-tcl/tcl_config.c create mode 100644 servers/slapd/back-tcl/tcl_unbind.c create mode 100644 servers/slapd/extended.c create mode 100644 servers/slapd/nt_svc.c create mode 100644 servers/slapd/schema/internet_mail.at.conf create mode 100644 servers/slapd/schema/internet_mail.oc.conf create mode 100644 servers/slapd/schema/nadf.schema create mode 100644 servers/slapd/schema/nis.at.conf create mode 100644 servers/slapd/schema/nis.oc.conf create mode 100644 servers/slapd/schema/nis.schema create mode 100644 servers/slapd/schema/others_nis.at.conf create mode 100644 servers/slapd/schema/others_nis.oc.conf create mode 100644 servers/slapd/shell-backends/Makefile.in create mode 100644 servers/slapd/suffixalias.c create mode 100644 tests/data/slapd-bdb2-acl.conf create mode 100644 tests/data/slapd-bdb2-master.conf create mode 100644 tests/data/slapd-bdb2-nis-master.conf create mode 100644 tests/data/slapd-bdb2-ref-slave.conf create mode 100644 tests/data/slapd-bdb2-repl-master.conf create mode 100644 tests/data/slapd-bdb2-repl-slave.conf create mode 100644 tests/data/slapd-nis-master.conf create mode 100644 tests/data/slapd-passwd.conf create mode 100644 tests/data/slapd-ref-slave.conf create mode 100755 tests/scripts/acfilter.sh create mode 100755 tests/scripts/passwd-search delete mode 100755 tests/scripts/test001-ldif2ldbm diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000000..a4c7025afa --- /dev/null +++ b/Makefile.in @@ -0,0 +1,30 @@ +# $OpenLDAP$ +# Master Makefile for OpenLDAP +## +## Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA +## All rights reserved. +## +## Redistribution and use in source and binary forms are permitted only +## as authorized by the OpenLDAP Public License. A copy of this +## license is available at http://www.OpenLDAP.org/license.html or +## in file LICENSE in the top-level directory of the distribution. +## + +SUBDIRS= include libraries clients servers tests doc +CLEANDIRS= contrib +INSTALLDIRS= + +makefiles: FORCE + ./config.status + +# force a make all before make install +# only done at the top-level +install-common: all FORCE + +clean-local: FORCE + $(RM) config.log + +veryclean-local: FORCE + $(RM) config.cache config.status libtool stamp-h stamp-h.in + +distclean: veryclean FORCE diff --git a/acconfig.h b/acconfig.h new file mode 100644 index 0000000000..9c89097b37 --- /dev/null +++ b/acconfig.h @@ -0,0 +1,89 @@ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _LDAP_PORTABLE_H +#define _LDAP_PORTABLE_H + +/* end of preamble */ +@TOP@ + +/* define this if needed to get reentrant functions */ +#ifndef REENTRANT +#undef REENTRANT +#endif +#ifndef _REENTRANT +#undef _REENTRANT +#endif + +/* define this if needed to get threadsafe functions */ +#ifndef THREADSAFE +#undef THREADSAFE +#endif +#ifndef _THREADSAFE +#undef _THREADSAFE +#endif +#ifndef THREAD_SAFE +#undef THREAD_SAFE +#endif +#ifndef _THREAD_SAFE +#undef _THREAD_SAFE +#endif + +#ifndef _SGI_MP_SOURCE +#undef _SGI_MP_SOURCE +#endif + +/* define this if TIOCGWINSZ is defined in sys/ioctl.h */ +#undef GWINSZ_IN_SYS_IOCTL + +/* These are defined in ldap_features.h */ +/* + LDAP_API_FEATURE_X_OPENLDAP_REENTRANT + LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE + LDAP_API_FEATURE_X_OPENLDAP_V2_DNS + LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS +*/ + +/* These are defined in lber_types.h */ +/* + LBER_INT_T + LBER_LEN_T + LBER_SOCKET_T + LBER_TAG_T +*/ + + +/* Leave that blank line there!! Autoheader needs it. */ + +@BOTTOM@ +/* begin of postamble */ + +#ifndef __NEED_PROTOTYPES +/* force LDAP_P to always include prototypes */ +#define __NEED_PROTOTYPES 1 +#endif + +#ifdef HAVE_STDDEF_H +# include +#endif + +#if defined(LDAP_DEVEL) && !defined(LDAP_TEST) +#define LDAP_TEST +#endif +#if defined(LDAP_TEST) && !defined(LDAP_DEBUG) +#define LDAP_DEBUG +#endif + +#include "ldap_cdefs.h" +#include "ldap_features.h" + +#include "ac/assert.h" + +#endif /* _LDAP_PORTABLE_H */ diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000000..35f9931fee --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,8 @@ +dnl $OpenLDAP$ +dnl +dnl Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. +dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file +dnl +dnl OpenLDAP Autoconf Macros +dnl +builtin(include, build/openldap.m4)dnl diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000000..008ce71664 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,695 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4a + +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +dnl $OpenLDAP$ +dnl +dnl Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. +dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file +dnl +dnl OpenLDAP Autoconf Macros +dnl +builtin(include, build/openldap.m4)dnl + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 1 + +dnl Usage: +dnl AM_INIT_AUTOMAKE(package,version, [no-define]) + +AC_DEFUN(AM_INIT_AUTOMAKE, +[AC_REQUIRE([AC_PROG_INSTALL]) +dnl We require 2.13 because we rely on SHELL being computed by configure. +AC_PREREQ([2.13]) +PACKAGE=[$1] +AC_SUBST(PACKAGE) +VERSION=[$2] +AC_SUBST(VERSION) +dnl test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi +ifelse([$3],, +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) +AC_REQUIRE([AM_SANITY_CHECK]) +AC_REQUIRE([AC_ARG_PROGRAM]) +dnl FIXME This is truly gross. +missing_dir=`cd $ac_aux_dir && pwd` +AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) +AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) +dnl Set install_sh for make dist +install_sh="$missing_dir/install-sh" +test -f "$install_sh" || install_sh="$missing_dir/install.sh" +AC_SUBST(install_sh) +dnl We check for tar when the user configures the end package. +dnl This is sad, since we only need this for "dist". However, +dnl there's no other good way to do it. We prefer GNU tar if +dnl we can find it. If we can't find a tar, it doesn't really matter. +AC_CHECK_PROGS(AMTAR, gnutar gtar tar) +dnl We need awk for the "check" target. The system "awk" is bad on +dnl some platforms. +AC_REQUIRE([AC_PROG_AWK]) +AMTARFLAGS= +if test -n "$AMTAR"; then + if $SHELL -c "$AMTAR --version" > /dev/null 2>&1; then + dnl We have GNU tar. + AMTARFLAGS=o + fi +fi +AC_SUBST(AMTARFLAGS) +AC_REQUIRE([AC_PROG_MAKE_SET])]) + +# +# Check to make sure that the build environment is sane. +# + +AC_DEFUN(AM_SANITY_CHECK, +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "[$]*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "[$]*" != "X $srcdir/configure conftestfile" \ + && test "[$]*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "[$]2" = conftestfile + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +rm -f conftest* +AC_MSG_RESULT(yes)]) + +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) +dnl The program must properly implement --version. +AC_DEFUN(AM_MISSING_PROG, +[AC_MSG_CHECKING(for working $2) +# 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. +if ($2 --version) < /dev/null > /dev/null 2>&1; then + $1=$2 + AC_MSG_RESULT(found) +else + $1="$3/missing $2" + AC_MSG_RESULT(missing) +fi +AC_SUBST($1)]) + + +# serial 40 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +AC_DEFUN(AC_LIBTOOL_SETUP, +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_RANLIB])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$host" in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +]) +esac +]) + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN(AC_PROG_LD, +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_SUBST(LD) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +AC_SUBST(NM) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$host" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library, adds --enable-ltdl-convenience to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case "$enable_ltdl_convenience" in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library, and adds --enable-ltdl-install to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + + +# serial 1 + +# @defmac AC_PROG_CC_STDC +# @maindex PROG_CC_STDC +# @ovindex CC +# If the C compiler in not in ANSI C mode by default, try to add an option +# to output variable @code{CC} to make it so. This macro tries various +# options that select ANSI C on some system or another. It considers the +# compiler to be in ANSI C mode if it handles function prototypes correctly. +# +# If you use this macro, you should check after calling it whether the C +# compiler has been set to accept ANSI C; if not, the shell variable +# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source +# code in ANSI C, you can make an un-ANSIfied copy of it by using the +# program @code{ansi2knr}, which comes with Ghostscript. +# @end defmac + +AC_DEFUN(AM_PROG_CC_STDC, +[AC_REQUIRE([AC_PROG_CC]) +AC_BEFORE([$0], [AC_C_INLINE]) +AC_BEFORE([$0], [AC_C_CONST]) +dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require +dnl a magic option to avoid problems with ANSI preprocessor commands +dnl like #elif. +dnl FIXME: can't do this because then AC_AIX won't work due to a +dnl circular dependency. +dnl AC_BEFORE([$0], [AC_PROG_CPP]) +AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) +AC_CACHE_VAL(am_cv_prog_cc_stdc, +[am_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + AC_TRY_COMPILE( +[#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +], [ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; +], +[am_cv_prog_cc_stdc="$ac_arg"; break]) +done +CC="$ac_save_CC" +]) +if test -z "$am_cv_prog_cc_stdc"; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT($am_cv_prog_cc_stdc) +fi +case "x$am_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $am_cv_prog_cc_stdc" ;; +esac +]) + +dnl From Jim Meyering. + +# serial 1 + +AC_DEFUN(AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL, +[AC_REQUIRE([AM_SYS_POSIX_TERMIOS]) + AC_CACHE_CHECK([whether use of TIOCGWINSZ requires sys/ioctl.h], + am_cv_sys_tiocgwinsz_needs_sys_ioctl_h, + [am_cv_sys_tiocgwinsz_needs_sys_ioctl_h=no + + gwinsz_in_termios_h=no + if test $am_cv_sys_posix_termios = yes; then + AC_EGREP_CPP([yes], + [#include +# include +# ifdef TIOCGWINSZ + yes +# endif + ], gwinsz_in_termios_h=yes) + fi + + if test $gwinsz_in_termios_h = no; then + AC_EGREP_CPP([yes], + [#include +# include +# ifdef TIOCGWINSZ + yes +# endif + ], am_cv_sys_tiocgwinsz_needs_sys_ioctl_h=yes) + fi + ]) + if test $am_cv_sys_tiocgwinsz_needs_sys_ioctl_h = yes; then + AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1, + [Define if TIOCGWINSZ requires sys/ioctl.h]) + fi +]) + +dnl From Jim Meyering. + +# serial 1 + +AC_DEFUN(AM_SYS_POSIX_TERMIOS, +[AC_CACHE_CHECK([POSIX termios], am_cv_sys_posix_termios, + [AC_TRY_LINK([#include +#include +#include ], + [/* SunOS 4.0.3 has termios.h but not the library calls. */ + tcgetattr(0, 0);], + am_cv_sys_posix_termios=yes, + am_cv_sys_posix_termios=no)]) +]) + +# From Ulrich Drepper. + +# serial 1 + +AC_DEFUN(AM_TYPE_PTRDIFF_T, + [AC_CACHE_CHECK([for ptrdiff_t], am_cv_type_ptrdiff_t, + [AC_TRY_COMPILE([#include ], [ptrdiff_t p], + am_cv_type_ptrdiff_t=yes, am_cv_type_ptrdiff_t=no)]) + if test $am_cv_type_ptrdiff_t = yes; then + AC_DEFINE(HAVE_PTRDIFF_T,1,[Define if system has ptrdiff_t type]) + fi +]) + diff --git a/build/db.2.x.README b/build/db.2.x.README new file mode 100644 index 0000000000..0b6cfdbf29 --- /dev/null +++ b/build/db.2.x.README @@ -0,0 +1,29 @@ +Berkeley DB version 2.x and OpenLDAP running threads +==================================================== + +Special care has to be taken when building Berkeley DB 2.x +for use with OpenLDAP as an slapd backend. If OpenLDAP is used +with threads, so must Berkeley DB. If OpenLDAP is built without +threads, so must Berkeley DB. In general, you should use +the latest Sleepycat version. + +The configuration tool of Sleepycat's Berkeley DB will automatically +set appropriate options on IRIX, OSF/1, and SUN Solaris platforms +(version 2.3.16), as well as FreeBSD (version 2.7.5). The options +must be manually defined on other plaforms, e.g. on LINUX. + +On PC-LINUX (kernel version 2.0.35, linux kernel threads as imple- +mented by libpthreads.so.1.60.4) with gcc as the standard compiler +the environment variable CPPFLAGS must define -D_REENTRANT, while +building the Berkeley DB package. + +DO NOT USE THE -ansi CFLAG, SINCE THEN THE DB PACKAGE'S CONFIGURE +CANNOT FIND THE X86/GCC SPINLOCKS, WHICH ARE NEEDED FOR THREAD- +SUPPORT WITH THE BERKELEY DB. + +Please check carefully if your platform is not mentioned above. + +The OpenLDAP configure tool will most probably find the correct +configuration itself. No special action has to be taken +while building the OpenLDAP package. + diff --git a/build/dir.mk b/build/dir.mk index ebf4d813e7..7f163fdc0d 100644 --- a/build/dir.mk +++ b/build/dir.mk @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998,1999 The OpenLDAP Foundation ## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory ## of this package for details. diff --git a/build/info.mk b/build/info.mk new file mode 100644 index 0000000000..df9d94ddb4 --- /dev/null +++ b/build/info.mk @@ -0,0 +1,10 @@ +# $OpenLDAP$ +## Copyright 1998,1999 The OpenLDAP Foundation +## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory +## of this package for details. +##--------------------------------------------------------------------------- +## +## Makefile Template for Non-Source Directories +## + +Makefile: $(top_srcdir)/build/info.mk diff --git a/build/install-sh b/build/install-sh new file mode 100755 index 0000000000..c7348ecd25 --- /dev/null +++ b/build/install-sh @@ -0,0 +1,255 @@ +#! /bin/sh +# $OpenLDAP$ +## Copyright 1998,1999 The OpenLDAP Foundation +## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory +## of this package for details. +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=$mkdirprog + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' + ' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/build/lib-shared.mk b/build/lib-shared.mk new file mode 100644 index 0000000000..776972ac6d --- /dev/null +++ b/build/lib-shared.mk @@ -0,0 +1,25 @@ +# $OpenLDAP$ +## Copyright 1998,1999 The OpenLDAP Foundation +## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory +## of this package for details. +##--------------------------------------------------------------------------- +## +## Makefile Template for Shared Libraries +## + +COMPILE = $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c +MKDEPFLAG = -l + +.SUFFIXES: .c .o .lo + +.c.lo: + $(COMPILE) $< + +$(LIBRARY): version.lo + $(LTLIBLINK) -rpath $(libdir) -o $@ $(OBJS) version.lo + $(RM) ../$@; \ + (d=`$(PWD)` ; $(LN_S) `$(BASENAME) $$d`/$@ ../$@) + $(RM) ../`$(BASENAME) $@ .la`.a; \ + (d=`$(PWD)`; t=`$(BASENAME) $@ .la`.a; $(LN_S) `$(BASENAME) $$d`/.libs/$$t ../$$t) + +Makefile: $(top_srcdir)/build/lib-shared.mk diff --git a/build/lib-static.mk b/build/lib-static.mk new file mode 100644 index 0000000000..ad0d14669c --- /dev/null +++ b/build/lib-static.mk @@ -0,0 +1,16 @@ +# $OpenLDAP$ +## Copyright 1998,1999 The OpenLDAP Foundation +## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory +## of this package for details. +##--------------------------------------------------------------------------- +## +## Makefile Template for Static Libraries +## + +$(LIBRARY): version.o + $(AR) ru $@ $(OBJS) version.o + @$(RANLIB) $@; \ + $(RM) ../$@; \ + (d=`$(PWD)` ; $(LN_S) `$(BASENAME) $$d`/$@ ../$@) + +Makefile: $(top_srcdir)/build/lib-static.mk diff --git a/build/lib.mk b/build/lib.mk new file mode 100644 index 0000000000..9bf542d340 --- /dev/null +++ b/build/lib.mk @@ -0,0 +1,35 @@ +# $OpenLDAP$ +## Copyright 1998,1999 The OpenLDAP Foundation +## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory +## of this package for details. +##--------------------------------------------------------------------------- +## +## Makefile Template for Libraries +## + +all-common: $(LIBRARY) $(PROGRAMS) + +version.c: $(OBJS) + $(RM) $@ + $(MKVERSION) $(LIBRARY) > $@ + +install-common: FORCE + +lint: lint-local FORCE + $(LINT) $(DEFS) $(DEFINES) $(SRCS) + +lint5: lint5-local FORCE + $(5LINT) $(DEFS) $(DEFINES) $(SRCS) + +clean-common: FORCE + $(RM) $(LIBRARY) ../$(LIBRARY) $(XLIBRARY) \ + $(PROGRAMS) $(XPROGRAMS) $(XSRCS) $(XXSRCS) \ + *.o *.lo a.out core version.c .libs/* + +depend-common: FORCE + $(MKDEP) $(DEFS) $(DEFINES) $(SRCS) $(XXSRCS) + +lint-local: FORCE +lint5-local: FORCE + +Makefile: $(top_srcdir)/build/lib.mk diff --git a/build/man.mk b/build/man.mk index ce0015fdc9..91a96065cb 100644 --- a/build/man.mk +++ b/build/man.mk @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998,1999 The OpenLDAP Foundation ## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory ## of this package for details. diff --git a/build/mkdep b/build/mkdep index 006f05abbc..55ef1e4c50 100755 --- a/build/mkdep +++ b/build/mkdep @@ -1,5 +1,10 @@ -#!/bin/sh - +#! /bin/sh - +# $OpenLDAP$ +## Copyright 1998,1999 The OpenLDAP Foundation +## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory +## of this package for details. # +# Portions # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # @@ -25,29 +30,52 @@ set -e # exit immediately if any errors occur MAKE=Makefile # default makefile name is "Makefile" NOSLASH="no" # by default, / dependencies are included -CC=cc # default compiler is cc +SRCDIR="" +SED=cat + +: ${CC=cc} # use cc by default + +# We generally set these via the command line options +: ${MKDEP_CC=$CC} # select default compiler to generate dependencies +: ${MKDEP_CFLAGS="-M"} # cc -M usually produces dependencies while : do case "$1" in + # the -s flag removes dependencies to files that begin with / + -s) + NOSLASH=yes; + shift ;; + # -f allows you to select a makefile name -f) MAKE=$2 shift; shift ;; - # -c allows you to select a compiler to use (default is cc) + # -d allows you to select a VPATH directory + -d) + SRCDIR=$2 + shift; shift ;; + + # -c allows you to override the compiler used to generate dependencies -c) - CC=$2 + MKDEP_CC=$2 + shift; shift ;; + + # -m allows you to override the compiler flags used to generate + # dependencies. + -m) + MKDEP_CFLAGS=$2 shift; shift ;; # the -p flag produces "program: program.c" style dependencies # so .o's don't get produced -p) - SED='s;\.o;;' + SED='sed -e s;\.o;;' shift ;; - # the -s flag removes dependencies to files that begin with / - -s) - NOSLASH=yes; + # the -l flag produces libtool compatible dependencies + -l) + SED='sed -e s;\.o:;.lo:;' shift ;; # -*) shift ;; @@ -57,19 +85,19 @@ while : esac done -if [ $# = 0 ] ; then - echo 'usage: mkdep [-p] [-f makefile] [flags] file ...' +if test $# = 0 ; then + echo 'usage: mkdep [-p] [-s] [-c cc] [-m flags] [-f makefile] [-d srcdir] [cppflags] file ...' exit 1 fi -if [ ! -w $MAKE ]; then +if test ! -w $MAKE ; then echo "mkdep: no writeable file \"$MAKE\"" exit 1 fi TMP=/tmp/mkdep$$ -trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 +trap 'rm -f $TMP.sed $TMP ; exit 1' 1 2 3 13 15 cp $MAKE ${MAKE}.bak @@ -89,38 +117,60 @@ _EOF_ # egrep '^#include[ ]*".*"' /dev/null $* | # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' | -$CC -M $* | -sed " - s; \./; ;g - $SED" | +if test "x$SRCDIR" = "x" ; then + files=$* +else + files= + for i in $* ; do + if test -f $i ; then + files="$files $i" + elif test -f $SRCDIR/$i ; then + files="$files $SRCDIR/$i" + else + files="$files $i" + fi + done + + MKDEP_CFLAGS="$MKDEP_CFLAGS -I$SRCDIR" +fi + +cat << _EOF_ >> $TMP + +# +# files: $* +# command: $MKDEP_CC $MKDEP_CFLAGS $files +# + +_EOF_ + +$MKDEP_CC $MKDEP_CFLAGS $files | \ + sed -e 's; \./; ;g' | \ + $SED > $TMP.sed +# do not pipe to awk. SGI awk wants a filename as argument. +# (or '-', but I do not know if all other awks support that.) awk ' -$1 ~ /:/ { +$1 ~ /:$/ { filenm=$1 - dep=$2 + dep=substr($0, length(filenm)+1) } -$1 !~ /:/ { - dep=$1 +$1 !~ /:$/ { + dep=$0 } /.*/ { - if ( noslash = "yes" && dep ~ /^\// ) next - if (filenm != prev) { - if (rec != "") - print rec; - rec = filenm " " dep; - prev = filenm; + if ( length(filenm) < 2 ) next + if ( filenm ~ /:.*:$/ ) next + split(dep, depends, " ") + for(d in depends) { + dfile = depends[d] + if ( length(dfile) < 2 ) continue + if ( dfile ~ /:/ ) continue + if (( noslash == "yes") && (dfile ~ /^\// )) continue + rec = filenm " " dfile + print rec } - else { - if (length(rec dep) > 78) { - print rec; - rec = filenm " " dep; - } - else - rec = rec " " dep - } - } -END { - print rec -}' noslash="$NOSLASH" >> $TMP +} +' noslash="$NOSLASH" $TMP.sed >> $TMP + cat << _EOF_ >> $TMP @@ -129,5 +179,5 @@ _EOF_ # copy to preserve permissions cp $TMP $MAKE -rm -f ${MAKE}.bak $TMP +rm -f ${MAKE}.bak $TMP.sed $TMP exit 0 diff --git a/build/mkrelease b/build/mkrelease index 6cdd3d0f8d..c694984f3c 100755 --- a/build/mkrelease +++ b/build/mkrelease @@ -1,4 +1,5 @@ #! /bin/sh +# $OpenLDAP$ ## Copyright 1998,1999 The OpenLDAP Foundation ## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory ## of this package for details. diff --git a/build/mkversion b/build/mkversion new file mode 100755 index 0000000000..d0ba1373a1 --- /dev/null +++ b/build/mkversion @@ -0,0 +1,58 @@ +#! /bin/sh +# $OpenLDAP$ +## Copyright 1998,1999 The OpenLDAP Foundation +## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory +## of this package for details. +# +# Create a version.c file +# +PACKAGE=OpenLDAP +VERSION=unknown +SYMBOL=__Version +static=static +const=const +while : + do case "$1" in + -p) + PACKAGE=$2 + shift; shift ;; + -v) + VERSION=$2 + shift; shift ;; + + -c) + const= + shift ;; + -n) + SYMBOL=$2 + shift; shift ;; + -s) + static= + shift ;; + +# -*) shift ;; + *) + break ;; + esac +done + +if test $# != 1 ; then + echo 'usage: mkversion [-c] [-s] [-p package] [-v version] application' + exit 1 +fi + +APPLICATION=$1 +WHEN=`date` +WHOWHERE="$USER@`uname -n`:`pwd`" + +cat << __EOF__ +/* + * Copyright 1998,1999 The OpenLDAP Foundation + * COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory + * of this package for details. + */ + +$static $const char $SYMBOL[] = +"@(#) \$$PACKAGE: $APPLICATION $VERSION ($WHEN) \$\n\t$WHOWHERE\n"; + +__EOF__ diff --git a/build/mod.mk b/build/mod.mk index 9c83d23a31..380e1dc78c 100644 --- a/build/mod.mk +++ b/build/mod.mk @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998,1999 The OpenLDAP Foundation ## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory ## of this package for details. diff --git a/build/openldap.m4 b/build/openldap.m4 index 0c3b675401..4ceadfe3e1 100644 --- a/build/openldap.m4 +++ b/build/openldap.m4 @@ -1,3 +1,5 @@ +dnl $OpenLDAP$ +dnl dnl Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file dnl @@ -605,6 +607,27 @@ fi ]) dnl dnl ==================================================================== +dnl Check GNU Pth pthread Header +dnl +dnl defines ol_cv_header linux_threads to 'yes' or 'no' +dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h +dnl doesn't exists. Existance of pthread.h should separately +dnl checked. +dnl +AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [ + AC_CACHE_CHECK([for GNU Pth pthread.h], + [ol_cv_header_gnu_pth_pthread_h], + [AC_EGREP_CPP(__gnu_pth__, + [#include +#ifdef _POSIX_THREAD_IS_GNU_PTH + __gnu_pth__ +#endif +], + [ol_cv_header_gnu_pth_pthread_h=yes], + [ol_cv_header_gnu_pth_pthread_h=no]) + ]) +])dnl +dnl ==================================================================== dnl Check LinuxThreads Header dnl dnl defines ol_cv_header linux_threads to 'yes' or 'no' diff --git a/build/rules.mk b/build/rules.mk index b2d3d9f2be..4f795ff353 100644 --- a/build/rules.mk +++ b/build/rules.mk @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998,1999 The OpenLDAP Foundation ## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory ## of this package for details. diff --git a/build/srv.mk b/build/srv.mk index c72254cd1a..ee6d5daa27 100644 --- a/build/srv.mk +++ b/build/srv.mk @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998,1999 The OpenLDAP Foundation ## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory ## of this package for details. diff --git a/build/top.mk b/build/top.mk index ff7fe5a46c..9dc7dcdce0 100644 --- a/build/top.mk +++ b/build/top.mk @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA ## All rights reserved. ## diff --git a/build/version b/build/version index b981f4806c..44640502d9 100644 --- a/build/version +++ b/build/version @@ -1 +1 @@ -2.0-Engineering +2.0-alpha3 diff --git a/clients/Makefile.in b/clients/Makefile.in new file mode 100644 index 0000000000..29f8931285 --- /dev/null +++ b/clients/Makefile.in @@ -0,0 +1,7 @@ +# $OpenLDAP$ +## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved. +## COPYING RESTRICTIONS APPLY, See COPYRIGHT file +## +## Clients Makefile.in for OpenLDAP + +SUBDIRS= tools ud finger gopher mail500 fax500 rcpt500 diff --git a/clients/fax500/Makefile.in b/clients/fax500/Makefile.in index 1955d9d411..4520a63ef6 100644 --- a/clients/fax500/Makefile.in +++ b/clients/fax500/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + PROGRAMS= rp500 fax500 xrpcomp.tmp SRCS= main.c faxtotpc.c rp500.c diff --git a/clients/fax500/fax500.h b/clients/fax500/fax500.h new file mode 100644 index 0000000000..f494e107b6 --- /dev/null +++ b/clients/fax500/fax500.h @@ -0,0 +1,11 @@ +/* $OpenLDAP$ */ +#ifndef FAX500_H +#define FAX500_H 1 + +/* in faxtotpc.c */ +void strip_nonnum ( char *str ); +char *remove_parens( char *ibuf, char *obuf ); +char *munge_phone ( char *ibuf, char *obuf ); +char *faxtotpc ( char *phone, char *userinfo ); + +#endif diff --git a/clients/fax500/faxtotpc.c b/clients/fax500/faxtotpc.c index d4631b43e6..1579c84fde 100644 --- a/clients/fax500/faxtotpc.c +++ b/clients/fax500/faxtotpc.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1993 Regents of the University of Michigan. * All rights reserved. @@ -13,29 +14,28 @@ * Routines for parsing the facsimileTelephoneNumber field out of * an X.500 entry and converting it to a "tpc.int" domain name. * - * char *faxtotpc(str) - * char *str; + * char *faxtotpc( char *str, char *userinfo) * * faxtotpc() returns a pointer to a string allocated with malloc(3). */ +#include "portable.h" + #include -#include -#include -#include -#ifdef ultrix -extern char *strdup(); -#endif +#include +#include +#include +#include "fax500.h" #define TPCDOMAIN "tpc.int" /* * Remove everything from 'str' which is not a digit */ -void strip_nonnum(str) -char *str; +void +strip_nonnum( char *str ) { char *p, *q; p = q = str; @@ -61,9 +61,8 @@ char *str; * Remove anything of the form (blah) where * "blah" contains a non-numeric character. */ -char *remove_parens(ibuf, obuf) -char *ibuf; -char *obuf; +char * +remove_parens( char *ibuf, char *obuf ) { char *p = ibuf; char *q = obuf; @@ -132,9 +131,8 @@ char *obuf; * 6 93 * 8 99 */ -char *munge_phone(ibuf, obuf) -char *ibuf; -char *obuf; +char * +munge_phone( char *ibuf, char *obuf ) { #define UMAREACODE "1313" @@ -176,17 +174,11 @@ char *obuf; - - - - - /* * Convert string to "tpc.int" domain name. */ -char *faxtotpc(phone, userinfo) -char *phone; -char *userinfo; +char * +faxtotpc( char *phone, char *userinfo ) { char *p; char *q; @@ -244,5 +236,4 @@ char *userinfo; strcat(obuf, TPCDOMAIN); /* tack on domain name */ p = strdup(obuf); return(p); - } diff --git a/clients/fax500/main.c b/clients/fax500/main.c index 5bc84f2fb8..b94a1a6215 100644 --- a/clients/fax500/main.c +++ b/clients/fax500/main.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. @@ -121,7 +122,7 @@ static void add_to(char ***list, int *nlist, char **new); static int isgroup(LDAPMessage *e); static void add_error(Error **err, int *nerr, int code, char *addr, LDAPMessage *msg); static void add_group(char *dn, Group **list, int *nlist); -static void unbind_and_exit(int rc); +static void unbind_and_exit(int rc) LDAP_GCCATTR((noreturn)); static int group_loop(char *dn); static void send_group(Group *group, int ngroup); static int has_attributes(LDAPMessage *e, char *attr1, char *attr2); diff --git a/clients/fax500/rp500.c b/clients/fax500/rp500.c index bc80325305..e957483a80 100644 --- a/clients/fax500/rp500.c +++ b/clients/fax500/rp500.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. diff --git a/clients/finger/Makefile.in b/clients/finger/Makefile.in index 4795e63924..613bda9e40 100644 --- a/clients/finger/Makefile.in +++ b/clients/finger/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + SRCS= main.c XSRCS= version.c OBJS= main.o diff --git a/clients/finger/main.c b/clients/finger/main.c index 63b77e9a4b..5e84fe4916 100644 --- a/clients/finger/main.c +++ b/clients/finger/main.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1990,1994 Regents of the University of Michigan. * All rights reserved. diff --git a/clients/gopher/Makefile.in b/clients/gopher/Makefile.in index b010e426d1..a9d5e4ee94 100644 --- a/clients/gopher/Makefile.in +++ b/clients/gopher/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## ## Makefile for gopher clients ## diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c index 9bf49a252c..e8342fc4a6 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. @@ -62,10 +63,10 @@ char *templatefile = TEMPLATEFILE; char myhost[MAXHOSTNAMELEN]; int myport; -static void usage ( char *name ); +static void usage ( char *name ) LDAP_GCCATTR((noreturn)); static int set_socket (int port); static RETSIGTYPE wait4child(int sig); -static void do_queries (int s); +static void do_queries (int s) LDAP_GCCATTR((noreturn)); static void do_error (FILE *fp, char *s); static void do_search (LDAP *ld, FILE *fp, char *buf); static void do_read (LDAP *ld, FILE *fp, char *dn); diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index 24b627f02b..c1c5ab4a9e 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. @@ -63,10 +64,10 @@ char *templatefile = TEMPLATEFILE; char *friendlyfile = FRIENDLYFILE; int rdncount = GO500GW_RDNCOUNT; -static void usage ( char *name ); +static void usage ( char *name ) LDAP_GCCATTR((noreturn)); static int set_socket (int port); static RETSIGTYPE wait4child(int sig); -static void do_queries (int s); +static void do_queries (int s) LDAP_GCCATTR((noreturn)); static char *pick_oc ( char **oclist ); static int isnonleaf ( LDAP *ld, char **oclist, char *dn ); static void do_menu (LDAP *ld, FILE *fp, char *dn); diff --git a/clients/mail500/Makefile.in b/clients/mail500/Makefile.in index 453d1199c7..38b61fd404 100644 --- a/clients/mail500/Makefile.in +++ b/clients/mail500/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + PROGRAMS= mail500 SRCS= main.c diff --git a/clients/mail500/main.c b/clients/mail500/main.c index 678663805d..064ed64c34 100644 --- a/clients/mail500/main.c +++ b/clients/mail500/main.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. @@ -178,7 +179,7 @@ static void add_to( char ***list, int *nlist, char **new ); static void add_single_to( char ***list, char *new ); static int isgroup( LDAPMessage *e ); static void add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg ); -static void unbind_and_exit( int rc ); +static void unbind_and_exit( int rc ) LDAP_GCCATTR((noreturn)); static void send_group( Group *group, int ngroup ); static int connect_to_x500( void ); @@ -1829,7 +1830,3 @@ unbind_and_exit( int rc ) exit( rc ); } - - - - diff --git a/clients/rcpt500/Makefile.in b/clients/rcpt500/Makefile.in index fc2ddaa88d..5af6536f91 100644 --- a/clients/rcpt500/Makefile.in +++ b/clients/rcpt500/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + PROGRAMS= rcpt500 SRCS= main.c cmds.c help.c query.c XSRCS= version.c diff --git a/clients/rcpt500/cmds.c b/clients/rcpt500/cmds.c index fe89309567..8e33658a33 100644 --- a/clients/rcpt500/cmds.c +++ b/clients/rcpt500/cmds.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * cmds.c: command table for rcpt500 (X.500 email query responder) * @@ -6,7 +7,9 @@ * All Rights Reserved */ -#include +#include "portable.h" + +#include #include "rcpt500.h" struct command cmds[] = { diff --git a/clients/rcpt500/help.c b/clients/rcpt500/help.c index 0f541ab9be..76dca44f8f 100644 --- a/clients/rcpt500/help.c +++ b/clients/rcpt500/help.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * help.c: for rcpt500 (X.500 email query responder) * @@ -6,22 +7,24 @@ * All Rights Reserved */ +#include "portable.h" + #include -#include -#include + +#include +#include +#include + +#ifdef HAVE_FCNTL_H #include +#endif -#include "portable.h" -#include "ldapconfig.h" +#include "ldap_defaults.h" #include "rcpt500.h" -extern int dosyslog; - int -help_cmd( msgp, reply ) - struct msginfo *msgp; - char *reply; +help_cmd(struct msginfo *msgp, char *reply) { int fd, len; diff --git a/clients/rcpt500/main.c b/clients/rcpt500/main.c index 74fe9d088d..afabd89322 100644 --- a/clients/rcpt500/main.c +++ b/clients/rcpt500/main.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * main.c: for rcpt500 (X.500 email query responder) * diff --git a/clients/rcpt500/query.c b/clients/rcpt500/query.c index dac5f15fc9..157b5a4baf 100644 --- a/clients/rcpt500/query.c +++ b/clients/rcpt500/query.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * query.c: for rcpt500 (X.500 email query responder) * diff --git a/clients/rcpt500/rcpt500.h b/clients/rcpt500/rcpt500.h index 537f92c1c4..068af6026b 100644 --- a/clients/rcpt500/rcpt500.h +++ b/clients/rcpt500/rcpt500.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * rcpt500.h: includes for rcpt500 (X.500 email query responder) * @@ -6,6 +7,10 @@ * All Rights Reserved */ +#include + +LDAP_BEGIN_DECL + struct msginfo { char *msg_subject; char *msg_replyto; /* actually could be from From: line */ @@ -16,8 +21,9 @@ struct msginfo { }; struct command { - char *cmd_text; /* text for command, e.g. "HELP" */ - int (*cmd_handler)(); /* pointer to handler function */ + char *cmd_text; /* text for command, e.g. "HELP" */ + /* pointer to handler function */ + int (*cmd_handler) LDAP_P((struct msginfo *msgp, char *reply)); }; @@ -27,10 +33,28 @@ struct command { /* * functions */ -int help_cmd(); -int query_cmd(); +int help_cmd LDAP_P((struct msginfo *msgp, char *reply)); +int query_cmd LDAP_P((struct msginfo *msgp, char *reply)); /* * externs */ + +/* cmds.c */ extern struct command cmds[]; +/* main.c */ +extern int dosyslog; +#ifdef LDAP_CONNECTIONLESS +extern int do_cldap; +#endif +extern int derefaliases; +extern int sizelimit; +extern int rdncount; +extern int ldapport; +extern char *ldaphost; +extern char *searchbase; +extern char *dapuser; +extern char *filterfile; +extern char *templatefile; + +LDAP_END_DECL diff --git a/clients/tools/Makefile.in b/clients/tools/Makefile.in index cfd882e582..11acdd9cff 100644 --- a/clients/tools/Makefile.in +++ b/clients/tools/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## ## Makefile for LDAP tools ## diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index 4eab6b1489..54778c42c8 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -1,4 +1,5 @@ /* ldapdelete.c - simple program to delete an entry using LDAP */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -20,7 +21,6 @@ static char *binddn = NULL; static char *passwd = NULL; -static char *base = NULL; static char *ldaphost = NULL; static int ldapport = 0; static int not, verbose, contoper; @@ -158,6 +158,9 @@ main( int argc, char **argv ) ldap_set_option( ld, LDAP_OPT_DEREF, &deref ); } + /* don't chase referrals */ + ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + if (want_bindpw) passwd = getpass("Enter LDAP Password: "); @@ -194,12 +197,12 @@ main( int argc, char **argv ) } } + rc = 0; if ( fp == NULL ) { for ( ; optind < argc; ++optind ) { rc = dodelete( ld, argv[ optind ] ); } } else { - rc = 0; while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) { buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ if ( *buf != '\0' ) { diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 729a6d1cd8..043d3bbc3d 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -60,7 +61,7 @@ static LDAP *ld; #define T_NEWSUPSTR "newsuperior" -static void usage LDAP_P(( const char *prog )); +static void usage LDAP_P(( const char *prog )) LDAP_GCCATTR((noreturn)); static int process_ldapmod_rec LDAP_P(( char *rbuf )); static int process_ldif_rec LDAP_P(( char *rbuf, int count )); static void addmodifyop LDAP_P(( LDAPMod ***pmodsp, int modop, char *attr, @@ -251,6 +252,8 @@ main( int argc, char **argv ) int deref = LDAP_DEREF_NEVER; ldap_set_option( ld, LDAP_OPT_DEREF, &deref); } + /* don't chase referrals */ + ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); if (want_bindpw) passwd = getpass("Enter LDAP Password: "); @@ -460,6 +463,7 @@ process_ldif_rec( char *rbuf, int count ) goto end_line; } else if ( strcasecmp( type, T_MODOPREPLACESTR ) == 0 ) { modop = LDAP_MOD_REPLACE; + addmodifyop( &pmods, modop, value, NULL, 0 ); goto end_line; } else if ( strcasecmp( type, T_MODOPDELETESTR ) == 0 ) { modop = LDAP_MOD_DELETE; diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index 51b9719724..3bc2e3140d 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -32,7 +33,6 @@ static char *binddn = NULL; static char *passwd = NULL; -static char *base = NULL; static char *ldaphost = NULL; static int ldapport = 0; static int not, verbose, contoper; @@ -210,6 +210,9 @@ main(int argc, char **argv) int deref = LDAP_DEREF_NEVER; ldap_set_option( ld, LDAP_OPT_DEREF, &deref); } + /* don't chase referrals */ + ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); + if (want_bindpw) passwd = getpass("Enter LDAP Password: "); diff --git a/clients/tools/ldappasswd.c b/clients/tools/ldappasswd.c index 6ced63a274..98aa570fed 100644 --- a/clients/tools/ldappasswd.c +++ b/clients/tools/ldappasswd.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -68,7 +69,7 @@ Salt; typedef struct hash_t { - char *name; + const char *name; unsigned int namesz; char *(*func) (const char *, Salt *); unsigned char takes_salt; @@ -89,7 +90,7 @@ static int auto_gen_pw = 0; * pw_encode() essentially base64 encodes a password and its salt */ -char * +static char * pw_encode (unsigned char *passwd, Salt * salt, unsigned int len) { int salted = salt && salt->salt && salt->len; @@ -123,7 +124,7 @@ pw_encode (unsigned char *passwd, Salt * salt, unsigned int len) * if you'd like to write a better salt generator, please, be my guest. */ -void +static void make_salt (Salt * salt, unsigned int len) { @@ -141,7 +142,7 @@ make_salt (Salt * salt, unsigned int len) * password generator */ -char * +static char * gen_pass (unsigned int len) { static const unsigned char autogen[] = @@ -160,7 +161,7 @@ gen_pass (unsigned int len) } #ifdef SLAPD_CLEARTEXT -char * +static char * hash_none (const char *pw_in, Salt * salt) { return (strdup (pw_in)); @@ -168,7 +169,7 @@ hash_none (const char *pw_in, Salt * salt) #endif #ifdef SLAPD_CRYPT -char * +static char * hash_crypt (const char *pw_in, Salt * salt) { static const unsigned char crypt64[] = @@ -198,7 +199,7 @@ hash_crypt (const char *pw_in, Salt * salt) } #endif -char * +static char * hash_md5 (const char *pw_in, Salt * salt) { lutil_MD5_CTX MD5context; @@ -214,7 +215,7 @@ hash_md5 (const char *pw_in, Salt * salt) return (pw_encode (MD5digest, salt, sizeof (MD5digest))); } -char * +static char * hash_sha1 (const char *pw_in, Salt * salt) { lutil_SHA1_CTX SHA1context; @@ -230,7 +231,7 @@ hash_sha1 (const char *pw_in, Salt * salt) return (pw_encode (SHA1digest, salt, sizeof (SHA1digest))); } -static Hash hashes[] = +static const Hash hashes[] = { #ifdef SLAPD_CLEARTEXT {"none", 4, hash_none, 0, HASHTYPE_NONE, HASHTYPE_NONE, 0}, @@ -245,7 +246,7 @@ static Hash hashes[] = {NULL, 0, NULL, 0, HASHTYPE_NONE, HASHTYPE_NONE, 0} }; -int +static int modify_dn (LDAP * ld, char *targetdn, char *pwattr, char *oldpw, char *newpw, HashTypes htype, Salt * salt) { @@ -325,8 +326,8 @@ modify_dn (LDAP * ld, char *targetdn, char *pwattr, char *oldpw, return (ret); } -void -usage (char *s) +static void +usage(const char *s) { fprintf (stderr, "Usage: %s [options] [filter]\n", s); fprintf (stderr, " -a attrib\tpassword attribute (default: " LDAP_PASSWD_ATTRIB ")\n"); @@ -623,6 +624,8 @@ main (int argc, char *argv[]) int deref = LDAP_DEREF_NEVER; ldap_set_option( ld, LDAP_OPT_DEREF, &deref); } + /* don't chase referrals */ + ldap_set_option( ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF ); if (version != -1 && ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != LDAP_OPT_SUCCESS ) diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index d5d09d1848..1eba56399a 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -21,7 +22,7 @@ #define DEFSEP "=" static void -usage( char *s ) +usage( const char *s ) { fprintf( stderr, "usage: %s [options] filter [attributes...]\nwhere:\n" @@ -561,7 +562,8 @@ static int dosearch( } -void print_entry( +static void +print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly) @@ -679,7 +681,7 @@ void print_entry( } -int +static int write_ldif( int type, char *name, char *value, ber_len_t vallen ) { char *ldif; diff --git a/clients/ud/Makefile.in b/clients/ud/Makefile.in index 0eaf5667b8..54c16e29e1 100644 --- a/clients/ud/Makefile.in +++ b/clients/ud/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + SRCS= main.c find.c mod.c print.c auth.c util.c help.c \ string_to_key.c group.c edit.c globals.c XSRCS= version.c diff --git a/clients/ud/auth.c b/clients/ud/auth.c index 89580347bb..b757d78169 100644 --- a/clients/ud/auth.c +++ b/clients/ud/auth.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1991, 1992 Regents of the University of Michigan. * All rights reserved. @@ -294,17 +295,6 @@ auth( char *who, int implicit ) #define FIVEMINS ( 5 * 60 ) #define TGT "krbtgt" -static void -str2upper( char *s ) -{ - char *p; - - for ( p = s; *p != '\0'; ++p ) { - *p = TOUPPER( (unsigned char) *p ); - } -} - - static int valid_tgt( char **names ) { @@ -324,7 +314,7 @@ valid_tgt( char **names ) /* * realm must be uppercase for krb_ routines */ - str2upper( realm ); + ldap_pvt_str2upper( realm ); #endif /* HAVE_AFS_KERBEROS */ /* @@ -395,7 +385,7 @@ kinit( char *kname ) /* * realm must be uppercase for krb_ routines */ - str2upper( realm ); + ldap_pvt_str2upper( realm ); #endif /* HAVE_AFS_KERBEROS */ rc = krb_get_in_tkt( name, inst, realm, TGT, realm, diff --git a/clients/ud/edit.c b/clients/ud/edit.c index 997926c23d..67f2ed9a86 100644 --- a/clients/ud/edit.c +++ b/clients/ud/edit.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1994 Regents of the University of Michigan. * All rights reserved. diff --git a/clients/ud/find.c b/clients/ud/find.c index 3551c1af6d..5e8b865603 100644 --- a/clients/ud/find.c +++ b/clients/ud/find.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1991, 1992, 1993 * Regents of the University of Michigan. All rights reserved. @@ -10,31 +11,30 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#include -#include -#ifndef __STDC__ -#include -#endif + +#include + +#include +#include +#include + #include #include + #include "ud.h" -extern char *search_base; /* search base */ -extern int verbose; /* verbose mode flag */ -extern LDAP *ld; /* our ldap descriptor */ - static int num_picked = 0; /* used when user picks entry at More prompt */ -#ifdef DEBUG -extern int debug; /* debug flag */ -#endif -vrfy(dn) -char *dn; +int +vrfy( char *dn ) { LDAPMessage *results; static char *attrs[2] = { "objectClass", NULL }; + int ld_errno = 0; #ifdef DEBUG if (debug & D_TRACE) @@ -43,9 +43,12 @@ char *dn; /* verify that this DN exists in the directory */ (void) ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", attrs, TRUE, &results); (void) ldap_msgfree(results); - if ((ld->ld_errno == LDAP_NO_SUCH_OBJECT) || (ld->ld_errno == LDAP_INVALID_DN_SYNTAX)) + + ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno); + + if ((ld_errno == LDAP_NO_SUCH_OBJECT) || (ld_errno == LDAP_INVALID_DN_SYNTAX)) return(0); - else if (ld->ld_errno == LDAP_SUCCESS) + else if (ld_errno == LDAP_SUCCESS) return(1); else { ldap_perror(ld, "ldap_search"); @@ -54,11 +57,8 @@ char *dn; } -static LDAPMessage * disambiguate( result, matches, read_attrs, who ) -LDAPMessage *result; -int matches; -char **read_attrs; -char *who; +static LDAPMessage * +disambiguate( LDAPMessage *result, int matches, char **read_attrs, char *who ) { int choice; /* entry that user chooses */ int i; @@ -66,18 +66,21 @@ char *who; char response[SMALL_BUF_SIZE]; /* results from user */ char *name = NULL; /* DN to lookup */ LDAPMessage *mp; - extern void Free(); + int ld_errno = 0; #ifdef DEBUG if (debug & D_TRACE) printf("->disambiguate(%x, %d, %x, %s)\n", result, matches, read_attrs, who); #endif + + ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno); + /* * If we are here, it means that we got back multiple answers. */ - if ((ld->ld_errno == LDAP_TIMELIMIT_EXCEEDED) - || (ld->ld_errno == LDAP_SIZELIMIT_EXCEEDED)) { + if ((ld_errno == LDAP_TIMELIMIT_EXCEEDED) + || (ld_errno == LDAP_SIZELIMIT_EXCEEDED)) { if (verbose) { printf(" Your query was too general and a limit was exceeded. The results listed\n"); printf(" are not complete. You may want to try again with a more refined query.\n\n"); @@ -150,9 +153,8 @@ char *who; } } -LDAPMessage * find(who, quiet) -char *who; -int quiet; +LDAPMessage * +find( char *who, int quiet ) { register int i, j, k; /* general ints */ int matches; /* from ldap_count_entries() */ @@ -166,9 +168,6 @@ int quiet; char response[SMALL_BUF_SIZE]; char *cp, *dn, **rdns; LDAPFiltInfo *fi; - extern LDAPFiltDesc *lfdp; /* LDAP filter descriptor */ - extern struct attribute attrlist[]; /* complete list of attrs */ - extern void Free(); #ifdef DEBUG if (debug & D_TRACE) @@ -203,39 +202,45 @@ int quiet; * here. If we don't find it, treat it as NOT a UFN. */ if (strchr(who, ',') != NULL) { - int savederef; + int savederef, deref; #ifdef DEBUG if (debug & D_FIND) printf("\"%s\" appears to be a UFN\n", who); #endif - savederef = ld->ld_deref; - ld->ld_deref = LDAP_DEREF_FINDING; + ldap_get_option(ld, LDAP_OPT_DEREF, &savederef); + deref = LDAP_DEREF_FINDING; + ldap_set_option(ld, LDAP_OPT_DEREF, &deref); + if ((rc = ldap_ufn_search_s(ld, who, search_attrs, FALSE, &res)) != LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED && rc != LDAP_TIMELIMIT_EXCEEDED) { ldap_perror(ld, "ldap_ufn_search_s"); - ld->ld_deref = savederef; + ldap_set_option(ld, LDAP_OPT_DEREF, &savederef); return(NULL); } if ((matches = ldap_count_entries(ld, res)) < 0) { ldap_perror(ld, "ldap_count_entries"); - ld->ld_deref = savederef; + ldap_set_option(ld, LDAP_OPT_DEREF, &savederef); return(NULL); } else if (matches == 1) { - if (ldap_search_s(ld, ldap_get_dn(ld, ldap_first_entry(ld, res)), LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) { - if (ld->ld_errno == LDAP_UNAVAILABLE) - printf(" Could not contact the X.500 server to find \"%s\".\n", who); + dn = ldap_get_dn(ld, ldap_first_entry(ld, res)); + rc = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res); + ldap_memfree(dn); + if (rc != LDAP_SUCCESS) { + int ld_errno = 0; + ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno); + if (ld_errno == LDAP_UNAVAILABLE) + printf(" Could not contact the LDAP server to find \"%s\".\n", who); else ldap_perror(ld, "ldap_search_s"); return(NULL); } - ld->ld_deref = savederef; + ldap_set_option(ld, LDAP_OPT_DEREF, &savederef); return(res); } else if (matches > 1 ) { - return( disambiguate( ld, res, matches, read_attrs, - who ) ); + return disambiguate( res, matches, read_attrs, who ); } - ld->ld_deref = savederef; + ldap_set_option(ld, LDAP_OPT_DEREF, &savederef); } /* @@ -287,7 +292,10 @@ int quiet; fflush(stdout); fetch_buffer(response, sizeof(response), stdin); if ((response[0] == 'n') || (response[0] == 'N')) + { + ldap_memfree(dn); return(NULL); + } } #ifdef DEBUG if (debug & D_FIND) { @@ -306,9 +314,9 @@ int quiet; if (ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) { ldap_perror(ld, "ldap_search_s"); ldap_msgfree(res); - return(NULL); + res = NULL; } - Free(dn); + ldap_memfree(dn); return(res); } else if (matches > 0) { @@ -322,8 +330,8 @@ int quiet; return(NULL); } -pick_one(i) -int i; +int +pick_one( int i ) { int n; char user_pick[SMALL_BUF_SIZE]; @@ -348,13 +356,10 @@ int i; /* NOTREACHED */ } -print_list(list, names, matches) -LDAPMessage *list; -char *names[]; -int *matches; +void +print_list( LDAPMessage *list, char **names, int *matches ) { char **rdns, **cpp; - extern int lpp; char resp[SMALL_BUF_SIZE]; register LDAPMessage *ep; register int i = 1; @@ -398,9 +403,8 @@ again: return; } -find_all_subscribers(sub, group) -char *sub[]; -char *group; +int +find_all_subscribers( char **sub, char *group ) { int count; LDAPMessage *result; @@ -416,7 +420,9 @@ char *group; sprintf(filter, "%s=%s", "memberOfGroup", group); if (ldap_search_s(ld, search_base, LDAP_SCOPE_SUBTREE, filter, attributes, FALSE, &result) != LDAP_SUCCESS) { - if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE) + int ld_errno = 0; + ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno); + if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE) return(0); ldap_perror(ld, "ldap_search_s"); return(0); @@ -443,9 +449,8 @@ char *group; return(count); } -char * fetch_boolean_value(who, attr) -char *who; -struct attribute attr; +char * +fetch_boolean_value( char *who, struct attribute attr ) { LDAPMessage *result; /* from the search below */ register LDAPMessage *ep; /* entry pointer */ @@ -458,7 +463,9 @@ struct attribute attr; #endif attributes[0] = attr.quipu_name; if (ldap_search_s(ld, who, LDAP_SCOPE_BASE, "objectClass=*", attributes, FALSE, &result) != LDAP_SUCCESS) { - if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE) + int ld_errno = 0; + ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno); + if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE) return("FALSE"); ldap_perror(ld, "ldap_search_s"); ldap_msgfree(result); diff --git a/clients/ud/globals.c b/clients/ud/globals.c index 121f36be21..5927351c5b 100644 --- a/clients/ud/globals.c +++ b/clients/ud/globals.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1992, 1993, 1994 Regents of the University of Michigan. * All rights reserved. @@ -10,16 +11,14 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include +#include /* portable.h+ldap.h needs time_t */ +#include +#include #include "ud.h" -extern void set_boolean(), - change_field(), -#ifdef UOFM - set_updates(), -#endif - mod_addrDN(); - struct attribute attrlist[] = { /* @@ -28,8 +27,8 @@ struct attribute attrlist[] = { * Field 3 = function used to modify this field (if any) * Field 4 = Flags specifying how this field is displayed */ - { "memberOfGroup", "Subscriptions", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN }, - { "acl", "Access Control", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ }, + { "memberOfGroup", "Subscriptions", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN }, + { "acl", "Access Control", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ }, { "cn", "Aliases", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_GROUP_MOD }, { "title", "Title", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_PERSON_MOD }, { "postalAddress", "Business address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE }, @@ -38,18 +37,18 @@ struct attribute attrlist[] = { { "member", "Members", mod_addrDN, ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN | ATTR_FLAG_GROUP_MOD }, { "homePhone", "Home phone", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD }, { "homePostalAddress", "Home address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE }, - { "objectClass", "Object class", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH }, + { "objectClass", "Object class", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH }, #ifdef UOFM { "multiLineDescription", "Description", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE }, #endif -#ifdef KERBEROS - { "krbName", "Kerberos name", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ }, +#ifdef HAVE_KERBEROS + { "krbName", "Kerberos name", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ }, #endif - { "description", "Brief description", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ }, + { "description", "Brief description", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ }, { "facsimileTelephoneNumber", "Fax number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD }, { "pager", "Pager number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD }, - { "uid", "Uniqname", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ }, - { "userPassword", "Password", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ }, + { "uid", "Uniqname", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ }, + { "userPassword", "Password", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ }, #ifdef UOFM { "noBatchUpdates", "No batch updates", set_updates, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD }, #endif @@ -65,7 +64,7 @@ struct attribute attrlist[] = { { "onVacation", "On Vacation", set_boolean, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_A_BOOL }, { "vacationMessage", "Vacation Message", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE }, { "drink", "Favorite Beverage", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD }, - { "lastModifiedBy", "Last modified by", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ }, - { "lastModifiedTime", "Last modified at", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE }, - { NULL, NULL, NULL, ATTR_FLAG_NONE } + { "lastModifiedBy", "Last modified by", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ }, + { "lastModifiedTime", "Last modified at", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE }, + { NULL, NULL, 0, ATTR_FLAG_NONE } }; diff --git a/clients/ud/group.c b/clients/ud/group.c index 3b7a87fb1c..950631d765 100644 --- a/clients/ud/group.c +++ b/clients/ud/group.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1993, 1994 Regents of the University of Michigan. * All rights reserved. diff --git a/clients/ud/help.c b/clients/ud/help.c index 2a2c96bde9..027e168e41 100644 --- a/clients/ud/help.c +++ b/clients/ud/help.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1992, 1993 Regents of the University of Michigan. * All rights reserved. diff --git a/clients/ud/main.c b/clients/ud/main.c index 6be4288ae5..7f0d4baa3d 100644 --- a/clients/ud/main.c +++ b/clients/ud/main.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/clients/ud/mod.c b/clients/ud/mod.c index 9f6322572e..40eea36316 100644 --- a/clients/ud/mod.c +++ b/clients/ud/mod.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1991,1993 Regents of the University of Michigan. * All rights reserved. diff --git a/clients/ud/print.c b/clients/ud/print.c index 4185bdaef3..8cb5c133dc 100644 --- a/clients/ud/print.c +++ b/clients/ud/print.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1991, 1993 * Regents of the University of Michigan. All rights reserved. @@ -10,27 +11,23 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#include -#include -#ifndef __STDC__ -#include -#endif -#include + +#include +#include +#include + #include #include -#include "ud.h" -#ifdef DEBUG -extern int debug; -#endif +#include "ud.h" struct entry Entry; -extern LDAP *ld; -extern void * Malloc(); -extern void Free(); -extern char * my_ldap_dn2ufn(); +static char *time2text(char *ldtimestr, int dateonly); +static long gtime(struct tm *tm); /* * When displaying entries, display only these attributes, and in this @@ -80,15 +77,14 @@ static char *group_attr_print_order[] = { NULL }; -parse_answer(s) -LDAPMessage *s; + +void +parse_answer( LDAPMessage *s ) { int idx; char **rdns; - BerElement *cookie; register LDAPMessage *ep; register char *ap; - void clear_entry(); #ifdef DEBUG if (debug & D_TRACE) @@ -102,6 +98,7 @@ LDAPMessage *s; printf(" Done clearing entry\n"); #endif for (ep = ldap_first_entry(ld, s); ep != NULL; ep = ldap_next_entry(ld, ep)) { + BerElement *cookie = NULL; #ifdef DEBUG if (debug & D_PARSE) printf(" Determining DN and name\n"); @@ -130,6 +127,10 @@ LDAPMessage *s; } add_value(&(Entry.attrs[idx]), ep, ap); } + + if( cookie != NULL ) { + ber_free( cookie, 0 ); + } } #ifdef DEBUG if (debug & D_PARSE) @@ -137,10 +138,8 @@ LDAPMessage *s; #endif } -add_value(attr, ep, ap) -struct attribute *attr; -LDAPMessage *ep; -char *ap; +void +add_value( struct attribute *attr, LDAPMessage *ep, char *ap ) { register int i = 0; char **vp, **tp, **avp; @@ -185,13 +184,12 @@ char *ap; ldap_value_free(vp); } -print_an_entry() +void +print_an_entry( void ) { int n = 0, i, idx; char is_a_group, **order; char *sub_list[MAX_VALUES], buf[SMALL_BUF_SIZE]; - extern int col_size, isaurl(), isadn(); - static char *time2text(); #ifdef DEBUG if (debug & D_TRACE) @@ -277,8 +275,8 @@ print_an_entry() #define OUT_LABEL_LEN 20 /* prints the values associated with an attribute */ -print_values(A) -struct attribute A; +void +print_values( struct attribute A ) { register int i, k; register char *cp, **vp; @@ -348,7 +346,7 @@ struct attribute A; putchar('\n'); for (k = lead; k > 0; k--) putchar(' '); - while (isspace(*(cp + 1))) + while (isspace((unsigned char) cp[1])) cp++; } else @@ -370,13 +368,12 @@ struct attribute A; } /* prints the DN's associated with an attribute */ -print_DN(A) -struct attribute A; +void +print_DN( struct attribute A ) { int i, lead; register char **vp; char out_buf[MED_BUF_SIZE], *padding = NULL; - extern int col_size; #ifdef DEBUG if (debug & D_TRACE) @@ -407,10 +404,10 @@ struct attribute A; return; } -void clear_entry() +void +clear_entry( void ) { register int i; - extern struct attribute attrlist[]; #ifdef DEBUG if (debug & D_TRACE) @@ -419,7 +416,7 @@ void clear_entry() printf(" Clearing entry \"%s\"\n", Entry.name); #endif if (Entry.DN != NULL) - Free(Entry.DN); + ldap_memfree(Entry.DN); if (Entry.name != NULL) Free(Entry.name); Entry.may_join = FALSE; @@ -456,11 +453,10 @@ void clear_entry() } } -attr_to_index(s) -char *s; +int +attr_to_index( char *s ) { register int i; - extern struct attribute attrlist[]; for (i = 0; attrlist[i].quipu_name != NULL; i++) if (!strcasecmp(s, attrlist[i].quipu_name)) @@ -468,11 +464,10 @@ char *s; return(-1); } -void initialize_attribute_strings() +void +initialize_attribute_strings( void ) { register int i; - extern struct entry Entry; - extern struct attribute attrlist[]; for (i = 0; attrlist[i].quipu_name != NULL; i++) Entry.attrs[i].quipu_name = attrlist[i].quipu_name; @@ -481,8 +476,8 @@ void initialize_attribute_strings() } /* prints the URL/label pairs associated with an attribute */ -print_URL(A) -struct attribute A; +void +print_URL( struct attribute A ) { int i, lead; register char **vp; @@ -516,25 +511,20 @@ struct attribute A; return; } -print_one_URL(s, label_lead, tag, url_lead) -char *s; -int label_lead; -char *tag; -int url_lead; +void +print_one_URL( char *s, int label_lead, char *tag, int url_lead ) { register int i; char c, *cp, *url; - extern int col_size; - extern void Free(); - for (cp = s; !isspace(*cp) && (*cp != '\0'); cp++) + for (cp = s; !isspace((unsigned char)*cp) && (*cp != '\0'); cp++) ; c = *cp; *cp = '\0'; url = strdup(s); *cp = c; if (*cp != '\0') { - for (cp++; isspace(*cp); cp++) + for (cp++; isspace((unsigned char)*cp); cp++) ; } else @@ -547,7 +537,7 @@ int url_lead; } -#define GET2BYTENUM( p ) (( *p - '0' ) * 10 + ( *(p+1) - '0' )) +#define GET2BYTENUM( p ) (( *(p) - '0' ) * 10 + ( *((p)+1) - '0' )) static char * time2text( char *ldtimestr, int dateonly ) @@ -555,21 +545,32 @@ time2text( char *ldtimestr, int dateonly ) struct tm t; char *p, *timestr, zone, *fmterr = "badly formatted time"; time_t gmttime; - static long gtime(); + int ndigits; - memset( (char *)&t, 0, sizeof( struct tm )); - if ( strlen( ldtimestr ) < 13 ) { - return( fmterr ); + if (strlen( ldtimestr ) < 12 ) { + return( fmterr ); + } + + for ( ndigits=0; isdigit((unsigned char) ldtimestr[ndigits]); ndigits++) { + ; /* EMPTY */ } - for ( p = ldtimestr; p - ldtimestr < 12; ++p ) { - if ( !isdigit( *p )) { + if ( ndigits != 12 && ndigits != 14) { return( fmterr ); } - } + + memset( (char *)&t, 0, sizeof( struct tm )); p = ldtimestr; + + if( ndigits == 14) { + /* came with a century */ + /* POSIX says tm_year should be year - 1900 */ + t.tm_year = 100 * GET2BYTENUM( p ) - 1900; + p += 2; + } t.tm_year = GET2BYTENUM( p ); p += 2; + t.tm_mon = GET2BYTENUM( p ) - 1; p += 2; t.tm_mday = GET2BYTENUM( p ); p += 2; t.tm_hour = GET2BYTENUM( p ); p += 2; @@ -585,19 +586,16 @@ time2text( char *ldtimestr, int dateonly ) timestr[ strlen( timestr ) - 1 ] = zone; /* replace trailing newline */ if ( dateonly ) { - strcpy( timestr + 11, timestr + 20 ); + SAFEMEMCPY( timestr + 11, timestr + 20, strlen( timestr + 20 ) + 1 ); } - Free ( ldtimestr ); return( strdup( timestr ) ); } /* gtime.c - inverse gmtime */ -#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS ) -#include -#endif /* !MACOS */ +#include /* gtime(): the inverse of localtime(). This routine was supplied by Mike Accetta at CMU many years ago. @@ -610,11 +608,24 @@ int dmsize[] = { #define dysize(y) \ (((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366))) -#define YEAR(y) ((y) >= 100 ? (y) : (y) + 1900) +/* + * Y2K YEAR + */ + /* per STDC & POSIX tm_year *should* be offset by 1900 */ +#define YEAR_POSIX(y) ((y) + 1900) + + /* + * year is < 1900, year is offset by 1900 + */ +#define YEAR_CAREFUL(y) ((y) < 1900 ? (y) + 1900 : (y)) + +#define YEAR(y) YEAR_CAREFUL(y) + /* */ -static long gtime ( struct tm *tm ) +static long +gtime( struct tm *tm ) { register int i, sec, diff --git a/clients/ud/string_to_key.c b/clients/ud/string_to_key.c index cff99b3612..8a6a5ae70f 100644 --- a/clients/ud/string_to_key.c +++ b/clients/ud/string_to_key.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ #include "portable.h" #if defined(HAVE_KERBEROS) && !defined(openbsd) diff --git a/clients/ud/ud.h b/clients/ud/ud.h index 40b6ecff7a..fa07c3531d 100644 --- a/clients/ud/ud.h +++ b/clients/ud/ud.h @@ -1,3 +1,13 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ /* * Copyright (c) 1991, 1992, 1993 * Regents of the University of Michigan. All rights reserved. @@ -10,14 +20,7 @@ * is provided ``as is'' without express or implied warranty. */ -#ifdef DOS -#include "protoud.h" -#define strncasecmp(a, b, n) strnicmp(a, b, n) -#define strcasecmp(a, b) stricmp(a, b) -#define MAX_VALUES 8 -#else #define MAX_VALUES 1000 -#endif /* end of DOS ifdef */ /***************************************************************************** ** @@ -35,7 +38,7 @@ * parsing names. */ #define MAX_NAME_COMPS 8 -#define isnamesepartor(x) (isspace(x)) +#define isnamesepartor(x) (isspace((unsigned char) (x))) #define isignorechar(x) (((x) == '.') || ((x) == '_')) /* @@ -87,7 +90,7 @@ /* * Authentication method we will be using. */ -#ifdef KERBEROS +#ifdef HAVE_KERBEROS #define UD_AUTH_METHOD LDAP_AUTH_KRBV4 #else #define UD_AUTH_METHOD LDAP_AUTH_SIMPLE @@ -136,6 +139,8 @@ #define ATTR_FLAG_IS_A_BOOL 0x4000 #define ATTR_FLAG_IS_MULTILINE 0x8000 +LDAP_BEGIN_DECL + /* * These are the structures we use when parsing an answer we get from the LDAP * server. @@ -143,7 +148,7 @@ struct attribute { char *quipu_name; char *output_string; - void (*mod_func)(); + void (*mod_func) LDAP_P(( char *who, int attr_idx )); unsigned short flags; int number_of_values; char **values; @@ -156,3 +161,145 @@ struct entry { char *name; struct attribute attrs[MAX_ATTRS]; }; + + + +/* + * Variables + */ + +/* in globals.c: */ +extern struct attribute attrlist[];/* complete list of attrs */ +/* in main.c: */ +extern char copyright[]; +extern char *default_bind_object; +extern char *bound_dn; +extern char *group_base; +extern char *search_base; /* search base */ +extern int lpp; +extern int verbose; /* verbose mode flag */ +extern int col_size; +extern int bind_status; +extern LDAP *ld; /* our ldap descriptor */ +extern LDAPFiltDesc *lfdp; /* LDAP filter descriptor */ +#ifdef DEBUG +extern int debug; /* debug flag */ +#endif +/* in print.c: */ +extern struct entry Entry; +extern int dmsize[]; +/* in version.c: */ +extern char Version[]; + + +/* + * Functions + */ + +/* in auth.c: */ +int auth LDAP_P(( char *who, int implicit )); +#if defined(HAVE_KERBEROS) && defined(_AC_KRB_H) +int krbgetpass LDAP_P(( char *u, char *in, char *re, char *pw, C_Block key )); +void destroy_tickets LDAP_P(( void )); +#endif + +/* in edit.c: */ +void edit LDAP_P(( char *who )); + +/* in find.c: */ +int vrfy LDAP_P(( char *dn )); +LDAPMessage *find LDAP_P(( char *who, int quiet )); +int pick_one LDAP_P(( int i )); +void print_list LDAP_P(( LDAPMessage *list, char **names, int *matches )); +int find_all_subscribers LDAP_P(( char **sub, char *group )); +char *fetch_boolean_value LDAP_P(( char *who, struct attribute attr )); + +/* in globals.c: */ + +/* in group.c: */ +void add_group LDAP_P(( char *name )); +void remove_group LDAP_P(( char *name )); +void x_group LDAP_P(( int action, char *name )); +void bulk_load LDAP_P(( char *group )); +void purge_group LDAP_P(( char *group )); +void tidy_up LDAP_P(( void )); +void mod_addrDN LDAP_P(( char *group, int offset )); +int my_ldap_modify_s LDAP_P(( LDAP *ldap, char *group, LDAPMod **mods )); +void list_groups LDAP_P(( char *who )); +void list_memberships LDAP_P(( char *who )); + +/* in help.c: */ +void print_help LDAP_P(( char *s )); + +/* in main.c: */ +#ifdef DEBUG +#endif + +void do_commands LDAP_P(( void )) LDAP_GCCATTR((noreturn)); +void status LDAP_P(( void )); +void change_base LDAP_P(( int type, char **base, char *s )); +void initialize_client LDAP_P(( void )); +RETSIGTYPE attn LDAP_P(( int sig )); +#if !defined(NO_TERMCAP) && defined(TIOCGWINSZ) +RETSIGTYPE chwinsz LDAP_P(( int sig )); +#endif + +/* in mod.c: */ +void modify LDAP_P(( char *who )); +void change_field LDAP_P(( char *who, int attr_idx )); +char *get_value LDAP_P(( char *id, char *prompt )); +void set_boolean LDAP_P(( char *who, int attr_idx )); +#ifdef UOFM +void set_updates LDAP_P(( char *who, int dummy )); +#endif +void print_mod_list LDAP_P(( int group )); +int perform_action LDAP_P(( char *choice, char *dn, int group )); +void mod_perror LDAP_P(( LDAP *ld )); + +/* in print.c: */ +void parse_answer LDAP_P(( LDAPMessage *s )); +void add_value LDAP_P(( struct attribute *attr, LDAPMessage *ep, char *ap )); +void print_an_entry LDAP_P(( void )); +void print_values LDAP_P(( struct attribute A )); +void print_DN LDAP_P(( struct attribute A )); +void clear_entry LDAP_P(( void )); +int attr_to_index LDAP_P(( char *s )); +void initialize_attribute_strings LDAP_P(( void )); +void print_URL LDAP_P(( struct attribute A )); +void print_one_URL LDAP_P(( char *s, int l_lead, char *tag, int u_lead )); + +/* in string_to_key.c: */ +#if defined(HAVE_KERBEROS) && !defined(openbsd) && defined(_AC_KRB_H) +#if defined(HAVE_AFS_KERBEROS) || !defined(HAVE_KERBEROS_V) +void des_string_to_key LDAP_P(( char *str, des_cblock *key )); +#endif +#if defined(HAVE_AFS_KERBEROS) +void ka_StringToKey LDAP_P(( char *str, char *cell, des_cblock *key )); +#endif +#endif + +/* in util.c: */ +void printbase LDAP_P(( char *lead, char *s )); +void fetch_buffer LDAP_P(( char *buffer, int length, FILE *where )); +void fatal LDAP_P(( char *s )) LDAP_GCCATTR((noreturn)); +int isgroup LDAP_P(( void )); +void format LDAP_P(( char *str, int width, int lead )); +void format2 LDAP_P(( char *s, char *ft, char *t, int fi, int i, int w )); +char *strip_ignore_chars LDAP_P(( char *cp )); +char *code_to_str LDAP_P(( int i )); +char *friendly_name LDAP_P(( char *s )); +#ifdef UOFM +int isauniqname LDAP_P(( char *s )); +#endif +int isadn LDAP_P(( char *s )); +char *my_ldap_dn2ufn LDAP_P(( char *s )); +int isaurl LDAP_P(( char *s )); +int isadate LDAP_P(( char *s )); +void *Malloc LDAP_P(( unsigned int size )); +void Free LDAP_P(( void *ptr )); +char *nextstr LDAP_P(( char *s )); +void free_mod_struct LDAP_P(( LDAPMod *modp )); +void StrFreeDup LDAP_P(( char **ptr, char *new_value )); +int confirm_action LDAP_P(( char *msg )); + +LDAP_END_DECL diff --git a/clients/ud/util.c b/clients/ud/util.c index 2efd2895d6..27023de759 100644 --- a/clients/ud/util.c +++ b/clients/ud/util.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1992, 1993 Regents of the University of Michigan. * All rights reserved. diff --git a/configure b/configure index aff1b9a483..214318b211 100755 --- a/configure +++ b/configure @@ -1,4 +1,13 @@ #! /bin/sh +# $OpenLDAP$ +# from OpenLDAP: pkg/ldap/configure.in,v 1.256 1999/09/10 00:10:20 kdz Exp + +# Copyright 1998,1999 The OpenLDAP Foundation. All Rights Reserved. +# +# Redistribution and use in source and binary forms are permitted only +# as authorized by the OpenLDAP Public License. A copy of this +# license is available at http://www.OpenLDAP.org/license.html or +# in file LICENSE in the top-level directory of the distribution. # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13.1 @@ -23,7 +32,7 @@ ac_help="$ac_help ac_help="$ac_help --enable-cache enable caching (yes)" ac_help="$ac_help - --enable-dns enable V2 DNS extension (no)" + --enable-dns enable V2 DX Referrals extension (no)" ac_help="$ac_help --enable-referrals enable V2 Referrals extension (yes)" ac_help="$ac_help @@ -33,21 +42,21 @@ ac_help="$ac_help ac_help="$ac_help --enable-dmalloc enable debug malloc support (no)" ac_help="$ac_help - --with-cyrus-sasl with Cyrus SASL support (auto)" + --with-cyrus-sasl with Cyrus SASL support (auto)" ac_help="$ac_help - --with-fetch with fetch URL support (auto)" + --with-fetch with fetch URL support (auto)" ac_help="$ac_help --with-kerberos with Kerberos support (auto)" ac_help="$ac_help - --with-readline with readline support (auto)" + --with-readline with readline support (auto)" ac_help="$ac_help --with-threads use threads (auto)" ac_help="$ac_help - --with-tls with TLS/SSL support (auto)" + --with-tls with TLS/SSL support (auto)" ac_help="$ac_help --with-yielding-select with implicitly yielding select (auto)" ac_help="$ac_help -SLAPD Options:" +SLAPD (Standalone LDAP Daemon) Options:" ac_help="$ac_help --enable-slapd enable building slapd (yes)" ac_help="$ac_help @@ -64,6 +73,10 @@ ac_help="$ac_help --enable-quipu build quipu migration tools (no)" ac_help="$ac_help --enable-rlookups enable reverse lookups (auto)" +ac_help="$ac_help + --enable-aci enable per-object ACIs (no)" +ac_help="$ac_help + --enable-discreteaci enable discrete rights in ACIs (no)" ac_help="$ac_help --enable-wrappers enable tcp wrapper support (no)" ac_help="$ac_help @@ -76,10 +89,10 @@ ac_help="$ac_help --with-ldap-module module type (static)" ac_help="$ac_help --enable-ldbm enable ldbm backend (yes)" -ac_help="$ac_help - --with-ldbm-module module type (static)" ac_help="$ac_help --with-ldbm-api use LDBM API (auto)" +ac_help="$ac_help + --with-ldbm-module module type (static)" ac_help="$ac_help --with-ldbm-type use LDBM type (auto)" ac_help="$ac_help @@ -99,7 +112,7 @@ ac_help="$ac_help ac_help="$ac_help --with-tcl-module module type (static)" ac_help="$ac_help -SLURPD Options:" +SLURPD (Replication Daemon) Options:" ac_help="$ac_help --enable-slurpd enable building slurpd (auto)" ac_help="$ac_help @@ -642,7 +655,7 @@ fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:646: checking host system type" >&5 +echo "configure:659: 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. @@ -683,7 +696,7 @@ host_os=$ac_cv_host_os echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:687: checking target system type" >&5 +echo "configure:700: 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. @@ -723,7 +736,7 @@ target_os=$ac_cv_target_os echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:727: checking build system type" >&5 +echo "configure:740: 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. @@ -800,7 +813,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:804: checking for a BSD compatible install" >&5 +echo "configure:817: 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 @@ -857,7 +870,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:861: checking whether build environment is sane" >&5 +echo "configure:874: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -918,7 +931,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:922: checking for $ac_word" >&5 +echo "configure:935: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_AWK+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -948,7 +961,7 @@ test -n "$AWK" && break done echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:952: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:965: 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 @@ -988,7 +1001,7 @@ fi missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:992: checking for working aclocal" >&5 +echo "configure:1005: 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. @@ -1001,7 +1014,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:1005: checking for working autoconf" >&5 +echo "configure:1018: 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. @@ -1014,7 +1027,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:1018: checking for working automake" >&5 +echo "configure:1031: 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. @@ -1027,7 +1040,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:1031: checking for working autoheader" >&5 +echo "configure:1044: 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. @@ -1040,7 +1053,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:1044: checking for working makeinfo" >&5 +echo "configure:1057: 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. @@ -1060,7 +1073,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:1064: checking for $ac_word" >&5 +echo "configure:1077: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_AMTAR+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1111,7 +1124,7 @@ EOF echo $ac_n "checking configure arguments""... $ac_c" 1>&6 -echo "configure:1115: checking configure arguments" >&5 +echo "configure:1128: checking configure arguments" >&5 top_builddir=`pwd` @@ -1409,7 +1422,7 @@ if test "${with_threads+set}" = set; then withval="$with_threads" ol_arg=invalid - for ol_val in auto posix mach lwp yes no manual ; do + for ol_val in auto posix mach pth lwp yes no manual ; do if test "$withval" = "$ol_val" ; then ol_arg="$ol_val" fi @@ -1634,6 +1647,46 @@ else ol_enable_rlookups="auto" fi # end --enable-rlookups +# OpenLDAP --enable-aci + # Check whether --enable-aci or --disable-aci was given. +if test "${enable_aci+set}" = set; then + enableval="$enable_aci" + + ol_arg=invalid + for ol_val in auto yes no ; 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-aci" 1>&2; exit 1; } + fi + ol_enable_aci="$ol_arg" + +else + ol_enable_aci="no" +fi +# end --enable-aci +# OpenLDAP --enable-discreteaci + # Check whether --enable-discreteaci or --disable-discreteaci was given. +if test "${enable_discreteaci+set}" = set; then + enableval="$enable_discreteaci" + + ol_arg=invalid + for ol_val in auto yes no ; 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-discreteaci" 1>&2; exit 1; } + fi + ol_enable_discreteaci="$ol_arg" + +else + ol_enable_discreteaci="no" +fi +# end --enable-discreteaci # OpenLDAP --enable-wrappers # Check whether --enable-wrappers or --disable-wrappers was given. if test "${enable_wrappers+set}" = set; then @@ -1757,47 +1810,47 @@ else ol_enable_ldbm="yes" fi # end --enable-ldbm -# OpenLDAP --with-ldbm_module - # Check whether --with-ldbm_module or --without-ldbm_module was given. -if test "${with_ldbm_module+set}" = set; then - withval="$with_ldbm_module" +# OpenLDAP --with-ldbm_api + # Check whether --with-ldbm_api or --without-ldbm_api was given. +if test "${with_ldbm_api+set}" = set; then + withval="$with_ldbm_api" ol_arg=invalid - for ol_val in static dynamic ; do + for ol_val in auto db2 db mdbm gdbm ndbm manual ; do if test "$withval" = "$ol_val" ; then ol_arg="$ol_val" fi done if test "$ol_arg" = "invalid" ; then - { echo "configure: error: bad value $withval for --with-ldbm_module" 1>&2; exit 1; } + { echo "configure: error: bad value $withval for --with-ldbm_api" 1>&2; exit 1; } fi - ol_with_ldbm_module="$ol_arg" + ol_with_ldbm_api="$ol_arg" else - ol_with_ldbm_module="static" + ol_with_ldbm_api="auto" fi -# end --with-ldbm_module +# end --with-ldbm_api -# OpenLDAP --with-ldbm_api - # Check whether --with-ldbm_api or --without-ldbm_api was given. -if test "${with_ldbm_api+set}" = set; then - withval="$with_ldbm_api" +# OpenLDAP --with-ldbm_module + # Check whether --with-ldbm_module or --without-ldbm_module was given. +if test "${with_ldbm_module+set}" = set; then + withval="$with_ldbm_module" ol_arg=invalid - for ol_val in auto db2 db mdbm gdbm ndbm manual ; do + for ol_val in static dynamic ; do if test "$withval" = "$ol_val" ; then ol_arg="$ol_val" fi done if test "$ol_arg" = "invalid" ; then - { echo "configure: error: bad value $withval for --with-ldbm_api" 1>&2; exit 1; } + { echo "configure: error: bad value $withval for --with-ldbm_module" 1>&2; exit 1; } fi - ol_with_ldbm_api="$ol_arg" + ol_with_ldbm_module="$ol_arg" else - ol_with_ldbm_api="auto" + ol_with_ldbm_module="static" fi -# end --with-ldbm_api +# end --with-ldbm_module # OpenLDAP --with-ldbm_type # Check whether --with-ldbm_type or --without-ldbm_type was given. @@ -2117,6 +2170,12 @@ if test $ol_enable_slapd = no ; then if test $ol_enable_rlookups = yes ; then echo "configure: warning: slapd disabled, ignoring --enable-rlookups argument" 1>&2 fi + if test $ol_enable_aci = yes ; then + echo "configure: warning: slapd disabled, ignoring --enable-aci argument" 1>&2 + fi + if test $ol_enable_discreteaci = yes ; then + echo "configure: warning: slapd disabled, ignoring --enable-discreteaci argument" 1>&2 + fi if test $ol_with_ldbm_api != auto ; then echo "configure: warning: slapd disabled, ignoring --with-ldbm-api argument" 1>&2 fi @@ -2162,6 +2221,8 @@ if test $ol_enable_slapd = no ; then ol_enable_phonetic=no ol_enable_quipu=no ol_enable_rlookups=no + ol_enable_aci=no + ol_enable_discreteaci=no ol_enable_wrappers=no ol_with_ldbm_api=no @@ -2303,7 +2364,6 @@ EOF - ol_aix_threads=no case "$target" in *-*-aix*) if test -z "$CC" ; then @@ -2321,7 +2381,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:2325: checking for $ac_word" >&5 +echo "configure:2385: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2373,7 +2433,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:2377: checking for $ac_word" >&5 +echo "configure:2437: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2432,7 +2492,7 @@ fi # 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:2436: checking for $ac_word" >&5 +echo "configure:2496: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2462,7 +2522,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:2466: checking for $ac_word" >&5 +echo "configure:2526: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2492,7 +2552,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:2496: checking for $ac_word" >&5 +echo "configure:2556: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2543,7 +2603,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:2547: checking for $ac_word" >&5 +echo "configure:2607: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2575,7 +2635,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2579: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5 +echo "configure:2639: 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. @@ -2586,12 +2646,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 2590 "configure" +#line 2650 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:2595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2655: \"$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 @@ -2617,12 +2677,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:2621: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:2681: 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:2626: checking whether we are using GNU C" >&5 +echo "configure:2686: 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 @@ -2631,7 +2691,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2635: \"$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:2695: \"$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 @@ -2650,7 +2710,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:2654: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:2714: 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 @@ -2693,7 +2753,7 @@ ac_prog=ld if test "$ac_cv_prog_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:2697: checking for ld used by GCC" >&5 +echo "configure:2757: checking for ld used by GCC" >&5 ac_prog=`($CC -print-prog-name=ld) 2>&5` case "$ac_prog" in # Accept absolute paths. @@ -2717,10 +2777,10 @@ echo "configure:2697: 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:2721: checking for GNU ld" >&5 +echo "configure:2781: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:2724: checking for non-GNU ld" >&5 +echo "configure:2784: checking for non-GNU ld" >&5 fi if eval "test \"\${ac_cv_path_LD+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2756,7 +2816,7 @@ 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:2760: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:2820: checking if the linker ($LD) is GNU ld" >&5 if eval "test \"\${ac_cv_prog_gnu_ld+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2772,7 +2832,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:2776: checking for BSD-compatible nm" >&5 +echo "configure:2836: checking for BSD-compatible nm" >&5 if eval "test \"\${ac_cv_path_NM+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2809,7 +2869,7 @@ echo "$ac_t""$NM" 1>&6 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:2813: checking whether ln -s works" >&5 +echo "configure:2873: 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 @@ -2853,8 +2913,8 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" case "$host" in *-*-irix6*) # Find out which ABI we are using. - echo '#line 2857 "configure"' > conftest.$ac_ext - if { (eval echo configure:2858: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 2917 "configure"' > conftest.$ac_ext + if { (eval echo configure:2918: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *32-bit*) LD="${LD-ld} -32" @@ -2875,19 +2935,19 @@ 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:2879: checking whether the C compiler needs -belf" >&5 +echo "configure:2939: 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 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2951: \"$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 @@ -2941,7 +3001,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:2945: checking for $ac_word" >&5 +echo "configure:3005: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_AWK+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2972,7 +3032,7 @@ done # test for ln hardlink support echo $ac_n "checking whether ln works""... $ac_c" 1>&6 -echo "configure:2976: checking whether ln works" >&5 +echo "configure:3036: checking whether ln works" >&5 if eval "test \"\${ol_cv_prog_LN_H+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2995,7 +3055,7 @@ else fi echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:2999: checking whether ln -s works" >&5 +echo "configure:3059: 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 @@ -3023,7 +3083,7 @@ fi # Extract the first word of "sendmail", so it can be a program name with args. set dummy sendmail; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3027: checking for $ac_word" >&5 +echo "configure:3087: checking for $ac_word" >&5 if eval "test \"\${ac_cv_path_SENDMAIL+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3059,7 +3119,7 @@ fi # Extract the first word of "vi", so it can be a program name with args. set dummy vi; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3063: checking for $ac_word" >&5 +echo "configure:3123: checking for $ac_word" >&5 if eval "test \"\${ac_cv_path_EDITOR+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3095,7 +3155,7 @@ fi # Extract the first word of "finger", so it can be a program name with args. set dummy finger; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3099: checking for $ac_word" >&5 +echo "configure:3159: checking for $ac_word" >&5 if eval "test \"\${ac_cv_path_FINGER+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3134,7 +3194,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:3138: checking for $ac_word" >&5 +echo "configure:3198: checking for $ac_word" >&5 if eval "test \"\${ac_cv_path_PERLBIN+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3182,7 +3242,7 @@ fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:3186: checking how to run the C preprocessor" >&5 +echo "configure:3246: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -3197,13 +3257,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:3207: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3267: \"$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 : @@ -3214,13 +3274,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:3224: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3284: \"$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 : @@ -3231,13 +3291,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:3241: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3301: \"$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 : @@ -3275,9 +3335,9 @@ elif test $cross_compiling = yes -a $ol_enable_x_compile = no; then fi echo $ac_n "checking for AIX""... $ac_c" 1>&6 -echo "configure:3279: checking for AIX" >&5 +echo "configure:3339: checking for AIX" >&5 cat > conftest.$ac_ext <&6 -echo "configure:3303: checking for POSIXized ISC" >&5 +echo "configure:3363: checking for POSIXized ISC" >&5 if test -d /etc/conf/kconfig.d && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 then @@ -3321,17 +3381,17 @@ fi ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 -echo "configure:3325: checking for minix/config.h" >&5 +echo "configure:3385: checking for minix/config.h" >&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:3335: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3395: \"$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* @@ -3370,12 +3430,12 @@ fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:3374: checking for Cygwin environment" >&5 +echo "configure:3434: 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:3450: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -3402,19 +3462,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:3406: checking for mingw32 environment" >&5 +echo "configure:3466: 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:3478: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -3430,19 +3490,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:3434: checking for EMX OS/2 environment" >&5 +echo "configure:3494: 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:3506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_emxos2=yes else @@ -3461,7 +3521,7 @@ test "$ac_cv_emxos2" = yes && EMXOS2=yes echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:3465: checking for executable suffix" >&5 +echo "configure:3525: checking for executable suffix" >&5 if eval "test \"\${ac_cv_exeext+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3471,7 +3531,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:3475: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:3535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.C | *.o | *.obj | *.xcoff) ;; @@ -3492,13 +3552,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:3496: checking for object suffix" >&5 +echo "configure:3556: 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:3502: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3562: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -3522,7 +3582,7 @@ EOF echo $ac_n "checking for be_app in -lbe""... $ac_c" 1>&6 -echo "configure:3526: checking for be_app in -lbe" >&5 +echo "configure:3586: 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 @@ -3530,7 +3590,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:3605: \"$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 @@ -3567,7 +3627,7 @@ fi echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 -echo "configure:3571: checking for ${CC-cc} option to accept ANSI C" >&5 +echo "configure:3631: 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 @@ -3584,7 +3644,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 @@ -3621,7 +3681,7 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } EOF -if { (eval echo configure:3625: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_prog_cc_stdc="$ac_arg"; break else @@ -3655,7 +3715,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:3659: checking for ${OL_MKDEP} depend flag" >&5 +echo "configure:3719: 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 @@ -3665,7 +3725,7 @@ else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } \ + if { ac_try='$OL_MKDEP $flag conftest.c'; { (eval echo configure:3729: \"$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 @@ -3703,17 +3763,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:3707: checking for $ac_hdr" >&5 +echo "configure:3767: 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:3717: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3777: \"$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* @@ -3746,7 +3806,7 @@ done fi echo $ac_n "checking for lt_dlinit in -lltdl""... $ac_c" 1>&6 -echo "configure:3750: checking for lt_dlinit in -lltdl" >&5 +echo "configure:3810: 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 @@ -3754,7 +3814,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:3829: \"$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 @@ -3808,13 +3868,13 @@ fi # test for EBCDIC echo $ac_n "checking for EBCDIC""... $ac_c" 1>&6 -echo "configure:3812: checking for EBCDIC" >&5 +echo "configure:3872: 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:3887: \"$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* @@ -3847,12 +3907,12 @@ EOF fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:3851: checking for ANSI C header files" >&5 +echo "configure:3911: 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 @@ -3860,7 +3920,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3864: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3924: \"$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* @@ -3877,7 +3937,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 @@ -3895,7 +3955,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 @@ -3916,7 +3976,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #ifndef HAVE_EBCDIC @@ -3934,7 +3994,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:3938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -3968,12 +4028,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:3972: checking for $ac_hdr that defines DIR" >&5 +echo "configure:4032: 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> @@ -3981,7 +4041,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:3985: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -4006,7 +4066,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:4010: checking for opendir in -ldir" >&5 +echo "configure:4070: 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 @@ -4014,7 +4074,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:4089: \"$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 @@ -4047,7 +4107,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:4051: checking for opendir in -lx" >&5 +echo "configure:4111: 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 @@ -4055,7 +4115,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:4130: \"$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 @@ -4089,12 +4149,12 @@ fi fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:4093: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:4153: 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 @@ -4110,7 +4170,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:4114: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4174: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -4131,12 +4191,12 @@ EOF fi echo $ac_n "checking POSIX termios""... $ac_c" 1>&6 -echo "configure:4135: checking POSIX termios" >&5 +echo "configure:4195: 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 @@ -4146,7 +4206,7 @@ int main() { tcgetattr(0, 0); ; return 0; } EOF -if { (eval echo configure:4150: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4210: \"$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 @@ -4162,7 +4222,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:4166: checking whether use of TIOCGWINSZ requires sys/ioctl.h" >&5 +echo "configure:4226: 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 @@ -4171,7 +4231,7 @@ else gwinsz_in_termios_h=no if test $am_cv_sys_posix_termios = yes; then cat > conftest.$ac_ext < # include @@ -4191,7 +4251,7 @@ rm -f conftest* if test $gwinsz_in_termios_h = no; then cat > conftest.$ac_ext < # include @@ -4247,7 +4307,6 @@ for ac_hdr in \ resolv.h \ sgtty.h \ shadow.h \ - stdarg.h \ stddef.h \ string.h \ strings.h \ @@ -4270,17 +4329,17 @@ for ac_hdr in \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4274: checking for $ac_hdr" >&5 +echo "configure:4333: 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:4284: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4343: \"$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* @@ -4310,12 +4369,12 @@ done echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:4314: checking for socket" >&5 +echo "configure:4373: 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:4402: \"$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 @@ -4358,7 +4417,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:4362: checking for main in -lsocket" >&5 +echo "configure:4421: 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 @@ -4366,14 +4425,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:4436: \"$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 @@ -4401,7 +4460,7 @@ else fi echo $ac_n "checking for main in -lnet""... $ac_c" 1>&6 -echo "configure:4405: checking for main in -lnet" >&5 +echo "configure:4464: 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 @@ -4409,14 +4468,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:4479: \"$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 @@ -4444,7 +4503,7 @@ else fi echo $ac_n "checking for socket in -lnet""... $ac_c" 1>&6 -echo "configure:4448: checking for socket in -lnet" >&5 +echo "configure:4507: checking for socket in -lnet" >&5 ac_lib_var=`echo net'_'socket | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4452,7 +4511,7 @@ 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:4526: \"$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 @@ -4491,7 +4550,7 @@ else fi echo $ac_n "checking for main in -lnsl_s""... $ac_c" 1>&6 -echo "configure:4495: checking for main in -lnsl_s" >&5 +echo "configure:4554: 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 @@ -4499,14 +4558,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:4569: \"$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 @@ -4534,7 +4593,7 @@ else fi echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:4538: checking for main in -lnsl" >&5 +echo "configure:4597: 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 @@ -4542,14 +4601,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:4612: \"$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 @@ -4577,7 +4636,7 @@ else fi echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6 -echo "configure:4581: checking for socket in -linet" >&5 +echo "configure:4640: 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 @@ -4585,7 +4644,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:4659: \"$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 @@ -4624,7 +4683,7 @@ else fi echo $ac_n "checking for main in -lgen""... $ac_c" 1>&6 -echo "configure:4628: checking for main in -lgen" >&5 +echo "configure:4687: 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 @@ -4632,14 +4691,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:4702: \"$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 @@ -4671,12 +4730,12 @@ fi echo $ac_n "checking for select""... $ac_c" 1>&6 -echo "configure:4675: checking for select" >&5 +echo "configure:4734: 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:4763: \"$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 @@ -4722,7 +4781,7 @@ fi echo $ac_n "checking types of arguments for select()""... $ac_c" 1>&6 -echo "configure:4726: checking types of arguments for select()" >&5 +echo "configure:4785: 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 @@ -4736,7 +4795,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 < @@ -4755,7 +4814,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:4759: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4818: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_not_found=no ; break 3 else @@ -4799,17 +4858,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:4803: checking for $ac_hdr" >&5 +echo "configure:4862: 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:4813: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4872: \"$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* @@ -4839,12 +4898,12 @@ if test "$ac_cv_header_regex_h" != yes ; then { echo "configure: error: POSIX regex.h required." 1>&2; exit 1; } fi echo $ac_n "checking for regfree""... $ac_c" 1>&6 -echo "configure:4843: checking for regfree" >&5 +echo "configure:4902: checking for regfree" >&5 if eval "test \"\${ac_cv_func_regfree+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:4931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_regfree=yes" else @@ -4891,7 +4950,7 @@ fi echo $ac_n "checking for compatible POSIX regex""... $ac_c" 1>&6 -echo "configure:4895: checking for compatible POSIX regex" >&5 +echo "configure:4954: 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 @@ -4900,7 +4959,7 @@ else ol_cv_c_posix_regex=cross else cat > conftest.$ac_ext < @@ -4926,7 +4985,7 @@ main() return rc; } EOF -if { (eval echo configure:4930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_c_posix_regex=yes else @@ -4946,9 +5005,8 @@ if test "$ol_cv_c_posix_regex" = no ; then { echo "configure: error: broken POSIX regex!" 1>&2; exit 1; } fi - echo $ac_n "checking for sigset in -lV3""... $ac_c" 1>&6 -echo "configure:4952: checking for sigset in -lV3" >&5 +echo "configure:5010: 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 @@ -4956,7 +5014,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:5029: \"$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 @@ -4996,12 +5054,12 @@ fi echo $ac_n "checking for res_search""... $ac_c" 1>&6 -echo "configure:5000: checking for res_search" >&5 +echo "configure:5058: checking for res_search" >&5 if eval "test \"\${ac_cv_func_res_search+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:5087: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_res_search=yes" else @@ -5046,7 +5104,7 @@ fi if test $ac_cv_func_res_search = no ; then echo $ac_n "checking for res_search in -lbind""... $ac_c" 1>&6 -echo "configure:5050: checking for res_search in -lbind" >&5 +echo "configure:5108: checking for res_search in -lbind" >&5 ac_lib_var=`echo bind'_'res_search | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5054,7 +5112,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lbind $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5127: \"$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 @@ -5097,7 +5155,7 @@ fi if test $ac_cv_func_res_search = no ; then echo $ac_n "checking for __res_search in -lbind""... $ac_c" 1>&6 -echo "configure:5101: checking for __res_search in -lbind" >&5 +echo "configure:5159: checking for __res_search in -lbind" >&5 ac_lib_var=`echo bind'_'__res_search | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5105,7 +5163,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lbind $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5178: \"$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 @@ -5148,7 +5206,7 @@ fi if test $ac_cv_func_res_search = no ; then echo $ac_n "checking for res_search in -lresolv""... $ac_c" 1>&6 -echo "configure:5152: checking for res_search in -lresolv" >&5 +echo "configure:5210: checking for res_search in -lresolv" >&5 ac_lib_var=`echo resolv'_'res_search | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5156,7 +5214,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lresolv $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5229: \"$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 @@ -5215,17 +5273,17 @@ if test $ol_enable_quipu != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5219: checking for $ac_hdr" >&5 +echo "configure:5277: 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:5229: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5287: \"$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* @@ -5268,17 +5326,17 @@ if test $ol_with_kerberos = auto -o $ol_with_kerberos = k5 ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5272: checking for $ac_hdr" >&5 +echo "configure:5330: 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:5282: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5340: \"$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* @@ -5307,7 +5365,7 @@ done if test $ac_cv_header_kerberosIV_krb_h = yes ; then echo $ac_n "checking for main in -lkrb4""... $ac_c" 1>&6 -echo "configure:5311: checking for main in -lkrb4" >&5 +echo "configure:5369: 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 @@ -5315,14 +5373,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lkrb4 -lkrb5 -ldes425 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5384: \"$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 @@ -5353,7 +5411,7 @@ fi LIBS="$KRB_LIBS $LIBS" echo $ac_n "checking for des_debug in Kerberos libraries""... $ac_c" 1>&6 -echo "configure:5357: checking for des_debug in Kerberos libraries" >&5 +echo "configure:5415: 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 @@ -5361,7 +5419,7 @@ else save_LIBS="$LIBS" LIBS="$KRB_LIBS $LIBS" cat > conftest.$ac_ext < @@ -5374,7 +5432,7 @@ des_debug = 1; ; return 0; } EOF -if { (eval echo configure:5378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5436: \"$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 @@ -5407,17 +5465,17 @@ if test $ol_with_kerberos = auto -o $ol_with_kerberos = k4 ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5411: checking for $ac_hdr" >&5 +echo "configure:5469: 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:5421: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5479: \"$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* @@ -5446,7 +5504,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:5450: checking for main in -lkrb" >&5 +echo "configure:5508: 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 @@ -5454,14 +5512,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:5523: \"$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 @@ -5506,17 +5564,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:5510: checking for $ac_hdr" >&5 +echo "configure:5568: 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:5520: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5578: \"$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* @@ -5545,7 +5603,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:5549: checking for SSLeay_add_ssl_algorithms in -lssl" >&5 +echo "configure:5607: 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 @@ -5553,7 +5611,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:5626: \"$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 @@ -5589,7 +5647,7 @@ fi if test $have_ssleay = no ; then echo $ac_n "checking for SSL_library_init in -lssl""... $ac_c" 1>&6 -echo "configure:5593: checking for SSL_library_init in -lssl" >&5 +echo "configure:5651: 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 @@ -5597,7 +5655,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:5670: \"$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 @@ -5634,7 +5692,7 @@ fi if test $have_ssleay = no ; then echo $ac_n "checking for ssl3_accept in -lssl""... $ac_c" 1>&6 -echo "configure:5638: checking for ssl3_accept in -lssl" >&5 +echo "configure:5696: 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 @@ -5642,7 +5700,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:5715: \"$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 @@ -5713,12 +5771,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5717: checking for $ac_func" >&5 +echo "configure:5775: 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:5804: \"$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 @@ -5771,19 +5829,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:5775: checking number of arguments of ctime_r" >&5 +echo "configure:5833: 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:5787: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5845: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_ctime_r_nargs=3 else @@ -5791,14 +5849,14 @@ else cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < int main() { time_t ti; char *buffer; ctime_r(&ti,buffer); ; return 0; } EOF -if { (eval echo configure:5802: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5860: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_ctime_r_nargs=2 else @@ -5824,12 +5882,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:5828: checking number of arguments of gethostbyname_r" >&5 +echo "configure:5886: 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 @@ -5843,7 +5901,7 @@ struct hostent hent; char buffer[BUFSIZE]; buffer, bufsize, &h_errno); ; return 0; } EOF -if { (eval echo configure:5847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_gethostbyname_r_nargs=5 else @@ -5851,7 +5909,7 @@ else cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < #include @@ -5866,7 +5924,7 @@ struct hostent hent;struct hostent *rhent; &rhent, &h_errno); ; return 0; } EOF -if { (eval echo configure:5870: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_gethostbyname_r_nargs=6 else @@ -5894,12 +5952,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:5898: checking number of arguments of gethostbyaddr_r" >&5 +echo "configure:5956: 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 @@ -5915,7 +5973,7 @@ struct hostent hent; char buffer[BUFSIZE]; alen, AF_INET, &hent, buffer, bufsize, &h_errno); ; return 0; } EOF -if { (eval echo configure:5919: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_gethostbyaddr_r_nargs=7 else @@ -5923,7 +5981,7 @@ else cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < #include @@ -5941,7 +5999,7 @@ struct hostent hent; &rhent, &h_errno); ; return 0; } EOF -if { (eval echo configure:5945: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6003: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_gethostbyaddr_r_nargs=8 else @@ -5988,21 +6046,21 @@ ol_link_threads=no if test $ol_with_threads = auto -o $ol_with_threads = yes \ -o $ol_with_threads = posix ; then - for ac_hdr in pthread.h sched.h + for ac_hdr in pthread.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5996: checking for $ac_hdr" >&5 +echo "configure:6054: 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:6006: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6064: \"$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* @@ -6031,13 +6089,13 @@ done if test $ac_cv_header_pthread_h = yes ; then echo $ac_n "checking POSIX thread version""... $ac_c" 1>&6 -echo "configure:6035: checking POSIX thread version" >&5 +echo "configure:6093: 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 < @@ -6059,7 +6117,7 @@ rm -f conftest* cat > conftest.$ac_ext < @@ -6112,12 +6170,12 @@ EOF echo $ac_n "checking for LinuxThreads pthread.h""... $ac_c" 1>&6 -echo "configure:6116: checking for LinuxThreads pthread.h" >&5 +echo "configure:6174: 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 @@ -6142,17 +6200,90 @@ EOF fi + + echo $ac_n "checking for GNU Pth pthread.h""... $ac_c" 1>&6 +echo "configure:6206: 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 + __gnu_pth__ +#endif + +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "__gnu_pth__" >/dev/null 2>&1; then + rm -rf conftest* + ol_cv_header_gnu_pth_pthread_h=yes +else + rm -rf conftest* + ol_cv_header_gnu_pth_pthread_h=no +fi +rm -f conftest* + + +fi + +echo "$ac_t""$ol_cv_header_gnu_pth_pthread_h" 1>&6 + + + if test $ol_cv_header_gnu_pth_pthread_h = no ; then + for ac_hdr in sched.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:6240: 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:6250: \"$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* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + + fi echo $ac_n "checking for pthread_create in default libraries""... $ac_c" 1>&6 -echo "configure:6149: checking for pthread_create in default libraries" >&5 +echo "configure:6280: 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 < @@ -6196,7 +6327,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_create=yes else @@ -6208,7 +6339,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -6257,7 +6388,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:6261: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_create=yes else @@ -6282,7 +6413,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:6286: checking for pthread link with -kthread" >&5 +echo "configure:6417: 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 @@ -6293,7 +6424,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -6337,7 +6468,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_kthread=yes else @@ -6349,7 +6480,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -6398,7 +6529,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:6402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_kthread=yes else @@ -6428,7 +6559,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:6432: checking for pthread link with -pthread" >&5 +echo "configure:6563: 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 @@ -6439,7 +6570,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -6483,7 +6614,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_pthread=yes else @@ -6495,7 +6626,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -6544,7 +6675,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:6548: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_pthread=yes else @@ -6574,7 +6705,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:6578: checking for pthread link with -pthreads" >&5 +echo "configure:6709: 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 @@ -6585,7 +6716,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -6629,7 +6760,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_pthreads=yes else @@ -6641,7 +6772,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -6690,7 +6821,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:6694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_pthreads=yes else @@ -6720,7 +6851,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:6724: checking for pthread link with -mthreads" >&5 +echo "configure:6855: 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 @@ -6731,7 +6862,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -6775,7 +6906,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6910: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_mthreads=yes else @@ -6787,7 +6918,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -6836,7 +6967,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:6840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_mthreads=yes else @@ -6866,7 +6997,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:6870: checking for pthread link with -thread" >&5 +echo "configure:7001: 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 @@ -6877,7 +7008,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -6921,7 +7052,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_thread=yes else @@ -6933,7 +7064,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -6982,7 +7113,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:6986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_thread=yes else @@ -7013,7 +7144,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:7017: checking for pthread link with -lpthread -lmach -lexc -lc_r" >&5 +echo "configure:7148: 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 @@ -7024,7 +7155,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -7068,7 +7199,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7203: \"$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 @@ -7080,7 +7211,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -7129,7 +7260,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:7133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7264: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lpthread_lmach_lexc_lc_r=yes else @@ -7159,7 +7290,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:7163: checking for pthread link with -lpthread -lmach -lexc" >&5 +echo "configure:7294: 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 @@ -7170,7 +7301,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -7214,7 +7345,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7349: \"$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 @@ -7226,7 +7357,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -7275,7 +7406,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:7279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lpthread_lmach_lexc=yes else @@ -7306,7 +7437,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:7310: checking for pthread link with -lpthread -Wl,-woff,85" >&5 +echo "configure:7441: 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 @@ -7317,7 +7448,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -7361,7 +7492,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7496: \"$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 @@ -7373,7 +7504,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -7422,7 +7553,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:7426: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lib_lpthread_woff=yes else @@ -7453,7 +7584,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:7457: checking for pthread link with -lpthread" >&5 +echo "configure:7588: 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 @@ -7464,7 +7595,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -7508,7 +7639,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7512: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_lpthread=yes else @@ -7520,7 +7651,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -7569,7 +7700,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:7573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lpthread=yes else @@ -7599,7 +7730,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:7603: checking for pthread link with -lc_r" >&5 +echo "configure:7734: 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 @@ -7610,7 +7741,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -7654,7 +7785,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7789: \"$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 @@ -7666,7 +7797,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -7715,7 +7846,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:7719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lc_r=yes else @@ -7746,7 +7877,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:7750: checking for pthread link with -threads" >&5 +echo "configure:7881: 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 @@ -7757,7 +7888,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -7801,7 +7932,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_pthread_threads=yes else @@ -7813,7 +7944,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -7862,7 +7993,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:7866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_threads=yes else @@ -7893,7 +8024,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:7897: checking for pthread link with -lpthreads -lmach -lexc -lc_r" >&5 +echo "configure:8028: 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 @@ -7904,7 +8035,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -7948,7 +8079,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8083: \"$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 @@ -7960,7 +8091,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -8009,7 +8140,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:8013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lpthreads_lmach_lexc_lc_r=yes else @@ -8039,7 +8170,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:8043: checking for pthread link with -lpthreads -lmach -lexc" >&5 +echo "configure:8174: 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 @@ -8050,7 +8181,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -8094,7 +8225,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8229: \"$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 @@ -8106,7 +8237,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -8155,7 +8286,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:8159: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lpthreads_lmach_lexc=yes else @@ -8185,7 +8316,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:8189: checking for pthread link with -lpthreads -lexc" >&5 +echo "configure:8320: 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 @@ -8196,7 +8327,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -8240,7 +8371,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8375: \"$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 @@ -8252,7 +8383,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -8301,7 +8432,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:8305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lpthreads_lexc=yes else @@ -8332,7 +8463,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:8336: checking for pthread link with -lpthreads" >&5 +echo "configure:8467: 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 @@ -8343,7 +8474,7 @@ else if test "$cross_compiling" = yes; then cat > conftest.$ac_ext < @@ -8387,7 +8518,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8522: \"$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 @@ -8399,7 +8530,7 @@ fi rm -f conftest* else cat > conftest.$ac_ext < @@ -8448,7 +8579,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:8452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_lib_lpthreads=yes else @@ -8490,12 +8621,12 @@ EOF for ac_func in sched_yield pthread_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8494: checking for $ac_func" >&5 +echo "configure:8625: 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:8654: \"$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 @@ -8547,7 +8678,7 @@ done if test $ac_cv_func_sched_yield = no -a \ $ac_cv_func_pthread_yield = no ; then echo $ac_n "checking for sched_yield in -lrt""... $ac_c" 1>&6 -echo "configure:8551: checking for sched_yield in -lrt" >&5 +echo "configure:8682: 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 @@ -8555,7 +8686,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:8701: \"$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 @@ -8598,12 +8729,12 @@ fi for ac_func in thr_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8602: checking for $ac_func" >&5 +echo "configure:8733: 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:8762: \"$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 @@ -8661,12 +8792,12 @@ done for ac_func in pthread_kill do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8665: checking for $ac_func" >&5 +echo "configure:8796: 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:8825: \"$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 @@ -8716,13 +8847,13 @@ done echo $ac_n "checking for pthread_detach with ""... $ac_c" 1>&6 -echo "configure:8720: checking for pthread_detach with " >&5 +echo "configure:8851: 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 < @@ -8734,7 +8865,7 @@ int main() { pthread_detach(NULL); ; return 0; } EOF -if { (eval echo configure:8738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8869: \"$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 @@ -8766,12 +8897,12 @@ EOF do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8770: checking for $ac_func" >&5 +echo "configure:8901: 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:8930: \"$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 @@ -8822,12 +8953,12 @@ done echo $ac_n "checking for pthread_kill_other_threads_np""... $ac_c" 1>&6 -echo "configure:8826: checking for pthread_kill_other_threads_np" >&5 +echo "configure:8957: checking for pthread_kill_other_threads_np" >&5 if eval "test \"\${ac_cv_func_pthread_kill_other_threads_np+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:8986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_pthread_kill_other_threads_np=yes" else @@ -8871,7 +9002,7 @@ else fi echo $ac_n "checking for LinuxThreads implementation""... $ac_c" 1>&6 -echo "configure:8875: checking for LinuxThreads implementation" >&5 +echo "configure:9006: 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 @@ -8884,7 +9015,7 @@ echo "$ac_t""$ol_cv_sys_linux_threads" 1>&6 echo $ac_n "checking for LinuxThreads consistency""... $ac_c" 1>&6 -echo "configure:8888: checking for LinuxThreads consistency" >&5 +echo "configure:9019: checking for LinuxThreads consistency" >&5 if eval "test \"\${ol_cv_linux_threads+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8909,7 +9040,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:8913: checking if pthread_create() works" >&5 +echo "configure:9044: 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 @@ -8918,7 +9049,7 @@ else ol_cv_pthread_create_works=yes else cat > conftest.$ac_ext < @@ -8967,7 +9098,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:8971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:9102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_create_works=yes else @@ -8989,7 +9120,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:8993: checking if select yields when using pthreads" >&5 +echo "configure:9124: 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 @@ -8998,7 +9129,7 @@ else ol_cv_pthread_select_yields=cross else cat > conftest.$ac_ext < @@ -9074,7 +9205,7 @@ int main(argc, argv) exit(2); } EOF -if { (eval echo configure:9078: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:9209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_pthread_select_yields=no else @@ -9118,17 +9249,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:9122: checking for $ac_hdr" >&5 +echo "configure:9253: 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:9132: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9263: \"$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* @@ -9158,12 +9289,12 @@ done ol_with_threads=found echo $ac_n "checking for cthread_fork""... $ac_c" 1>&6 -echo "configure:9162: checking for cthread_fork" >&5 +echo "configure:9293: 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:9322: \"$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 @@ -9209,7 +9340,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:9213: checking for cthread_fork with -all_load" >&5 +echo "configure:9344: 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 @@ -9217,7 +9348,7 @@ else save_LIBS="$LIBS" LIBS="-all_load $LIBS" cat > conftest.$ac_ext < int main() { @@ -9226,7 +9357,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:9230: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9361: \"$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 @@ -9264,6 +9395,108 @@ EOF fi fi +if test $ol_with_threads = auto -o $ol_with_threads = yes \ + -o $ol_with_threads = pth ; then + + for ac_hdr in pth.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:9406: 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:9416: \"$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* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +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:9445: 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 +else + ac_save_LIBS="$LIBS" +LIBS="-lpth $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + have_pth=yes +else + echo "$ac_t""no" 1>&6 +have_pth=no +fi + + + if test $have_pth = yes ; then + cat >> confdefs.h <<\EOF +#define HAVE_GNU_PTH 1 +EOF + + LTHREAD_LIBS="$LTHREAD_LIBS -lpth" + ol_link_threads=pth + + if test $ol_with_yielding_select = auto ; then + ol_with_yielding_select=yes + fi + fi + fi +fi + if test $ol_with_threads = auto -o $ol_with_threads = yes \ -o $ol_with_threads = lwp ; then @@ -9271,17 +9504,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:9275: checking for $ac_hdr" >&5 +echo "configure:9508: 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:9285: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9518: \"$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* @@ -9309,7 +9542,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:9313: checking for thr_create in -lthread" >&5 +echo "configure:9546: 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 @@ -9317,7 +9550,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:9565: \"$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 @@ -9368,12 +9601,12 @@ EOF do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:9372: checking for $ac_func" >&5 +echo "configure:9605: 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:9634: \"$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 @@ -9428,17 +9661,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:9432: checking for $ac_hdr" >&5 +echo "configure:9665: 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:9442: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9675: \"$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* @@ -9466,7 +9699,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:9470: checking for lwp_create in -llwp" >&5 +echo "configure:9703: 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 @@ -9474,7 +9707,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:9722: \"$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 @@ -9538,17 +9771,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:9542: checking for $ac_hdr" >&5 +echo "configure:9775: 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:9552: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9785: \"$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* @@ -9577,12 +9810,12 @@ done for ac_func in sched_yield pthread_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:9581: checking for $ac_func" >&5 +echo "configure:9814: 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:9843: \"$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 @@ -9632,12 +9865,12 @@ done echo $ac_n "checking for LinuxThreads pthread.h""... $ac_c" 1>&6 -echo "configure:9636: checking for LinuxThreads pthread.h" >&5 +echo "configure:9869: 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 @@ -9667,17 +9900,17 @@ EOF do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:9671: checking for $ac_hdr" >&5 +echo "configure:9904: 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:9681: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9914: \"$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* @@ -9707,17 +9940,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:9711: checking for $ac_hdr" >&5 +echo "configure:9944: 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:9721: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9954: \"$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* @@ -9747,17 +9980,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:9751: checking for $ac_hdr" >&5 +echo "configure:9984: 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:9761: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9994: \"$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* @@ -9816,20 +10049,20 @@ EOF echo $ac_n "checking for thread specific errno""... $ac_c" 1>&6 -echo "configure:9820: checking for thread specific errno" >&5 +echo "configure:10053: 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:9833: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10066: \"$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 @@ -9845,20 +10078,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:9849: checking for thread specific h_errno" >&5 +echo "configure:10082: 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:9862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10095: \"$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 @@ -9909,13 +10142,13 @@ fi ol_link_ldbm=no if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then echo $ac_n "checking for DB2 library""... $ac_c" 1>&6 -echo "configure:9913: checking for DB2 library" >&5 +echo "configure:10146: checking for DB2 library" >&5 if eval "test \"\${ol_cv_lib_db2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for db_open in -ldb""... $ac_c" 1>&6 -echo "configure:9919: checking for db_open in -ldb" >&5 +echo "configure:10152: checking for db_open in -ldb" >&5 ac_lib_var=`echo db'_'db_open | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9923,7 +10156,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldb $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10171: \"$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 @@ -9965,17 +10198,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:9969: checking for $ac_hdr" >&5 +echo "configure:10202: 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:9979: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10212: \"$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* @@ -10003,13 +10236,13 @@ done if test $ac_cv_header_db_h = yes ; then echo $ac_n "checking if db.h is DB2""... $ac_c" 1>&6 -echo "configure:10007: checking if db.h is DB2" >&5 +echo "configure:10240: checking if db.h is DB2" >&5 if eval "test \"\${ol_cv_header_db2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -10041,7 +10274,7 @@ fi echo $ac_n "checking for Berkeley DB2""... $ac_c" 1>&6 -echo "configure:10045: checking for Berkeley DB2" >&5 +echo "configure:10278: checking for Berkeley DB2" >&5 if eval "test \"\${ol_cv_berkeley_db2+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10092,7 +10325,7 @@ fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then echo $ac_n "checking for Berkeley DB library""... $ac_c" 1>&6 -echo "configure:10096: checking for Berkeley DB library" >&5 +echo "configure:10329: checking for Berkeley DB library" >&5 if eval "test \"\${ol_cv_lib_db+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10101,17 +10334,17 @@ else do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:10105: checking for $ac_hdr" >&5 +echo "configure:10338: 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:10115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10348: \"$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* @@ -10139,12 +10372,12 @@ done ol_LIBS="$LIBS" echo $ac_n "checking for dbopen""... $ac_c" 1>&6 -echo "configure:10143: checking for dbopen" >&5 +echo "configure:10376: checking for dbopen" >&5 if eval "test \"\${ac_cv_func_dbopen+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:10405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_dbopen=yes" else @@ -10187,7 +10420,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbopen in -ldb1""... $ac_c" 1>&6 -echo "configure:10191: checking for dbopen in -ldb1" >&5 +echo "configure:10424: checking for dbopen in -ldb1" >&5 ac_lib_var=`echo db1'_'dbopen | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -10195,7 +10428,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldb1 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10443: \"$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 @@ -10226,7 +10459,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6 -echo "configure:10230: checking for dbopen in -ldb" >&5 +echo "configure:10463: checking for dbopen in -ldb" >&5 ac_lib_var=`echo db'_'dbopen | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -10234,7 +10467,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldb $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10482: \"$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 @@ -10283,17 +10516,17 @@ for ac_hdr in db_185.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:10287: checking for $ac_hdr" >&5 +echo "configure:10520: 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:10297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10530: \"$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* @@ -10329,7 +10562,7 @@ fi echo $ac_n "checking for Berkeley DB""... $ac_c" 1>&6 -echo "configure:10333: checking for Berkeley DB" >&5 +echo "configure:10566: checking for Berkeley DB" >&5 if eval "test \"\${ol_cv_berkeley_db+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10382,17 +10615,17 @@ if test $ol_with_ldbm_api = manual ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:10386: checking for $ac_hdr" >&5 +echo "configure:10619: 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:10396: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10629: \"$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* @@ -10427,18 +10660,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:10431: checking for MDBM library" >&5 +echo "configure:10664: 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:10437: checking for mdbm_set_chain" >&5 +echo "configure:10670: 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:10699: \"$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 @@ -10481,7 +10714,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for mdbm_set_chain in -lmdbm""... $ac_c" 1>&6 -echo "configure:10485: checking for mdbm_set_chain in -lmdbm" >&5 +echo "configure:10718: 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 @@ -10489,7 +10722,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:10737: \"$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 @@ -10535,17 +10768,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:10539: checking for $ac_hdr" >&5 +echo "configure:10772: 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:10549: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10782: \"$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* @@ -10572,7 +10805,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:10576: checking for db" >&5 +echo "configure:10809: checking for db" >&5 if eval "test \"\${ol_cv_mdbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10605,18 +10838,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:10609: checking for GDBM library" >&5 +echo "configure:10842: 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:10615: checking for gdbm_open" >&5 +echo "configure:10848: 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:10877: \"$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 @@ -10659,7 +10892,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6 -echo "configure:10663: checking for gdbm_open in -lgdbm" >&5 +echo "configure:10896: 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 @@ -10667,7 +10900,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:10915: \"$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 @@ -10713,17 +10946,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:10717: checking for $ac_hdr" >&5 +echo "configure:10950: 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:10727: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:10960: \"$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* @@ -10750,7 +10983,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:10754: checking for db" >&5 +echo "configure:10987: checking for db" >&5 if eval "test \"\${ol_cv_gdbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -10786,18 +11019,18 @@ if test $ol_with_ldbm_api = auto ; then echo "configure: warning: skipping automatic checking for NDBM, must be manually enabled." 1>&2 elif test $ol_with_ldbm_api = ndbm ; then echo $ac_n "checking for NDBM library""... $ac_c" 1>&6 -echo "configure:10790: checking for NDBM library" >&5 +echo "configure:11023: 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:10796: checking for dbm_open" >&5 +echo "configure:11029: 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:11058: \"$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 @@ -10840,7 +11073,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbm_open in -lndbm""... $ac_c" 1>&6 -echo "configure:10844: checking for dbm_open in -lndbm" >&5 +echo "configure:11077: 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 @@ -10848,7 +11081,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:11096: \"$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 @@ -10879,7 +11112,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6 -echo "configure:10883: checking for dbm_open in -ldbm" >&5 +echo "configure:11116: 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 @@ -10887,7 +11120,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:11135: \"$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 @@ -10935,17 +11168,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:10939: checking for $ac_hdr" >&5 +echo "configure:11172: 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:10949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11182: \"$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* @@ -10972,7 +11205,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:10976: checking for db" >&5 +echo "configure:11209: checking for db" >&5 if eval "test \"\${ol_cv_ndbm+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -11019,17 +11252,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:11023: checking for $ac_hdr" >&5 +echo "configure:11256: 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:11033: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11266: \"$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* @@ -11060,7 +11293,7 @@ done have_wrappers=no else echo $ac_n "checking for main in -lwrap""... $ac_c" 1>&6 -echo "configure:11064: checking for main in -lwrap" >&5 +echo "configure:11297: checking for main in -lwrap" >&5 ac_lib_var=`echo wrap'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11068,14 +11301,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lwrap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11312: \"$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 @@ -11106,7 +11339,7 @@ EOF SLAPD_LIBS="$SLAPD_LIBS -lwrap" echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:11110: checking for main in -lnsl" >&5 +echo "configure:11343: 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 @@ -11114,14 +11347,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:11358: \"$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 @@ -11161,12 +11394,12 @@ fi if test $ol_enable_syslog != no ; then echo $ac_n "checking for openlog""... $ac_c" 1>&6 -echo "configure:11165: checking for openlog" >&5 +echo "configure:11398: 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:11427: \"$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 @@ -11220,17 +11453,17 @@ if test $ol_enable_dmalloc != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11224: checking for $ac_hdr" >&5 +echo "configure:11457: 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:11234: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11467: \"$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* @@ -11257,7 +11490,7 @@ fi done echo $ac_n "checking for dmalloc_shutdown in -ldmalloc""... $ac_c" 1>&6 -echo "configure:11261: checking for dmalloc_shutdown in -ldmalloc" >&5 +echo "configure:11494: checking for dmalloc_shutdown in -ldmalloc" >&5 ac_lib_var=`echo dmalloc'_'dmalloc_shutdown | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11265,7 +11498,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldmalloc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11513: \"$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 @@ -11310,17 +11543,17 @@ if test $ol_enable_tcl != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11314: checking for $ac_hdr" >&5 +echo "configure:11547: 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:11324: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11557: \"$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* @@ -11351,7 +11584,7 @@ done have_tcl=no else echo $ac_n "checking for main in -ltcl""... $ac_c" 1>&6 -echo "configure:11355: checking for main in -ltcl" >&5 +echo "configure:11588: checking for main in -ltcl" >&5 ac_lib_var=`echo tcl'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11359,14 +11592,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltcl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11603: \"$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 @@ -11390,7 +11623,7 @@ fi if test $have_tcl != yes; then echo $ac_n "checking for main in -ltcl7.6""... $ac_c" 1>&6 -echo "configure:11394: checking for main in -ltcl7.6" >&5 +echo "configure:11627: checking for main in -ltcl7.6" >&5 ac_lib_var=`echo tcl7.6'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11398,14 +11631,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltcl7.6 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11642: \"$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 @@ -11430,7 +11663,7 @@ fi if test $have_tcl != yes; then echo $ac_n "checking for main in -ltcl8.0""... $ac_c" 1>&6 -echo "configure:11434: checking for main in -ltcl8.0" >&5 +echo "configure:11667: checking for main in -ltcl8.0" >&5 ac_lib_var=`echo tcl8.0'_'main | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11438,14 +11671,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltcl8.0 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11682: \"$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 @@ -11485,17 +11718,17 @@ for ac_hdr in termcap.h ncurses.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11489: checking for $ac_hdr" >&5 +echo "configure:11722: 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:11499: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11732: \"$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* @@ -11524,7 +11757,7 @@ done if test $ol_link_termcap = no ; then echo $ac_n "checking for tputs in -ltermcap""... $ac_c" 1>&6 -echo "configure:11528: checking for tputs in -ltermcap" >&5 +echo "configure:11761: checking for tputs in -ltermcap" >&5 ac_lib_var=`echo termcap'_'tputs | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11532,7 +11765,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ltermcap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11780: \"$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 @@ -11576,7 +11809,7 @@ fi if test $ol_link_termcap = no ; then echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6 -echo "configure:11580: checking for initscr in -lncurses" >&5 +echo "configure:11813: checking for initscr in -lncurses" >&5 ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11584,7 +11817,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11832: \"$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 @@ -11638,17 +11871,17 @@ ol_link_sasl=no if test $ol_with_cyrus_sasl != no ; then ac_safe=`echo "sasl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for sasl.h""... $ac_c" 1>&6 -echo "configure:11642: checking for sasl.h" >&5 +echo "configure:11875: checking for sasl.h" >&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:11652: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:11885: \"$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* @@ -11672,7 +11905,7 @@ fi if test $ac_cv_header_sasl_h = yes ; then echo $ac_n "checking for sasl_client_init in -lsasl""... $ac_c" 1>&6 -echo "configure:11676: checking for sasl_client_init in -lsasl" >&5 +echo "configure:11909: 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 @@ -11680,7 +11913,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:11928: \"$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 @@ -11733,13 +11966,13 @@ if test $ol_with_fetch != no ; then ol=$LIBS LIBS="-lfetch -lcom_err $LIBS" echo $ac_n "checking fetch(3) library""... $ac_c" 1>&6 -echo "configure:11737: checking fetch(3) library" >&5 +echo "configure:11970: 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 < @@ -11749,7 +11982,7 @@ int main() { struct url *u = fetchParseURL("file:///"); ; return 0; } EOF -if { (eval echo configure:11753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:11986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_lib_fetch=yes else @@ -11787,17 +12020,17 @@ if test $ol_with_readline != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:11791: checking for $ac_hdr" >&5 +echo "configure:12024: 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:11801: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:12034: \"$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* @@ -11828,7 +12061,7 @@ done save_LIBS="$LIBS" LIBS="$TERMCAP_LIBS $LIBS" echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6 -echo "configure:11832: checking for readline in -lreadline" >&5 +echo "configure:12065: checking for readline in -lreadline" >&5 ac_lib_var=`echo readline'_'readline | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -11836,7 +12069,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lreadline $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:12084: \"$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 @@ -11890,12 +12123,12 @@ fi # FreeBSD (and others) have crypt(3) in -lcrypt if test $ol_enable_crypt != no ; then echo $ac_n "checking for crypt""... $ac_c" 1>&6 -echo "configure:11894: checking for crypt" >&5 +echo "configure:12127: 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:12156: \"$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 @@ -11938,7 +12171,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6 -echo "configure:11942: checking for crypt in -lcrypt" >&5 +echo "configure:12175: 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 @@ -11946,7 +12179,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:12194: \"$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 @@ -12001,12 +12234,12 @@ fi # FreeBSD (and others) have setproctitle(3) in -lutil if test $ol_enable_proctitle != no ; then echo $ac_n "checking for setproctitle""... $ac_c" 1>&6 -echo "configure:12005: checking for setproctitle" >&5 +echo "configure:12238: 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:12267: \"$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 @@ -12049,7 +12282,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for setproctitle in -lutil""... $ac_c" 1>&6 -echo "configure:12053: checking for setproctitle in -lutil" >&5 +echo "configure:12286: 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 @@ -12057,7 +12290,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:12305: \"$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 @@ -12103,12 +12336,12 @@ EOF fi echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:12107: checking for uid_t in sys/types.h" >&5 +echo "configure:12340: 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 @@ -12137,7 +12370,7 @@ EOF fi echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6 -echo "configure:12141: checking type of array argument to getgroups" >&5 +echo "configure:12374: checking type of array argument to getgroups" >&5 if eval "test \"\${ac_cv_type_getgroups+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -12145,7 +12378,7 @@ else ac_cv_type_getgroups=cross else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:12407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_type_getgroups=gid_t else @@ -12184,7 +12417,7 @@ fi if test $ac_cv_type_getgroups = cross; then cat > conftest.$ac_ext < EOF @@ -12207,12 +12440,12 @@ cat >> confdefs.h <&6 -echo "configure:12211: checking for ANSI C header files" >&5 +echo "configure:12444: 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 @@ -12220,7 +12453,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:12224: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:12457: \"$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* @@ -12237,7 +12470,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 @@ -12255,7 +12488,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 @@ -12276,7 +12509,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -12287,7 +12520,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:12291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:12524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -12311,12 +12544,12 @@ EOF fi echo $ac_n "checking for mode_t""... $ac_c" 1>&6 -echo "configure:12315: checking for mode_t" >&5 +echo "configure:12548: 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 @@ -12346,12 +12579,12 @@ EOF fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:12350: checking for off_t" >&5 +echo "configure:12583: 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 @@ -12381,12 +12614,12 @@ EOF fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:12385: checking for pid_t" >&5 +echo "configure:12618: 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 @@ -12416,19 +12649,19 @@ EOF fi echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6 -echo "configure:12420: checking for ptrdiff_t" >&5 +echo "configure:12653: 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:12432: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12665: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_type_ptrdiff_t=yes else @@ -12449,12 +12682,12 @@ EOF fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:12453: checking return type of signal handlers" >&5 +echo "configure:12686: 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 @@ -12471,7 +12704,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:12475: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12708: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -12490,19 +12723,19 @@ EOF echo $ac_n "checking for sig_atomic_t""... $ac_c" 1>&6 -echo "configure:12494: checking for sig_atomic_t" >&5 +echo "configure:12727: 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:12506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12739: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_type_sig_atomic_t=yes else @@ -12523,12 +12756,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:12527: checking for size_t" >&5 +echo "configure:12760: 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 @@ -12558,12 +12791,12 @@ EOF fi echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 -echo "configure:12562: checking for socklen_t" >&5 +echo "configure:12795: 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:12814: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_type_socklen_t=yes else @@ -12598,12 +12831,12 @@ EOF fi echo $ac_n "checking for member st_blksize in aggregate type struct stat""... $ac_c" 1>&6 -echo "configure:12602: checking for member st_blksize in aggregate type struct stat" >&5 +echo "configure:12835: 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 @@ -12611,7 +12844,7 @@ int main() { struct stat foo; foo.st_blksize; ; return 0; } EOF -if { (eval echo configure:12615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12848: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_struct_member_st_blksize=yes else @@ -12633,12 +12866,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:12637: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:12870: 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 @@ -12647,7 +12880,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:12651: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12884: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -12668,12 +12901,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:12672: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:12905: 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 @@ -12681,7 +12914,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:12685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12918: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -12703,13 +12936,13 @@ fi # test for pw_gecos in struct passwd echo $ac_n "checking struct passwd for pw_gecos""... $ac_c" 1>&6 -echo "configure:12707: checking struct passwd for pw_gecos" >&5 +echo "configure:12940: 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() { @@ -12719,7 +12952,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:12723: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12956: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_struct_passwd_pw_gecos=yes else @@ -12741,13 +12974,13 @@ fi # test for pw_passwd in struct passwd echo $ac_n "checking struct passwd for pw_passwd""... $ac_c" 1>&6 -echo "configure:12745: checking struct passwd for pw_passwd" >&5 +echo "configure:12978: 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() { @@ -12757,7 +12990,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:12761: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12994: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_struct_passwd_pw_passwd=yes else @@ -12779,7 +13012,7 @@ fi echo $ac_n "checking if toupper() requires islower()""... $ac_c" 1>&6 -echo "configure:12783: checking if toupper() requires islower()" >&5 +echo "configure:13016: 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 @@ -12788,7 +13021,7 @@ else ol_cv_c_upper_lower=safe else cat > conftest.$ac_ext < @@ -12800,7 +13033,7 @@ main() exit(1); } EOF -if { (eval echo configure:12804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:13037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ol_cv_c_upper_lower=no else @@ -12823,12 +13056,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:12827: checking for working const" >&5 +echo "configure:13060: 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:13114: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -12898,12 +13131,12 @@ EOF fi echo $ac_n "checking if compiler understands volatile""... $ac_c" 1>&6 -echo "configure:12902: checking if compiler understands volatile" >&5 +echo "configure:13135: 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:13149: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_c_volatile=yes else @@ -12956,14 +13189,14 @@ EOF else echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:12960: checking whether byte ordering is bigendian" >&5 +echo "configure:13193: 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 @@ -12974,11 +13207,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:12978: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:13211: \"$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 @@ -12989,7 +13222,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:12993: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:13226: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -13009,7 +13242,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>/dev/null +if { (eval echo configure:13259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -13046,7 +13279,7 @@ EOF fi echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:13050: checking size of short" >&5 +echo "configure:13283: checking size of short" >&5 if eval "test \"\${ac_cv_sizeof_short+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -13054,7 +13287,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -13065,7 +13298,7 @@ main() exit(0); } EOF -if { (eval echo configure:13069: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:13302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_short=`cat conftestval` else @@ -13085,7 +13318,7 @@ EOF echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:13089: checking size of int" >&5 +echo "configure:13322: checking size of int" >&5 if eval "test \"\${ac_cv_sizeof_int+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -13093,7 +13326,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -13104,7 +13337,7 @@ main() exit(0); } EOF -if { (eval echo configure:13108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:13341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else @@ -13124,7 +13357,7 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:13128: checking size of long" >&5 +echo "configure:13361: checking size of long" >&5 if eval "test \"\${ac_cv_sizeof_long+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -13132,7 +13365,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -13143,7 +13376,7 @@ main() exit(0); } EOF -if { (eval echo configure:13147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:13380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else @@ -13200,7 +13433,7 @@ EOF echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:13204: checking for 8-bit clean memcmp" >&5 +echo "configure:13437: 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 @@ -13208,7 +13441,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>/dev/null +if { (eval echo configure:13455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_memcmp_clean=yes else @@ -13236,12 +13469,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" echo $ac_n "checking for strftime""... $ac_c" 1>&6 -echo "configure:13240: checking for strftime" >&5 +echo "configure:13473: 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:13502: \"$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 @@ -13287,7 +13520,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:13291: checking for strftime in -lintl" >&5 +echo "configure:13524: 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 @@ -13295,7 +13528,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:13543: \"$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 @@ -13334,12 +13567,12 @@ fi echo $ac_n "checking for inet_aton()""... $ac_c" 1>&6 -echo "configure:13338: checking for inet_aton()" >&5 +echo "configure:13571: 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:13598: \"$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 @@ -13383,12 +13616,12 @@ EOF echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:13387: checking for vprintf" >&5 +echo "configure:13620: 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:13649: \"$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 @@ -13436,12 +13669,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:13440: checking for _doprnt" >&5 +echo "configure:13673: 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:13702: \"$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 @@ -13494,12 +13727,12 @@ if test $ac_cv_func_vprintf = yes ; then for ac_func in vsnprintf vsprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:13498: checking for $ac_func" >&5 +echo "configure:13731: 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:13760: \"$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 @@ -13568,6 +13801,7 @@ for ac_func in \ memcpy \ memmove \ mkstemp \ + pipe \ read \ recv \ recvfrom \ @@ -13577,6 +13811,7 @@ for ac_func in \ setsid \ setuid \ seteuid \ + sigaction \ signal \ sigset \ snprintf \ @@ -13598,12 +13833,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:13602: checking for $ac_func" >&5 +echo "configure:13837: 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:13866: \"$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 @@ -13655,12 +13890,12 @@ done for ac_func in getopt tempnam do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:13659: checking for $ac_func" >&5 +echo "configure:13894: 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:13923: \"$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 @@ -13713,13 +13948,13 @@ done # Check Configuration echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6 -echo "configure:13717: checking declaration of sys_errlist" >&5 +echo "configure:13952: 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 < @@ -13729,7 +13964,7 @@ int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:13733: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:13968: \"$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 @@ -13752,20 +13987,20 @@ EOF echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6 -echo "configure:13756: checking existence of sys_errlist" >&5 +echo "configure:13991: 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:13769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:14004: \"$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 @@ -13866,6 +14101,18 @@ if test "$ol_enable_rlookups" != no ; then #define SLAPD_RLOOKUPS 1 EOF +fi +if test "$ol_enable_aci" != no ; then + cat >> confdefs.h <<\EOF +#define SLAPD_ACI_ENABLED 1 +EOF + +fi +if test "$ol_enable_discreteaci" != no ; then + cat >> confdefs.h <<\EOF +#define SLAPD_ACI_DISCRETE_RIGHTS 1 +EOF + fi if test "$ol_link_modules" != no ; then diff --git a/configure.in b/configure.in index 083e62b604..e08413ddc4 100644 --- a/configure.in +++ b/configure.in @@ -1,3 +1,4 @@ +dnl $OpenLDAP$ dnl dnl Copyright 1998,1999 The OpenLDAP Foundation. All Rights Reserved. dnl @@ -6,6 +7,18 @@ dnl as authorized by the OpenLDAP Public License. A copy of this dnl license is available at http://www.OpenLDAP.org/license.html or dnl in file LICENSE in the top-level directory of the distribution. dnl +define([AC_INIT_BINSH], +[[#! /bin/sh +# $]OpenLDAP[$ +# from] translit([$OpenLDAP$], $")] [ + +# Copyright 1998,1999 The OpenLDAP Foundation. All Rights Reserved. +# +# Redistribution and use in source and binary forms are permitted only +# as authorized by the OpenLDAP Public License. A copy of this +# license is available at http://www.OpenLDAP.org/license.html or +# in file LICENSE in the top-level directory of the distribution. +])dnl dnl Disable config.cache! define([AC_CACHE_LOAD], )dnl @@ -71,7 +84,7 @@ dnl ol_enable_syslog=no OL_ARG_ENABLE(syslog,[ --enable-syslog enable syslog support], auto)dnl OL_ARG_ENABLE(proctitle,[ --enable-proctitle enable proctitle support], yes)dnl OL_ARG_ENABLE(cache,[ --enable-cache enable caching], yes)dnl -OL_ARG_ENABLE(dns,[ --enable-dns enable V2 DNS extension], no)dnl +OL_ARG_ENABLE(dns,[ --enable-dns enable V2 DX Referrals extension], no)dnl OL_ARG_ENABLE(referrals,[ --enable-referrals enable V2 Referrals extension], yes)dnl OL_ARG_ENABLE(cldap,[ --enable-cldap enable connectionless ldap], no)dnl OL_ARG_ENABLE(x_compile,[ --enable-x-compile enable cross compiling], @@ -80,17 +93,17 @@ OL_ARG_ENABLE(x_compile,[ --enable-x-compile enable cross compiling], dnl General "with" options OL_ARG_ENABLE(dmalloc,[ --enable-dmalloc enable debug malloc support], no)dnl -OL_ARG_WITH(cyrus_sasl,[ --with-cyrus-sasl with Cyrus SASL support], +OL_ARG_WITH(cyrus_sasl,[ --with-cyrus-sasl with Cyrus SASL support], auto, [auto yes no] ) -OL_ARG_WITH(fetch,[ --with-fetch with fetch URL support], +OL_ARG_WITH(fetch,[ --with-fetch with fetch URL support], auto, [auto yes no] ) OL_ARG_WITH(kerberos,[ --with-kerberos with Kerberos support], auto, [auto k5 k4 afs yes no]) -OL_ARG_WITH(readline,[ --with-readline with readline support], +OL_ARG_WITH(readline,[ --with-readline with readline support], auto, [auto yes no] ) OL_ARG_WITH(threads,[ --with-threads use threads], - auto, [auto posix mach lwp yes no manual] ) -OL_ARG_WITH(tls,[ --with-tls with TLS/SSL support], + auto, [auto posix mach pth lwp yes no manual] ) +OL_ARG_WITH(tls,[ --with-tls with TLS/SSL support], auto, [auto ssleay openssl yes no] ) OL_ARG_WITH(yielding_select,[ --with-yielding-select with implicitly yielding select], auto, [auto yes no manual] ) @@ -98,7 +111,7 @@ OL_ARG_WITH(yielding_select,[ --with-yielding-select with implicitly yielding s dnl Server options dnl SLAPD OPTIONS -AC_ARG_WITH(xxslapdoptions,[SLAPD Options:]) +AC_ARG_WITH(xxslapdoptions,[SLAPD (Standalone LDAP Daemon) Options:]) OL_ARG_ENABLE(slapd,[ --enable-slapd enable building slapd], yes)dnl OL_ARG_ENABLE(cleartext,[ --enable-cleartext enable cleartext passwords], yes)dnl OL_ARG_ENABLE(crypt,[ --enable-crypt enable crypt(3) passwords], auto)dnl @@ -107,6 +120,8 @@ OL_ARG_ENABLE(multimaster,[ --enable-multimaster enable multimaster replicati OL_ARG_ENABLE(phonetic,[ --enable-phonetic enable phonetic/soundex], no)dnl OL_ARG_ENABLE(quipu,[ --enable-quipu build quipu migration tools], no)dnl OL_ARG_ENABLE(rlookups,[ --enable-rlookups enable reverse lookups], auto)dnl +OL_ARG_ENABLE(aci,[ --enable-aci enable per-object ACIs], no)dnl +OL_ARG_ENABLE(discreteaci,[ --enable-discreteaci enable discrete rights in ACIs], no)dnl OL_ARG_ENABLE(wrappers,[ --enable-wrappers enable tcp wrapper support], no)dnl dnl SLAPD Backend options @@ -117,10 +132,10 @@ OL_ARG_ENABLE(ldap,[ --enable-ldap enable ldap backend], no)dnl OL_ARG_WITH(ldap_module,[ --with-ldap-module module type], static, [static dynamic]) OL_ARG_ENABLE(ldbm,[ --enable-ldbm enable ldbm backend], yes)dnl -OL_ARG_WITH(ldbm_module,[ --with-ldbm-module module type], static, - [static dynamic]) OL_ARG_WITH(ldbm_api,[ --with-ldbm-api use LDBM API], auto, [auto db2 db mdbm gdbm ndbm manual]) +OL_ARG_WITH(ldbm_module,[ --with-ldbm-module module type], static, + [static dynamic]) OL_ARG_WITH(ldbm_type,[ --with-ldbm-type use LDBM type], auto, [auto btree hash]) @@ -138,7 +153,7 @@ OL_ARG_WITH(tcl_module,[ --with-tcl-module module type], static, [static dynamic]) dnl SLURPD OPTIONS -AC_ARG_WITH(xxslurpdoptions,[SLURPD Options:]) +AC_ARG_WITH(xxslurpdoptions,[SLURPD (Replication Daemon) Options:]) OL_ARG_ENABLE(slurpd,[ --enable-slurpd enable building slurpd], auto)dnl AC_ARG_WITH(xxliboptions,[Library Generation & Linking Options]) @@ -199,6 +214,12 @@ if test $ol_enable_slapd = no ; then if test $ol_enable_rlookups = yes ; then AC_MSG_WARN([slapd disabled, ignoring --enable-rlookups argument]) fi + if test $ol_enable_aci = yes ; then + AC_MSG_WARN([slapd disabled, ignoring --enable-aci argument]) + fi + if test $ol_enable_discreteaci = yes ; then + AC_MSG_WARN([slapd disabled, ignoring --enable-discreteaci argument]) + fi if test $ol_with_ldbm_api != auto ; then AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-api argument]) fi @@ -244,6 +265,8 @@ if test $ol_enable_slapd = no ; then ol_enable_phonetic=no ol_enable_quipu=no ol_enable_rlookups=no + ol_enable_aci=no + ol_enable_discreteaci=no ol_enable_wrappers=no ol_with_ldbm_api=no @@ -387,7 +410,6 @@ dnl AC_PROG_INSTALL AC_DEFINE(HAVE_MKVERSION, 1, [define this if you have mkversion]) - dnl dnl Determine which C translator to use dnl @@ -583,7 +605,6 @@ AC_CHECK_HEADERS( \ resolv.h \ sgtty.h \ shadow.h \ - stdarg.h \ stddef.h \ string.h \ strings.h \ @@ -613,9 +634,7 @@ dnl -lsocket [ -lnsl_s | -lnsl ] dnl -linet AC_CHECK_FUNC(socket, :, [ -dnl dnl hopefully we won't include too many libraries -dnl AC_CHECK_LIB(socket, main) AC_CHECK_LIB(net, main) AC_CHECK_LIB(net, socket) @@ -625,14 +644,19 @@ dnl AC_CHECK_LIB(gen, main) ]) +dnl require select AC_CHECK_FUNC(select, :, AC_MSG_ERROR([select() required.])) +dnl AC_CHECK_FUNCS(socketpair) dnl Select arg types dnl (if this detection becomes permenent, it and the select() detection dnl should be done before the yielding select test) AC_FUNC_SELECT_ARGTYPES +dnl check to see if system call automatically restart +dnl AC_SYS_RESTARTABLE_SYSCALLS +dnl require POSIX regex AC_CHECK_HEADERS( regex.h ) if test "$ac_cv_header_regex_h" != yes ; then AC_MSG_ERROR([POSIX regex.h required.]) @@ -644,7 +668,6 @@ if test "$ol_cv_c_posix_regex" = no ; then AC_MSG_ERROR([broken POSIX regex!]) fi - dnl HP-UX requires -lV3 AC_CHECK_LIB(V3, sigset) @@ -849,7 +872,7 @@ ol_link_threads=no if test $ol_with_threads = auto -o $ol_with_threads = yes \ -o $ol_with_threads = posix ; then - AC_CHECK_HEADERS(pthread.h sched.h) + AC_CHECK_HEADERS(pthread.h) if test $ac_cv_header_pthread_h = yes ; then OL_POSIX_THREAD_VERSION @@ -868,6 +891,11 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ ol_with_threads=found OL_HEADER_LINUX_THREADS + OL_HEADER_GNU_PTH_PTHREAD_H + + if test $ol_cv_header_gnu_pth_pthread_h = no ; then + AC_CHECK_HEADERS(sched.h) + fi dnl Now the hard part, how to link? dnl @@ -1188,6 +1216,26 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ fi fi +if test $ol_with_threads = auto -o $ol_with_threads = yes \ + -o $ol_with_threads = pth ; then + + AC_CHECK_HEADERS(pth.h) + + if test $ac_cv_header_pth_h = yes ; then + AC_CHECK_LIB(pth, pth_version, [have_pth=yes], [have_pth=no]) + + if test $have_pth = yes ; then + AC_DEFINE(HAVE_GNU_PTH,1,[if you have GNU Pth]) + LTHREAD_LIBS="$LTHREAD_LIBS -lpth" + ol_link_threads=pth + + if test $ol_with_yielding_select = auto ; then + ol_with_yielding_select=yes + fi + fi + fi +fi + if test $ol_with_threads = auto -o $ol_with_threads = yes \ -o $ol_with_threads = lwp ; then @@ -1766,6 +1814,7 @@ AC_CHECK_FUNCS( \ memcpy \ memmove \ mkstemp \ + pipe \ read \ recv \ recvfrom \ @@ -1775,6 +1824,7 @@ AC_CHECK_FUNCS( \ setsid \ setuid \ seteuid \ + sigaction \ signal \ sigset \ snprintf \ @@ -1850,6 +1900,12 @@ fi if test "$ol_enable_rlookups" != no ; then AC_DEFINE(SLAPD_RLOOKUPS,1,[define to support reverse lookups]) fi +if test "$ol_enable_aci" != no ; then + AC_DEFINE(SLAPD_ACI_ENABLED,1,[define to support per-object ACIs]) +fi +if test "$ol_enable_discreteaci" != no ; then + AC_DEFINE(SLAPD_ACI_DISCRETE_RIGHTS,1,[define to support discrete rights in ACIs]) +fi if test "$ol_link_modules" != no ; then AC_DEFINE(SLAPD_MODULES,1,[define to support modules]) diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000000..754eee763d --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,7 @@ +# $OpenLDAP$ +## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved. +## COPYING RESTRICTIONS APPLY, See COPYRIGHT file +## +## doc Makefile.in for OpenLDAP + +SUBDIRS= man diff --git a/doc/man/man5/ldap.conf.5 b/doc/man/man5/ldap.conf.5 new file mode 100644 index 0000000000..00d9d4adc0 --- /dev/null +++ b/doc/man/man5/ldap.conf.5 @@ -0,0 +1,86 @@ +.TH LDAP.CONF 5 "29 November 1998" "OpenLDAP LDVERSION" +.UC 6 +.SH NAME +ldap.conf \- ldap configuration file +.SH SYNOPSIS +ETCDIR/ldap.conf +.SH DESCRIPTION +The +.I ldap.conf +configuration file is used to set system-wide defaults to be applied when +running +.I ldap +clients. If the environment variable \fBLDAPNOINIT\fP is defined, all +defaulting is disabled. +.LP +Each user may specify an optional configuration file, +.IR .ldaprc , +in his/her home directory which will be used to override the system-wide +defaults file. +.LP +Additional configuration files can be specified using +the \fBLDAPCONF\fP and \fBLDAPRC\fP environment variables. +\fBLDAPCONF\fP may be set the path of a configuration file. This +path can be absolute or relative to current working directory. +The \fBLDAPRC\fP, if defined, should be a basename of a file +in the current working directory or in the user's home directory. +.LP +Environmental variables may also be used to augment the file based defaults. +The name of the option is the as listed but with a prefix of \fBLDAP\fP. +For example, to define \fBBASE\fP via the environment, define the variable +\fBLDAPBASE\fP to desired value. +.SH OPTIONS +The different configuration options are: +.TP 1i +\fBBASE \fP +Used to specify the default base dn to use when performing ldap operations. +The base must be specified as a Distinguished Name in LDAP format. +.TP 1i +\fBHOST \fP +Used to specify the name(s) of an LDAP server(s) to which +.I ldap +library should connect to. Each server's name can be specified as a +domain-style name or an IP address and optionally followed a ':' and +the port number the ldap server is listening on. A space separated +listed of host may be provided. +.TP 1i +\fBPORT \fP +Used to specify the port used with connecting to LDAP servers(s). +The port may be specified as a number. +.TP 1i +\fBSIZELIMIT \fP +Used to specify a size limit to use when performing searches. The +number should be an non-negative integer. \fISIZELIMIT\fP of zero (0) +specifies unlimited search size. +.TP 1i +\fBTIMELIMIT \fP +Used to specify a time limit to use when performing searches. The +number should be an non-negative integer. \fITIMELIMIT\fP of zero (0) +specifies unlimited search time to be used. +.TP 1i +\fBDEREF \fP +Specify how aliases dereferencing is done. \fIDEREF\fP should +be set to one of +.B never, +.B always, +.B search, +or +.B find +to specify that aliases are never dereferenced, always dereferenced, +dereferenced when searching, or dereferenced only when locating the +base object for the search. The default is to never dereference aliases. +.SH FILES +.I ETCDIR/ldap.conf +.LP +.I $HOME/.ldaprc +.LP +.I $CWD/.ldaprc +.SH "SEE ALSO" +ldap(3) +.SH AUTHOR +Kurt Zeilenga, The OpenLDAP Project +.SH ACKNOWLEDGEMENTS +.B OpenLDAP +is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). +.B OpenLDAP +is derived from University of Michigan LDAP 3.3 Release. diff --git a/doc/man/man8/slapd.8 b/doc/man/man8/slapd.8 index be0c97d3bf..6fc43e11ba 100644 --- a/doc/man/man8/slapd.8 +++ b/doc/man/man8/slapd.8 @@ -1,16 +1,21 @@ -.TH SLAPD 8C "6 November 1995" "U-M LDAP LDVERSION" +.TH SLAPD 8C "3 April 1999" "OpenLDAP LDVERSION" .SH NAME slapd \- Stand-alone LDAP Daemon .SH SYNOPSIS -.B ETCDIR/slapd [\-d debug\-level] -.B [\-f slapd\-config\-file] [\-p port\-number] -.B [\-s syslog\-level] [\-i] +.B LIBEXECDIR/slapd +.B [\-f slapd\-config\-file] +.B [\-h URLs] +.B [\-d debug\-level] +.B [\-p port\-number] +.B [\-P tls\-port\-number] +.B [\-s syslog\-level] [\-l syslog\-local\-user] +.B [\-u user] [\-g group] .B .SH DESCRIPTION .LP .B Slapd is the stand-alone LDAP daemon. It listens for LDAP connections on -port 389, responding +any number of ports (default 389), responding to the LDAP operations it receives over these connections. .B slapd is typically invoked at boot time, usually out of @@ -18,10 +23,22 @@ is typically invoked at boot time, usually out of Upon startup, .B slapd normally forks and disassociates itself from the invoking tty. +If configured in +.BR ETCDIR/slapd.conf , +the +.B slapd +process will print its process ID ( see +.BR getpid (2) +) to a +.B .pid +file, as well as the command line options during invocation to an +.B .args +file ( see +.BR slapd.conf (5) +). If the .B \-d -flag is given and debugging is set to some non-zero -value, +flag is given, even with a zero argument, .B slapd will not fork and disassociate from the invoking tty. .LP @@ -41,7 +58,7 @@ See "The SLAPD and SLURPD Administrator's Guide" for more details on .BI \-d " debug\-level" Turn on debugging as defined by .I debug\-level. -If this option is specified, +If this option is specified, even with a zero argument, .B slapd will not fork or disassociate from the invoking terminal. Some general operation and status messages are printed for any value of \fIdebug\-level\fP. @@ -55,21 +72,76 @@ at what level debugging statements should be logged to the .BR syslog (8) facility. .TP +.BI \-l " syslog\-local\-user" +Selects the local user of the +.BR syslog (8) +facility. Values can be +.BR LOCAL0 , +.BR LOCAL1 , +and so on, up to +.BR LOCAL7 . +The default is +.BR LOCAL4 . +However, this option is only permitted on systems that support +local users with the +.BR syslog (8) +facility. +.TP .BI \-f " slapd\-config\-file" Specifies the slapd configuration file. The default is .BR ETCDIR/slapd.conf . .TP +.BI \-h " URLlist" +.B slapd +will serve +.B ldap:/// +(LDAP over TCP on all interfaces on default LDAP port). As such, +it will bind to INADDR_ANY, port 389. +The +.B \-h +option may be used to specify LDAP (and LDAPS) URLs to serve. +For example, if slapd is given +.B \-h " ldap://127.0.0.1:9009/ ldaps:///", +It will bind 127.0.0.1:9009 for LDAP and INADDR_ANY:636 for LDAP over TLS. +A space separated list of URLs is expected. The URLS should be of +LDAP (ldap://) or, if supported, LDAP over TLS (ldaps://) type without +a DN or other optional parameters. Hosts may be specified in either +Internet '.' format (preferred) or by name. Ports, if specfied, +must be numeric. +.TP .BI \-p " port\-number" .B slapd -will listen on the default LDAP port (389) unless this option is given -to override the default. +will use on the default port (389) for LDAP URLs unless this +option is given to override the default. +A numeric port number is expected. .TP -.B \-i -This option tells +.BI \-P " tls\-port\-number" .B slapd -that it is being run from -.BR inetd(8) , -the Internet protocol daemon. +will use on the default port (636) for LDAPS (LDAP over TLS) URLs +unless this option is given to override the default. A numeric port +number is expected. +.TP +.BI \-P " port\-number" +Changes the port where +.B slapd +will expect LDAP over raw TLS connections. If this option is not given, +the default port for this purpose (636) will be used. A numeric port +number is expected. +.TP +.BI \-u " user" +.B slapd +will run slapd with the specified user name or id, and that user's +supplementary group access list as set with initgroups(3). The group ID +is also changed to this user's gid, unless the -g option is used to +override. +.TP +.BI \-g " group" +.B slapd +will run with the specified group name or id. +.LP +Note that on some systems, running as a non-privileged user will prevent +passwd back-ends from accessing the encrypted passwords. Note also that +any shell back-ends will run as the specified non-privileged user. .SH EXAMPLES To start .I slapd @@ -78,7 +150,7 @@ the LDAP databases defined in the default config file, just type: .LP .nf .ft tt - ETCDIR/slapd + LIBEXECDIR/slapd .ft .fi .LP @@ -89,7 +161,7 @@ on voluminous debugging which will be printed on standard error, type: .LP .nf .ft tt - ETCDIR/slapd -f /usr/local/slapd/slapd.conf -d 255 + LIBEXECDIR/slapd -f ETCDIR/slapd.conf -d 255 .ft .fi .LP @@ -102,3 +174,8 @@ on voluminous debugging which will be printed on standard error, type: .SH BUGS When using the LDBM database backend, the Modify RDN operation does not update the attribute values in the entry that are affected by the change. +.SH ACKNOWLEDGEMENTS +.B OpenLDAP +is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). +.B OpenLDAP +is derived from University of Michigan LDAP 3.3 Release. diff --git a/doc/man/man8/slurpd.8 b/doc/man/man8/slurpd.8 index 037584e8a1..51c8c14b0d 100644 --- a/doc/man/man8/slurpd.8 +++ b/doc/man/man8/slurpd.8 @@ -1,8 +1,8 @@ -.TH SLURPD 8C "6 November 1995" "U-M LDAP LDVERSION" +.TH SLURPD 8C "22 September 1998" "OpenLDAP LDVERSION" .SH NAME slurpd \- Standalone LDAP Update Replication Daemon .SH SYNOPSIS -.B ETCDIR/slurpd [\-d debug\-level] +.B LIBEXECDIR/slurpd [\-d debug\-level] .B [\-f slapd\-config\-file] [\-r slapd\-replog\-file] .B [\-t temp\-dir] [\-o] [\-k srvtab\-file] .B @@ -62,7 +62,7 @@ for details on the standalone LDAP daemon. .BI \-d " debug\-level" Turn on debugging as defined by .I debug\-level. -If this option is specified, +If this option is specified, even with a zero argument, .B slurpd will not fork or disassociate from the invoking terminal. Some general operation and status messages are printed for any value of \fIdebug\-level\fP. @@ -126,7 +126,7 @@ just type: .LP .nf .ft tt - ETCDIR/slurpd + LIBEXECDIR/slurpd .ft .fi .LP @@ -139,7 +139,7 @@ on voluminous debugging which will be printed on standard error, type: .LP .nf .ft tt - ETCDIR/slurpd -f /usr/local/etc/slapd.conf -d 255 + LIBEXECDIR/slurpd -f ETCDIR/slapd.conf -d 255 .ft .fi .LP @@ -149,3 +149,8 @@ on voluminous debugging which will be printed on standard error, type: .BR slapd (8) .LP "The SLAPD and SLURPD Administrator's Guide" +.SH ACKNOWLEDGEMENTS +.B OpenLDAP +is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). +.B OpenLDAP +is derived from University of Michigan LDAP 3.3 Release. diff --git a/include/Makefile.in b/include/Makefile.in index eb7ccd560d..a3342c6a58 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved. ## COPYING RESTRICTIONS APPLY, See COPYRIGHT file ## diff --git a/include/ac/alloca.h b/include/ac/alloca.h new file mode 100644 index 0000000000..3d04de6179 --- /dev/null +++ b/include/ac/alloca.h @@ -0,0 +1,36 @@ +/* Generic alloca.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_ALLOCA_H +#define _AC_ALLOCA_H + +#error "alloca() not supported, use malloc()" + +/* AIX requires this to be the first thing in the file. */ +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# if HAVE_ALLOCA_H +# include +# else +# ifdef _AIX +#pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +extern char *(alloca)(); +# endif +# endif +# endif +#endif + + +#endif /* _AC_ALLOCA_H */ diff --git a/include/ac/assert.h b/include/ac/assert.h index 6849638cfd..6c3a44ed77 100644 --- a/include/ac/assert.h +++ b/include/ac/assert.h @@ -1,4 +1,5 @@ /* Generic assert.h */ +/* $OpenLDAP$ */ /* * Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. diff --git a/include/ac/bytes.h b/include/ac/bytes.h new file mode 100644 index 0000000000..160f0bbc8e --- /dev/null +++ b/include/ac/bytes.h @@ -0,0 +1,66 @@ +/* Generic bytes.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_BYTES_H +#define _AC_BYTES_H + +/* cross compilers should define both AC_INT{2,4}_TYPE in CPPFLAGS */ + +#if !defined( AC_INT4_TYPE ) || !defined( AC_INT2_TYPE ) + /* use autoconf defines to provide sized typedefs */ +# if SIZEOF_LONG == 4 +# define AC_INT4_TYPE long +# elif SIZEOF_INT == 4 +# define AC_INT4_TYPE int +# else +# error "AC_INT4_TYPE?" +# endif + +# if SIZEOF_SHORT == 2 +# define AC_INT2_TYPE short +# elif SIZEOF_INT == 2 +# define AC_INT2_TYPE int +# else +# error "AC_INT2_TYPE?" +# endif +#endif + +typedef AC_INT4_TYPE ac_int4; +typedef signed AC_INT4_TYPE ac_sint4; +typedef unsigned AC_INT4_TYPE ac_uint4; + +typedef AC_INT2_TYPE ac_int2; +typedef signed AC_INT2_TYPE ac_sint2; +typedef unsigned AC_INT2_TYPE ac_uint2; + +#ifndef BYTE_ORDER +/* cross compilers should define BYTE_ORDER in CPPFLAGS */ + +/* + * Definitions for byte order, according to byte significance from low + * address to high. + */ +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ + +/* assume autoconf's AC_C_BIGENDIAN has been ran */ +/* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */ +# ifdef WORDS_BIGENDIAN +# define BYTE_ORDER BIG_ENDIAN +# else +# define BYTE_ORDER LITTLE_ENDIAN +# endif + +#endif /* BYTE_ORDER */ + +#endif /* _AC_BYTES_H */ diff --git a/include/ac/ctype.h b/include/ac/ctype.h new file mode 100644 index 0000000000..cfdcd924d7 --- /dev/null +++ b/include/ac/ctype.h @@ -0,0 +1,29 @@ +/* Generic ctype.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_CTYPE_H +#define _AC_CTYPE_H + +#include + +#undef TOUPPER +#undef TOLOWER + +#ifdef C_UPPER_LOWER +# define TOUPPER(c) (islower(c) ? toupper(c) : (c)) +# define TOLOWER(c) (isupper(c) ? tolower(c) : (c)) +#else +# define TOUPPER(c) toupper(c) +# define TOLOWER(c) tolower(c) +#endif + +#endif /* _AC_CTYPE_H */ diff --git a/include/ac/dirent.h b/include/ac/dirent.h new file mode 100644 index 0000000000..53f189a518 --- /dev/null +++ b/include/ac/dirent.h @@ -0,0 +1,33 @@ +/* Generic dirent.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_DIRENT_H +#define _AC_DIRENT_H + +#if HAVE_DIRENT_H +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif +#endif + +#endif /* _AC_DIRENT_H */ diff --git a/include/ac/errno.h b/include/ac/errno.h new file mode 100644 index 0000000000..3d26e5e464 --- /dev/null +++ b/include/ac/errno.h @@ -0,0 +1,41 @@ +/* Generic errno.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_ERRNO_H +#define _AC_ERRNO_H + +#if defined( HAVE_ERRNO_H ) +# include +#elif defined( HAVE_SYS_ERRNO_H ) +# include +#endif + +#ifndef HAVE_SYS_ERRLIST + /* no sys_errlist */ +# define sys_nerr 0 +# define sys_errlist ((char **)0) +#elif DECL_SYS_ERRLIST + /* have sys_errlist but need declaration */ + extern int sys_nerr; + extern char *sys_errlist[]; +#endif + +#ifdef HAVE_STRERROR +#define STRERROR(err) strerror(err) +#else +#define STRERROR(err) \ + ((err) > -1 && (err) < sys_nerr ? sys_errlist[(err)] : "unknown") +#endif + +extern char* strerror_r(); + +#endif /* _AC_ERRNO_H */ diff --git a/include/ac/krb.h b/include/ac/krb.h new file mode 100644 index 0000000000..a5ffa7abd8 --- /dev/null +++ b/include/ac/krb.h @@ -0,0 +1,31 @@ +/* Generic krb.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_KRB_H +#define _AC_KRB_H + +#if defined( HAVE_KERBEROS ) + +#if defined( HAVE_KERBEROSIV_KRB_H ) +#include +#elif defined( HAVE_KRB_H ) +#include +#endif + +#if defined( HAVE_KERBEROSIV_DES_H ) +#include +#elif defined( HAVE_DES_H ) +#include +#endif + +#endif /* HAVE_KERBEROS */ +#endif /* _AC_KRB_H */ diff --git a/include/ac/regex.h b/include/ac/regex.h new file mode 100644 index 0000000000..897f7f5fd1 --- /dev/null +++ b/include/ac/regex.h @@ -0,0 +1,36 @@ +/* Generic Regex */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +#ifndef _AC_REGEX_H_ +#define _AC_REGEX_H_ + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifndef HAVE_REGEX_H +/* NO POSIX REGEX!! + you'll need to install a POSIX compatible REGEX library. + Either Henry Spencer's or GNU regex will do. + + For NT: http://people.delphi.com/gjc/hs_regex.html +*/ +#error "No POSIX REGEX available." + +#elif HAVE_GNUREGEX_H + /* system has GNU gnuregex.h */ +# include +#else + /* have regex.h, assume it's POSIX compliant */ +# include +#endif /* regex.h */ + +#endif /* _AC_REGEX_H_ */ diff --git a/include/ac/setproctitle.h b/include/ac/setproctitle.h new file mode 100644 index 0000000000..5bf1d2f496 --- /dev/null +++ b/include/ac/setproctitle.h @@ -0,0 +1,29 @@ +/* Generic setproctitle.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_SETPROCTITLE_H +#define _AC_SETPROCTITLE_H + +#ifdef LDAP_PROCTITLE + +#if defined( HAVE_LIBUTIL_H ) +# include +#else + /* use lutil version */ + LDAP_F(void) (setproctitle) LDAP_P((const char *fmt, ...)) \ + LDAP_GCCATTR((format(printf, 1, 2))); + LDAP_F(int) Argc; + LDAP_F(char) **Argv; +#endif + +#endif /* LDAP_PROCTITLE */ +#endif /* _AC_SETPROCTITLE_H */ diff --git a/include/ac/signal.h b/include/ac/signal.h new file mode 100644 index 0000000000..73f5d48092 --- /dev/null +++ b/include/ac/signal.h @@ -0,0 +1,65 @@ +/* Generic signal.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_SIGNAL_H +#define _AC_SIGNAL_H + +#include + +#undef SIGNAL +#ifdef HAVE_SIGSET +#define SIGNAL sigset +#else +#define SIGNAL signal +#endif + +#if !defined( LDAP_SIGUSR1 ) || !defined( LDAP_SIGUSR2 ) +#undef LDAP_SIGUSR1 +#undef LDAP_SIGUSR2 + +# ifndef HAVE_LINUX_THREADS +# define LDAP_SIGUSR1 SIGUSR1 +# define LDAP_SIGUSR2 SIGUSR2 + +# else + /* + LinuxThreads implemented unfortunately uses the only + two signals reserved for user applications. This forces + OpenLDAP to use, hopefullly unused, signals reserved + for other uses. + */ + +# if defined( SIGSTKFLT ) +# define LDAP_SIGUSR1 SIGSTKFLT +# elif defined ( SIGSYS ) +# define LDAP_SIGUSR1 SIGSYS +# endif + +# if defined( SIGUNUSED ) +# define LDAP_SIGUSR2 SIGUNUSED +# elif defined ( SIGINFO ) +# define LDAP_SIGUSR2 SIGINFO +# elif defined ( SIGEMT ) +# define LDAP_SIGUSR2 SIGEMT +# endif +# endif +#endif + +#ifndef LDAP_SIGCHLD +#ifdef SIGCHLD +#define LDAP_SIGCHLD SIGCHLD +#elif SIGCLD +#define LDAP_SIGCHLD SIGCLD +#endif +#endif + +#endif /* _AC_SIGNAL_H */ diff --git a/include/ac/socket.h b/include/ac/socket.h index b852042976..fc1d533b6f 100644 --- a/include/ac/socket.h +++ b/include/ac/socket.h @@ -1,6 +1,5 @@ -/* - * Generic socket.h - */ +/* Generic socket.h */ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. @@ -67,8 +66,15 @@ #define MAXHOSTNAMELEN 64 #endif +#undef sock_errno +#undef sock_errstr +#define sock_errno() errno +#define sock_errstr(e) STRERROR(e) + #ifdef HAVE_WINSOCK -# define tcp_close( s ) closesocket( s ); +# define tcp_close( s ) closesocket( s ) +# define tcp_read( s, buf, len ) recv( s, buf, len, 0 ) +# define tcp_write( s, buf, len ) send( s, buf, len, 0 ) # define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) ) # define ioctl_t u_long # define AC_SOCKET_INVALID ((unsigned int) ~0) @@ -77,15 +83,28 @@ #define EINPROGRESS WSAEINPROGRESS #define ETIMEDOUT WSAETIMEDOUT +#undef sock_errno +#undef sock_errstr +#define sock_errno() WSAGetLastError() +#define sock_errstr(e) WSAGetErrorString(e) + +extern char* WSAGetErrorString LDAP_P((int)); + #elif MACOS # define tcp_close( s ) tcpclose( s ) +# define tcp_read( s, buf, len ) tcpread( s, buf, len ) +# define tcp_write( s, buf, len ) tcpwrite( s, buf, len ) #elif DOS # ifdef PCNFS # define tcp_close( s ) close( s ) +# define tcp_read( s, buf, len ) recv( s, buf, len, 0 ) +# define tcp_write( s, buf, len ) send( s, buf, len, 0 ) # endif /* PCNFS */ # ifdef NCSA # define tcp_close( s ) do { netclose( s ); netshut() } while(0) +# define tcp_read( s, buf, len ) nread( s, buf, len ) +# define tcp_write( s, buf, len ) netwrite( s, buf, len ) # endif /* NCSA */ #elif HAVE_CLOSESOCKET @@ -93,6 +112,17 @@ #else # define tcp_close( s ) close( s ) +# define tcp_read( s, buf, len) read( s, buf, len ) +# define tcp_write( s, buf, len) write( s, buf, len ) + +#ifdef HAVE_PIPE +/* + * Only use pipe() on systems where file and socket descriptors + * are interchangable + */ +#define USE_PIPE HAVE_PIPE +#endif + #endif /* MACOS */ #ifndef ioctl_t @@ -102,6 +132,9 @@ #ifndef AC_SOCKET_INVALID # define AC_SOCKET_INVALID (-1) #endif +#ifndef AC_SOCKET_ERROR +# define AC_SOCKET_ERROR (-1) +#endif #if !defined( HAVE_INET_ATON ) && !defined( inet_aton ) #define inet_aton ldap_pvt_inet_aton diff --git a/include/ac/stdarg.h b/include/ac/stdarg.h new file mode 100644 index 0000000000..c7b2d46c87 --- /dev/null +++ b/include/ac/stdarg.h @@ -0,0 +1,24 @@ +/* Generic stdarg.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_STDARG_H +#define _AC_STDARG_H 1 + +/* require STDC variable argument support */ + +#include + +#ifndef HAVE_STDARG +# define HAVE_STDARG 1 +#endif + +#endif /* _AC_STDARG_H */ diff --git a/include/ac/stdlib.h b/include/ac/stdlib.h index 6fc2f6a4d0..e8037ed496 100644 --- a/include/ac/stdlib.h +++ b/include/ac/stdlib.h @@ -1,4 +1,5 @@ /* Generic stdlib.h */ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. diff --git a/include/ac/string.h b/include/ac/string.h new file mode 100644 index 0000000000..980511d3d0 --- /dev/null +++ b/include/ac/string.h @@ -0,0 +1,79 @@ +/* Generic string.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_STRING_H +#define _AC_STRING_H + +#ifdef STDC_HEADERS +# include + +#else +# ifdef HAVE_STRING_H +# include +# elif HAVE_STRINGS_H +# include +# endif + +# ifdef HAVE_MEMORY_H +# include +# endif + +# ifndef HAVE_STRRCHR +# undef strchr +# define strchr index +# undef strrchr +# define strrchr rindex +# endif + +# ifndef HAVE_MEMCPY +# undef memcpy +# define memcpy(d, s, n) ((void) bcopy ((s), (d), (n))) +# undef memmove +# define memmove(d, s, n) ((void) bcopy ((s), (d), (n))) +# endif +#endif + +/* use ldap_pvt_strtok instead of strtok or strtok_r! */ +LDAP_F(char *) ldap_pvt_strtok LDAP_P(( + char *str, const char *delim, char **pos )); + +LDAP_F(char *) ldap_pvt_strdup LDAP_P(( + const char * s )); + +#ifndef HAVE_STRDUP + /* strdup() is missing, declare our own version */ +# undef strdup +# define strdup(s) ldap_pvt_strdup(s) +#else + /* some systems fail to declare strdup */ + extern char *(strdup)(); +#endif + +/* + * some systems fail to declare strcasecmp() and strncasecmp() + * we need them declared so we can obtain pointers to them + */ +extern int (strcasecmp)(); +extern int (strncasecmp)(); + +#ifndef SAFEMEMCPY +# if defined( HAVE_MEMMOVE ) +# define SAFEMEMCPY( d, s, n ) memmove((d), (s), (n)) +# elif defined( HAVE_BCOPY ) +# define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n)) +# else + /* nothing left but memcpy() */ +# define SAFEMEMCPY( d, s, n ) memcpy((d), (s), (n)) +# endif +#endif + +#endif /* _AC_STRING_H */ diff --git a/include/ac/sysexits.h b/include/ac/sysexits.h new file mode 100644 index 0000000000..8d5df5ffdf --- /dev/null +++ b/include/ac/sysexits.h @@ -0,0 +1,21 @@ +/* Generic sysexits */ +/* $OpenLDAP$ */ +/* + * Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +#ifndef _AC_SYSEXITS_H_ +#define _AC_SYSEXITS_H_ + +#ifdef HAVE_SYSEXITS_H +# include +#else +# include +#endif + +#endif /* _AC_SYSEXITS_H_ */ diff --git a/include/ac/syslog.h b/include/ac/syslog.h new file mode 100644 index 0000000000..4015fd96a8 --- /dev/null +++ b/include/ac/syslog.h @@ -0,0 +1,33 @@ +/* Generic syslog.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +#ifndef _AC_SYSLOG_H_ +#define _AC_SYSLOG_H_ + +#if defined( HAVE_SYSLOG_H ) +#include +#elif defined ( HAVE_SYS_SYSLOG_H ) +#include +#endif + +#if defined( LOG_NDELAY ) && defined( LOG_NOWAIT ) +# define OPENLOG_OPTIONS ( LOG_PID | LOG_NDELAY | LOG_NOWAIT ) +#elif defined( LOG_NDELAY ) +# define OPENLOG_OPTIONS ( LOG_PID | LOG_NDELAY ) +#elif defined( LOG_NOWAIT ) +# define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT ) +#elif defined( LOG_PID ) +# define OPENLOG_OPTIONS ( LOG_PID ) +#else +# define OPENLOG_OPTIONS ( 0 ) +#endif + +#endif /* _AC_SYSLOG_H_ */ diff --git a/include/ac/termios.h b/include/ac/termios.h new file mode 100644 index 0000000000..5b548a4994 --- /dev/null +++ b/include/ac/termios.h @@ -0,0 +1,46 @@ +/* Generic termios.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_TERMIOS_H +#define _AC_TERMIOS_H + +#ifdef HAVE_POSIX_TERMIOS +#include + +#ifdef GCWINSZ_IN_SYS_IOCTL +#include +#endif + +#define TERMIO_TYPE struct termios +#define TERMFLAG_TYPE tcflag_t +#define GETATTR( fd, tiop ) tcgetattr((fd), (tiop)) +#define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop)) +#define GETFLAGS( tio ) ((tio).c_lflag) +#define SETFLAGS( tio, flags ) ((tio).c_lflag = (flags)) + +#elif defined( HAVE_SGTTY_H ) +#include + +#ifdef HAVE_SYS_IOCTL_H +#include +#endif + +#define TERMIO_TYPE struct sgttyb +#define TERMFLAG_TYPE int +#define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop)) +#define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop)) +#define GETFLAGS( tio ) ((tio).sg_flags) +#define SETFLAGS( tio, flags ) ((tio).sg_flags = (flags)) + +#endif /* HAVE_SGTTY_H */ + +#endif /* _AC_TERMIOS_H */ diff --git a/include/ac/time.h b/include/ac/time.h new file mode 100644 index 0000000000..9f8d303868 --- /dev/null +++ b/include/ac/time.h @@ -0,0 +1,28 @@ +/* Generic time.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_TIME_H +#define _AC_TIME_H + +#if TIME_WITH_SYS_TIME +# include +# include +#elif HAVE_SYS_TIME_H +# include +# ifdef HAVE_SYS_TIMEB_H +# include +# endif +#else +# include +#endif + +#endif /* _AC_TIME_H */ diff --git a/include/ac/unistd.h b/include/ac/unistd.h new file mode 100644 index 0000000000..7c2fdfc533 --- /dev/null +++ b/include/ac/unistd.h @@ -0,0 +1,65 @@ +/* Generic unistd.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_UNISTD_H +#define _AC_UNISTD_H + +#if HAVE_SYS_TYPES_H +# include +#endif + +#if HAVE_UNISTD_H +# include +#endif + +/* crypt() may be defined in a separate include file */ +#if HAVE_CRYPT_H +# include +#else + extern char *(crypt)(); +#endif + +#ifndef HAVE_GETPASS +LDAP_F(char*)(getpass) LDAP_P((const char *getpass)); +#else +LDAP_F(char*)(getpass)(); +#endif + +/* getopt() defines may be in separate include file */ +#if HAVE_GETOPT_H +# include + +#elif !defined(HAVE_GETOPT) + /* no getopt, assume we need getopt-compat.h */ +# include + +#else + /* assume we need to declare these externs */ + extern char *optarg; + extern int optind, opterr, optopt; +#endif + +#ifndef HAVE_TEMPNAM + LDAP_F(char *)(tempnam) LDAP_P(( + const char *tmpdir, + const char *prefix)); +#endif +#ifndef HAVE_MKTEMP + LDAP_F(char *)(mktemp) LDAP_P((char *)); +#endif + +/* use lutil file locking */ +#define ldap_lockf(x) lutil_lockf(x) +#define ldap_unlockf(x) lutil_unlockf(x) +#include + +#endif /* _AC_UNISTD_H */ diff --git a/include/ac/wait.h b/include/ac/wait.h new file mode 100644 index 0000000000..12bb7d4a6a --- /dev/null +++ b/include/ac/wait.h @@ -0,0 +1,52 @@ +/* Generic wait.h */ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _AC_WAIT_H +#define _AC_WAIT_H + +#include + +#if HAVE_SYS_WAIT_H +# include +#endif + +#define LDAP_HI(s) (((s) >> 8) & 0377) +#define LDAP_LO(s) ((s) & 0377) + +/* These should work on non-POSIX UNIX platforms, + all bets on off on non-POSIX non-UNIX platforms... */ +#ifndef WIFEXITED +# define WIFEXITED(s) (LDAP_LO(s) == 0) +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(s) LDAP_HI(s) +#endif +#ifndef WIFSIGNALED +# define WIFSIGNALED(s) (LDAP_LO(s) > 0 && LDAP_HI(s) == 0) +#endif +#ifndef WTERMSIG +# define WTERMSIG(s) (LDAP_LO(s) & 0177) +#endif +#ifndef WIFSTOPPED +# define WIFSTOPPED(s) (LDAP_LO(s) == 0177 && LDAP_HI(s) != 0) +#endif +#ifndef WSTOPSIG +# define WSTOPSIG(s) LDAP_HI(s) +#endif + +#ifdef WCONTINUED +# define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED ) +#else +# define WAIT_FLAGS ( WNOHANG | WUNTRACED ) +#endif + +#endif /* _AC_WAIT_H */ diff --git a/include/avl.h b/include/avl.h index 745cc17d61..ae3b44ab65 100644 --- a/include/avl.h +++ b/include/avl.h @@ -1,5 +1,14 @@ -/* avl.h - avl tree definitions */ +/* $OpenLDAP$ */ /* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* Portions * Copyright (c) 1993 Regents of the University of Michigan. * All rights reserved. * @@ -10,47 +19,90 @@ * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ +/* avl.h - avl tree definitions */ #ifndef _AVL #define _AVL +#include + /* * this structure represents a generic avl tree node. */ -typedef struct avlnode { - caddr_t avl_data; - char avl_bf; +LDAP_BEGIN_DECL + +typedef struct avlnode Avlnode; + +#ifdef AVL_INTERNAL +struct avlnode { + void* avl_data; + signed int avl_bf; struct avlnode *avl_left; struct avlnode *avl_right; -} Avlnode; +}; #define NULLAVL ((Avlnode *) NULL) /* balance factor values */ -#define LH -1 +#define LH (-1) #define EH 0 #define RH 1 /* avl routines */ -#define avl_getone(x) (x == 0 ? 0 : (x)->avl_data) -#define avl_onenode(x) (x == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0)) -extern int avl_insert(); -extern caddr_t avl_delete(); -extern caddr_t avl_find(); -extern caddr_t avl_getfirst(); -extern caddr_t avl_getnext(); -extern int avl_dup_error(); -extern int avl_apply(); +#define avl_getone(x) ((x) == 0 ? 0 : (x)->avl_data) +#define avl_onenode(x) ((x) == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0)) + +#endif /* AVL_INTERNALS */ + +typedef int (*AVL_APPLY) LDAP_P((void *, void*)); +typedef int (*AVL_CMP) LDAP_P((const void*, const void*)); +typedef int (*AVL_DUP) LDAP_P((void*, void*)); +typedef void (*AVL_FREE) LDAP_P((void*)); + +LDAP_F( int ) +avl_free LDAP_P(( Avlnode *root, AVL_FREE dfree )); + +LDAP_F( int ) +avl_insert LDAP_P((Avlnode **, void*, AVL_CMP, AVL_DUP)); + +LDAP_F( void* ) +avl_delete LDAP_P((Avlnode **, void*, AVL_CMP)); + +LDAP_F( void* ) +avl_find LDAP_P((Avlnode *, const void*, AVL_CMP)); + +LDAP_F( void* ) +avl_find_lin LDAP_P((Avlnode *, const void*, AVL_CMP)); + +#ifdef AVL_NONREENTRANT +LDAP_F( void* ) +avl_getfirst LDAP_P((Avlnode *)); + +LDAP_F( void* ) +avl_getnext LDAP_P((void)); +#endif + +LDAP_F( int ) +avl_dup_error LDAP_P((void*, void*)); + +LDAP_F( int ) +avl_dup_ok LDAP_P((void*, void*)); + +LDAP_F( int ) +avl_apply LDAP_P((Avlnode *, AVL_APPLY, void*, int, int)); + +LDAP_F( int ) +avl_prefixapply LDAP_P((Avlnode *, void*, AVL_CMP, void*, AVL_CMP, void*, int)); /* apply traversal types */ #define AVL_PREORDER 1 #define AVL_INORDER 2 #define AVL_POSTORDER 3 /* what apply returns if it ran out of nodes */ -#define AVL_NOMORE -6 +#define AVL_NOMORE (-6) -typedef int (*IFP)(); +LDAP_END_DECL #endif /* _AVL */ diff --git a/include/disptmpl.h b/include/disptmpl.h index c4e06ef2fe..ba6f4bd982 100644 --- a/include/disptmpl.h +++ b/include/disptmpl.h @@ -1,4 +1,14 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* Portions * Copyright (c) 1993, 1994 Regents of the University of Michigan. * All rights reserved. * @@ -16,10 +26,9 @@ #ifndef _DISPTMPL_H #define _DISPTMPL_H -#ifdef __cplusplus -extern "C" { -#endif +#include +LDAP_BEGIN_DECL #define LDAP_TEMPLATE_VERSION 1 @@ -123,16 +132,14 @@ struct ldap_tmplitem { }; -#define NULLTMPLITEM ((struct ldap_tmplitem *)0) - #define LDAP_SET_TMPLITEM_APPDATA( ti, datap ) \ - (ti)->ti_appdata = (void *)(datap) + ( (ti)->ti_appdata = (void *)(datap) ) #define LDAP_GET_TMPLITEM_APPDATA( ti, type ) \ - (type)((ti)->ti_appdata) + ( (type)((ti)->ti_appdata) ) #define LDAP_IS_TMPLITEM_OPTION_SET( ti, option ) \ - (((ti)->ti_options & option ) != 0 ) + ( ((ti)->ti_options & (option) ) != 0 ) /* @@ -143,8 +150,6 @@ struct ldap_oclist { struct ldap_oclist *oc_next; }; -#define NULLOCLIST ((struct ldap_oclist *)0) - /* * add defaults list @@ -158,8 +163,6 @@ struct ldap_adddeflist { struct ldap_adddeflist *ad_next; }; -#define NULLADLIST ((struct ldap_adddeflist *)0) - /* * display template global options @@ -199,16 +202,14 @@ struct ldap_disptmpl { struct ldap_disptmpl *dt_next; }; -#define NULLDISPTMPL ((struct ldap_disptmpl *)0) - #define LDAP_SET_DISPTMPL_APPDATA( dt, datap ) \ - (dt)->dt_appdata = (void *)(datap) + ( (dt)->dt_appdata = (void *)(datap) ) #define LDAP_GET_DISPTMPL_APPDATA( dt, type ) \ - (type)((dt)->dt_appdata) + ( (type)((dt)->dt_appdata) ) #define LDAP_IS_DISPTMPL_OPTION_SET( dt, option ) \ - (((dt)->dt_options & option ) != 0 ) + ( ((dt)->dt_options & (option) ) != 0 ) #define LDAP_TMPL_ERR_VERSION 1 #define LDAP_TMPL_ERR_MEM 2 @@ -221,110 +222,96 @@ struct ldap_disptmpl { #define LDAP_DTMPL_BUFSIZ 8192 -#ifndef NEEDPROTOS - -typedef int (*writeptype)(); +typedef int (*ldap_writeptype) LDAP_P(( + void *writeparm, char *p, ber_len_t len )); -int ldap_init_templates(); -int ldap_init_templates_buf(); -void ldap_free_templates(); -struct ldap_disptmpl *ldap_first_disptmpl(); -struct ldap_disptmpl *ldap_next_disptmpl(); -struct ldap_disptmpl *ldap_name2template(); -struct ldap_disptmpl *ldap_oc2template(); -char **ldap_tmplattrs(); -struct ldap_tmplitem *ldap_first_tmplrow(); -struct ldap_tmplitem *ldap_next_tmplrow(); -struct ldap_tmplitem *ldap_first_tmplcol(); -struct ldap_tmplitem *ldap_next_tmplcol(); -int ldap_entry2text_search(); -int ldap_entry2text(); -int ldap_vals2text(); -int ldap_entry2html_search(); -int ldap_entry2html(); -int ldap_vals2html(); +LDAP_F( int ) +ldap_init_templates LDAP_P(( char *file, struct ldap_disptmpl **tmpllistp )); -#else /* !NEEDPROTOS */ +LDAP_F( int ) +ldap_init_templates_buf LDAP_P(( char *buf, + ber_len_t buflen, + struct ldap_disptmpl **tmpllistp )); -typedef int (*writeptype)( void *writeparm, char *p, int len ); +LDAP_F( void ) +ldap_free_templates LDAP_P(( struct ldap_disptmpl *tmpllist )); -LDAPFUNCDECL int -ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp ); +LDAP_F( struct ldap_disptmpl * ) +ldap_first_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist )); -LDAPFUNCDECL int -ldap_init_templates_buf( char *buf, long buflen, - struct ldap_disptmpl **tmpllistp ); +LDAP_F( struct ldap_disptmpl * ) +ldap_next_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist, + struct ldap_disptmpl *tmpl )); -LDAPFUNCDECL void -ldap_free_templates( struct ldap_disptmpl *tmpllist ); +LDAP_F( struct ldap_disptmpl * ) +ldap_name2template LDAP_P(( char *name, + struct ldap_disptmpl *tmpllist )); -LDAPFUNCDECL struct ldap_disptmpl * -ldap_first_disptmpl( struct ldap_disptmpl *tmpllist ); +LDAP_F( struct ldap_disptmpl * ) +ldap_oc2template LDAP_P(( char **oclist, + struct ldap_disptmpl *tmpllist )); -LDAPFUNCDECL struct ldap_disptmpl * -ldap_next_disptmpl( struct ldap_disptmpl *tmpllist, - struct ldap_disptmpl *tmpl ); +LDAP_F( char ** ) +ldap_tmplattrs LDAP_P(( struct ldap_disptmpl *tmpl, + char **includeattrs, + int exclude, + unsigned long syntaxmask )); -LDAPFUNCDECL struct ldap_disptmpl * -ldap_name2template( char *name, struct ldap_disptmpl *tmpllist ); +LDAP_F( struct ldap_tmplitem * ) +ldap_first_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl )); -LDAPFUNCDECL struct ldap_disptmpl * -ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist ); +LDAP_F( struct ldap_tmplitem * ) +ldap_next_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl, + struct ldap_tmplitem *row )); -LDAPFUNCDECL char ** -ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, int exclude, - unsigned long syntaxmask ); +LDAP_F( struct ldap_tmplitem * ) +ldap_first_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl, + struct ldap_tmplitem *row )); -LDAPFUNCDECL struct ldap_tmplitem * -ldap_first_tmplrow( struct ldap_disptmpl *tmpl ); +LDAP_F( struct ldap_tmplitem * ) +ldap_next_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl, + struct ldap_tmplitem *row, + struct ldap_tmplitem *col )); -LDAPFUNCDECL struct ldap_tmplitem * -ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row ); - -LDAPFUNCDECL struct ldap_tmplitem * -ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row ); - -LDAPFUNCDECL struct ldap_tmplitem * -ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, - struct ldap_tmplitem *col ); - -LDAPFUNCDECL int -ldap_entry2text( LDAP *ld, char *buf, LDAPMessage *entry, +LDAP_F( int ) +ldap_entry2text LDAP_P(( LDAP *ld, + char *buf, LDAPMessage *entry, struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, - writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts ); - -LDAPFUNCDECL int -ldap_vals2text( LDAP *ld, char *buf, char **vals, char *label, int labelwidth, - unsigned long syntaxid, writeptype writeproc, void *writeparm, - char *eol, int rdncount ); - -LDAPFUNCDECL int -ldap_entry2text_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry, + ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts )); + +LDAP_F( int ) +ldap_vals2text LDAP_P(( LDAP *ld, + char *buf, char **vals, char *label, int labelwidth, + unsigned long syntaxid, ldap_writeptype writeproc, void *writeparm, + char *eol, int rdncount )); + +LDAP_F( int ) +ldap_entry2text_search LDAP_P(( LDAP *ld, + char *dn, char *base, LDAPMessage *entry, struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, - writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts ); + ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts )); -LDAPFUNCDECL int -ldap_entry2html( LDAP *ld, char *buf, LDAPMessage *entry, +LDAP_F( int ) +ldap_entry2html LDAP_P(( LDAP *ld, + char *buf, LDAPMessage *entry, struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, - writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts, char *urlprefix, char *base ); - -LDAPFUNCDECL int -ldap_vals2html( LDAP *ld, char *buf, char **vals, char *label, int labelwidth, - unsigned long syntaxid, writeptype writeproc, void *writeparm, - char *eol, int rdncount, char *urlprefix ); - -LDAPFUNCDECL int -ldap_entry2html_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry, + ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts, char *urlprefix, char *base )); + +LDAP_F( int ) +ldap_vals2html LDAP_P(( LDAP *ld, + char *buf, char **vals, char *label, int labelwidth, + unsigned long syntaxid, ldap_writeptype writeproc, void *writeparm, + char *eol, int rdncount, char *urlprefix )); + +LDAP_F( int ) +ldap_entry2html_search LDAP_P(( LDAP + *ld, char *dn, char *base, LDAPMessage *entry, struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, - writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts, char *urlprefix ); -#endif /* !NEEDPROTOS */ - + ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts, char *urlprefix )); -#ifdef __cplusplus -} -#endif +LDAP_END_DECL #endif /* _DISPTMPL_H */ diff --git a/include/getopt-compat.h b/include/getopt-compat.h new file mode 100644 index 0000000000..14b2a2f5b0 --- /dev/null +++ b/include/getopt-compat.h @@ -0,0 +1,32 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* + * getopt(3) declarations + */ +#ifndef _GETOPT_COMPAT_H +#define _GETOPT_COMPAT_H + +#include + +LDAP_BEGIN_DECL + +extern char *optarg; +extern int optind, opterr, optopt; + +LDAP_F( int ) +getopt LDAP_P(( + int, + char * const [], + const char *)); + +LDAP_END_DECL + +#endif /* _GETOPT_COMPAT_H */ diff --git a/include/lber.h b/include/lber.h index 667fc26578..229e97e55c 100644 --- a/include/lber.h +++ b/include/lber.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. diff --git a/include/lber_pvt.h b/include/lber_pvt.h new file mode 100644 index 0000000000..7e26591cea --- /dev/null +++ b/include/lber_pvt.h @@ -0,0 +1,38 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* + * lber_pvt.h - Header for ber_pvt_ functions. These are meant to be used + * by the OpenLDAP distribution only. + */ + +#ifndef _LBER_PVT_H +#define _LBER_PVT_H 1 + +#include + +LDAP_BEGIN_DECL + +/* + * bprint.c + */ +LDAP_F( BER_LOG_PRINT_FN ) ber_pvt_log_print; + +LDAP_F( int ) +ber_pvt_log_printf LDAP_P(( + int errlvl, + int loglvl, + const char *fmt, + ... )) LDAP_GCCATTR((format(printf, 3, 4))); + +LDAP_END_DECL + +#endif + diff --git a/include/lber_types.h.in b/include/lber_types.h.in new file mode 100644 index 0000000000..6abba8f722 --- /dev/null +++ b/include/lber_types.h.in @@ -0,0 +1,31 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* + * LBER types + */ + +#ifndef _LBER_TYPES_H +#define _LBER_TYPES_H + +/* LBER boolean, enum, integers - 32 bits or larger*/ +#undef LBER_INT_T + +/* LBER tags - 32 bits or larger */ +#undef LBER_TAG_T + +/* LBER socket descriptor */ +#undef LBER_SOCKET_T + +/* LBER lengths - 32 bits or larger*/ +#undef LBER_LEN_T + +#endif /* _LBER_TYPES_H */ diff --git a/include/lber_types.nt b/include/lber_types.nt new file mode 100644 index 0000000000..884188edcf --- /dev/null +++ b/include/lber_types.nt @@ -0,0 +1,44 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* + * LBER types for Windows NT + */ + +#ifndef _LBER_TYPES_H_NT +#define _LBER_TYPES_H_NT + +/* + * NT types: + * + * bitsof(short) == 2 + * bitsof(int) == 4 + * bitsof(long) == 4 + * + * typedef unsigned int size_t; + * typedef unsigned int SOCKET; + * + * we use native C types to avoid sucking in system headers + */ + +/* LBER boolean, enum, integers - 32 bits or larger*/ +#define LBER_INT_T int + +/* LBER tags - 32 bits or larger */ +#define LBER_TAG_T long + +/* LBER socket descriptor */ +#define LBER_SOCKET_T unsigned int + +/* LBER lengths - 32 bits or larger*/ +#define LBER_LEN_T int + +#endif /* _LBER_TYPES_H_NT */ diff --git a/include/ldap.h b/include/ldap.h index 36221c1c1a..8dbbd1b1ef 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. @@ -167,7 +168,7 @@ typedef struct ldapcontrol { #define LDAP_CHASE_SUBORDINATE_REFERRALS 0x0020 #define LDAP_CHASE_EXTERNAL_REFERRALS 0x0040 -#define LDAP_CONTROL_MANAGEDSAIT "2.16.16.840.1.113730.3.4.2" +#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.2.6" /* LDAP Unsolicited Notifications */ #define LDAP_NOTICE_DISCONNECT "1.3.6.1.4.1.1466.20036" @@ -869,6 +870,27 @@ ldap_modify_s LDAP_P(( * in modrdn.c: */ LDAP_F( int ) +ldap_rename LDAP_P(( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *newrdn, + int deleteoldrdn, + LDAP_CONST char *newSuperior, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp )); + +LDAP_F( int ) +ldap_rename_s LDAP_P(( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *newrdn, + int deleteoldrdn, + LDAP_CONST char *newSuperior, + LDAPControl **sctrls, + LDAPControl **cctrls )); + +LDAP_F( int ) ldap_rename_ext LDAP_P(( LDAP *ld, LDAP_CONST char *dn, @@ -1034,38 +1056,38 @@ ldap_add_result_entry LDAP_P(( /* * in getdn.c */ -LDAP_F( char *) +LDAP_F( char * ) ldap_get_dn LDAP_P(( LDAP *ld, LDAPMessage *entry )); -LDAP_F( char *) +LDAP_F( char * ) ldap_dn2ufn LDAP_P(( LDAP_CONST char *dn )); -LDAP_F( char **) +LDAP_F( char ** ) ldap_explode_dn LDAP_P(( LDAP_CONST char *dn, int notypes )); -LDAP_F( char **) +LDAP_F( char ** ) ldap_explode_rdn LDAP_P(( LDAP_CONST char *rdn, int notypes )); -LDAP_F( char *) -ldap_parent_dn LDAP_P(( /* new (from slapd) */ +LDAP_F( char * ) +ldap_parent_dn LDAP_P(( LDAP_CONST char *dn )); -LDAP_F( char *) -ldap_relative_dn LDAP_P(( /* new (from slapd) */ +LDAP_F( char * ) +ldap_relative_dn LDAP_P(( LDAP_CONST char *dn )); -LDAP_F( char *) -ldap_normalize_dn LDAP_P(( /* new (from slapd) */ +LDAP_F( char * ) +ldap_normalize_dn LDAP_P(( LDAP_CONST char *dn )); -LDAP_F( char **) +LDAP_F( char ** ) ldap_explode_dns LDAP_P(( /* deprecated */ LDAP_CONST char *dn )); diff --git a/include/ldap_cdefs.h b/include/ldap_cdefs.h new file mode 100644 index 0000000000..dc5722d82e --- /dev/null +++ b/include/ldap_cdefs.h @@ -0,0 +1,78 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* LDAP C Defines */ + +#ifndef _LDAP_CDEFS_H +#define _LDAP_CDEFS_H + +#if defined(__cplusplus) || defined(c_plusplus) +# define LDAP_BEGIN_DECL extern "C" { +# define LDAP_END_DECL } +#else +# define LDAP_BEGIN_DECL /* begin declarations */ +# define LDAP_END_DECL /* end declarations */ +#endif + +#if !defined(__NO_PROTOTYPES) && ( defined(__NEED_PROTOTYPES) || \ + defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) ) + + /* ANSI C or C++ */ +# define LDAP_P(protos) protos +# define LDAP_CONCAT1(x,y) x ## y +# define LDAP_CONCAT(x,y) LDAP_CONCAT1(x,y) +# define LDAP_STRING(x) #x /* stringify without expanding x */ +# define LDAP_XSTRING(x) LDAP_STRING(x) /* expand x, then stringify */ + +#ifndef LDAP_CONST +# define LDAP_CONST const +#endif + +#else /* no prototypes */ + + /* traditional C */ +# define LDAP_P(protos) () +# define LDAP_CONCAT(x,y) x/**/y +# define LDAP_STRING(x) "x" + +#ifndef LDAP_CONST +# define LDAP_CONST /* no const */ +#endif + +#endif /* no prototypes */ + +#if _WIN32 && _DLL +# define LDAP_F_IMPORT extern __declspec( dllimport ) +# define LDAP_F_EXPORT extern __declspec( dllexport ) +#else +# define LDAP_F_IMPORT extern +# define LDAP_F_EXPORT extern +#endif + +#if (__GNUC__) * 1000 + (__GNUC_MINOR__) >= 2006 +# define LDAP_GCCATTR(attrs) __attribute__(attrs) +#else +# define LDAP_GCCATTR(attrs) +#endif + + +#endif /* _LDAP_CDEFS_H */ + +/* purposely allow these to be redefined */ +#ifndef LDAP_F_PRE +# define LDAP_F_PRE LDAP_F_IMPORT +#endif +#ifndef LDAP_F_POST +# define LDAP_F_POST /* no post */ +#endif +#ifndef LDAP_F +#define LDAP_F(type) LDAP_F_PRE type LDAP_F_POST +#endif + diff --git a/include/ldap_config.h.in b/include/ldap_config.h.in new file mode 100644 index 0000000000..a7d0f01cb9 --- /dev/null +++ b/include/ldap_config.h.in @@ -0,0 +1,56 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* + * This file works in confunction with OpenLDAP configure system. + * If you do no like the values below, adjust your configure options. + */ + +#ifndef _LDAP_CONFIG_H +#define _LDAP_CONFIG_H + +/* directory separator */ +#ifndef LDAP_DIRSEP +#define LDAP_DIRSEP "/" +#endif + +/* directories */ +#ifndef LDAP_BINDIR +#define LDAP_BINDIR "%BINDIR%" +#endif +#ifndef LDAP_SBINDIR +#define LDAP_SBINDIR "%SBINDIR%" +#endif +#ifndef LDAP_DATADIR +#define LDAP_DATADIR "%DATADIR%" +#endif +#ifndef LDAP_SYSCONFDIR +#define LDAP_SYSCONFDIR "%SYSCONFDIR%" +#endif +#ifndef LDAP_LIBEXECDIR +#define LDAP_LIBEXECDIR "%LIBEXECDIR%" +#endif +#ifndef LDAP_RUNDIR +#define LDAP_RUNDIR "%RUNDIR%" +#endif + +/* command locations */ +#ifndef LDAP_EDITOR +#define LDAP_EDITOR "%EDITOR%" +#endif +#ifndef LDAP_FINGER +#define LDAP_FINGER "%FINGER%" +#endif +#ifndef LDAP_SENDMAIL +#define LDAP_SENDMAIL "%SENDMAIL%" +#endif + +#endif /* _LDAP_CONFIG_H */ diff --git a/include/ldap_config.nt b/include/ldap_config.nt new file mode 100644 index 0000000000..ce3597a76b --- /dev/null +++ b/include/ldap_config.nt @@ -0,0 +1,59 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* + * This file works in confunction with OpenLDAP configure system. + * If you do no like the values below, adjust your configure options. + */ + +#ifndef _LDAP_CONFIG_H +#define _LDAP_CONFIG_H + +/* directory separator */ +#ifndef LDAP_DIRSEP +#define LDAP_DIRSEP "\\" +#endif + +/* directories */ +#ifndef LDAP_PREFIX +#define LDAP_PREFIX "C:\\OpenLDAP" +#endif +#ifndef LDAP_BINDIR +#define LDAP_BINDIR LDAP_PREFIX "\\bin" +#endif +#ifndef LDAP_SBINDIR +#define LDAP_SBINDIR LDAP_PREFIX "\\sbin" +#endif +#ifndef LDAP_DATADIR +#define LDAP_DATADIR LDAP_PREFIX "\\share" +#endif +#ifndef LDAP_SYSCONFDIR +#define LDAP_SYSCONFDIR LDAP_PREFIX "\\sysconf" +#endif +#ifndef LDAP_LIBEXECDIR +#define LDAP_LIBEXECDIR LDAP_PREFIX "\\libexec" +#endif +#ifndef LDAP_RUNDIR +#define LDAP_RUNDIR LDAP_PREFIX "\\run" +#endif + +/* command locations */ +#ifndef LDAP_EDITOR +#define LDAP_EDITOR "%EDITOR%" +#endif +#ifndef LDAP_FINGER +#define LDAP_FINGER "%FINGER%" +#endif +#ifndef LDAP_SENDMAIL +#define LDAP_SENDMAIL "%SENDMAIL%" +#endif + +#endif /* _LDAP_CONFIG_H */ diff --git a/include/ldap_defaults.h b/include/ldap_defaults.h new file mode 100644 index 0000000000..0b27fff34e --- /dev/null +++ b/include/ldap_defaults.h @@ -0,0 +1,221 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* Portions + * Copyright (c) 1994 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +/* + * This file controls defaults for OpenLDAP package. + * You should not change any of these settings. + */ + +#ifndef _LDAP_DEFAULTS_H +#define _LDAP_DEFAULTS_H + + +#include + +#define LDAP_CONF_FILE LDAP_SYSCONFDIR LDAP_DIRSEP "ldap.conf" +#define LDAP_USERRC_FILE "ldaprc" +#define LDAP_ENV_PREFIX "LDAP" + + +/********************************************************************* + * * + * You probably do not need to edit anything below this point * + * * + *********************************************************************/ + +/* + * SHARED DEFINITIONS - other things you can change + */ + /* default attribute to use when sorting entries, NULL => sort by DN */ +#define SORT_ATTR NULL + /* default count of DN components to show in entry displays */ +#define DEFAULT_RDNCOUNT 2 + /* default config file locations */ +#define FILTERFILE LDAP_SYSCONFDIR LDAP_DIRSEP "ldapfilter.conf" +#define TEMPLATEFILE LDAP_SYSCONFDIR LDAP_DIRSEP "ldaptemplates.conf" +#define SEARCHFILE LDAP_SYSCONFDIR LDAP_DIRSEP "ldapsearchprefs.conf" +#define FRIENDLYFILE LDAP_DATADIR LDAP_DIRSEP "ldapfriendly" + +/* + * FINGER DEFINITIONS + */ + /* banner to print */ +#define FINGER_BANNER "OpenLDAP Finger Service...\r\n" + /* who to report errors to */ +#define FINGER_ERRORS "System Administrator" + /* what to say if no matches are found */ +#define FINGER_NOMATCH "Search failed to find anything.\r\n" + /* what to say if the service may be unavailable */ +#define FINGER_UNAVAILABLE \ +"The directory service may be temporarily unavailable.\r\n\ +Please try again later.\r\n" + /* printed if a match has no email address - for disptmp default */ +#define FINGER_NOEMAIL1 "None registered in this service." +#define FINGER_NOEMAIL2 NULL +#define FINGER_NOEMAIL { FINGER_NOEMAIL1, FINGER_NOEMAIL2, NULL } + /* maximum number of matches returned */ +#define FINGER_SIZELIMIT 50 + /* max number of hits displayed in full before a list is presented */ +#define FINGER_LISTLIMIT 1 + /* what to exec for "finger @host" */ +#define FINGER_CMD LDAP_FINGER + /* how to treat aliases when searching */ +#define FINGER_DEREF LDAP_DEREF_FINDING + /* attribute to use when sorting results */ +#define FINGER_SORT_ATTR SORT_ATTR + /* enable ufn support */ +#define FINGER_UFN + /* timeout for searches */ +#define FINGER_TIMEOUT 60 + /* number of DN components to show in entry displays */ +#define FINGER_RDNCOUNT DEFAULT_RDNCOUNT + +/* + * GO500 GOPHER GATEWAY DEFINITIONS + */ + /* port on which to listen */ +#define GO500_PORT 5555 + /* how to handle aliases */ +#define GO500_DEREF LDAP_DEREF_FINDING + /* attribute to use when sorting results */ +#define GO500_SORT_ATTR SORT_ATTR + /* timeout for searches */ +#define GO500_TIMEOUT 180 + /* enable ufn support */ +#define GO500_UFN + /* + * only set and uncomment this if your hostname() does not return + * a fully qualified hostname + */ +/* #define GO500_HOSTNAME "fully.qualified.hostname.here" */ + /* number of DN components to show in entry displays */ +#define GO500_RDNCOUNT DEFAULT_RDNCOUNT + +/* + * GO500GW GOPHER GATEWAY DEFINITIONS + */ + /* where the helpfile lives */ +#define GO500GW_HELPFILE LDAP_DATADIR LDAP_DIRSEP "go500gw.help" + /* port on which to listen */ +#define GO500GW_PORT 7777 + /* timeout on all searches */ +#define GO500GW_TIMEOUT 180 + /* enable ufn support */ +#define GO500GW_UFN + /* attribute to use when sorting results */ +#define GO500GW_SORT_ATTR SORT_ATTR + /* + * only set and uncomment this if your hostname() does not return + * a fully qualified hostname + */ +/* #define GO500GW_HOSTNAME "fully.qualified.hostname.here" */ + /* number of DN components to show in entry displays */ +#define GO500GW_RDNCOUNT DEFAULT_RDNCOUNT + +/* + * RCPT500 MAIL RESPONDER GATEWAY DEFINITIONS + */ + /* where the helpfile lives */ +#define RCPT500_HELPFILE LDAP_DATADIR LDAP_DIRSEP "rcpt500.help" + /* maximum number of matches returned */ +#define RCPT500_SIZELIMIT 50 + /* address replies will appear to come from */ +#define RCPT500_FROM "\"Directory Query Program\" " + /* command that will accept an RFC822 message text on standard + input, and send it. sendmail -t does this nicely. */ +#define RCPT500_PIPEMAILCMD LDAP_SENDMAIL " -t" + /* attribute to use when sorting results */ +#define RCPT500_SORT_ATTR SORT_ATTR + /* max number of hits displayed in full before a list is presented */ +#define RCPT500_LISTLIMIT 1 + /* enable ufn support */ +#define RCPT500_UFN + /* number of DN components to show in entry displays */ +#define RCPT500_RDNCOUNT DEFAULT_RDNCOUNT + +/* + * MAIL500 MAILER DEFINITIONS + */ + /* max number of ambiguous matches reported */ +#define MAIL500_MAXAMBIGUOUS 10 + /* max subscribers allowed (size limit when searching for them ) */ +#define MAIL500_MAXGROUPMEMBERS LDAP_NO_LIMIT + /* timeout for all searches */ +#define MAIL500_TIMEOUT 180 + /* sendmail location - mail500 needs to exec this */ +#define MAIL500_SENDMAIL LDAP_SENDMAIL + +/* + * UD DEFINITIONS + */ + /* ud configuration file */ +#define UD_CONFIG_FILE LDAP_SYSCONFDIR LDAP_DIRSEP "ud.conf" + /* default editor */ +#define UD_DEFAULT_EDITOR LDAP_EDITOR + /* default bbasename of user config file */ +#define UD_USER_CONFIG_FILE ".udrc" + /* default base where groups are created */ +#define UD_WHERE_GROUPS_ARE_CREATED "" + /* default base below which all groups live */ +#define UD_WHERE_ALL_GROUPS_LIVE "" + +/* + * FAX500 DEFINITIONS + */ + /* how long to wait for searches */ +#define FAX_TIMEOUT 180 + /* maximum number of ambiguous matches reported */ +#define FAX_MAXAMBIGUOUS 10 + /* maximum number of members allowed */ +#define FAX_MAXMEMBERS LDAP_NO_LIMIT + /* program to send mail */ +#define FAX_SENDMAIL LDAP_SENDMAIL + +/* + * RP500 DEFINITIONS + */ + /* prefix to add to non-fully-qualified numbers */ +#define RP_PHONEPREFIX "" + +/* + * SLAPD DEFINITIONS + */ + /* location of the default slapd config file */ +#define SLAPD_DEFAULT_CONFIGFILE LDAP_SYSCONFDIR LDAP_DIRSEP "slapd.conf" + /* default max deref depth for aliases */ +#define SLAPD_DEFAULT_MAXDEREFDEPTH 15 + /* default sizelimit on number of entries from a search */ +#define SLAPD_DEFAULT_SIZELIMIT 500 + /* default timelimit to spend on a search */ +#define SLAPD_DEFAULT_TIMELIMIT 3600 + /* minimum max ids that a single index entry can map to in ldbm */ +#define SLAPD_LDBM_MIN_MAXIDS 4000 + +/* the following DNs must be normalized and in uppercase! */ + /* dn of the special "monitor" entry */ +#define SLAPD_MONITOR_DN "CN=MONITOR" + /* dn of the special "config" entry */ +#define SLAPD_CONFIG_DN "CN=CONFIG" + /* dn of the special "schema" entry */ +#define SLAPD_SCHEMA_DN "CN=SCHEMA" + +#endif /* _LDAP_CONFIG_H */ diff --git a/include/ldap_features.h.in b/include/ldap_features.h.in new file mode 100644 index 0000000000..62c3b5a167 --- /dev/null +++ b/include/ldap_features.h.in @@ -0,0 +1,56 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* + * LDAP Features + */ +#ifndef _LDAP_FEATURES_H +#define _LDAP_FEATURES_H 1 + +/* +** OpenLDAP reentrancy/thread-safeness should be dynamically +** checked using ldap_get_option(). +** +** The -lldap implementation may or may not be: +** LDAP_API_FEATURE_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_REENTRANT can +** be used to determine if -lldap is LDAP_API_FEATURE_THREAD_SAFE at +** compile time. +** +** The -lldap_r implementation is always THREAD_SAFE but +** may also be: +** LDAP_API_FEATURE_SESSION_THREAD_SAFE +** LDAP_API_FEATURE_OPERATION_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE +** can be used to determine if -lldap_r is available at compile +** time. You must define LDAP_THREAD_SAFE if and only if you +** link with -lldap_r. +** +** If you fail to define LDAP_THREAD_SAFE when linking with +** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap, +** provided header definations and declarations may be incorrect. +** +*/ + +/* is -lldap reentrant or not */ +#undef LDAP_API_FEATURE_X_OPENLDAP_REENTRANT + +/* is threadsafe version of -lldap (ie: -lldap_r) *available* or not */ +#undef LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE + +/* LDAP v2 DNS */ +#undef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS + +/* LDAP v2 Referrals */ +#undef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS + +#endif /* LDAP_FEATURES */ diff --git a/include/ldap_features.nt b/include/ldap_features.nt new file mode 100644 index 0000000000..29cd0a5314 --- /dev/null +++ b/include/ldap_features.nt @@ -0,0 +1,56 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* + * LDAP Features + */ +#ifndef _LDAP_FEATURES_H +#define _LDAP_FEATURES_H 1 + +/* +** OpenLDAP reentrancy/thread-safeness should be dynamically +** checked using ldap_get_option(). +** +** The -lldap implementation may or may not be: +** LDAP_API_FEATURE_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_REENTRANT can +** be used to determine if -lldap is LDAP_API_FEATURE_THREAD_SAFE at +** compile time. +** +** The -lldap_r implementation is always THREAD_SAFE but +** may also be: +** LDAP_API_FEATURE_SESSION_THREAD_SAFE +** LDAP_API_FEATURE_OPERATION_THREAD_SAFE +** +** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE +** can be used to determine if -lldap_r is availalbe at compile +** time. You must define LDAP_THREAD_SAFE if and only if you +** link with -lldap_r. +** +** If you fail to define LDAP_THREAD_SAFE when linking with +** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap, +** provided header definations and declarations may be incorrect. +** +*/ + +/* is -lldap reentrant or not */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_REENTRANT */ + +/* is threadsafe version of -lldap (ie: -lldap_r) *available* or not */ +#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE LDAP_VENDOR_VERSION + +/* LDAP v2 DNS */ +/* #undef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */ + +/* LDAP v2 Referrals */ +#define LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS LDAP_VENDOR_VERSION + +#endif /* LDAP_FEATURES */ diff --git a/include/ldap_log.h b/include/ldap_log.h new file mode 100644 index 0000000000..dfb2e7a9cd --- /dev/null +++ b/include/ldap_log.h @@ -0,0 +1,83 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* Portions + * Copyright (c) 1990 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +#ifndef _LDAP_LOG_H +#define _LDAP_LOG_H + +#include + +LDAP_BEGIN_DECL + +#define LDAP_DEBUG_TRACE 0x0001 +#define LDAP_DEBUG_PACKETS 0x0002 +#define LDAP_DEBUG_ARGS 0x0004 +#define LDAP_DEBUG_CONNS 0x0008 +#define LDAP_DEBUG_BER 0x0010 +#define LDAP_DEBUG_FILTER 0x0020 +#define LDAP_DEBUG_CONFIG 0x0040 +#define LDAP_DEBUG_ACL 0x0080 +#define LDAP_DEBUG_STATS 0x0100 +#define LDAP_DEBUG_STATS2 0x0200 +#define LDAP_DEBUG_SHELL 0x0400 +#define LDAP_DEBUG_PARSE 0x0800 + +#define LDAP_DEBUG_DEPRECATED 0x1000 +#define LDAP_DEBUG_NONE 0x8000 +#define LDAP_DEBUG_ANY -1 + +/* debugging stuff */ +#ifdef LDAP_DEBUG + +#ifndef ldap_debug +extern int ldap_debug; +#endif /* !ldap_debug */ + +#ifdef LDAP_SYSLOG +extern int ldap_syslog; +extern int ldap_syslog_level; +#endif /* LDAP_SYSLOG */ + +/* this doesn't below as part of ldap.h */ +#ifdef LDAP_SYSLOG +#define Debug( level, fmt, arg1, arg2, arg3 ) \ + do { \ + lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ); \ + if ( ldap_syslog & (level) ) \ + syslog( ldap_syslog_level, (fmt), (arg1), (arg2), (arg3) ); \ + } while ( 0 ) + +#else +#define Debug( level, fmt, arg1, arg2, arg3 ) \ + lutil_debug( ldap_debug, (level), (fmt), (arg1), (arg2), (arg3) ) +#endif + +#else /* LDAP_DEBUG */ +#define Debug( level, fmt, arg1, arg2, arg3 ) +#endif /* LDAP_DEBUG */ + +LDAP_F(void) lutil_debug LDAP_P(( + int debug, int level, + const char* fmt, ... )) LDAP_GCCATTR((format(printf, 3, 4))); + +LDAP_END_DECL + +#endif /* _LDAP_LOG_H */ diff --git a/include/ldap_pvt.h b/include/ldap_pvt.h index 3014e217ee..2b20ed4929 100644 --- a/include/ldap_pvt.h +++ b/include/ldap_pvt.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. @@ -16,6 +17,7 @@ #define _LDAP_PVT_H 1 #include +#include /* get ber_slen_t */ LDAP_BEGIN_DECL @@ -77,6 +79,41 @@ ldap_str2charray LDAP_P(( void ldap_pvt_hex_unescape LDAP_P(( char *s )); int ldap_pvt_unhex( int c ); +/* these macros assume 'x' is an ASCII x */ +#define LDAP_DNSEPARATOR(c) ((c) == ',' || (c) == ';') +#define LDAP_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '+') +#define LDAP_SPACE(c) ((c) == ' ' || (c) == '\n') + +#define LDAP_LOWER(c) ( (c) >= 'a' && (c) <= 'z' ) +#define LDAP_UPPER(c) ( (c) >= 'A' && (c) <= 'Z' ) +#define LDAP_ALPHA(c) ( LDAP_LOWER(c) || LDAP_UPPER(c) ) +#define LDAP_DIGIT(c) ( (c) >= '0' && (c) <= '9' ) +#define LDAP_ALNUM(c) ( LDAP_ALPHA(c) || LDAP_DIGIT(c) ) + +#define LDAP_LEADKEYCHAR(c) ( LDAP_ALPHA(c) ) +#define LDAP_KEYCHAR(c) ( LDAP_ALNUM(c) || (c) == '-' ) +#define LDAP_LEADOIDCHAR(c) ( LDAP_DIGIT(c) ) +#define LDAP_OIDCHAR(c) ( LDAP_DIGIT(c) || (c) == '.' ) + +#define LDAP_LEADATTRCHAR(c) ( LDAP_LEADKEYCHAR(c) || LDAP_LEADOIDCHAR(c) ) +#define LDAP_ATTRCHAR(c) ( LDAP_KEYCHAR((c)) || (c) == '.' ) + +#define LDAP_NEEDSESCAPE(c) ((c) == '\\' || (c) == '"') + +/* search.c */ +LDAP_F( char * ) +ldap_pvt_find_wildcard LDAP_P(( char *s )); + +LDAP_F( ber_slen_t ) +ldap_pvt_filter_value_unescape LDAP_P(( char *filter )); + +/* string.c */ +LDAP_F( char * ) +ldap_pvt_str2upper LDAP_P(( char *str )); + +LDAP_F( char * ) +ldap_pvt_str2lower LDAP_P(( char *str )); + LDAP_END_DECL #endif diff --git a/include/ldap_pvt_thread.h b/include/ldap_pvt_thread.h new file mode 100644 index 0000000000..a006a2ef66 --- /dev/null +++ b/include/ldap_pvt_thread.h @@ -0,0 +1,308 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* ldap_pvt_thread.h - ldap threads header file NG */ + +#ifndef _LDAP_PVT_THREAD_H +#define _LDAP_PVT_THREAD_H + +#include "ldap_cdefs.h" + +#if defined( HAVE_PTHREADS ) +/********************************** + * * + * definitions for POSIX Threads * + * * + **********************************/ + +#include +#ifdef HAVE_SCHED_H +#include +#endif + +LDAP_BEGIN_DECL + +typedef pthread_t ldap_pvt_thread_t; +typedef pthread_mutex_t ldap_pvt_thread_mutex_t; +typedef pthread_cond_t ldap_pvt_thread_cond_t; + +#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \ + defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \ + defined( _POSIX_THREADSAFE_FUNCTIONS ) +#define HAVE_REENTRANT_FUNCTIONS 1 +#endif + +#if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \ + defined( HAVE_THR_GETCONCURRENCY ) +#define HAVE_GETCONCURRENCY 1 +#endif + +#if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \ + defined( HAVE_THR_SETCONCURRENCY ) +#define HAVE_SETCONCURRENCY 1 +#endif + +LDAP_END_DECL + +#elif defined ( HAVE_MACH_CTHREADS ) +/********************************** + * * + * definitions for Mach CThreads * + * * + **********************************/ + +#include + +LDAP_BEGIN_DECL + +typedef cthread_t ldap_pvt_thread_t; +typedef struct mutex ldap_pvt_thread_mutex_t; +typedef struct condition ldap_pvt_thread_cond_t; + +LDAP_END_DECL + +#elif defined( HAVE_GNU_PTH ) +/*********************************** + * * + * thread definitions for GNU Pth * + * * + ***********************************/ + +#include + +LDAP_BEGIN_DECL + +typedef pth_t ldap_pvt_thread_t; +typedef pth_mutex_t ldap_pvt_thread_mutex_t; +typedef pth_cond_t ldap_pvt_thread_cond_t; + +LDAP_END_DECL + + +#elif defined( HAVE_THR ) +/******************************************** + * * + * thread definitions for Solaris LWP (THR) * + * * + ********************************************/ + +#include +#include + +LDAP_BEGIN_DECL + +typedef thread_t ldap_pvt_thread_t; +typedef mutex_t ldap_pvt_thread_mutex_t; +typedef cond_t ldap_pvt_thread_cond_t; + +#define HAVE_REENTRANT_FUNCTIONS 1 + +#ifdef HAVE_THR_GETCONCURRENCY +#define HAVE_GETCONCURRENCY 1 +#endif +#ifdef HAVE_THR_SETCONCURRENCY +#define HAVE_SETCONCURRENCY 1 +#endif + +LDAP_END_DECL + +#elif defined( HAVE_LWP ) +/************************************* + * * + * thread definitions for SunOS LWP * + * * + *************************************/ + +#include +#include + +LDAP_BEGIN_DECL + +typedef thread_t ldap_pvt_thread_t; +typedef mon_t ldap_pvt_thread_mutex_t; +struct ldap_pvt_thread_lwp_cv { + int lcv_created; + cv_t lcv_cv; +}; +typedef struct ldap_pvt_thread_lwp_cv ldap_pvt_thread_cond_t; + +#define HAVE_REENTRANT_FUNCTIONS 1 + +LDAP_END_DECL + +#elif HAVE_NT_THREADS + +LDAP_BEGIN_DECL + +#define WIN32_LEAN_AND_MEAN +#include +#include + +typedef unsigned long ldap_pvt_thread_t; +typedef HANDLE ldap_pvt_thread_mutex_t; +typedef HANDLE ldap_pvt_thread_cond_t; + +LDAP_END_DECL + +#else + +/*********************************** + * * + * thread definitions for no * + * underlying library support * + * * + ***********************************/ + +LDAP_BEGIN_DECL + +#ifndef NO_THREADS +#define NO_THREADS 1 +#endif + +typedef int ldap_pvt_thread_t; +typedef int ldap_pvt_thread_mutex_t; +typedef int ldap_pvt_thread_cond_t; + +LDAP_END_DECL + +#endif /* no threads support */ + +LDAP_BEGIN_DECL + +LDAP_F( int ) +ldap_pvt_thread_initialize LDAP_P(( void )); + +LDAP_F( int ) +ldap_pvt_thread_destroy LDAP_P(( void )); + +LDAP_F( unsigned int ) +ldap_pvt_thread_sleep LDAP_P(( unsigned int s )); + +#ifdef HAVE_GETCONCURRENCY +LDAP_F( int ) +ldap_pvt_thread_get_concurrency LDAP_P(( void )); +#endif + +#ifdef HAVE_SETCONCURRENCY +# ifndef LDAP_THREAD_CONCURRENCY + /* three concurrent threads should be enough */ +# define LDAP_THREAD_CONCURRENCY 3 +# endif +LDAP_F( int ) +ldap_pvt_thread_set_concurrency LDAP_P(( int )); +#endif + +#define LDAP_PVT_THREAD_CREATE_JOINABLE 0 +#define LDAP_PVT_THREAD_CREATE_DETACHED 1 + +LDAP_F( int ) +ldap_pvt_thread_create LDAP_P(( + ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void * ), + void *arg)); + +LDAP_F( void ) +ldap_pvt_thread_exit LDAP_P(( void *retval )); + +LDAP_F( int ) +ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status )); + +LDAP_F( int ) +ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo )); + +LDAP_F( int ) +ldap_pvt_thread_yield LDAP_P(( void )); + +LDAP_F( int ) +ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond )); + +LDAP_F( int ) +ldap_pvt_thread_cond_destroy LDAP_P(( ldap_pvt_thread_cond_t *cond )); + +LDAP_F( int ) +ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond )); + +LDAP_F( int ) +ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond )); + +LDAP_F( int ) +ldap_pvt_thread_cond_wait LDAP_P(( + ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex )); + +LDAP_F( int ) +ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); + +LDAP_F( int ) +ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); + +LDAP_F( int ) +ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); + +LDAP_F( int ) +ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); + +LDAP_F( int ) +ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); + +typedef struct ldap_pvt_thread_rdwr_var { + ldap_pvt_thread_mutex_t ltrw_mutex; + ldap_pvt_thread_cond_t ltrw_read; /* wait for read */ + ldap_pvt_thread_cond_t ltrw_write; /* wait for write */ + int ltrw_valid; +#define LDAP_PVT_THREAD_RDWR_VALID 0x0bad + int ltrw_r_active; + int ltrw_w_active; + int ltrw_r_wait; + int ltrw_w_wait; +} ldap_pvt_thread_rdwr_t; + +LDAP_F( int ) +ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_destroy LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_rtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_runlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_wlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_wtrylock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_wunlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +#ifdef LDAP_DEBUG +LDAP_F( int ) +ldap_pvt_thread_rdwr_readers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_writers LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); + +LDAP_F( int ) +ldap_pvt_thread_rdwr_active LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); +#endif /* LDAP_DEBUG */ + +#define LDAP_PVT_THREAD_EINVAL EINVAL +#define LDAP_PVT_THREAD_EBUSY EINVAL + +LDAP_END_DECL + +#endif /* _LDAP_THREAD_H */ diff --git a/include/ldap_schema.h b/include/ldap_schema.h index 64de1b08d6..c0c21bc88d 100644 --- a/include/ldap_schema.h +++ b/include/ldap_schema.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. @@ -160,7 +161,7 @@ ldap_matchingrule2str LDAP_P(( LDAP_F( char *) ldap_scherr2str LDAP_P(( - int code )); + int code )) LDAP_GCCATTR((const)); LDAP_END_DECL diff --git a/include/ldbm.h b/include/ldbm.h index 10f9b3b44d..9fd65730e3 100644 --- a/include/ldbm.h +++ b/include/ldbm.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. diff --git a/include/ldif.h b/include/ldif.h index 901fb58e70..a50bbf0634 100644 --- a/include/ldif.h +++ b/include/ldif.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. @@ -7,7 +8,6 @@ * license is available at http://www.OpenLDAP.org/license.html or * in file LICENSE in the top-level directory of the distribution. */ - /* Portions * Copyright (c) 1996 Regents of the University of Michigan. * All rights reserved. diff --git a/include/lutil.h b/include/lutil.h index d7eb530fcd..05d6279f94 100644 --- a/include/lutil.h +++ b/include/lutil.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. @@ -12,6 +13,8 @@ #define _LUTIL_H 1 #include +#include + /* * Include file for LDAP utility routine */ @@ -54,6 +57,9 @@ lutil_progname LDAP_P(( int argc, char *argv[] )); +/* sockpair.c */ +LDAP_F( int ) +lutil_pair( LBER_SOCKET_T sd[2] ); LDAP_END_DECL diff --git a/include/lutil_lockf.h b/include/lutil_lockf.h new file mode 100644 index 0000000000..728b445cbf --- /dev/null +++ b/include/lutil_lockf.h @@ -0,0 +1,30 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* File locking methods + * + * lutil_lockf() will block until an exclusive lock is acquired. + */ + +#ifndef _LUTIL_LOCKF_H_ +#define _LUTIL_LOCKF_H_ + +LDAP_BEGIN_DECL + +LDAP_F( int ) +lutil_lockf LDAP_P(( int fd )); + +LDAP_F( int ) +lutil_unlockf LDAP_P(( int fd )); + +LDAP_END_DECL + +#endif /* _LUTIL_LOCKF_H_ */ diff --git a/include/lutil_md5.h b/include/lutil_md5.h new file mode 100644 index 0000000000..6a140c9753 --- /dev/null +++ b/include/lutil_md5.h @@ -0,0 +1,66 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* See md5.c for explanation and copyright information. */ + +#ifndef _LUTIL_MD5_H_ +#define _LUTIL_MD5_H_ + +#include +#include + +LDAP_BEGIN_DECL + +/* Unlike previous versions of this code, uint32 need not be exactly + 32 bits, merely 32 bits or more. Choosing a data type which is 32 + bits instead of 64 is not important; speed is considerably more + important. ANSI guarantees that "unsigned long" will be big enough, + and always using it seems to have few disadvantages. */ + +#ifndef LDAP_UINT32 +#define LDAP_UINT32 1 +typedef ac_uint4 uint32; +#endif + +struct lutil_MD5Context { + uint32 buf[4]; + uint32 bits[2]; + unsigned char in[64]; +}; + +LDAP_F( void ) +lutil_MD5Init LDAP_P(( + struct lutil_MD5Context *context)); + +LDAP_F( void ) +lutil_MD5Update LDAP_P(( + struct lutil_MD5Context *context, + unsigned char const *buf, + unsigned len)); + +LDAP_F( void ) +lutil_MD5Final LDAP_P(( + unsigned char digest[16], + struct lutil_MD5Context *context)); + +LDAP_F( void ) +lutil_MD5Transform LDAP_P(( + uint32 buf[4], + const unsigned char in[64])); + +/* + * This is needed to make RSAREF happy on some MS-DOS compilers. + */ +typedef struct lutil_MD5Context lutil_MD5_CTX; + +LDAP_END_DECL + +#endif /* _LUTIL_MD5_H_ */ diff --git a/include/lutil_sha1.h b/include/lutil_sha1.h new file mode 100644 index 0000000000..07f82fb8eb --- /dev/null +++ b/include/lutil_sha1.h @@ -0,0 +1,69 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* This version is based on: + * $OpenBSD: sha1.h,v 1.8 1997/07/15 01:54:23 millert Exp $ */ + +#ifndef _LUTIL_SHA1_H_ +#define _LUTIL_SHA1_H_ + +#include +#include + +LDAP_BEGIN_DECL + +/* + * SHA-1 in C + * By Steve Reid + */ + +#ifndef LDAP_UINT32 +#define LDAP_UINT32 1 +typedef ac_uint4 uint32; +#endif + +typedef struct { + uint32 state[5]; + uint32 count[2]; + unsigned char buffer[64]; +} lutil_SHA1_CTX; + +LDAP_F( void ) +lutil_SHA1Transform + LDAP_P((uint32 state[5], const unsigned char buffer[64])); + +LDAP_F( void ) +lutil_SHA1Init + LDAP_P((lutil_SHA1_CTX *context)); + +LDAP_F( void ) +lutil_SHA1Update + LDAP_P((lutil_SHA1_CTX *context, const unsigned char *data, uint32 len)); + +LDAP_F( void ) +lutil_SHA1Final + LDAP_P((unsigned char digest[20], lutil_SHA1_CTX *context)); + +LDAP_F( char * ) +lutil_SHA1End + LDAP_P((lutil_SHA1_CTX *, char *)); + +LDAP_F( char * ) +lutil_SHA1File + LDAP_P((char *, char *)); + +LDAP_F( char * ) +lutil_SHA1Data + LDAP_P((const unsigned char *, size_t, char *)); + +LDAP_END_DECL + +#endif /* _LUTIL_SHA1_H_ */ diff --git a/include/portable.h.in b/include/portable.h.in index 82341447b9..3464300ce2 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -213,6 +213,9 @@ /* Define if you have the mkstemp function. */ #undef HAVE_MKSTEMP +/* Define if you have the pipe function. */ +#undef HAVE_PIPE + /* Define if you have the pthread_getconcurrency function. */ #undef HAVE_PTHREAD_GETCONCURRENCY @@ -261,6 +264,9 @@ /* Define if you have the setuid function. */ #undef HAVE_SETUID +/* Define if you have the sigaction function. */ +#undef HAVE_SIGACTION + /* Define if you have the signal function. */ #undef HAVE_SIGNAL @@ -429,6 +435,9 @@ /* Define if you have the header file. */ #undef HAVE_PSAP_H +/* Define if you have the header file. */ +#undef HAVE_PTH_H + /* Define if you have the header file. */ #undef HAVE_PTHREAD_H @@ -462,9 +471,6 @@ /* Define if you have the header file. */ #undef HAVE_SSL_H -/* Define if you have the header file. */ -#undef HAVE_STDARG_H - /* Define if you have the header file. */ #undef HAVE_STDDEF_H @@ -642,6 +648,9 @@ /* define if you have Mach Cthreads */ #undef HAVE_MACH_CTHREADS +/* if you have GNU Pth */ +#undef HAVE_GNU_PTH + /* if you have Solaris LWP (thr) package */ #undef HAVE_THR @@ -777,6 +786,12 @@ /* define to support reverse lookups */ #undef SLAPD_RLOOKUPS +/* define to support per-object ACIs */ +#undef SLAPD_ACI_ENABLED + +/* define to support discrete rights in ACIs */ +#undef SLAPD_ACI_DISCRETE_RIGHTS + /* define to support modules */ #undef SLAPD_MODULES @@ -824,6 +839,11 @@ /* begin of postamble */ +#ifndef __NEED_PROTOTYPES +/* force LDAP_P to always include prototypes */ +#define __NEED_PROTOTYPES 1 +#endif + #ifdef HAVE_STDDEF_H # include #endif diff --git a/include/portable.nt b/include/portable.nt new file mode 100644 index 0000000000..af077ef6f2 --- /dev/null +++ b/include/portable.nt @@ -0,0 +1,759 @@ +/* $OpenLDAP$ */ +/* include/portable.h.nt -- manually updated of MS NT (MS VC5) */ +/* synced with portable.h.in 1.24 */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#ifndef _LDAP_PORTABLE_H +#define _LDAP_PORTABLE_H + +/* end of preamble */ + +/* --------------------------------------------------- */ +/* begin of MSVC5 specific entries */ + +#define OPENLDAP_PACKAGE "OpenLDAP" +#define OPENLDAP_VERSION "-devel" +#define EXEEXT ".exe" +#define LDAP_DIRSEP "\\" + +/* don't suck in all of the win32 api */ +#define WIN32_LEAN_AND_MEAN + +#ifdef _WINNT +/* WindowsNT specific features */ +#define HAVE_NT_SERVICE_MANAGER 1 +#define HAVE_NT_EVENT_LOG 1 + +#elif _WIN95 +/* Windows95 specific features */ +#endif + +#if defined( _DEBUG ) && !defined( LDAP_DEBUG ) +/* #define LDAP_MEMORY_DEBUG 1 */ +#define LDAP_DEBUG 1 +#endif + +/* we installed Henry Spencer's REGEX */ +#define HAVE_REGEX_H 1 + +/* win32 specific stuff */ +#define sleep _sleep + +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define strdup _strdup + +#define snprintf _snprintf +#define vsnprintf _vsnprintf +/* #define vsprintf _vsprintf */ + +/* define type for caddr_t */ +typedef char * caddr_t; + +#define ssize_t signed int + +#define LOG_DEBUG 0 +#define openlog( a, b ) +#define closelog() + +#define FD_SETSIZE 1024 + +/* we have NT threads */ +#ifdef _MT +#define HAVE_NT_THREADS 1 +#else +#define NO_THREADS 1 +#endif + +/* we have spawnlp instead of fork/execlp */ +#define HAVE_SPAWNLP 1 + +/* we have winsock2 */ +#define HAVE_WINSOCK2 1 + +/* we have winsock */ +#define HAVE_WINSOCK 1 + +/* we have */ +#define HAVE_CONIO_H 1 + +/* we have */ +#define HAVE_DIRECT_H 1 + +/* we have */ +#define HAVE_IO_H 1 + +/* we have */ +#define HAVE_PROCESS_H 1 + +#define LDAP_SIGUSR1 SIGILL +#define LDAP_SIGUSR2 SIGTERM + +#define MAXPATHLEN _MAX_PATH + +/* end of MSVC5 specific entries */ +/* --------------------------------------------------- */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to the type of elements in the array set by `getgroups'. + Usually this is either `int' or `gid_t'. */ +/* #undef GETGROUPS_T */ + +/* Define to `int' if doesn't define. */ +#define gid_t long + +/* Define if you don't have vprintf but do have _doprnt. */ +/* #undef HAVE_DOPRNT */ + +/* Define if your struct stat has st_blksize. */ +/* #undef HAVE_ST_BLKSIZE */ + +/* Define if you have the strftime function. */ +#define HAVE_STRFTIME 1 + +/* Define if you have that is POSIX.1 compatible. */ +/* #undef HAVE_SYS_WAIT_H */ + +/* Define if you have the vprintf function. */ +#define HAVE_VPRINTF 1 + +/* Define if on MINIX. */ +/* #undef _MINIX */ + +/* Define to `int' if doesn't define. */ +#define mode_t int + +/* Define to `long' if doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if doesn't define. */ +#define pid_t int + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +/* #undef TIME_WITH_SYS_TIME */ + +/* Define if your declares struct tm. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define to `int' if doesn't define. */ +#define uid_t long + +/* Define if your processor stores words with the most significant + byte first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* define this if needed to get reentrant functions */ +#ifndef REENTRANT +/* #undef REENTRANT */ +#endif +#ifndef _REENTRANT +/* #undef _REENTRANT */ +#endif + +/* define this if needed to get threadsafe functions */ +#ifndef THREADSAFE +/* #undef THREADSAFE */ +#endif +#ifndef _THREADSAFE +/* #undef _THREADSAFE */ +#endif +#ifndef THREAD_SAFE +/* #undef THREAD_SAFE */ +#endif +#ifndef _THREAD_SAFE +/* #undef _THREAD_SAFE */ +#endif + +/* define this if toupper() requires tolower() */ +#define C_UPPER_LOWER 1 + +/* define this to the number of arguments ctime_r() expects */ +/* #undef CTIME_R_NARGS */ + +/* define this if sys_errlist is not defined in stdio.h or errno.h */ +/* #undef DECL_SYS_ERRLIST */ + +/* define this if sys_errlist is available */ +#define HAVE_SYS_ERRLIST 1 + +/* define if you have berkeley db */ +/* #undef HAVE_BERKELEY_DB */ + +/* define if you have berkeley db2 */ +#define HAVE_BERKELEY_DB2 1 + +/* define if you have crypt */ +/* #undef HAVE_CRYPT */ + +/* define if you have GDBM */ +/* #undef HAVE_GDBM */ + +/* define if you have NDBM */ +/* #undef HAVE_NDBM */ + +/* define if you have res_search() */ +#ifdef __notdef__ +/* see second res_search define */ +/* #undef HAVE_RES_SEARCH */ +#endif + +/* define if you have sched_yield() */ +#ifdef __notdef__ +/* see second sched_yield define */ +/* #undef HAVE_SCHED_YIELD */ +#endif + +/* define if you have setproctitle() */ +/* #undef HAVE_SETPROCTITLE */ + +/* define this for connectionless LDAP support */ +/* #undef LDAP_CONNECTIONLESS */ + +/* define this to add debugging code */ +/* #undef LDAP_DEBUG */ + +/* define this to remove -lldap cache support */ +/* #undef LDAP_NOCACHE */ + +/* define this for LDAP process title support */ +/* #undef LDAP_PROCTITLE */ + +/* define this for LDAP User Interface support */ +/* #undef LDAP_LIBUI */ + +/* define this to add syslog code */ +/* #undef LDAP_SYSLOG */ + +/* define this to use DBBTREE w/ LDBM backend */ +#define LDBM_USE_DBBTREE 1 + +/* define this to use DBHASH w/ LDBM backend */ +/* #undef LDBM_USE_DBHASH */ + +/* define this for ACL Group support */ +#define SLAPD_ACLGROUPS 1 + +/* define this to use SLAPD Berkeley DB2 backend */ +/* #define SLAPD_BDB2 1 */ + +/* define this for ClearText password support */ +#define SLAPD_CLEARTEXT 1 + +/* define this for crypt(3) password support */ +/* #undef SLAPD_CRYPT */ + +/* define this to use SLAPD LDAP backend */ +/* #undef SLAPD_LDAP */ + +/* define this to use SLAPD LDBM backend */ +#define SLAPD_LDBM 1 + +/* define this to use SLAPD passwd backend */ +/* #undef SLAPD_PASSWD */ + +/* define this to use SLAPD perl backend */ +/* #undef SLAPD_PERL */ + +/* define this for phonetic support */ +/* #undef SLAPD_PHONETIC */ + +/* define this for Reverse Lookup support */ +#define SLAPD_RLOOKUPS 1 + +/* define this for per-object ACIs */ +/* #undef SLAPD_ACI_ENABLED */ + +/* define this for discrete rights in ACIs */ +/* #undef SLAPD_ACI_DISCRETE_RIGHTS */ + +/* define this to use SLAPD shell backend */ +/* #undef SLAPD_SHELL */ + +/* define this to be empty if your compiler doesn't support volatile */ +/* #undef volatile */ + +/* define this if sig_atomic_t isn't defined in signal.h */ +/* #undef sig_atomic_t */ + +/* define this if socklen_t isn't defined in sys/types.h or sys/socket.h */ +#define socklen_t int + +/* These are defined in ldap_features.h */ +/* + LDAP_API_FEATURE_X_OPENLDAP_REENTRANT + LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE + LDAP_API_FEATURE_X_OPENLDAP_V2_DNS + LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS +*/ + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/* The number of bytes in a short. */ +#define SIZEOF_SHORT 2 + +/* Define if you have the bcopy function. */ +/* #undef HAVE_BCOPY */ + +/* Define if you have the ctime_r function. */ +/* #undef HAVE_CTIME_R */ + +/* Define if you have the flock function. */ +/* #undef HAVE_FLOCK */ + +/* Define if you have the getdtablesize function. */ +/* #undef HAVE_GETDTABLESIZE */ + +/* Define if you have the gethostbyaddr_r function. */ +/* #undef HAVE_GETHOSTBYADDR_R */ + +/* Define if you have the gethostbyname_r function. */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define if you have the gethostname function. */ +#define HAVE_GETHOSTNAME 1 + +/* define if you have the getopt function */ +/* #undef HAVE_GETOPT */ + +/* Define if you have the getpwuid function. */ +/* #undef HAVE_GETPWUID */ + +/* Define if you have the gettimeofday function. */ +/* #undef HAVE_GETTIMEOFDAY */ + +/* Define if you have the lockf function. */ +/* #undef HAVE_LOCKF */ + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the mkstemp function. */ +/* #undef HAVE_MKSTEMP */ + +/* Define if you have the pthread_getconcurrency function. */ +/* #undef HAVE_PTHREAD_GETCONCURRENCY */ + +/* Define if you have the pthread_kill function. */ +/* #undef HAVE_PTHREAD_KILL */ + +/* Define if you have the pthread_setconcurrency function. */ +/* #undef HAVE_PTHREAD_SETCONCURRENCY */ + +/* Define if you have the pthread_yield function. */ +/* #undef HAVE_PTHREAD_YIELD */ + +/* Define if you have the res_search function. */ +/* #undef HAVE_RES_SEARCH */ + +/* Define if you have the sched_yield function. */ +/* #undef HAVE_SCHED_YIELD */ + +/* Define if you have the select function. */ +#define HAVE_SELECT 1 + +/* Define if you have the setpwfile function. */ +/* #undef HAVE_SETPWFILE */ + +/* Define if you have the setsid function. */ +/* #undef HAVE_SETSID */ + +/* Define if you have the signal function. */ +#define HAVE_SIGNAL 1 + +/* Define if you have the sigset function. */ +/* #undef HAVE_SIGSET */ + +/* Define if you have the snprintf function. */ +/* #undef HAVE_SNPRINTF */ + +/* Define if you have the socket function. */ +#define HAVE_SOCKET 1 + +/* Define if you have the strdup function. */ +#define HAVE_STRDUP 1 + +/* Define if you have the strerror function. */ +#define HAVE_STRERROR 1 + +/* Define if you have the strpbrk function. */ +#define HAVE_STRPBRK 1 + +/* Define if you have the strrchr function. */ +#define HAVE_STRRCHR 1 + +/* Define if you have the strsep function. */ +/* #undef HAVE_STRSEP */ + +/* Define if you have the strspn function. */ +#define HAVE_STRSPN 1 + +/* Define if you have the strstr function. */ +#define HAVE_STRSTR 1 + +/* Define if you have the strtok function. */ +#define HAVE_STRTOK 1 + +/* Define if you have the strtok_r function. */ +/* #undef HAVE_STRTOK_R */ + +/* Define if you have the strtol function. */ +#define HAVE_STRTOL 1 + +/* Define if you have the strtoul function. */ +#define HAVE_STRTOUL 1 + +/* Define if you have the sysconf function. */ +/* #undef HAVE_SYSCONF */ + +/* Define if you have the tempnam function. */ +/* #undef HAVE_TEMPNAM */ + +/* Define if you have the thr_getconcurrency function. */ +/* #undef HAVE_THR_GETCONCURRENCY */ + +/* Define if you have the thr_setconcurrency function. */ +/* #undef HAVE_THR_SETCONCURRENCY */ + +/* Define if you have the thr_yield function. */ +/* #undef HAVE_THR_YIELD */ + +/* Define if you have the vsnprintf function. */ +#define HAVE_VSNPRINTF 1 + +/* Define if you have the vsprintf function. */ +#define HAVE_VSPRINTF 1 + +/* Define if you have the waitpid function. */ +/* #undef HAVE_WAITPID 1 */ + +/* Define if you have the header file. */ +/* #undef HAVE_ARPA_NAMESER_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_CRYPT_H */ + +/* Define if you have the header file. */ +#define HAVE_DB_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_DB_185_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_DES_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_DIRENT_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_DMALLOC_H */ + +/* Define if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_FILIO_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_GDBM_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_GETOPT_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_KERBEROSIV_DES_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_KERBEROSIV_KRB_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_KRB_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_LWP_LWP_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_MACH_CTHREADS_H */ + +/* Define if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define if you have the header file. */ +/* #define HAVE_MEMORY_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_NDBM_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_PSAP_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_PTHREAD_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_PWD_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_REGEX_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_RESOLV_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SCHED_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SGTTY_H */ + +/* Define if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_STRINGS_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYNCH_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_ERRNO_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_FILE_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_FILIO_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_IOCTL_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_PARAM_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_RESOURCE_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_SOCKET_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_SYSLOG_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_TIME_H */ + +/* Define if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYSEXITS_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYSLOG_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_TCPD_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_TERMCAP_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_TERMIOS_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_UNISTD_H */ + +/* Define if you have the V3 library (-lV3). */ +/* #undef HAVE_LIBV3 */ + +/* Define if you have the bind library (-lbind). */ +/* #undef HAVE_LIBBIND */ + +/* Define if you have the dmalloc library (-ldmalloc). */ +/* #undef HAVE_LIBDMALLOC */ + +/* Define if you have the gen library (-lgen). */ +/* #undef HAVE_LIBGEN */ + +/* Define if you have the inet library (-linet). */ +/* #undef HAVE_LIBINET */ + +/* Define if you have the net library (-lnet). */ +/* #undef HAVE_LIBNET */ + +/* Define if you have the nsl library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define if you have the nsl_s library (-lnsl_s). */ +/* #undef HAVE_LIBNSL_S */ + +/* Define if you have the resolv library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define if you have the socket library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* define if you have -lxtpp */ +/* #undef HAVE_XTPP */ + +/* define if you have -ldsap */ +/* #undef HAVE_DSAP */ + +/* define if you have -lisode */ +/* #undef HAVE_ISODE */ + +/* define if you have -lpp */ +/* #undef HAVE_PP */ + +/* define if you have Kerberos des_debug */ +/* #undef HAVE_DES_DEBUG */ + +/* define if you have Kerberos */ +/* #undef HAVE_KERBEROS */ + +/* define if pthreads API compatible with final spec */ +/* #undef HAVE_PTHREADS_FINAL */ + +/* define if pthreads API compatible with draft4 spec */ +/* #undef HAVE_PTHREADS_D4 */ + +/* define if you have LinuxThreads */ +/* #undef HAVE_LINUX_THREADS */ + +/* define if you have POSIX Threads */ +/* #undef HAVE_PTHREADS */ + +/* define if you have pthread_detach function */ +/* #undef HAVE_PTHREAD_DETACH */ + +/* define if you have Mach Cthreads */ +/* #undef HAVE_MACH_CTHREADS */ + +/* if you have Solaris LWP (thr) package */ +/* #undef HAVE_THR */ + +/* if you have SunOS LWP package */ +/* #undef HAVE_LWP */ + +/* define if select implicitly yields */ +#define HAVE_YIELDING_SELECT 1 + +/* define if you have (or want) no threads */ +/* #undef NO_THREADS */ + +/* define if you have -lwrap */ +/* #undef HAVE_TCPD */ + +/* define if you have -ltermcap */ +/* #undef HAVE_TERMCAP */ + +/* define if you have -lncurses */ +/* #undef HAVE_NCURSES */ + +/* define if you have no termcap support */ +#define NO_TERMCAP 1 + +/* Define if TIOCGWINSZ requires sys/ioctl.h */ +/* #undef GWINSZ_IN_SYS_IOCTL */ + +/* define if you have POSIX termios */ +/* #undef HAVE_POSIX_TERMIOS */ + +/* Define if system has ptrdiff_t type */ +#define HAVE_PTRDIFF_T 1 + +/* define if cross compiling */ +/* #undef CROSS_COMPILING */ + +/* begin of postamble */ + +#ifndef __NEED_PROTOTYPES +/* force LDAP_P to always include prototypes */ +#define __NEED_PROTOTYPES 1 +#endif + +#ifdef HAVE_STDDEF_H +# include +#endif + +#if defined(LDAP_DEVEL) && !defined(LDAP_TEST) +#define LDAP_TEST +#endif +#if defined(LDAP_TEST) && !defined(LDAP_DEBUG) +#define LDAP_DEBUG +#endif + +#include "ldap_cdefs.h" +#include "ldap_features.h" + +#include + +#endif /* _LDAP_PORTABLE_H */ diff --git a/include/setup.dsp b/include/setup.dsp new file mode 100644 index 0000000000..2114f7205e --- /dev/null +++ b/include/setup.dsp @@ -0,0 +1,100 @@ +# Microsoft Developer Studio Project File - Name="setup" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=setup - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "setup.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "setup.mak" CFG="setup - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "setup - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "setup - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "setup - Win32 Release" + +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f setup.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "setup.txt" +# PROP BASE Bsc_Name "setup.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "NMAKE /f setup.mak" +# PROP Rebuild_Opt "/a" +# PROP Target_File "setup.txt" +# PROP Bsc_Name "setup.bsc" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "setup - Win32 Debug" + +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f setup.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "setup.txt" +# PROP BASE Bsc_Name "setup.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "NMAKE /f setup.mak" +# PROP Rebuild_Opt "/a" +# PROP Target_File "setup.txt" +# PROP Bsc_Name "setup.bsc" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "setup - Win32 Release" +# Name "setup - Win32 Debug" + +!IF "$(CFG)" == "setup - Win32 Release" + +!ELSEIF "$(CFG)" == "setup - Win32 Debug" + +!ENDIF + +# Begin Source File + +SOURCE=.\lber_types.nt +# End Source File +# Begin Source File + +SOURCE=.\ldap_config.nt +# End Source File +# Begin Source File + +SOURCE=.\ldap_features.nt +# End Source File +# Begin Source File + +SOURCE=.\portable.nt +# End Source File +# Begin Source File + +SOURCE=.\setup.mak +# End Source File +# End Target +# End Project diff --git a/include/setup.mak b/include/setup.mak index ad8ddaa022..9e3b1c3a53 100644 --- a/include/setup.mak +++ b/include/setup.mak @@ -1,21 +1,20 @@ +# $OpenLDAP$ # # Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. # COPYING RESTRICTIONS APPLY, see COPYRIGHT file # -all: setup.txt - -setup.txt: lber_types.h ldap_config.h ldap_features.h portable.h - copy setup.mak setup.txt +.SUFFIXES: .nt -lber_types.h: lber_types.h.nt - copy lber_types.h.nt lber_types.h +.nt.h: + copy $*.nt $*.h -ldap_config.h: ldap_config.h.nt - copy ldap_config.h.nt ldap_config.h +all: setup.txt -ldap_features.h: ldap_features.h.nt - copy ldap_features.h.nt ldap_features.h +setup.txt: lber_types.h ldap_config.h ldap_features.h portable.h setup.mak + copy setup.mak setup.txt -portable.h: portable.h.nt - copy portable.h.nt portable.h +lber_types.h: lber_types.nt +ldap_config.h: ldap_config.nt +ldap_features.h: ldap_features.nt +portable.h: portable.nt diff --git a/include/srchpref.h b/include/srchpref.h index a1d65cffb0..e3523b0051 100644 --- a/include/srchpref.h +++ b/include/srchpref.h @@ -1,4 +1,14 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* Portions * Copyright (c) 1993, 1994 Regents of the University of Michigan. * All rights reserved. * @@ -17,10 +27,9 @@ #ifndef _SRCHPREF_H #define _SRCHPREF_H -#ifdef __cplusplus -extern "C" { -#endif +#include +LDAP_BEGIN_DECL struct ldap_searchattr { char *sa_attrlabel; @@ -52,15 +61,13 @@ struct ldap_searchobj { struct ldap_searchobj *so_next; }; -#define NULLSEARCHOBJ ((struct ldap_searchobj *)0) - /* * global search object options */ #define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001 #define LDAP_IS_SEARCHOBJ_OPTION_SET( so, option ) \ - (((so)->so_options & option ) != 0 ) + (((so)->so_options & (option) ) != 0 ) #define LDAP_SEARCHPREF_VERSION_ZERO 0 #define LDAP_SEARCHPREF_VERSION 1 @@ -71,36 +78,26 @@ struct ldap_searchobj { #define LDAP_SEARCHPREF_ERR_FILE 4 -#ifndef NEEDPROTOS -int ldap_init_searchprefs(); -int ldap_init_searchprefs_buf(); -void ldap_free_searchprefs(); -struct ldap_searchobj *ldap_first_searchobj(); -struct ldap_searchobj *ldap_next_searchobj(); - -#else /* !NEEDPROTOS */ - -LDAPFUNCDECL int -ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp ); +LDAP_F( int ) +ldap_init_searchprefs LDAP_P(( char *file, + struct ldap_searchobj **solistp )); -LDAPFUNCDECL int -ldap_init_searchprefs_buf( char *buf, long buflen, - struct ldap_searchobj **solistp ); +LDAP_F( int ) +ldap_init_searchprefs_buf LDAP_P(( char *buf, + ber_len_t buflen, + struct ldap_searchobj **solistp )); -LDAPFUNCDECL void -ldap_free_searchprefs( struct ldap_searchobj *solist ); +LDAP_F( void ) +ldap_free_searchprefs LDAP_P(( struct ldap_searchobj *solist )); -LDAPFUNCDECL struct ldap_searchobj * -ldap_first_searchobj( struct ldap_searchobj *solist ); +LDAP_F( struct ldap_searchobj * ) +ldap_first_searchobj LDAP_P(( struct ldap_searchobj *solist )); -LDAPFUNCDECL struct ldap_searchobj * -ldap_next_searchobj( struct ldap_searchobj *sollist, - struct ldap_searchobj *so ); +LDAP_F( struct ldap_searchobj * ) +ldap_next_searchobj LDAP_P(( struct ldap_searchobj *sollist, + struct ldap_searchobj *so )); -#endif /* !NEEDPROTOS */ +LDAP_END_DECL -#ifdef __cplusplus -} -#endif #endif /* _SRCHPREF_H */ diff --git a/include/sysexits-compat.h b/include/sysexits-compat.h index 9be67fa417..4855154980 100644 --- a/include/sysexits-compat.h +++ b/include/sysexits-compat.h @@ -1,4 +1,14 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ +/* Portions * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * diff --git a/libraries/Makefile.in b/libraries/Makefile.in new file mode 100644 index 0000000000..d911128bea --- /dev/null +++ b/libraries/Makefile.in @@ -0,0 +1,8 @@ +# $OpenLDAP$ +## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved. +## COPYING RESTRICTIONS APPLY, see COPYRIGHT file +## +## Libraries Makefile for OpenLDAP + +SUBDIRS= liblutil libldif liblber libldap libavl libldbm libldap_r + diff --git a/libraries/libavl/Makefile.in b/libraries/libavl/Makefile.in new file mode 100644 index 0000000000..92af71fa0d --- /dev/null +++ b/libraries/libavl/Makefile.in @@ -0,0 +1,18 @@ +# $OpenLDAP$ +## +## LIBAVL +## + +SRCS = avl.c testavl.c +XSRCS = version.c +OBJS = avl.o + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + +LIBRARY = libavl.a +PROGRAMS = testavl +XLIBS = -lavl + +testavl: $(LIBRARY) testavl.o + $(LTLINK) $(LDFLAGS) -o $@ testavl.o $(LIBS) diff --git a/libraries/libavl/avl.c b/libraries/libavl/avl.c index 3b6c113ccc..eb30049ef4 100644 --- a/libraries/libavl/avl.c +++ b/libraries/libavl/avl.c @@ -1,4 +1,5 @@ /* avl.c - routines to implement an avl tree */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libavl/testavl.c b/libraries/libavl/testavl.c index bd6d35bf01..94540c304d 100644 --- a/libraries/libavl/testavl.c +++ b/libraries/libavl/testavl.c @@ -1,4 +1,5 @@ /* testavl.c - Test Tim Howes AVL code */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/libraries/liblber/Makefile.in b/libraries/liblber/Makefile.in new file mode 100644 index 0000000000..4808224b22 --- /dev/null +++ b/libraries/liblber/Makefile.in @@ -0,0 +1,35 @@ +# $OpenLDAP$ +## Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. +## COPYING RESTRICTIONS APPLY, see COPYRIGHT file +## +## LIBLBER +## + +LIBRARY = liblber.la +XLIBRARY = ../liblber.a + +SRCS= assert.c decode.c encode.c io.c bprint.c \ + memory.c options.c sockbuf.c +OBJS= assert.lo decode.lo encode.lo io.lo bprint.lo \ + memory.lo options.lo sockbuf.lo +XSRCS= version.c + +PROGRAMS= dtest etest idtest + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + +XLIBS = -llber +XXLIBS = + +dtest: $(LIBRARY) dtest.o + $(LTLINK) $(LDFLAGS) -o $@ dtest.o $(LIBS) +etest: $(LIBRARY) etest.o + $(LTLINK) $(LDFLAGS) -o $@ etest.o $(LIBS) +idtest: $(LIBRARY) idtest.o + $(LTLINK) $(LDFLAGS) -o $@ idtest.o $(LIBS) + +install-local: FORCE + -$(MKDIR) $(libdir) + $(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(libdir) + diff --git a/libraries/liblber/assert.c b/libraries/liblber/assert.c index f71df23435..50b70dd53b 100644 --- a/libraries/liblber/assert.c +++ b/libraries/liblber/assert.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c index e4b6fd27ea..eb8808563c 100644 --- a/libraries/liblber/bprint.c +++ b/libraries/liblber/bprint.c @@ -1,40 +1,136 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + #include -#include -#include -#include "lber.h" + +#include +#include +#include + +#undef LDAP_F_PRE +#define LDAP_F_PRE LDAP_F_EXPORT + +#include "lber-int.h" + +/* + * Print stuff + */ +static void +ber_error_print( char *data ) +{ + assert( data != NULL ); + + fputs( data, stderr ); + fflush( stderr ); +} + +BER_LOG_PRINT_FN ber_pvt_log_print = ber_error_print; + +/* + * lber log + */ + +static int ber_log_check( int errlvl, int loglvl ) +{ + return errlvl & loglvl ? 1 : 0; +} + +int ber_pvt_log_printf( int errlvl, int loglvl, const char *fmt, ... ) +{ + char buf[ 1024 ]; + va_list ap; + + assert( fmt != NULL ); + + if ( !ber_log_check( errlvl, loglvl )) { + return 0; + } + + va_start( ap, fmt ); + +#ifdef HAVE_VSNPRINTF + buf[sizeof(buf) - 1] = '\0'; + vsnprintf( buf, sizeof(buf)-1, fmt, ap ); +#elif HAVE_VSPRINTF + vsprintf( buf, fmt, ap ); /* hope it's not too long */ +#else + /* use doprnt() */ +#error "vsprintf() required." +#endif + + va_end(ap); + + (*ber_pvt_log_print)( buf ); + return 1; +} + +static int ber_log_puts(int errlvl, int loglvl, char *buf) +{ + assert( buf != NULL ); + + if ( !ber_log_check( errlvl, loglvl )) { + return 0; + } + + (*ber_pvt_log_print)( buf ); + return 1; +} /* * Print arbitrary stuff, for debugging. */ -#ifdef LDAP_DEBUG +int +ber_log_bprint(int errlvl, + int loglvl, + const char *data, + ber_len_t len ) +{ + assert( data != NULL ); -#ifndef NO_USERINTERFACE -#define BPLEN 48 + if ( !ber_log_check( errlvl, loglvl )) { + return 0; + } + + ber_bprint(data, len); + return 1; +} void -lber_bprint( char *data, int len ) +ber_bprint( + LDAP_CONST char *data, + ber_len_t len ) { - static char hexdig[] = "0123456789abcdef"; + static const char hexdig[] = "0123456789abcdef"; +#define BPLEN 48 char out[ BPLEN ]; + char buf[ BPLEN + sizeof("\t%s\n") ]; int i = 0; + assert( data != NULL ); + memset( out, 0, BPLEN ); for ( ;; ) { if ( len < 1 ) { - fprintf( stderr, "\t%s\n", ( i == 0 ) ? "(end)" : out ); + sprintf( buf, "\t%s\n", ( i == 0 ) ? "(end)" : out ); + (*ber_pvt_log_print)( buf ); break; } -#ifndef HEX +#ifndef LDAP_HEX if ( isgraph( (unsigned char)*data )) { out[ i ] = ' '; out[ i+1 ] = *data; } else { #endif - out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ]; - out[ i+1 ] = hexdig[ *data & 0x0f ]; -#ifndef HEX + out[ i ] = hexdig[ ( *data & 0xf0U ) >> 4 ]; + out[ i+1 ] = hexdig[ *data & 0x0fU ]; +#ifndef LDAP_HEX } #endif i += 2; @@ -42,7 +138,9 @@ lber_bprint( char *data, int len ) data++; if ( i > BPLEN - 2 ) { - fprintf( stderr, "\t%s\n", out ); + char data[128 + BPLEN]; + sprintf( data, "\t%s\n", out ); + (*ber_pvt_log_print)(data); memset( out, 0, BPLEN ); i = 0; continue; @@ -50,11 +148,96 @@ lber_bprint( char *data, int len ) out[ i++ ] = ' '; } } -#else /* NO_USERINTERFACE */ + +int +ber_log_dump( + int errlvl, + int loglvl, + const BerElement *ber, + int inout ) +{ + assert( ber != NULL ); + assert( BER_VALID( ber ) ); + + if ( !ber_log_check( errlvl, loglvl )) { + return 0; + } + + ber_dump(ber, inout); + return 1; +} + void -lber_bprint( char *data, int len ) +ber_dump( + LDAP_CONST BerElement *ber, + int inout ) +{ + char buf[132]; + + assert( ber != NULL ); + assert( BER_VALID( ber ) ); + + sprintf( buf, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n", + (long) ber->ber_buf, + (long) ber->ber_ptr, + (long) ber->ber_end ); + + (*ber_pvt_log_print)( buf ); + + if ( inout == 1 ) { + sprintf( buf, " current len %ld, contents:\n", + (long) (ber->ber_end - ber->ber_ptr) ); + ber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr ); + + } else { + sprintf( buf, " current len %ld, contents:\n", + (long) (ber->ber_ptr - ber->ber_buf) ); + + ber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf ); + } +} + +int +ber_log_sos_dump( + int errlvl, + int loglvl, + const Seqorset *sos ) { + assert( sos != NULL ); + + if ( !ber_log_check( errlvl, loglvl )) { + return 0; + } + + ber_sos_dump( sos ); + return 1; } -#endif /* NO_USERINTERFACE */ -#endif +void +ber_sos_dump( + LDAP_CONST Seqorset *sos ) +{ + char buf[132]; + + assert( sos != NULL ); + + (*ber_pvt_log_print)( "*** sos dump ***\n" ); + + while ( sos != NULL ) { + sprintf( buf, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n", + (long) sos->sos_clen, + (long) sos->sos_first, + (long) sos->sos_ptr ); + (*ber_pvt_log_print)( buf ); + + sprintf( buf, " current len %ld contents:\n", + (long) (sos->sos_ptr - sos->sos_first) ); + (*ber_pvt_log_print)( buf ); + + ber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first ); + + sos = sos->sos_next; + } + + (*ber_pvt_log_print)( "*** end dump ***\n" ); +} diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 6b029b3cd6..e2c204d793 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -1,4 +1,5 @@ /* decode.c - ber input decoding routines */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -486,21 +487,11 @@ ber_next_element( /* VARARGS */ ber_tag_t -ber_scanf -#if HAVE_STDARG - ( BerElement *ber, +ber_scanf ( BerElement *ber, LDAP_CONST char *fmt, ... ) -#else - ( va_alist ) -va_dcl -#endif { va_list ap; -#ifndef HAVE_STDARG - BerElement *ber; - char *fmt; -#endif LDAP_CONST char *fmt_reset; char *last; char *s, **ss, ***sss; @@ -512,13 +503,7 @@ va_dcl ber_tag_t rc, tag; ber_len_t len; -#ifdef HAVE_STDARG va_start( ap, fmt ); -#else - va_start( ap ); - ber = va_arg( ap, BerElement * ); - fmt = va_arg( ap, char * ); -#endif assert( ber != NULL ); assert( fmt != NULL ); @@ -672,13 +657,7 @@ va_dcl * Error. Reclaim malloced memory that was given to the caller. * Set allocated pointers to NULL, "data length" outvalues to 0. */ -#ifdef HAVE_STDARG va_start( ap, fmt ); -#else - va_start( ap ); - (void) va_arg( ap, BerElement * ); - (void) va_arg( ap, char * ); -#endif for ( ; fmt_reset < fmt; fmt_reset++ ) { switch ( *fmt_reset ) { diff --git a/libraries/liblber/dtest.c b/libraries/liblber/dtest.c index 30d803eb93..749958b1ee 100644 --- a/libraries/liblber/dtest.c +++ b/libraries/liblber/dtest.c @@ -1,4 +1,5 @@ /* dtest.c - lber decoding test program */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblber/encode.c b/libraries/liblber/encode.c index 0d95239544..ef515a3369 100644 --- a/libraries/liblber/encode.c +++ b/libraries/liblber/encode.c @@ -1,4 +1,5 @@ /* encode.c - ber output encoding routines */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -619,40 +620,22 @@ ber_put_set( BerElement *ber ) /* VARARGS */ int -ber_printf -#ifdef HAVE_STDARG - ( BerElement *ber, - LDAP_CONST char *fmt, - ... ) -#else - ( va_alist ) -va_dcl -#endif +ber_printf( BerElement *ber, LDAP_CONST char *fmt, ... ) { va_list ap; -#ifndef HAVE_STDARG - BerElement *ber; - char *fmt; -#endif char *s, **ss; struct berval *bv, **bvp; int rc; ber_int_t i; ber_len_t len; -#ifdef HAVE_STDARG - va_start( ap, fmt ); -#else - va_start( ap ); - ber = va_arg( ap, BerElement * ); - fmt = va_arg( ap, char * ); -#endif - assert( ber != NULL ); assert( fmt != NULL ); assert( BER_VALID( ber ) ); + va_start( ap, fmt ); + for ( rc = 0; *fmt && rc != -1; fmt++ ) { switch ( *fmt ) { case '!': { /* hook */ diff --git a/libraries/liblber/etest.c b/libraries/liblber/etest.c index 50ac00d4bf..9d235b8554 100644 --- a/libraries/liblber/etest.c +++ b/libraries/liblber/etest.c @@ -1,166 +1,157 @@ /* test.c - lber encoding test program */ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. */ +#include "portable.h" + #include -#include -#ifdef MACOS -#include -#include -#include + +#include + +#include +#include +#include + +#ifdef HAVE_CONSOLE_H #include -#else /* MACOS */ -#include -#include -#endif /* MACOS */ +#endif /* HAVE_CONSOLE_H */ + #include "lber.h" -static usage( char *name ) +static void usage( char *name ) { fprintf( stderr, "usage: %s fmtstring\n", name ); } +static char* getbuf() { + char *p; + static char buf[128]; + + if ( fgets( buf, sizeof(buf), stdin ) == NULL ) + return NULL; + + if ( (p = strchr( buf, '\n' )) != NULL ) + *p = '\0'; + + return buf; +} + +int main( int argc, char **argv ) { - int i, num, len; - char *s, *p; - Seqorset *sos = NULLSEQORSET; + char *s; + + int fd, rc; BerElement *ber; - Sockbuf sb; - extern char *optarg; + Sockbuf *sb; + + /* enable debugging */ + int ival = -1; + ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ival ); if ( argc < 2 ) { usage( argv[0] ); - exit( 1 ); + return( EXIT_FAILURE ); } - bzero( &sb, sizeof(sb) ); - sb.sb_sd = 1; - sb.sb_ber.ber_buf = NULL; - -#ifdef MACOS +#ifdef HAVE_CONSOLE_H ccommand( &argv ); cshow( stdout ); - if (( sb.sb_sd = open( "lber-test", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY )) + if (( fd = open( "lber-test", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY )) < 0 ) { perror( "open" ); - exit( 1 ); + return( EXIT_FAILURE ); } -#endif /* MACOS */ - if ( (ber = ber_alloc()) == NULLBER ) { - perror( "ber_alloc" ); - exit( 1 ); +#else + fd = fileno(stdout); +#endif + + sb = ber_sockbuf_alloc_fd( fd ); + + if( sb == NULL ) { + perror( "ber_sockbuf_alloc_fd" ); + return( EXIT_FAILURE ); } - num = 7; - if ( ber_printf( ber, "{ti}", 0x1f44, num ) == -1 ) { - fprintf( stderr, "ber_printf returns -1" ); - exit( 1 ); + if ( (ber = ber_alloc_t( LBER_USE_DER )) == NULL ) { + perror( "ber_alloc" ); + return( EXIT_FAILURE ); } - if ( ber_flush( &sb, ber, 1 ) == -1 ) { - perror( "ber_flush" ); - exit( 1 ); + fprintf(stderr, "encode: start\n" ); + if( ber_printf( ber, "{" /*}*/ ) ) { + perror( "ber_printf {" /*}*/ ); + return( EXIT_FAILURE ); } -#ifdef notdef + for ( s = argv[1]; *s; s++ ) { - if ( fgets( buf, sizeof(buf), stdin ) == NULL ) - break; - if ( (p = strchr( buf, '\n' )) != NULL ) - *p = '\0'; + char *buf; + char fmt[2]; + fmt[0] = *s; + fmt[1] = '\0'; + + fprintf(stderr, "encode: %s\n", fmt ); switch ( *s ) { case 'i': /* int */ case 'b': /* boolean */ - i = atoi( buf ); - if ( ber_printf( ber, "i", i ) == -1 ) { - fprintf( stderr, "ber_printf i\n" ); - exit( 1 ); - } - break; - case 'e': /* enumeration */ - i = va_arg( ap, int ); - rc = ber_put_enum( ber, i, (char)ber->ber_tag ); + buf = getbuf(); + rc = ber_printf( ber, fmt, atoi(buf) ); break; case 'n': /* null */ - rc = ber_put_null( ber, (char)ber->ber_tag ); + case '{': /* begin sequence */ + case '}': /* end sequence */ + case '[': /* begin set */ + case ']': /* end set */ + rc = ber_printf( ber, fmt ); break; case 'o': /* octet string (non-null terminated) */ - s = va_arg( ap, char * ); - len = va_arg( ap, int ); - rc = ber_put_ostring( ber, s, len, (char)ber->ber_tag ); - break; - - case 's': /* string */ - s = va_arg( ap, char * ); - rc = ber_put_string( ber, s, (char)ber->ber_tag ); - break; - case 'B': /* bit string */ - s = va_arg( ap, char * ); - len = va_arg( ap, int ); /* in bits */ - rc = ber_put_bitstring( ber, s, len, (char)ber->ber_tag ); + buf = getbuf(); + rc = ber_printf( ber, fmt, buf, strlen(buf) ); break; + case 's': /* string */ case 't': /* tag for the next element */ - ber->ber_tag = va_arg( ap, int ); - ber->ber_usertag = 1; - break; - - case 'v': /* vector of strings */ - if ( (ss = va_arg( ap, char ** )) == NULL ) - break; - for ( i = 0; ss[i] != NULL; i++ ) { - if ( (rc = ber_put_string( ber, ss[i], - (char)ber->ber_tag )) == -1 ) - break; - } - break; - - case 'V': /* sequences of strings + lengths */ - if ( (bv = va_arg( ap, struct berval ** )) == NULL ) - break; - for ( i = 0; bv[i] != NULL; i++ ) { - if ( (rc = ber_put_ostring( ber, bv[i]->bv_val, - bv[i]->bv_len, (char)ber->ber_tag )) == -1 ) - break; - } - break; - - case '{': /* begin sequence */ - rc = ber_start_seq( ber, (char)ber->ber_tag ); - break; - - case '}': /* end sequence */ - rc = ber_put_seqorset( ber ); - break; - - case '[': /* begin set */ - rc = ber_start_set( ber, (char)ber->ber_tag ); - break; - - case ']': /* end set */ - rc = ber_put_seqorset( ber ); + buf = getbuf(); + rc = ber_printf( ber, fmt, buf ); break; default: -#ifndef NO_USERINTERFACE - fprintf( stderr, "unknown fmt %c\n", *fmt ); -#endif /* NO_USERINTERFACE */ + fprintf( stderr, "encode: unknown fmt %c\n", *fmt ); rc = -1; break; } + + if( rc == -1 ) { + perror( "ber_printf" ); + return( EXIT_FAILURE ); } } -#endif + fprintf(stderr, "encode: end\n" ); + if( ber_printf( ber, /*{*/ "}" ) == -1 ) { + perror( /*{*/ "ber_printf }" ); + return( EXIT_FAILURE ); + } + + if ( ber_flush( sb, ber, 1 ) == -1 ) { + perror( "ber_flush" ); + return( EXIT_FAILURE ); + } - return( 0 ); + ber_sockbuf_free( sb ); + return( EXIT_SUCCESS ); } diff --git a/libraries/liblber/idtest.c b/libraries/liblber/idtest.c index 83d8ec7ace..2bc6822971 100644 --- a/libraries/liblber/idtest.c +++ b/libraries/liblber/idtest.c @@ -1,4 +1,5 @@ /* idtest.c - ber decoding test program using isode libraries */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index 081f386794..830c16e5f0 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -1,5 +1,10 @@ /* io.c - ber general i/o routines */ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * @@ -11,211 +16,109 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#include - -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS || _WIN32 */ - -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined(NeXT) || defined(VMS) -#include -#else /* next || vms */ -#include -#endif /* next || vms */ -#include -#include -#include -#include -#ifdef PCNFS -#include -#endif /* PCNFS */ -#endif /* MACOS */ - -#ifndef VMS -#include -#endif -#include -#include "lber.h" -#ifdef _WIN32 -#include +#include + +#include +#include +#include +#include +#include + +#ifdef HAVE_IO_H #include -#endif /* _WIN32 */ - -#ifdef NEEDPROTOS -static int ber_realloc( BerElement *ber, unsigned long len ); -static int ber_filbuf( Sockbuf *sb, long len ); -static long BerRead( Sockbuf *sb, char *buf, long len ); -#ifdef PCNFS -static int BerWrite( Sockbuf *sb, char *buf, long len ); -#endif /* PCNFS */ -#else -int ber_filbuf(); -long BerRead(); -static int ber_realloc(); -#endif /* NEEDPROTOS */ - -#define bergetc( sb, len ) ( sb->sb_ber.ber_end > sb->sb_ber.ber_ptr ? \ - (unsigned char)*sb->sb_ber.ber_ptr++ : \ - ber_filbuf( sb, len )) - -#ifdef MACOS -/* - * MacTCP/OpenTransport - */ -#define read( s, b, l ) tcpread( s, 0, (unsigned char *)b, l, NULL ) -#define MAX_WRITE 65535 -#define BerWrite( sb, b, l ) tcpwrite( sb->sb_sd, (unsigned char *)(b), (lsb_sd, b, (int) l, 0 ) -#endif /* PCNFS */ -#ifdef NCSA -/* - * NCSA Telnet TCP/IP stack (under DOS) - */ -#define read( s, b, l ) nread( s, b, l ) -#define BerWrite( s, b, l ) netwrite( s->sb_sd, b, l ) -#endif /* NCSA */ -#ifdef WINSOCK -/* - * Windows Socket API (under DOS/Windows 3.x) - */ -#define read( s, b, l ) recv( s, b, l, 0 ) -#define BerWrite( s, b, l ) send( s->sb_sd, b, l, 0 ) -#endif /* WINSOCK */ -#else /* DOS */ -#ifdef _WIN32 -/* - * 32-bit Windows Socket API (under Windows NT or Windows 95) - */ -#define read( s, b, l ) recv( s, b, l, 0 ) -#define BerWrite( s, b, l ) send( s->sb_sd, b, l, 0 ) -#else /* _WIN32 */ -#ifdef VMS -/* - * VMS -- each write must be 64K or smaller - */ -#define MAX_WRITE 65535 -#define BerWrite( sb, b, l ) write( sb->sb_sd, b, (lsb_sd, b, l ) -#endif /* VMS */ -#define udp_read( sb, b, l, al ) recvfrom(sb->sb_sd, (char *)b, l, 0, \ - (struct sockaddr *)sb->sb_fromaddr, \ - (al = sizeof(struct sockaddr), &al)) -#define udp_write( sb, b, l ) sendto(sb->sb_sd, (char *)(b), l, 0, \ - (struct sockaddr *)sb->sb_useaddr, sizeof(struct sockaddr)) -#endif /* _WIN32 */ -#endif /* DOS */ -#endif /* MACOS */ - -#ifndef udp_read -#define udp_read( sb, b, l, al ) CLDAP NOT SUPPORTED -#define udp_write( sb, b, l ) CLDAP NOT SUPPORTED -#endif /* udp_read */ +#endif -#define EXBUFSIZ 1024 +#undef LDAP_F_PRE +#define LDAP_F_PRE LDAP_F_EXPORT -int -ber_filbuf( Sockbuf *sb, long len ) -{ - short rc; -#ifdef CLDAP - int addrlen; -#endif /* CLDAP */ - - if ( sb->sb_ber.ber_buf == NULL ) { - if ( (sb->sb_ber.ber_buf = (char *) malloc( READBUFSIZ )) == - NULL ) - return( -1 ); - sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf; - sb->sb_ber.ber_end = sb->sb_ber.ber_buf; - } +#include "lber-int.h" - if ( sb->sb_naddr > 0 ) { -#ifdef CLDAP - rc = udp_read(sb, sb->sb_ber.ber_buf, READBUFSIZ, addrlen ); -#ifdef LDAP_DEBUG - if ( lber_debug ) { - fprintf( stderr, "ber_filbuf udp_read %d bytes\n", - rc ); - if ( lber_debug > 1 && rc > 0 ) - lber_bprint( sb->sb_ber.ber_buf, rc ); - } -#endif /* LDAP_DEBUG */ -#else /* CLDAP */ - rc = -1; -#endif /* CLDAP */ - } else { - rc = read( sb->sb_sd, sb->sb_ber.ber_buf, - ((sb->sb_options & LBER_NO_READ_AHEAD) && - (len < READBUFSIZ)) ? - len : READBUFSIZ ); - } +static ber_slen_t BerRead LDAP_P(( + Sockbuf *sb, + char *buf, + ber_len_t len )); - if ( rc > 0 ) { - sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf + 1; - sb->sb_ber.ber_end = sb->sb_ber.ber_buf + rc; - return( (unsigned char)*sb->sb_ber.ber_buf ); - } +static int ber_realloc LDAP_P(( + BerElement *ber, + ber_len_t len )); - return( -1 ); -} +#define EXBUFSIZ 1024 +/* probably far too large... */ +#define MAX_BERBUFSIZE (128*1024) -long -BerRead( Sockbuf *sb, char *buf, long len ) +#if defined( DOS ) && !defined( _WIN32 ) && (MAX_BERBUFSIZE > 65535) +# undef MAX_BERBUFSIZE +# define MAX_BERBUFSIZE 65535 +#endif + +static ber_slen_t +BerRead( + Sockbuf *sb, + char *buf, + ber_len_t len ) { - int c; - long nread = 0; + ber_slen_t c; + ber_slen_t nread = 0; + + assert( sb != NULL ); + assert( buf != NULL ); + + assert( SOCKBUF_VALID( sb ) ); while ( len > 0 ) { - if ( (c = bergetc( sb, len )) < 0 ) { + if ( (c = ber_pvt_sb_read( sb, buf, len )) <= 0 ) { if ( nread > 0 ) break; return( c ); } - *buf++ = c; - nread++; - len--; + buf+= c; + nread+=c; + len-=c; } return( nread ); } - -long -ber_read( BerElement *ber, char *buf, unsigned long len ) +ber_slen_t +ber_read( + BerElement *ber, + char *buf, + ber_len_t len ) { - unsigned long actuallen, nleft; + ber_len_t actuallen, nleft; + + assert( ber != NULL ); + assert( buf != NULL ); + + assert( BER_VALID( ber ) ); nleft = ber->ber_end - ber->ber_ptr; actuallen = nleft < len ? nleft : len; - SAFEMEMCPY( buf, ber->ber_ptr, (size_t)actuallen ); + SAFEMEMCPY( buf, ber->ber_ptr, actuallen ); ber->ber_ptr += actuallen; - return( (long)actuallen ); + return( (ber_slen_t) actuallen ); } -long -ber_write( BerElement *ber, char *buf, unsigned long len, int nosos ) +ber_slen_t +ber_write( + BerElement *ber, + LDAP_CONST char *buf, + ber_len_t len, + int nosos ) { + assert( ber != NULL ); + assert( buf != NULL ); + + assert( BER_VALID( ber ) ); + if ( nosos || ber->ber_sos == NULL ) { if ( ber->ber_ptr + len > ber->ber_end ) { if ( ber_realloc( ber, len ) != 0 ) @@ -223,7 +126,8 @@ ber_write( BerElement *ber, char *buf, unsigned long len, int nosos ) } SAFEMEMCPY( ber->ber_ptr, buf, (size_t)len ); ber->ber_ptr += len; - return( len ); + return( (ber_slen_t) len ); + } else { if ( ber->ber_sos->sos_ptr + len > ber->ber_end ) { if ( ber_realloc( ber, len ) != 0 ) @@ -232,30 +136,35 @@ ber_write( BerElement *ber, char *buf, unsigned long len, int nosos ) SAFEMEMCPY( ber->ber_sos->sos_ptr, buf, (size_t)len ); ber->ber_sos->sos_ptr += len; ber->ber_sos->sos_clen += len; - return( len ); + return( (ber_slen_t) len ); } } static int -ber_realloc( BerElement *ber, unsigned long len ) +ber_realloc( BerElement *ber, ber_len_t len ) { - unsigned long need, have, total; + ber_len_t need, have, total; Seqorset *s; long off; char *oldbuf; + assert( ber != NULL ); + assert( len > 0 ); + + assert( BER_VALID( ber ) ); + have = (ber->ber_end - ber->ber_buf) / EXBUFSIZ; need = (len < EXBUFSIZ ? 1 : (len + (EXBUFSIZ - 1)) / EXBUFSIZ); total = have * EXBUFSIZ + need * EXBUFSIZ; oldbuf = ber->ber_buf; + ber->ber_buf = (char *) LBER_REALLOC( ber->ber_buf, total ); + if ( ber->ber_buf == NULL ) { - if ( (ber->ber_buf = (char *) malloc( (size_t)total )) == NULL ) - return( -1 ); - } else if ( (ber->ber_buf = (char *) realloc( ber->ber_buf, - (size_t)total )) == NULL ) + ber->ber_buf = oldbuf; return( -1 ); + } ber->ber_end = ber->ber_buf + total; @@ -268,7 +177,7 @@ ber_realloc( BerElement *ber, unsigned long len ) if ( ber->ber_buf != oldbuf ) { ber->ber_ptr = ber->ber_buf + (ber->ber_ptr - oldbuf); - for ( s = ber->ber_sos; s != NULLSEQORSET; s = s->sos_next ) { + for ( s = ber->ber_sos; s != NULL; s = s->sos_next ) { off = s->sos_first - oldbuf; s->sos_first = ber->ber_buf + off; @@ -283,62 +192,67 @@ ber_realloc( BerElement *ber, unsigned long len ) void ber_free( BerElement *ber, int freebuf ) { +#ifdef LDAP_MEMORY_DEBUG + assert( ber != NULL ); +#endif + + if( ber == NULL ) { + return; + } + + assert( BER_VALID( ber ) ); + if ( freebuf && ber->ber_buf != NULL ) - free( ber->ber_buf ); - free( (char *) ber ); + LBER_FREE( ber->ber_buf ); + + ber->ber_buf = NULL; + ber->ber_valid = LBER_UNINITIALIZED; + + LBER_FREE( (char *) ber ); } int ber_flush( Sockbuf *sb, BerElement *ber, int freeit ) { - long nwritten, towrite, rc; + ber_len_t nwritten, towrite; + ber_slen_t rc; + + assert( sb != NULL ); + assert( ber != NULL ); + + assert( SOCKBUF_VALID( ber ) ); + assert( BER_VALID( ber ) ); if ( ber->ber_rwptr == NULL ) { ber->ber_rwptr = ber->ber_buf; } towrite = ber->ber_ptr - ber->ber_rwptr; -#ifdef LDAP_DEBUG - if ( lber_debug ) { - fprintf( stderr, "ber_flush: %ld bytes to sd %ld%s\n", towrite, - sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)" + if ( sb->sb_debug ) { + ber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug, + "ber_flush: %ld bytes to sd %ld%s\n", towrite, + (long) sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)" : "" ); - if ( lber_debug > 1 ) - lber_bprint( ber->ber_rwptr, towrite ); + ber_log_bprint( LDAP_DEBUG_PACKETS, sb->sb_debug, + ber->ber_rwptr, towrite ); } -#endif -#if !defined(MACOS) && !defined(DOS) + +#if HAVE_WRITE if ( sb->sb_options & (LBER_TO_FILE | LBER_TO_FILE_ONLY) ) { - rc = write( sb->sb_fd, ber->ber_buf, towrite ); + rc = write( sb->sb_fd, ber->ber_rwptr, towrite ); if ( sb->sb_options & LBER_TO_FILE_ONLY ) { + if ( freeit ) + ber_free( ber, 1 ); return( (int)rc ); } } #endif - + nwritten = 0; do { - if (sb->sb_naddr > 0) { -#ifdef CLDAP - rc = udp_write( sb, ber->ber_buf + nwritten, - (size_t)towrite ); -#else /* CLDAP */ - rc = -1; -#endif /* CLDAP */ - if ( rc <= 0 ) - return( -1 ); - /* fake error if write was not atomic */ - if (rc < towrite) { -#if !defined( MACOS ) && !defined( DOS ) - errno = EMSGSIZE; -#endif - return( -1 ); - } - } else { - if ( (rc = BerWrite( sb, ber->ber_rwptr, - (size_t) towrite )) <= 0 ) { - return( -1 ); - } + rc = ber_pvt_sb_write( sb, ber->ber_rwptr, towrite ); + if (rc<=0) { + return -1; } towrite -= rc; nwritten += rc; @@ -356,118 +270,191 @@ ber_alloc_t( int options ) { BerElement *ber; - if ( (ber = (BerElement *) calloc( 1, sizeof(BerElement) )) == NULLBER ) - return( NULLBER ); + ber_int_options.lbo_valid = LBER_INITIALIZED; + + ber = (BerElement *) LBER_CALLOC( 1, sizeof(BerElement) ); + + if ( ber == NULL ) + return( NULL ); + + ber->ber_valid = LBER_VALID_BERELEMENT; ber->ber_tag = LBER_DEFAULT; ber->ber_options = options; + ber->ber_debug = ber_int_debug; + assert( BER_VALID( ber ) ); return( ber ); } BerElement * -ber_alloc() +ber_alloc( void ) /* deprecated */ { return( ber_alloc_t( 0 ) ); } BerElement * -der_alloc() +der_alloc( void ) /* deprecated */ { return( ber_alloc_t( LBER_USE_DER ) ); } BerElement * -ber_dup( BerElement *ber ) +ber_dup( LDAP_CONST BerElement *ber ) { BerElement *new; - if ( (new = ber_alloc()) == NULLBER ) - return( NULLBER ); + assert( ber != NULL ); + assert( BER_VALID( ber ) ); + + if ( (new = ber_alloc_t( ber->ber_options )) == NULL ) { + return( NULL ); + } *new = *ber; + assert( BER_VALID( new ) ); return( new ); } +/* OLD U-Mich ber_init() */ void -ber_init( BerElement *ber, int options ) +ber_init_w_nullc( BerElement *ber, int options ) { + assert( ber != NULL ); + + ber_int_options.lbo_valid = LBER_INITIALIZED; + (void) memset( (char *)ber, '\0', sizeof( BerElement )); + ber->ber_valid = LBER_VALID_BERELEMENT; ber->ber_tag = LBER_DEFAULT; - ber->ber_options = options; -} + ber->ber_options = (char) options; + ber->ber_debug = ber_int_debug; + assert( BER_VALID( ber ) ); +} -void -ber_reset( BerElement *ber, int was_writing ) +/* New C-API ber_init() */ +/* This function constructs a BerElement containing a copy +** of the data in the bv argument. +*/ +BerElement * +ber_init( struct berval *bv ) { - if ( was_writing ) { - ber->ber_end = ber->ber_ptr; - ber->ber_ptr = ber->ber_buf; - } else { - ber->ber_ptr = ber->ber_end; + BerElement *ber; + + assert( bv != NULL ); + + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if ( bv == NULL ) { + return NULL; } - ber->ber_rwptr = NULL; -} + ber = ber_alloc_t( 0 ); + if( ber == NULL ) { + /* allocation failed */ + return ( NULL ); + } -#ifdef LDAP_DEBUG + /* copy the data */ + if ( ( (ber_len_t) ber_write ( ber, bv->bv_val, bv->bv_len, 0 )) != bv->bv_len ) { + /* write failed, so free and return NULL */ + ber_free( ber, 1 ); + return( NULL ); + } -void -ber_dump( BerElement *ber, int inout ) + ber_reset( ber, 1 ); /* reset the pointer to the start of the buffer */ + + return ( ber ); +} + +/* New C-API ber_flatten routine */ +/* This routine allocates a struct berval whose contents are a BER +** encoding taken from the ber argument. The bvPtr pointer pointers to +** the returned berval. +*/ +int ber_flatten( + LDAP_CONST BerElement *ber, + struct berval **bvPtr) { - fprintf( stderr, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n", - ber->ber_buf, ber->ber_ptr, ber->ber_end ); - if ( inout == 1 ) { - fprintf( stderr, " current len %ld, contents:\n", - ber->ber_end - ber->ber_ptr ); - lber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr ); + struct berval *bv; + + assert( bvPtr != NULL ); + + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if(bvPtr == NULL) { + return( -1 ); + } + + if ( (bv = LBER_MALLOC( sizeof(struct berval))) == NULL ) { + return( -1 ); + } + + if ( ber == NULL ) { + /* ber is null, create an empty berval */ + bv->bv_val = NULL; + bv->bv_len = 0; + } else { - fprintf( stderr, " current len %ld, contents:\n", - ber->ber_ptr - ber->ber_buf ); - lber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf ); + /* copy the berval */ + ber_len_t len = ber->ber_ptr - ber->ber_buf; + + if ( (bv->bv_val = (char *) LBER_MALLOC( len + 1 )) == NULL ) { + ber_bvfree( bv ); + return( -1 ); + } + + SAFEMEMCPY( bv->bv_val, ber->ber_buf, len ); + bv->bv_val[len] = '\0'; + bv->bv_len = len; } + + *bvPtr = bv; + return( 0 ); } void -ber_sos_dump( Seqorset *sos ) +ber_reset( BerElement *ber, int was_writing ) { - fprintf( stderr, "*** sos dump ***\n" ); - while ( sos != NULLSEQORSET ) { - fprintf( stderr, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n", - sos->sos_clen, sos->sos_first, sos->sos_ptr ); - fprintf( stderr, " current len %ld contents:\n", - sos->sos_ptr - sos->sos_first ); - lber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first ); - - sos = sos->sos_next; + assert( ber != NULL ); + assert( BER_VALID( ber ) ); + + if ( was_writing ) { + ber->ber_end = ber->ber_ptr; + ber->ber_ptr = ber->ber_buf; + } else { + ber->ber_ptr = ber->ber_end; } - fprintf( stderr, "*** end dump ***\n" ); -} -#endif + ber->ber_rwptr = NULL; +} +#if 0 /* return the tag - LBER_DEFAULT returned means trouble */ -static unsigned long +static ber_tag_t get_tag( Sockbuf *sb ) { unsigned char xbyte; - unsigned long tag; + ber_tag_t tag; char *tagp; - int i; + unsigned int i; + + assert( sb != NULL ); + assert( SOCKBUF_VALID( sb ) ); - if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 ) + if ( ber_pvt_sb_read( sb, (char *) &xbyte, 1 ) != 1 ) return( LBER_DEFAULT ); if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK ) - return( (unsigned long) xbyte ); + return( (ber_tag_t) xbyte ); tagp = (char *) &tag; tagp[0] = xbyte; - for ( i = 1; i < sizeof(long); i++ ) { - if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 ) + for ( i = 1; i < sizeof(ber_tag_t); i++ ) { + if ( ber_pvt_sb_read( sb, (char *) &xbyte, 1 ) != 1 ) return( LBER_DEFAULT ); tagp[i] = xbyte; @@ -477,25 +464,35 @@ get_tag( Sockbuf *sb ) } /* tag too big! */ - if ( i == sizeof(long) ) + if ( i == sizeof(ber_tag_t) ) return( LBER_DEFAULT ); /* want leading, not trailing 0's */ - return( tag >> (sizeof(long) - i - 1) ); + return( tag >> (sizeof(ber_tag_t) - i - 1) ); } +#endif -unsigned long -ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) +/* + * A rewrite of ber_get_next that can safely be called multiple times + * for the same packet. It will simply continue were it stopped until + * a full packet is read. + */ + +ber_tag_t +ber_get_next( + Sockbuf *sb, + ber_len_t *len, + BerElement *ber ) { - unsigned long tag, netlen, toread; - unsigned char lc; - long rc; - int noctets, diff; - -#ifdef LDAP_DEBUG - if ( lber_debug ) - fprintf( stderr, "ber_get_next\n" ); -#endif + assert( sb != NULL ); + assert( len != NULL ); + assert( ber != NULL ); + + assert( SOCKBUF_VALID( sb ) ); + assert( BER_VALID( ber ) ); + + ber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug, + "ber_get_next\n" ); /* * Any ber element looks like this: tag length contents. @@ -508,94 +505,132 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) * 2) definite lengths * 3) primitive encodings used whenever possible */ - - /* - * first time through - malloc the buffer, set up ptrs, and - * read the tag and the length and as much of the rest as we can - */ - - if ( ber->ber_rwptr == NULL ) { - /* - * First, we read the tag. - */ - - if ( (tag = get_tag( sb )) == LBER_DEFAULT ) { - return( LBER_DEFAULT ); - } - ber->ber_tag = tag; - - /* - * Next, read the length. The first byte contains the length - * of the length. If bit 8 is set, the length is the long - * form, otherwise it's the short form. We don't allow a - * length that's greater than what we can hold in an unsigned - * long. + + if (ber->ber_rwptr == NULL) { + /* XXYYZ + * dtest does like this assert. */ + /* assert( ber->ber_buf == NULL ); */ + ber->ber_rwptr = (char *) &ber->ber_tag; + ber->ber_tag = 0; + } - *len = netlen = 0; - if ( BerRead( sb, (char *) &lc, 1 ) != 1 ) { - return( LBER_DEFAULT ); +#define PTR_IN_VAR( ptr, var )\ +(((ptr)>=(char *) &(var)) && ((ptr)< (char *) &(var)+sizeof(var))) + + if (PTR_IN_VAR(ber->ber_rwptr, ber->ber_tag)) { + if (ber->ber_rwptr == (char *) &ber->ber_tag) { + if (ber_pvt_sb_read( sb, ber->ber_rwptr, 1)<=0) + return LBER_DEFAULT; + if ((ber->ber_rwptr[0] & LBER_BIG_TAG_MASK) + != LBER_BIG_TAG_MASK) { + ber->ber_tag = ber->ber_rwptr[0]; + ber->ber_rwptr = (char *) &ber->ber_usertag; + goto get_lenbyte; + } + ber->ber_rwptr++; } - if ( lc & 0x80 ) { - noctets = (lc & 0x7f); - if ( noctets > sizeof(unsigned long) ) - return( LBER_DEFAULT ); - diff = sizeof(unsigned long) - noctets; - if ( BerRead( sb, (char *) &netlen + diff, noctets ) != - noctets ) { - return( LBER_DEFAULT ); + do { + /* reading the tag... */ + if (ber_pvt_sb_read( sb, ber->ber_rwptr, 1)<=0) + return LBER_DEFAULT; + if (! (ber->ber_rwptr[0] & LBER_MORE_TAG_MASK) ) { + ber->ber_tag>>=sizeof(ber->ber_tag) - + ((char *) &ber->ber_tag - ber->ber_rwptr); + ber->ber_rwptr = (char *) &ber->ber_usertag; + goto get_lenbyte; + } + } while (PTR_IN_VAR(ber->ber_rwptr,ber->ber_tag)); + errno = ERANGE; /* this is a serious error. */ + return LBER_DEFAULT; + } +get_lenbyte: + if (ber->ber_rwptr==(char *) &ber->ber_usertag) { + unsigned char c; + if (ber_pvt_sb_read( sb, (char *) &c, 1)<=0) + return LBER_DEFAULT; + if (c & 0x80U) { + int len = c & 0x7fU; + if ( (len==0) || ( len>sizeof( ber->ber_len ) ) ) { + errno = ERANGE; + return LBER_DEFAULT; } - *len = LBER_NTOHL( netlen ); + ber->ber_rwptr = (char *) &ber->ber_len + + sizeof(ber->ber_len) - len; + ber->ber_len = 0; } else { - *len = lc; - } - ber->ber_len = *len; - - /* - * Finally, malloc a buffer for the contents and read it in. - * It's this buffer that's passed to all the other ber decoding - * routines. - */ - -#if defined( DOS ) && !defined( _WIN32 ) - if ( *len > 65535 ) { /* DOS can't allocate > 64K */ - return( LBER_DEFAULT ); + ber->ber_len = c; + goto fill_buffer; } -#endif /* DOS && !_WIN32 */ - - if ( ( sb->sb_options & LBER_MAX_INCOMING_SIZE ) && - *len > sb->sb_max_incoming ) { - return( LBER_DEFAULT ); + } + if (PTR_IN_VAR(ber->ber_rwptr, ber->ber_len)) { + ber_slen_t res; + ber_slen_t to_go; + to_go = (char *) &ber->ber_len + sizeof( ber->ber_len ) - + ber->ber_rwptr; + assert( to_go > 0 ); + res = ber_pvt_sb_read( sb, ber->ber_rwptr, to_go ); + if (res <=0) + return LBER_DEFAULT; + ber->ber_rwptr += res; + if (res==to_go) { + /* convert length. */ + ber->ber_len = LBER_LEN_NTOH( ber->ber_len ); + goto fill_buffer; + } else { +#if defined( EWOULDBLOCK ) + errno = EWOULDBLOCK; +#elif defined( EAGAIN ) + errno = EAGAIN; +#endif + return LBER_DEFAULT; } - - if ( (ber->ber_buf = (char *) malloc( (size_t)*len )) == NULL ) { - return( LBER_DEFAULT ); + } +fill_buffer: + /* now fill the buffer. */ + if (ber->ber_buf==NULL) { + if (ber->ber_len > MAX_BERBUFSIZE) { + errno = ERANGE; + return LBER_DEFAULT; } - ber->ber_ptr = ber->ber_buf; - ber->ber_end = ber->ber_buf + *len; + ber->ber_buf = (char *) LBER_MALLOC( ber->ber_len ); + if (ber->ber_buf==NULL) + return LBER_DEFAULT; ber->ber_rwptr = ber->ber_buf; + ber->ber_ptr = ber->ber_buf; + ber->ber_end = ber->ber_buf + ber->ber_len; } - - toread = (unsigned long)ber->ber_end - (unsigned long)ber->ber_rwptr; - do { - if ( (rc = BerRead( sb, ber->ber_rwptr, (long)toread )) <= 0 ) { - return( LBER_DEFAULT ); + if ((ber->ber_rwptr>=ber->ber_buf) && (ber->ber_rwptrber_end)) { + ber_slen_t res; + ber_slen_t to_go; + + to_go = ber->ber_end - ber->ber_rwptr; + assert( to_go > 0 ); + + res = ber_pvt_sb_read( sb, ber->ber_rwptr, to_go ); + if (res<=0) + return LBER_DEFAULT; + ber->ber_rwptr+=res; + + if (resber_rwptr += rc; - } while ( toread > 0 ); - -#ifdef LDAP_DEBUG - if ( lber_debug ) { - fprintf( stderr, "ber_get_next: tag 0x%lx len %ld contents:\n", - tag, ber->ber_len ); - if ( lber_debug > 1 ) - ber_dump( ber, 1 ); + + ber->ber_rwptr = NULL; + *len = ber->ber_len; + if ( ber->ber_debug ) { + ber_log_printf( LDAP_DEBUG_TRACE, ber->ber_debug, + "ber_get_next: tag 0x%lx len %ld contents:\n", + ber->ber_tag, ber->ber_len ); + ber_log_dump( LDAP_DEBUG_BER, ber->ber_debug, ber, 1 ); + } + return (ber->ber_tag); } -#endif - - *len = ber->ber_len; - ber->ber_rwptr = NULL; - return( ber->ber_tag ); + assert( 0 ); /* ber structure is messed up ?*/ + return LBER_DEFAULT; } diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h index c1a8675eba..7d080349f5 100644 --- a/libraries/liblber/lber-int.h +++ b/libraries/liblber/lber-int.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblber/memory.c b/libraries/liblber/memory.c new file mode 100644 index 0000000000..604e8ccc94 --- /dev/null +++ b/libraries/liblber/memory.c @@ -0,0 +1,320 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +#include "portable.h" + +#include +#include + +#undef LDAP_F_PRE +#define LDAP_F_PRE LDAP_F_EXPORT + +#include "lber-int.h" + +#if LDAP_MEMORY_DEBUG +struct ber_mem_hdr { + union bmu_align_u { + ber_len_t bmu_len_t; + ber_tag_t bmu_tag_t; + ber_int_t bmu_int_t; + + size_t bmu_size_t; + void * bmu_voidp; + double bmu_double; + long bmu_long; + long (*bmu_funcp)( double ); + char bmu_char[4]; + } ber_align; +#define bm_junk ber_align.bmu_len_t +#define bm_data ber_align.bmu_char[1] +}; +#define BER_MEM_JUNK 0xddeeddeeU +static const struct ber_mem_hdr ber_int_mem_hdr = { BER_MEM_JUNK }; +#define BER_MEM_BADADDR ((void *) &ber_int_mem_hdr.bm_data) +#define BER_MEM_VALID(p) do { \ + assert( (p) != BER_MEM_BADADDR ); \ + assert( (p) != (void *) &ber_int_mem_hdr ); \ + } while(0) +#else +#define BER_MEM_VALID(p) /* no-op */ +#endif + +BerMemoryFunctions *ber_int_memory_fns = NULL; + +#if 0 && defined( LDAP_MEMORY_DEBUG ) +void +ber_int_memfree( void **p ) +{ + assert( p != NULL ); + BER_MEM_VALID( *p ); + + ber_memfree( p ); + + *p = BER_MEM_BADADDR; +} +#endif + +void +ber_memfree( void *p ) +{ + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if( p == NULL ) { + return; + } + + BER_MEM_VALID( p ); + + if( ber_int_memory_fns == NULL ) { +#ifdef LDAP_MEMORY_DEBUG + struct ber_mem_hdr *mh = (struct ber_mem_hdr *) + ((char *)p - sizeof(struct ber_mem_hdr)); + + assert( mh->bm_junk == BER_MEM_JUNK ); + mh->bm_junk = ~BER_MEM_JUNK; + free( mh ); +#else + free( p ); +#endif + return; + } + + assert( ber_int_memory_fns->bmf_free ); + + + (*ber_int_memory_fns->bmf_free)( p ); +} + + +void +ber_memvfree( void **vec ) +{ + int i; + + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if( vec == NULL ) { + return; + } + + BER_MEM_VALID( vec ); + + for ( i = 0; vec[i] != NULL; i++ ) { + LBER_FREE( vec[i] ); + } + + LBER_FREE( vec ); +} + + +void * +ber_memalloc( ber_len_t s ) +{ + ber_int_options.lbo_valid = LBER_INITIALIZED; + +#ifdef LDAP_MEMORY_DEBUG + assert( s != 0 ); +#endif + + if( s == 0 ) { + return NULL; + } + + if( ber_int_memory_fns == NULL ) { +#ifdef LDAP_MEMORY_DEBUG + struct ber_mem_hdr *mh = malloc(s + sizeof(struct ber_mem_hdr)); + + if( mh == NULL ) return NULL; + + mh->bm_junk = BER_MEM_JUNK; + + BER_MEM_VALID( &mh[1] ); + return &mh[1]; +#else + return malloc( s ); +#endif + } + + assert( ber_int_memory_fns->bmf_malloc ); + + return (*ber_int_memory_fns->bmf_malloc)( s ); +} + + +void * +ber_memcalloc( ber_len_t n, ber_len_t s ) +{ + ber_int_options.lbo_valid = LBER_INITIALIZED; + +#ifdef LDAP_MEMORY_DEBUG + assert( n != 0 && s != 0); +#endif + + if( n == 0 || s == 0 ) { + return NULL; + } + + if( ber_int_memory_fns == NULL ) { +#ifdef LDAP_MEMORY_DEBUG + struct ber_mem_hdr *mh = calloc(1, + (n * s) + sizeof(struct ber_mem_hdr) ); + + mh->bm_junk = BER_MEM_JUNK; + + BER_MEM_VALID( &mh[1] ); + return &mh[1]; +#else + return calloc( n, s ); +#endif + } + + assert( ber_int_memory_fns->bmf_calloc ); + + return (*ber_int_memory_fns->bmf_calloc)( n, s ); +} + + +void * +ber_memrealloc( void* p, ber_len_t s ) +{ + ber_int_options.lbo_valid = LBER_INITIALIZED; + + /* realloc(NULL,s) -> malloc(s) */ + if( p == NULL ) { + return ber_memalloc( s ); + } + + /* realloc(p,0) -> free(p) */ + if( s == 0 ) { + ber_memfree( p ); + return NULL; + } + + BER_MEM_VALID( p ); + + if( ber_int_memory_fns == NULL ) { +#ifdef LDAP_MEMORY_DEBUG + struct ber_mem_hdr *mh = (struct ber_mem_hdr *) + ((char *)p - sizeof(struct ber_mem_hdr)); + assert( mh->bm_junk == BER_MEM_JUNK ); + + p = realloc( mh, s + sizeof(struct ber_mem_hdr) ); + + if( p == NULL ) return NULL; + + mh = p; + + assert( mh->bm_junk == BER_MEM_JUNK ); + + BER_MEM_VALID( &mh[1] ); + return &mh[1]; +#else + return realloc( p, s ); +#endif + } + + assert( ber_int_memory_fns->bmf_realloc ); + + return (*ber_int_memory_fns->bmf_realloc)( p, s ); +} + + +void +ber_bvfree( struct berval *bv ) +{ + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if( bv == NULL ) { + return; + } + + BER_MEM_VALID( bv ); + + if ( bv->bv_val != NULL ) + LBER_FREE( bv->bv_val ); + + LBER_FREE( (char *) bv ); +} + + +void +ber_bvecfree( struct berval **bv ) +{ + int i; + + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if( bv == NULL ) { + return; + } + + BER_MEM_VALID( bv ); + + for ( i = 0; bv[i] != NULL; i++ ) + ber_bvfree( bv[i] ); + + LBER_FREE( (char *) bv ); +} + + +struct berval * +ber_bvdup( + LDAP_CONST struct berval *bv ) +{ + struct berval *new; + + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if( bv == NULL ) { + return NULL; + } + + if(( new = LBER_MALLOC( sizeof(struct berval) )) == NULL ) { + return NULL; + } + + if ( bv->bv_val == NULL ) { + new->bv_val = NULL; + new->bv_len = 0; + return new; + } + + if(( new->bv_val = LBER_MALLOC( bv->bv_len + 1 )) == NULL ) { + LBER_FREE( new ); + return NULL; + } + + SAFEMEMCPY( new->bv_val, bv->bv_val, bv->bv_len ); + new->bv_val[bv->bv_len] = '\0'; + new->bv_len = bv->bv_len; + + return( new ); +} + +char * +ber_strdup( LDAP_CONST char *s ) +{ + char *p; + size_t len; + + ber_int_options.lbo_valid = LBER_INITIALIZED; + +#ifdef LDAP_MEMORY_DEBUG + assert(s != NULL); /* bv damn better point to something */ +#endif + + if( s == NULL ) { + return( NULL ); + } + + len = strlen( s ) + 1; + + if ( (p = LBER_MALLOC( len )) == NULL ) { + return( NULL ); + } + + SAFEMEMCPY( p, s, len ); + return( p ); +} diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c new file mode 100644 index 0000000000..4ffea28b1d --- /dev/null +++ b/libraries/liblber/options.c @@ -0,0 +1,143 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +#include "portable.h" + +#include +#include + +#undef LDAP_F_PRE +#define LDAP_F_PRE LDAP_F_EXPORT + +#include "lber-int.h" + +struct lber_options ber_int_options = { + LBER_UNINITIALIZED, 0, 0 }; + +int +ber_get_option( + LDAP_CONST void *item, + int option, + void *outvalue) +{ + LDAP_CONST BerElement *ber; + LDAP_CONST Sockbuf *sb; + + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if(outvalue == NULL) { + /* no place to get to */ + return LBER_OPT_ERROR; + } + + if(item == NULL) { + if(option == LBER_OPT_BER_DEBUG) { + * (int *) outvalue = ber_int_debug; + return LBER_OPT_SUCCESS; + } + + return LBER_OPT_ERROR; + } + + ber = item; + sb = item; + + switch(option) { + case LBER_OPT_BER_OPTIONS: + assert( BER_VALID( ber ) ); + * (int *) outvalue = ber->ber_options; + return LBER_OPT_SUCCESS; + + case LBER_OPT_BER_DEBUG: + assert( BER_VALID( ber ) ); + * (int *) outvalue = ber->ber_debug; + return LBER_OPT_SUCCESS; + + default: + /* bad param */ + break; + } + + return LBER_OPT_ERROR; +} + +int +ber_set_option( + void *item, + int option, + LDAP_CONST void *invalue) +{ + BerElement *ber; + Sockbuf *sb; + + if( (ber_int_options.lbo_valid == LBER_UNINITIALIZED) + && ( ber_int_memory_fns == NULL ) + && ( option == LBER_OPT_MEMORY_FNS ) + && ( 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 )) + { + return LBER_OPT_ERROR; + } + + ber_int_memory_fns = (BerMemoryFunctions *) + (*(f->bmf_malloc))(sizeof(BerMemoryFunctions)); + + if ( ber_int_memory_fns == NULL ) { + return LBER_OPT_ERROR; + } + + memcpy(ber_int_memory_fns, f, sizeof(BerMemoryFunctions)); + + ber_int_options.lbo_valid = LBER_INITIALIZED; + return LBER_OPT_SUCCESS; + } + + ber_int_options.lbo_valid = LBER_INITIALIZED; + + if(invalue == NULL) { + /* no place to set from */ + return LBER_OPT_ERROR; + } + + if(item == NULL) { + if(option == LBER_OPT_BER_DEBUG) { + ber_int_debug = * (const int *) invalue; + return LBER_OPT_SUCCESS; + + } else if(option == LBER_OPT_LOG_PRINT_FN) { + ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue; + return LBER_OPT_SUCCESS; + } + + return LBER_OPT_ERROR; + } + + ber = item; + sb = item; + + switch(option) { + case LBER_OPT_BER_OPTIONS: + assert( BER_VALID( ber ) ); + ber->ber_options = * (const int *) invalue; + return LBER_OPT_SUCCESS; + + case LBER_OPT_BER_DEBUG: + assert( BER_VALID( ber ) ); + ber->ber_debug = * (const int *) invalue; + return LBER_OPT_SUCCESS; + + default: + /* bad param */ + break; + } + + return LBER_OPT_ERROR; +} diff --git a/libraries/liblber/sockbuf.c b/libraries/liblber/sockbuf.c index 52b3204081..30bceb6bed 100644 --- a/libraries/liblber/sockbuf.c +++ b/libraries/liblber/sockbuf.c @@ -1,4 +1,5 @@ /* sockbuf.c - i/o routines with support for adding i/o layers. */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -104,7 +105,7 @@ status_is_ok( Sockbuf *sb ) #ifdef USE_SASL static ber_len_t -packet_length( char *buf ) +packet_length( Sockbuf *sb, const char *buf ) { ber_len_t size; @@ -115,11 +116,11 @@ packet_length( char *buf ) (((ber_len_t)buf[2])<<8)| (((ber_len_t)buf[3])); - if ((size<0) || (size>MAX_BUF_SIZE)) { + if ( size > MAX_BUF_SIZE ) { /* somebody is trying to mess me up. */ - lber_log_printf( LDAP_DEBUG_SASL, sb->sb_debug, - "SASL: received packet length of %d bytes\n", - size ); + ber_log_printf( LDAP_DEBUG_SASL, sb->sb_debug, + "SASL: received packet length of %lu bytes\n", + (unsigned long) size ); size = 16; /* this should lead to an error. */ } @@ -228,7 +229,7 @@ sockbuf_sec_release( Sockbuf *sb, char *buf, ber_len_t len ) ptr+=size; if (ptr+4<=end) - size = packet_length( ptr ); + size = packet_length( sb, ptr ); /* size is always at least 4, so the loop condition is always OK !!*/ assert( size>=4 ); @@ -444,14 +445,14 @@ ber_pvt_sb_read( Sockbuf *sb, void *buf_arg, ber_len_t len ) } /* calculate the packet length. */ sb->sb_sec_buf_in.buf_end = - packet_length(sb->sb_sec_buf_in.buf_base ); + packet_length(sb, sb->sb_sec_buf_in.buf_base ); if ((sb->sb_sec_buf_in.buf_end > sb->sb_sec_buf_in.buf_size) && (grow_buffer( &(sb->sb_sec_buf_in), sb->sb_sec_buf_in.buf_end)<0)) { /* buffer has to be to big. exit with error. */ ret = -1; goto do_return; } - if (sb->sb_sec_buf_in.buf_ptr >= sb_sec_buf_in.buf_end) { + if (sb->sb_sec_buf_in.buf_ptr >= sb->sb_sec_buf_in.buf_end) { /* finished packet. decode it. */ goto decode_packet; } @@ -531,6 +532,7 @@ do_return: long sockbuf_do_write( Sockbuf *sb ) { long to_go; + ber_slen_t ret; assert( sb != NULL ); assert( SOCKBUF_VALID( sb ) ); @@ -782,10 +784,10 @@ int ber_pvt_sb_set_sec( Sockbuf *sb, Sockbuf_Sec * sec, void *arg ) memcpy( sb->sb_sec_buf_in.buf_base, sb->sb_buf.buf_base + sb->sb_buf.buf_ptr, len ); sb->sb_sec_buf_in.buf_ptr = len; - sb->sb_sec_buf_in.buf_end = (len>4) ? packet_length( sb->sb_sec_buf_in ) : 0; + sb->sb_sec_buf_in.buf_end = (len>4) ? packet_length( sb, sb->sb_sec_buf_in ) : 0; sb->sb_buf.buf_ptr = sb->sb_buf.buf_end = 0; } - update_status(); + update_status( sb ); return 0; } @@ -1026,8 +1028,8 @@ dgram_read( Sockbuf *sb, void *buf, ber_len_t len ) if ( sb->sb_debug ) { ber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug, - "dgram_read udp_read %d bytes\n", - rc ); + "dgram_read udp_read %ld bytes\n", + (long) rc ); if ( rc > 0 ) ber_log_bprint( LDAP_DEBUG_PACKETS, sb->sb_debug, buf, rc ); diff --git a/libraries/libldap/Makefile.in b/libraries/libldap/Makefile.in index 2603785cea..1ee85ec934 100644 --- a/libraries/libldap/Makefile.in +++ b/libraries/libldap/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file ## @@ -16,7 +17,7 @@ SRCS = bind.c open.c result.c error.c compare.c search.c \ getdn.c getentry.c getattr.c getvalues.c addentry.c \ request.c getdxbyname.c os-ip.c url.c charset.c \ init.c options.c print.c string.c util-int.c schema.c \ - charray.c digest.c tls.c + charray.c digest.c tls.c dn.c OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \ controls.lo messages.lo references.lo extended.lo \ modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \ @@ -25,7 +26,7 @@ OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \ getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \ request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \ init.lo options.lo print.lo string.lo util-int.lo schema.lo \ - charray.lo digest.lo tls.lo + charray.lo digest.lo tls.lo dn.lo LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries diff --git a/libraries/libldap/abandon.c b/libraries/libldap/abandon.c index 18324260bd..0541dd93cc 100644 --- a/libraries/libldap/abandon.c +++ b/libraries/libldap/abandon.c @@ -1,43 +1,69 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * abandon.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +/* + * An abandon request looks like this: + * AbandonRequest ::= MessageID + */ + +#include "portable.h" #include -#include - -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#endif /* DOS */ +#include -#ifdef MACOS -#include -#include "macos.h" -#endif /* MACOS */ +#include +#include +#include -#include "lber.h" -#include "ldap.h" #include "ldap-int.h" -#ifdef NEEDPROTOS -static int do_abandon( LDAP *ld, int origid, int msgid ); -#else /* NEEDPROTOS */ -static int do_abandon(); -#endif /* NEEDPROTOS */ +static int do_abandon LDAP_P(( + LDAP *ld, + ber_int_t origid, + ber_int_t msgid, + LDAPControl **sctrls, + LDAPControl **cctrls)); + /* - * ldap_abandon - perform an ldap (and X.500) abandon operation. Parameters: + * ldap_abandon_ext - perform an ldap extended abandon operation. + * + * Parameters: + * ld LDAP descriptor + * msgid The message id of the operation to abandon + * scntrls Server Controls + * ccntrls Client Controls + * + * ldap_abandon_ext returns a LDAP error code. + * (LDAP_SUCCESS if everything went ok) + * + * Example: + * ldap_abandon_ext( ld, msgid, scntrls, ccntrls ); + */ +int +ldap_abandon_ext( + LDAP *ld, + int msgid, + LDAPControl **sctrls, + LDAPControl **cctrls ) +{ + Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 ); + + return do_abandon( ld, msgid, msgid, sctrls, cctrls ); +} + + +/* + * ldap_abandon - perform an ldap abandon operation. Parameters: * * ld LDAP descriptor * msgid The message id of the operation to abandon @@ -51,38 +77,38 @@ int ldap_abandon( LDAP *ld, int msgid ) { Debug( LDAP_DEBUG_TRACE, "ldap_abandon %d\n", msgid, 0, 0 ); - return( do_abandon( ld, msgid, msgid )); + return do_abandon( ld, msgid, msgid, NULL, NULL ) == LDAP_SUCCESS + ? 0 : -1; } static int -do_abandon( LDAP *ld, int origid, int msgid ) +do_abandon( + LDAP *ld, + ber_int_t origid, + ber_int_t msgid, + LDAPControl **sctrls, + LDAPControl **cctrls) { BerElement *ber; int i, err, sendabandon; + ber_int_t *old_abandon; Sockbuf *sb; -#ifdef LDAP_REFERRALS LDAPRequest *lr; -#endif /* LDAP_REFERRALS */ - - /* - * An abandon request looks like this: - * AbandonRequest ::= MessageID - */ Debug( LDAP_DEBUG_TRACE, "do_abandon origid %d, msgid %d\n", origid, msgid, 0 ); sendabandon = 1; -#ifdef LDAP_REFERRALS /* find the request that we are abandoning */ for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { if ( lr->lr_msgid == msgid ) { /* this message */ break; } - if ( lr->lr_origid == msgid ) { /* child: abandon it */ - do_abandon( ld, msgid, lr->lr_msgid ); + if ( lr->lr_origid == msgid ) {/* child: abandon it */ + (void) do_abandon( ld, + msgid, lr->lr_msgid, sctrls, cctrls ); } } @@ -90,54 +116,73 @@ do_abandon( LDAP *ld, int origid, int msgid ) if ( origid == msgid && lr->lr_parent != NULL ) { /* don't let caller abandon child requests! */ ld->ld_errno = LDAP_PARAM_ERROR; - return( -1 ); + return( LDAP_PARAM_ERROR ); } if ( lr->lr_status != LDAP_REQST_INPROGRESS ) { /* no need to send abandon message */ sendabandon = 0; } } -#endif /* LDAP_REFERRALS */ if ( ldap_msgdelete( ld, msgid ) == 0 ) { ld->ld_errno = LDAP_SUCCESS; - return( 0 ); + return LDAP_SUCCESS; } err = 0; if ( sendabandon ) { /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { err = -1; ld->ld_errno = LDAP_NO_MEMORY; + } else { -#ifdef CLDAP - if ( ld->ld_sb.sb_naddr > 0 ) { - err = ber_printf( ber, "{isti}", +#ifdef LDAP_CONNECTIONLESS + if ( ld->ld_cldapnaddr > 0 ) { + err = ber_printf( ber, "{isti", /* '}' */ ++ld->ld_msgid, ld->ld_cldapdn, LDAP_REQ_ABANDON, msgid ); - } else { -#endif /* CLDAP */ - err = ber_printf( ber, "{iti}", ++ld->ld_msgid, + } else +#endif /* LDAP_CONNECTIONLESS */ + { + err = ber_printf( ber, "{iti", /* '}' */ + ++ld->ld_msgid, LDAP_REQ_ABANDON, msgid ); -#ifdef CLDAP } -#endif /* CLDAP */ - if ( err == -1 ) { + if( err == -1 ) { + /* encoding error */ ld->ld_errno = LDAP_ENCODING_ERROR; + + } else { + /* Put Server Controls */ + if ( ldap_int_put_controls( ld, sctrls, ber ) + != LDAP_SUCCESS ) + { + err = -1; + + } else { + /* close '{' */ + err = ber_printf( ber, /*{*/ "}" ); + + if( err == -1 ) { + /* encoding error */ + ld->ld_errno = LDAP_ENCODING_ERROR; + } + } + } + + if ( err == -1 ) { ber_free( ber, 1 ); + } else { /* send the message */ -#ifdef LDAP_REFERRALS if ( lr != NULL ) { sb = lr->lr_conn->lconn_sb; } else { sb = &ld->ld_sb; } -#else /* LDAP_REFERRALS */ - sb = &ld->ld_sb; -#endif /* LDAP_REFERRALS */ + if ( ber_flush( sb, ber, 1 ) != 0 ) { ld->ld_errno = LDAP_SERVER_DOWN; err = -1; @@ -148,39 +193,38 @@ do_abandon( LDAP *ld, int origid, int msgid ) } } -#ifdef LDAP_REFERRALS if ( lr != NULL ) { if ( sendabandon ) { - free_connection( ld, lr->lr_conn, 0, 1 ); + ldap_free_connection( ld, lr->lr_conn, 0, 1 ); } if ( origid == msgid ) { - free_request( ld, lr ); + ldap_free_request( ld, lr ); } } -#endif /* LDAP_REFERRALS */ + i = 0; + if ( ld->ld_abandoned != NULL ) { + for ( ; ld->ld_abandoned[i] != -1; i++ ) + ; /* NULL */ + } + + old_abandon = ld->ld_abandoned; + ld->ld_abandoned = (ber_int_t *) LDAP_REALLOC( (char *) + ld->ld_abandoned, (i + 2) * sizeof(ber_int_t) ); + if ( ld->ld_abandoned == NULL ) { - if ( (ld->ld_abandoned = (int *) malloc( 2 * sizeof(int) )) - == NULL ) { - ld->ld_errno = LDAP_NO_MEMORY; - return( -1 ); - } - i = 0; - } else { - for ( i = 0; ld->ld_abandoned[i] != -1; i++ ) - ; /* NULL */ - if ( (ld->ld_abandoned = (int *) realloc( (char *) - ld->ld_abandoned, (i + 2) * sizeof(int) )) == NULL ) { - ld->ld_errno = LDAP_NO_MEMORY; - return( -1 ); - } + ld->ld_abandoned = old_abandon; + ld->ld_errno = LDAP_NO_MEMORY; + return( ld->ld_errno ); } + ld->ld_abandoned[i] = msgid; ld->ld_abandoned[i + 1] = -1; if ( err != -1 ) { ld->ld_errno = LDAP_SUCCESS; } - return( err ); + + return( ld->ld_errno ); } diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index b79cd09b9d..aa69653572 100644 --- a/libraries/libldap/add.c +++ b/libraries/libldap/add.c @@ -1,37 +1,38 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * add.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif - -#include -#include +/* + * An add request looks like this: + * AddRequest ::= SEQUENCE { + * entry DistinguishedName, + * attrs SEQUENCE OF SEQUENCE { + * type AttributeType, + * values SET OF AttributeValue + * } + * } + */ -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ +#include "portable.h" -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#endif /* DOS */ +#include -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif /* !MACOS && !DOS */ +#include +#include +#include -#include "lber.h" -#include "ldap.h" #include "ldap-int.h" /* - * ldap_add - initiate an ldap (and X.500) add operation. Parameters: + * ldap_add - initiate an ldap add operation. Parameters: * * ld LDAP descriptor * dn DN of the entry to add @@ -50,34 +51,73 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of * msgid = ldap_add( ld, dn, attrs ); */ int -ldap_add( LDAP *ld, char *dn, LDAPMod **attrs ) +ldap_add( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs ) +{ + int rc; + int msgid; + + rc = ldap_add_ext( ld, dn, attrs, NULL, NULL, &msgid ); + + if ( rc != LDAP_SUCCESS ) + return -1; + + return msgid; +} + + +/* + * ldap_add_ext - initiate an ldap extended add operation. Parameters: + * + * ld LDAP descriptor + * dn DN of the entry to add + * mods List of attributes for the entry. This is a null- + * terminated array of pointers to LDAPMod structures. + * only the type and values in the structures need be + * filled in. + * sctrl Server Controls + * cctrl Client Controls + * msgidp Message ID pointer + * + * Example: + * LDAPMod *attrs[] = { + * { 0, "cn", { "babs jensen", "babs", 0 } }, + * { 0, "sn", { "jensen", 0 } }, + * { 0, "objectClass", { "person", 0 } }, + * 0 + * } + * rc = ldap_add_ext( ld, dn, attrs, NULL, NULL, &msgid ); + */ +int +ldap_add_ext( + LDAP *ld, + LDAP_CONST char *dn, + LDAPMod **attrs, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp ) { BerElement *ber; int i, rc; - /* - * An add request looks like this: - * AddRequest ::= SEQUENCE { - * entry DistinguishedName, - * attrs SEQUENCE OF SEQUENCE { - * type AttributeType, - * values SET OF AttributeValue - * } - * } - */ - Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 ); + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( dn != NULL ); + assert( msgidp != NULL ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { - return( -1 ); + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + ld->ld_errno = LDAP_NO_MEMORY; + return ld->ld_errno; } - if ( ber_printf( ber, "{it{s{", ++ld->ld_msgid, LDAP_REQ_ADD, dn ) - == -1 ) { + rc = ber_printf( ber, "{it{s{", /* '}}}' */ + ++ld->ld_msgid, LDAP_REQ_ADD, dn ); + + if ( rc == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return ld->ld_errno; } /* for each attribute in the entry... */ @@ -92,28 +132,52 @@ ldap_add( LDAP *ld, char *dn, LDAPMod **attrs ) if ( rc == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return ld->ld_errno; } } - if ( ber_printf( ber, "}}}" ) == -1 ) { + if ( ber_printf( ber, /*{{*/ "}}" ) == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return ld->ld_errno; + } + + /* Put Server Controls */ + if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + return ld->ld_errno; + } + + if ( ber_printf( ber, /*{*/ "}" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return ld->ld_errno; } /* send the message */ - return( send_initial_request( ld, LDAP_REQ_ADD, dn, ber )); + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_ADD, dn, ber ); + + if(*msgidp < 0) + return ld->ld_errno; + + return LDAP_SUCCESS; } int -ldap_add_s( LDAP *ld, char *dn, LDAPMod **attrs ) +ldap_add_ext_s( + LDAP *ld, + LDAP_CONST char *dn, + LDAPMod **attrs, + LDAPControl **sctrls, + LDAPControl **cctrls ) { - int msgid; + int msgid, rc; LDAPMessage *res; - if ( (msgid = ldap_add( ld, dn, attrs )) == -1 ) - return( ld->ld_errno ); + rc = ldap_add_ext( ld, dn, attrs, sctrls, cctrls, &msgid ); + + if ( rc != LDAP_SUCCESS ) + return( rc ); if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) return( ld->ld_errno ); @@ -121,3 +185,9 @@ ldap_add_s( LDAP *ld, char *dn, LDAPMod **attrs ) return( ldap_result2error( ld, res, 1 ) ); } +int +ldap_add_s( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs ) +{ + return ldap_add_ext_s( ld, dn, attrs, NULL, NULL ); +} + diff --git a/libraries/libldap/addentry.c b/libraries/libldap/addentry.c index a0fc4174e6..1249157f0d 100644 --- a/libraries/libldap/addentry.c +++ b/libraries/libldap/addentry.c @@ -1,38 +1,36 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * addentry.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" LDAPMessage * ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e ) { LDAPMessage *tmp, *prev = NULL; + assert( list != NULL ); + assert( e != NULL ); + for ( tmp = *list; tmp != NULL && tmp != e; tmp = tmp->lm_chain ) prev = tmp; @@ -51,6 +49,9 @@ ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e ) void ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e ) { + assert( list != NULL ); + assert( e != NULL ); + e->lm_chain = *list; *list = e; } diff --git a/libraries/libldap/apitest.c b/libraries/libldap/apitest.c index 94ba779400..b14f563d4b 100644 --- a/libraries/libldap/apitest.c +++ b/libraries/libldap/apitest.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/bind.c b/libraries/libldap/bind.c index 0a0487349e..b9579f2b4a 100644 --- a/libraries/libldap/bind.c +++ b/libraries/libldap/bind.c @@ -1,34 +1,47 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * bind.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; +/* + * BindRequest ::= SEQUENCE { + * version INTEGER, + * name DistinguishedName, -- who + * authentication CHOICE { + * simple [0] OCTET STRING -- passwd +#ifdef HAVE_KERBEROS + * krbv42ldap [1] OCTET STRING + * krbv42dsa [2] OCTET STRING #endif + * sasl [3] SaslCredentials -- LDAPv3 + * } + * } + * + * BindResponse ::= SEQUENCE { + * COMPONENTS OF LDAPResult, + * serverSaslCreds OCTET STRING OPTIONAL -- LDAPv3 + * } + * + */ + +#include "portable.h" #include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include "msdos.h" -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#else /* DOS */ -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" + +#include + +#include +#include +#include + +#include "ldap-int.h" /* @@ -45,31 +58,15 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of */ int -ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod ) +ldap_bind( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd, int authmethod ) { - /* - * The bind request looks like this: - * BindRequest ::= SEQUENCE { - * version INTEGER, - * name DistinguishedName, -- who - * authentication CHOICE { - * simple [0] OCTET STRING -- passwd -#ifdef KERBEROS - * krbv42ldap [1] OCTET STRING - * krbv42dsa [2] OCTET STRING -#endif - * } - * } - * all wrapped up in an LDAPMessage sequence. - */ - Debug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 ); switch ( authmethod ) { case LDAP_AUTH_SIMPLE: return( ldap_simple_bind( ld, dn, passwd ) ); -#ifdef KERBEROS +#ifdef HAVE_KERBEROS case LDAP_AUTH_KRBV41: return( ldap_kerberos_bind1( ld, dn ) ); @@ -77,6 +74,10 @@ ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod ) return( ldap_kerberos_bind2( ld, dn ) ); #endif + case LDAP_AUTH_SASL: + /* user must use ldap_sasl_bind */ + /* FALL-THRU */ + default: ld->ld_errno = LDAP_AUTH_UNKNOWN; return( -1 ); @@ -98,7 +99,11 @@ ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod ) * NULL, LDAP_AUTH_KRBV4 ) */ int -ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod ) +ldap_bind_s( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *passwd, + int authmethod ) { Debug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 ); @@ -106,7 +111,7 @@ ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod ) case LDAP_AUTH_SIMPLE: return( ldap_simple_bind_s( ld, dn, passwd ) ); -#ifdef KERBEROS +#ifdef HAVE_KERBEROS case LDAP_AUTH_KRBV4: return( ldap_kerberos_bind_s( ld, dn ) ); @@ -117,17 +122,22 @@ ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod ) return( ldap_kerberos_bind2_s( ld, dn ) ); #endif + case LDAP_AUTH_SASL: + /* user must use ldap_sasl_bind */ + /* FALL-THRU */ + default: return( ld->ld_errno = LDAP_AUTH_UNKNOWN ); } } -#ifdef LDAP_REFERRALS void ldap_set_rebind_proc( LDAP *ld, int (*rebindproc)( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, int freeit )) { + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + ld->ld_rebindproc = rebindproc; } -#endif /* LDAP_REFERRALS */ diff --git a/libraries/libldap/cache.c b/libraries/libldap/cache.c index 197f4fb9e3..0e01394a90 100644 --- a/libraries/libldap/cache.c +++ b/libraries/libldap/cache.c @@ -1,66 +1,46 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1993 The Regents of the University of Michigan. * All rights reserved. * * cache.c - local caching support for LDAP */ -#ifndef NO_CACHE - -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1993 The Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include -#ifdef MACOS -#include -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#ifdef WINSOCK -#include -#endif /* WINSOCK */ -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ -#include "lber.h" -#include "ldap.h" + +#include + +#include +#include +#include + #include "ldap-int.h" -#ifdef NEEDPROTOS -static int cache_hash( BerElement *ber ); -static LDAPMessage *msg_dup( LDAPMessage *msg ); -static int request_cmp( BerElement *req1, BerElement *req2 ); -static int chain_contains_dn( LDAPMessage *msg, char *dn ); -static long msg_size( LDAPMessage *msg ); -static void check_cache_memused( LDAPCache *lc ); -static void uncache_entry_or_req( LDAP *ld, char *dn, int msgid ); -#else /* NEEDPROTOS */ -static int cache_hash(); -static LDAPMessage *msg_dup(); -static int request_cmp(); -static int chain_contains_dn(); -static long msg_size(); -static void check_cache_memused(); -static void uncache_entry_or_req(); -#endif /* NEEDPROTOS */ +#ifndef LDAP_NOCACHE +static int cache_hash LDAP_P(( BerElement *ber )); +static LDAPMessage *msg_dup LDAP_P(( LDAPMessage *msg )); +static int request_cmp LDAP_P(( BerElement *req1, BerElement *req2 )); +static int chain_contains_dn LDAP_P(( LDAPMessage *msg, LDAP_CONST char *dn )); +static ber_len_t msg_size LDAP_P(( LDAPMessage *msg )); +static void check_cache_memused LDAP_P(( LDAPCache *lc )); +static void uncache_entry_or_req LDAP_P(( LDAP *ld, LDAP_CONST char *dn, ber_int_t msgid )); + +#endif int -ldap_enable_cache( LDAP *ld, long timeout, long maxmem ) +ldap_enable_cache( LDAP *ld, long timeout, ber_len_t maxmem ) { - if ( ld->ld_cache == NULLLDCACHE ) { - if (( ld->ld_cache = (LDAPCache *)malloc( sizeof( LDAPCache ))) - == NULLLDCACHE ) { +#ifndef LDAP_NOCACHE + if ( ld->ld_cache == NULL ) { + if (( ld->ld_cache = (LDAPCache *)LDAP_MALLOC( sizeof( LDAPCache ))) + == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( -1 ); } @@ -73,15 +53,20 @@ ldap_enable_cache( LDAP *ld, long timeout, long maxmem ) check_cache_memused( ld->ld_cache ); ld->ld_cache->lc_enabled = 1; return( 0 ); +#else + return( -1 ); +#endif } void ldap_disable_cache( LDAP *ld ) { - if ( ld->ld_cache != NULLLDCACHE ) { +#ifndef LDAP_NOCACHE + if ( ld->ld_cache != NULL ) { ld->ld_cache->lc_enabled = 0; } +#endif } @@ -89,96 +74,108 @@ ldap_disable_cache( LDAP *ld ) void ldap_set_cache_options( LDAP *ld, unsigned long opts ) { - if ( ld->ld_cache != NULLLDCACHE ) { +#ifndef LDAP_NOCACHE + if ( ld->ld_cache != NULL ) { ld->ld_cache->lc_options = opts; } +#endif } void ldap_destroy_cache( LDAP *ld ) { - if ( ld->ld_cache != NULLLDCACHE ) { +#ifndef LDAP_NOCACHE + if ( ld->ld_cache != NULL ) { ldap_flush_cache( ld ); - free( (char *)ld->ld_cache ); - ld->ld_cache = NULLLDCACHE; + LDAP_FREE( (char *)ld->ld_cache ); + ld->ld_cache = NULL; } +#endif } void ldap_flush_cache( LDAP *ld ) { +#ifndef LDAP_NOCACHE int i; LDAPMessage *m, *next; Debug( LDAP_DEBUG_TRACE, "ldap_flush_cache\n", 0, 0, 0 ); - if ( ld->ld_cache != NULLLDCACHE ) { + if ( ld->ld_cache != NULL ) { /* delete all requests in the queue */ - for ( m = ld->ld_cache->lc_requests; m != NULLMSG; m = next ) { + for ( m = ld->ld_cache->lc_requests; m != NULL; m = next ) { next = m->lm_next; ldap_msgfree( m ); } - ld->ld_cache->lc_requests = NULLMSG; + ld->ld_cache->lc_requests = NULL; /* delete all messages in the cache */ for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) { for ( m = ld->ld_cache->lc_buckets[ i ]; - m != NULLMSG; m = next ) { + m != NULL; m = next ) { next = m->lm_next; ldap_msgfree( m ); } - ld->ld_cache->lc_buckets[ i ] = NULLMSG; + ld->ld_cache->lc_buckets[ i ] = NULL; } ld->ld_cache->lc_memused = sizeof( LDAPCache ); } +#endif } void ldap_uncache_request( LDAP *ld, int msgid ) { - Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %x\n", - msgid, ld->ld_cache, 0 ); +#ifndef LDAP_NOCACHE + Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %lx\n", + msgid, (long) ld->ld_cache, 0 ); uncache_entry_or_req( ld, NULL, msgid ); +#endif } void -ldap_uncache_entry( LDAP *ld, char *dn ) +ldap_uncache_entry( LDAP *ld, LDAP_CONST char *dn ) { - Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %x\n", - dn, ld->ld_cache, 0 ); +#ifndef LDAP_NOCACHE + Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %lx\n", + dn, (long) ld->ld_cache, 0 ); uncache_entry_or_req( ld, dn, 0 ); +#endif } +#ifndef LDAP_NOCACHE + static void uncache_entry_or_req( LDAP *ld, - char *dn, /* if non-NULL, uncache entry */ - int msgid ) /* request to uncache (if dn == NULL) */ + const char *dn, /* if non-NULL, uncache entry */ + ber_int_t msgid ) /* request to uncache (if dn == NULL) */ { int i; LDAPMessage *m, *prev, *next; Debug( LDAP_DEBUG_TRACE, - "ldap_uncache_entry_or_req dn %s msgid %d ld_cache %x\n", - dn, msgid, ld->ld_cache ); + "ldap_uncache_entry_or_req dn %s msgid %ld ld_cache %lx\n", + dn, (long) msgid, (long) ld->ld_cache ); - if ( ld->ld_cache == NULLLDCACHE ) { + if ( ld->ld_cache == NULL ) { return; } /* first check the request queue */ - prev = NULLMSG; - for ( m = ld->ld_cache->lc_requests; m != NULLMSG; m = next ) { + prev = NULL; + for ( m = ld->ld_cache->lc_requests; m != NULL; m = next ) { next = m->lm_next; if (( dn != NULL && chain_contains_dn( m, dn )) || ( dn == NULL && m->lm_msgid == msgid )) { - if ( prev == NULLMSG ) { + if ( prev == NULL ) { ld->ld_cache->lc_requests = next; } else { prev->lm_next = next; @@ -192,13 +189,13 @@ uncache_entry_or_req( LDAP *ld, /* now check the rest of the cache */ for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) { - prev = NULLMSG; - for ( m = ld->ld_cache->lc_buckets[ i ]; m != NULLMSG; + prev = NULL; + for ( m = ld->ld_cache->lc_buckets[ i ]; m != NULL; m = next ) { next = m->lm_next; if (( dn != NULL && chain_contains_dn( m, dn )) || ( dn == NULL && m->lm_msgid == msgid )) { - if ( prev == NULLMSG ) { + if ( prev == NULL ) { ld->ld_cache->lc_buckets[ i ] = next; } else { prev->lm_next = next; @@ -212,32 +209,34 @@ uncache_entry_or_req( LDAP *ld, } } +#endif void -add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) +ldap_add_request_to_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) { +#ifndef LDAP_NOCACHE LDAPMessage *new; - long len; + ber_len_t len; - Debug( LDAP_DEBUG_TRACE, "add_request_to_cache\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_add_request_to_cache\n", 0, 0, 0 ); ld->ld_errno = LDAP_SUCCESS; - if ( ld->ld_cache == NULLLDCACHE || + if ( ld->ld_cache == NULL || ( ld->ld_cache->lc_enabled == 0 )) { return; } - if (( new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) )) + if (( new = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) )) != NULL ) { - if (( new->lm_ber = alloc_ber_with_options( ld )) == NULLBER ) { - free( (char *)new ); + if (( new->lm_ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + LDAP_FREE( (char *)new ); return; } len = request->ber_ptr - request->ber_buf; - if (( new->lm_ber->ber_buf = (char *) malloc( (size_t)len )) + if (( new->lm_ber->ber_buf = (char *) ber_memalloc( (size_t)len )) == NULL ) { ber_free( new->lm_ber, 0 ); - free( (char *)new ); + LDAP_FREE( (char *)new ); ld->ld_errno = LDAP_NO_MEMORY; return; } @@ -252,25 +251,28 @@ add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) } else { ld->ld_errno = LDAP_NO_MEMORY; } +#endif } void -add_result_to_cache( LDAP *ld, LDAPMessage *result ) +ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) { +#ifndef LDAP_NOCACHE LDAPMessage *m, **mp, *req, *new, *prev; int err, keep; - Debug( LDAP_DEBUG_TRACE, "add_result_to_cache: id %d, type %d\n", - result->lm_msgid, result->lm_msgtype, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %ld, type %ld\n", + (long) result->lm_msgid, (long) result->lm_msgtype, 0 ); - if ( ld->ld_cache == NULLLDCACHE || + if ( ld->ld_cache == NULL || ( ld->ld_cache->lc_enabled == 0 )) { Debug( LDAP_DEBUG_TRACE, "artc: cache disabled\n", 0, 0, 0 ); return; } if ( result->lm_msgtype != LDAP_RES_SEARCH_ENTRY && + result->lm_msgtype != LDAP_RES_SEARCH_REFERENCE && result->lm_msgtype != LDAP_RES_SEARCH_RESULT && result->lm_msgtype != LDAP_RES_COMPARE ) { /* @@ -286,7 +288,7 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result ) * result to it. if this result completes the results for the * request, add the request/result chain to the cache proper. */ - prev = NULLMSG; + prev = NULL; for ( m = ld->ld_cache->lc_requests; m != NULL; m = m->lm_next ) { if ( m->lm_msgid == result->lm_msgid ) { break; @@ -294,12 +296,12 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result ) prev = m; } - if ( m != NULLMSG ) { /* found request; add to end of chain */ + if ( m != NULL ) { /* found request; add to end of chain */ req = m; - for ( ; m->lm_chain != NULLMSG; m = m->lm_chain ) + for ( ; m->lm_chain != NULL; m = m->lm_chain ) ; - if (( new = msg_dup( result )) != NULLMSG ) { - new->lm_chain = NULLMSG; + if (( new = msg_dup( result )) != NULL ) { + new->lm_chain = NULL; m->lm_chain = new; Debug( LDAP_DEBUG_TRACE, "artc: result added to cache request chain\n", @@ -330,7 +332,7 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result ) keep = 1; } - if ( prev == NULLMSG ) { + if ( prev == NULL ) { ld->ld_cache->lc_requests = req->lm_next; } else { prev->lm_next = req->lm_next; @@ -358,6 +360,7 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result ) Debug( LDAP_DEBUG_TRACE, "artc: msgid not in request list\n", 0, 0, 0 ); } +#endif } @@ -369,16 +372,17 @@ add_result_to_cache( LDAP *ld, LDAPMessage *result ) * will find them. */ int -check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) +ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) { +#ifndef LDAP_NOCACHE LDAPMessage *m, *new, *prev, *next; BerElement reqber; int first, hash; - unsigned long validtime; + time_t c_time; - Debug( LDAP_DEBUG_TRACE, "check_cache\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_check_cache\n", 0, 0, 0 ); - if ( ld->ld_cache == NULLLDCACHE || + if ( ld->ld_cache == NULL || ( ld->ld_cache->lc_enabled == 0 )) { return( -1 ); } @@ -386,14 +390,14 @@ check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) reqber.ber_buf = reqber.ber_ptr = request->ber_buf; reqber.ber_end = request->ber_ptr; - validtime = (long)time( NULL ) - ld->ld_cache->lc_timeout; + c_time = time( NULL ); - prev = NULLMSG; + prev = NULL; hash = cache_hash( &reqber ); - for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULLMSG; m = next ) { - Debug( LDAP_DEBUG_TRACE,"cc: examining id %d,type %d\n", - m->lm_msgid, m->lm_msgtype, 0 ); - if ( m->lm_time < validtime ) { + for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULL; m = next ) { + Debug( LDAP_DEBUG_TRACE,"cc: examining id %ld,type %ld\n", + (long) m->lm_msgid, (long) m->lm_msgtype, 0 ); + if ( difftime(c_time, m->lm_time) > ld->ld_cache->lc_timeout ) { /* delete expired message */ next = m->lm_next; if ( prev == NULL ) { @@ -415,7 +419,7 @@ check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) } } - if ( m == NULLMSG ) { + if ( m == NULL ) { return( -1 ); } @@ -423,13 +427,13 @@ check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) * add duplicates of responses to incoming queue */ first = 1; - for ( m = m->lm_chain; m != NULLMSG; m = m->lm_chain ) { - if (( new = msg_dup( m )) == NULLMSG ) { + for ( m = m->lm_chain; m != NULL; m = m->lm_chain ) { + if (( new = msg_dup( m )) == NULL ) { return( -1 ); } new->lm_msgid = ld->ld_msgid; - new->lm_chain = NULLMSG; + new->lm_chain = NULL; if ( first ) { new->lm_next = ld->ld_responses; ld->ld_responses = new; @@ -438,20 +442,24 @@ check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ) prev->lm_chain = new; } prev = new; - Debug( LDAP_DEBUG_TRACE, "cc: added type %d\n", - new->lm_msgtype, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "cc: added type %ld\n", + (long) new->lm_msgtype, 0, 0 ); } Debug( LDAP_DEBUG_TRACE, "cc: result returned from cache\n", 0, 0, 0 ); return( 0 ); +#else + return( -1 ); +#endif } +#ifndef LDAP_NOCACHE static int cache_hash( BerElement *ber ) { BerElement bercpy; - unsigned long len; + ber_len_t len; /* * just take the length of the packet and mod with # of buckets @@ -474,20 +482,20 @@ static LDAPMessage * msg_dup( LDAPMessage *msg ) { LDAPMessage *new; - long len; + ber_len_t len; - if (( new = (LDAPMessage *)malloc( sizeof(LDAPMessage))) != NULL ) { + if (( new = (LDAPMessage *)LDAP_MALLOC( sizeof(LDAPMessage))) != NULL ) { *new = *msg; /* struct copy */ - if (( new->lm_ber = ber_dup( msg->lm_ber )) == NULLBER ) { - free( (char *)new ); - return( NULLMSG ); + if (( new->lm_ber = ber_dup( msg->lm_ber )) == NULL ) { + LDAP_FREE( (char *)new ); + return( NULL ); } len = msg->lm_ber->ber_end - msg->lm_ber->ber_buf; - if (( new->lm_ber->ber_buf = (char *) malloc( + if (( new->lm_ber->ber_buf = (char *) ber_memalloc( (size_t)len )) == NULL ) { ber_free( new->lm_ber, 0 ); - free( (char *)new ); - return( NULLMSG ); + LDAP_FREE( (char *)new ); + return( NULL ); } SAFEMEMCPY( new->lm_ber->ber_buf, msg->lm_ber->ber_buf, (size_t)len ); @@ -503,7 +511,7 @@ msg_dup( LDAPMessage *msg ) static int request_cmp( BerElement *req1, BerElement *req2 ) { - unsigned long len; + ber_len_t len; BerElement r1, r2; r1 = *req1; /* struct copies */ @@ -524,7 +532,9 @@ request_cmp( BerElement *req1, BerElement *req2 ) /* * check remaining length and bytes if necessary */ - if (( len = r1.ber_end - r1.ber_ptr ) != r2.ber_end - r2.ber_ptr ) { + if (( len = r1.ber_end - r1.ber_ptr ) != + (ber_len_t) (r2.ber_end - r2.ber_ptr) ) + { return( -1 ); /* different lengths */ } return( memcmp( r1.ber_ptr, r2.ber_ptr, (size_t)len )); @@ -532,11 +542,11 @@ request_cmp( BerElement *req1, BerElement *req2 ) static int -chain_contains_dn( LDAPMessage *msg, char *dn ) +chain_contains_dn( LDAPMessage *msg, const char *dn ) { LDAPMessage *m; BerElement ber; - long msgid; + ber_int_t msgid; char *s; int rc; @@ -545,9 +555,9 @@ chain_contains_dn( LDAPMessage *msg, char *dn ) * first check the base or dn of the request */ ber = *msg->lm_ber; /* struct copy */ - if ( ber_scanf( &ber, "{i{a", &msgid, &s ) != LBER_ERROR ) { + if ( ber_scanf( &ber, "{i{a" /*}}*/, &msgid, &s ) != LBER_ERROR ) { rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0; - free( s ); + LDAP_FREE( s ); if ( rc != 0 ) { return( rc ); } @@ -561,14 +571,14 @@ chain_contains_dn( LDAPMessage *msg, char *dn ) * now check the dn of each search result */ rc = 0; - for ( m = msg->lm_chain; m != NULLMSG && rc == 0 ; m = m->lm_chain ) { + for ( m = msg->lm_chain; m != NULL && rc == 0 ; m = m->lm_chain ) { if ( m->lm_msgtype != LDAP_RES_SEARCH_ENTRY ) { continue; } ber = *m->lm_ber; /* struct copy */ - if ( ber_scanf( &ber, "{a", &s ) != LBER_ERROR ) { + if ( ber_scanf( &ber, "{a" /*}*/, &s ) != LBER_ERROR ) { rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0; - free( s ); + LDAP_FREE( s ); } } @@ -576,14 +586,14 @@ chain_contains_dn( LDAPMessage *msg, char *dn ) } -static long +static ber_len_t msg_size( LDAPMessage *msg ) { LDAPMessage *m; - long size; + ber_len_t size; size = 0; - for ( m = msg; m != NULLMSG; m = m->lm_chain ) { + for ( m = msg; m != NULL; m = m->lm_chain ) { size += ( sizeof( LDAPMessage ) + m->lm_ber->ber_end - m->lm_ber->ber_buf ); } @@ -609,27 +619,28 @@ check_cache_memused( LDAPCache *lc ) * } while ( cache size is > SIZE_FACTOR * lc_maxmem ) */ int i; - unsigned long remove_threshold, validtime; + unsigned long remove_threshold; + time_t c_time; LDAPMessage *m, *prev, *next; Debug( LDAP_DEBUG_TRACE, "check_cache_memused: %ld bytes in use (%ld max)\n", lc->lc_memused, lc->lc_maxmem, 0 ); - if ( lc->lc_maxmem <= sizeof( LDAPCache ) + if ( (unsigned) lc->lc_maxmem <= sizeof( LDAPCache ) || lc->lc_memused <= lc->lc_maxmem * SIZE_FACTOR ) { return; } remove_threshold = lc->lc_timeout; while ( lc->lc_memused > lc->lc_maxmem * SIZE_FACTOR ) { - validtime = (long)time( NULL ) - remove_threshold; + c_time = time( NULL ); for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) { - prev = NULLMSG; - for ( m = lc->lc_buckets[ i ]; m != NULLMSG; + prev = NULL; + for ( m = lc->lc_buckets[ i ]; m != NULL; m = next ) { next = m->lm_next; - if ( m->lm_time < validtime ) { - if ( prev == NULLMSG ) { + if ( difftime(c_time, m->lm_time) > remove_threshold) { + if ( prev == NULL ) { lc->lc_buckets[ i ] = next; } else { prev->lm_next = next; diff --git a/libraries/libldap/charray.c b/libraries/libldap/charray.c new file mode 100644 index 0000000000..6be3152427 --- /dev/null +++ b/libraries/libldap/charray.c @@ -0,0 +1,219 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* charray.c - routines for dealing with char * arrays */ + +#include "portable.h" + +#include + +#include +#include + +#include "ldap-int.h" + +int +ldap_charray_add( + char ***a, + char *s +) +{ + int n; + + if ( *a == NULL ) { + *a = (char **) LDAP_MALLOC( 2 * sizeof(char *) ); + n = 0; + + if( *a == NULL ) { + return -1; + } + + } else { + char **new; + + for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) { + ; /* NULL */ + } + + new = (char **) LDAP_REALLOC( (char *) *a, + (n + 2) * sizeof(char *) ); + + if( new == NULL ) { + /* caller is required to call ldap_charray_free(*a) */ + return -1; + } + + *a = new; + } + + (*a)[n] = LDAP_STRDUP(s); + + if( (*a)[n] == NULL ) { + return 1; + } + + (*a)[++n] = NULL; + + return 0; +} + +int +ldap_charray_merge( + char ***a, + char **s +) +{ + int i, n, nn; + char **aa; + + for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) { + ; /* NULL */ + } + for ( nn = 0; s[nn] != NULL; nn++ ) { + ; /* NULL */ + } + + aa = (char **) LDAP_REALLOC( (char *) *a, (n + nn + 1) * sizeof(char *) ); + + if( aa == NULL ) + return -1; + + *a = aa; + + for ( i = 0; i < nn; i++ ) { + (*a)[n + i] = LDAP_STRDUP(s[i]); + + if( (*a)[n + i] == NULL ) { + for( --i ; i >= 0 ; i-- ) { + LDAP_FREE( (*a)[n + i] ); + (*a)[n + i] = NULL; + } + return -1; + } + } + + (*a)[n + nn] = NULL; + return 0; +} + +void +ldap_charray_free( char **a ) +{ + char **p; + + if ( a == NULL ) { + return; + } + + for ( p = a; *p != NULL; p++ ) { + if ( *p != NULL ) { + LDAP_FREE( *p ); + } + } + + LDAP_FREE( (char *) a ); +} + +int +ldap_charray_inlist( + char **a, + char *s +) +{ + int i; + + for ( i = 0; a[i] != NULL; i++ ) { + if ( strcasecmp( s, a[i] ) == 0 ) { + return( 1 ); + } + } + + return( 0 ); +} + +char ** +ldap_charray_dup( char **a ) +{ + int i; + char **new; + + for ( i = 0; a[i] != NULL; i++ ) + ; /* NULL */ + + new = (char **) LDAP_MALLOC( (i + 1) * sizeof(char *) ); + + if( new == NULL ) { + return NULL; + } + + for ( i = 0; a[i] != NULL; i++ ) { + new[i] = LDAP_STRDUP( a[i] ); + + if( new[i] == NULL ) { + for( --i ; i >= 0 ; i-- ) { + LDAP_FREE( new[i] ); + } + LDAP_FREE( new ); + return NULL; + } + } + new[i] = NULL; + + return( new ); +} + +char ** +ldap_str2charray( char *str, char *brkstr ) +{ + char **res; + char *s; + char *lasts; + int i; + + /* protect the input string from strtok */ + str = LDAP_STRDUP( str ); + if( str == NULL ) { + return NULL; + } + + i = 1; + for ( s = str; *s; s++ ) { + if ( strchr( brkstr, *s ) != NULL ) { + i++; + } + } + + res = (char **) LDAP_MALLOC( (i + 1) * sizeof(char *) ); + + if( res == NULL ) { + LDAP_FREE( str ); + return NULL; + } + + i = 0; + + for ( s = ldap_pvt_strtok( str, brkstr, &lasts ); + s != NULL; + s = ldap_pvt_strtok( NULL, brkstr, &lasts ) ) + { + res[i] = LDAP_STRDUP( s ); + + if(res[i] == NULL) { + for( --i ; i >= 0 ; i-- ) { + LDAP_FREE( res[i] ); + } + LDAP_FREE( res ); + LDAP_FREE( str ); + return NULL; + } + + i++; + } + + res[i] = NULL; + + LDAP_FREE( str ); + return( res ); +} diff --git a/libraries/libldap/charset.c b/libraries/libldap/charset.c index d5b74006f5..7d85f5ad79 100644 --- a/libraries/libldap/charset.c +++ b/libraries/libldap/charset.c @@ -1,40 +1,31 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1995 Regents of the University of Michigan. * All rights reserved. * * charset.c */ -#if defined( DOS ) || defined( _WIN32 ) -/* - * This MUST precede "#ifdef STR_TRANSLATION" - * because STR_TRANSLATION and friends are defined in msdos.h. - */ -#include "msdos.h" -#endif /* DOS */ +#include "portable.h" #ifdef STR_TRANSLATION -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif - #include -#include -#ifdef MACOS -#include -#include "macos.h" -#endif /* MACOS */ +#include + +#include +#include +#include -#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) && !defined(VMS) -#include -#include -#include +#ifdef HAVE_SYS_PARAM_H #include #endif -#include "lber.h" -#include "ldap.h" + #include "ldap-int.h" @@ -50,9 +41,9 @@ ldap_set_string_translators( LDAP *ld, BERTranslateProc encode_proc, void ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable ) { - char *optionsp; + unsigned short *optionsp; - optionsp = ( entry == NULLMSG ) ? &ld->ld_lberoptions : + optionsp = ( entry == NULL ) ? &ld->ld_lberoptions : &entry->lm_ber->ber_options; if ( enable ) { @@ -64,10 +55,10 @@ ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable ) int -ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp, +ldap_translate_from_t61( LDAP *ld, char **bufp, ber_len_t *lenp, int free_input ) { - if ( ld->ld_lber_decode_translate_proc == NULL ) { + if ( ld->ld_lber_decode_translate_proc == 0 ) { return( LDAP_SUCCESS ); } @@ -76,10 +67,10 @@ ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp, int -ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp, +ldap_translate_to_t61( LDAP *ld, char **bufp, ber_len_t *lenp, int free_input ) { - if ( ld->ld_lber_encode_translate_proc == NULL ) { + if ( ld->ld_lber_encode_translate_proc == 0 ) { return( LDAP_SUCCESS ); } @@ -158,8 +149,8 @@ ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp, #include -#include -#include +#include +#include /* Character set used: ISO 8859-1, ISO 8859-2, ISO 8859-3, ... */ /* #define ISO_8859 1 */ @@ -171,17 +162,12 @@ ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp, typedef unsigned char Byte; typedef struct { Byte a, b; } Couple; -#ifdef NEEDPROTOS -static Byte *c_to_hh( Byte *o, Byte c ); -static Byte *c_to_cc( Byte *o, Couple *cc, Byte c ); -static int hh_to_c( Byte *h ); -static Byte *cc_to_t61( Byte *o, Byte *s ); -#else /* NEEDPROTOS */ -static Byte *c_to_hh(); -static Byte *c_to_cc(); -static int hh_to_c(); -static Byte *cc_to_t61(); -#endif /* NEEDPROTOS */ +/* Prototypes without LDAP_P(): + * 'Byte' in definition incompatible with unprototyped declaration. */ +static Byte *c_to_hh ( Byte *o, Byte c ); +static Byte *c_to_cc ( Byte *o, const Couple *cc, Byte c ); +static int hh_to_c ( const Byte *h ); +static Byte *cc_to_t61 ( Byte *o, const Byte *s ); /* Character choosed as base in diacritics alone: NO-BREAK SPACE. @@ -189,7 +175,7 @@ static Byte *cc_to_t61(); */ #define ALONE 0xA0 -static Couple diacritic[16] = { +static const Couple diacritic[16] = { #if (ISO_8859 == 1) || (ISO_8859 == 9) {0,0}, {'`',0}, {0xb4,0}, {'^',0}, {'~',0}, {0xaf,0}, {'(',ALONE}, {'.',ALONE}, @@ -224,7 +210,7 @@ static Couple diacritic[16] = { L, N, O, R, S, T, U, W, Y, Z. ----------------------------------------------------------------------- */ -static int letter_w_diacritic[16][38] = { +static const int letter_w_diacritic[16][38] = { #if (ISO_8859 == 1) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -686,7 +672,7 @@ static int letter_w_diacritic[16][38] = { /* --- T.61 characters [0xA0 .. 0xBF] ----------------- */ -static Couple trans_t61a_iso8859[32] = { +static const Couple trans_t61a_iso8859[32] = { #if (ISO_8859 == 1) || (ISO_8859 == 9) {'N','S'}, {0xa1,0}, {0xa2,0}, {0xa3,0}, {'D','O'}, {0xa5,0}, {'C','u'}, {0xa7,0}, @@ -738,7 +724,7 @@ static Couple trans_t61a_iso8859[32] = { /* --- T.61 characters [0xE0 .. 0xFF] ----------------- */ -static Couple trans_t61b_iso8859[48] = { +static const Couple trans_t61b_iso8859[48] = { #if (ISO_8859 == 1) {'-','M'}, {0xb9,0}, {0xae,0}, {0xa9,0}, {'T','M'}, {'M','8'}, {0xac,0}, {0xa6,0}, @@ -837,7 +823,7 @@ static Couple trans_t61b_iso8859[48] = { --- ISO 8859-n characters <0xA0 .. 0xFF> ------------------- */ #if (ISO_8859 == 1) -static Couple trans_iso8859_t61[96] = { +static const Couple trans_iso8859_t61[96] = { {0xa0,0}, {0xa1,0}, {0xa2,0}, {0xa3,0}, {0xa8,0}, {0xa5,0}, {0xd7,0}, {0xa7,0}, {0xc8,ALONE}, {0xd3,0}, {0xe3,0}, {0xab,0}, @@ -864,7 +850,7 @@ static Couple trans_iso8859_t61[96] = { {0xc8,'u'}, {0xc2,'y'}, {0xfc,0}, {0xc8,'y'} }; #elif (ISO_8859 == 2) -static Couple trans_iso8859_t61[96] = { +static const Couple trans_iso8859_t61[96] = { {0xa0,0}, {0xce,'A'}, {0xc6,ALONE}, {0xe8,0}, {0xa8,0}, {0xcf,'L'}, {0xc2,'S'}, {0xa7,0}, {0xc8,ALONE}, {0xcf,'S'}, {0xcb,'S'}, {0xcf,'T'}, @@ -891,7 +877,7 @@ static Couple trans_iso8859_t61[96] = { {0xc8,'u'}, {0xc2,'y'}, {0xcb,'t'}, {0xc7,ALONE} }; #elif (ISO_8859 == 3) -static Couple trans_iso8859_t61[96] = { +static const Couple trans_iso8859_t61[96] = { {0xa0,0}, {0xe4,0}, {0xc6,ALONE}, {0xa3,0}, {0xa8,0}, {0,0}, {0xc3,'H'}, {0xa7,0}, {0xc8,ALONE}, {0xc7,'I'}, {0xcb,'S'}, {0xc6,'G'}, @@ -918,7 +904,7 @@ static Couple trans_iso8859_t61[96] = { {0xc8,'u'}, {0xc6,'u'}, {0xc3,'s'}, {0xc7,ALONE} }; #elif (ISO_8859 == 4) -static Couple trans_iso8859_t61[96] = { +static const Couple trans_iso8859_t61[96] = { {0xa0,0}, {0xce,'A'}, {0xf0,0}, {0xcb,'R'}, {0xa8,0}, {0xc4,'I'}, {0xcb,'L'}, {0xa7,0}, {0xc8,ALONE}, {0xcf,'S'}, {0xc5,'E'}, {0xcb,'G'}, @@ -945,7 +931,7 @@ static Couple trans_iso8859_t61[96] = { {0xc8,'u'}, {0xc4,'u'}, {0xc5,'u'}, {0xc7,ALONE} }; #elif (ISO_8859 == 9) -static Couple trans_iso8859_t61[96] = { +static const Couple trans_iso8859_t61[96] = { {0xa0,0}, {0xa1,0}, {0xa2,0}, {0xa3,0}, {0xa8,0}, {0xa5,0}, {0xd7,0}, {0xa7,0}, {0xc8,ALONE}, {0xd3,0}, {0xe3,0}, {0xab,0}, @@ -972,7 +958,7 @@ static Couple trans_iso8859_t61[96] = { {0xc8,'u'}, {0xf5,0}, {0xcb,'s'}, {0xc8,'y'} }; #elif (ISO_8859 == 10) -static Couple trans_iso8859_t61[96] = { +static const Couple trans_iso8859_t61[96] = { {0xa0,0}, {0xce,'A'}, {0xc5,'E'}, {0xcb,'G'}, {0xc5,'I'}, {0xc4,'I'}, {0xcb,'K'}, {0xa7,0}, {0xcb,'L'}, {0xe2,0}, {0xcf,'S'}, {0xed,0}, @@ -1017,7 +1003,7 @@ c_to_hh( Byte *o, Byte c ) static Byte * -c_to_cc( Byte *o, Couple *cc, Byte c ) +c_to_cc( Byte *o, const Couple *cc, Byte c ) { if ( (*cc).a != 0 ) { if ( (*cc).b == 0 ) @@ -1037,13 +1023,12 @@ c_to_cc( Byte *o, Couple *cc, Byte c ) /* --- routine to convert from T.61 to ISO 8859-n --- */ int -ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input ) +ldap_t61_to_8859( char **bufp, ber_len_t *buflenp, int free_input ) { Byte *s, *oo, *o; unsigned int n; int c; - unsigned long len; - Couple *cc; + ber_len_t len; Debug( LDAP_DEBUG_TRACE, "ldap_t61_to_8859 input length: %ld\n", *buflenp, 0, 0 ); @@ -1051,7 +1036,7 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input ) len = *buflenp; s = (Byte *) *bufp; - if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) { + if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * len + 64 )) == NULL ) { return( 1 ); } @@ -1153,13 +1138,13 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input ) len = o - oo; o = oo; - if ( (oo = (Byte *)realloc( o, len )) == NULL ) { - free( o ); + if ( (oo = (Byte *)LDAP_REALLOC( o, len )) == NULL ) { + LDAP_FREE( o ); return( 1 ); } if ( free_input ) { - free( *bufp ); + LDAP_FREE( *bufp ); } *bufp = (char *) oo; *buflenp = len; @@ -1168,7 +1153,7 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input ) static int -hh_to_c( Byte *h ) +hh_to_c( const Byte *h ) { Byte c; @@ -1189,7 +1174,7 @@ hh_to_c( Byte *h ) static Byte * -cc_to_t61( Byte *o, Byte *s ) +cc_to_t61( Byte *o, const Byte *s ) { int n, c = 0; @@ -1575,12 +1560,12 @@ cc_to_t61( Byte *o, Byte *s ) /* --- routine to convert from ISO 8859-n to T.61 --- */ int -ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input ) +ldap_8859_to_t61( char **bufp, ber_len_t *buflenp, int free_input ) { Byte *s, *oo, *o, *aux; int c; - unsigned long len; - Couple *cc; + ber_len_t len; + const Couple *cc; Debug( LDAP_DEBUG_TRACE, "ldap_8859_to_t61 input length: %ld\n", *buflenp, 0, 0 ); @@ -1588,7 +1573,7 @@ ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input ) len = *buflenp; s = (Byte *) *bufp; - if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) { + if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * len + 64 )) == NULL ) { return( 1 ); } @@ -1667,13 +1652,13 @@ ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input ) len = o - oo; o = oo; - if ( (oo = (Byte *)realloc( o, len )) == NULL ) { - free( o ); + if ( (oo = (Byte *)LDAP_REALLOC( o, len )) == NULL ) { + LDAP_FREE( o ); return( 1 ); } if ( free_input ) { - free( *bufp ); + LDAP_FREE( *bufp ); } *bufp = (char *) oo; *buflenp = len; @@ -1692,7 +1677,7 @@ char *s; while ( *s ) { if ( *s == '\\' ) { - if ( (c = hh_to_c( ++s )) != -1 ) { + if ( (c = hh_to_c( (Byte *) ++s )) != -1 ) { *o++ = c; s += 2; } else @@ -1706,12 +1691,12 @@ char *s; /* --- routine to convert 8bits characters to the "escaped" (\hh) form --- */ char *convert_8bit_to_escaped( s ) -Byte *s; +const Byte *s; { Byte *o, *oo; Byte n; - if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) { + if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) { return( NULL ); } @@ -1730,8 +1715,8 @@ Byte *s; o = oo; - if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) { - free( o ); + if ( (oo = (Byte *)LDAP_REALLOC( o, strlen( o ) + 1 )) == NULL ) { + LDAP_FREE( o ); return( NULL ); } @@ -1747,7 +1732,7 @@ Byte *s; that conversion is language dependent. */ -static Couple last_t61_printabled[32] = { +static const Couple last_t61_printabled[32] = { {0,0}, {'A','E'}, {'D',0}, {0,0}, {'H',0}, {0,0}, {'I','J'}, {'L',0}, {'L',0}, {'O',0}, {'O','E'}, {0,0}, @@ -1763,9 +1748,9 @@ Byte *s; { Byte *o, *oo; Byte n; - Couple *cc; + const Couple *cc; - if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) { + if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) { return( NULL ); } @@ -1808,8 +1793,8 @@ Byte *s; o = oo; - if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) { - free( o ); + if ( (oo = (Byte *)LDAP_REALLOC( o, strlen( o ) + 1 )) == NULL ) { + LDAP_FREE( o ); return( NULL ); } diff --git a/libraries/libldap/cldap.c b/libraries/libldap/cldap.c index 19782f77d8..de6208136b 100644 --- a/libraries/libldap/cldap.c +++ b/libraries/libldap/cldap.c @@ -1,46 +1,34 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990, 1994 Regents of the University of Michigan. * All rights reserved. * * cldap.c - synchronous, retrying interface to the cldap protocol */ +#include "portable.h" -#ifdef CLDAP - -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#ifdef LDAP_CONNECTIONLESS #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include "msdos.h" -#else /* DOS */ -#include -#include -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" + +#include + +#include +#include +#include +#include +#include + #include "ldap-int.h" #define DEF_CLDAP_TIMEOUT 3 #define DEF_CLDAP_TRIES 4 -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK ((unsigned long) 0x7f000001) -#endif - struct cldap_retinfo { int cri_maxtries; @@ -49,17 +37,14 @@ struct cldap_retinfo { long cri_timeout; }; -#ifdef NEEDPROTOS -static int add_addr( LDAP *ld, struct sockaddr *sap ); -static int cldap_result( LDAP *ld, int msgid, LDAPMessage **res, - struct cldap_retinfo *crip, char *base ); -static int cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, - LDAPMessage **res, char *base ); -#else /* NEEDPROTOS */ -static int add_addr(); -static int cldap_result(); -static int cldap_parsemsg(); -#endif /* NEEDPROTOS */ +static int add_addr LDAP_P(( + LDAP *ld, struct sockaddr *sap )); +static int cldap_result LDAP_P(( + LDAP *ld, int msgid, LDAPMessage **res, + struct cldap_retinfo *crip, const char *base )); +static int cldap_parsemsg LDAP_P(( + LDAP *ld, int msgid, BerElement *ber, + LDAPMessage **res, const char *base )); /* * cldap_open - initialize and connect to an ldap server. A magic cookie to @@ -71,7 +56,7 @@ static int cldap_parsemsg(); */ LDAP * -cldap_open( char *host, int port ) +cldap_open( LDAP_CONST char *host, int port ) { int s; unsigned long address; @@ -81,11 +66,14 @@ cldap_open( char *host, int port ) char *p; int i; - Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 ); + /* buffers for ldap_pvt_gethostbyname_a ... */ + struct hostent he_buf; + int local_h_errno; + char *ha_buf=NULL; - if ( port == 0 ) { - port = LDAP_PORT; - } +#define DO_RETURN(x) if (ha_buf) LDAP_FREE(ha_buf); return (x); + + Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 ); if ( (s = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) { return( NULL ); @@ -95,23 +83,23 @@ cldap_open( char *host, int port ) sock.sin_family = AF_INET; sock.sin_port = 0; if ( bind(s, (struct sockaddr *) &sock, sizeof(sock)) < 0) { - close( s ); + tcp_close( s ); return( NULL ); } - if (( ld = ldap_init( host, port )) == NULL ) { - close( s ); + tcp_close( s ); return( NULL ); } - if ( (ld->ld_sb.sb_fromaddr = (void *) calloc( 1, - sizeof( struct sockaddr ))) == NULL ) { - free( ld ); - close( s ); - return( NULL ); - } - ld->ld_sb.sb_sd = s; - ld->ld_sb.sb_naddr = 0; - ld->ld_version = LDAP_VERSION; + + ld->ld_cldapnaddr = 0; + ld->ld_cldapaddrs = NULL; + + if (ber_pvt_sb_set_io( &(ld->ld_sb), &ber_pvt_sb_io_udp, NULL )<0) { + ldap_ld_free(ld, 1, NULL, NULL ); + return NULL; + } + + ld->ld_version = LDAP_VERSION2; sock.sin_family = AF_INET; sock.sin_port = htons( port ); @@ -120,6 +108,8 @@ cldap_open( char *host, int port ) * 'host' may be a space-separated list. */ if ( host != NULL ) { + char *host_dup = LDAP_STRDUP( host ); + host = host_dup; for ( ; host != NULL; host = p ) { if (( p = strchr( host, ' ' )) != NULL ) { for (*p++ = '\0'; *p == ' '; p++) { @@ -127,10 +117,15 @@ cldap_open( char *host, int port ) } } - if ( (address = inet_addr( host )) == -1 ) { - if ( (hp = gethostbyname( host )) == NULL ) { - errno = EHOSTUNREACH; - continue; + address = inet_addr( host ); + /* This was just a test for -1 until OSF1 let inet_addr return + unsigned int, which is narrower than 'unsigned long address' */ + if ( address == 0xffffffff || address == (unsigned long) -1 ) { + if ((ldap_pvt_gethostbyname_a( host, &he_buf, &ha_buf, + &hp,&local_h_errno)<0) || + (hp==NULL)) { + errno = EHOSTUNREACH; + continue; } for ( i = 0; hp->h_addr_list[ i ] != 0; ++i ) { @@ -138,66 +133,63 @@ cldap_open( char *host, int port ) (char *)hp->h_addr_list[ i ], sizeof(sock.sin_addr.s_addr)); if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) { - close( s ); - free( ld ); - return( NULL ); + ldap_ld_free( ld, 1, NULL, NULL ); + LDAP_FREE( host_dup ); + DO_RETURN( NULL ); } } } else { sock.sin_addr.s_addr = address; if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) { - close( s ); - free( ld ); - return( NULL ); + ldap_ld_free( ld, 1, NULL, NULL ); + LDAP_FREE( host_dup ); + DO_RETURN( NULL ); } } if ( ld->ld_host == NULL ) { - ld->ld_host = strdup( host ); + ld->ld_host = LDAP_STRDUP( host ); } } - + LDAP_FREE( host_dup ); } else { - address = INADDR_LOOPBACK; - sock.sin_addr.s_addr = htonl( address ); + sock.sin_addr.s_addr = htonl( INADDR_LOOPBACK ); if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) { - close( s ); - free( ld ); - return( NULL ); + ldap_ld_free( ld, 1, NULL, NULL ); + DO_RETURN( NULL ); } } - if ( ld->ld_sb.sb_addrs == NULL -#ifdef LDAP_REFERRALS - || ( ld->ld_defconn = new_connection( ld, NULL, 1,0,0 )) == NULL -#endif /* LDAP_REFERRALS */ + if ( ld->ld_cldapaddrs == NULL + || ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL ) { - free( ld ); - return( NULL ); + ldap_ld_free( ld, 0, NULL, NULL ); + DO_RETURN( NULL ); } - ld->ld_sb.sb_useaddr = ld->ld_sb.sb_addrs[ 0 ]; + ber_pvt_sb_udp_set_dst( &ld->ld_sb, ld->ld_cldapaddrs[0] ); + cldap_setretryinfo( ld, 0, 0 ); #ifdef LDAP_DEBUG putchar( '\n' ); - for ( i = 0; i < ld->ld_sb.sb_naddr; ++i ) { + for ( i = 0; i < ld->ld_cldapnaddr; ++i ) { Debug( LDAP_DEBUG_TRACE, "end of cldap_open address %d is %s\n", i, inet_ntoa( ((struct sockaddr_in *) - ld->ld_sb.sb_addrs[ i ])->sin_addr ), 0 ); + ld->ld_cldapaddrs[ i ])->sin_addr ), 0 ); } #endif - return( ld ); + DO_RETURN( ld ); } - +#undef DO_RETURN void cldap_close( LDAP *ld ) { - ldap_ld_free( ld, 0 ); + ldap_ld_free( ld, 0, NULL, NULL ); } @@ -210,13 +202,19 @@ cldap_setretryinfo( LDAP *ld, int tries, int timeout ) int -cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs, - int attrsonly, LDAPMessage **res, char *logdn ) +cldap_search_s( LDAP *ld, + LDAP_CONST char *base, + int scope, + LDAP_CONST char *filter, + char **attrs, + int attrsonly, + LDAPMessage **res, + char *logdn ) { int ret, msgid; struct cldap_retinfo cri; - *res = NULLMSG; + *res = NULL; (void) memset( &cri, 0, sizeof( cri )); @@ -230,17 +228,19 @@ cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs, if ( cri.cri_try != 0 ) { --ld->ld_msgid; /* use same id as before */ } - ld->ld_sb.sb_useaddr = ld->ld_sb.sb_addrs[ cri.cri_useaddr ]; + + ber_pvt_sb_udp_set_dst( &(ld->ld_sb), + ld->ld_cldapaddrs[ cri.cri_useaddr ] ); Debug( LDAP_DEBUG_TRACE, "cldap_search_s try %d (to %s)\n", cri.cri_try, inet_ntoa( ((struct sockaddr_in *) - ld->ld_sb.sb_useaddr)->sin_addr ), 0 ); + ld->ld_cldapaddrs[ cri.cri_useaddr ])->sin_addr), 0 ); if ( (msgid = ldap_search( ld, base, scope, filter, attrs, attrsonly )) == -1 ) { return( ld->ld_errno ); } -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL && ld->ld_responses != NULL ) { Debug( LDAP_DEBUG_TRACE, "cldap_search_s res from cache\n", 0, 0, 0 ); @@ -248,7 +248,7 @@ cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs, ld->ld_responses = ld->ld_responses->lm_next; return( ldap_result2error( ld, *res, 0 )); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ ret = cldap_result( ld, msgid, res, &cri, base ); } while (ret == -1); @@ -261,62 +261,59 @@ add_addr( LDAP *ld, struct sockaddr *sap ) { struct sockaddr *newsap, **addrs; - if (( newsap = (struct sockaddr *)malloc( sizeof( struct sockaddr ))) + if (( newsap = (struct sockaddr *)LDAP_MALLOC( sizeof( struct sockaddr ))) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( -1 ); } - - if ( ld->ld_sb.sb_naddr == 0 ) { - addrs = (struct sockaddr **)malloc( sizeof(struct sockaddr *)); - } else { - addrs = (struct sockaddr **)realloc( ld->ld_sb.sb_addrs, - ( ld->ld_sb.sb_naddr + 1 ) * sizeof(struct sockaddr *)); - } + + addrs = (struct sockaddr **)LDAP_REALLOC( ld->ld_cldapaddrs, + ( ld->ld_cldapnaddr + 1 ) * sizeof(struct sockaddr *)); if ( addrs == NULL ) { - free( newsap ); + LDAP_FREE( newsap ); ld->ld_errno = LDAP_NO_MEMORY; return( -1 ); } SAFEMEMCPY( (char *)newsap, (char *)sap, sizeof( struct sockaddr )); - addrs[ ld->ld_sb.sb_naddr++ ] = newsap; - ld->ld_sb.sb_addrs = (void **)addrs; + addrs[ ld->ld_cldapnaddr++ ] = newsap; + ld->ld_cldapaddrs = (void **)addrs; return( 0 ); } static int cldap_result( LDAP *ld, int msgid, LDAPMessage **res, - struct cldap_retinfo *crip, char *base ) + struct cldap_retinfo *crip, const char *base ) { Sockbuf *sb = &ld->ld_sb; BerElement ber; char *logdn; - int ret, id, fromaddr, i; + int ret, fromaddr, i; + ber_int_t id; struct timeval tv; fromaddr = -1; if ( crip->cri_try == 0 ) { - crip->cri_maxtries = ld->ld_cldaptries * sb->sb_naddr; + crip->cri_maxtries = ld->ld_cldaptries * ld->ld_cldapnaddr; crip->cri_timeout = ld->ld_cldaptimeout; crip->cri_useaddr = 0; Debug( LDAP_DEBUG_TRACE, "cldap_result tries %d timeout %d\n", ld->ld_cldaptries, ld->ld_cldaptimeout, 0 ); } - if ((tv.tv_sec = crip->cri_timeout / sb->sb_naddr) < 1 ) { + if ((tv.tv_sec = crip->cri_timeout / ld->ld_cldapnaddr) < 1 ) { tv.tv_sec = 1; } tv.tv_usec = 0; Debug( LDAP_DEBUG_TRACE, - "cldap_result waiting up to %d seconds for a response\n", - tv.tv_sec, 0, 0 ); - ber_init( &ber, 0 ); - set_ber_options( ld, &ber ); + "cldap_result waiting up to %ld seconds for a response\n", + (long) tv.tv_sec, 0, 0 ); + ber_init_w_nullc( &ber, 0 ); + ldap_set_ber_options( ld, &ber ); if ( cldap_getmsg( ld, &tv, &ber ) == -1 ) { ret = ld->ld_errno; @@ -332,7 +329,7 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res, ret = LDAP_TIMEOUT; --crip->cri_try; } else { - if ( ++crip->cri_useaddr >= sb->sb_naddr ) { + if ( ++crip->cri_useaddr >= ld->ld_cldapnaddr ) { /* * new round: reset address to first one and * double the timeout @@ -351,38 +348,41 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res, logdn = NULL; if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) { - free( ber.ber_buf ); /* gack! */ + LDAP_FREE( ber.ber_buf ); /* gack! */ ret = LDAP_DECODING_ERROR; Debug( LDAP_DEBUG_TRACE, "cldap_result: ber_scanf returned LBER_ERROR (%d)\n", ret, 0, 0 ); } else if ( id != msgid ) { - free( ber.ber_buf ); /* gack! */ + LDAP_FREE( ber.ber_buf ); /* gack! */ Debug( LDAP_DEBUG_TRACE, "cldap_result: looking for msgid %d; got %d\n", msgid, id, 0 ); ret = -1; /* ignore and keep looking */ } else { + struct sockaddr_in * src; /* * got a result: determine which server it came from * decode into ldap message chain */ - for ( fromaddr = 0; fromaddr < sb->sb_naddr; ++fromaddr ) { + src = (struct sockaddr_in *) ber_pvt_sb_udp_get_src( sb ); + + for ( fromaddr = 0; fromaddr < ld->ld_cldapnaddr; ++fromaddr ) { if ( memcmp( &((struct sockaddr_in *) - sb->sb_addrs[ fromaddr ])->sin_addr, - &((struct sockaddr_in *)sb->sb_fromaddr)->sin_addr, + ld->ld_cldapaddrs[ fromaddr ])->sin_addr, + &(src->sin_addr), sizeof( struct in_addr )) == 0 ) { break; } } ret = cldap_parsemsg( ld, msgid, &ber, res, base ); - free( ber.ber_buf ); /* gack! */ + LDAP_FREE( ber.ber_buf ); /* gack! */ Debug( LDAP_DEBUG_TRACE, "cldap_result got result (%d)\n", ret, 0, 0 ); } if ( logdn != NULL ) { - free( logdn ); + LDAP_FREE( logdn ); } } @@ -393,18 +393,19 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res, */ if ( ret != -1 ) { i = crip->cri_try; - if ( i >= sb->sb_naddr ) { - i = sb->sb_naddr - 1; + if ( i >= ld->ld_cldapnaddr ) { + i = ld->ld_cldapnaddr - 1; } for ( ; i >= 0; --i ) { if ( i == fromaddr ) { continue; } - sb->sb_useaddr = sb->sb_addrs[ i ]; + ber_pvt_sb_udp_set_dst( sb, ld->ld_cldapaddrs[i] ); + Debug( LDAP_DEBUG_TRACE, "cldap_result abandoning id %d (to %s)\n", msgid, inet_ntoa( ((struct sockaddr_in *) - sb->sb_useaddr)->sin_addr ), 0 ); + ld->ld_cldapaddrs[i])->sin_addr ), 0 ); (void) ldap_abandon( ld, msgid ); } } @@ -415,25 +416,27 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res, static int cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, - LDAPMessage **res, char *base ) + LDAPMessage **res, const char *base ) { - unsigned long tag, len; - int baselen, slen, rc; + ber_tag_t tag; + ber_len_t len; + int baselen, slen; + ber_tag_t rc; char *dn, *p, *cookie; LDAPMessage *chain, *prev, *ldm; struct berval *bv; rc = LDAP_DECODING_ERROR; /* pessimistic */ - ldm = chain = prev = NULLMSG; + ldm = chain = prev = NULL; baselen = ( base == NULL ) ? 0 : strlen( base ); bv = NULL; for ( tag = ber_first_element( ber, &len, &cookie ); tag != LBER_DEFAULT && rc != LDAP_SUCCESS; tag = ber_next_element( ber, &len, cookie )) { - if (( ldm = (LDAPMessage *)calloc( 1, sizeof(LDAPMessage))) - == NULL || ( ldm->lm_ber = alloc_ber_with_options( ld )) - == NULLBER ) { + if (( ldm = (LDAPMessage *)LDAP_CALLOC( 1, sizeof(LDAPMessage))) + == NULL || ( ldm->lm_ber = ldap_alloc_ber_with_options( ld )) + == NULL ) { rc = LDAP_NO_MEMORY; break; /* return w/error*/ } @@ -448,8 +451,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, break; /* return w/error */ } - if ( ber_printf( ldm->lm_ber, "to", tag, bv->bv_val, - bv->bv_len ) == -1 ) { + if ( ber_printf( ldm->lm_ber, "tO", tag, bv ) == -1 ) { break; /* return w/error */ } ber_bvfree( bv ); @@ -457,7 +459,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, rc = LDAP_SUCCESS; } else if ( tag == LDAP_RES_SEARCH_ENTRY ) { - if ( ber_scanf( ber, "{aO", &dn, &bv ) == LBER_ERROR ) { + if ( ber_scanf( ber, "{aO" /*}*/, &dn, &bv ) == LBER_ERROR ) { break; /* return w/error */ } Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg entry %s\n", dn, 0, 0 ); @@ -466,14 +468,14 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, /* * substitute original searchbase for trailing '*' */ - if (( p = (char *)malloc( slen + baselen )) == NULL ) { + if (( p = (char *)LDAP_MALLOC( slen + baselen )) == NULL ) { rc = LDAP_NO_MEMORY; - free( dn ); + LDAP_FREE( dn ); break; /* return w/error */ } strcpy( p, dn ); strcpy( p + slen - 1, base ); - free( dn ); + LDAP_FREE( dn ); dn = p; } @@ -481,14 +483,17 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, bv->bv_len ) == -1 ) { break; /* return w/error */ } - free( dn ); + LDAP_FREE( dn ); ber_bvfree( bv ); bv = NULL; +#ifdef notyet + } else if ( tag == LDAP_RES_SEARCH_REFERENCE ) { +#endif } else { - Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %d\n", + Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %lu\n", tag, 0, 0 ); - rc = LDAP_PROTOCOL_ERROR; + rc = LDAP_DECODING_ERROR; break; /* return w/error */ } @@ -498,17 +503,17 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, #ifdef LDAP_DEBUG if ( ldap_debug & LDAP_DEBUG_PACKETS ) { - fprintf( stderr, "cldap_parsemsg add message id %d type %d:\n", - ldm->lm_msgid, ldm->lm_msgtype ); - ber_dump( ldm->lm_ber, 1 ); + fprintf( stderr, "cldap_parsemsg add message id %ld type %ld:\n", + (long) ldm->lm_msgid, (long) ldm->lm_msgtype ); + ber_log_dump( LDAP_DEBUG_BER, ldap_debug, ldm->lm_ber, 1 ); } #endif /* LDAP_DEBUG */ -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) { - add_result_to_cache( ld, ldm ); + ldap_add_result_to_cache( ld, ldm ); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ if ( chain == NULL ) { chain = ldm; @@ -521,10 +526,10 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, /* dispose of any leftovers */ if ( ldm != NULL ) { - if ( ldm->lm_ber != NULLBER ) { + if ( ldm->lm_ber != NULL ) { ber_free( ldm->lm_ber, 1 ); } - free( ldm ); + LDAP_FREE( ldm ); } if ( bv != NULL ) { ber_bvfree( bv ); @@ -532,6 +537,6 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber, /* return chain, calling result2error if we got anything at all */ *res = chain; - return(( *res == NULLMSG ) ? rc : ldap_result2error( ld, *res, 0 )); + return(( *res == NULL ) ? rc : ldap_result2error( ld, *res, 0 )); } -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ diff --git a/libraries/libldap/compare.c b/libraries/libldap/compare.c index 74388f1cea..e7ddcc70aa 100644 --- a/libraries/libldap/compare.c +++ b/libraries/libldap/compare.c @@ -1,94 +1,169 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * compare.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +/* The compare request looks like this: + * CompareRequest ::= SEQUENCE { + * entry DistinguishedName, + * ava SEQUENCE { + * type AttributeType, + * value AttributeValue + * } + * } + */ -#include -#include +#include "portable.h" -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ +#include -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include +#include -#include "lber.h" -#include "ldap.h" #include "ldap-int.h" /* - * ldap_compare - perform an ldap (and X.500) compare operation. The dn + * ldap_compare_ext - perform an ldap extended compare operation. The dn * of the entry to compare to and the attribute and value to compare (in * attr and value) are supplied. The msgid of the response is returned. * * Example: - * ldap_compare( ld, "c=us@cn=bob", "userPassword", "secret" ) + * struct berval bvalue = { "secret", strlen("secret") }; + * rc = ldap_compare( ld, "c=us@cn=bob", + * "userPassword", &bvalue, + * sctrl, cctrl, &msgid ) */ int -ldap_compare( LDAP *ld, char *dn, char *attr, char *value ) +ldap_compare_ext( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *attr, + struct berval *bvalue, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp ) { BerElement *ber; - /* The compare request looks like this: - * CompareRequest ::= SEQUENCE { - * entry DistinguishedName, - * ava SEQUENCE { - * type AttributeType, - * value AttributeValue - * } - * } - * and must be wrapped in an LDAPMessage. - */ - Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 ); + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( dn != NULL ); + assert( attr != NULL ); + assert( msgidp != NULL ); + /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { - return( -1 ); + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + return( LDAP_NO_MEMORY ); + } + + if ( ber_printf( ber, "{it{s{sO}}", /* '}' */ + ++ld->ld_msgid, + LDAP_REQ_COMPARE, dn, attr, &bvalue ) == -1 ) + { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return( ld->ld_errno ); + } + + /* Put Server Controls */ + if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + return ld->ld_errno; } - if ( ber_printf( ber, "{it{s{ss}}}", ++ld->ld_msgid, LDAP_REQ_COMPARE, - dn, attr, value ) == -1 ) { + if( ber_printf( ber, /*{*/ "}" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return( ld->ld_errno ); } -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) { - if ( check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) { + if ( ldap_check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) { ber_free( ber, 1 ); ld->ld_errno = LDAP_SUCCESS; - return( ld->ld_msgid ); + *msgidp = ld->ld_msgid; + return( ld->ld_errno ); } - add_request_to_cache( ld, LDAP_REQ_COMPARE, ber ); + ldap_add_request_to_cache( ld, LDAP_REQ_COMPARE, ber ); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber )); + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber ); + return ( *msgidp < 0 ? ld->ld_errno : LDAP_SUCCESS ); +} + +/* + * ldap_compare_ext - perform an ldap extended compare operation. The dn + * of the entry to compare to and the attribute and value to compare (in + * attr and value) are supplied. The msgid of the response is returned. + * + * Example: + * msgid = ldap_compare( ld, "c=us@cn=bob", "userPassword", "secret" ) + */ +int +ldap_compare( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *attr, + LDAP_CONST char *value ) +{ + int msgid; + struct berval bvalue; + + bvalue.bv_val = (char *) value; + bvalue.bv_len = (value == NULL) ? 0 : strlen( value ); + + return ldap_compare_ext( ld, dn, attr, &bvalue, NULL, NULL, &msgid ) == LDAP_SUCCESS + ? msgid : -1; } int -ldap_compare_s( LDAP *ld, char *dn, char *attr, char *value ) +ldap_compare_ext_s( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *attr, + struct berval *bvalue, + LDAPControl **sctrl, + LDAPControl **cctrl ) { + int rc; int msgid; LDAPMessage *res; - if ( (msgid = ldap_compare( ld, dn, attr, value )) == -1 ) - return( ld->ld_errno ); + rc = ldap_compare_ext( ld, dn, attr, bvalue, sctrl, cctrl, &msgid ); + + if ( rc != LDAP_SUCCESS ) + return( rc ); if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) return( ld->ld_errno ); return( ldap_result2error( ld, res, 1 ) ); } + +int +ldap_compare_s( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *attr, + LDAP_CONST char *value ) +{ + struct berval bvalue; + + bvalue.bv_val = (char *) value; + bvalue.bv_len = (value == NULL) ? 0 : strlen( value ); + + return ldap_compare_ext_s( ld, dn, attr, &bvalue, NULL, NULL ); +} diff --git a/libraries/libldap/controls.c b/libraries/libldap/controls.c new file mode 100644 index 0000000000..cc07664c90 --- /dev/null +++ b/libraries/libldap/controls.c @@ -0,0 +1,359 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +/* LDAPv3 Controls (RFC2251) + * + * Controls ::= SEQUENCE OF Control + * + * Control ::= SEQUENCE { + * controlType LDAPOID, + * criticality BOOLEAN DEFAULT FALSE, + * controlValue OCTET STRING OPTIONAL + * } + */ + +#include "portable.h" + +#include + +#include +#include + +#include "ldap-int.h" + + +/* + * ldap_int_put_controls + */ + +int +ldap_int_put_controls( + LDAP *ld, + LDAPControl *const *ctrls, + BerElement *ber ) +{ + LDAPControl *const *c; + + assert( ld != NULL ); + assert( ber != NULL ); + + if( ctrls == NULL ) { + /* use default server controls */ + ctrls = ld->ld_sctrls; + } + + if( ctrls == NULL || *ctrls == NULL ) { + return LDAP_SUCCESS; + } + + if ( ld->ld_version < LDAP_VERSION3 ) { + /* LDAPv2 doesn't support controls, + * error if any control is critical + */ + for( c = ctrls ; *c != NULL; c++ ) { + if( (*c)->ldctl_iscritical ) { + ld->ld_errno = LDAP_NOT_SUPPORTED; + return ld->ld_errno; + } + } + + return LDAP_SUCCESS; + } + + /* Controls are encoded as a sequence of sequences */ + if( ber_printf( ber, "t{"/*}*/, LDAP_TAG_CONTROLS ) == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + return ld->ld_errno; + } + + for( c = ctrls ; *c != NULL; c++ ) { + if ( ber_printf( ber, "{s" /*}*/, + (*c)->ldctl_oid ) == -1 ) + { + ld->ld_errno = LDAP_ENCODING_ERROR; + return ld->ld_errno; + } + + if( (*c)->ldctl_iscritical /* only if true */ + && ( ber_printf( ber, "b", + (ber_int_t) (*c)->ldctl_iscritical ) == -1 ) ) + { + ld->ld_errno = LDAP_ENCODING_ERROR; + return ld->ld_errno; + } + + if( (*c)->ldctl_value.bv_val != NULL /* only if we have a value */ + && ( ber_printf( ber, "O", + &((*c)->ldctl_value) ) == -1 ) ) + { + ld->ld_errno = LDAP_ENCODING_ERROR; + return ld->ld_errno; + } + + + if( ber_printf( ber, /*{*/"}" ) == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + return ld->ld_errno; + } + } + + + if( ber_printf( ber, /*{*/"}" ) == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + return ld->ld_errno; + } + + return LDAP_SUCCESS; +} + +int ldap_int_get_controls( + BerElement *ber, + LDAPControl ***ctrls ) +{ + int nctrls; + ber_tag_t tag; + ber_len_t len; + char *opaque; + + assert( ber != NULL ); + + if( ctrls == NULL ) { + return LDAP_SUCCESS; + } + *ctrls = NULL; + + len = ber_pvt_ber_remaining(ber); + + if( len == 0) { + /* no controls */ + return LDAP_SUCCESS; + } + + + if(( tag = ber_peek_tag( ber, &len )) != LDAP_TAG_CONTROLS ) { + if( tag == LBER_ERROR ) { + /* decoding error */ + return LDAP_DECODING_ERROR; + } + + /* ignore unexpected input */ + return LDAP_SUCCESS; + } + + /* set through each element */ + nctrls = 0; + *ctrls = LDAP_MALLOC( 1 * sizeof(LDAPControl *) ); + + if( *ctrls == NULL ) { + return LDAP_NO_MEMORY; + } + + ctrls[nctrls] = NULL; + + for( tag = ber_first_element( ber, &len, &opaque ); + tag != LBER_ERROR; + tag = ber_next_element( ber, &len, opaque ) ) + { + LDAPControl *tctrl; + LDAPControl **tctrls; + + tctrl = LDAP_CALLOC( 1, sizeof(LDAPControl) ); + + /* allocate pointer space for current controls (nctrls) + * + this control + extra NULL + */ + tctrls = (tctrl == NULL) ? NULL : + LDAP_REALLOC(*ctrls, (nctrls+2) * sizeof(LDAPControl *)); + + if( tctrls == NULL ) { + /* one of the above allocation failed */ + + if( tctrl != NULL ) { + LDAP_FREE( tctrl ); + } + + ldap_controls_free(*ctrls); + *ctrls = NULL; + + return LDAP_NO_MEMORY; + } + + + tctrls[nctrls++] = tctrl; + tctrls[nctrls] = NULL; + + tag = ber_scanf( ber, "{a" /*}*/, &tctrl->ldctl_oid ); + + if( tag != LBER_ERROR ) { + tag = ber_peek_tag( ber, &len ); + } + + if( tag == LBER_BOOLEAN ) { + ber_int_t crit; + tag = ber_scanf( ber, "b", &crit ); + tctrl->ldctl_iscritical = crit ? (char) 0 : (char) ~0; + } + + if( tag != LBER_ERROR ) { + tag = ber_peek_tag( ber, &len ); + } + + if( tag == LBER_OCTETSTRING ) { + tag = ber_scanf( ber, "o", &tctrl->ldctl_value ); + + } else { + tctrl->ldctl_value.bv_val = NULL; + } + + if( tag == LBER_ERROR ) { + *ctrls = NULL; + ldap_controls_free( tctrls ); + return LDAP_DECODING_ERROR; + } + + *ctrls = tctrls; + } + + return LDAP_SUCCESS; +} + +/* + * Free a LDAPControl + */ +void +ldap_control_free( LDAPControl *c ) +{ + assert( c != NULL ); + + if ( c != NULL ) { + if( c->ldctl_oid != NULL) { + LDAP_FREE( c->ldctl_oid ); + } + + if( c->ldctl_value.bv_val != NULL ) { + LDAP_FREE( c->ldctl_value.bv_val ); + } + + LDAP_FREE( c ); + } +} + +/* + * Free an array of LDAPControl's + */ +void +ldap_controls_free( LDAPControl **controls ) +{ + assert( controls != NULL ); + + if ( controls != NULL ) { + int i; + + for( i=0; controls[i] != NULL; i++) { + ldap_control_free( controls[i] ); + } + + LDAP_FREE( controls ); + } +} + +/* + * Duplicate an array of LDAPControl + */ +LDAPControl ** +ldap_controls_dup( LDAPControl *const *controls ) +{ + LDAPControl **new; + int i; + + if ( controls == NULL ) { + return NULL; + } + + /* count the controls */ + for(i=0; controls[i] != NULL; i++) /* empty */ ; + + if( i < 1 ) { + /* no controls to duplicate */ + return NULL; + } + + new = (LDAPControl **) LDAP_MALLOC( i * sizeof(LDAPControl *) ); + + if( new == NULL ) { + /* memory allocation failure */ + return NULL; + } + + /* duplicate the controls */ + for(i=0; controls[i] != NULL; i++) { + new[i] = ldap_control_dup( controls[i] ); + + if( new[i] == NULL ) { + ldap_controls_free( new ); + return NULL; + } + } + + new[i] = NULL; + + return new; +} + +/* + * Duplicate a LDAPControl + */ +LDAPControl * +ldap_control_dup( const LDAPControl *c ) +{ + LDAPControl *new; + + if ( c == NULL ) { + return NULL; + } + + new = (LDAPControl *) LDAP_MALLOC( sizeof(LDAPControl) ); + + if( new == NULL ) { + return NULL; + } + + if( c->ldctl_oid != NULL ) { + new->ldctl_oid = LDAP_STRDUP( c->ldctl_oid ); + + if(new->ldctl_oid == NULL) { + LDAP_FREE( new ); + return NULL; + } + + } else { + new->ldctl_oid = NULL; + } + + if( c->ldctl_value.bv_len > 0 ) { + new->ldctl_value.bv_val = (char *) LDAP_MALLOC( c->ldctl_value.bv_len ); + + if(new->ldctl_value.bv_val == NULL) { + if(new->ldctl_oid != NULL) { + LDAP_FREE( new->ldctl_oid ); + } + LDAP_FREE( new ); + return NULL; + } + + SAFEMEMCPY( new->ldctl_value.bv_val, c->ldctl_value.bv_val, + c->ldctl_value.bv_len ); + + new->ldctl_value.bv_len = c->ldctl_value.bv_len; + + } else { + new->ldctl_value.bv_len = 0; + new->ldctl_value.bv_val = NULL; + } + + new->ldctl_iscritical = c->ldctl_iscritical; + return new; +} diff --git a/libraries/libldap/delete.c b/libraries/libldap/delete.c index 47e240ea6a..6d463e17f6 100644 --- a/libraries/libldap/delete.c +++ b/libraries/libldap/delete.c @@ -1,79 +1,108 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * delete.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif - -#include -#include +/* + * A delete request looks like this: + * DelRequet ::= DistinguishedName, + */ -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ +#include "portable.h" -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ +#include -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include +#include -#include "lber.h" -#include "ldap.h" #include "ldap-int.h" /* - * ldap_delete - initiate an ldap (and X.500) delete operation. Parameters: + * ldap_delete_ext - initiate an ldap extended delete operation. Parameters: * * ld LDAP descriptor * dn DN of the object to delete + * sctrls Server Controls + * cctrls Client Controls + * msgidp Message Id Pointer * * Example: - * msgid = ldap_delete( ld, dn ); + * rc = ldap_delete( ld, dn, sctrls, cctrls, msgidp ); */ int -ldap_delete( LDAP *ld, char *dn ) +ldap_delete_ext( + LDAP *ld, + LDAP_CONST char* dn, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp ) { BerElement *ber; - /* - * A delete request looks like this: - * DelRequet ::= DistinguishedName, - */ - Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 ); + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( dn != NULL ); + assert( msgidp != NULL ); + /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { - return( -1 ); + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + ld->ld_errno = LDAP_NO_MEMORY; + return( ld->ld_errno ); } - if ( ber_printf( ber, "{its}", ++ld->ld_msgid, LDAP_REQ_DELETE, dn ) - == -1 ) { + if ( ber_printf( ber, "{its", /* '}' */ + ++ld->ld_msgid, LDAP_REQ_DELETE, dn ) == -1 ) + { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return( ld->ld_errno ); + } + + /* Put Server Controls */ + if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + return ld->ld_errno; + } + + if ( ber_printf( ber, /*{*/ "}" ) == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return( ld->ld_errno ); } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_DELETE, dn, ber )); -} + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_DELETE, dn, ber ); + + if(*msgidp < 0) + return ld->ld_errno; + return LDAP_SUCCESS; +} int -ldap_delete_s( LDAP *ld, char *dn ) +ldap_delete_ext_s( + LDAP *ld, + LDAP_CONST char *dn, + LDAPControl **sctrls, + LDAPControl **cctrls ) { - int msgid; + int msgid; + int rc; LDAPMessage *res; - if ( (msgid = ldap_delete( ld, dn )) == -1 ) + rc = ldap_delete_ext( ld, dn, sctrls, cctrls, &msgid ); + + if( rc != LDAP_SUCCESS ) return( ld->ld_errno ); if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) @@ -81,3 +110,34 @@ ldap_delete_s( LDAP *ld, char *dn ) return( ldap_result2error( ld, res, 1 ) ); } +/* + * ldap_delete - initiate an ldap (and X.500) delete operation. Parameters: + * + * ld LDAP descriptor + * dn DN of the object to delete + * + * Example: + * msgid = ldap_delete( ld, dn ); + */ +int +ldap_delete( LDAP *ld, LDAP_CONST char *dn ) +{ + int msgid; + + /* + * A delete request looks like this: + * DelRequet ::= DistinguishedName, + */ + + Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 ); + + return ldap_delete_ext( ld, dn, NULL, NULL, &msgid ) == LDAP_SUCCESS + ? msgid : -1 ; +} + + +int +ldap_delete_s( LDAP *ld, LDAP_CONST char *dn ) +{ + return ldap_delete_ext_s( ld, dn, NULL, NULL ); +} diff --git a/libraries/libldap/digest.c b/libraries/libldap/digest.c index e3c784b3e9..69aa80c120 100644 --- a/libraries/libldap/digest.c +++ b/libraries/libldap/digest.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/disptmpl.c b/libraries/libldap/disptmpl.c index be418309e9..40c2b77343 100644 --- a/libraries/libldap/disptmpl.c +++ b/libraries/libldap/disptmpl.c @@ -1,4 +1,9 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1993, 1994 Regents of the University of Michigan. * All rights reserved. * @@ -13,56 +18,42 @@ * 7 March 1994 by Mark C Smith */ +#include "portable.h" + #include -#include -#include -#include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include + +#include + +#include +#include +#include +#include + +#ifdef HAVE_SYS_FILE_H #include -#ifndef VMS -#include -#endif /* VMS */ -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" +#endif + +#include "ldap-int.h" #include "disptmpl.h" -#ifndef NEEDPROTOS -static void free_disptmpl(); -static int read_next_tmpl(); -int next_line_tokens(); -void free_strarray(); -#else /* !NEEDPROTOS */ -static void free_disptmpl( struct ldap_disptmpl *tmpl ); -static int read_next_tmpl( char **bufp, long *blenp, - struct ldap_disptmpl **tmplp, int dtversion ); -int next_line_tokens( char **bufp, long *blenp, char ***toksp ); -void free_strarray( char **sap ); -#endif /* !NEEDPROTOS */ - -static char *tmploptions[] = { +static void free_disptmpl LDAP_P(( struct ldap_disptmpl *tmpl )); +static int read_next_tmpl LDAP_P(( char **bufp, ber_len_t *blenp, + struct ldap_disptmpl **tmplp, int dtversion )); + +static const char *const tmploptions[] = { "addable", "modrdn", "altview", NULL }; -static unsigned long tmploptvals[] = { +static const unsigned long tmploptvals[] = { LDAP_DTMPL_OPT_ADDABLE, LDAP_DTMPL_OPT_ALLOWMODRDN, LDAP_DTMPL_OPT_ALTVIEW, }; -static char *itemtypes[] = { +static const char *const itemtypes[] = { "cis", "mls", "dn", "bool", "jpeg", "jpegbtn", "fax", "faxbtn", "audiobtn", @@ -72,7 +63,7 @@ static char *itemtypes[] = { NULL }; -static unsigned long itemsynids[] = { +static const unsigned long itemsynids[] = { LDAP_SYN_CASEIGNORESTR, LDAP_SYN_MULTILINESTR, LDAP_SYN_DN, LDAP_SYN_BOOLEAN, LDAP_SYN_JPEGIMAGE, LDAP_SYN_JPEGBUTTON, LDAP_SYN_FAXIMAGE, LDAP_SYN_FAXBUTTON, LDAP_SYN_AUDIOBUTTON, @@ -82,7 +73,7 @@ static unsigned long itemsynids[] = { }; -static char *itemoptions[] = { +static const char *const itemoptions[] = { "ro", "sort", "1val", "hide", "required", "hideiffalse", @@ -90,7 +81,7 @@ static char *itemoptions[] = { }; -static unsigned long itemoptvals[] = { +static const unsigned long itemoptvals[] = { LDAP_DITEM_OPT_READONLY, LDAP_DITEM_OPT_SORTVALUES, LDAP_DITEM_OPT_SINGLEVALUED, LDAP_DITEM_OPT_HIDEIFEMPTY, LDAP_DITEM_OPT_VALUEREQUIRED, LDAP_DITEM_OPT_HIDEIFFALSE, @@ -109,7 +100,7 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp ) long rlen, len; int rc, eof; - *tmpllistp = NULLDISPTMPL; + *tmpllistp = NULL; if (( fp = fopen( file, "r" )) == NULL ) { return( LDAP_TMPL_ERR_FILE ); @@ -127,7 +118,7 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp ) return( LDAP_TMPL_ERR_FILE ); } - if (( buf = malloc( (size_t)len )) == NULL ) { + if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) { fclose( fp ); return( LDAP_TMPL_ERR_MEM ); } @@ -137,26 +128,26 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp ) fclose( fp ); if ( rlen != len && !eof ) { /* error: didn't get the whole file */ - free( buf ); + LDAP_FREE( buf ); return( LDAP_TMPL_ERR_FILE ); } rc = ldap_init_templates_buf( buf, rlen, tmpllistp ); - free( buf ); + LDAP_FREE( buf ); return( rc ); } int -ldap_init_templates_buf( char *buf, long buflen, +ldap_init_templates_buf( char *buf, ber_len_t buflen, struct ldap_disptmpl **tmpllistp ) { - int rc, version; + int rc=-1, version; char **toks; struct ldap_disptmpl *prevtmpl, *tmpl; - *tmpllistp = prevtmpl = NULLDISPTMPL; + *tmpllistp = prevtmpl = NULL; if ( next_line_tokens( &buf, &buflen, &toks ) != 2 || strcasecmp( toks[ 0 ], "version" ) != 0 ) { @@ -170,8 +161,8 @@ ldap_init_templates_buf( char *buf, long buflen, } while ( buflen > 0 && ( rc = read_next_tmpl( &buf, &buflen, &tmpl, - version )) == 0 && tmpl != NULLDISPTMPL ) { - if ( prevtmpl == NULLDISPTMPL ) { + version )) == 0 && tmpl != NULL ) { + if ( prevtmpl == NULL ) { *tmpllistp = tmpl; } else { prevtmpl->dt_next = tmpl; @@ -207,27 +198,27 @@ free_disptmpl( struct ldap_disptmpl *tmpl ) { if ( tmpl != NULL ) { if ( tmpl->dt_name != NULL ) { - free( tmpl->dt_name ); + LDAP_FREE( tmpl->dt_name ); } if ( tmpl->dt_pluralname != NULL ) { - free( tmpl->dt_pluralname ); + LDAP_FREE( tmpl->dt_pluralname ); } if ( tmpl->dt_iconname != NULL ) { - free( tmpl->dt_iconname ); + LDAP_FREE( tmpl->dt_iconname ); } if ( tmpl->dt_authattrname != NULL ) { - free( tmpl->dt_authattrname ); + LDAP_FREE( tmpl->dt_authattrname ); } if ( tmpl->dt_defrdnattrname != NULL ) { - free( tmpl->dt_defrdnattrname ); + LDAP_FREE( tmpl->dt_defrdnattrname ); } if ( tmpl->dt_defaddlocation != NULL ) { - free( tmpl->dt_defaddlocation ); + LDAP_FREE( tmpl->dt_defaddlocation ); } if ( tmpl->dt_oclist != NULL ) { @@ -236,7 +227,7 @@ free_disptmpl( struct ldap_disptmpl *tmpl ) for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = nextocp ) { nextocp = ocp->oc_next; free_strarray( ocp->oc_objclasses ); - free( ocp ); + LDAP_FREE( ocp ); } } @@ -246,12 +237,12 @@ free_disptmpl( struct ldap_disptmpl *tmpl ) for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = nextadp ) { nextadp = adp->ad_next; if( adp->ad_attrname != NULL ) { - free( adp->ad_attrname ); + LDAP_FREE( adp->ad_attrname ); } if( adp->ad_value != NULL ) { - free( adp->ad_value ); + LDAP_FREE( adp->ad_value ); } - free( adp ); + LDAP_FREE( adp ); } } @@ -263,20 +254,20 @@ free_disptmpl( struct ldap_disptmpl *tmpl ) for ( colp = rowp; colp != NULL; colp = nextcolp ) { nextcolp = colp->ti_next_in_row; if ( colp->ti_attrname != NULL ) { - free( colp->ti_attrname ); + LDAP_FREE( colp->ti_attrname ); } if ( colp->ti_label != NULL ) { - free( colp->ti_label ); + LDAP_FREE( colp->ti_label ); } if ( colp->ti_args != NULL ) { free_strarray( colp->ti_args ); } - free( colp ); + LDAP_FREE( colp ); } } } - free( tmpl ); + LDAP_FREE( tmpl ); } } @@ -292,7 +283,7 @@ struct ldap_disptmpl * ldap_next_disptmpl( struct ldap_disptmpl *tmpllist, struct ldap_disptmpl *tmpl ) { - return( tmpl == NULLDISPTMPL ? tmpl : tmpl->dt_next ); + return( tmpl == NULL ? tmpl : tmpl->dt_next ); } @@ -301,14 +292,14 @@ ldap_name2template( char *name, struct ldap_disptmpl *tmpllist ) { struct ldap_disptmpl *dtp; - for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULLDISPTMPL; + for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULL; dtp = ldap_next_disptmpl( tmpllist, dtp )) { if ( strcasecmp( name, dtp->dt_name ) == 0 ) { return( dtp ); } } - return( NULLDISPTMPL ); + return( NULL ); } @@ -320,12 +311,12 @@ ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist ) int i, j, needcnt, matchcnt; if ( tmpllist == NULL || oclist == NULL || oclist[ 0 ] == NULL ) { - return( NULLDISPTMPL ); + return( NULL ); } - for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULLDISPTMPL; + for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULL; dtp = ldap_next_disptmpl( tmpllist, dtp )) { - for ( oclp = dtp->dt_oclist; oclp != NULLOCLIST; + for ( oclp = dtp->dt_oclist; oclp != NULL; oclp = oclp->oc_next ) { needcnt = matchcnt = 0; for ( i = 0; oclp->oc_objclasses[ i ] != NULL; ++i ) { @@ -344,7 +335,7 @@ ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist ) } } - return( NULLDISPTMPL ); + return( NULL ); } @@ -358,7 +349,7 @@ ldap_first_tmplrow( struct ldap_disptmpl *tmpl ) struct ldap_tmplitem * ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row ) { - return( row == NULLTMPLITEM ? row : row->ti_next_in_col ); + return( row == NULL ? row : row->ti_next_in_col ); } @@ -373,7 +364,7 @@ struct ldap_tmplitem * ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, struct ldap_tmplitem *col ) { - return( col == NULLTMPLITEM ? col : col->ti_next_in_row ); + return( col == NULL ? col : col->ti_next_in_row ); } @@ -391,15 +382,15 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, attrcnt = 0; memerr = 0; - if (( attrs = (char **)malloc( sizeof( char * ))) == NULL ) { + if (( attrs = (char **)LDAP_MALLOC( sizeof( char * ))) == NULL ) { return( NULL ); } if ( includeattrs != NULL ) { for ( i = 0; !memerr && includeattrs[ i ] != NULL; ++i ) { - if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) * + if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) * sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] = - strdup( includeattrs[ i ] )) == NULL ) { + LDAP_STRDUP( includeattrs[ i ] )) == NULL ) { memerr = 1; } else { attrs[ attrcnt ] = NULL; @@ -408,10 +399,10 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, } for ( tirowp = ldap_first_tmplrow( tmpl ); - !memerr && tirowp != NULLTMPLITEM; + !memerr && tirowp != NULL; tirowp = ldap_next_tmplrow( tmpl, tirowp )) { for ( ticolp = ldap_first_tmplcol( tmpl, tirowp ); - ticolp != NULLTMPLITEM; + ticolp != NULL; ticolp = ldap_next_tmplcol( tmpl, tirowp, ticolp )) { if ( syntaxmask != 0 ) { @@ -424,9 +415,9 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, } if ( ticolp->ti_attrname != NULL ) { - if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) * + if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) * sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] = - strdup( ticolp->ti_attrname )) == NULL ) { + LDAP_STRDUP( ticolp->ti_attrname )) == NULL ) { memerr = 1; } else { attrs[ attrcnt ] = NULL; @@ -438,11 +429,11 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, if ( memerr || attrcnt == 0 ) { for ( i = 0; i < attrcnt; ++i ) { if ( attrs[ i ] != NULL ) { - free( attrs[ i ] ); + LDAP_FREE( attrs[ i ] ); } } - free( (char *)attrs ); + LDAP_FREE( (char *)attrs ); return( NULL ); } @@ -451,15 +442,15 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, static int -read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, +read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, int dtversion ) { int i, j, tokcnt, samerow, adsource; char **toks, *itemopts; struct ldap_disptmpl *tmpl; - struct ldap_oclist *ocp, *prevocp; - struct ldap_adddeflist *adp, *prevadp; - struct ldap_tmplitem *rowp, *ip, *previp; + struct ldap_oclist *ocp, *prevocp = NULL; + struct ldap_adddeflist *adp, *prevadp = NULL; + struct ldap_tmplitem *rowp = NULL, *ip, *previp = NULL; *tmplp = NULL; @@ -471,13 +462,13 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, return( tokcnt == 0 ? 0 : LDAP_TMPL_ERR_SYNTAX ); } - if (( tmpl = (struct ldap_disptmpl *)calloc( 1, + if (( tmpl = (struct ldap_disptmpl *)LDAP_CALLOC( 1, sizeof( struct ldap_disptmpl ))) == NULL ) { free_strarray( toks ); return( LDAP_TMPL_ERR_MEM ); } tmpl->dt_name = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * template plural name comes next @@ -488,7 +479,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, return( LDAP_TMPL_ERR_SYNTAX ); } tmpl->dt_pluralname = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * template icon name is next @@ -499,7 +490,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, return( LDAP_TMPL_ERR_SYNTAX ); } tmpl->dt_iconname = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * template options come next @@ -522,7 +513,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, * object class list is next */ while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) { - if (( ocp = (struct ldap_oclist *)calloc( 1, + if (( ocp = (struct ldap_oclist *)LDAP_CALLOC( 1, sizeof( struct ldap_oclist ))) == NULL ) { free_strarray( toks ); free_disptmpl( tmpl ); @@ -552,9 +543,9 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, if ( toks[ 0 ][ 0 ] != '\0' ) { tmpl->dt_authattrname = toks[ 0 ]; } else { - free( toks[ 0 ] ); + LDAP_FREE( toks[ 0 ] ); } - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * read default attribute to use for RDN @@ -565,7 +556,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, return( LDAP_TMPL_ERR_SYNTAX ); } tmpl->dt_defrdnattrname = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * read default location for new entries @@ -578,9 +569,9 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, if ( toks[ 0 ][ 0 ] != '\0' ) { tmpl->dt_defaddlocation = toks[ 0 ]; } else { - free( toks[ 0 ] ); + LDAP_FREE( toks[ 0 ] ); } - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * read list of rules used to define default values for new entries @@ -601,7 +592,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, return( LDAP_TMPL_ERR_SYNTAX ); } - if (( adp = (struct ldap_adddeflist *)calloc( 1, + if (( adp = (struct ldap_adddeflist *)LDAP_CALLOC( 1, sizeof( struct ldap_adddeflist ))) == NULL ) { free_strarray( toks ); free_disptmpl( tmpl ); @@ -612,8 +603,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, if ( adsource == LDAP_ADSRC_CONSTANTVALUE ) { adp->ad_value = toks[ 2 ]; } - free( toks[ 0 ] ); - free( (char *)toks ); + LDAP_FREE( toks[ 0 ] ); + LDAP_FREE( (char *)toks ); if ( tmpl->dt_adddeflist == NULL ) { tmpl->dt_adddeflist = adp; @@ -635,7 +626,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, return( LDAP_TMPL_ERR_SYNTAX ); } - if (( ip = (struct ldap_tmplitem *)calloc( 1, + if (( ip = (struct ldap_tmplitem *)LDAP_CALLOC( 1, sizeof( struct ldap_tmplitem ))) == NULL ) { free_strarray( toks ); free_disptmpl( tmpl ); @@ -671,13 +662,13 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, return( LDAP_TMPL_ERR_SYNTAX ); } - free( toks[ 0 ] ); - free( toks[ 1 ] ); + LDAP_FREE( toks[ 0 ] ); + LDAP_FREE( toks[ 1 ] ); ip->ti_syntaxid = itemsynids[ i ]; ip->ti_label = toks[ 2 ]; if ( toks[ 3 ][ 0 ] == '\0' ) { ip->ti_attrname = NULL; - free( toks[ 3 ] ); + LDAP_FREE( toks[ 3 ] ); } else { ip->ti_attrname = toks[ 3 ]; } @@ -685,7 +676,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, for ( i = 0; toks[ i + 4 ] != NULL; ++i ) { ; } - if (( ip->ti_args = (char **) calloc( i + 1, sizeof( char * ))) + if (( ip->ti_args = (char **) LDAP_CALLOC( i + 1, sizeof( char * ))) == NULL ) { free_disptmpl( tmpl ); return( LDAP_TMPL_ERR_MEM ); @@ -694,7 +685,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, ip->ti_args[ i ] = toks[ i + 4 ]; } } - free( (char *)toks ); + LDAP_FREE( (char *)toks ); if ( tmpl->dt_items == NULL ) { tmpl->dt_items = rowp = ip; diff --git a/libraries/libldap/dn.c b/libraries/libldap/dn.c new file mode 100644 index 0000000000..fc1c6ead88 --- /dev/null +++ b/libraries/libldap/dn.c @@ -0,0 +1,339 @@ +/* dn.c - routines for dealing with distinguished names */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" + +#if 0 +/* this should wait for UTF-8 routines */ + +#define B4LEADTYPE 0 +#define B4TYPE 1 +#define INOIDTYPE 2 +#define INKEYTYPE 3 +#define B4EQUAL 4 +#define B4VALUE 5 +#define INVALUE 6 +#define INQUOTEDVALUE 7 +#define B4SEPARATOR 8 + +/* + * ldap_dn_normalize - put dn into a canonical format + * and return it. + */ + +char * +ldap_dn_normalize( const char *dn ) +{ + char *d, *s; + int state, gotesc; + char *ndn; + + if( dn == NULL ) { + return NULL; + } + + ndn = LDAP_STRDUP( dn ); + + if( ndn == NULL ) { + return NULL; + } + + gotesc = 0; + state = B4LEADTYPE; + for ( d = s = ndn; *s; s++ ) { + switch ( state ) { + case B4LEADTYPE: + case B4TYPE: + if ( LDAP_LEADOIDCHAR(*s) ) { + state = INOIDTYPE; + *d++ = *s; + } else if ( LDAP_LEADKEYCHAR(*s) ) { + state = INKEYTYPE; + *d++ = *s; + } else if ( ! LDAP_SPACE( *s ) ) { + dn = NULL; + state = INKEYTYPE; + *d++ = *s; + } + break; + + case INOIDTYPE: + if ( LDAP_OIDCHAR(*s) ) { + *d++ = *s; + } else if ( *s == '=' ) { + state = B4VALUE; + *d++ = *s; + } else if ( LDAP_SPACE( *s ) ) { + state = B4EQUAL; + } else { + dn = NULL; + *d++ = *s; + } + break; + + case INKEYTYPE: + if ( LDAP_KEYCHAR(*s) ) { + *d++ = *s; + } else if ( *s == '=' ) { + state = B4VALUE; + *d++ = *s; + } else if ( LDAP_SPACE( *s ) ) { + state = B4EQUAL; + } else { + dn = NULL; + *d++ = *s; + } + break; + + case B4EQUAL: + if ( *s == '=' ) { + state = B4VALUE; + *d++ = *s; + } else if ( ! LDAP_SPACE( *s ) ) { + /* not a valid dn - but what can we do here? */ + *d++ = *s; + dn = NULL; + } + break; + + case B4VALUE: + if ( *s == '"' ) { + state = INQUOTEDVALUE; + *d++ = *s; + } else if ( ! LDAP_SPACE( *s ) ) { + state = INVALUE; + *d++ = *s; + } + break; + + case INVALUE: + if ( !gotesc && LDAP_SEPARATOR( *s ) ) { + while ( LDAP_SPACE( *(d - 1) ) ) + d--; + state = B4TYPE; + if ( *s == '+' ) { + *d++ = *s; + } else { + *d++ = ','; + } + } else if ( gotesc && !LDAP_NEEDSESCAPE( *s ) && + !LDAP_SEPARATOR( *s ) ) { + *--d = *s; + d++; + } else { + *d++ = *s; + } + break; + + case INQUOTEDVALUE: + if ( !gotesc && *s == '"' ) { + state = B4SEPARATOR; + *d++ = *s; + } else if ( gotesc && !LDAP_NEEDSESCAPE( *s ) ) { + *--d = *s; + d++; + } else { + *d++ = *s; + } + break; + case B4SEPARATOR: + if ( LDAP_SEPARATOR( *s ) ) { + state = B4TYPE; + *d++ = *s; + } + break; + default: + dn = NULL; + Debug( LDAP_DEBUG_ANY, + "dn_normalize - unknown state %d\n", state, 0, 0 ); + break; + } + if ( *s == '\\' ) { + gotesc = 1; + } else { + gotesc = 0; + } + } + *d = '\0'; + + if( gotesc ) { + /* shouldn't be left in escape */ + dn = NULL; + } + + /* check end state */ + switch( state ) { + case B4LEADTYPE: /* looking for first type */ + case B4SEPARATOR: /* looking for separator */ + case INVALUE: /* inside value */ + break; + default: + dn = NULL; + } + + if( dn == NULL ) { + return( ndn ); + ndn = NULL; + } + + return( ndn ); +} + +/* + * ldap_dn_parent - return a copy of the dn of dn's parent + */ + +char * +ldap_dn_parent( + const char *dn +) +{ + const char *s; + int inquote; + + if( dn == NULL ) { + return NULL; + } + + while(*dn && LDAP_SPACE(*dn)) { + dn++; + } + + if( *dn == '\0' ) { + return( NULL ); + } + + /* + * no =, assume it is a dns name, like blah@some.domain.name + * if the blah@ part is there, return some.domain.name. if + * it's just some.domain.name, return domain.name. + */ + if ( strchr( dn, '=' ) == NULL ) { + if ( (s = strchr( dn, '@' )) == NULL ) { + if ( (s = strchr( dn, '.' )) == NULL ) { + return( NULL ); + } + } + if ( *(s + 1) == '\0' ) { + return( NULL ); + } else { + return( LDAP_STRDUP( &s[1] ) ); + } + } + + /* + * else assume it is an X.500-style name, which looks like + * foo=bar,sha=baz,... + */ + + inquote = 0; + for ( s = dn; *s; s++ ) { + if ( *s == '\\' ) { + if ( *(s + 1) ) { + s++; + } + continue; + } + if ( inquote ) { + if ( *s == '"' ) { + inquote = 0; + } + } else { + if ( *s == '"' ) { + inquote = 1; + } else if ( LDAP_DNSEPARATOR( *s ) ) { + return( LDAP_STRDUP( &s[1] ) ); + } + } + } + + return( LDAP_STRDUP( "" ) ); +} + +char * ldap_dn_rdn( + const char *dn ) +{ + char *s; + char *rdn; + int inquote; + + if( dn == NULL ) { + return NULL; + } + + while(*dn && LDAP_SPACE(*dn)) { + dn++; + } + + if( *dn == '\0' ) { + return( NULL ); + } + + rdn = LDAP_STRDUP( dn ); + + if( rdn == NULL ) { + return NULL; + } + +#ifdef DNS_DN + /* + * no =, assume it is a dns name, like blah@some.domain.name + * if the blah@ part is there, return some.domain.name. if + * it's just some.domain.name, return domain.name. + */ + if ( strchr( rdn, '=' ) == NULL ) { + if ( (s = strchr( rdn, '@' )) == NULL ) { + if ( (s = strchr( rdn, '.' )) == NULL ) { + return( rdn ); + } + } + *s = '\0'; + return( rdn ); + } +#endif + + /* + * else assume it is an X.500-style name, which looks like + * foo=bar,sha=baz,... + */ + + inquote = 0; + + for ( s = rdn; *s; s++ ) { + if ( *s == '\\' ) { + if ( *(s + 1) ) { + s++; + } + continue; + } + if ( inquote ) { + if ( *s == '"' ) { + inquote = 0; + } + } else { + if ( *s == '"' ) { + inquote = 1; + } else if ( LDAP_DNSEPARATOR( *s ) ) { + *s = '\0'; + return( rdn ); + } + } + } + + return( rdn ); +} + +#endif diff --git a/libraries/libldap/dsparse.c b/libraries/libldap/dsparse.c index 1771d7283e..336025db55 100644 --- a/libraries/libldap/dsparse.c +++ b/libraries/libldap/dsparse.c @@ -1,4 +1,9 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1993, 1994 Regents of the University of Michigan. * All rights reserved. * @@ -15,42 +20,28 @@ * 7 March 1994 by Mark C Smith */ +#include "portable.h" + #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include +#include + +#include +#include +#include + +#ifdef HAVE_SYS_FILE_H #include -#include -#endif /* DOS */ -#endif /* MACOS */ +#endif -#include "lber.h" -#include "ldap.h" +#include "ldap-int.h" -#ifndef NEEDPROTOS -int next_line_tokens(); -void free_strarray(); -static int next_line(); -static char *next_token(); -#else /* !NEEDPROTOS */ -int next_line_tokens( char **bufp, long *blenp, char ***toksp ); -void free_strarray( char **sap ); -static int next_line( char **bufp, long *blenp, char **linep ); -static char *next_token( char ** sp ); -#endif /* !NEEDPROTOS */ +static int next_line LDAP_P(( char **bufp, ber_len_t *blenp, char **linep )); +static char *next_token LDAP_P(( char ** sp )); int -next_line_tokens( char **bufp, long *blenp, char ***toksp ) +next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp ) { char *p, *line, *token, **toks; int rc, tokcnt; @@ -61,18 +52,18 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp ) return( rc ); } - if (( toks = (char **)calloc( 1, sizeof( char * ))) == NULL ) { - free( line ); + if (( toks = (char **)LDAP_CALLOC( 1, sizeof( char * ))) == NULL ) { + LBER_FREE( line ); return( -1 ); } tokcnt = 0; p = line; while (( token = next_token( &p )) != NULL ) { - if (( toks = (char **)realloc( toks, ( tokcnt + 2 ) * + if (( toks = (char **)LDAP_REALLOC( toks, ( tokcnt + 2 ) * sizeof( char * ))) == NULL ) { - free( (char *)toks ); - free( line ); + LBER_FREE( (char *)toks ); + LBER_FREE( line ); return( -1 ); } toks[ tokcnt ] = token; @@ -85,11 +76,11 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp ) toks = NULL; } - free( line ); + LBER_FREE( line ); if ( tokcnt == 0 ) { if ( toks != NULL ) { - free( (char *)toks ); + LBER_FREE( (char *)toks ); } } else { *toksp = toks; @@ -100,10 +91,10 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp ) static int -next_line( char **bufp, long *blenp, char **linep ) +next_line( char **bufp, ber_len_t *blenp, char **linep ) { char *linestart, *line, *p; - long plen; + ber_slen_t plen; linestart = *bufp; p = *bufp; @@ -141,7 +132,7 @@ next_line( char **bufp, long *blenp, char **linep ) return( 0 ); /* end of file */ } - if (( line = malloc( p - linestart )) == NULL ) { + if (( line = LDAP_MALLOC( p - linestart )) == NULL ) { *linep = NULL; return( -1 ); /* fatal error */ } @@ -165,7 +156,7 @@ next_token( char **sp ) p = *sp; - while ( isspace( *p )) { /* skip leading white space */ + while ( isspace( (unsigned char) *p )) { /* skip leading white space */ ++p; } @@ -180,7 +171,7 @@ next_token( char **sp ) t = tokstart = p; for ( ;; ) { - if ( *p == '\0' || ( isspace( *p ) && !in_quote )) { + if ( *p == '\0' || ( isspace( (unsigned char) *p ) && !in_quote )) { if ( *p != '\0' ) { ++p; } @@ -202,7 +193,7 @@ next_token( char **sp ) return( NULL ); } - return( strdup( tokstart )); + return( LDAP_STRDUP( tokstart )); } @@ -213,8 +204,8 @@ free_strarray( char **sap ) if ( sap != NULL ) { for ( i = 0; sap[ i ] != NULL; ++i ) { - free( sap[ i ] ); + LBER_FREE( sap[ i ] ); } - free( (char *)sap ); + LBER_FREE( (char *)sap ); } } diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index ad1bcd7710..ff15bfe462 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/extended.c b/libraries/libldap/extended.c new file mode 100644 index 0000000000..e284b485fd --- /dev/null +++ b/libraries/libldap/extended.c @@ -0,0 +1,267 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +/* + * LDAPv3 Extended Operation Request + * ExtendedRequest ::= [APPLICATION 23] SEQUENCE { + * requestName [0] LDAPOID, + * requestValue [1] OCTET STRING OPTIONAL + * } + * + * LDAPv3 Extended Operation Response + * ExtendedResponse ::= [APPLICATION 24] SEQUENCE { + * COMPONENTS OF LDAPResult, + * responseName [10] LDAPOID OPTIONAL, + * response [11] OCTET STRING OPTIONAL + * } + * + */ + +#include "portable.h" + +#include +#include + +#include +#include +#include + +#include "ldap-int.h" + +int +ldap_extended_operation( + LDAP *ld, + LDAP_CONST char *reqoid, + struct berval *reqdata, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp ) +{ + BerElement *ber; + int rc; + + Debug( LDAP_DEBUG_TRACE, "ldap_extended_operation\n", 0, 0, 0 ); + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( reqoid != NULL || *reqoid == '\0' ); + assert( msgidp != NULL ); + + /* must be version 3 (or greater) */ + if ( ld->ld_version < LDAP_VERSION3 ) { + ld->ld_errno = LDAP_NOT_SUPPORTED; + return( ld->ld_errno ); + } + + if( reqoid == NULL || *reqoid == '\0' || msgidp == NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + return( ld->ld_errno ); + } + + /* create a message to send */ + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + ld->ld_errno = LDAP_NO_MEMORY; + return( ld->ld_errno ); + } + + if ( reqdata != NULL ) { + rc = ber_printf( ber, "{it{tstO}", /* '}' */ + ++ld->ld_msgid, LDAP_REQ_EXTENDED, + LDAP_TAG_EXOP_REQ_OID, reqoid, + LDAP_TAG_EXOP_REQ_VALUE, reqdata ); + + } else { + rc = ber_printf( ber, "{it{ts}", /* '}' */ + ++ld->ld_msgid, LDAP_REQ_EXTENDED, + LDAP_TAG_EXOP_REQ_OID, reqoid ); + } + + if( rc == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return( ld->ld_errno ); + } + + /* Put Server Controls */ + if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + return ld->ld_errno; + } + + if ( ber_printf( ber, /*{*/ "}" ) == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return( ld->ld_errno ); + } + + /* send the message */ + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_EXTENDED, NULL, ber ); + + return( *msgidp < 0 ? ld->ld_errno : LDAP_SUCCESS ); +} + +int +ldap_extended_operation_s( + LDAP *ld, + LDAP_CONST char *reqoid, + struct berval *reqdata, + LDAPControl **sctrls, + LDAPControl **cctrls, + char **retoidp, + struct berval **retdatap ) +{ + int rc; + int msgid; + LDAPMessage *res; + + Debug( LDAP_DEBUG_TRACE, "ldap_extended_operation_s\n", 0, 0, 0 ); + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( reqoid != NULL || *reqoid == '\0' ); + assert( retoidp != NULL || retdatap != NULL ); + + if( retoidp == NULL || retdatap == NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + return( ld->ld_errno ); + } + + rc = ldap_extended_operation( ld, reqoid, reqdata, + sctrls, cctrls, &msgid ); + + if ( rc != LDAP_SUCCESS ) { + return( rc ); + } + + if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) { + return( ld->ld_errno ); + } + + *retoidp = NULL; + *retdatap = NULL; + + rc = ldap_parse_extended_result( ld, res, retoidp, retdatap, 0 ); + + if( rc != LDAP_SUCCESS ) { + ldap_msgfree( res ); + return rc; + } + + return( ldap_result2error( ld, res, 1 ) ); +} + +/* Parse an extended result */ +int +ldap_parse_extended_result ( + LDAP *ld, + LDAPMessage *res, + char **retoidp, + struct berval **retdatap, + int freeit ) +{ + BerElement *ber; + ber_tag_t rc; + ber_tag_t tag; + ber_len_t len; + struct berval *resdata; + ber_int_t errcode; + char *resoid; + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( res != NULL ); + + Debug( LDAP_DEBUG_TRACE, "ldap_parse_extended_result\n", 0, 0, 0 ); + + if( ld->ld_version < LDAP_VERSION3 ) { + ld->ld_errno = LDAP_NOT_SUPPORTED; + return ld->ld_errno; + } + + if( res->lm_msgtype == LDAP_RES_EXTENDED ) { + ld->ld_errno = LDAP_PARAM_ERROR; + return ld->ld_errno; + } + + if( retoidp != NULL ) *retoidp = NULL; + if( retdatap != NULL ) *retdatap = NULL; + + ber = ber_dup( res->lm_ber ); + + if ( ld->ld_error ) { + LDAP_FREE( ld->ld_error ); + ld->ld_error = NULL; + } + + if ( ld->ld_matched ) { + LDAP_FREE( ld->ld_matched ); + ld->ld_matched = NULL; + } + + rc = ber_scanf( ber, "{iaa" /*}*/, &errcode, + &ld->ld_matched, &ld->ld_matched ); + + if( rc == LBER_ERROR ) { + ld->ld_errno = LDAP_DECODING_ERROR; + ber_free( ber, 0 ); + return ld->ld_errno; + } + + resoid = NULL; + resdata = NULL; + + tag = ber_peek_tag( ber, &len ); + + if( tag == LDAP_TAG_REFERRAL ) { + /* skip over referral */ + tag = ber_scanf( ber, "x" ); + + if( tag != LBER_ERROR ) { + tag = ber_peek_tag( ber, &len ); + } + } + + if( tag == LDAP_TAG_EXOP_RES_OID ) { + /* we have a resoid */ + if( ber_scanf( ber, "a", &resoid ) == LBER_ERROR ) { + ld->ld_errno = LDAP_DECODING_ERROR; + ber_free( ber, 0 ); + return ld->ld_errno; + } + + tag = ber_peek_tag( ber, &len ); + } + + if( tag == LDAP_TAG_EXOP_RES_VALUE ) { + /* we have a resdata */ + if( ber_scanf( ber, "O", &resoid ) == LBER_ERROR ) { + ld->ld_errno = LDAP_DECODING_ERROR; + ber_free( ber, 0 ); + if( resoid != NULL ) LDAP_FREE( resoid ); + return ld->ld_errno; + } + } + + if( retoidp != NULL ) { + *retoidp = resoid; + } else { + LDAP_FREE( resoid ); + } + + if( retdatap != NULL ) { + *retdatap = resdata; + } else { + ber_bvfree( resdata ); + } + + ld->ld_errno = errcode; + + if( freeit ) { + ldap_msgfree( res ); + } + + return LDAP_SUCCESS; +} diff --git a/libraries/libldap/free.c b/libraries/libldap/free.c index d7a13228e6..120e1605b0 100644 --- a/libraries/libldap/free.c +++ b/libraries/libldap/free.c @@ -1,4 +1,9 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1994 The Regents of the University of Michigan. * All rights reserved. * @@ -6,29 +11,55 @@ * link in lots of extra code when not using certain features */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1994 The Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif - +#include "portable.h" #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" +#include + +#include +#include +#include + +#include "ldap-int.h" + +/* + * C-API deallocator + */ +void +ldap_memfree( void *p ) +{ + LDAP_FREE( p ); +} + +void +ldap_memvfree( void **v ) +{ + LDAP_VFREE( v ); +} + +void * +ldap_memalloc( ber_len_t s ) +{ + return LDAP_MALLOC( s ); +} + +void * +ldap_memcalloc( ber_len_t n, ber_len_t s ) +{ + return LDAP_CALLOC( n, s ); +} + +void * +ldap_memrealloc( void* p, ber_len_t s ) +{ + return LDAP_REALLOC( p, s ); +} + +char * +ldap_strdup( LDAP_CONST char *p ) +{ + return LDAP_STRDUP( p ); +} void ldap_getfilter_free( LDAPFiltDesc *lfdp ) @@ -39,31 +70,31 @@ ldap_getfilter_free( LDAPFiltDesc *lfdp ) for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = nextflp ) { for ( fip = flp->lfl_ilist; fip != NULL; fip = nextfip ) { nextfip = fip->lfi_next; - free( fip->lfi_filter ); - free( fip->lfi_desc ); - free( fip ); + LDAP_FREE( fip->lfi_filter ); + LDAP_FREE( fip->lfi_desc ); + LDAP_FREE( fip ); } nextflp = flp->lfl_next; - free( flp->lfl_pattern ); - free( flp->lfl_delims ); - free( flp->lfl_tag ); - free( flp ); + LDAP_FREE( flp->lfl_pattern ); + LDAP_FREE( flp->lfl_delims ); + LDAP_FREE( flp->lfl_tag ); + LDAP_FREE( flp ); } if ( lfdp->lfd_curvalcopy != NULL ) { - free( lfdp->lfd_curvalcopy ); + LDAP_FREE( lfdp->lfd_curvalcopy ); } if ( lfdp->lfd_curvalwords != NULL ) { - free( lfdp->lfd_curvalwords ); + LDAP_FREE( lfdp->lfd_curvalwords ); } if ( lfdp->lfd_filtprefix != NULL ) { - free( lfdp->lfd_filtprefix ); + LDAP_FREE( lfdp->lfd_filtprefix ); } if ( lfdp->lfd_filtsuffix != NULL ) { - free( lfdp->lfd_filtsuffix ); + LDAP_FREE( lfdp->lfd_filtsuffix ); } - free( lfdp ); + LDAP_FREE( lfdp ); } /* @@ -82,13 +113,21 @@ ldap_mods_free( LDAPMod **mods, int freemods ) for ( i = 0; mods[i] != NULL; i++ ) { if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) { - ber_bvecfree( mods[i]->mod_bvalues ); - } else { - ldap_value_free( mods[i]->mod_values ); + if( mods[i]->mod_bvalues != NULL ) + ber_bvecfree( mods[i]->mod_bvalues ); + + } else if( mods[i]->mod_values != NULL ) { + LDAP_VFREE( mods[i]->mod_values ); } - free( (char *) mods[i] ); + + if ( mods[i]->mod_type != NULL ) { + LDAP_FREE( mods[i]->mod_type ); + } + + LDAP_FREE( (char *) mods[i] ); } - if ( freemods ) - free( (char *) mods ); + if ( freemods ) { + LDAP_FREE( (char *) mods ); + } } diff --git a/libraries/libldap/friendly.c b/libraries/libldap/friendly.c index 5d77f0be1c..ec37982a70 100644 --- a/libraries/libldap/friendly.c +++ b/libraries/libldap/friendly.c @@ -1,38 +1,33 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * friendly.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#endif /* MACOS */ - -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#endif /* DOS */ - -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#include -#endif - -#include "lber.h" -#include "ldap.h" +#include + +#include +#include +#include +#include +#include + +#include "ldap-int.h" char * -ldap_friendly_name( char *filename, char *uname, FriendlyMap **map ) +ldap_friendly_name( + LDAP_CONST char *filename, + /* LDAP_CONST */ char *uname, + LDAPFriendlyMap **map ) { int i, entries; FILE *fp; @@ -40,9 +35,7 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map ) char buf[BUFSIZ]; if ( map == NULL ) { -#if !defined( MACOS ) && !defined( DOS ) errno = EINVAL; -#endif return( uname ); } @@ -57,8 +50,8 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map ) } rewind( fp ); - if ( (*map = (FriendlyMap *) malloc( (entries + 1) * - sizeof(FriendlyMap) )) == NULL ) { + if ( (*map = (LDAPFriendlyMap *) LDAP_MALLOC( (entries + 1) * + sizeof(LDAPFriendlyMap) )) == NULL ) { fclose( fp ); return( uname ); } @@ -94,37 +87,37 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map ) } } - (*map)[i].f_unfriendly = strdup( buf ); - (*map)[i].f_friendly = strdup( s ); + (*map)[i].lf_unfriendly = LDAP_STRDUP( buf ); + (*map)[i].lf_friendly = LDAP_STRDUP( s ); i++; } fclose( fp ); - (*map)[i].f_unfriendly = NULL; + (*map)[i].lf_unfriendly = NULL; } - for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) { - if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 ) - return( (*map)[i].f_friendly ); + for ( i = 0; (*map)[i].lf_unfriendly != NULL; i++ ) { + if ( strcasecmp( uname, (*map)[i].lf_unfriendly ) == 0 ) + return( (*map)[i].lf_friendly ); } return( uname ); } void -ldap_free_friendlymap( FriendlyMap **map ) +ldap_free_friendlymap( LDAPFriendlyMap **map ) { - struct friendly* pF = *map; + LDAPFriendlyMap* pF = *map; if ( pF == NULL ) return; - while ( pF->f_unfriendly ) + while ( pF->lf_unfriendly ) { - free( pF->f_unfriendly ); - free( pF->f_friendly ); + LDAP_FREE( pF->lf_unfriendly ); + LDAP_FREE( pF->lf_friendly ); pF++; } - free( *map ); + LDAP_FREE( *map ); *map = NULL; } diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index 50caa774c5..079db4b9f3 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -1,42 +1,41 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * getattr.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" +#include + +#include +#include +#include +#include + #include "ldap-int.h" char * ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber ) { - long len; + char *attr; Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 ); - if ( (*ber = alloc_ber_with_options( ld )) == NULLBER ) { + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( ber != NULL ); + + if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + *ber = NULL; return( NULL ); } @@ -48,33 +47,36 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber ) * positioned right before the next attribute type/value sequence. */ - len = LDAP_MAX_ATTR_LEN; - if ( ber_scanf( *ber, "{x{{sx}", ld->ld_attrbuffer, &len ) + if ( ber_scanf( *ber, "{x{{ax}" /*}}*/, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; ber_free( *ber, 0 ); + *ber = NULL; return( NULL ); } - return( ld->ld_attrbuffer ); + return( attr ); } /* ARGSUSED */ char * ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber ) { - long len; + char *attr; Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 ); + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( ber != NULL ); + /* skip sequence, snarf attribute type, skip values */ - len = LDAP_MAX_ATTR_LEN; - if ( ber_scanf( ber, "{sx}", ld->ld_attrbuffer, &len ) + if ( ber_scanf( ber, "{ax}", &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; - ber_free( ber, 0 ); return( NULL ); } - return( ld->ld_attrbuffer ); + return( attr ); } diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index 2ea0d037c4..0110e298e7 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -1,32 +1,29 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1994 Regents of the University of Michigan. * All rights reserved. * * getdn.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" + +static char **explode_name( const char *name, int notypes, int is_dn ); char * ldap_get_dn( LDAP *ld, LDAPMessage *entry ) @@ -42,7 +39,7 @@ ldap_get_dn( LDAP *ld, LDAPMessage *entry ) } tmp = *entry->lm_ber; /* struct copy */ - if ( ber_scanf( &tmp, "{a", &dn ) == LBER_ERROR ) { + if ( ber_scanf( &tmp, "{a" /*}*/, &dn ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -51,17 +48,25 @@ ldap_get_dn( LDAP *ld, LDAPMessage *entry ) } char * -ldap_dn2ufn( char *dn ) +ldap_dn2ufn( LDAP_CONST char *dn ) { char *p, *ufn, *r; int state; Debug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 ); - if ( ldap_is_dns_dn( dn ) || ( p = strchr( dn, '=' )) == NULL ) - return( strdup( dn )); + if( dn == NULL ) { + return NULL; + } + + if ( ldap_is_dns_dn( dn ) || + ( p = strchr( dn, '=' ) ) == NULL ) + { + return( LDAP_STRDUP( dn ) ); + } + - ufn = strdup( ++p ); + ufn = LDAP_STRDUP( ++p ); #define INQUOTE 1 #define OUTQUOTE 2 @@ -97,8 +102,8 @@ ldap_dn2ufn( char *dn ) char *rsave = r; *r-- = '\0'; - while ( !isspace( *r ) && *r != ';' - && *r != ',' && r > ufn ) + while ( !isspace( (unsigned char) *r ) + && *r != ';' && *r != ',' && r > ufn ) r--; r++; @@ -124,47 +129,75 @@ ldap_dn2ufn( char *dn ) } char ** -ldap_explode_dns( char *dn ) +ldap_explode_dns( LDAP_CONST char *dn_in ) { - int ncomps, maxcomps; char *s; char **rdns; + char *tok_r; + char *dn; - if ( (rdns = (char **) malloc( 8 * sizeof(char *) )) == NULL ) { + int ncomps; + int maxcomps = 8; + + if ( (dn = LDAP_STRDUP( dn_in )) == NULL ) { + return( NULL ); + } + + if ( (rdns = (char **) LDAP_MALLOC( maxcomps * sizeof(char *) )) == NULL ) { + LDAP_FREE( dn ); return( NULL ); } - maxcomps = 8; ncomps = 0; - for ( s = strtok( dn, "@." ); s != NULL; s = strtok( NULL, "@." ) ) { + for ( s = ldap_pvt_strtok( dn, "@.", &tok_r ); s != NULL; + s = ldap_pvt_strtok( NULL, "@.", &tok_r ) ) + { if ( ncomps == maxcomps ) { maxcomps *= 2; - if ( (rdns = (char **) realloc( rdns, maxcomps * - sizeof(char *) )) == NULL ) { - return( NULL ); + if ( (rdns = (char **) LDAP_REALLOC( rdns, maxcomps * + sizeof(char *) )) == NULL ) + { + LDAP_FREE( dn ); + return NULL; } } - rdns[ncomps++] = strdup( s ); + rdns[ncomps++] = LDAP_STRDUP( s ); } + LDAP_FREE(dn); + rdns[ncomps] = NULL; + /* trim rdns */ + rdns = (char **) LDAP_REALLOC( rdns, (ncomps+1) * sizeof(char*) ); return( rdns ); } char ** -ldap_explode_dn( char *dn, int notypes ) +ldap_explode_dn( LDAP_CONST char *dn, int notypes ) { - char *p, *q, *rdnstart, **rdns = NULL; - int state, count = 0, endquote, len; - Debug( LDAP_DEBUG_TRACE, "ldap_explode_dn\n", 0, 0, 0 ); if ( ldap_is_dns_dn( dn ) ) { return( ldap_explode_dns( dn ) ); } + return explode_name( dn, notypes, 1 ); +} - rdnstart = dn; - p = dn-1; +char ** +ldap_explode_rdn( LDAP_CONST char *rdn, int notypes ) +{ + Debug( LDAP_DEBUG_TRACE, "ldap_explode_rdn\n", 0, 0, 0 ); + return explode_name( rdn, notypes, 0 ); +} + +static char ** +explode_name( const char *name, int notypes, int is_dn ) +{ + const char *p, *q; + char **parts = NULL; + int state, count = 0, endquote, len; + + p = name-1; state = OUTQUOTE; do { @@ -181,33 +214,41 @@ ldap_explode_dn( char *dn, int notypes ) else state = INQUOTE; break; + case '+': + if (!is_dn) + goto end_part; + break; case ';': case ',': + if (!is_dn) + break; + goto end_part; case '\0': + end_part: if ( state == OUTQUOTE ) { ++count; - if ( rdns == NULL ) { - if (( rdns = (char **)malloc( 8 + if ( parts == NULL ) { + if (( parts = (char **)LDAP_MALLOC( 8 * sizeof( char *))) == NULL ) return( NULL ); } else if ( count >= 8 ) { - if (( rdns = (char **)realloc( rdns, + if (( parts = (char **)LDAP_REALLOC( parts, (count+1) * sizeof( char *))) == NULL ) return( NULL ); } - rdns[ count ] = NULL; + parts[ count ] = NULL; endquote = 0; if ( notypes ) { - for ( q = rdnstart; + for ( q = name; q < p && *q != '='; ++q ) { ; } if ( q < p ) { - rdnstart = ++q; + name = ++q; } - if ( *rdnstart == '"' ) { - ++rdnstart; + if ( *name == '"' ) { + ++name; } if ( *(p-1) == '"' ) { @@ -216,12 +257,12 @@ ldap_explode_dn( char *dn, int notypes ) } } - len = p - rdnstart; - if (( rdns[ count-1 ] = (char *)calloc( 1, + len = p - name; + if (( parts[ count-1 ] = (char *)LDAP_CALLOC( 1, len + 1 )) != NULL ) { - SAFEMEMCPY( rdns[ count-1 ], rdnstart, + SAFEMEMCPY( parts[ count-1 ], name, len ); - rdns[ count-1 ][ len ] = '\0'; + parts[ count-1 ][ len ] = '\0'; } /* @@ -232,38 +273,24 @@ ldap_explode_dn( char *dn, int notypes ) if ( endquote == 1 ) p++; - rdnstart = *p ? p + 1 : p; - while ( isspace( *rdnstart )) - ++rdnstart; + name = *p ? p + 1 : p; + while ( isascii( *name ) && isspace( *name ) ) + ++name; } break; } } while ( *p ); - return( rdns ); + return( parts ); } int -ldap_is_dns_dn( char *dn ) +ldap_is_dns_dn( LDAP_CONST char *dn ) { - return( dn[ 0 ] != '\0' && strchr( dn, '=' ) == NULL && - strchr( dn, ',' ) == NULL ); -} - - -#if defined( ultrix ) || defined( NeXT ) - -char *strdup( char *s ) -{ - char *p; - - if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL ) - return( NULL ); - - strcpy( p, s ); - - return( p ); + return( dn[ 0 ] != '\0' + && strchr( dn, '=' ) == NULL + && strchr( dn, ',' ) == NULL + && strchr( dn, ';' ) == NULL ); } -#endif /* ultrix */ diff --git a/libraries/libldap/getdxbyname.c b/libraries/libldap/getdxbyname.c index 4543e88e45..602721a05e 100644 --- a/libraries/libldap/getdxbyname.c +++ b/libraries/libldap/getdxbyname.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -123,7 +124,7 @@ decode_answer( unsigned char *answer, ber_len_t len ) rr_len = _getshort( p ); p += INT16SZ; if ( class == C_IN && type == T_TXT ) { - int i, n, pref, txt_len; + int pref, txt_len; char *q, *r; q = (char *)p; diff --git a/libraries/libldap/getentry.c b/libraries/libldap/getentry.c index f3f896e7b8..09721f1d8e 100644 --- a/libraries/libldap/getentry.c +++ b/libraries/libldap/getentry.c @@ -1,60 +1,133 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * getentry.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" +#include + +#include +#include +#include +#include + +#include "ldap-int.h" /* ARGSUSED */ LDAPMessage * ldap_first_entry( LDAP *ld, LDAPMessage *chain ) { - return( chain == NULLMSG || chain->lm_msgtype == LDAP_RES_SEARCH_RESULT - ? NULLMSG : chain ); + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( chain != NULL ); + + if( ld == NULL || chain == NULL ) { + return NULL; + } + + return chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY + ? chain + : ldap_next_entry( ld, chain ); } -/* ARGSUSED */ -LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry ) +LDAPMessage * +ldap_next_entry( LDAP *ld, LDAPMessage *entry ) { - if ( entry == NULLMSG || entry->lm_chain == NULLMSG - || entry->lm_chain->lm_msgtype == LDAP_RES_SEARCH_RESULT ) - return( NULLMSG ); + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); - return( entry->lm_chain ); + if ( ld == NULL || entry == NULL ) { + return NULL; + } + + for ( + entry = entry->lm_chain; + entry != NULL; + entry = entry->lm_chain ) + { + if( entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) { + return( entry ); + } + } + + return( NULL ); } -/* ARGSUSED */ int ldap_count_entries( LDAP *ld, LDAPMessage *chain ) { int i; - for ( i = 0; chain != NULL && chain->lm_msgtype - != LDAP_RES_SEARCH_RESULT; chain = chain->lm_chain ) - i++; + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + + if ( ld == NULL ) { + return -1; + } + + for ( i = 0; chain != NULL; chain = chain->lm_chain ) { + if( chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) { + i++; + } + } return( i ); } + +int +ldap_get_entry_controls( + LDAP *ld, + LDAPMessage *entry, + LDAPControl ***sctrls ) +{ + int rc; + BerElement be; + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( sctrls != NULL ); + + if ( ld == NULL || sctrls == NULL || + entry == NULL || entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY ) + { + return LDAP_PARAM_ERROR; + } + + /* make a local copy of the BerElement */ + SAFEMEMCPY(&be, entry->lm_ber, sizeof(be)); + + if ( ber_scanf( &be, "{xx" /*}*/ ) == LBER_ERROR ) { + rc = LDAP_DECODING_ERROR; + goto cleanup_and_return; + } + + rc = ldap_int_get_controls( &be, sctrls ); + +cleanup_and_return: + if( rc != LDAP_SUCCESS ) { + ld->ld_errno = rc; + + if( ld->ld_matched != NULL ) { + LDAP_FREE( ld->ld_matched ); + ld->ld_matched = NULL; + } + + if( ld->ld_error != NULL ) { + LDAP_FREE( ld->ld_error ); + ld->ld_error = NULL; + } + } + + return rc; +} diff --git a/libraries/libldap/getfilter.c b/libraries/libldap/getfilter.c index b0a181a8ef..efafeb5067 100644 --- a/libraries/libldap/getfilter.c +++ b/libraries/libldap/getfilter.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -243,17 +244,17 @@ ldap_getfirstfilter( for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) { /* compile tagpat, continue if we fail */ - if (regcomp(&re, tagpat, 0) != 0) + if (regcomp(&re, tagpat, REG_EXTENDED|REG_NOSUB) != 0) continue; - /* match tagpatern and tag, continue if we fail */ + /* match tagpattern and tag, continue if we fail */ rc = regexec(&re, flp->lfl_tag, 0, NULL, 0); regfree(&re); if (rc != 0) continue; /* compile flp->ifl_pattern, continue if we fail */ - if (regcomp(&re, flp->lfl_pattern, 0) != 0) + if (regcomp(&re, flp->lfl_pattern, REG_EXTENDED|REG_NOSUB) != 0) continue; /* match ifl_pattern and lfd_curval, continue if we fail */ diff --git a/libraries/libldap/getvalues.c b/libraries/libldap/getvalues.c index 55102be8ab..a5d5f0ee9d 100644 --- a/libraries/libldap/getvalues.c +++ b/libraries/libldap/getvalues.c @@ -1,49 +1,47 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * getvalues.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include -#include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" char ** -ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target ) +ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) { BerElement ber; - char attr[LDAP_MAX_ATTR_LEN]; + char *attr; int found = 0; - long len; char **vals; + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( target != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 ); ber = *entry->lm_ber; /* skip sequence, dn, sequence of, and snag the first attr */ - len = sizeof(attr); - if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) { + if ( ber_scanf( &ber, "{x{{a" /*}}}*/, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -53,16 +51,22 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target ) /* break out on success, return out on error */ while ( ! found ) { - len = sizeof(attr); - if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) { + LDAP_FREE(attr); + attr = NULL; + + if ( ber_scanf( &ber, /*{*/ "x}{a" /*}*/, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } if ( strcasecmp( target, attr ) == 0 ) break; + } + LDAP_FREE(attr); + attr = NULL; + /* * if we get this far, we've found the attribute and are sitting * just before the set of values. @@ -77,21 +81,24 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target ) } struct berval ** -ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target ) +ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) { BerElement ber; - char attr[LDAP_MAX_ATTR_LEN]; + char *attr; int found = 0; - long len; struct berval **vals; + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( target != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 ); ber = *entry->lm_ber; /* skip sequence, dn, sequence of, and snag the first attr */ - len = sizeof(attr); - if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) { + if ( ber_scanf( &ber, "{x{{a" /* }}} */, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -101,8 +108,10 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target ) /* break out on success, return out on error */ while ( ! found ) { - len = sizeof(attr); - if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) { + LDAP_FREE( attr ); + attr = NULL; + + if ( ber_scanf( &ber, /*{*/ "x}{a" /*}*/, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -111,6 +120,9 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target ) break; } + LDAP_FREE( attr ); + attr = NULL; + /* * if we get this far, we've found the attribute and are sitting * just before the set of values. @@ -147,25 +159,11 @@ ldap_count_values_len( struct berval **vals ) void ldap_value_free( char **vals ) { - int i; - - if ( vals == NULL ) - return; - for ( i = 0; vals[i] != NULL; i++ ) - free( vals[i] ); - free( (char *) vals ); + LDAP_VFREE( vals ); } void ldap_value_free_len( struct berval **vals ) { - int i; - - if ( vals == NULL ) - return; - for ( i = 0; vals[i] != NULL; i++ ) { - free( vals[i]->bv_val ); - free( vals[i] ); - } - free( (char *) vals ); + ber_bvecfree( vals ); } diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index 8546a348e0..69ffdec8ef 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/kbind.c b/libraries/libldap/kbind.c index ce4a8a7f6d..731a8b5fc6 100644 --- a/libraries/libldap/kbind.c +++ b/libraries/libldap/kbind.c @@ -1,39 +1,49 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1993 Regents of the University of Michigan. * All rights reserved. * * kbind.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; +/* + * BindRequest ::= SEQUENCE { + * version INTEGER, + * name DistinguishedName, -- who + * authentication CHOICE { + * simple [0] OCTET STRING -- passwd +#ifdef HAVE_KERBEROS + * krbv42ldap [1] OCTET STRING + * krbv42dsa [2] OCTET STRING #endif + * sasl [3] SaslCredentials -- LDAPv3 + * } + * } + * + * BindResponse ::= SEQUENCE { + * COMPONENTS OF LDAPResult, + * serverSaslCreds OCTET STRING OPTIONAL -- LDAPv3 + * } + * + */ -#ifdef KERBEROS +#include "portable.h" + +#ifdef HAVE_KERBEROS #include -#include - -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include "msdos.h" -#endif /* DOS */ -#include -#include -#if !defined(DOS) && !defined( _WIN32 ) -#include -#endif /* !DOS && !_WIN32 */ -#include -#include -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" -#include "ldap-int.h" +#include +#include +#include +#include +#include + +#include "ldap-int.h" /* @@ -47,42 +57,29 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of * ldap_kerberos_bind1( ld, "cn=manager, o=university of michigan, c=us" ) */ int -ldap_kerberos_bind1( LDAP *ld, char *dn ) +ldap_kerberos_bind1( LDAP *ld, LDAP_CONST char *dn ) { BerElement *ber; char *cred; - int rc, credlen; - char *get_kerberosv4_credentials(); + int rc; + ber_len_t credlen; #ifdef STR_TRANSLATION int str_translation_on; #endif /* STR_TRANSLATION */ - /* - * The bind request looks like this: - * BindRequest ::= SEQUENCE { - * version INTEGER, - * name DistinguishedName, - * authentication CHOICE { - * krbv42ldap [1] OCTET STRING - * krbv42dsa [2] OCTET STRING - * } - * } - * all wrapped up in an LDAPMessage sequence. - */ - Debug( LDAP_DEBUG_TRACE, "ldap_kerberos_bind1\n", 0, 0, 0 ); if ( dn == NULL ) dn = ""; - if ( (cred = get_kerberosv4_credentials( ld, dn, "ldapserver", + if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "ldapserver", &credlen )) == NULL ) { return( -1 ); /* ld_errno should already be set */ } /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { - free( cred ); + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + LDAP_FREE( cred ); return( -1 ); } @@ -104,26 +101,26 @@ ldap_kerberos_bind1( LDAP *ld, char *dn ) #endif /* STR_TRANSLATION */ if ( rc == -1 ) { - free( cred ); + LDAP_FREE( cred ); ber_free( ber, 1 ); ld->ld_errno = LDAP_ENCODING_ERROR; return( -1 ); } - free( cred ); + LDAP_FREE( cred ); -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) { ldap_flush_cache( ld ); } -#endif /* !NO_CACHE */ +#endif /* !LDAP_NOCACHE */ /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); } int -ldap_kerberos_bind1_s( LDAP *ld, char *dn ) +ldap_kerberos_bind1_s( LDAP *ld, LDAP_CONST char *dn ) { int msgid; LDAPMessage *res; @@ -154,12 +151,12 @@ ldap_kerberos_bind1_s( LDAP *ld, char *dn ) * ldap_kerberos_bind2( ld, "cn=manager, o=university of michigan, c=us" ) */ int -ldap_kerberos_bind2( LDAP *ld, char *dn ) +ldap_kerberos_bind2( LDAP *ld, LDAP_CONST char *dn ) { BerElement *ber; char *cred; - int rc, credlen; - char *get_kerberosv4_credentials(); + int rc; + ber_len_t credlen; #ifdef STR_TRANSLATION int str_translation_on; #endif /* STR_TRANSLATION */ @@ -169,14 +166,14 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) if ( dn == NULL ) dn = ""; - if ( (cred = get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen )) + if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen )) == NULL ) { return( -1 ); /* ld_errno should already be set */ } /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { - free( cred ); + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + LDAP_FREE( cred ); return( -1 ); } @@ -198,7 +195,7 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) } #endif /* STR_TRANSLATION */ - free( cred ); + LDAP_FREE( cred ); if ( rc == -1 ) { ber_free( ber, 1 ); @@ -207,12 +204,12 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); } /* synchronous bind to DSA using kerberos */ int -ldap_kerberos_bind2_s( LDAP *ld, char *dn ) +ldap_kerberos_bind2_s( LDAP *ld, LDAP_CONST char *dn ) { int msgid; LDAPMessage *res; @@ -234,7 +231,7 @@ ldap_kerberos_bind2_s( LDAP *ld, char *dn ) /* synchronous bind to ldap and DSA using kerberos */ int -ldap_kerberos_bind_s( LDAP *ld, char *dn ) +ldap_kerberos_bind_s( LDAP *ld, LDAP_CONST char *dn ) { int err; @@ -249,45 +246,45 @@ ldap_kerberos_bind_s( LDAP *ld, char *dn ) #ifndef AUTHMAN /* - * get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. + * ldap_get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. * The dn of the entry to which to bind is supplied. It's assumed the * user already has a tgt. */ char * -get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) +ldap_get_kerberosv4_credentials( + LDAP *ld, + LDAP_CONST char *who, + LDAP_CONST char *service, + ber_len_t *len ) { KTEXT_ST ktxt; int err; char realm[REALM_SZ], *cred, *krbinstance; - Debug( LDAP_DEBUG_TRACE, "get_kerberosv4_credentials\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_kerberosv4_credentials\n", 0, 0, 0 ); if ( (err = krb_get_tf_realm( tkt_string(), realm )) != KSUCCESS ) { -#ifndef NO_USERINTERFACE +#ifdef LDAP_LIBUI fprintf( stderr, "krb_get_tf_realm failed (%s)\n", krb_err_txt[err] ); -#endif /* NO_USERINTERFACE */ +#endif /* LDAP_LIBUI */ ld->ld_errno = LDAP_INVALID_CREDENTIALS; return( NULL ); } -#ifdef LDAP_REFERRALS krbinstance = ld->ld_defconn->lconn_krbinstance; -#else /* LDAP_REFERRALS */ - krbinstance = ld->ld_host; -#endif /* LDAP_REFERRALS */ if ( (err = krb_mk_req( &ktxt, service, krbinstance, realm, 0 )) != KSUCCESS ) { -#ifndef NO_USERINTERFACE +#ifdef LDAP_LIBUI fprintf( stderr, "krb_mk_req failed (%s)\n", krb_err_txt[err] ); -#endif /* NO_USERINTERFACE */ +#endif /* LDAP_LIBUI */ ld->ld_errno = LDAP_INVALID_CREDENTIALS; return( NULL ); } - if ( ( cred = malloc( ktxt.length )) == NULL ) { + if ( ( cred = LDAP_MALLOC( ktxt.length )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( NULL ); } @@ -299,4 +296,4 @@ get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) } #endif /* !AUTHMAN */ -#endif /* KERBEROS */ +#endif /* HAVE_KERBEROS */ diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index e9146db127..ab446da5a9 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -299,7 +300,8 @@ void ldap_int_utils_init LDAP_P(( void )); /* * in print.c */ -int ldap_log_printf LDAP_P((LDAP *ld, int level, const char *fmt, ...)); +int ldap_log_printf LDAP_P((LDAP *ld, int level, const char *fmt, ...)) + LDAP_GCCATTR((format(printf, 3, 4))); /* * in cache.c diff --git a/libraries/libldap/ldap.conf b/libraries/libldap/ldap.conf new file mode 100644 index 0000000000..1d1b786be7 --- /dev/null +++ b/libraries/libldap/ldap.conf @@ -0,0 +1,17 @@ +# $OpenLDAP$ +# +# LDAP Defaults +# + +# See ldap.conf(5) for details +# This file should be world readable. + +#BASE dc=OpenLDAP, dc=Org +#HOST ldap.openldap.org + +#HOST ldap.openldap.org ldap-master.openldap.org:666 +#PORT 389 + +#SIZELIMIT 12 +#TIMELIMIT 15 +#DEREF never diff --git a/libraries/libldap/ldapfilter.conf b/libraries/libldap/ldapfilter.conf index c602f7d2e7..fad388e4d8 100644 --- a/libraries/libldap/ldapfilter.conf +++ b/libraries/libldap/ldapfilter.conf @@ -1,3 +1,5 @@ +# $OpenLDAP$ +# # ldap filter file # # lines like this that start with # or empty lines are ignored @@ -24,33 +26,35 @@ # "finger and ud and go500 and go500gw subtree and web500gw subtree and rp500 and rcpt500 and ufn last" + "^$" "" "(objectclass=*)" "default filter" "=" " " "%v" "arbitrary filter" - "^[0-9][0-9-]*$" " " "(telephoneNumber=*%v)" "phone number" + "^[0-9][0-9\-]*$" " " "(telephoneNumber=*%v)" "phone number" "@" " " "(mail=%v)" "email address" "(mail=%v*)" "start of email address" - "^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial" + "^.[\. _].*" ". _" "(cn=%v1* %v2-)" "first initial" ".*[. _].$" ". _" "(cn=%v1-*)" "last initial" "[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact" "(|(sn~=%v1-)(cn~=%v1-))" "approximate" - ".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact" - "(|(cn~=%v1)(sn~=%v1))" "approximate" + ".*" ". " "(|(cn=%v1)(sn=%v1)(ou=%v1))" "exact" + "(|(cn~=%v1)(sn~=%v1)(ou~=%v1))" "approximate" "go500gw onelevel and web500gw onelevel and ufn first and ufn intermediate" + "^$" "" "(!(objectclass=dSA))" "default filter" "=" " " "%v" "arbitrary filter" - "^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact" - "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate" + "^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact2" + "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate2" " " " " "(|(o=%v)(l=%v)(co=%v)(ou=%v))" "exact" "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate" - "\." " " "(associatedDomain=%v)" "exact" + "\." " " "(associatedDomain=%v)" "exact" ".*" " " "(|(o=%v)(l=%v)(co=%v)(ou=%v))" "exact" "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate" diff --git a/libraries/libldap/ldapsearchprefs.conf b/libraries/libldap/ldapsearchprefs.conf index 74be091d4c..4dfb7a8b45 100644 --- a/libraries/libldap/ldapsearchprefs.conf +++ b/libraries/libldap/ldapsearchprefs.conf @@ -1,3 +1,4 @@ +# $OpenLDAP$ # Version should be 1 now Version 1 # diff --git a/libraries/libldap/ldaptemplates.conf b/libraries/libldap/ldaptemplates.conf index f08e3b2757..40c1d8bbae 100644 --- a/libraries/libldap/ldaptemplates.conf +++ b/libraries/libldap/ldaptemplates.conf @@ -1,3 +1,4 @@ +# $OpenLDAP$ ########################################################################## # LDAP display templates ########################################################################## diff --git a/libraries/libldap/libldap.dsp b/libraries/libldap/libldap.dsp new file mode 100644 index 0000000000..48692feb92 --- /dev/null +++ b/libraries/libldap/libldap.dsp @@ -0,0 +1,365 @@ +# Microsoft Developer Studio Project File - Name="libldap" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=libldap - Win32 Single Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libldap.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libldap.mak" CFG="libldap - Win32 Single Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libldap - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libldap - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "libldap - Win32 Single Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "libldap - Win32 Single Release" (based on\ + "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "libldap - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\Release" +# PROP Intermediate_Dir "Release\libldap" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Release\oldap32.lib" + +!ELSEIF "$(CFG)" == "libldap - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\Debug" +# PROP Intermediate_Dir "Debug\libldap" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Debug\oldap32.lib" + +!ELSEIF "$(CFG)" == "libldap - Win32 Single Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "libldap_" +# PROP BASE Intermediate_Dir "libldap_" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\SDebug" +# PROP Intermediate_Dir "SDebug\libldap" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"..\Debug\oldap32.lib" +# ADD LIB32 /nologo /out:"..\SDebug\oldap32.lib" + +!ELSEIF "$(CFG)" == "libldap - Win32 Single Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "libldap0" +# PROP BASE Intermediate_Dir "libldap0" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\SRelease" +# PROP Intermediate_Dir "SRelease\libldap" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"..\Release\oldap32.lib" +# ADD LIB32 /nologo /out:"..\SRelease\oldap32.lib" + +!ENDIF + +# Begin Target + +# Name "libldap - Win32 Release" +# Name "libldap - Win32 Debug" +# Name "libldap - Win32 Single Debug" +# Name "libldap - Win32 Single Release" +# Begin Source File + +SOURCE=.\abandon.c +# End Source File +# Begin Source File + +SOURCE=.\add.c +# End Source File +# Begin Source File + +SOURCE=.\addentry.c +# End Source File +# Begin Source File + +SOURCE=.\bind.c +# End Source File +# Begin Source File + +SOURCE=.\cache.c +# End Source File +# Begin Source File + +SOURCE=.\charray.c +# End Source File +# Begin Source File + +SOURCE=.\charset.c +# End Source File +# Begin Source File + +SOURCE=.\cldap.c +# End Source File +# Begin Source File + +SOURCE=.\compare.c +# End Source File +# Begin Source File + +SOURCE=.\controls.c +# End Source File +# Begin Source File + +SOURCE=.\delete.c +# End Source File +# Begin Source File + +SOURCE=.\digest.c +# End Source File +# Begin Source File + +SOURCE=.\disptmpl.c +# End Source File +# Begin Source File + +SOURCE=..\..\include\disptmpl.h +# End Source File +# Begin Source File + +SOURCE=.\dn.c +# End Source File +# Begin Source File + +SOURCE=.\dsparse.c +# End Source File +# Begin Source File + +SOURCE=.\error.c +# End Source File +# Begin Source File + +SOURCE=.\extended.c +# End Source File +# Begin Source File + +SOURCE=.\free.c +# End Source File +# Begin Source File + +SOURCE=.\friendly.c +# End Source File +# Begin Source File + +SOURCE=.\getattr.c +# End Source File +# Begin Source File + +SOURCE=.\getdn.c +# End Source File +# Begin Source File + +SOURCE=.\getdxbyname.c +# End Source File +# Begin Source File + +SOURCE=.\getentry.c +# End Source File +# Begin Source File + +SOURCE=.\getfilter.c +# End Source File +# Begin Source File + +SOURCE=.\getvalues.c +# End Source File +# Begin Source File + +SOURCE=.\init.c +# End Source File +# Begin Source File + +SOURCE=.\kbind.c +# End Source File +# Begin Source File + +SOURCE=".\ldap-int.h" +# End Source File +# Begin Source File + +SOURCE=..\..\include\ldap.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ldap_cdefs.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ldap_config.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ldap_defaults.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ldap_features.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ldap_log.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ldap_pvt.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\ldap_schema.h +# End Source File +# Begin Source File + +SOURCE=.\messages.c +# End Source File +# Begin Source File + +SOURCE=.\modify.c +# End Source File +# Begin Source File + +SOURCE=.\modrdn.c +# End Source File +# Begin Source File + +SOURCE=.\open.c +# End Source File +# Begin Source File + +SOURCE=.\options.c +# End Source File +# Begin Source File + +SOURCE=".\os-ip.c" +# End Source File +# Begin Source File + +SOURCE=..\..\include\portable.h +# End Source File +# Begin Source File + +SOURCE=.\print.c +# End Source File +# Begin Source File + +SOURCE=.\references.c +# End Source File +# Begin Source File + +SOURCE=.\request.c +# End Source File +# Begin Source File + +SOURCE=.\result.c +# End Source File +# Begin Source File + +SOURCE=.\sasl.c +# End Source File +# Begin Source File + +SOURCE=.\sbind.c +# End Source File +# Begin Source File + +SOURCE=.\schema.c +# End Source File +# Begin Source File + +SOURCE=.\search.c +# End Source File +# Begin Source File + +SOURCE=.\sort.c +# End Source File +# Begin Source File + +SOURCE=.\srchpref.c +# End Source File +# Begin Source File + +SOURCE=..\..\include\srchpref.h +# End Source File +# Begin Source File + +SOURCE=.\string.c +# End Source File +# Begin Source File + +SOURCE=.\ufn.c +# End Source File +# Begin Source File + +SOURCE=.\unbind.c +# End Source File +# Begin Source File + +SOURCE=.\url.c +# End Source File +# Begin Source File + +SOURCE=".\util-int.c" +# End Source File +# End Target +# End Project diff --git a/libraries/libldap/messages.c b/libraries/libldap/messages.c new file mode 100644 index 0000000000..57e331daeb --- /dev/null +++ b/libraries/libldap/messages.c @@ -0,0 +1,66 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* + * messages.c + */ + +#include "portable.h" + +#include + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" + +LDAPMessage * +ldap_first_message( LDAP *ld, LDAPMessage *chain ) +{ + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + + if ( ld == NULL || chain == NULL ) { + return NULL; + } + + return chain; +} + +LDAPMessage * +ldap_next_message( LDAP *ld, LDAPMessage *msg ) +{ + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + + if ( ld == NULL || msg == NULL || msg->lm_chain == NULL ) { + return NULL; + } + + return( msg->lm_chain ); +} + +int +ldap_count_messages( LDAP *ld, LDAPMessage *chain ) +{ + int i; + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + + if ( ld == NULL ) { + return -1; + } + + for ( i = 0; chain != NULL; chain = chain->lm_chain ) { + i++; + } + + return( i ); +} diff --git a/libraries/libldap/modify.c b/libraries/libldap/modify.c index 316dde787f..a758fc1607 100644 --- a/libraries/libldap/modify.c +++ b/libraries/libldap/modify.c @@ -1,38 +1,38 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * modify.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include - -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include +#include -#include "lber.h" -#include "ldap.h" #include "ldap-int.h" /* - * ldap_modify - initiate an ldap (and X.500) modify operation. Parameters: + * ldap_modify_ext - initiate an ldap extended modify operation. + * + * Parameters: * * ld LDAP descriptor * dn DN of the object to modify * mods List of modifications to make. This is null-terminated * array of struct ldapmod's, specifying the modifications * to perform. + * sctrls Server Controls + * cctrls Client Controls + * msgidp Message ID pointer * * Example: * LDAPMod *mods[] = { @@ -40,10 +40,15 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of * { LDAP_MOD_REPLACE, "sn", { "jensen", 0 } }, * 0 * } - * msgid = ldap_modify( ld, dn, mods ); + * rc= ldap_modify_ext( ld, dn, mods, sctrls, cctrls, &msgid ); */ int -ldap_modify( LDAP *ld, char *dn, LDAPMod **mods ) +ldap_modify_ext( LDAP *ld, + LDAP_CONST char *dn, + LDAPMod **mods, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp ) { BerElement *ber; int i, rc; @@ -66,56 +71,108 @@ ldap_modify( LDAP *ld, char *dn, LDAPMod **mods ) * } */ - Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_modify_ext\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { - return( -1 ); + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + return( LDAP_NO_MEMORY ); } - if ( ber_printf( ber, "{it{s{", ++ld->ld_msgid, LDAP_REQ_MODIFY, dn ) + if ( ber_printf( ber, "{it{s{" /*}}}*/, ++ld->ld_msgid, LDAP_REQ_MODIFY, dn ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return( ld->ld_errno ); } /* for each modification to be performed... */ for ( i = 0; mods[i] != NULL; i++ ) { if (( mods[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) { rc = ber_printf( ber, "{e{s[V]}}", - mods[i]->mod_op & ~LDAP_MOD_BVALUES, + (ber_int_t) ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ), mods[i]->mod_type, mods[i]->mod_bvalues ); } else { - rc = ber_printf( ber, "{e{s[v]}}", mods[i]->mod_op, + rc = ber_printf( ber, "{e{s[v]}}", + (ber_int_t) mods[i]->mod_op, mods[i]->mod_type, mods[i]->mod_values ); } if ( rc == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return( ld->ld_errno ); } } - if ( ber_printf( ber, "}}}" ) == -1 ) { + if ( ber_printf( ber, /*{{*/ "}}" ) == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return( ld->ld_errno ); + } + + /* Put Server Controls */ + if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + return ld->ld_errno; + } + + if ( ber_printf( ber, /*{*/ "}" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return( ld->ld_errno ); } /* send the message */ - return( send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber )); + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber ); + return( *msgidp < 0 ? ld->ld_errno : LDAP_SUCCESS ); } +/* + * ldap_modify - initiate an ldap modify operation. + * + * Parameters: + * + * ld LDAP descriptor + * dn DN of the object to modify + * mods List of modifications to make. This is null-terminated + * array of struct ldapmod's, specifying the modifications + * to perform. + * + * Example: + * LDAPMod *mods[] = { + * { LDAP_MOD_ADD, "cn", { "babs jensen", "babs", 0 } }, + * { LDAP_MOD_REPLACE, "sn", { "jensen", 0 } }, + * 0 + * } + * msgid = ldap_modify( ld, dn, mods ); + */ int -ldap_modify_s( LDAP *ld, char *dn, LDAPMod **mods ) +ldap_modify( LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods ) { + int rc, msgid; + + Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 ); + + rc = ldap_modify_ext( ld, dn, mods, NULL, NULL, &msgid ); + + if ( rc != LDAP_SUCCESS ) + return -1; + + return msgid; +} + +int +ldap_modify_ext_s( LDAP *ld, LDAP_CONST char *dn, + LDAPMod **mods, LDAPControl **sctrl, LDAPControl **cctrl ) +{ + int rc; int msgid; LDAPMessage *res; - if ( (msgid = ldap_modify( ld, dn, mods )) == -1 ) - return( ld->ld_errno ); + rc = ldap_modify_ext( ld, dn, mods, sctrl, cctrl, &msgid ); + + if ( rc != LDAP_SUCCESS ) + return( rc ); if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) return( ld->ld_errno ); @@ -123,3 +180,9 @@ ldap_modify_s( LDAP *ld, char *dn, LDAPMod **mods ) return( ldap_result2error( ld, res, 1 ) ); } +int +ldap_modify_s( LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods ) +{ + return ldap_modify_ext_s( ld, dn, mods, NULL, NULL ); +} + diff --git a/libraries/libldap/modrdn.c b/libraries/libldap/modrdn.c index f4624a919a..209ec4315a 100644 --- a/libraries/libldap/modrdn.c +++ b/libraries/libldap/modrdn.c @@ -1,96 +1,238 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * modrdn.c */ +/* + * Support for MODIFYDN REQUEST V3 (newSuperior) by: + * + * Copyright 1999, Juan C. Gomez, All rights reserved. + * This software is not subject to any license of Silicon Graphics + * Inc. or Purdue University. + * + * Redistribution and use in source and binary forms are permitted + * without restriction or fee of any kind as long as this notice + * is preserved. + */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +/* + * A modify rdn request looks like this: + * ModifyRDNRequest ::= SEQUENCE { + * entry DistinguishedName, + * newrdn RelativeDistinguishedName, + * deleteoldrdn BOOLEAN + * newSuperior [0] DistinguishedName [v3 only] + * } + */ -#include -#include +#include "portable.h" -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ +#include -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include +#include -#include "lber.h" -#include "ldap.h" #include "ldap-int.h" /* - * ldap_modrdn2 - initiate an ldap (and X.500) modifyRDN operation. Parameters: + * ldap_rename - initiate an ldap extended modifyDN operation. * - * ld LDAP descriptor - * dn DN of the object to modify - * newrdn RDN to give the object + * Parameters: + * ld LDAP descriptor + * dn DN of the object to modify + * newrdn RDN to give the object * deleteoldrdn nonzero means to delete old rdn values from the entry + * newSuperior DN of the new parent if applicable * - * Example: - * msgid = ldap_modrdn( ld, dn, newrdn ); + * Returns the LDAP error code. */ + int -ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn ) +ldap_rename( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *newrdn, + int deleteoldrdn, + LDAP_CONST char *newSuperior, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp ) { BerElement *ber; + int rc; - /* - * A modify rdn request looks like this: - * ModifyRDNRequest ::= SEQUENCE { - * entry DistinguishedName, - * newrdn RelativeDistinguishedName, - * deleteoldrdn BOOLEAN - * } - */ - - Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_rename\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { - return( -1 ); + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + return( LDAP_NO_MEMORY ); + } + + if( newSuperior != NULL ) { + /* must be version 3 (or greater) */ + if ( ld->ld_version < LDAP_VERSION3 ) { + ld->ld_errno = LDAP_NOT_SUPPORTED; + ber_free( ber, 1 ); + return( ld->ld_errno ); + } + + rc = ber_printf( ber, "{it{ssbts}", /* '}' */ + ++ld->ld_msgid, LDAP_REQ_MODDN, + dn, newrdn, (ber_int_t) deleteoldrdn, + LDAP_TAG_NEWSUPERIOR, newSuperior ); + + } else { + rc = ber_printf( ber, "{it{ssb}", /* '}' */ + ++ld->ld_msgid, LDAP_REQ_MODDN, + dn, newrdn, (ber_int_t) deleteoldrdn ); } - if ( ber_printf( ber, "{it{ssb}}", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn, - newrdn, deleteoldrdn ) == -1 ) { + if ( rc < 0 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); - return( -1 ); + return( ld->ld_errno ); + } + + /* Put Server Controls */ + if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + return ld->ld_errno; + } + + rc = ber_printf( ber, /*{*/ "}" ); + if ( rc < 0 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return( ld->ld_errno ); } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber )); + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber ); + + if( *msgidp < 0 ) { + return( ld->ld_errno ); + } + + return LDAP_SUCCESS; } + +/* + * ldap_rename2 - initiate an ldap (and X.500) modifyDN operation. Parameters: + * (LDAP V3 MODIFYDN REQUEST) + * ld LDAP descriptor + * dn DN of the object to modify + * newrdn RDN to give the object + * deleteoldrdn nonzero means to delete old rdn values from the entry + * newSuperior DN of the new parent if applicable + * + * ldap_rename2 uses a U-Mich Style API. It returns the msgid. + */ + int -ldap_modrdn( LDAP *ld, char *dn, char *newrdn ) +ldap_rename2( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *newrdn, + int deleteoldrdn, + LDAP_CONST char *newSuperior ) { - return( ldap_modrdn2( ld, dn, newrdn, 1 ) ); + int msgid; + int rc; + + Debug( LDAP_DEBUG_TRACE, "ldap_rename2\n", 0, 0, 0 ); + + rc = ldap_rename( ld, dn, newrdn, deleteoldrdn, newSuperior, + NULL, NULL, &msgid ); + + return rc == LDAP_SUCCESS ? msgid : -1; } + +/* + * ldap_modrdn2 - initiate an ldap modifyRDN operation. Parameters: + * + * ld LDAP descriptor + * dn DN of the object to modify + * newrdn RDN to give the object + * deleteoldrdn nonzero means to delete old rdn values from the entry + * + * Example: + * msgid = ldap_modrdn( ld, dn, newrdn ); + */ int -ldap_modrdn2_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn ) +ldap_modrdn2( LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *newrdn, + int deleteoldrdn ) { - int msgid; - LDAPMessage *res; + return ldap_rename2( ld, dn, newrdn, deleteoldrdn, NULL ); +} - if ( (msgid = ldap_modrdn2( ld, dn, newrdn, deleteoldrdn )) == -1 ) - return( ld->ld_errno ); +int +ldap_modrdn( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn ) +{ + return( ldap_rename2( ld, dn, newrdn, 1, NULL ) ); +} - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) - return( ld->ld_errno ); - return( ldap_result2error( ld, res, 1 ) ); +int +ldap_rename_s( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *newrdn, + int deleteoldrdn, + LDAP_CONST char *newSuperior, + LDAPControl **sctrls, + LDAPControl **cctrls ) +{ + int rc; + int msgid; + LDAPMessage *res; + + rc = ldap_rename( ld, dn, newrdn, deleteoldrdn, + newSuperior, sctrls, cctrls, &msgid ); + + if( rc != LDAP_SUCCESS ) { + return rc; + } + + rc = ldap_result( ld, msgid, 1, NULL, &res ); + + if( rc == -1 ) { + return ld->ld_errno; + } + + return ldap_result2error( ld, res, 1 ); } int -ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn ) +ldap_rename2_s( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *newrdn, + int deleteoldrdn, + LDAP_CONST char *newSuperior ) { - return( ldap_modrdn2_s( ld, dn, newrdn, 1 ) ); + return ldap_rename_s( ld, dn, newrdn, deleteoldrdn, newSuperior, NULL, NULL ); } + +int +ldap_modrdn2_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn, int deleteoldrdn ) +{ + return ldap_rename_s( ld, dn, newrdn, deleteoldrdn, NULL, NULL, NULL ); +} + +int +ldap_modrdn_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn ) +{ + return ldap_rename_s( ld, dn, newrdn, 1, NULL, NULL, NULL ); +} + diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index 93019b0915..e8785387f5 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index 0d978e3274..12edf629fc 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 42460cccec..2eb1c02eff 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -187,8 +188,8 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_in *sin, int async) tv.tv_sec = opt_tv->tv_sec; } - osip_debug(ld, "ldap_connect_timeout: fd: %d tm: %d async: %d\n", - s, opt_tv ? tv.tv_sec : -1, async); + osip_debug(ld, "ldap_connect_timeout: fd: %d tm: %ld async: %d\n", + s, opt_tv ? tv.tv_sec : -1L, async); if ( ldap_pvt_ndelay_on(ld, s) == -1 ) return ( -1 ); diff --git a/libraries/libldap/print.c b/libraries/libldap/print.c new file mode 100644 index 0000000000..a6616c53ec --- /dev/null +++ b/libraries/libldap/print.c @@ -0,0 +1,60 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" + +/* + * ldap log + */ + +static int ldap_log_check( LDAP *ld, int loglvl ) +{ + int errlvl; + + if(ld == NULL) { + errlvl = ldap_debug; + } else { + errlvl = ld->ld_errno; + } + + return errlvl & loglvl ? 1 : 0; +} + +int ldap_log_printf( LDAP *ld, int loglvl, const char *fmt, ... ) +{ + char buf[ 1024 ]; + va_list ap; + + if ( !ldap_log_check( ld, loglvl )) { + return 0; + } + + va_start( ap, fmt ); + +#ifdef HAVE_VSNPRINTF + buf[sizeof(buf) - 1] = '\0'; + vsnprintf( buf, sizeof(buf)-1, fmt, ap ); +#elif HAVE_VSPRINTF + vsprintf( buf, fmt, ap ); /* hope it's not too long */ +#else + /* use doprnt() */ + chokeme = "choke me! I don't have a doprnt manual handy!"; +#endif + + va_end(ap); + + (*ber_pvt_log_print)( buf ); + return 1; +} diff --git a/libraries/libldap/references.c b/libraries/libldap/references.c new file mode 100644 index 0000000000..371919db10 --- /dev/null +++ b/libraries/libldap/references.c @@ -0,0 +1,157 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* + * references.c + */ + +#include "portable.h" + +#include + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" + +LDAPMessage * +ldap_first_reference( LDAP *ld, LDAPMessage *chain ) +{ + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( chain != NULL ); + + if ( ld == NULL || chain == NULL ) { + return NULL; + } + + return chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE + ? chain + : ldap_next_reference( ld, chain ); +} + +LDAPMessage * +ldap_next_reference( LDAP *ld, LDAPMessage *ref ) +{ + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( ref != NULL ); + + if ( ld == NULL || ref == NULL ) { + return NULL; + } + + for ( + ref = ref->lm_chain; + ref != NULL; + ref = ref->lm_chain ) + { + if( ref->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) { + return( ref ); + } + } + + return( NULL ); +} + +int +ldap_count_references( LDAP *ld, LDAPMessage *chain ) +{ + int i; + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( chain != NULL ); + + if ( ld == NULL ) { + return -1; + } + + + for ( i = 0; chain != NULL; chain = chain->lm_chain ) { + if( chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE ) { + i++; + } + } + + return( i ); +} + +int +ldap_parse_reference( + LDAP *ld, + LDAPMessage *ref, + char ***referralsp, + LDAPControl ***serverctrls, + int freeit) +{ + BerElement be; + char **refs = NULL; + int rc; + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( ref != NULL ); + + if( ld == NULL || ref == NULL || + ref->lm_msgtype != LDAP_RES_SEARCH_REFERENCE ) + { + return LDAP_PARAM_ERROR; + } + + /* make a private copy of BerElement */ + SAFEMEMCPY(&be, ref->lm_ber, sizeof(be)); + + if ( ber_scanf( &be, "{v" /*}*/, &refs ) == LBER_ERROR ) { + rc = LDAP_DECODING_ERROR; + goto free_and_return; + } + + if ( serverctrls == NULL ) { + rc = LDAP_SUCCESS; + goto free_and_return; + } + + if ( ber_scanf( &be, /*{*/ "}" ) == LBER_ERROR ) { + rc = LDAP_DECODING_ERROR; + goto free_and_return; + } + + rc = ldap_int_get_controls( &be, serverctrls ); + +free_and_return: + + if( referralsp != NULL ) { + /* provide references regradless of return code */ + *referralsp = refs; + + } else { + ldap_value_free( refs ); + } + + if( freeit ) { + ldap_msgfree( ref ); + } + + if( rc != LDAP_SUCCESS ) { + ld->ld_errno = rc; + + if( ld->ld_matched != NULL ) { + LDAP_FREE( ld->ld_matched ); + ld->ld_matched = NULL; + } + + if( ld->ld_error != NULL ) { + LDAP_FREE( ld->ld_error ); + ld->ld_error = NULL; + } + } + + return rc; +} diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index a807d9c2e0..07da8e9bce 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 3f8408df18..a47e0577e9 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -1,88 +1,50 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * result.c - wait for an ldap result */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +/* + * LDAPv3 (RFC2251) + * LDAPResult ::= SEQUENCE { + * resultCode ENUMERATED { ... }, + * matchedDN LDAPDN, + * errorMessage LDAPString, + * referral Referral OPTIONAL + * } + * Referral ::= SEQUENCE OF LDAPURL (one or more) + * LDAPURL ::= LDAPString (limited to URL chars) + */ -#include -#include -#ifdef MACOS -#include -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#ifdef PCNFS -#include -#include -#include -#endif /* PCNFS */ -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#else /* DOS */ -#include -#include -#include -#include -#ifdef _AIX -#include -#endif /* _AIX */ #include "portable.h" -#endif /* DOS */ -#endif /* MACOS */ -#ifdef VMS -#include "ucx_select.h" -#endif -#include "lber.h" -#include "ldap.h" + +#include + +#include + +#include +#include +#include +#include +#include + #include "ldap-int.h" -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ - -#ifdef NEEDPROTOS -static int ldap_abandoned( LDAP *ld, int msgid ); -static int ldap_mark_abandoned( LDAP *ld, int msgid ); -static int wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, - LDAPMessage **result ); -#ifdef LDAP_REFERRALS -static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc, - LDAPMessage **result ); -static int build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ); -static void merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ); -#else /* LDAP_REFERRALS */ -static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, - LDAPMessage **result ); -#endif /* LDAP_REFERRALS */ -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -static int ldap_select1( LDAP *ld, struct timeval *timeout ); -#endif -#else /* NEEDPROTOS */ -static int ldap_abandoned(); -static int ldap_mark_abandoned(); -static int wait4msg(); -static int read1msg(); -#ifdef LDAP_REFERRALS -static int build_result_ber(); -static void merge_error_info(); -#endif /* LDAP_REFERRALS */ -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -static int ldap_select1(); -#endif -#endif /* NEEDPROTOS */ -#if !defined( MACOS ) && !defined( DOS ) -extern int errno; -#endif +static int ldap_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid )); +static int ldap_mark_abandoned LDAP_P(( LDAP *ld, ber_int_t msgid )); +static int wait4msg LDAP_P(( LDAP *ld, ber_int_t msgid, int all, struct timeval *timeout, + LDAPMessage **result )); +static ber_tag_t try_read1msg LDAP_P(( LDAP *ld, ber_int_t msgid, + int all, Sockbuf *sb, LDAPConn *lc, LDAPMessage **result )); +static ber_tag_t build_result_ber LDAP_P(( LDAP *ld, BerElement **bp, LDAPRequest *lr )); +static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )); /* @@ -100,11 +62,29 @@ extern int errno; * ldap_result( s, msgid, all, timeout, result ) */ int -ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout, +ldap_result( + LDAP *ld, + int msgid, + int all, + struct timeval *timeout, LDAPMessage **result ) { LDAPMessage *lm, *lastlm, *nextlm; + assert( ld != NULL ); + assert( result != NULL ); + + Debug( LDAP_DEBUG_TRACE, "ldap_result\n", 0, 0, 0 ); + + if( ld == NULL ) { + return -1; + } + + if( result == NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + return -1; + } + /* * First, look through the list of responses we have received on * this association and see if the response we're interested in @@ -112,17 +92,15 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout, * wait until it arrives or timeout occurs. */ - Debug( LDAP_DEBUG_TRACE, "ldap_result\n", 0, 0, 0 ); - - *result = NULLMSG; - lastlm = NULLMSG; - for ( lm = ld->ld_responses; lm != NULLMSG; lm = nextlm ) { + *result = NULL; + lastlm = NULL; + for ( lm = ld->ld_responses; lm != NULL; lm = nextlm ) { nextlm = lm->lm_next; if ( ldap_abandoned( ld, lm->lm_msgid ) ) { ldap_mark_abandoned( ld, lm->lm_msgid ); - if ( lastlm == NULLMSG ) { + if ( lastlm == NULL ) { ld->ld_responses = lm->lm_next; } else { lastlm->lm_next = nextlm; @@ -138,37 +116,37 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout, if ( all == 0 || (lm->lm_msgtype != LDAP_RES_SEARCH_RESULT + && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE /* LDAPv3 */ && lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) ) break; - for ( tmp = lm; tmp != NULLMSG; tmp = tmp->lm_chain ) { + for ( tmp = lm; tmp != NULL; tmp = tmp->lm_chain ) { if ( tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT ) break; } - if ( tmp == NULLMSG ) { - return( wait4msg( ld, msgid, all, timeout, - result ) ); + if ( tmp == NULL ) { + lm = NULL; } break; } lastlm = lm; } - if ( lm == NULLMSG ) { + if ( lm == NULL ) { return( wait4msg( ld, msgid, all, timeout, result ) ); } - if ( lastlm == NULLMSG ) { - ld->ld_responses = (all == 0 && lm->lm_chain != NULLMSG + if ( lastlm == NULL ) { + ld->ld_responses = (all == 0 && lm->lm_chain != NULL ? lm->lm_chain : lm->lm_next); } else { - lastlm->lm_next = (all == 0 && lm->lm_chain != NULLMSG + lastlm->lm_next = (all == 0 && lm->lm_chain != NULL ? lm->lm_chain : lm->lm_next); } if ( all == 0 ) - lm->lm_chain = NULLMSG; - lm->lm_next = NULLMSG; + lm->lm_chain = NULL; + lm->lm_next = NULL; *result = lm; ld->ld_errno = LDAP_SUCCESS; @@ -176,15 +154,21 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout, } static int -wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, +wait4msg( + LDAP *ld, + ber_int_t msgid, + int all, + struct timeval *timeout, LDAPMessage **result ) { int rc; struct timeval tv, *tvp; - long start_time, tmp_time; -#ifdef LDAP_REFERRALS + time_t start_time = 0; + time_t tmp_time; LDAPConn *lc, *nextlc; -#endif /* LDAP_REFERRALS */ + + assert( ld != NULL ); + assert( result != NULL ); #ifdef LDAP_DEBUG if ( timeout == NULL ) { @@ -192,7 +176,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, 0, 0, 0 ); } else { Debug( LDAP_DEBUG_TRACE, "wait4msg (timeout %ld sec, %ld usec)\n", - timeout->tv_sec, timeout->tv_usec, 0 ); + (long) timeout->tv_sec, (long) timeout->tv_usec, 0 ); } #endif /* LDAP_DEBUG */ @@ -201,44 +185,20 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, } else { tv = *timeout; tvp = &tv; - start_time = (long)time( NULL ); + start_time = time( NULL ); } rc = -2; while ( rc == -2 ) { -#ifndef LDAP_REFERRALS - /* hack attack */ - if ( ld->ld_sb.sb_ber.ber_ptr >= ld->ld_sb.sb_ber.ber_end ) { - rc = ldap_select1( ld, tvp ); - -#if !defined( MACOS ) && !defined( DOS ) - if ( rc == 0 || ( rc == -1 && (( ld->ld_options & - LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) { -#else - if ( rc == -1 || rc == 0 ) { -#endif - ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN : - LDAP_TIMEOUT); - return( rc ); - } - - } - if ( rc == -1 ) { - rc = -2; /* select interrupted: loop */ - } else { - rc = read1msg( ld, msgid, all, &ld->ld_sb, result ); - } -#else /* !LDAP_REFERRALS */ #ifdef LDAP_DEBUG if ( ldap_debug & LDAP_DEBUG_TRACE ) { - dump_connection( ld, ld->ld_conns, 1 ); - dump_requests_and_responses( ld ); + ldap_dump_connection( ld, ld->ld_conns, 1 ); + ldap_dump_requests_and_responses( ld ); } #endif /* LDAP_DEBUG */ for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { - if ( lc->lconn_sb->sb_ber.ber_ptr < - lc->lconn_sb->sb_ber.ber_end ) { - rc = read1msg( ld, msgid, all, lc->lconn_sb, + if ( ber_pvt_sb_data_ready(lc->lconn_sb) ) { + rc = try_read1msg( ld, msgid, all, lc->lconn_sb, lc, result ); break; } @@ -248,7 +208,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, rc = do_ldap_select( ld, tvp ); -#if defined( LDAP_DEBUG ) && !defined( MACOS ) && !defined( DOS ) +#ifdef LDAP_DEBUG if ( rc == -1 ) { Debug( LDAP_DEBUG_TRACE, "do_ldap_select returned -1: errno %d\n", @@ -256,12 +216,10 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, } #endif -#if !defined( MACOS ) && !defined( DOS ) - if ( rc == 0 || ( rc == -1 && (( ld->ld_options & - LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) { -#else - if ( rc == -1 || rc == 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 ); @@ -276,18 +234,17 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, nextlc = lc->lconn_next; if ( lc->lconn_status == LDAP_CONNST_CONNECTED && - is_read_ready( ld, + ldap_is_read_ready( ld, lc->lconn_sb )) { - rc = read1msg( ld, msgid, all, + rc = try_read1msg( ld, msgid, all, lc->lconn_sb, lc, result ); } } } } -#endif /* !LDAP_REFERRALS */ if ( rc == -2 && tvp != NULL ) { - tmp_time = (long)time( NULL ); + tmp_time = time( NULL ); if (( tv.tv_sec -= ( tmp_time - start_time )) <= 0 ) { rc = 0; /* timed out */ ld->ld_errno = LDAP_TIMEOUT; @@ -295,7 +252,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, } Debug( LDAP_DEBUG_TRACE, "wait4msg: %ld secs to go\n", - tv.tv_sec, 0, 0 ); + (long) tv.tv_sec, 0, 0 ); start_time = tmp_time; } } @@ -304,71 +261,104 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, } -static int -read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, -#ifdef LDAP_REFERRALS +static ber_tag_t +try_read1msg( + LDAP *ld, + ber_int_t msgid, + int all, + Sockbuf *sb, LDAPConn *lc, -#endif /* LDAP_REFERRALS */ - LDAPMessage **result ) + LDAPMessage **result ) { - BerElement ber; + BerElement *ber; LDAPMessage *new, *l, *prev, *tmp; - long id; - unsigned long tag, len; + ber_int_t id; + ber_tag_t tag; + ber_len_t len; int foundit = 0; -#ifdef LDAP_REFERRALS LDAPRequest *lr; BerElement tmpber; int rc, refer_cnt, hadref, simple_request; - unsigned long lderr; -#endif /* LDAP_REFERRALS */ + ber_int_t lderr; + assert( ld != NULL ); + assert( lc != NULL ); + Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 ); - ber_init( &ber, 0 ); - set_ber_options( ld, &ber ); + if ( lc->lconn_ber == NULL ) { + lc->lconn_ber = ldap_alloc_ber_with_options(ld); + + if( lc->lconn_ber == NULL ) { + return -1; + } + } + + ber = lc->lconn_ber; + assert( BER_VALID (ber) ); /* get the next message */ - if ( (tag = ber_get_next( sb, &len, &ber )) + errno = 0; + if ( (tag = ber_get_next( sb, &len, ber )) != LDAP_TAG_MESSAGE ) { - ld->ld_errno = (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN : - LDAP_LOCAL_ERROR); - return( -1 ); + if ( tag == LBER_DEFAULT) { +#ifdef LDAP_DEBUG + Debug( LDAP_DEBUG_CONNS, + "ber_get_next failed.\n", 0, 0, 0 ); +#endif +#ifdef EWOULDBLOCK + if (errno==EWOULDBLOCK) return -2; +#endif +#ifdef EAGAIN + if (errno == EAGAIN) return -2; +#endif + ld->ld_errno = LDAP_SERVER_DOWN; + return -1; + } + ld->ld_errno = LDAP_LOCAL_ERROR; + return -1; } + /* + * We read a complete message. + * The connection should no longer need this ber. + */ + lc->lconn_ber = NULL; + /* message id */ - if ( ber_get_int( &ber, &id ) == LBER_ERROR ) { + if ( ber_get_int( ber, &id ) == LBER_ERROR ) { + ber_free( ber, 1 ); ld->ld_errno = LDAP_DECODING_ERROR; return( -1 ); } /* if it's been abandoned, toss it */ - if ( ldap_abandoned( ld, (int)id ) ) { - free( ber.ber_buf ); /* gack! */ + if ( ldap_abandoned( ld, id ) ) { + ber_free( ber, 1 ); return( -2 ); /* continue looking */ } -#ifdef LDAP_REFERRALS - if (( lr = find_request_by_msgid( ld, id )) == NULL ) { + if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) { Debug( LDAP_DEBUG_ANY, "no request for response with msgid %ld (tossing)\n", - id, 0, 0 ); - free( ber.ber_buf ); /* gack! */ + (long) id, 0, 0 ); + ber_free( ber, 1 ); return( -2 ); /* continue looking */ } - Debug( LDAP_DEBUG_TRACE, "got %s msgid %ld, original id %d\n", - ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" : "result", id, - lr->lr_origid ); - id = lr->lr_origid; -#endif /* LDAP_REFERRALS */ /* the message type */ - if ( (tag = ber_peek_tag( &ber, &len )) == LBER_ERROR ) { + if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; + ber_free( ber, 1 ); return( -1 ); } -#ifdef LDAP_REFERRALS + Debug( LDAP_DEBUG_TRACE, "ldap_read: %s msgid %ld, original id %ld\n", + ( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" : + ( tag == LDAP_RES_SEARCH_REFERENCE ) ? "reference" : "result", + (long) id, (long) lr->lr_origid ); + + id = lr->lr_origid; refer_cnt = 0; hadref = simple_request = 0; rc = -2; /* default is to keep looking (no response found) */ @@ -376,15 +366,16 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, if ( tag != LDAP_RES_SEARCH_ENTRY ) { if ( ld->ld_version >= LDAP_VERSION2 && - ( lr->lr_parent != NULL || - ( ld->ld_options & LDAP_OPT_REFERRALS ) != 0 )) { - tmpber = ber; /* struct copy */ + ( lr->lr_parent != NULL || + LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) ) ) + { + tmpber = *ber; /* struct copy */ if ( ber_scanf( &tmpber, "{iaa}", &lderr, &lr->lr_res_matched, &lr->lr_res_error ) != LBER_ERROR ) { if ( lderr != LDAP_SUCCESS ) { /* referrals are in error string */ - refer_cnt = chase_referrals( ld, lr, + refer_cnt = ldap_chase_referrals( ld, lr, &lr->lr_res_error, &hadref ); } @@ -409,8 +400,8 @@ Debug( LDAP_DEBUG_TRACE, "read1msg: %d new referrals\n", refer_cnt, 0, 0 ); if ( refer_cnt != 0 ) { /* chasing referrals */ - free( ber.ber_buf ); /* gack! */ - ber.ber_buf = NULL; + ber_free( ber, 1 ); + ber = NULL; if ( refer_cnt < 0 ) { return( -1 ); /* fatal error */ } @@ -421,8 +412,8 @@ Debug( LDAP_DEBUG_TRACE, simple_request = ( hadref ? 0 : 1 ); } else { /* request with referrals or child request */ - free( ber.ber_buf ); /* gack! */ - ber.ber_buf = NULL; + ber_free( ber, 1 ); + ber = NULL; } while ( lr->lr_parent != NULL ) { @@ -438,52 +429,48 @@ Debug( LDAP_DEBUG_TRACE, id = lr->lr_msgid; tag = lr->lr_res_msgtype; Debug( LDAP_DEBUG_ANY, "request %ld done\n", - id, 0, 0 ); + (long) id, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "res_errno: %d, res_error: <%s>, res_matched: <%s>\n", lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "", lr->lr_res_matched ? lr->lr_res_matched : "" ); if ( !simple_request ) { - if ( ber.ber_buf != NULL ) { - free( ber.ber_buf ); /* gack! */ - ber.ber_buf = NULL; - } + ber_free( ber, 1 ); + ber = NULL; if ( build_result_ber( ld, &ber, lr ) == LBER_ERROR ) { - ld->ld_errno = LDAP_NO_MEMORY; rc = -1; /* fatal error */ } } - free_request( ld, lr ); + ldap_free_request( ld, lr ); } if ( lc != NULL ) { - free_connection( ld, lc, 0, 1 ); + ldap_free_connection( ld, lc, 0, 1 ); } } } - if ( ber.ber_buf == NULL ) { + if ( ber == NULL ) { return( rc ); } -#endif /* LDAP_REFERRALS */ /* make a new ldap message */ - if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) )) + if ( (new = (LDAPMessage *) LDAP_CALLOC( 1, sizeof(LDAPMessage) )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( -1 ); } new->lm_msgid = (int)id; new->lm_msgtype = tag; - new->lm_ber = ber_dup( &ber ); + new->lm_ber = ber; -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) { - add_result_to_cache( ld, new ); + ldap_add_result_to_cache( ld, new ); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ /* is this the one we're looking for? */ if ( msgid == LDAP_RES_ANY || id == msgid ) { @@ -504,15 +491,15 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); * search response. */ - prev = NULLMSG; - for ( l = ld->ld_responses; l != NULLMSG; l = l->lm_next ) { + prev = NULL; + for ( l = ld->ld_responses; l != NULL; l = l->lm_next ) { if ( l->lm_msgid == new->lm_msgid ) break; prev = l; } /* not part of an existing search response */ - if ( l == NULLMSG ) { + if ( l == NULL ) { if ( foundit ) { *result = new; ld->ld_errno = LDAP_SUCCESS; @@ -524,11 +511,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); return( -2 ); /* continue looking */ } - Debug( LDAP_DEBUG_TRACE, "adding response id %d type %d:\n", - new->lm_msgid, new->lm_msgtype, 0 ); + Debug( LDAP_DEBUG_TRACE, "adding response id %ld type %ld:\n", + (long) new->lm_msgid, (long) new->lm_msgtype, 0 ); /* part of a search response - add to end of list of entries */ - for ( tmp = l; tmp->lm_chain != NULLMSG && + for ( tmp = l; tmp->lm_chain != NULL && tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY; tmp = tmp->lm_chain ) ; /* NULL */ @@ -536,45 +523,80 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); /* return the whole chain if that's what we were looking for */ if ( foundit ) { - if ( prev == NULLMSG ) + if ( prev == NULL ) ld->ld_responses = l->lm_next; else prev->lm_next = l->lm_next; *result = l; ld->ld_errno = LDAP_SUCCESS; +#ifdef LDAP_WORLD_P16 + /* + * XXX questionable fix; see text for [P16] on + * http://www.critical-angle.com/ldapworld/patch/ + * + * inclusion of this patch causes searchs to hang on + * multiple platforms + */ + return( l->lm_msgtype ); +#else /* LDAP_WORLD_P16 */ return( tag ); +#endif /* !LDAP_WORLD_P16 */ } return( -2 ); /* continue looking */ } -#ifdef LDAP_REFERRALS -static int -build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ) +static ber_tag_t +build_result_ber( LDAP *ld, BerElement **bp, LDAPRequest *lr ) { - unsigned long len; - long along; + ber_len_t len; + ber_int_t tag; + ber_int_t along; + BerElement *ber; + + *bp = NULL; + ber = ldap_alloc_ber_with_options( ld ); + + if( ber == NULL ) { + ld->ld_errno = LDAP_NO_MEMORY; + return LBER_ERROR; + } - ber_init( ber, 0 ); - set_ber_options( ld, ber ); if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid, - (long)lr->lr_res_msgtype, lr->lr_res_errno, + lr->lr_res_msgtype, lr->lr_res_errno, lr->lr_res_matched ? lr->lr_res_matched : "", - lr->lr_res_error ? lr->lr_res_error : "" ) == LBER_ERROR ) { + lr->lr_res_error ? lr->lr_res_error : "" ) == -1 ) { + + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free(ber, 1); return( LBER_ERROR ); } ber_reset( ber, 1 ); + if ( ber_skip_tag( ber, &len ) == LBER_ERROR ) { + ld->ld_errno = LDAP_DECODING_ERROR; + ber_free(ber, 1); return( LBER_ERROR ); } if ( ber_get_int( ber, &along ) == LBER_ERROR ) { + ld->ld_errno = LDAP_DECODING_ERROR; + ber_free(ber, 1); return( LBER_ERROR ); } - return( ber_peek_tag( ber, &len )); + tag = ber_peek_tag( ber, &len ); + + if ( tag == LBER_ERROR ) { + ld->ld_errno = LDAP_DECODING_ERROR; + ber_free(ber, 1); + return( LBER_ERROR ); + } + + *bp = ber; + return tag; } @@ -587,20 +609,20 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) { parentr->lr_res_errno = lr->lr_res_errno; if ( lr->lr_res_error != NULL ) { - (void)append_referral( ld, &parentr->lr_res_error, + (void)ldap_append_referral( ld, &parentr->lr_res_error, lr->lr_res_error ); } } else if ( lr->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 ) { - free( parentr->lr_res_error ); + LDAP_FREE( parentr->lr_res_error ); } parentr->lr_res_error = lr->lr_res_error; lr->lr_res_error = NULL; - if ( NAME_ERROR( lr->lr_res_errno )) { + if ( LDAP_NAME_ERROR( lr->lr_res_errno )) { if ( parentr->lr_res_matched != NULL ) { - free( parentr->lr_res_matched ); + LDAP_FREE( parentr->lr_res_matched ); } parentr->lr_res_matched = lr->lr_res_matched; lr->lr_res_matched = NULL; @@ -614,103 +636,24 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) parentr->lr_res_error : "", parentr->lr_res_matched ? parentr->lr_res_matched : "" ); } -#endif /* LDAP_REFERRALS */ - -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -#if !defined( MACOS ) && !defined( DOS ) && !defined( _WIN32 ) -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - fd_set readfds; - static int tblsize; - - if ( tblsize == 0 ) { -#ifdef USE_SYSCONF - tblsize = sysconf( _SC_OPEN_MAX ); -#else /* USE_SYSCONF */ - tblsize = getdtablesize(); -#endif /* USE_SYSCONF */ - } - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sb.sb_sd, &readfds ); - - return( select( tblsize, &readfds, 0, 0, timeout ) ); -} -#endif /* !MACOS */ - -#ifdef MACOS -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - return( tcpselect( ld->ld_sb.sb_sd, timeout )); -} -#endif /* MACOS */ - - -#if ( defined( DOS ) && defined( WINSOCK )) || defined( _WIN32 ) -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) +int +ldap_msgtype( LDAPMessage *lm ) { - fd_set readfds; - int rc; - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sb.sb_sd, &readfds ); - - rc = select( 1, &readfds, 0, 0, timeout ); - return( rc == SOCKET_ERROR ? -1 : rc ); + assert( lm != NULL ); + return ( lm == NULL ) ? lm->lm_msgtype : -1; } -#endif /* WINSOCK || _WIN32 */ - -#ifdef DOS -#ifdef PCNFS -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - fd_set readfds; - int res; - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sb.sb_sd, &readfds ); - - res = select( FD_SETSIZE, &readfds, NULL, NULL, timeout ); - if ( res == -1 && errno == EINTR) { - /* We've been CTRL-C'ed at this point. It'd be nice to - carry on but PC-NFS currently won't let us! */ - printf("\n*** CTRL-C ***\n"); - exit(-1); - } - return( res ); -} -#endif /* PCNFS */ -#ifdef NCSA -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) +int +ldap_msgid( LDAPMessage *lm ) { - int rc; - clock_t endtime; - - if ( timeout != NULL ) { - endtime = timeout->tv_sec * CLK_TCK + - timeout->tv_usec * CLK_TCK / 1000000 + clock(); - } - - do { - Stask(); - rc = netqlen( ld->ld_sb.sb_sd ); - } while ( rc <= 0 && ( timeout == NULL || clock() < endtime )); + assert( lm != NULL ); - return( rc > 0 ? 1 : 0 ); + return ( lm == NULL ) ? lm->lm_msgid : -1; } -#endif /* NCSA */ -#endif /* DOS */ -#endif /* !LDAP_REFERRALS */ int @@ -719,13 +662,15 @@ ldap_msgfree( LDAPMessage *lm ) LDAPMessage *next; int type = 0; + assert( lm != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_msgfree\n", 0, 0, 0 ); - for ( ; lm != NULLMSG; lm = next ) { + for ( ; lm != NULL; lm = next ) { next = lm->lm_chain; type = lm->lm_msgtype; ber_free( lm->lm_ber, 1 ); - free( (char *) lm ); + LDAP_FREE( (char *) lm ); } return( type ); @@ -741,19 +686,21 @@ ldap_msgdelete( LDAP *ld, int msgid ) { LDAPMessage *lm, *prev; + assert( ld != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_msgdelete\n", 0, 0, 0 ); - prev = NULLMSG; - for ( lm = ld->ld_responses; lm != NULLMSG; lm = lm->lm_next ) { + prev = NULL; + for ( lm = ld->ld_responses; lm != NULL; lm = lm->lm_next ) { if ( lm->lm_msgid == msgid ) break; prev = lm; } - if ( lm == NULLMSG ) + if ( lm == NULL ) return( -1 ); - if ( prev == NULLMSG ) + if ( prev == NULL ) ld->ld_responses = lm->lm_next; else prev->lm_next = lm->lm_next; @@ -769,7 +716,7 @@ ldap_msgdelete( LDAP *ld, int msgid ) * return 1 if message msgid is waiting to be abandoned, 0 otherwise */ static int -ldap_abandoned( LDAP *ld, int msgid ) +ldap_abandoned( LDAP *ld, ber_int_t msgid ) { int i; @@ -785,7 +732,7 @@ ldap_abandoned( LDAP *ld, int msgid ) static int -ldap_mark_abandoned( LDAP *ld, int msgid ) +ldap_mark_abandoned( LDAP *ld, ber_int_t msgid ) { int i; @@ -807,15 +754,23 @@ ldap_mark_abandoned( LDAP *ld, int msgid ) } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS int cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber ) { - int rc; - unsigned long tag, len; + int rc; + ber_tag_t tag; + ber_len_t len; + + if ( ! ber_pvt_sb_data_ready(&ld->ld_sb) ) { + /* restored from ldap_select1() in result.c version 1.24 */ + fd_set readfds; + if ( ldap_int_tblsize == 0 ) + ldap_int_ip_init(); + FD_ZERO( &readfds ); + FD_SET( ber_pvt_sb_get_desc(&ld->ld_sb), &readfds ); + rc = select( ldap_int_tblsize, &readfds, 0, 0, timeout ); - if ( ld->ld_sb.sb_ber.ber_ptr >= ld->ld_sb.sb_ber.ber_end ) { - rc = ldap_select1( ld, timeout ); if ( rc == -1 || rc == 0 ) { ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN : LDAP_TIMEOUT); @@ -831,6 +786,6 @@ cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber ) return( -1 ); } - return( tag ); + return( 0 ); } -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c new file mode 100644 index 0000000000..a397288c4d --- /dev/null +++ b/libraries/libldap/sasl.c @@ -0,0 +1,334 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +/* + * BindRequest ::= SEQUENCE { + * version INTEGER, + * name DistinguishedName, -- who + * authentication CHOICE { + * simple [0] OCTET STRING -- passwd +#ifdef HAVE_KERBEROS + * krbv42ldap [1] OCTET STRING + * krbv42dsa [2] OCTET STRING +#endif + * sasl [3] SaslCredentials -- LDAPv3 + * } + * } + * + * BindResponse ::= SEQUENCE { + * COMPONENTS OF LDAPResult, + * serverSaslCreds OCTET STRING OPTIONAL -- LDAPv3 + * } + * + */ + +#include "portable.h" + +#include + +#include +#include +#include + +#include "ldap-int.h" + + +/* + * ldap_sasl_bind - bind to the ldap server (and X.500). The dn, mechanism, and + * credentials of the entry to which to bind are supplied. The message id + * of the request initiated is provided upon successful (LDAP_SUCCESS) return. + * + * Example: + * ldap_sasl_bind( ld, "cn=manager, o=university of michigan, c=us", + * "mechanism", "secret", NULL, NULL, &msgid ) + */ + +int +ldap_sasl_bind( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *mechanism, + struct berval *cred, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp ) +{ + BerElement *ber; + int rc; + + Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind\n", 0, 0, 0 ); + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( msgidp != NULL ); + + if( msgidp == NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + return ld->ld_errno; + } + + if( mechanism != LDAP_SASL_SIMPLE + && ld->ld_version < LDAP_VERSION3) + { + ld->ld_errno = LDAP_NOT_SUPPORTED; + return ld->ld_errno; + } + + if ( dn == NULL ) + dn = ""; + + /* create a message to send */ + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { + ld->ld_errno = LDAP_NO_MEMORY; + return ld->ld_errno; + } + + assert( BER_VALID( ber ) ); + + if( mechanism == LDAP_SASL_SIMPLE ) { + /* simple bind */ + rc = ber_printf( ber, "{it{istO}" /*}*/, + ++ld->ld_msgid, LDAP_REQ_BIND, + ld->ld_version, dn, LDAP_AUTH_SIMPLE, + cred ); + + } else if ( cred == NULL ) { + /* SASL bind w/o creditials */ + rc = ber_printf( ber, "{it{ist{s}}" /*}*/, + ++ld->ld_msgid, LDAP_REQ_BIND, + ld->ld_version, dn, LDAP_AUTH_SASL, + mechanism ); + + } else { + /* SASL bind w/ creditials */ + rc = ber_printf( ber, "{it{ist{sO}}" /*}*/, + ++ld->ld_msgid, LDAP_REQ_BIND, + ld->ld_version, dn, LDAP_AUTH_SASL, + mechanism, cred ); + } + + if( rc == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return( -1 ); + } + + /* Put Server Controls */ + if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) { + ber_free( ber, 1 ); + return ld->ld_errno; + } + + if ( ber_printf( ber, /*{*/ "}" ) == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return ld->ld_errno; + } + +#ifndef LDAP_NOCACHE + if ( ld->ld_cache != NULL ) { + ldap_flush_cache( ld ); + } +#endif /* !LDAP_NOCACHE */ + + /* send the message */ + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber ); + + if(*msgidp < 0) + return ld->ld_errno; + + return LDAP_SUCCESS; +} + +/* + * ldap_sasl_bind_s - bind to the ldap server (and X.500) using simple + * authentication. The dn and password of the entry to which to bind are + * supplied. LDAP_SUCCESS is returned upon success, the ldap error code + * otherwise. + * + * Example: + * ldap_sasl_bind_s( ld, "cn=manager, o=university of michigan, c=us", + * "mechanism", "secret", NULL, NULL, &servercred ) + */ + +int +ldap_sasl_bind_s( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *mechanism, + struct berval *cred, + LDAPControl **sctrls, + LDAPControl **cctrls, + struct berval **servercredp ) +{ + int rc, msgid; + LDAPMessage *result; + struct berval *scredp = NULL; + + Debug( LDAP_DEBUG_TRACE, "ldap_sasl_bind_s\n", 0, 0, 0 ); + + /* do a quick !LDAPv3 check... ldap_sasl_bind will do the rest. */ + if( servercredp != NULL ) { + if (ld->ld_version < LDAP_VERSION3) { + ld->ld_errno = LDAP_NOT_SUPPORTED; + return ld->ld_errno; + } + *servercredp = NULL; + } + + rc = ldap_sasl_bind( ld, dn, mechanism, cred, sctrls, cctrls, &msgid ); + + if ( rc != LDAP_SUCCESS ) { + return( rc ); + } + + if ( ldap_result( ld, msgid, 1, NULL, &result ) == -1 ) { + return( ld->ld_errno ); /* ldap_result sets ld_errno */ + } + + /* parse the results */ + scredp = NULL; + if( servercredp != NULL ) { + rc = ldap_parse_sasl_bind_result( ld, result, &scredp, 0 ); + } + + if( rc != LDAP_SUCCESS ) { + ldap_msgfree( result ); + return( rc ); + } + + rc = ldap_result2error( ld, result, 1 ); + + if( rc == LDAP_SUCCESS ) { + if( servercredp != NULL ) { + *servercredp = scredp; + } + + } else if (scredp != NULL ) { + ber_bvfree(scredp); + } + + return rc; +} + + +/* + * Parse BindResponse: + * + * BindResponse ::= [APPLICATION 1] SEQUENCE { + * COMPONENTS OF LDAPResult, + * serverSaslCreds [7] OCTET STRING OPTIONAL } + * + * LDAPResult ::= SEQUENCE { + * resultCode ENUMERATED, + * matchedDN LDAPDN, + * errorMessage LDAPString, + * referral [3] Referral OPTIONAL } + */ + +int +ldap_parse_sasl_bind_result( + LDAP *ld, + LDAPMessage *res, + struct berval **servercredp, + int freeit ) +{ + ber_int_t errcode; + struct berval* scred; + + ber_tag_t tag; + BerElement *ber; + + Debug( LDAP_DEBUG_TRACE, "ldap_parse_sasl_bind_result\n", 0, 0, 0 ); + + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( res != NULL ); + + if ( ld == NULL || res == NULL ) { + return LDAP_PARAM_ERROR; + } + + if(servercredp != NULL) { + if( ld->ld_version < LDAP_VERSION2 ) { + return LDAP_NOT_SUPPORTED; + } + *servercredp = NULL; + } + + if( res->lm_msgtype == LDAP_RES_BIND ) { + ld->ld_errno = LDAP_PARAM_ERROR; + return ld->ld_errno; + } + + errcode = LDAP_SUCCESS; + scred = NULL; + + if ( ld->ld_error ) { + LDAP_FREE( ld->ld_error ); + ld->ld_error = NULL; + } + if ( ld->ld_matched ) { + LDAP_FREE( ld->ld_matched ); + ld->ld_matched = NULL; + } + + /* parse results */ + + ber = ber_dup( res->lm_ber ); + + if ( ld->ld_version < LDAP_VERSION2 ) { + tag = ber_scanf( ber, "{ia}", + &errcode, &ld->ld_error ); + + } else { + ber_len_t len; + + tag = ber_scanf( ber, "{iaa" /*}*/, + &errcode, &ld->ld_matched, &ld->ld_error ); + + if( tag != LBER_ERROR ) { + tag = ber_peek_tag(ber, &len); + } + + if( tag == LDAP_TAG_REFERRAL ) { + /* skip 'em */ + tag = ber_scanf( ber, "x" ); + + if( tag != LBER_ERROR ) { + tag = ber_peek_tag(ber, &len); + } + } + + /* need to clean out misc items */ + if( tag == LDAP_TAG_SASL_RES_CREDS ) { + tag = ber_scanf( ber, "O", &scred ); + } + } + + if ( tag == LBER_ERROR ) { + errcode = LDAP_DECODING_ERROR; + } + + if( ber != NULL ) { + ber_free( ber, 0 ); + } + + /* return */ + if ( errcode == LDAP_SUCCESS && servercredp != NULL ) { + *servercredp = scred; + + } else if ( scred != NULL ) { + ber_bvfree( scred ); + } + + if ( freeit ) { + ldap_msgfree( res ); + } + + ld->ld_errno = errcode; + return( ld->ld_errno ); +} diff --git a/libraries/libldap/sbind.c b/libraries/libldap/sbind.c index 656c722f15..96d9a78433 100644 --- a/libraries/libldap/sbind.c +++ b/libraries/libldap/sbind.c @@ -1,28 +1,44 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1993 Regents of the University of Michigan. * All rights reserved. * * sbind.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; +/* + * BindRequest ::= SEQUENCE { + * version INTEGER, + * name DistinguishedName, -- who + * authentication CHOICE { + * simple [0] OCTET STRING -- passwd +#ifdef HAVE_KERBEROS + * krbv42ldap [1] OCTET STRING + * krbv42dsa [2] OCTET STRING #endif + * sasl [3] SaslCredentials -- LDAPv3 + * } + * } + * + * BindResponse ::= SEQUENCE { + * COMPONENTS OF LDAPResult, + * serverSaslCreds OCTET STRING OPTIONAL -- LDAPv3 + * } + * + */ + +#include "portable.h" #include -#include -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ +#include +#include +#include -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif - -#include "lber.h" -#include "ldap.h" #include "ldap-int.h" @@ -37,50 +53,32 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of */ int -ldap_simple_bind( LDAP *ld, char *dn, char *passwd ) +ldap_simple_bind( + LDAP *ld, + LDAP_CONST char *dn, + LDAP_CONST char *passwd ) { - BerElement *ber; - - /* - * The bind request looks like this: - * BindRequest ::= SEQUENCE { - * version INTEGER, - * name DistinguishedName, -- who - * authentication CHOICE { - * simple [0] OCTET STRING -- passwd - * } - * } - * all wrapped up in an LDAPMessage sequence. - */ + int rc; + int msgid; + struct berval cred; Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind\n", 0, 0, 0 ); - if ( dn == NULL ) - dn = ""; - if ( passwd == NULL ) - passwd = ""; - - /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { - return( -1 ); - } + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); - /* fill it in */ - if ( ber_printf( ber, "{it{ists}}", ++ld->ld_msgid, LDAP_REQ_BIND, - ld->ld_version, dn, LDAP_AUTH_SIMPLE, passwd ) == -1 ) { - ld->ld_errno = LDAP_ENCODING_ERROR; - ber_free( ber, 1 ); - return( -1 ); + if ( passwd != NULL ) { + cred.bv_val = (char *) passwd; + cred.bv_len = strlen( passwd ); + } else { + cred.bv_val = ""; + cred.bv_len = 0; } -#ifndef NO_CACHE - if ( ld->ld_cache != NULL ) { - ldap_flush_cache( ld ); - } -#endif /* !NO_CACHE */ + rc = ldap_sasl_bind( ld, dn, LDAP_SASL_SIMPLE, &cred, + NULL, NULL, &msgid ); - /* send the message */ - return( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return rc == LDAP_SUCCESS ? msgid : -1; } /* @@ -95,18 +93,20 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd ) */ int -ldap_simple_bind_s( LDAP *ld, char *dn, char *passwd ) +ldap_simple_bind_s( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd ) { - int msgid; - LDAPMessage *result; + struct berval cred; Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind_s\n", 0, 0, 0 ); - if ( (msgid = ldap_simple_bind( ld, dn, passwd )) == -1 ) - return( ld->ld_errno ); - - if ( ldap_result( ld, msgid, 1, (struct timeval *) 0, &result ) == -1 ) - return( ld->ld_errno ); /* ldap_result sets ld_errno */ + if ( passwd != NULL ) { + cred.bv_val = (char *) passwd; + cred.bv_len = strlen( passwd ); + } else { + cred.bv_val = ""; + cred.bv_len = 0; + } - return( ldap_result2error( ld, result, 1 ) ); + return ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &cred, + NULL, NULL, NULL ); } diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 33f8f2674a..78fbe8a3fa 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -1260,9 +1261,6 @@ ldap_str2attributetype( const char * s, int * code, const char ** errp ) int seen_substr = 0; int seen_syntax = 0; int seen_usage = 0; - int seen_kind = 0; - int seen_must = 0; - int seen_may = 0; LDAP_ATTRIBUTE_TYPE * at; char ** ssdummy; const char * savepos; @@ -1837,7 +1835,7 @@ ldap_str2objectclass( const char * s, int * code, const char ** errp ) } } -static char *err2text[] = { +static char *const err2text[] = { "", "Out of memory", "Unexpected token", diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index e120b49e0d..f6d84d10d1 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -31,15 +32,9 @@ static int ldap_is_attr_desc LDAP_P(( static int hex2value LDAP_P(( int c )); -static ber_slen_t filter_value_unescape LDAP_P(( - char *filter )); - static char *find_right_paren LDAP_P(( char *s )); -static char *find_wildcard LDAP_P(( - char *s )); - static char *put_complex_filter LDAP_P(( BerElement *ber, char *str, @@ -222,7 +217,7 @@ ldap_search( BerElement * ldap_build_search_req( LDAP *ld, - LDAP_CONST char *base_in, + LDAP_CONST char *base, ber_int_t scope, LDAP_CONST char *filter_in, char **attrs, @@ -234,7 +229,6 @@ ldap_build_search_req( { BerElement *ber; int err; - char *base; char *filter; /* @@ -266,16 +260,14 @@ ldap_build_search_req( return( NULL ); } - if ( base_in == NULL ) { + if ( base == NULL ) { /* no base provided, use session default base */ base = ld->ld_options.ldo_defbase; - } else { - base = (char *) base_in; - } - if ( base == NULL ) { - /* no session default base, use top */ - base = ""; + if ( base == NULL ) { + /* no session default base, use top */ + base = ""; + } } #ifdef LDAP_CONNECTIONLESS @@ -333,11 +325,11 @@ ldap_build_search_req( return( ber ); } -static int ldap_is_attr_oid LDAP_P(( const char *attr )) +static int ldap_is_attr_oid ( const char *attr ) { int i, c, digit=0; - for( i=0 ; c = attr[i] ; i++ ) { + for( i = 0; (c = attr[i]) != 0; i++ ) { if( c >= '0' && c <= '9' ) { digit=1; @@ -359,12 +351,12 @@ static int ldap_is_attr_oid LDAP_P(( const char *attr )) } -static int ldap_is_attr_desc LDAP_P(( const char *attr )) +static int ldap_is_attr_desc ( const char *attr ) { /* cheap attribute description check */ int i, c; - for( i=0; c = attr[i]; i++ ) { + for( i = 0; (c = attr[i]) != 0; i++ ) { if (( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'Z' ) || ( c >= 'a' && c <= 'z' ) @@ -419,8 +411,8 @@ static int hex2value( int c ) return -1; } -static char * -find_wildcard( char *s ) +char * +ldap_pvt_find_wildcard( char *s ) { for( ; *s != '\0' ; s++ ) { switch( *s ) { @@ -429,10 +421,8 @@ find_wildcard( char *s ) case '\\': s++; /* skip over escape */ - if( hex2value( s[0] ) >= 0 && hex2value( s[1] ) >= 0 ) { - /* skip over lead digit of two hex digit code */ - s++; - } + if ( *s == '\0' ) + return NULL; /* escape at end of string */ } } @@ -442,8 +432,8 @@ find_wildcard( char *s ) /* unescape filter value */ /* support both LDAP v2 and v3 escapes */ /* output can include nul characters */ -static ber_slen_t -filter_value_unescape( char *fval ) +ber_slen_t +ldap_pvt_filter_value_unescape( char *fval ) { ber_slen_t r, v; int v1, v2; @@ -458,7 +448,9 @@ filter_value_unescape( char *fval ) /* escape at end of string */ return -1; - } else if (( v1 = hex2value( fval[v] )) < 0 ) { + } + + if (( v1 = hex2value( fval[v] )) >= 0 ) { /* LDAPv3 escape */ if (( v2 = hex2value( fval[v+1] )) < 0 ) { @@ -804,7 +796,7 @@ put_simple_filter( } if( rc != -1 ) { - ber_slen_t len = filter_value_unescape( value ); + ber_slen_t len = ldap_pvt_filter_value_unescape( value ); if( len >= 0 ) { rc = ber_printf( ber, "totb}", @@ -818,7 +810,7 @@ put_simple_filter( break; default: - if ( find_wildcard( value ) == NULL ) { + if ( ldap_pvt_find_wildcard( value ) == NULL ) { ftype = LDAP_FILTER_EQUALITY; } else if ( strcmp( value, "*" ) == 0 ) { ftype = LDAP_FILTER_PRESENT; @@ -833,7 +825,7 @@ put_simple_filter( rc = ber_printf( ber, "ts", ftype, str ); } else { - ber_slen_t len = filter_value_unescape( value ); + ber_slen_t len = ldap_pvt_filter_value_unescape( value ); if( len >= 0 ) { rc = ber_printf( ber, "t{so}", @@ -861,7 +853,7 @@ put_substring_filter( BerElement *ber, char *type, char *val ) return( -1 ); for( ; val != NULL; val=nextstar ) { - if ( (nextstar = find_wildcard( val )) != NULL ) + if ( (nextstar = ldap_pvt_find_wildcard( val )) != NULL ) *nextstar++ = '\0'; if ( gotstar == 0 ) { @@ -873,7 +865,7 @@ put_substring_filter( BerElement *ber, char *type, char *val ) } if ( *val != '\0' ) { - ber_slen_t len = filter_value_unescape( val ); + ber_slen_t len = ldap_pvt_filter_value_unescape( val ); if ( len < 0 ) { return -1; diff --git a/libraries/libldap/sort.c b/libraries/libldap/sort.c index ee5d549c89..c62961b773 100644 --- a/libraries/libldap/sort.c +++ b/libraries/libldap/sort.c @@ -1,4 +1,9 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1994 Regents of the University of Michigan. * All rights reserved. * @@ -12,53 +17,45 @@ * sort.c: LDAP library entry and value sort routines */ +#include "portable.h" + #include -#include -#include -#include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" +#include + +#include +#include +#include + + +#include "ldap-int.h" struct entrything { char **et_vals; LDAPMessage *et_msg; + int (*et_cmp_fn) LDAP_P((const char *a, const char *b)); }; -#ifndef NEEDPROTOS -static int (*et_cmp_fn)(); -static int et_cmp(); -#else /* !NEEDPROTOS */ -static int (*et_cmp_fn)( char *a, char *b ); -static int et_cmp( void *aa, void *bb); -#endif /* !NEEDPROTOS */ +static int et_cmp LDAP_P(( const void *aa, const void *bb)); + int ldap_sort_strcasecmp( - char **a, - char **b + const void *a, + const void *b ) { - return( strcasecmp( *a, *b ) ); + return( strcasecmp( *(char *const *)a, *(char *const *)b ) ); } static int et_cmp( - void *aa, - void *bb + const void *aa, + const void *bb ) { int i, rc; - struct entrything *a = (struct entrything *)aa; - struct entrything *b = (struct entrything *)bb; + const struct entrything *a = (const struct entrything *)aa; + const struct entrything *b = (const struct entrything *)bb; if ( a->et_vals == NULL && b->et_vals == NULL ) return( 0 ); @@ -68,8 +65,7 @@ et_cmp( return( 1 ); for ( i = 0; a->et_vals[i] && b->et_vals[i]; i++ ) { - if ( (rc = (*et_cmp_fn)( a->et_vals[i], b->et_vals[i] )) - != 0 ) { + if ( (rc = a->et_cmp_fn( a->et_vals[i], b->et_vals[i] )) != 0 ) { return( rc ); } } @@ -85,8 +81,8 @@ int ldap_sort_entries( LDAP *ld, LDAPMessage **chain, - char *attr, /* NULL => sort by DN */ - int (*cmp)() + LDAP_CONST char *attr, /* NULL => sort by DN */ + int (*cmp) (LDAP_CONST char *, LDAP_CONST char *) ) { int i, count; @@ -96,7 +92,19 @@ ldap_sort_entries( count = ldap_count_entries( ld, *chain ); - if ( (et = (struct entrything *) malloc( count * + + if ( count < 0 ) { + if( ld != NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + } + return -1; + + } else if ( count < 2 ) { + /* zero or one entries -- already sorted! */ + return 0; + } + + if ( (et = (struct entrything *) LDAP_MALLOC( count * sizeof(struct entrything) )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( -1 ); @@ -104,13 +112,14 @@ ldap_sort_entries( e = *chain; for ( i = 0; i < count; i++ ) { + et[i].et_cmp_fn = cmp; et[i].et_msg = e; if ( attr == NULL ) { char *dn; dn = ldap_get_dn( ld, e ); et[i].et_vals = ldap_explode_dn( dn, 1 ); - free( dn ); + LDAP_FREE( dn ); } else { et[i].et_vals = ldap_get_values( ld, e, attr ); } @@ -119,8 +128,7 @@ ldap_sort_entries( } last = e; - et_cmp_fn = cmp; - qsort( et, count, sizeof(struct entrything), (void *) et_cmp ); + qsort( et, count, sizeof(struct entrything), et_cmp ); ep = chain; for ( i = 0; i < count; i++ ) { @@ -130,7 +138,7 @@ ldap_sort_entries( ldap_value_free( et[i].et_vals ); } *ep = last; - free( (char *) et ); + LDAP_FREE( (char *) et ); return( 0 ); } @@ -139,7 +147,7 @@ int ldap_sort_values( LDAP *ld, char **vals, - int (*cmp)() + int (*cmp) (const void *, const void *) ) { int nel; diff --git a/libraries/libldap/srchpref.c b/libraries/libldap/srchpref.c index 88c094ce76..adfca3de10 100644 --- a/libraries/libldap/srchpref.c +++ b/libraries/libldap/srchpref.c @@ -1,4 +1,9 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1993, 1994 Regents of the University of Michigan. * All rights reserved. * @@ -13,50 +18,38 @@ * 17 May 1994 by Gordon Good */ +#include "portable.h" + #include -#include -#include -#include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include + +#include + +#include +#include +#include +#include + +#ifdef HAVE_SYS_FILE_H #include -#ifndef VMS -#include -#endif /* VMS */ -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" +#endif + +#include "ldap-int.h" #include "srchpref.h" -#ifndef NEEDPROTOS -int next_line_tokens(); -void free_strarray(); -static void free_searchobj(); -static int read_next_searchobj(); -#else /* !NEEDPROTOS */ -int next_line_tokens( char **bufp, long *blenp, char ***toksp ); -void free_strarray( char **sap ); -static void free_searchobj( struct ldap_searchobj *so ); -static int read_next_searchobj( char **bufp, long *blenp, - struct ldap_searchobj **sop, int soversion ); -#endif /* !NEEDPROTOS */ - - -static char *sobjoptions[] = { +#include "ldap-int.h" + +static void free_searchobj LDAP_P(( struct ldap_searchobj *so )); +static int read_next_searchobj LDAP_P(( char **bufp, ber_len_t *blenp, + struct ldap_searchobj **sop, int soversion )); + + +static const char *const sobjoptions[] = { "internal", NULL }; -static unsigned long sobjoptvals[] = { +static const unsigned long sobjoptvals[] = { LDAP_SEARCHOBJ_OPT_INTERNAL, }; @@ -85,7 +78,7 @@ ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp ) return( LDAP_SEARCHPREF_ERR_FILE ); } - if (( buf = malloc( (size_t)len )) == NULL ) { + if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) { fclose( fp ); return( LDAP_SEARCHPREF_ERR_MEM ); } @@ -95,26 +88,28 @@ ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp ) fclose( fp ); if ( rlen != len && !eof ) { /* error: didn't get the whole file */ - free( buf ); + LDAP_FREE( buf ); return( LDAP_SEARCHPREF_ERR_FILE ); } rc = ldap_init_searchprefs_buf( buf, rlen, solistp ); - free( buf ); + LDAP_FREE( buf ); return( rc ); } int -ldap_init_searchprefs_buf( char *buf, long buflen, +ldap_init_searchprefs_buf( + char *buf, + ber_len_t buflen, struct ldap_searchobj **solistp ) { - int rc, version; + int rc = -1, version; char **toks; struct ldap_searchobj *prevso, *so; - *solistp = prevso = NULLSEARCHOBJ; + *solistp = prevso = NULL; if ( next_line_tokens( &buf, &buflen, &toks ) != 2 || strcasecmp( toks[ 0 ], "version" ) != 0 ) { @@ -129,8 +124,8 @@ ldap_init_searchprefs_buf( char *buf, long buflen, } while ( buflen > 0 && ( rc = read_next_searchobj( &buf, &buflen, &so, - version )) == 0 && so != NULLSEARCHOBJ ) { - if ( prevso == NULLSEARCHOBJ ) { + version )) == 0 && so != NULL ) { + if ( prevso == NULL ) { *solistp = so; } else { prevso->so_next = so; @@ -167,40 +162,40 @@ free_searchobj( struct ldap_searchobj *so ) { if ( so != NULL ) { if ( so->so_objtypeprompt != NULL ) { - free( so->so_objtypeprompt ); + LDAP_FREE( so->so_objtypeprompt ); } if ( so->so_prompt != NULL ) { - free( so->so_prompt ); + LDAP_FREE( so->so_prompt ); } if ( so->so_filterprefix != NULL ) { - free( so->so_filterprefix ); + LDAP_FREE( so->so_filterprefix ); } if ( so->so_filtertag != NULL ) { - free( so->so_filtertag ); + LDAP_FREE( so->so_filtertag ); } if ( so->so_defaultselectattr != NULL ) { - free( so->so_defaultselectattr ); + LDAP_FREE( so->so_defaultselectattr ); } if ( so->so_defaultselecttext != NULL ) { - free( so->so_defaultselecttext ); + LDAP_FREE( so->so_defaultselecttext ); } if ( so->so_salist != NULL ) { struct ldap_searchattr *sa, *nextsa; for ( sa = so->so_salist; sa != NULL; sa = nextsa ) { nextsa = sa->sa_next; if ( sa->sa_attrlabel != NULL ) { - free( sa->sa_attrlabel ); + LDAP_FREE( sa->sa_attrlabel ); } if ( sa->sa_attr != NULL ) { - free( sa->sa_attr ); + LDAP_FREE( sa->sa_attr ); } if ( sa->sa_selectattr != NULL ) { - free( sa->sa_selectattr ); + LDAP_FREE( sa->sa_selectattr ); } if ( sa->sa_selecttext != NULL ) { - free( sa->sa_selecttext ); + LDAP_FREE( sa->sa_selecttext ); } - free( sa ); + LDAP_FREE( sa ); } } if ( so->so_smlist != NULL ) { @@ -208,15 +203,15 @@ free_searchobj( struct ldap_searchobj *so ) for ( sm = so->so_smlist; sm != NULL; sm = nextsm ) { nextsm = sm->sm_next; if ( sm->sm_matchprompt != NULL ) { - free( sm->sm_matchprompt ); + LDAP_FREE( sm->sm_matchprompt ); } if ( sm->sm_filter != NULL ) { - free( sm->sm_filter ); + LDAP_FREE( sm->sm_filter ); } - free( sm ); + LDAP_FREE( sm ); } } - free( so ); + LDAP_FREE( so ); } } @@ -232,13 +227,16 @@ ldap_first_searchobj( struct ldap_searchobj *solist ) struct ldap_searchobj * ldap_next_searchobj( struct ldap_searchobj *solist, struct ldap_searchobj *so ) { - return( so == NULLSEARCHOBJ ? so : so->so_next ); + return( so == NULL ? so : so->so_next ); } static int -read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, +read_next_searchobj( + char **bufp, + ber_len_t *blenp, + struct ldap_searchobj **sop, int soversion ) { int i, j, tokcnt; @@ -257,13 +255,13 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, return( tokcnt == 0 ? 0 : LDAP_SEARCHPREF_ERR_SYNTAX ); } - if (( so = (struct ldap_searchobj *)calloc( 1, + if (( so = (struct ldap_searchobj *)LDAP_CALLOC( 1, sizeof( struct ldap_searchobj ))) == NULL ) { free_strarray( toks ); return( LDAP_SEARCHPREF_ERR_MEM ); } so->so_objtypeprompt = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * if this is post-version zero, options come next @@ -293,7 +291,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, return( LDAP_SEARCHPREF_ERR_SYNTAX ); } so->so_prompt = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * Filter prefix for "More Choices" searching is next @@ -304,7 +302,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, return( LDAP_SEARCHPREF_ERR_SYNTAX ); } so->so_filterprefix = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * "Fewer Choices" filter tag comes next @@ -315,7 +313,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, return( LDAP_SEARCHPREF_ERR_SYNTAX ); } so->so_filtertag = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * Selection (disambiguation) attribute comes next @@ -326,7 +324,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, return( LDAP_SEARCHPREF_ERR_SYNTAX ); } so->so_defaultselectattr = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * Label for selection (disambiguation) attribute @@ -337,7 +335,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, return( LDAP_SEARCHPREF_ERR_SYNTAX ); } so->so_defaultselecttext = toks[ 0 ]; - free( (char *)toks ); + LDAP_FREE( (char *)toks ); /* * Search scope is next @@ -370,7 +368,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } - if (( *sa = ( struct ldap_searchattr * ) calloc( 1, + if (( *sa = ( struct ldap_searchattr * ) LDAP_CALLOC( 1, sizeof( struct ldap_searchattr ))) == NULL ) { free_strarray( toks ); ldap_free_searchprefs( so ); @@ -387,8 +385,8 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, ( *sa )->sa_matchtypebitmap |= (1 << j); } } - free( toks[ 2 ] ); - free( ( char * ) toks ); + LDAP_FREE( toks[ 2 ] ); + LDAP_FREE( ( char * ) toks ); sa = &(( *sa )->sa_next); } *sa = NULL; @@ -403,7 +401,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, ldap_free_searchprefs( so ); return( LDAP_SEARCHPREF_ERR_SYNTAX ); } - if (( *sm = ( struct ldap_searchmatch * ) calloc( 1, + if (( *sm = ( struct ldap_searchmatch * ) LDAP_CALLOC( 1, sizeof( struct ldap_searchmatch ))) == NULL ) { free_strarray( toks ); ldap_free_searchprefs( so ); @@ -411,7 +409,7 @@ read_next_searchobj( char **bufp, long *blenp, struct ldap_searchobj **sop, } ( *sm )->sm_matchprompt = toks[ 0 ]; ( *sm )->sm_filter = toks[ 1 ]; - free( ( char * ) toks ); + LDAP_FREE( ( char * ) toks ); sm = &(( *sm )->sm_next ); } *sm = NULL; diff --git a/libraries/libldap/string.c b/libraries/libldap/string.c new file mode 100644 index 0000000000..cd9994ad06 --- /dev/null +++ b/libraries/libldap/string.c @@ -0,0 +1,133 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include +#include +#include +#include + +#include "ldap-int.h" + + +#if defined ( HAVE_STRSPN ) +#define int_strspn strspn +#else +static int int_strspn( const char *str, const char *delim ) +{ + int pos; + const char *p=delim; + + for( pos=0; (*str) ; pos++,str++) { + if (*str!=*p) { + for( p=delim; (*p) ; p++ ) { + if (*str==*p) { + break; + } + } + } + + if (*p=='\0') { + return pos; + } + } + return pos; +} +#endif + +#if defined( HAVE_STRPBRK ) +#define int_strpbrk strpbrk +#else +static char *(int_strpbrk)( const char *str, const char *accept ) +{ + const char *p; + + for( ; (*str) ; str++ ) { + for( p=accept; (*p) ; p++) { + if (*str==*p) { + return str; + } + } + } + + return NULL; +} +#endif + +char *(ldap_pvt_strtok)( char *str, const char *delim, char **pos ) +{ + char *p; + + if (pos==NULL) { + return NULL; + } + + if (str==NULL) { + if (*pos==NULL) { + return NULL; + } + + str=*pos; + } + + /* skip any initial delimiters */ + str += int_strspn( str, delim ); + if (*str == '\0') { + return NULL; + } + + p = int_strpbrk( str, delim ); + if (p==NULL) { + *pos = NULL; + + } else { + *p ='\0'; + *pos = p+1; + } + + return str; +} + +char * +(ldap_pvt_strdup)( const char *s ) +{ + char *p; + size_t len = strlen( s ) + 1; + + if ( (p = (char *) malloc( len )) == NULL ) { + return( NULL ); + } + + memcpy( p, s, len ); + return( p ); +} + +char * +ldap_pvt_str2upper( char *str ) +{ + char *s; + + /* to upper */ + for ( s = str; *s; s++ ) { + *s = TOUPPER( (unsigned char) *s ); + } + + return( str ); +} + +char * +ldap_pvt_str2lower( char *str ) +{ + char *s; + + /* to lower */ + for ( s = str; *s; s++ ) { + *s = TOLOWER( (unsigned char) *s ); + } + + return( str ); +} diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index e5178bbdc6..d52859042b 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/tls.c b/libraries/libldap/tls.c index 1ac30e5496..0a6f47fe22 100644 --- a/libraries/libldap/tls.c +++ b/libraries/libldap/tls.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -414,19 +415,19 @@ ldap_pvt_tls_get_option( struct ldapoptions *lo, int option, void *arg ) break; case LDAP_OPT_X_TLS_CACERTFILE: *(char **)arg = tls_opt_cacertfile ? - strdup( tls_opt_cacertfile ) : NULL; + LDAP_STRDUP( tls_opt_cacertfile ) : NULL; break; case LDAP_OPT_X_TLS_CACERTDIR: *(char **)arg = tls_opt_cacertdir ? - strdup( tls_opt_cacertdir ) : NULL; + LDAP_STRDUP( tls_opt_cacertdir ) : NULL; break; case LDAP_OPT_X_TLS_CERTFILE: *(char **)arg = tls_opt_certfile ? - strdup( tls_opt_certfile ) : NULL; + LDAP_STRDUP( tls_opt_certfile ) : NULL; break; case LDAP_OPT_X_TLS_KEYFILE: *(char **)arg = tls_opt_keyfile ? - strdup( tls_opt_keyfile ) : NULL; + LDAP_STRDUP( tls_opt_keyfile ) : NULL; break; case LDAP_OPT_X_TLS_REQUIRE_CERT: *(int *)arg = tls_opt_require_cert; @@ -466,26 +467,26 @@ ldap_pvt_tls_set_option( struct ldapoptions *lo, int option, void *arg ) switch( option ) { case LDAP_OPT_X_TLS_CACERTFILE: if ( tls_opt_cacertfile ) free( tls_opt_cacertfile ); - tls_opt_cacertfile = arg ? strdup( (char *) arg ) : NULL; + tls_opt_cacertfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; case LDAP_OPT_X_TLS_CACERTDIR: if ( tls_opt_cacertdir ) free( tls_opt_cacertdir ); - tls_opt_cacertdir = arg ? strdup( (char *) arg ) : NULL; + tls_opt_cacertdir = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; case LDAP_OPT_X_TLS_CERTFILE: if ( tls_opt_certfile ) free( tls_opt_certfile ); - tls_opt_certfile = arg ? strdup( (char *) arg ) : NULL; + tls_opt_certfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; case LDAP_OPT_X_TLS_KEYFILE: if ( tls_opt_keyfile ) free( tls_opt_keyfile ); - tls_opt_keyfile = arg ? strdup( (char *) arg ) : NULL; + tls_opt_keyfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; case LDAP_OPT_X_TLS_REQUIRE_CERT: tls_opt_require_cert = * (int *) arg; break; case LDAP_OPT_X_TLS_CIPHER_SUITE: if ( tls_opt_ciphersuite ) free( tls_opt_ciphersuite ); - tls_opt_ciphersuite = arg ? strdup( (char *) arg ) : NULL; + tls_opt_ciphersuite = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; default: return -1; diff --git a/libraries/libldap/tmplout.c b/libraries/libldap/tmplout.c index 06c8fe33cd..8b480a3ef5 100644 --- a/libraries/libldap/tmplout.c +++ b/libraries/libldap/tmplout.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/tmpltest.c b/libraries/libldap/tmpltest.c index b796933488..bbdae7fa1a 100644 --- a/libraries/libldap/tmpltest.c +++ b/libraries/libldap/tmpltest.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/ufn.c b/libraries/libldap/ufn.c index 9596adf131..9d215cdec9 100644 --- a/libraries/libldap/ufn.c +++ b/libraries/libldap/ufn.c @@ -1,55 +1,40 @@ +/* $OpenLDAP$ */ /* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * ufn.c */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include -#include -#include - -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#else /* DOS */ -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ - -#include "lber.h" -#include "ldap.h" - -#ifdef NEEDPROTOS -typedef int (*cancelptype)( void *cancelparm ); -#else /* NEEDPROTOS */ -typedef int (*cancelptype)(); -#endif /* NEEDPROTOS */ - -#ifdef NEEDPROTOS -static int ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" +#include "ldap_defaults.h" + +typedef int (*cancelptype) LDAP_P(( void *cancelparm )); + +/* local functions */ +static int ldap_ufn_search_ctx LDAP_P(( LDAP *ld, char **ufncomp, int ncomp, char *prefix, char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2, - char *tag3 ); -static LDAPMessage *ldap_msg_merge( LDAP *ld, LDAPMessage *a, LDAPMessage *b ); -static LDAPMessage *ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, + char *tag3 )); +static LDAPMessage *ldap_msg_merge LDAP_P(( LDAP *ld, LDAPMessage *a, LDAPMessage *b )); +static LDAPMessage *ldap_ufn_expand LDAP_P(( LDAP *ld, cancelptype cancelproc, void *cancelparm, char **dns, char *filter, int scope, - char **attrs, int aonly, int *err ); -LDAPFiltDesc *ldap_ufn_setfilter( LDAP *ld, char *fname ); -#else /* NEEDPROTOS */ -static LDAPMessage *ldap_msg_merge(); -static LDAPMessage *ldap_ufn_expand(); -LDAPFiltDesc *ldap_ufn_setfilter(); -#endif /* NEEDPROTOS */ + char **attrs, int aonly, int *err )); /* * ldap_ufn_search_ctx - do user friendly searching; provide cancel feature; @@ -63,8 +48,8 @@ LDAPFiltDesc *ldap_ufn_setfilter(); * attrsonly 1 => attributes only 0 => attributes and values * res will contain the result of the search * cancelproc routine that returns non-zero if operation should be - * cancelled. This can be NULL. If it is non-NULL, the - * routine will be called periodically. + * cancelled. This can be a null function pointer. If + * it is not 0, the routine will be called periodically. * cancelparm void * that is passed to cancelproc * tag[123] the ldapfilter.conf tag that will be used in phases * 1, 2, and 3 of the search, respectively @@ -83,13 +68,12 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2, char *tag3 ) { - char *dn, *ftag; - char **dns; - int max, i, err, scope, phase, tries; + char *dn, *ftag = NULL; + char **dns = NULL; + int max, i, err, scope = 0, phase, tries; LDAPFiltInfo *fi; LDAPMessage *tmpcand; LDAPMessage *candidates; - LDAPMessage *ldap_msg_merge(), *ldap_ufn_expand(); static char *objattrs[] = { "objectClass", NULL }; /* @@ -115,7 +99,8 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, if ( (quote = strrchr( ufncomp[ncomp], '"' )) != NULL ) *quote = '\0'; - strcpy( ufncomp[ncomp], ufncomp[ncomp] + 1 ); + SAFEMEMCPY( ufncomp[ncomp], ufncomp[ncomp] + 1, + strlen( ufncomp[ncomp] + 1 ) + 1 ); } if ( ncomp == 0 ) phase = 3; @@ -142,11 +127,11 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, if ( candidates == NULL ) { if ( prefix != NULL ) { - if ( (dns = (char **) malloc( sizeof(char *) + if ( (dns = (char **) LDAP_MALLOC( sizeof(char *) * 2 )) == NULL ) { return( ld->ld_errno = LDAP_NO_MEMORY ); } - dns[0] = strdup( prefix ); + dns[0] = LDAP_STRDUP( prefix ); dns[1] = NULL; } else { dns = NULL; @@ -161,14 +146,14 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, continue; if ( dns == NULL ) { - if ( (dns = (char **) malloc( + if ( (dns = (char **) LDAP_MALLOC( sizeof(char *) * 8 )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( LDAP_NO_MEMORY ); } max = 8; } else if ( i >= max ) { - if ( (dns = (char **) realloc( dns, + if ( (dns = (char **) LDAP_REALLOC( dns, sizeof(char *) * 2 * max )) == NULL ) { @@ -234,13 +219,14 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, } int -ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, +ldap_ufn_search_ct( + LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2, char *tag3 ) { char **ufncomp, **prefixcomp; char *pbuf; - int ncomp, pcomp, i, err; + int ncomp, pcomp, i, err = 0; /* initialize the getfilter stuff if it's not already */ if ( ld->ld_filtd == NULL && ldap_ufn_setfilter( ld, FILTERFILE ) @@ -280,7 +266,7 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, } for ( pcomp = 0; prefixcomp[pcomp] != NULL; pcomp++ ) ; /* NULL */ - if ( (pbuf = (char *) malloc( strlen( ld->ld_ufnprefix ) + 1 )) + if ( (pbuf = (char *) LDAP_MALLOC( strlen( ld->ld_ufnprefix ) + 1 )) == NULL ) { ldap_value_free( ufncomp ); ldap_value_free( prefixcomp ); @@ -309,7 +295,7 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, ldap_value_free( ufncomp ); ldap_value_free( prefixcomp ); - free( pbuf ); + LDAP_FREE( pbuf ); return( err ); } @@ -319,7 +305,8 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, * ldapfilter.conf tags. */ int -ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly, +ldap_ufn_search_c( + LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc, void *cancelparm ) { return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res, cancelproc, @@ -330,7 +317,8 @@ ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly, * same as ldap_ufn_search_c without the cancel function */ int -ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs, int attrsonly, +ldap_ufn_search_s( + LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly, LDAPMessage **res ) { struct timeval tv; @@ -444,7 +432,7 @@ ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, void *cancelparm, do { *err = ldap_result( ld, msgid, 1, &tv, &tmpres ); - if ( *err == 0 && cancelproc != NULL && + if ( *err == 0 && cancelproc != 0 && (*cancelproc)( cancelparm ) != 0 ) { ldap_abandon( ld, msgid ); *err = LDAP_USER_CANCELLED; @@ -476,7 +464,7 @@ ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, void *cancelparm, */ LDAPFiltDesc * -ldap_ufn_setfilter( LDAP *ld, char *fname ) +ldap_ufn_setfilter( LDAP *ld, LDAP_CONST char *fname ) { if ( ld->ld_filtd != NULL ) ldap_getfilter_free( ld->ld_filtd ); @@ -485,12 +473,12 @@ ldap_ufn_setfilter( LDAP *ld, char *fname ) } void -ldap_ufn_setprefix( LDAP *ld, char *prefix ) +ldap_ufn_setprefix( LDAP *ld, LDAP_CONST char *prefix ) { if ( ld->ld_ufnprefix != NULL ) - free( ld->ld_ufnprefix ); + LDAP_FREE( ld->ld_ufnprefix ); - ld->ld_ufnprefix = strdup( prefix ); + ld->ld_ufnprefix = LDAP_STRDUP( prefix ); } int diff --git a/libraries/libldap/unbind.c b/libraries/libldap/unbind.c index 93ce360d75..852926f785 100644 --- a/libraries/libldap/unbind.c +++ b/libraries/libldap/unbind.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index 988bac7d45..b632c688f8 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c new file mode 100644 index 0000000000..a3128e6e17 --- /dev/null +++ b/libraries/libldap/util-int.c @@ -0,0 +1,372 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* + * util-int.c Various functions to replace missing threadsafe ones. + * Without the real *_r funcs, things will + * work, but might not be threadsafe. + * + * Written by Bart Hartgers. + * + * Copyright 1998, A. Hartgers, All rights reserved. + * This software is not subject to any license of Eindhoven University of + * Technology, since it was written in my spare time. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + + +#include "portable.h" + +#include + +#include +#include +#include +#include + +#include "ldap-int.h" + +#if defined( LDAP_R_COMPILE ) +# include +#else +# undef HAVE_REENTRANT_FUNCTIONS +#endif + +#if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \ + && defined( CTIME_R_NARGS ) +# define USE_CTIME_R +#endif + +#if defined(HAVE_GETHOSTBYNAME_R) && \ + (GETHOSTBYNAME_R_NARGS > 6 || GETHOSTBYNAME_R_NARGS < 5) + /* Don't know how to handle this version, pretend it's not there */ +# undef HAVE_GETHOSTBYNAME_R +#endif +#if defined(HAVE_GETHOSTBYADDR_R) && \ + (GETHOSTBYADDR_R_NARGS > 8 || GETHOSTBYADDR_R_NARGS < 7) + /* Don't know how to handle this version, pretend it's not there */ +# undef HAVE_GETHOSTBYADDR_R +#endif + +#ifdef LDAP_R_COMPILE +# ifndef USE_CTIME_R + static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex; +# endif +# ifndef HAVE_GETHOSTBYNAME_R + static ldap_pvt_thread_mutex_t ldap_int_gethostbyname_mutex; +# endif +# ifndef HAVE_GETHOSTBYADDR_R + static ldap_pvt_thread_mutex_t ldap_int_gethostbyaddr_mutex; +# endif +#endif /* LDAP_R_COMPILE */ + +char *ldap_pvt_ctime( const time_t *tp, char *buf ) +{ +#ifdef USE_CTIME_R +# if (CTIME_R_NARGS > 3) || (CTIME_R_NARGS < 2) +# error "CTIME_R_NARGS should be 2 or 3" +# elif CTIME_R_NARGS > 2 && defined(CTIME_R_RETURNS_INT) + return( ctime_r(tp,buf,26) < 0 ? 0 : buf ); +# elif CTIME_R_NARGS > 2 + return ctime_r(tp,buf,26); +# else + return ctime_r(tp,buf); +# endif + +#else +# ifdef LDAP_R_COMPILE + ldap_pvt_thread_mutex_lock( &ldap_int_ctime_mutex ); +# endif + memcpy( buf, ctime(tp), 26 ); +# ifdef LDAP_R_COMPILE + ldap_pvt_thread_mutex_unlock( &ldap_int_ctime_mutex ); +# endif + return buf; +#endif +} + +#define BUFSTART 1024 +#define BUFMAX (32*1024) + +static char *safe_realloc( char **buf, int len ); +static int copy_hostent( struct hostent *res, char **buf, struct hostent * src ); + +int ldap_pvt_gethostbyname_a( + const char *name, + struct hostent *resbuf, + char **buf, + struct hostent **result, + int *herrno_ptr ) +{ +#if defined( HAVE_GETHOSTBYNAME_R ) + +# define NEED_SAFE_REALLOC 1 + int r=-1; + int buflen=BUFSTART; + *buf = NULL; + for(;buflenh_name ) + 1; + + for( n_alias=total_alias_len=0, p=src->h_aliases; (*p) ; p++ ) { + total_alias_len += strlen( *p ) + 1; + n_alias++; + } + + for( n_addr=0, p=src->h_addr_list; (*p) ; p++ ) { + n_addr++; + } + total_addr_len = n_addr * src->h_length; + + total_len = (n_alias + n_addr + 2) * sizeof( char * ) + + total_addr_len + total_alias_len + name_len; + + if (safe_realloc( buf, total_len )) { + tp = (char **) *buf; + tbuf = *buf + (n_alias + n_addr + 2) * sizeof( char * ); + memcpy( res, src, sizeof( struct hostent ) ); + /* first the name... */ + memcpy( tbuf, src->h_name, name_len ); + res->h_name = tbuf; tbuf+=name_len; + /* now the aliases */ + res->h_aliases = tp; + tbuf = cpy_aliases( &tp, tbuf, src->h_aliases ); + *tp++=NULL; + /* finally the addresses */ + res->h_addr_list = tp; + tbuf = cpy_addresses( &tp, tbuf, src->h_addr_list, src->h_length ); + *tp++=NULL; + return 0; + } + return -1; +} +#endif + +#if defined( NEED_SAFE_REALLOC ) +static char *safe_realloc( char **buf, int len ) +{ + char *tmpbuf; + tmpbuf = LDAP_REALLOC( *buf, len ); + if (tmpbuf) { + *buf=tmpbuf; + } + return tmpbuf; +} +#endif + + diff --git a/libraries/libldap_r/Makefile.in b/libraries/libldap_r/Makefile.in index a305b7d20e..fba054ecb0 100644 --- a/libraries/libldap_r/Makefile.in +++ b/libraries/libldap_r/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## ## Makefile.in for LDAP -lldap ## @@ -15,9 +16,9 @@ XXSRCS = apitest.c test.c tmpltest.c extended.c \ getdn.c getentry.c getattr.c getvalues.c addentry.c \ request.c getdxbyname.c os-ip.c url.c charset.c \ init.c options.c print.c string.c util-int.c schema.c \ - charray.c digest.c tls.c + charray.c digest.c tls.c dn.c SRCS = thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \ - thr_sleep.c thr_stub.c rdwr.c + thr_pth.c thr_sleep.c thr_stub.c rdwr.c OBJS = extended.lo \ bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \ modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \ @@ -27,8 +28,8 @@ OBJS = extended.lo \ request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \ init.lo options.lo print.lo string.lo util-int.lo schema.lo \ thr_posix.lo thr_cthreads.lo thr_thr.lo thr_lwp.lo thr_nt.lo \ - thr_sleep.lo thr_stub.lo rdwr.lo \ - charray.lo digest.lo tls.lo + thr_pth.lo thr_sleep.lo thr_stub.lo rdwr.lo \ + charray.lo digest.lo tls.lo dn.lo LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries diff --git a/libraries/libldap_r/rdwr.c b/libraries/libldap_r/rdwr.c new file mode 100644 index 0000000000..ab31f426ae --- /dev/null +++ b/libraries/libldap_r/rdwr.c @@ -0,0 +1,262 @@ +/* $OpenLDAP$ */ +/* +** This is an improved implementation of Reader/Writer locks does +** not protect writers from starvation. That is, if a writer is +** currently waiting on a reader, any new reader will get +** the lock before the writer. +** +** Does not support cancellation nor does any status checking. +*/ + +/******************************************************** + * Adapted from: + * "Programming with Posix Threads" + * by David R Butenhof + * Addison-Wesley + ******************************************************** + */ + +#include "portable.h" + +#include + +#include +#include + +#include "ldap_pvt_thread.h" + +int +ldap_pvt_thread_rdwr_init( ldap_pvt_thread_rdwr_t *rw ) +{ + assert( rw != NULL ); + + memset( rw, 0, sizeof(ldap_pvt_thread_rdwr_t) ); + + /* we should check return results */ + ldap_pvt_thread_mutex_init( &rw->ltrw_mutex ); + ldap_pvt_thread_cond_init( &rw->ltrw_read ); + ldap_pvt_thread_cond_init( &rw->ltrw_write ); + + rw->ltrw_valid = LDAP_PVT_THREAD_RDWR_VALID; + return 0; +} + +int +ldap_pvt_thread_rdwr_destroy( ldap_pvt_thread_rdwr_t *rw ) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID ) + return LDAP_PVT_THREAD_EINVAL; + + ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex ); + + /* active threads? */ + if( rw->ltrw_r_active > 0 || rw->ltrw_w_active > 1) { + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + return LDAP_PVT_THREAD_EBUSY; + } + + /* waiting threads? */ + if( rw->ltrw_r_wait > 0 || rw->ltrw_w_wait > 0) { + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + return LDAP_PVT_THREAD_EBUSY; + } + + rw->ltrw_valid = 0; + + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + + ldap_pvt_thread_mutex_destroy( &rw->ltrw_mutex ); + ldap_pvt_thread_cond_destroy( &rw->ltrw_read ); + ldap_pvt_thread_cond_destroy( &rw->ltrw_write ); + + return 0; +} + +int ldap_pvt_thread_rdwr_rlock( ldap_pvt_thread_rdwr_t *rw ) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID ) + return LDAP_PVT_THREAD_EINVAL; + + ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex ); + + if( rw->ltrw_w_active > 1 ) { + /* writer is active */ + + rw->ltrw_r_wait++; + + do { + ldap_pvt_thread_cond_wait( + &rw->ltrw_read, &rw->ltrw_mutex ); + } while( rw->ltrw_w_active > 1 ); + + rw->ltrw_r_wait--; + } + + rw->ltrw_r_active++; + + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + + return 0; +} + +int ldap_pvt_thread_rdwr_rtrylock( ldap_pvt_thread_rdwr_t *rw ) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID ) + return LDAP_PVT_THREAD_EINVAL; + + ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex ); + + if( rw->ltrw_w_active > 1) { + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + return LDAP_PVT_THREAD_EBUSY; + } + + rw->ltrw_r_active++; + + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + + return 0; +} + +int ldap_pvt_thread_rdwr_runlock( ldap_pvt_thread_rdwr_t *rw ) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID ) + return LDAP_PVT_THREAD_EINVAL; + + ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex ); + + rw->ltrw_r_active--; + + if (rw->ltrw_r_active == 0 && rw->ltrw_w_wait > 0 ) { + ldap_pvt_thread_cond_signal( &rw->ltrw_write ); + } + + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + + return 0; +} + +int ldap_pvt_thread_rdwr_wlock( ldap_pvt_thread_rdwr_t *rw ) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID ) + return LDAP_PVT_THREAD_EINVAL; + + ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex ); + + if ( rw->ltrw_w_active > 0 || rw->ltrw_r_active > 0 ) { + rw->ltrw_w_wait++; + + do { + ldap_pvt_thread_cond_wait( + &rw->ltrw_write, &rw->ltrw_mutex ); + } while ( rw->ltrw_w_active > 0 || rw->ltrw_r_active > 0 ); + + rw->ltrw_w_wait--; + } + + rw->ltrw_w_active++; + + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + + return 0; +} + +int ldap_pvt_thread_rdwr_wtrylock( ldap_pvt_thread_rdwr_t *rw ) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID ) + return LDAP_PVT_THREAD_EINVAL; + + ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex ); + + if ( rw->ltrw_w_active > 0 || rw->ltrw_r_active > 0 ) { + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + return LDAP_PVT_THREAD_EBUSY; + } + + rw->ltrw_w_active++; + + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + + return 0; +} + +int ldap_pvt_thread_rdwr_wunlock( ldap_pvt_thread_rdwr_t *rw ) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + if( rw->ltrw_valid != LDAP_PVT_THREAD_RDWR_VALID ) + return LDAP_PVT_THREAD_EINVAL; + + ldap_pvt_thread_mutex_lock( &rw->ltrw_mutex ); + + rw->ltrw_w_active--; + + if (rw->ltrw_r_wait > 0) { + ldap_pvt_thread_cond_broadcast( &rw->ltrw_read ); + + } else if (rw->ltrw_w_wait > 0) { + ldap_pvt_thread_cond_signal( &rw->ltrw_write ); + } + + ldap_pvt_thread_mutex_unlock( &rw->ltrw_mutex ); + + return 0; +} + +#ifdef LDAP_DEBUG + +/* just for testing, + * return 0 if false, suitable for assert(ldap_pvt_thread_rdwr_Xchk(rdwr)) + * + * Currently they don't check if the calling thread is the one + * that has the lock, just that there is a reader or writer. + * + * Basically sufficent for testing that places that should have + * a lock are caught. + */ + +int ldap_pvt_thread_rdwr_readers(ldap_pvt_thread_rdwr_t *rw) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + return( rw->ltrw_r_active ); +} + +int ldap_pvt_thread_rdwr_writers(ldap_pvt_thread_rdwr_t *rw) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + return( rw->ltrw_w_active ); +} + +int ldap_pvt_thread_rdwr_active(ldap_pvt_thread_rdwr_t *rw) +{ + assert( rw != NULL ); + assert( rw->ltrw_valid == LDAP_PVT_THREAD_RDWR_VALID ); + + return(ldap_pvt_thread_rdwr_readers(rw) + + ldap_pvt_thread_rdwr_writers(rw)); +} + +#endif /* LDAP_DEBUG */ diff --git a/libraries/libldap_r/thr_cthreads.c b/libraries/libldap_r/thr_cthreads.c index 5eda39c798..8d3949aa98 100644 --- a/libraries/libldap_r/thr_cthreads.c +++ b/libraries/libldap_r/thr_cthreads.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA * All rights reserved. diff --git a/libraries/libldap_r/thr_lwp.c b/libraries/libldap_r/thr_lwp.c new file mode 100644 index 0000000000..3c1dff3389 --- /dev/null +++ b/libraries/libldap_r/thr_lwp.c @@ -0,0 +1,363 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* thr_lwp.c - wrappers around SunOS LWP threads */ + +/* BUGS: + * - slurpd calls the get_stack/free_stack functions. Should be fixed, so + * they can become static. + */ + +#include "portable.h" + +#if defined( HAVE_LWP ) + +/************* + * * + * SunOS LWP * + * * + *************/ + +/* This implementation NEEDS WORK. It currently does not compile */ + +#include + +#include +#include + +#include "ldap-int.h" + +#include "ldap_pvt_thread.h" + +#include +#include + +#define MAX_STACK 51200 +#define MAX_THREADS 20 + +/* + * Initialize LWP by spinning of a schedular + */ +int +ldap_pvt_thread_initialize( void ) +{ + thread_t tid; + stkalign_t *stack; + int stackno; + + if (( stack = get_stack( &stackno )) == NULL ) { + return -1; + } + + lwp_create( &tid, lwp_scheduler, MINPRIO, 0, stack, 1, stackno ); + return 0; +} + +int +ldap_pvt_thread_destroy( void ) +{ + /* need to destory lwp_scheduler thread and clean up private + variables */ + return 0; +} + +struct stackinfo { + int stk_inuse; + stkalign_t *stk_stack; +}; + +static struct stackinfo *stacks; + +static stkalign_t * ldap_pvt_thread_get_stack( int *stacknop ) +{ + int i; + + if ( stacks == NULL ) { + stacks = (struct stackinfo *) LDAP_CALLOC( 1, MAX_THREADS * + sizeof(struct stackinfo) ); + + if( stacks == NULL ) { + Debug( LDAP_DEBUG_ANY, "stacks allocation failed", + 0, 0, 0 ); + return NULL; + } + } + + for ( i = 0; i < MAX_THREADS; i++ ) { + if ( stacks[i].stk_inuse == 0 ) { + break; + } + } + + if ( i == MAX_THREADS ) { + Debug( LDAP_DEBUG_ANY, + "no more stacks (max %d) - increase MAX_THREADS for more", + MAX_THREADS, 0, 0 ); + return( NULL ); + } + + if ( stacks[i].stk_stack == NULL ) { + stacks[i].stk_stack = (stkalign_t *) LDAP_MALLOC( + (MAX_STACK / sizeof(stkalign_t) + 1 ) + * sizeof(stkalign_t) ); + + if( stacks[i].stk_stack == NULL ) { + Debug( LDAP_DEBUG_ANY, "stack allocation failed", + 0, 0, 0 ); + return( NULL ); + } + } + + *stacknop = i; + stacks[i].stk_inuse = 1; + return( stacks[i].stk_stack + MAX_STACK / sizeof(stkalign_t) ); +} + +static void +ldap_pvt_thread_free_stack( int stackno ) +{ + if ( stackno < 0 || stackno > MAX_THREADS ) { + Debug( LDAP_DEBUG_ANY, "free_stack of bogus stack %d\n", + stackno, 0, 0 ); + } + + stacks[stackno].stk_inuse = 0; +} + +static void +lwp_create_stack( void *(*func)(), void *arg, int stackno ) +{ + (*func)( arg ); + + ldap_pvt_thread_free_stack( stackno ); +} + +int +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void *), + void *arg) +{ + stkalign_t *stack; + int stackno; + + if ( (stack = ldap_pvt_thread_get_stack( &stackno )) == NULL ) { + return( -1 ); + } + return( lwp_create( thread, lwp_create_stack, MINPRIO, 0, + stack, 3, start_routine, arg, stackno ) ); +} + +void +ldap_pvt_thread_exit( void *retval ) +{ + lwp_destroy( SELF ); +} + +unsigned int +ldap_pvt_thread_sleep( + unsigned int interval +) +{ + thread_t mylwp; + tl_t *t, *nt; + time_t now; + + + if ( lwp_self( &mylwp ) < 0 ) { + return -1; + } + + time( &now ); + + mon_enter( &sglob->tsl_mon ); + + if ( sglob->tsl_list != NULL ) { + for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { + if ( SAMETHREAD( t->tl_tid, mylwp )) { + /* We're already sleeping? */ + t->tl_wake = now + interval; + mon_exit( &sglob->tsl_mon ); + lwp_suspend( mylwp ); + return 0; + } + } + } + + nt = (tl_t *) LDAP_MALLOC( sizeof( tl_t )); + + if( nt == NULL ) return -1; + + nt->tl_next = sglob->tsl_list; + nt->tl_wake = now + interval; + nt->tl_tid = mylwp; + sglob->tsl_list = nt; + + mon_exit( &sglob->tsl_mon ); + + lwp_suspend( mylwp ); + return 0; +} + +/* + * The lwp_scheduler thread periodically checks to see if any threads + * are due to be resumed. If there are, it resumes them. Otherwise, + * it computes the lesser of ( 1 second ) or ( the minimum time until + * a thread need to be resumed ) and puts itself to sleep for that amount + * of time. + */ +static void +lwp_scheduler( + int stackno +) +{ + time_t now, min; + struct timeval interval; + tl_t *t; + + while ( !sglob->slurpd_shutdown ) { + mon_enter( &sglob->tsl_mon ); + + time( &now ); + min = 0L; + if ( sglob->tsl_list != NULL ) { + for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { + if (( t->tl_wake > 0L ) && ( t->tl_wake < now )) { + lwp_resume( t->tl_tid ); + t->tl_wake = 0L; + } + + if (( t->tl_wake > now ) && ( t->tl_wake < min )) { + min = t->tl_wake; + } + } + } + + mon_exit( &sglob->tsl_mon ); + + interval.tv_usec = 0L; + if ( min == 0L ) { + interval.tv_sec = 1L; + } else { + interval.tv_sec = min; + } + + lwp_sleep( &interval ); + } + + mon_enter( &sglob->tsl_mon ); + + for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { + lwp_resume( t->tl_tid ); + } + + mon_exit( &sglob->tsl_mon ); + + free_stack( stackno ); +} + +int +ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +{ + lwp_join( thread ); + return 0; +} + +int +ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +{ + return 0; +} + +int +ldap_pvt_thread_yield( void ) +{ + lwp_yield( SELF ); + return 0; +} + +int +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +{ + /* + * lwp cv_create requires the monitor id be passed in + * when the cv is created, pthreads passes it when the + * condition is waited for. so, we fake the creation + * here and actually do it when the cv is waited for + * later. + */ + + cond->lcv_created = 0; + + return( 0 ); +} + +int +ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +{ + return( cond->lcv_created ? cv_notify( cv->lcv_cv ) : 0 ); +} + +int +ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) +{ + if ( ! cond->lcv_created ) { + cv_create( &cond->lcv_cv, *mutex ); + cond->lcv_created = 1; + } + + return( cv_wait( cond->lcv_cv ) ); +} + +int +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +{ + return( mon_create( mutex ) ); +} + +int +ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +{ + return( mon_destroy( *mutex ) ); +} + +int +ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +{ + return( mon_enter( *mutex ) ); +} + +int +ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +{ + return( mon_exit( *mutex ) ); +} + +int +ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp ) +{ + return( mon_cond_enter( *mp ) ); +} + +int +ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) +{ + return( cv->lcv_created ? cv_destroy( cv->lcv_cv ) : 0 ); +} + +int +ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv ) +{ + return( cv->lcv_created ? cv_broadcast( cv->lcv_cv ) : 0 ); +} + +#endif /* HAVE_LWP */ diff --git a/libraries/libldap_r/thr_nt.c b/libraries/libldap_r/thr_nt.c new file mode 100644 index 0000000000..20cca306ea --- /dev/null +++ b/libraries/libldap_r/thr_nt.c @@ -0,0 +1,151 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* thr_nt.c - wrapper around NT threads */ + +#include "portable.h" + +#if defined( HAVE_NT_THREADS ) + +#include "ldap_pvt_thread.h" + +int +ldap_pvt_thread_initialize( void ) +{ + return 0; +} + +int +ldap_pvt_thread_destroy( void ) +{ + return 0; +} + +int +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void *), + void *arg) +{ + *thread = (ldap_pvt_thread_t)_beginthread( (void *) start_routine, + 0, arg ); + return ( (unsigned long)*thread == -1 ? -1 : 0 ); +} + +void +ldap_pvt_thread_exit( void *retval ) +{ + _endthread( ); +} + +int +ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +{ + DWORD status; + status = WaitForSingleObject( (HANDLE) thread, INFINITE ); + if (status == WAIT_FAILED) { + return -1; + } + return 0; +} + +int +ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +{ + return 0; +} + +int +ldap_pvt_thread_yield( void ) +{ + Sleep( 0 ); + return 0; +} + +int +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +{ + *cond = CreateEvent( NULL, FALSE, FALSE, NULL ); + return( 0 ); +} + +int +ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) +{ + CloseHandle( *cv ); + return( 0 ); +} + +int +ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +{ + SetEvent( *cond ); + return( 0 ); +} + +int +ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) +{ + ReleaseMutex( *mutex ); + WaitForSingleObject( *cond, INFINITE ); + WaitForSingleObject( *mutex, INFINITE ); + return( 0 ); +} + +int +ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv ) +{ + SetEvent( *cv ); + return( 0 ); +} + +int +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +{ + *mutex = CreateMutex( NULL, 0, NULL ); + return ( 0 ); +} + +int +ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +{ + CloseHandle( *mutex ); + return ( 0 ); +} + +int +ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +{ + WaitForSingleObject( *mutex, INFINITE ); + return ( 0 ); +} + +int +ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +{ + ReleaseMutex( *mutex ); + return ( 0 ); +} + +int +ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp ) +{ + DWORD status; + + status = WaitForSingleObject( *mp, 0 ); + if ( (status == WAIT_FAILED) || (status == WAIT_TIMEOUT) ) + return 0; + else + return 1; +} + +#endif diff --git a/libraries/libldap_r/thr_posix.c b/libraries/libldap_r/thr_posix.c new file mode 100644 index 0000000000..c44bee48c3 --- /dev/null +++ b/libraries/libldap_r/thr_posix.c @@ -0,0 +1,205 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* thr_posix.c - wrapper around posix and posixish thread implementations. + */ + +#include "portable.h" + +#if defined( HAVE_PTHREADS ) + +#include + +#include "ldap_pvt_thread.h" + + +#if HAVE_PTHREADS_D4 +# define LDAP_PVT_THREAD_ATTR_DEFAULT pthread_attr_default +# define LDAP_PVT_THREAD_CONDATTR_DEFAULT pthread_condattr_default +# define LDAP_PVT_THREAD_MUTEXATTR_DEFAULT pthread_mutexattr_default +#else +# define LDAP_PVT_THREAD_ATTR_DEFAULT NULL +# define LDAP_PVT_THREAD_CONDATTR_DEFAULT NULL +# define LDAP_PVT_THREAD_MUTEXATTR_DEFAULT NULL +#endif + + +int +ldap_pvt_thread_initialize( void ) +{ +#if defined( LDAP_THREAD_CONCURRENCY ) && HAVE_PTHREAD_SETCONCURRENCY + ldap_pvt_thread_set_concurrency( LDAP_THREAD_CONCURRENCY ); +#endif + return 0; +} + +int +ldap_pvt_thread_destroy( void ) +{ + return 0; +} + +#ifdef HAVE_PTHREAD_SETCONCURRENCY +int +ldap_pvt_thread_set_concurrency(int n) +{ +#ifdef HAVE_PTHREAD_SETCONCURRENCY + return pthread_setconcurrency( n ); +#elif HAVE_THR_SETCONCURRENCY + return pthread_setconcurrency( n ); +#else + return 0; +#endif +} +#endif + +#ifdef HAVE_PTHREAD_GETCONCURRENCY +int +ldap_pvt_thread_get_concurrency(void) +{ +#ifdef HAVE_PTHREAD_GETCONCURRENCY + return pthread_getconcurrency(); +#elif HAVE_THR_GETCONCURRENCY + return pthread_getconcurrency(); +#else + return 0; +#endif +} +#endif + +int +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void * ), + void *arg) +{ + int rtn = pthread_create( thread, LDAP_PVT_THREAD_ATTR_DEFAULT, + start_routine, arg ); + + if( detach ) { +#ifdef HAVE_PTHREADS_FINAL + pthread_detach( *thread ); +#else + pthread_detach( thread ); +#endif + } + return rtn; +} + +void +ldap_pvt_thread_exit( void *retval ) +{ + pthread_exit( retval ); +} + +int +ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +{ +#if !defined( HAVE_PTHREADS_FINAL ) + void *dummy; + if (thread_return==NULL) + thread_return=&dummy; +#endif + return pthread_join( thread, thread_return ); +} + +int +ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +{ +#ifdef HAVE_PTHREAD_KILL + return pthread_kill( thread, signo ); +#else + /* pthread package with DCE */ + if (kill( getpid(), signo )<0) + return errno; + return 0; +#endif +} + +int +ldap_pvt_thread_yield( void ) +{ +#ifdef _POSIX_THREAD_IS_GNU_PTH + sched_yield(); + return 0; + +#elif HAVE_SCHED_YIELD + return sched_yield(); + +#elif HAVE_PTHREAD_YIELD + pthread_yield(); + return 0; + +#elif HAVE_THR_YIELD + return thr_yield(); + +#else + return 0; +#endif +} + +int +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +{ + return pthread_cond_init( cond, LDAP_PVT_THREAD_CONDATTR_DEFAULT ); +} + +int +ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond ) +{ + return pthread_cond_destroy( cond ); +} + +int +ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +{ + return pthread_cond_signal( cond ); +} + +int +ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) +{ + return pthread_cond_broadcast( cond ); +} + +int +ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) +{ + return pthread_cond_wait( cond, mutex ); +} + +int +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +{ + return pthread_mutex_init( mutex, LDAP_PVT_THREAD_MUTEXATTR_DEFAULT ); +} + +int +ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +{ + return pthread_mutex_destroy( mutex ); +} + +int +ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +{ + return pthread_mutex_lock( mutex ); +} + +int +ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +{ + return pthread_mutex_unlock( mutex ); +} + +#endif /* HAVE_PTHREADS */ + diff --git a/libraries/libldap_r/thr_pth.c b/libraries/libldap_r/thr_pth.c new file mode 100644 index 0000000000..132644cff0 --- /dev/null +++ b/libraries/libldap_r/thr_pth.c @@ -0,0 +1,143 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* thr_thr.c - wrappers around solaris threads */ + +#include "portable.h" + +#if defined( HAVE_GNU_PTH ) + +#include "ldap_pvt_thread.h" + +/******************* + * * + * GNU Pth Threads * + * * + *******************/ + +static pth_attr_t detach_attr; + +int +ldap_pvt_thread_initialize( void ) +{ + detach_attr = pth_attr_new(); + pth_attr_set( detach_attr, PTH_ATTR_JOINABLE, FALSE ); + return pth_init(); +} + +int +ldap_pvt_thread_destroy( void ) +{ + pth_attr_destroy(detach_attr); + pth_kill(); + return 0; +} + +int +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void *), + void *arg) +{ + *thread = pth_spawn( detach ? detach_attr : PTH_ATTR_DEFAULT, + start_routine, arg ); + + return *thread == NULL; +} + +void +ldap_pvt_thread_exit( void *retval ) +{ + pth_exit( retval ); +} + +int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +{ + pth_join( thread, thread_return ); + return 0; +} + +int +ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +{ + pth_raise( thread, signo ); + return 0; +} + +int +ldap_pvt_thread_yield( void ) +{ + pth_yield(NULL); + return 0; +} + +int +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +{ + return( pth_cond_init( cond ) ); +} + +int +ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +{ + return( pth_cond_notify( cond, 0 ) ); +} + +int +ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) +{ + return( pth_cond_notify( cond, 1 ) ); +} + +int +ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) +{ + return( pth_cond_await( cond, mutex, NULL ) ); +} + +int +ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) +{ + return 0; +} + +int +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +{ + return( pth_mutex_init( mutex ) ); +} + +int +ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +{ + return 0; +} + +int +ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +{ + return( pth_mutex_acquire( mutex, 0, NULL ) ); +} + +int +ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +{ + return( pth_mutex_release( mutex ) ); +} + +int +ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex ) +{ + return( pth_mutex_acquire( mutex, 1, NULL ) ); +} + +#endif /* HAVE_GNU_PTH */ diff --git a/libraries/libldap_r/thr_sleep.c b/libraries/libldap_r/thr_sleep.c new file mode 100644 index 0000000000..fac90d0825 --- /dev/null +++ b/libraries/libldap_r/thr_sleep.c @@ -0,0 +1,57 @@ +/* $OpenLDAP$ */ +/* + * Copyright (c) 1996 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +/* + * ldap_pvt_thread_sleep.c - allow a thread to sleep without putting + * the whole process (e.g. pod under lwp) to sleep. + * + * Contains platform-specific code to allow this: + * + * Under non-preemptive threads packages like SunOS lwp, tsleep() adds + * the thread to a list of sleepers. The lwp_scheduler process takes + * care of resuming suspended threads. + * + * Under a fully-preemptive threads package, like Solaris threads, + * tsleep just calls sleep(), and there is no scheduler thread. Life + * is so much simpler... + */ + +#include "portable.h" + +#if !defined( HAVE_LWP ) + +#include +#include +#include /* get sleep() */ + +#include "ldap_pvt_thread.h" + + +/* + * Here we assume we have fully preemptive threads and that sleep() + * does the right thing. + */ +unsigned int +ldap_pvt_thread_sleep( + unsigned int interval +) +{ + sleep( interval ); + return 0; +} + +#else + +/* LWP implementation of sleep can be found in thr_lwp.c */ + +#endif /* HAVE_LWP */ diff --git a/libraries/libldap_r/thr_stub.c b/libraries/libldap_r/thr_stub.c new file mode 100644 index 0000000000..60da3cec1f --- /dev/null +++ b/libraries/libldap_r/thr_stub.c @@ -0,0 +1,135 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* thr_stub.c - stubs for the threads */ + +#include "portable.h" + +#if defined( NO_THREADS ) + +#include "ldap_pvt_thread.h" + +/*********************************************************************** + * * + * no threads package defined for this system - fake ok returns from * + * all threads routines (making it single-threaded). * + * * + ***********************************************************************/ + +int +ldap_pvt_thread_initialize( void ) +{ + return 0; +} + +int +ldap_pvt_thread_destroy( void ) +{ + return 0; +} + +static void* ldap_int_status = NULL; + +int +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)(void *), + void *arg) +{ + if( ! detach ) ldap_int_status = NULL; + start_routine( arg ); + return 0; +} + +void +ldap_pvt_thread_exit( void *retval ) +{ + if( retval != NULL ) { + ldap_int_status = retval; + } + return; +} + +int +ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **status ) +{ + if(status != NULL) *status = ldap_int_status; + return 0; +} + +int +ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +{ + return 0; +} + +int +ldap_pvt_thread_yield( void ) +{ + return 0; +} + +int +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +{ + return 0; +} + +int +ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond ) +{ + return 0; +} + +int +ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +{ + return 0; +} + +int +ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) +{ + return 0; +} + +int +ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) +{ + return 0; +} + +int +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +{ + return 0; +} + +int +ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +{ + return 0; +} + +int +ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +{ + return 0; +} + +int +ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +{ + return 0; +} + +#endif /* NO_THREADS */ diff --git a/libraries/libldap_r/thr_thr.c b/libraries/libldap_r/thr_thr.c new file mode 100644 index 0000000000..bb3b10d6b7 --- /dev/null +++ b/libraries/libldap_r/thr_thr.c @@ -0,0 +1,151 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* thr_thr.c - wrappers around solaris threads */ + +#include "portable.h" + +#if defined( HAVE_THR ) + +#include "ldap_pvt_thread.h" + +/******************* + * * + * Solaris Threads * + * * + *******************/ + +int +ldap_pvt_thread_initialize( void ) +{ +#ifdef LDAP_THREAD_CONCURRENCY + thr_setconcurrency( LDAP_THREAD_CONCURRENCY ); +#endif + return 0; +} + +int +ldap_pvt_thread_destroy( void ) +{ + return 0; +} + +int +ldap_pvt_thread_set_concurrency(int n) +{ + return thr_setconcurrency( n ); +} + +int +ldap_pvt_thread_get_concurrency(void) +{ + return thr_getconcurrency(); +} + +int +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void *), + void *arg) +{ + return( thr_create( NULL, 0, start_routine, arg, + detach ? THR_DETACHED : 0, + thread ) ); +} + +void +ldap_pvt_thread_exit( void *retval ) +{ + thr_exit( NULL ); +} + +int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) +{ + thr_join( thread, NULL, thread_return ); + return 0; +} + +int +ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) +{ + thr_kill( thread, signo ); + return 0; +} + +int +ldap_pvt_thread_yield( void ) +{ + thr_yield(); + return 0; +} + +int +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) +{ + return( cond_init( cond, USYNC_THREAD, NULL ) ); +} + +int +ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) +{ + return( cond_signal( cond ) ); +} + +int +ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv ) +{ + return( cond_broadcast( cv ) ); +} + +int +ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) +{ + return( cond_wait( cond, mutex ) ); +} + +int +ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) +{ + return( cond_destroy( cv ) ); +} + +int +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +{ + return( mutex_init( mutex, USYNC_THREAD, NULL ) ); +} + +int +ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) +{ + return( mutex_destroy( mutex ) ); +} + +int +ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) +{ + return( mutex_lock( mutex ) ); +} + +int +ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) +{ + return( mutex_unlock( mutex ) ); +} + +int +ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp ) +{ + return( mutex_trylock( mp ) ); +} + +#endif /* HAVE_THR */ diff --git a/libraries/libldbm/Makefile.in b/libraries/libldbm/Makefile.in new file mode 100644 index 0000000000..7926c3673d --- /dev/null +++ b/libraries/libldbm/Makefile.in @@ -0,0 +1,18 @@ +# $OpenLDAP$ +## +## Makefile for -lldbm +## + +LIBRARY = libldbm.a +XPROGRAMS = testldbm +SRCS = ldbm.c +OBJS = ldbm.o + +LDAP_INCDIR= ../../include +LDAP_LIBDIR= ../../libraries + +XLIBS = -lldbm -lavl +XXLIBS = $(LDBM_LIBS) + +testldbm: libldbm.a testldbm.o + $(CC) $(LDFLAGS) -o $@ testldbm.o $(LIBS) diff --git a/libraries/libldbm/ldbm.c b/libraries/libldbm/ldbm.c index e9091a9a10..461db8657e 100644 --- a/libraries/libldbm/ldbm.c +++ b/libraries/libldbm/ldbm.c @@ -1,4 +1,5 @@ /* ldbm.c - ldap dbm compatibility routines */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -114,7 +115,7 @@ DB_ENV *ldbm_Env = NULL; int ldbm_initialize( void ) { int err; - int envFlags; + u_int32_t envFlags; if(ldbm_initialized++) return 1; @@ -441,12 +442,16 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize ) #ifdef HAVE_ST_BLKSIZE if ( dbcachesize > 0 && stat( name, &st ) == 0 ) { - dbcachesize = (dbcachesize / st.st_blksize); + dbcachesize /= st.st_blksize; + if( dbcachesize == 0 ) dbcachesize = 1; gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) ); } #else - dbcachesize = (dbcachesize / 4096); - gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) ); + if ( dbcachesize > 0 ) { + dbcachesize /= 4096; + if( dbcachesize == 0 ) dbcachesize = 1; + gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) ); + } #endif LDBM_UNLOCK; diff --git a/libraries/libldif/Makefile.in b/libraries/libldif/Makefile.in index 9b7e6b9a4a..020e16d816 100644 --- a/libraries/libldif/Makefile.in +++ b/libraries/libldif/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## ## Makefile for -lldif ## diff --git a/libraries/libldif/fetch.c b/libraries/libldif/fetch.c index 69c15b7749..94d0861455 100644 --- a/libraries/libldif/fetch.c +++ b/libraries/libldif/fetch.c @@ -1,4 +1,5 @@ /* line64.c - routines for dealing with the slapd line format */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -71,7 +72,7 @@ ldif_fetch_url( total = 0; - while( bytes = fread( buffer, 1, sizeof(buffer), url ) ) { + while( (bytes = fread( buffer, 1, sizeof(buffer), url )) != 0 ) { char *newp = ber_memrealloc( p, total + bytes ); if( newp == NULL ) { ber_memfree( p ); @@ -90,4 +91,3 @@ ldif_fetch_url( return 0; } - diff --git a/libraries/libldif/line64.c b/libraries/libldif/line64.c index cd84e3d26b..f2a8e995ed 100644 --- a/libraries/libldif/line64.c +++ b/libraries/libldif/line64.c @@ -1,4 +1,5 @@ /* line64.c - routines for dealing with the slapd line format */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -110,6 +111,9 @@ ldif_parse_line( } *s++ = '\0'; + url = 0; + b64 = 0; + if ( *s == '\0' ) { /* no value */ value = NULL; @@ -117,9 +121,6 @@ ldif_parse_line( goto done; } - url = 0; - b64 = 0; - if ( *s == '<' ) { s++; url = 1; @@ -341,11 +342,12 @@ ldif_sput( len++; } + } #ifdef LDAP_DEBUG - } else { + else { assert( type == LDIF_PUT_COMMENT ); -#endif } +#endif switch( type ) { case LDIF_PUT_NOVALUE: @@ -552,7 +554,7 @@ ldif_read_record( char **bufp, /* ptr to malloced output buffer */ int *buflenp ) /* ptr to length of *bufp */ { - char linebuf[BUFSIZ], *line; + char linebuf[BUFSIZ], *line, *nbufp; ber_len_t lcur = 0, len, linesize; int last_ch = '\n', found_entry = 0, stop; @@ -588,7 +590,8 @@ ldif_read_record( } if ( *buflenp - lcur <= len ) { - char *nbufp = ber_memrealloc( *bufp, *buflenp += len + BUFSIZ ); + *buflenp += len + BUFSIZ; + nbufp = ber_memrealloc( *bufp, *buflenp ); if( nbufp == NULL ) { return 0; } diff --git a/libraries/liblutil/Makefile.in b/libraries/liblutil/Makefile.in index 189f2f6623..31e3aa9d8d 100644 --- a/libraries/liblutil/Makefile.in +++ b/libraries/liblutil/Makefile.in @@ -1,12 +1,13 @@ +# $OpenLDAP$ ## ## Makefile for -lutil ## LIBRARY = liblutil.a SRCS = base64.c debug.c detach.c \ - md5.c passwd.c sha1.c getpass.c lockf.c utils.c + md5.c passwd.c sha1.c getpass.c lockf.c utils.c sockpair.c OBJS = base64.o debug.o detach.o \ - md5.o passwd.o sha1.o getpass.o lockf.o utils.o \ + md5.o passwd.o sha1.o getpass.o lockf.o utils.o sockpair.o \ @LIBOBJS@ LDAP_INCDIR= ../../include diff --git a/libraries/liblutil/base64.c b/libraries/liblutil/base64.c index e837088347..d4e107b621 100644 --- a/libraries/liblutil/base64.c +++ b/libraries/liblutil/base64.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblutil/debug.c b/libraries/liblutil/debug.c index f6b9979060..a6fc5064d2 100644 --- a/libraries/liblutil/debug.c +++ b/libraries/liblutil/debug.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -33,7 +34,7 @@ static FILE *log_file; int lutil_debug_file( FILE *file ) { - log_file = log_file; + log_file = file; return 0; } diff --git a/libraries/liblutil/detach.c b/libraries/liblutil/detach.c index a398ed356a..c4f2aa4478 100644 --- a/libraries/liblutil/detach.c +++ b/libraries/liblutil/detach.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1990, 1994 Regents of the University of Michigan. * All rights reserved. diff --git a/libraries/liblutil/getopt.c b/libraries/liblutil/getopt.c index 2294dcf519..3b0ca476a5 100644 --- a/libraries/liblutil/getopt.c +++ b/libraries/liblutil/getopt.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblutil/getpass.c b/libraries/liblutil/getpass.c index 6efd3f00d4..ce8f6de8c8 100644 --- a/libraries/liblutil/getpass.c +++ b/libraries/liblutil/getpass.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblutil/liblutil.dsp b/libraries/liblutil/liblutil.dsp index 539fc479c0..54800a3eca 100644 --- a/libraries/liblutil/liblutil.dsp +++ b/libraries/liblutil/liblutil.dsp @@ -255,6 +255,10 @@ InputPath=.\slapdmsg.mc # End Source File # Begin Source File +SOURCE=.\sockpair.c +# End Source File +# Begin Source File + SOURCE=.\utils.c # End Source File # End Target diff --git a/libraries/liblutil/lockf.c b/libraries/liblutil/lockf.c new file mode 100644 index 0000000000..a3424ba146 --- /dev/null +++ b/libraries/liblutil/lockf.c @@ -0,0 +1,114 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* + * File Locking Routines + * + * Implementations (in order of preference) + * - lockf + * - fcntl + * - flock + * + * Other implementations will be added as needed. + * + * NOTE: lutil_lockf() MUST block until an exclusive lock is acquired. + */ + +#include "portable.h" + +#include +#include + +#undef LOCK_API + +#if HAVE_LOCKF && defined(F_LOCK) +# define USE_LOCKF 1 +# define LOCK_API "lockf" +#endif + +#if !defined(LOCK_API) && HAVE_FCNTL +# ifdef HAVE_FCNTL_H +# include +# endif +# ifdef F_WRLCK +# define USE_FCNTL 1 +# define LOCK_API "fcntl" +# endif +#endif + +#if !defined(LOCK_API) && HAVE_FLOCK +# if HAVE_SYS_FILE_H +# include +# endif +# define USE_FLOCK 1 +# define LOCK_API "flock" +#endif + +#if !defined(USE_LOCKF) && !defined(USE_FCNTL) && !defined(USE_FLOCK) +int lutil_lockf ( int fd ) { + fd = fd; + return 0; +} + +int lutil_unlockf ( int fd ) { + fd = fd; + return 0; +} +#endif + +#ifdef USE_LOCKF +int lutil_lockf ( int fd ) { + /* use F_LOCK instead of F_TLOCK, ie: block */ + return lockf( fd, F_LOCK, 0 ); +} + +int lutil_unlockf ( int fd ) { + return lockf( fd, F_ULOCK, 0 ); +} +#endif + +#ifdef USE_FCNTL +int lutil_lockf ( int fd ) { + struct flock file_lock; + + memset( &file_lock, 0, sizeof( file_lock ) ); + file_lock.l_type = F_WRLCK; + file_lock.l_whence = SEEK_SET; + file_lock.l_start = 0; + file_lock.l_len = 0; + + /* use F_SETLKW instead of F_SETLK, ie: block */ + return( fcntl( fd, F_SETLKW, &file_lock ) ); +} + +int lutil_unlockf ( int fd ) { + struct flock file_lock; + + memset( &file_lock, 0, sizeof( file_lock ) ); + file_lock.l_type = F_UNLCK; + file_lock.l_whence = SEEK_SET; + file_lock.l_start = 0; + file_lock.l_len = 0; + + return( fcntl ( fd, F_SETLKW, &file_lock ) ); +} +#endif + +#ifdef USE_FLOCK +int lutil_lockf ( int fd ) { + /* use LOCK_EX instead of LOCK_EX|LOCK_NB, ie: block */ + return flock( fd, LOCK_EX ); +} + +int lutil_unlockf ( int fd ) { + return flock( fd, LOCK_UN ); +} +#endif diff --git a/libraries/liblutil/md5.c b/libraries/liblutil/md5.c index 0109b1c652..6758de0240 100644 --- a/libraries/liblutil/md5.c +++ b/libraries/liblutil/md5.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblutil/memcmp.c b/libraries/liblutil/memcmp.c new file mode 100644 index 0000000000..eed4b89dee --- /dev/null +++ b/libraries/liblutil/memcmp.c @@ -0,0 +1,20 @@ +/* $OpenLDAP$ */ +#include "portable.h" + +#include + +/* + * Memory Compare + */ +int +(memcmp)(const void *v1, const void *v2, int n) +{ + if (n != 0) { + const unsigned char *s1=v1, *s2=v2; + do { + if (*s1++ != *s2++) + return (*--s1 - *--s2); + } while (--n != 0); + } + return (0); +} diff --git a/libraries/liblutil/nt_err.c b/libraries/liblutil/nt_err.c new file mode 100644 index 0000000000..6d119d2b3d --- /dev/null +++ b/libraries/liblutil/nt_err.c @@ -0,0 +1,108 @@ +/* $OpenLDAP$ */ +#include "portable.h" + +#ifdef HAVE_WINSOCK2 +#include + +#define __RETSTR( x ) case x: return #x; + +char *WSAGetErrorString( int err ) +{ + switch( err ) + { + __RETSTR( WSAEINTR ) + __RETSTR( WSAEBADF ) + __RETSTR( WSAEACCES ) + __RETSTR( WSAEFAULT ) + __RETSTR( WSAEINVAL ) + __RETSTR( WSAEMFILE ) + __RETSTR( WSAEWOULDBLOCK ) + __RETSTR( WSAEINPROGRESS ) + __RETSTR( WSAEALREADY ) + __RETSTR( WSAENOTSOCK ) + __RETSTR( WSAEDESTADDRREQ ) + __RETSTR( WSAEMSGSIZE ) + __RETSTR( WSAEPROTOTYPE ) + __RETSTR( WSAENOPROTOOPT ) + __RETSTR( WSAEPROTONOSUPPORT ) + __RETSTR( WSAESOCKTNOSUPPORT ) + __RETSTR( WSAEOPNOTSUPP ) + __RETSTR( WSAEPFNOSUPPORT ) + __RETSTR( WSAEAFNOSUPPORT ) + __RETSTR( WSAEADDRINUSE ) + __RETSTR( WSAEADDRNOTAVAIL ) + __RETSTR( WSAENETDOWN ) + __RETSTR( WSAENETUNREACH ) + __RETSTR( WSAENETRESET ) + __RETSTR( WSAECONNABORTED ) + __RETSTR( WSAECONNRESET ) + __RETSTR( WSAENOBUFS ) + __RETSTR( WSAEISCONN ) + __RETSTR( WSAENOTCONN ) + __RETSTR( WSAESHUTDOWN ) + __RETSTR( WSAETOOMANYREFS ) + __RETSTR( WSAETIMEDOUT ) + __RETSTR( WSAECONNREFUSED ) + __RETSTR( WSAELOOP ) + __RETSTR( WSAENAMETOOLONG ) + __RETSTR( WSAEHOSTDOWN ) + __RETSTR( WSAEHOSTUNREACH ) + __RETSTR( WSAENOTEMPTY ) + __RETSTR( WSAEPROCLIM ) + __RETSTR( WSAEUSERS ) + __RETSTR( WSAEDQUOT ) + __RETSTR( WSAESTALE ) + __RETSTR( WSAEREMOTE ) + __RETSTR( WSASYSNOTREADY ) + __RETSTR( WSAVERNOTSUPPORTED ) + __RETSTR( WSANOTINITIALISED ) + __RETSTR( WSAEDISCON ) + __RETSTR( WSAENOMORE ) + __RETSTR( WSAECANCELLED ) + __RETSTR( WSAEINVALIDPROCTABLE ) + __RETSTR( WSAEINVALIDPROVIDER ) + __RETSTR( WSASYSCALLFAILURE ) + __RETSTR( WSASERVICE_NOT_FOUND ) + __RETSTR( WSATYPE_NOT_FOUND ) + __RETSTR( WSA_E_NO_MORE ) + __RETSTR( WSA_E_CANCELLED ) + __RETSTR( WSAEREFUSED ) + + __RETSTR( WSAHOST_NOT_FOUND ) + __RETSTR( WSATRY_AGAIN ) + __RETSTR( WSANO_RECOVERY ) + __RETSTR( WSANO_DATA ) + } + return "unknown"; +} + +char *WSAGetLastErrorString( void ) +{ + return WSAGetErrorString( WSAGetLastError() ); +} + +#undef __RETSTR + +#endif /* HAVE_WINSOCK2 */ + + +char *GetErrorString( int err ) +{ + static char msgBuf[1024]; + + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + msgBuf, 1024, NULL ); + + return msgBuf; +} + +char *GetLastErrorString( void ) +{ + return GetErrorString( GetLastError() ); +} + + + diff --git a/libraries/liblutil/ntservice.c b/libraries/liblutil/ntservice.c index 57ab8c89f9..e1554a5cb4 100644 --- a/libraries/liblutil/ntservice.c +++ b/libraries/liblutil/ntservice.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index 8fc16c2a01..d350770ef9 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblutil/setproctitle.c b/libraries/liblutil/setproctitle.c new file mode 100644 index 0000000000..6d1ab6a032 --- /dev/null +++ b/libraries/liblutil/setproctitle.c @@ -0,0 +1,73 @@ +/* $OpenLDAP$ */ +#include "portable.h" + +#ifndef HAVE_SETPROCTITLE + +#include + +#include + +#include +#include +#include + +/* + * Copyright (c) 1990,1991 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +char **Argv; /* pointer to original (main's) argv */ +int Argc; /* original argc */ + +/* + * takes a printf-style format string (fmt) and up to three parameters (a,b,c) + * this clobbers the original argv... + */ + +/* VARARGS */ +void setproctitle( const char *fmt, ... ) +{ + static char *endargv = (char *)0; + char *s; + int i; + char buf[ 1024 ]; + va_list ap; + + va_start(ap, fmt); + +#ifdef HAVE_VSNPRINTF + buf[sizeof(buf) - 1] = '\0'; + vsnprintf( buf, sizeof(buf)-1, fmt, ap ); +#elif HAVE_VPRINTF + vsprintf( buf, fmt, ap ); /* hope it's not too long */ +#else + /* use doprnt() */ + chokeme = "choke me! I don't have a doprnt() manual handy"; +#endif + + va_end(ap); + + if ( endargv == (char *)0 ) { + /* set pointer to end of original argv */ + endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] ); + } + /* make ps print "([prog name])" */ + s = Argv[0]; + *s++ = '-'; + i = strlen( buf ); + if ( i > endargv - s - 2 ) { + i = endargv - s - 2; + buf[ i ] = '\0'; + } + strcpy( s, buf ); + s += i; + while ( s < endargv ) *s++ = ' '; +} +#endif /* NOSETPROCTITLE */ diff --git a/libraries/liblutil/sha1.c b/libraries/liblutil/sha1.c index bdaafda162..f8c38a1a66 100644 --- a/libraries/liblutil/sha1.c +++ b/libraries/liblutil/sha1.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/libraries/liblutil/sockpair.c b/libraries/liblutil/sockpair.c new file mode 100644 index 0000000000..39bcde0fb0 --- /dev/null +++ b/libraries/liblutil/sockpair.c @@ -0,0 +1,62 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" +#include +#include + +#include + +/* Return a pair of socket descriptors that are connected to each other. + * The returned descriptors are suitable for use with select(). The two + * descriptors may or may not be identical; the function may return + * the same descriptor number in both slots. It is guaranteed that + * data written on sds[1] will be readable on sds[0]. The returned + * descriptors may be datagram oriented, so data should be written + * in reasonably small pieces and read all at once. On Unix systems + * this function is best implemented using a single pipe() call. + */ + +int lutil_pair( LBER_SOCKET_T sds[2] ) +{ +#ifdef USE_PIPE + return pipe( sds ); +#else + struct sockaddr_in si; + int rc, len = sizeof(si); + LBER_SOCKET_T sd; + + sd = socket( AF_INET, SOCK_DGRAM, 0 ); + if ( sd == AC_SOCKET_INVALID ) + return sd; + + (void) memset( (void*) &si, 0, len ); + si.sin_family = AF_INET; + si.sin_port = 0; + si.sin_addr.s_addr = htonl( INADDR_LOOPBACK ); + + rc = bind( sd, (struct sockaddr *)&si, len ); + if ( rc == AC_SOCKET_ERROR ) { + tcp_close(sd); + return rc; + } + + rc = getsockname( sd, (struct sockaddr *)&si, &len ); + if ( rc == AC_SOCKET_ERROR ) { + tcp_close(sd); + return rc; + } + + rc = connect( sd, (struct sockaddr *)&si, len ); + if ( rc == AC_SOCKET_ERROR ) { + tcp_close(sd); + return rc; + } + + sds[0] = sds[1] = sd; + return 0; +#endif +} diff --git a/libraries/liblutil/tempnam.c b/libraries/liblutil/tempnam.c new file mode 100644 index 0000000000..024f1fd725 --- /dev/null +++ b/libraries/liblutil/tempnam.c @@ -0,0 +1,46 @@ +/* $OpenLDAP$ */ +#include "portable.h" + +#ifndef HAVE_TEMPNAM + +#include + +#include +#include +#include + +#include "lutil.h" + +char * +(tempnam)( const char *dir, const char *pfx ) +{ + char *s; + + if ( dir == NULL ) { + dir = "/tmp"; + } + +/* + * allocate space for dir + '/' + pfx (up to 5 chars) + 6 trailing 'X's + 0 byte + */ + if (( s = (char *)malloc( strlen( dir ) + 14 )) == NULL ) { + return( NULL ); + } + + strcpy( s, dir ); + strcat( s, "/" ); + if ( pfx != NULL ) { + strcat( s, pfx ); + } + strcat( s, "XXXXXX" ); + mktemp( s ); + + if ( *s == '\0' ) { + free( s ); + s = NULL; + } + + return( s ); +} + +#endif /* TEMPNAM */ diff --git a/libraries/liblutil/utils.c b/libraries/liblutil/utils.c index 8bd298facf..0f0f3704a2 100644 --- a/libraries/liblutil/utils.c +++ b/libraries/liblutil/utils.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/Makefile.in b/servers/Makefile.in index 3fa1332f8b..9cf821cda5 100644 --- a/servers/Makefile.in +++ b/servers/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved. ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file ## diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in index 05744d04ca..8752f3f40c 100644 --- a/servers/slapd/Makefile.in +++ b/servers/slapd/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ## ## Makefile.in for slapd ## diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index 0d31209148..3340bc70f7 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -1,4 +1,5 @@ /* abandon.c - decode and handle an ldap abandon operation */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -99,7 +100,7 @@ done: ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); Debug( LDAP_DEBUG_TRACE, "do_abandon: op=%ld %sfound\n", - id, notfound ? "not " : "", 0 ); + (long) id, notfound ? "not " : "", 0 ); return LDAP_SUCCESS; } diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 76e54530c6..99b4283266 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -1,4 +1,5 @@ /* acl.c - routines to parse and check acl's */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -14,6 +15,11 @@ #include "slap.h" +#ifdef SLAPD_ACI_ENABLED +int aci_access_allowed (struct berval *aci, char *attr, Backend *be, Entry *e, + Operation *op, int access, char *edn, regmatch_t *matches); +#endif + static int regex_matches(char *pat, char *str, char *buf, regmatch_t *matches); static void string_expand(char *newbuf, int bufsiz, char *pattern, char *match, regmatch_t *matches); @@ -83,7 +89,7 @@ access_allowed( } } - rc = acl_access_allowed( a, be, conn, e, val, op, access, edn, matches ); + rc = acl_access_allowed( a, attr, be, conn, e, val, op, access, edn, matches ); Debug( LDAP_DEBUG_ACL, "\n=> access_allowed: exit (%s) attr (%s)\n", e->e_dn, attr, 0); @@ -208,6 +214,7 @@ acl_get_applicable( int acl_access_allowed( AccessControl *a, + char *attr, Backend *be, Connection *conn, Entry *e, @@ -376,6 +383,52 @@ acl_access_allowed( } } +#ifdef SLAPD_ACI_ENABLED + if ( b->a_aci_at != NULL ) { + Attribute *at; + + /* this case works different from the others above. + * since aci's themselves give permissions, we need + * to first check b->a_access, the ACL's access level. + */ + + if( op->o_ndn == NULL || op->o_ndn[0] == '\0' ) { + continue; + } + + if ( e->e_dn == NULL ) { + continue; + } + + /* first check if the right being requested is + * higher than allowed by the ACL clause. + */ + if ( ! ACL_GRANT( b->a_access, access ) ) { + continue; + } + + /* get the aci attribute */ + at = attr_find( e->e_attrs, b->a_aci_at ); + if ( at == NULL ) { + continue; + } + + /* the aci is an multi-valued attribute. The + * rights are determined by OR'ing the individual + * rights given by the acis. + */ + for ( i = 0; at->a_vals[i] != NULL; i++ ) { + if ( aci_access_allowed( at->a_vals[i], attr, be, e, op, access, edn, matches ) ) { + Debug( LDAP_DEBUG_ACL, + "<= acl_access_allowed: matched by clause #%d access granted\n", + i, 0, 0 ); + return(1); + } + } + continue; + } +#endif + Debug( LDAP_DEBUG_ACL, "<= acl_access_allowed: matched by clause #%d access %s\n", i, @@ -433,7 +486,7 @@ acl_check_modlist( break; } for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) { - if ( ! acl_access_allowed( a, be, conn, e, mlist->ml_bvalues[i], + if ( ! acl_access_allowed( a, mlist->ml_type, be, conn, e, mlist->ml_bvalues[i], op, ACL_WRITE, edn, matches) ) { return( LDAP_INSUFFICIENT_ACCESS ); @@ -443,7 +496,7 @@ acl_check_modlist( case LDAP_MOD_DELETE: if ( mlist->ml_bvalues == NULL ) { - if ( ! acl_access_allowed( a, be, conn, e, + if ( ! acl_access_allowed( a, mlist->ml_type, be, conn, e, NULL, op, ACL_WRITE, edn, matches) ) { return( LDAP_INSUFFICIENT_ACCESS ); @@ -451,7 +504,7 @@ acl_check_modlist( break; } for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) { - if ( ! acl_access_allowed( a, be, conn, e, mlist->ml_bvalues[i], + if ( ! acl_access_allowed( a, mlist->ml_type, be, conn, e, mlist->ml_bvalues[i], op, ACL_WRITE, edn, matches) ) { return( LDAP_INSUFFICIENT_ACCESS ); @@ -464,6 +517,333 @@ acl_check_modlist( return( LDAP_SUCCESS ); } +#ifdef SLAPD_ACI_ENABLED +static char * +aci_bvstrdup (struct berval *bv) +{ + char *s; + + s = (char *)ch_malloc(bv->bv_len + 1); + if (s != NULL) { + memcpy(s, bv->bv_val, bv->bv_len); + s[bv->bv_len] = 0; + } + return(s); +} + +static int +aci_strbvcmp (char *s, struct berval *bv) +{ + int res, len; + + res = strncasecmp( s, bv->bv_val, bv->bv_len ); + if (res) + return(res); + len = strlen(s); + if (len > bv->bv_len) + return(1); + if (len < bv->bv_len) + return(-1); + return(0); +} + +static int +aci_get_part (struct berval *list, int ix, char sep, struct berval *bv) +{ + int len; + char *p; + + if (bv) { + bv->bv_len = 0; + bv->bv_val = NULL; + } + len = list->bv_len; + p = list->bv_val; + while (len >= 0 && --ix >= 0) { + while (--len >= 0 && *p++ != sep) ; + } + while (len >= 0 && *p == ' ') { + len--; + p++; + } + if (len < 0) + return(-1); + + if (!bv) + return(0); + + bv->bv_val = p; + while (--len >= 0 && *p != sep) { + bv->bv_len++; + p++; + } + while (bv->bv_len > 0 && *--p == ' ') + bv->bv_len--; + return(bv->bv_len); +} + +static int +aci_list_has_right (struct berval *list, int access, int action) +{ + struct berval bv; + int i, right; + + for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) { + if (bv.bv_len <= 0) + continue; + switch (*bv.bv_val) { + case 'c': + right = ACL_COMPARE; + break; + case 's': + /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt defines + * the right 's' to mean "set", but in the examples states + * that the right 's' means "search". The latter definition + * is used here. + */ + right = ACL_SEARCH; + break; + case 'r': + right = ACL_READ; + break; + case 'w': + right = ACL_WRITE; + break; + case 'x': + /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt does not + * define any equivalent to the AUTH right, so I've just used + * 'x' for now. + */ + right = ACL_AUTH; + break; + default: + right = 0; + break; + } +#ifdef SLAPD_ACI_DISCRETE_RIGHTS + if (right & access) { + return(action); + } + } + return(!action); +#else + if (action != 0) { + /* check granted */ + if (ACL_GRANT(right, access)) + return(1); + } else { + /* check denied */ + if (right <= access) + return(1); + } + } + return(0); +#endif +} + +static int +aci_list_has_attr (struct berval *list, char *attr) +{ + struct berval bv; + int i; + + for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) { + if (aci_strbvcmp(attr, &bv) == 0) { + return(1); + } + } + return(0); +} + +static int +aci_list_has_attr_right (struct berval *list, char *attr, int access, int action) +{ + struct berval bv; + int i, found; + + /* loop through each rights/attr pair, skip first part (action) */ + found = -1; + for (i = 1; aci_get_part(list, i + 1, ';', &bv) >= 0; i += 2) { + if (aci_list_has_attr(&bv, attr) == 0) + continue; + found = 0; + if (aci_get_part(list, i, ';', &bv) < 0) + continue; + if (aci_list_has_right(&bv, access, action) != 0) + return(1); + } + return(found); +} + +static int +aci_list_has_permission (struct berval *list, char *attr, int access) +{ + struct berval perm, actn; + int i, action, specific, general; + + if (attr == NULL || *attr == 0 || strcasecmp(attr, "entry") == 0) { + attr = "[entry]"; + } + + /* loop through each permissions clause */ + for (i = 0; aci_get_part(list, i, '$', &perm) >= 0; i++) { + if (aci_get_part(&perm, 0, ';', &actn) < 0) + continue; + if (aci_strbvcmp( "grant", &actn ) == 0) { + action = 1; + } else if (aci_strbvcmp( "deny", &actn ) == 0) { + action = 0; + } else { + continue; + } + + specific = aci_list_has_attr_right(&perm, attr, access, action); + if (specific >= 0) + return(specific); + + general = aci_list_has_attr_right(&perm, "[all]", access, action); + if (general >= 0) + return(general); + } + return(0); +} + +static int +aci_group_member ( + struct berval *subj, + char *grpoc, + char *grpat, + Backend *be, + Entry *e, + Operation *op, + char *edn, + regmatch_t *matches +) +{ + struct berval bv; + char *subjdn, *grpdn; + int rc = 0; + + /* format of string is "group/objectClassValue/groupAttrName" */ + if (aci_get_part(subj, 0, '/', &bv) < 0) + return(0); + subjdn = aci_bvstrdup(&bv); + if (subjdn == NULL) + return(0); + + if (aci_get_part(subj, 1, '/', &bv) < 0) + grpoc = ch_strdup(grpoc); + else + grpoc = aci_bvstrdup(&bv); + + if (aci_get_part(subj, 2, '/', &bv) < 0) + grpat = ch_strdup(grpat); + else + grpat = aci_bvstrdup(&bv); + + grpdn = (char *)ch_malloc(1024); + if (grpoc != NULL && grpat != NULL && grpdn != NULL) { + string_expand(grpdn, 1024, subjdn, edn, matches); + if ( dn_normalize_case(grpdn) != NULL ) { + rc = (backend_group(be, e, grpdn, op->o_ndn, grpoc, grpat) == 0); + } + ch_free(grpdn); + } + if (grpat != NULL) + ch_free(grpat); + if (grpoc != NULL) + ch_free(grpoc); + ch_free(subjdn); + return(rc); +} + +int +aci_access_allowed ( + struct berval *aci, + char *attr, + Backend *be, + Entry *e, + Operation *op, + int access, + char *edn, + regmatch_t *matches +) +{ + struct berval bv, perms, sdn; + char *subjdn; + int rc; + + Debug( LDAP_DEBUG_ACL, + "\n=> aci_access_allowed: %s access to entry \"%s\"\n", + access2str( access ), e->e_dn, 0 ); + + Debug( LDAP_DEBUG_ACL, + "\n=> aci_access_allowed: %s access to attribute \"%s\" by \"%s\"\n", + access2str( access ), + attr, + op->o_ndn ? op->o_ndn : "" ); + + /* parse an aci of the form: + oid#scope#action;rights;attr;rights;attr$action;rights;attr;rights;attr#dnType#subjectDN + + See draft-ietf-ldapext-aci-model-0.3.txt section 9.1 for + a full description of the format for this attribute. + + For now, this routine only supports scope=entry. + */ + + /* check that the aci has all 5 components */ + if (aci_get_part(aci, 4, '#', NULL) < 0) + return(0); + + /* check that the scope is "entry" */ + if (aci_get_part(aci, 1, '#', &bv) < 0 + || aci_strbvcmp( "entry", &bv ) != 0) + { + return(0); + } + + /* get the list of permissions clauses, bail if empty */ + if (aci_get_part(aci, 2, '#', &perms) <= 0) + return(0); + + /* check if any permissions allow desired access */ + if (aci_list_has_permission(&perms, attr, access) == 0) + return(0); + + /* see if we have a DN match */ + if (aci_get_part(aci, 3, '#', &bv) < 0) + return(0); + + if (aci_get_part(aci, 4, '#', &sdn) < 0) + return(0); + if (aci_strbvcmp( "access-id", &bv ) == 0) { + subjdn = aci_bvstrdup(&sdn); + if (subjdn == NULL) + return(0); + rc = 0; + if (dn_normalize_case(subjdn) != NULL) + rc = (strcasecmp(op->o_ndn, subjdn) == 0); + ch_free(subjdn); + return(rc); + } + + if (aci_strbvcmp( "self", &bv ) == 0) { + return(strcasecmp(op->o_ndn, edn) == 0); + } + + if (aci_strbvcmp( "group", &bv ) == 0) { + return(aci_group_member(&sdn, "groupOfNames", "member", be, e, op, edn, matches)); + } + + if (aci_strbvcmp( "role", &bv ) == 0) { + return(aci_group_member(&sdn, "organizationalRole", "roleOccupant", be, e, op, edn, matches)); + } + + return(0); +} +#endif /* SLAPD_ACI_ENABLED */ + static void string_expand( char *newbuf, diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index f31993f2d2..a134506908 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -1,4 +1,5 @@ /* acl.c - routines to parse and check acl's */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -19,14 +20,14 @@ static void split(char *line, int splitchar, char **left, char **right); static void acl_append(AccessControl **l, AccessControl *a); static void access_append(Access **l, Access *a); -static void acl_usage(void); +static void acl_usage(void) LDAP_GCCATTR((noreturn)); #ifdef LDAP_DEBUG static void print_acl(AccessControl *a); static void print_access(Access *b); #endif static int -regtest(char *fname, int lineno, char *pat) { +regtest(const char *fname, int lineno, char *pat) { int e; regex_t re; @@ -64,7 +65,7 @@ regtest(char *fname, int lineno, char *pat) { if ( size >= (sizeof(buf)-1) ) { fprintf( stderr, "%s: line %d: regular expression \"%s\" too large\n", - fname, lineno, pat, 0 ); + fname, lineno, pat ); acl_usage(); } @@ -84,7 +85,7 @@ regtest(char *fname, int lineno, char *pat) { void parse_acl( Backend *be, - char *fname, + const char *fname, int lineno, int argc, char **argv @@ -106,6 +107,11 @@ parse_acl( acl_usage(); } a = (AccessControl *) ch_calloc( 1, sizeof(AccessControl) ); + a->acl_filter = NULL; + a->acl_dn_pat = NULL; + a->acl_attrs = NULL; + a->acl_access = NULL; + a->acl_next = NULL; for ( ++i; i < argc; i++ ) { if ( strcasecmp( argv[i], "by" ) == 0 ) { i--; @@ -135,20 +141,7 @@ parse_acl( } } else if ( strcasecmp( left, "dn" ) == 0 ) { - int e; - - if ((e = regcomp(&a->acl_dn_re, right, - REG_EXTENDED|REG_ICASE))) { - char buf[512]; - regerror(e, &a->acl_dn_re, buf, sizeof(buf)); - fprintf( stderr, - "%s: line %d: regular expression \"%s\" bad because of %s\n", - fname, lineno, right, buf ); - acl_usage(); - - } else { a->acl_dn_pat = ch_strdup( right ); - } } else if ( strncasecmp( left, "attr", 4 ) == 0 ) { char **alist; @@ -165,6 +158,19 @@ parse_acl( } } + if ( a->acl_dn_pat != NULL ) { + int e = regcomp( &a->acl_dn_re, a->acl_dn_pat, + REG_EXTENDED | REG_ICASE ); + if ( e ) { + char buf[512]; + regerror( e, &a->acl_dn_re, buf, sizeof(buf) ); + fprintf( stderr, + "%s: line %d: regular expression \"%s\" bad because of %s\n", + fname, lineno, right, buf ); + acl_usage(); + } + } + /* by clause - select who has what access to entries */ } else if ( strcasecmp( argv[i], "by" ) == 0 ) { if ( a == NULL ) { @@ -321,6 +327,23 @@ parse_acl( continue; } +#ifdef SLAPD_ACI_ENABLED + if ( strcasecmp( left, "aci" ) == 0 ) { + if( b->a_aci_at != NULL ) { + fprintf( stderr, + "%s: line %d: aci attribute already specified.\n", + fname, lineno ); + acl_usage(); + } + + if ( right != NULL && *right != '\0' ) + b->a_aci_at = ch_strdup( right ); + else + b->a_aci_at = ch_strdup( SLAPD_ACI_DEFAULT_ATTR ); + continue; + } +#endif + /* get */ if ( ACL_IS_INVALID(ACL_SET(b->a_access, str2access( left ))) ) { fprintf( stderr, @@ -441,6 +464,9 @@ acl_usage( void ) "\t[group[/[/]]=]\n" "\t[peername=] [sockname=]\n" "\t[domain=] [sockurl=]\n" +#ifdef SLAPD_ACI_ENABLED + "\t[aci=]\n" +#endif " ::= [self]{none|auth|compare|search|read|write}\n" ); exit( EXIT_FAILURE ); @@ -528,6 +554,12 @@ print_access( Access *b ) fprintf( stderr, " sockurl=%s", b->a_sockurl_pat ); } +#ifdef SLAPD_ACI_ENABLED + if ( b->a_aci_at != NULL ) { + fprintf( stderr, " aci=%s", b->a_aci_at ); + } +#endif + fprintf( stderr, "\n" ); } diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 1d37dad4e3..388ad9d629 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -145,6 +146,15 @@ do_add( Connection *conn, Operation *op ) return rc; } + if ( global_readonly || be->be_readonly ) { + Debug( LDAP_DEBUG_ANY, "do_add: database is read-only\n", + 0, 0, 0 ); + entry_free( e ); + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, "database is read-only", NULL, NULL ); + return LDAP_UNWILLING_TO_PERFORM; + } + /* * do the add if 1 && (2 || 3) * 1) there is an add function implemented in this backend; diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 74e5c241c5..8a5f5358cb 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -22,7 +23,7 @@ #include #endif -#include "ldap_defaults.h" +#include "ldap_pvt.h" #include "slap.h" #ifdef LDAP_DEBUG @@ -67,6 +68,8 @@ Attribute *attr_dup( Attribute *a ) for( i=0; a->a_vals[i] != NULL; i++ ) { tmp->a_vals[i] = ber_bvdup( a->a_vals[i] ); + + if( tmp->a_vals[i] == NULL ) break; } tmp->a_vals[i] = NULL; @@ -109,7 +112,7 @@ attr_normalize( char *s ) { assert( s != NULL ); - return( str2lower( s ) ); + return( ldap_pvt_str2lower( s ) ); } /* @@ -191,7 +194,7 @@ attr_merge( Attribute * attr_find( Attribute *a, - char *type + const char *type ) { for ( ; a != NULL; a = a->a_next ) { @@ -213,7 +216,7 @@ attr_find( int attr_delete( Attribute **attrs, - char *type + const char *type ) { Attribute **a; @@ -261,7 +264,7 @@ attr_syntax( char *type ) void attr_syntax_config( - char *fname, + const char *fname, int lineno, int argc, char **argv @@ -693,8 +696,8 @@ at_schema_info( Entry *e ) val.bv_val = ldap_attributetype2str( &at->sat_atype ); if ( val.bv_val ) { val.bv_len = strlen( val.bv_val ); - Debug( LDAP_DEBUG_TRACE, "Merging at [%d] %s\n", - val.bv_len, val.bv_val, 0 ); + Debug( LDAP_DEBUG_TRACE, "Merging at [%ld] %s\n", + (long) val.bv_len, val.bv_val, 0 ); attr_merge( e, "attributeTypes", vals ); ldap_memfree( val.bv_val ); } else { diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index dcb4ba8d7b..b3f314050a 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-bdb2/Makefile.in b/servers/slapd/back-bdb2/Makefile.in index 08e30bea34..fd25b63bcb 100644 --- a/servers/slapd/back-bdb2/Makefile.in +++ b/servers/slapd/back-bdb2/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \ index.c id2children.c nextid.c abandon.c compare.c group.c \ modify.c modrdn.c delete.c init.c config.c bind.c attr.c \ diff --git a/servers/slapd/back-bdb2/abandon.c b/servers/slapd/back-bdb2/abandon.c new file mode 100644 index 0000000000..a062487393 --- /dev/null +++ b/servers/slapd/back-bdb2/abandon.c @@ -0,0 +1,47 @@ +/* abandon.c - ldbm backend abandon routine */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include +#include + +#include "slap.h" +#include "back-bdb2.h" + + +/*ARGSUSED*/ +static int +bdb2i_back_abandon_internal( + BackendDB *be, + Connection *c, + Operation *o, + int msgid ) +{ + return 0; +} + + +int +bdb2_back_abandon( + BackendDB *be, + Connection *conn, + Operation *op, + int msgid ) +{ + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + ret = bdb2i_back_abandon_internal( be, conn, op, msgid ); + + bdb2i_stop_timing( be->bd_info, time1, "ABND", conn, op ); + + return( ret ); +} + + diff --git a/servers/slapd/back-bdb2/add.c b/servers/slapd/back-bdb2/add.c index 7324cc2e13..b72dc51512 100644 --- a/servers/slapd/back-bdb2/add.c +++ b/servers/slapd/back-bdb2/add.c @@ -1,4 +1,5 @@ /* add.c - ldap bdb2 back-end add routine */ +/* $OpenLDAP$ */ #include "portable.h" @@ -243,7 +244,7 @@ bdb2i_back_add_internal( if ( bdb2i_id2entry_add( be, e ) != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb2i_id2entry_add failed\n", 0, 0, 0 ); - (void) bdb2i_dn2id_delete( be, e->e_ndn ); + (void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL, NULL, NULL ); diff --git a/servers/slapd/back-bdb2/alias.c b/servers/slapd/back-bdb2/alias.c new file mode 100644 index 0000000000..3de54b9bf0 --- /dev/null +++ b/servers/slapd/back-bdb2/alias.c @@ -0,0 +1,285 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include +#include +#include +#include "slap.h" +#include "back-bdb2.h" +#include "proto-back-bdb2.h" + +static char* get_alias_dn( + Entry *e, + int *err, + char **errmsg ); + +static char* new_superior( + char *dn, + char *oldSup, + char *newSup ); + +static int dnlist_subordinate( + char** dnlist, + char *dn ); + +Entry *bdb2i_deref_r( + Backend* be, + Entry* alias, + char* dn, + int* err, + Entry** matched, + char** text ) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + Entry *entry; + Entry *sup; + unsigned depth; + char **dnlist; + + assert( ( alias != NULL && dn == NULL ) || ( alias == NULL && dn != NULL ) ); + + *matched = NULL; + *err = LDAP_SUCCESS; + *text = NULL; + + if( alias == NULL ) { + dn = ch_strdup( dn ); + entry = bdb2i_dn2entry_r( be, dn, &sup ); + + } else { + dn = ch_strdup( alias->e_ndn ); + entry = alias; + sup = NULL; + } + + dnlist = NULL; + charray_add( &dnlist, dn ); + + for( depth=0 ; ; depth++ ) { + if( entry != NULL ) { + Entry *newe; + char *aliasDN; + + /* have entry, may be an alias */ + + if( !is_entry_alias( entry ) ) { + /* entry is not an alias */ + break; + } + + /* entry is alias */ + if( depth > be->be_max_deref_depth ) { + *matched = entry; + entry = NULL; + *err = LDAP_ALIAS_DEREF_PROBLEM; + *text = "maximum deref depth exceeded"; + break; + } + + /* deref entry */ + aliasDN = get_alias_dn( entry, err, text ); + + if( aliasDN == NULL ) { + *matched = entry; + entry = NULL; + break; + } + + /* check if aliasDN is a subordinate of any DN in our list */ + if( dnlist_subordinate( dnlist, aliasDN ) ) { + *matched = entry; + entry = NULL; + *err = LDAP_ALIAS_PROBLEM; + *text = "circular alias"; + break; + } + + /* attempt to dereference alias */ + + newe = bdb2i_dn2entry_r( be, aliasDN, &sup ); + + if( newe != NULL ) { + free( dn ); + bdb2i_cache_return_entry_r(&li->li_cache, entry ); + entry = newe; + dn = ch_strdup( entry->e_ndn ); + charray_add( &dnlist, dn ); + continue; + + } + + if ( sup != NULL ) { + bdb2i_cache_return_entry_r(&li->li_cache, entry ); + entry = NULL; + continue; + } + + /* no newe and no superior, we're done */ + break; + + } else if( sup != NULL ) { + /* have superior, may be an alias */ + Entry *newe; + Entry *newSup; + char *supDN; + char *aliasDN; + + if( !is_entry_alias( sup ) ) { + /* entry is not an alias */ + *matched = sup; + sup = NULL; + break; + } + + /* entry is alias */ + if( depth > be->be_max_deref_depth ) { + *matched = sup; + entry = NULL; + *err = LDAP_ALIAS_DEREF_PROBLEM; + *text = "maximum deref depth exceeded"; + break; + } + + /* deref entry */ + supDN = get_alias_dn( sup, err, text ); + + if( supDN == NULL ) { + *matched = sup; + break; + } + + aliasDN = new_superior( dn, sup->e_ndn, supDN ); + + if( aliasDN == NULL ) { + free(aliasDN); + *matched = sup; + *err = LDAP_ALIAS_PROBLEM; + *text = "superior alias problem"; + break; + } + + /* check if aliasDN is a subordinate of any DN in our list */ + if( dnlist_subordinate( dnlist, aliasDN ) ) { + free(aliasDN); + *matched = entry; + entry = NULL; + *err = LDAP_ALIAS_PROBLEM; + *text = "subordinate circular alias"; + break; + } + + /* attempt to dereference alias */ + newe = bdb2i_dn2entry_r( be, aliasDN, &newSup ); + + if( newe != NULL ) { + free(aliasDN); + free( dn ); + bdb2i_cache_return_entry_r(&li->li_cache, sup ); + entry = newe; + dn = ch_strdup( entry->e_ndn ); + charray_add( &dnlist, dn ); + continue; + + } + + if ( newSup != NULL ) { + free( dn ); + bdb2i_cache_return_entry_r(&li->li_cache, sup ); + sup = newSup; + dn = aliasDN; + continue; + } + + break; + + } else { + /* no newe and no superior, we're done */ + break; + } + } + + free( dn ); + return entry; +} + + +static char* get_alias_dn( + Entry *e, + int *err, + char **errmsg ) +{ + Attribute *a = attr_find( e->e_attrs, "aliasedobjectname" ); + + if( a == NULL ) { + /* + * there was an aliasedobjectname defined but no data. + */ + *err = LDAP_ALIAS_PROBLEM; + *errmsg = "alias missing aliasedObjectName attribute"; + return NULL; + } + + /* + * aliasedObjectName should be SINGLE-VALUED with a single value. + */ + if ( a->a_vals[0] == NULL || a->a_vals[0]->bv_val == NULL ) { + /* + * there was an aliasedobjectname defined but no data. + */ + *err = LDAP_ALIAS_PROBLEM; + *errmsg = "alias missing aliasedObjectName value"; + return NULL; + } + + if( a->a_vals[1] != NULL ) { + *err = LDAP_ALIAS_PROBLEM; + *errmsg = "alias has multivalued aliasedObjectName"; + return NULL; + } + + return a->a_vals[0]->bv_val; +} + +static char* new_superior( + char *dn, + char *oldSup, + char *newSup ) +{ + char *newDN; + size_t dnlen, olen, nlen; + assert( dn && oldSup && newSup ); + + dnlen = strlen( dn ); + olen = strlen( oldSup ); + nlen = strlen( newSup ); + + newDN = ch_malloc( dnlen - olen + nlen + 1 ); + + memcpy( newDN, dn, dnlen - olen ); + memcpy( &newDN[dnlen - olen], newSup, nlen ); + newDN[dnlen - olen + nlen] = '\0'; + + return newDN; +} + +static int dnlist_subordinate( + char** dnlist, + char *dn ) +{ + int i; + assert( dnlist ); + + for( i = 0; dnlist[i] != NULL; i++ ) { + if( dn_issuffix( dnlist[i], dn ) ) { + return 1; + } + } + + return 0; +} + diff --git a/servers/slapd/back-bdb2/attr.c b/servers/slapd/back-bdb2/attr.c new file mode 100644 index 0000000000..7fa5988865 --- /dev/null +++ b/servers/slapd/back-bdb2/attr.c @@ -0,0 +1,174 @@ +/* attr.c - backend routines for dealing with attributes */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-bdb2.h" + +static int +ainfo_type_cmp( + char *type, + struct attrinfo *a +) +{ + return( strcasecmp( type, a->ai_type ) ); +} + +static int +ainfo_cmp( + struct attrinfo *a, + struct attrinfo *b +) +{ + return( strcasecmp( a->ai_type, b->ai_type ) ); +} + +/* + * Called when a duplicate "index" line is encountered. + * + * returns 1 => original from init code, indexmask updated + * 2 => original not from init code, warn the user + */ + +static int +ainfo_dup( + struct attrinfo *a, + struct attrinfo *b +) +{ + /* + * if the duplicate definition is because we initialized the attr, + * just add what came from the config file. otherwise, complain. + */ + if ( a->ai_indexmask & INDEX_FROMINIT ) { + a->ai_indexmask |= b->ai_indexmask; + + return( 1 ); + } + + return( 2 ); +} + +void +bdb2i_attr_masks( + struct ldbminfo *li, + char *type, + int *indexmask, + int *syntaxmask +) +{ + struct attrinfo *a; + + *indexmask = 0; + *syntaxmask = 0; + if ( (a = (struct attrinfo *) avl_find( li->li_attrs, type, + (AVL_CMP) ainfo_type_cmp )) == NULL ) { + if ( (a = (struct attrinfo *) avl_find( li->li_attrs, "default", + (AVL_CMP) ainfo_type_cmp )) == NULL ) { + return; + } + } + *indexmask = a->ai_indexmask; + if ( strcasecmp( a->ai_type, "default" ) == 0 ) { + *syntaxmask = attr_syntax( type ); + } else { + *syntaxmask = a->ai_syntaxmask; + } +} + + +/* BDB2 changed */ +void +bdb2i_attr_index_config( + struct ldbminfo *li, + const char *fname, + int lineno, + int argc, + char **argv, + int init +) +{ + int i, j; + char **attrs, **indexes; + struct attrinfo *a; + + attrs = str2charray( argv[0], "," ); + if ( argc > 1 ) { + indexes = str2charray( argv[1], "," ); + } + for ( i = 0; attrs[i] != NULL; i++ ) { + a = (struct attrinfo *) ch_malloc( sizeof(struct attrinfo) ); + a->ai_type = ch_strdup( attrs[i] ); + a->ai_syntaxmask = attr_syntax( a->ai_type ); + if ( argc == 1 ) { + a->ai_indexmask = (INDEX_PRESENCE | INDEX_EQUALITY | + INDEX_APPROX | INDEX_SUB); + } else { + a->ai_indexmask = 0; + for ( j = 0; indexes[j] != NULL; j++ ) { + if ( strncasecmp( indexes[j], "pres", 4 ) + == 0 ) { + a->ai_indexmask |= INDEX_PRESENCE; + } else if ( strncasecmp( indexes[j], "eq", 2 ) + == 0 ) { + a->ai_indexmask |= INDEX_EQUALITY; + } else if ( strncasecmp( indexes[j], "approx", + 6 ) == 0 ) { + a->ai_indexmask |= INDEX_APPROX; + } else if ( strncasecmp( indexes[j], "sub", 3 ) + == 0 ) { + a->ai_indexmask |= INDEX_SUB; + } else if ( strncasecmp( indexes[j], "none", 4 ) + == 0 ) { + if ( a->ai_indexmask != 0 ) { + fprintf( stderr, +"%s: line %d: index type \"none\" cannot be combined with other types\n", + fname, lineno ); + } + a->ai_indexmask = 0; + } else { + fprintf( stderr, + "%s: line %d: unknown index type \"%s\" (ignored)\n", + fname, lineno, indexes[j] ); + fprintf( stderr, + "valid index types are \"pres\", \"eq\", \"approx\", or \"sub\"\n" ); + } + } + } + if ( init ) { + a->ai_indexmask |= INDEX_FROMINIT; + } else { + if ( a->ai_indexmask ) + bdb2i_txn_attr_config( li, a->ai_type, 0 ); + } + + switch (avl_insert( &li->li_attrs, (caddr_t) a, + (AVL_CMP) ainfo_cmp, (AVL_DUP) ainfo_dup )) + { + case 1: /* duplicate - updating init version */ + free( a->ai_type ); + free( (char *) a ); + break; + + case 2: /* user duplicate - ignore and warn */ + fprintf( stderr, + "%s: line %d: duplicate index definition for attr \"%s\" (ignored)\n", + fname, lineno, a->ai_type ); + free( a->ai_type ); + free( (char *) a ); + break; + + default:; /* inserted ok */ + /* FALL */ + } + } + charray_free( attrs ); + if ( argc > 1 ) + charray_free( indexes ); +} diff --git a/servers/slapd/back-bdb2/back-bdb2.h b/servers/slapd/back-bdb2/back-bdb2.h index 758318c080..4ebc54422c 100644 --- a/servers/slapd/back-bdb2/back-bdb2.h +++ b/servers/slapd/back-bdb2/back-bdb2.h @@ -1,4 +1,5 @@ /* back-bdb2.h - ldap bdb2 back-end header file */ +/* $OpenLDAP$ */ #ifndef _BACK_BDB2_H_ #define _BACK_BDB2_H_ diff --git a/servers/slapd/back-bdb2/bind.c b/servers/slapd/back-bdb2/bind.c new file mode 100644 index 0000000000..e022a5533b --- /dev/null +++ b/servers/slapd/back-bdb2/bind.c @@ -0,0 +1,347 @@ +/* bind.c - bdb2 backend bind and unbind routines */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include +#include +#include + +#include "slap.h" +#include "back-bdb2.h" +#include "proto-back-bdb2.h" + +#include + +#ifdef HAVE_KERBEROS +extern int bdb2i_krbv4_ldap_auth(); +#endif + +static int +crypted_value_find( + struct berval **vals, + struct berval *v, + int syntax, + int normalize, + struct berval *cred +) +{ + int i; + for ( i = 0; vals[i] != NULL; i++ ) { + if ( syntax != SYNTAX_BIN ) { + int result; + +#ifdef SLAPD_CRYPT + ldap_pvt_thread_mutex_lock( &crypt_mutex ); +#endif + + result = lutil_passwd( + (char*) cred->bv_val, + (char*) vals[i]->bv_val, + NULL ); + +#ifdef SLAPD_CRYPT + ldap_pvt_thread_mutex_unlock( &crypt_mutex ); +#endif + + return result; + + } else { + if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) { + return( 0 ); + } + } + } + + return( 1 ); +} + +static int +bdb2i_back_bind_internal( + BackendDB *be, + Connection *conn, + Operation *op, + char *dn, + int method, + char *mech, + struct berval *cred, + char** edn +) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + Entry *e; + Attribute *a; + int rc; + Entry *matched; +#ifdef HAVE_KERBEROS + char krbname[MAX_K_NAME_SZ + 1]; + AUTH_DAT ad; +#endif + + Debug(LDAP_DEBUG_ARGS, "==> bdb2_back_bind: dn: %s\n", dn, 0, 0); + + *edn = NULL; + + /* get entry with reader lock */ + if ( (e = bdb2i_dn2entry_r( be, dn, &matched )) == NULL ) { + char *matched_dn = NULL; + struct berval **refs = NULL; + + if ( matched != NULL ) { + matched_dn = ch_strdup( matched->e_dn ); + refs = is_entry_referral( matched ) + ? get_entry_referrals( be, conn, op, matched ) + : NULL; + bdb2i_cache_return_entry_r( &li->li_cache, matched ); + } else { + refs = default_referral; + } + + /* allow noauth binds */ + rc = 1; + if ( method == LDAP_AUTH_SIMPLE ) { + if( cred->bv_len == 0 ) { + /* SUCCESS */ + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + + } else if ( be_isroot_pw( be, dn, cred ) ) { + /* front end will send result */ + *edn = ch_strdup( be_root_dn( be ) ); + rc = 0; + + } else { + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + } + + } else if ( method == LDAP_AUTH_SASL ) { + if( mech != NULL && strcasecmp(mech,"DIGEST-MD5") == 0 ) { + /* insert DIGEST calls here */ + send_ldap_result( conn, op, LDAP_AUTH_METHOD_NOT_SUPPORTED, + NULL, NULL, NULL, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_AUTH_METHOD_NOT_SUPPORTED, + NULL, NULL, NULL, NULL ); + } + + } else { + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + rc = 1; + } + + if ( matched != NULL ) { + ber_bvecfree( refs ); + free( matched_dn ); + } + return( rc ); + } + + *edn = ch_strdup( e->e_dn ); + + /* check for deleted */ + + if ( ! access_allowed( be, conn, op, e, + "entry", NULL, ACL_AUTH ) ) + { + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; + } + + if ( is_entry_alias( e ) ) { + /* entry is a alias, don't allow bind */ + Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, + 0, 0 ); + + send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, + NULL, NULL, NULL, NULL ); + + rc = 1; + goto return_results; + } + + + if ( is_entry_referral( e ) ) { + /* entry is a referral, don't allow bind */ + struct berval **refs = get_entry_referrals( be, + conn, op, e ); + + Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, + 0, 0 ); + + send_ldap_result( conn, op, LDAP_REFERRAL, + e->e_dn, NULL, refs, NULL ); + + ber_bvecfree( refs ); + + rc = 1; + goto return_results; + } + + switch ( method ) { + case LDAP_AUTH_SIMPLE: + if ( cred->bv_len == 0 ) { + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + + /* stop front end from sending result */ + rc = 1; + goto return_results; + } + + /* check for root dn/passwd */ + if ( be_isroot_pw( be, dn, cred ) ) { + /* front end will send result */ + if( *edn != NULL ) free( *edn ); + *edn = ch_strdup( be_root_dn( be ) ); + rc = 0; + goto return_results; + } + + if ( ! access_allowed( be, conn, op, e, + "userpassword", NULL, ACL_AUTH ) ) + { + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL); + rc = 1; + goto return_results; + } + + if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) { + send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH, + NULL, NULL, NULL, NULL); + + /* stop front end from sending result */ + rc = 1; + goto return_results; + } + + if ( crypted_value_find( a->a_vals, cred, a->a_syntax, 0, cred ) != 0 ) + { + send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, + NULL, NULL, NULL, NULL); + /* stop front end from sending result */ + rc = 1; + goto return_results; + } + rc = 0; + break; + +#ifdef HAVE_KERBEROS + case LDAP_AUTH_KRBV41: + if ( bdb2i_krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) { + send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, + NULL, NULL, NULL, NULL); + rc = 1; + goto return_results; + } + + if ( ! access_allowed( be, conn, op, e, + "krbname", NULL, ACL_AUTH ) ) + { + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL); + rc = 1; + goto return_results; + } + + sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "." + : "", ad.pinst, ad.prealm ); + + if ( (a = attr_find( e->e_attrs, "krbname" )) == NULL ) { + /* + * no krbName values present: check against DN + */ + if ( strcasecmp( dn, krbname ) == 0 ) { + rc = 0; /* XXX wild ass guess */ + break; + } + send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH, + NULL, NULL, NULL, NULL); + rc = 1; + goto return_results; + } else { /* look for krbName match */ + struct berval krbval; + + krbval.bv_val = krbname; + krbval.bv_len = strlen( krbname ); + + if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) != 0 ) { + send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS, + NULL, NULL, NULL, NULL); + rc = 1; + goto return_results; + } + } + rc = 0; + break; + + case LDAP_AUTH_KRBV42: + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + /* stop front end from sending result */ + rc = 1; + goto return_results; +#endif + + case LDAP_AUTH_SASL: + /* insert sasl code here */ + + default: + send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED, + NULL, "auth method not supported", NULL, NULL ); + rc = 1; + goto return_results; + } + +return_results:; + /* free entry and reader lock */ + bdb2i_cache_return_entry_r( &li->li_cache, e ); + + /* front end with send result on success (rc==0) */ + return( rc ); +} + + +int +bdb2_back_bind( + BackendDB *be, + Connection *conn, + Operation *op, + char *dn, + int method, + char *mech, + struct berval *cred, + char** edn +) +{ + DB_LOCK lock; + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + if ( bdb2i_enter_backend_r( &lock ) != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return( 1 ); + } + + ret = bdb2i_back_bind_internal( be, conn, op, dn, method, mech, cred, edn ); + + (void) bdb2i_leave_backend_r( lock ); + + bdb2i_stop_timing( be->bd_info, time1, "BIND", conn, op ); + + return( ret ); +} + + diff --git a/servers/slapd/back-bdb2/cache.c b/servers/slapd/back-bdb2/cache.c new file mode 100644 index 0000000000..4c44dbcc46 --- /dev/null +++ b/servers/slapd/back-bdb2/cache.c @@ -0,0 +1,590 @@ +/* cache.c - routines to maintain an in-core cache of entries */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include +#include + +#include "slap.h" + +#include "back-bdb2.h" + +/* LDBM backend specific entry info -- visible only to the cache */ +struct ldbm_entry_info { + /* + * These items are specific to the LDBM backend and should + * be hidden. + */ + int lei_state; /* for the cache */ +#define CACHE_ENTRY_UNDEFINED 0 +#define CACHE_ENTRY_CREATING 1 +#define CACHE_ENTRY_READY 2 +#define CACHE_ENTRY_DELETED 3 + + int lei_refcnt; /* # threads ref'ing this entry */ + Entry *lei_lrunext; /* for cache lru list */ + Entry *lei_lruprev; +}; +#define LEI(e) ((struct ldbm_entry_info *) ((e)->e_private)) + +static int cache_delete_entry_internal(struct cache *cache, Entry *e); +#ifdef LDAP_DEBUG +static void lru_print(struct cache *cache); +#endif + +static int +cache_entry_private_init( Entry*e ) +{ + assert( e->e_private == NULL ); + + if( e->e_private != NULL ) { + /* this should never happen */ + return 1; + } + + e->e_private = ch_calloc(1, sizeof(struct ldbm_entry_info)); + + return 0; +} + +static int +cache_entry_private_destroy( Entry*e ) +{ + assert( e->e_private ); + + free( e->e_private ); + e->e_private = NULL; + return 0; +} + +void +bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw ) +{ + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + + assert( e->e_private ); + + LEI(e)->lei_refcnt--; + + if ( LEI(e)->lei_state == CACHE_ENTRY_CREATING ) { + Debug( LDAP_DEBUG_TRACE, + "====> bdb2i_cache_return_entry_%s( %ld ): created (%d)\n", + rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt ); + + LEI(e)->lei_state = CACHE_ENTRY_READY; + + } else if ( LEI(e)->lei_state == CACHE_ENTRY_DELETED ) { + if( LEI(e)->lei_refcnt > 0 ) { + Debug( LDAP_DEBUG_TRACE, + "====> bdb2i_cache_return_entry_%s( %ld ): delete pending (%d)\n", + rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt ); + + } else { + Debug( LDAP_DEBUG_TRACE, + "====> bdb2i_cache_return_entry_%s( %ld ): deleted (%d)\n", + rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt ); + + cache_entry_private_destroy( e ); + entry_free( e ); + } + + } else { + Debug( LDAP_DEBUG_TRACE, + "====> bdb2i_cache_return_entry_%s( %ld ): returned (%d)\n", + rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt); + } + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); +} + +#define LRU_DELETE( cache, e ) { \ + if ( LEI(e)->lei_lruprev != NULL ) { \ + LEI(LEI(e)->lei_lruprev)->lei_lrunext = LEI(e)->lei_lrunext; \ + } else { \ + (cache)->c_lruhead = LEI(e)->lei_lrunext; \ + } \ + if ( LEI(e)->lei_lrunext != NULL ) { \ + LEI(LEI(e)->lei_lrunext)->lei_lruprev = LEI(e)->lei_lruprev; \ + } else { \ + (cache)->c_lrutail = LEI(e)->lei_lruprev; \ + } \ +} + +#define LRU_ADD( cache, e ) { \ + LEI(e)->lei_lrunext = (cache)->c_lruhead; \ + if ( LEI(e)->lei_lrunext != NULL ) { \ + LEI(LEI(e)->lei_lrunext)->lei_lruprev = (e); \ + } \ + (cache)->c_lruhead = (e); \ + LEI(e)->lei_lruprev = NULL; \ + if ( (cache)->c_lrutail == NULL ) { \ + (cache)->c_lrutail = (e); \ + } \ +} + +/* + * bdb2i_cache_add_entry_rw - create and lock an entry in the cache + * returns: 0 entry has been created and locked + * 1 entry already existed + * -1 something bad happened + */ +int +bdb2i_cache_add_entry_rw( + struct cache *cache, + Entry *e, + int rw +) +{ + int i; + Entry *ee; + + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + + assert( e->e_private == NULL ); + + if( cache_entry_private_init(e) != 0 ) { + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + + Debug( LDAP_DEBUG_ANY, + "====> bdb2i_cache_add_entry( %ld ): \"%s\": private init failed!\n", + e->e_id, e->e_dn, 0 ); + + return( -1 ); + } + + if ( avl_insert( &cache->c_dntree, (caddr_t) e, + (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 ) + { + Debug( LDAP_DEBUG_TRACE, + "====> bdb2i_cache_add_entry( %ld ): \"%s\": already in dn cache\n", + e->e_id, e->e_dn, 0 ); + + cache_entry_private_destroy(e); + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( 1 ); + } + + /* id tree */ + if ( avl_insert( &cache->c_idtree, (caddr_t) e, + (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) + { + Debug( LDAP_DEBUG_ANY, + "====> bdb2i_cache_add_entry( %ld ): \"%s\": already in id cache\n", + e->e_id, e->e_dn, 0 ); + + /* delete from dn tree inserted above */ + if ( avl_delete( &cache->c_dntree, (caddr_t) e, + (AVL_CMP) entry_dn_cmp ) == NULL ) + { + Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n", + 0, 0, 0 ); + } + + cache_entry_private_destroy(e); + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( -1 ); + } + + /* put the entry into 'CREATING' state */ + /* will be marked after when entry is returned */ + LEI(e)->lei_state = CACHE_ENTRY_CREATING; + LEI(e)->lei_refcnt = 1; + + /* lru */ + LRU_ADD( cache, e ); + if ( ++cache->c_cursize > cache->c_maxsize ) { + /* + * find the lru entry not currently in use and delete it. + * in case a lot of entries are in use, only look at the + * first 10 on the tail of the list. + */ + i = 0; + while ( cache->c_lrutail != NULL && + LEI(cache->c_lrutail)->lei_refcnt != 0 && + i < 10 ) + { + /* move this in-use entry to the front of the q */ + ee = cache->c_lrutail; + LRU_DELETE( cache, ee ); + LRU_ADD( cache, ee ); + i++; + } + + /* + * found at least one to delete - try to get back under + * the max cache size. + */ + while ( cache->c_lrutail != NULL && + LEI(cache->c_lrutail)->lei_refcnt == 0 && + cache->c_cursize > cache->c_maxsize ) + { + e = cache->c_lrutail; + + /* delete from cache and lru q */ + cache_delete_entry_internal( cache, e ); + cache_entry_private_destroy( e ); + entry_free( e ); + } + } + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( 0 ); +} + +/* + * cache_update_entry - update a LOCKED entry which has been deleted. + * returns: 0 entry has been created and locked + * 1 entry already existed + * -1 something bad happened + */ +int +bdb2i_cache_update_entry( + struct cache *cache, + Entry *e +) +{ + int i; + Entry *ee; + + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + + assert( e->e_private ); + + if ( avl_insert( &cache->c_dntree, (caddr_t) e, + (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 ) + { + Debug( LDAP_DEBUG_TRACE, + "====> bdb2i_cache_add_entry( %ld ): \"%s\": already in dn cache\n", + e->e_id, e->e_dn, 0 ); + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( 1 ); + } + + /* id tree */ + if ( avl_insert( &cache->c_idtree, (caddr_t) e, + (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) + { + Debug( LDAP_DEBUG_ANY, + "====> bdb2i_cache_update_entry( %ld ): \"%s\": already in id cache\n", + e->e_id, e->e_dn, 0 ); + + /* delete from dn tree inserted above */ + if ( avl_delete( &cache->c_dntree, (caddr_t) e, + (AVL_CMP) entry_dn_cmp ) == NULL ) + { + Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n", + 0, 0, 0 ); + } + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( -1 ); + } + + /* put the entry into 'CREATING' state */ + /* will be marked after when entry is returned */ + LEI(e)->lei_state = CACHE_ENTRY_CREATING; + + /* lru */ + LRU_ADD( cache, e ); + if ( ++cache->c_cursize > cache->c_maxsize ) { + /* + * find the lru entry not currently in use and delete it. + * in case a lot of entries are in use, only look at the + * first 10 on the tail of the list. + */ + i = 0; + while ( cache->c_lrutail != NULL && + LEI(cache->c_lrutail)->lei_refcnt != 0 && + i < 10 ) + { + /* move this in-use entry to the front of the q */ + ee = cache->c_lrutail; + LRU_DELETE( cache, ee ); + LRU_ADD( cache, ee ); + i++; + } + + /* + * found at least one to delete - try to get back under + * the max cache size. + */ + while ( cache->c_lrutail != NULL && + LEI(cache->c_lrutail)->lei_refcnt == 0 && + cache->c_cursize > cache->c_maxsize ) + { + e = cache->c_lrutail; + + /* delete from cache and lru q */ + cache_delete_entry_internal( cache, e ); + cache_entry_private_destroy( e ); + entry_free( e ); + } + } + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( 0 ); +} + +/* + * bdb2i_cache_find_entry_dn2id - find an entry in the cache, given dn + */ + +ID +bdb2i_cache_find_entry_dn2id( + BackendDB *be, + struct cache *cache, + const char *dn +) +{ + Entry e, *ep; + ID id; + int count = 0; + + e.e_dn = (char *) dn; + e.e_ndn = ch_strdup( dn ); + (void) dn_normalize_case( e.e_ndn ); + +try_again: + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + + if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e, + (AVL_CMP) entry_dn_cmp )) != NULL ) + { + int state; + count++; + + /* + * ep now points to an unlocked entry + * we do not need to lock the entry if we only + * check the state, refcnt, LRU, and id. + */ + + assert( ep->e_private ); + + /* save id */ + id = ep->e_id; + state = LEI(ep)->lei_state; + + /* + * entry is deleted or not fully created yet + */ + if ( state != CACHE_ENTRY_READY ) { + assert(state != CACHE_ENTRY_UNDEFINED); + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + + Debug(LDAP_DEBUG_TRACE, + "====> bdb2i_cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n", + dn, id, state); + + ldap_pvt_thread_yield(); + goto try_again; + } + + /* lru */ + LRU_DELETE( cache, ep ); + LRU_ADD( cache, ep ); + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + + Debug(LDAP_DEBUG_TRACE, + "====> bdb2i_cache_find_entry_dn2id(\"%s\"): %ld (%d tries)\n", + dn, id, count); + + } else { + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + + id = NOID; + } + + free(e.e_ndn); + + return( id ); +} + +/* + * cache_find_entry_id - find an entry in the cache, given id + */ + +Entry * +bdb2i_cache_find_entry_id( + struct cache *cache, + ID id, + int rw +) +{ + Entry e; + Entry *ep; + int count=0; + + e.e_id = id; + +try_again: + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + + if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e, + (AVL_CMP) entry_id_cmp )) != NULL ) + { + int state; + + assert( ep->e_private ); + + state = LEI(ep)->lei_state; + + /* + * entry is deleted or not fully created yet + */ + if ( state != CACHE_ENTRY_READY ) { + ID ep_id = ep->e_id; + + assert(state != CACHE_ENTRY_UNDEFINED); + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + + Debug(LDAP_DEBUG_TRACE, + "====> bdb2i_cache_find_entry_id( %ld ): %ld (not ready) %d\n", + id, ep_id, state); + + ldap_pvt_thread_yield(); + goto try_again; + } + + /* lru */ + LRU_DELETE( cache, ep ); + LRU_ADD( cache, ep ); + + LEI(ep)->lei_refcnt++; + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + + Debug(LDAP_DEBUG_TRACE, + "====> bdb2i_cache_find_entry_id( %ld ) \"%s\" (found) (%d tries)\n", + id, ep->e_dn, count); + + return( ep ); + } + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + + return( NULL ); +} + +/* + * cache_delete_entry - delete the entry e from the cache. the caller + * should have obtained e (increasing its ref count) via a call to one + * of the cache_find_* routines. the caller should *not* call the + * cache_return_entry() routine prior to calling cache_delete_entry(). + * it performs this function. + * + * returns: 0 e was deleted ok + * 1 e was not in the cache + * -1 something bad happened + */ +int +bdb2i_cache_delete_entry( + struct cache *cache, + Entry *e +) +{ + int rc; + + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + + assert( e->e_private ); + + Debug( LDAP_DEBUG_TRACE, "====> bdb2i_cache_delete_entry( %ld )\n", + e->e_id, 0, 0 ); + + rc = cache_delete_entry_internal( cache, e ); + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( rc ); +} + +static int +cache_delete_entry_internal( + struct cache *cache, + Entry *e +) +{ + int rc = 0; /* return code */ + + /* dn tree */ + if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp ) + == NULL ) + { + rc = -1; + } + + /* id tree */ + if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp ) + == NULL ) + { + rc = -1; + } + + if (rc != 0) { + return rc; + } + + /* lru */ + LRU_DELETE( cache, e ); + cache->c_cursize--; + + /* + * flag entry to be freed later by a call to cache_return_entry() + */ + LEI(e)->lei_state = CACHE_ENTRY_DELETED; + + return( 0 ); +} + +#ifdef LDAP_DEBUG + +static void +lru_print( struct cache *cache ) +{ + Entry *e; + + fprintf( stderr, "LRU queue (head to tail):\n" ); + for ( e = cache->c_lruhead; e != NULL; e = LEI(e)->lei_lrunext ) { + fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n", + e->e_dn, e->e_id, LEI(e)->lei_refcnt ); + } + fprintf( stderr, "LRU queue (tail to head):\n" ); + for ( e = cache->c_lrutail; e != NULL; e = LEI(e)->lei_lruprev ) { + fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n", + e->e_dn, e->e_id, LEI(e)->lei_refcnt ); + } +} + +#endif + diff --git a/servers/slapd/back-bdb2/close.c b/servers/slapd/back-bdb2/close.c index 894e4dfadc..98d68c7c68 100644 --- a/servers/slapd/back-bdb2/close.c +++ b/servers/slapd/back-bdb2/close.c @@ -1,4 +1,5 @@ /* close.c - close bdb2 backend database */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/compare.c b/servers/slapd/back-bdb2/compare.c new file mode 100644 index 0000000000..46093d61a6 --- /dev/null +++ b/servers/slapd/back-bdb2/compare.c @@ -0,0 +1,136 @@ +/* compare.c - bdb2 backend compare routine */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-bdb2.h" +#include "proto-back-bdb2.h" + +static int +bdb2i_back_compare_internal( + BackendDB *be, + Connection *conn, + Operation *op, + char *dn, + Ava *ava +) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + Entry *matched; + Entry *e; + Attribute *a; + int rc; + int manageDSAit = get_manageDSAit( op ); + + /* get entry with reader lock */ + if ( (e = bdb2i_dn2entry_r( be, dn, &matched )) == NULL ) { + char *matched_dn = NULL; + struct berval **refs = NULL; + + if ( matched != NULL ) { + matched_dn = ch_strdup( matched->e_dn ); + refs = is_entry_referral( matched ) + ? get_entry_referrals( be, conn, op, matched ) + : NULL; + bdb2i_cache_return_entry_r( &li->li_cache, matched ); + } else { + refs = default_referral; + } + + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + + if( matched != NULL ) { + ber_bvecfree( refs ); + free( matched_dn ); + } + + return( 1 ); + } + + if (!manageDSAit && is_entry_referral( e ) ) { + /* entry is a referral, don't allow add */ + struct berval **refs = get_entry_referrals( be, + conn, op, e ); + + Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, + 0, 0 ); + + send_ldap_result( conn, op, LDAP_REFERRAL, + e->e_dn, NULL, refs, NULL ); + + ber_bvecfree( refs ); + + rc = 1; + goto return_results; + } + + if ( ! access_allowed( be, conn, op, e, + ava->ava_type, &ava->ava_value, ACL_COMPARE ) ) + { + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; + } + + if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) { + send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE, + NULL, NULL, NULL, NULL ); + rc = 1; + goto return_results; + } + + if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 ) + send_ldap_result( conn, op, LDAP_COMPARE_TRUE, + NULL, NULL, NULL, NULL ); + else + send_ldap_result( conn, op, LDAP_COMPARE_FALSE, + NULL, NULL, NULL, NULL ); + + rc = 0; + +return_results:; + bdb2i_cache_return_entry_r( &li->li_cache, e ); + return( rc ); +} + + +int +bdb2_back_compare( + BackendDB *be, + Connection *conn, + Operation *op, + char *dn, + Ava *ava +) +{ + DB_LOCK lock; + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + if ( bdb2i_enter_backend_r( &lock ) != 0 ) { + + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return( 1 ); + + } + + ret = bdb2i_back_compare_internal( be, conn, op, dn, ava ); + (void) bdb2i_leave_backend_r( lock ); + bdb2i_stop_timing( be->bd_info, time1, "CMP", conn, op ); + + return( ret ); +} + + diff --git a/servers/slapd/back-bdb2/config.c b/servers/slapd/back-bdb2/config.c new file mode 100644 index 0000000000..87d739204a --- /dev/null +++ b/servers/slapd/back-bdb2/config.c @@ -0,0 +1,202 @@ +/* config.c - bdb2 backend configuration file routine */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-bdb2.h" + +static int +bdb2i_back_config_internal( + BackendInfo *bi, + const char *fname, + int lineno, + int argc, + char **argv +) +{ + struct ldbtype *lty = (struct ldbtype *) bi->bi_private; + + if ( lty == NULL ) { + fprintf( stderr, "%s: line %d: ldbm backend type info is null!\n", + fname, lineno ); + return( 1 ); + } + + /* directory where DB control files live */ + if ( strcasecmp( argv[0], "home" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: missing dir in \"home \" line\n", + fname, lineno ); + return( 1 ); + } + lty->lty_dbhome = ch_strdup( argv[1] ); + + /* size of the DB memory pool */ + } else if ( strcasecmp( argv[0], "mpoolsize" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: missing size in \"mpoolsize \" line\n", + fname, lineno ); + return( 1 ); + } + lty->lty_mpsize = (size_t) atoi( argv[1] ); + /* we should at least have the suggested 128k */ + if ( lty->lty_mpsize < DEFAULT_DBCACHE_SIZE ) + lty->lty_mpsize = DEFAULT_DBCACHE_SIZE; + + /* anything else */ + } else { + fprintf( stderr, +"%s: line %d: unknown directive \"%s\" in ldbm backend definition (ignored)\n", + fname, lineno, argv[0] ); + } + + return 0; +} + + +int +bdb2_back_config( + BackendInfo *bi, + const char *fname, + int lineno, + int argc, + char **argv +) +{ + struct timeval time1; + int ret; + + bdb2i_start_timing( bi, &time1 ); + + ret = bdb2i_back_config_internal( bi, fname, lineno, argc, argv ); + bdb2i_stop_timing( bi, time1, "BE-CONFIG", NULL, NULL ); + + return( ret ); +} + + +static int +bdb2i_back_db_config_internal( + BackendDB *be, + const char *fname, + int lineno, + int argc, + char **argv +) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + + if ( li == NULL ) { + fprintf( stderr, "%s: line %d: ldbm database info is null!\n", + fname, lineno ); + return( 1 ); + } + + /* directory where database files live */ + if ( strcasecmp( argv[0], "directory" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: missing dir in \"directory \" line\n", + fname, lineno ); + return( 1 ); + } + li->li_directory = ch_strdup( argv[1] ); + + li->li_nextid_file = + ch_malloc( strlen(li->li_directory) + sizeof("/NEXTID") + 1 ); + + strcpy(li->li_nextid_file, li->li_directory); + strcat(li->li_nextid_file, "/NEXTID"); + + /* mode with which to create new database files */ + } else if ( strcasecmp( argv[0], "mode" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: missing mode in \"mode \" line\n", + fname, lineno ); + return( 1 ); + } + li->li_mode = strtol( argv[1], NULL, 0 ); + + /* attribute to index */ + } else if ( strcasecmp( argv[0], "index" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, +"%s: line %d: missing attr in \"index [pres,eq,approx,sub]\" line\n", + fname, lineno ); + return( 1 ); + } else if ( argc > 3 ) { + fprintf( stderr, +"%s: line %d: extra junk after \"index [pres,eq,approx,sub]\" line (ignored)\n", + fname, lineno ); + } + bdb2i_attr_index_config( li, fname, lineno, argc - 1, &argv[1], 0 ); + + /* size of the cache in entries */ + } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: missing size in \"cachesize \" line\n", + fname, lineno ); + return( 1 ); + } + li->li_cache.c_maxsize = atoi( argv[1] ); + + /* size of each dbcache in bytes */ + } else if ( strcasecmp( argv[0], "dbcachesize" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: missing size in \"dbcachesize \" line\n", + fname, lineno ); + return( 1 ); + } + li->li_dbcachesize = atoi( argv[1] ); + /* we should at least have the suggested 128k */ + if ( li->li_dbcachesize < DEFAULT_DBCACHE_SIZE ) + li->li_dbcachesize = DEFAULT_DBCACHE_SIZE; + + /* no write sync */ + } else if ( strcasecmp( argv[0], "dbcachenowsync" ) == 0 ) { + li->li_dbcachewsync = 0; + + /* anything else */ + } else { + fprintf( stderr, +"%s: line %d: unknown directive \"%s\" in ldbm database definition (ignored)\n", + fname, lineno, argv[0] ); + } + + return 0; +} + + +int +bdb2_back_db_config( + BackendDB *be, + const char *fname, + int lineno, + int argc, + char **argv +) +{ + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + ret = bdb2i_back_db_config_internal( be, fname, lineno, argc, argv ); + + bdb2i_stop_timing( be->bd_info, time1, "DB-CONFIG", NULL, NULL ); + + return( ret ); +} + + diff --git a/servers/slapd/back-bdb2/dbcache.c b/servers/slapd/back-bdb2/dbcache.c index d77e1e772e..6a1a0ef3d8 100644 --- a/servers/slapd/back-bdb2/dbcache.c +++ b/servers/slapd/back-bdb2/dbcache.c @@ -1,4 +1,5 @@ /* ldbmcache.c - maintain a cache of open bdb2 files */ +/* $OpenLDAP$ */ #include "portable.h" @@ -15,7 +16,6 @@ #include #endif -#include "ldap_defaults.h" #include "slap.h" #include "back-bdb2.h" diff --git a/servers/slapd/back-bdb2/delete.c b/servers/slapd/back-bdb2/delete.c index d80d2dceb2..eee7b6d914 100644 --- a/servers/slapd/back-bdb2/delete.c +++ b/servers/slapd/back-bdb2/delete.c @@ -1,4 +1,5 @@ /* delete.c - bdb2 backend delete routine */ +/* $OpenLDAP$ */ #include "portable.h" @@ -126,7 +127,7 @@ bdb2i_back_delete_internal( } /* delete from dn2id mapping */ - if ( bdb2i_dn2id_delete( be, e->e_ndn ) != 0 ) { + if ( bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) { Debug(LDAP_DEBUG_ARGS, "<=- bdb2i_back_delete: operations error %s\n", dn, 0, 0); diff --git a/servers/slapd/back-bdb2/dn2id.c b/servers/slapd/back-bdb2/dn2id.c index 43707b77d9..1d4599a826 100644 --- a/servers/slapd/back-bdb2/dn2id.c +++ b/servers/slapd/back-bdb2/dn2id.c @@ -1,4 +1,5 @@ /* dn2id.c - routines to deal with the dn2id index */ +/* $OpenLDAP$ */ #include "portable.h" @@ -14,7 +15,7 @@ int bdb2i_dn2id_add( BackendDB *be, - char *dn, + const char *dn, ID id ) { @@ -91,7 +92,7 @@ bdb2i_dn2id_add( ID bdb2i_dn2id( BackendDB *be, - char *dn + const char *dn ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; @@ -143,7 +144,7 @@ bdb2i_dn2id( ID_BLOCK * bdb2i_dn2idl( BackendDB *be, - char *dn, + const char *dn, int prefix ) { struct dbcache *db; @@ -178,14 +179,16 @@ bdb2i_dn2idl( int bdb2i_dn2id_delete( BackendDB *be, - char *dn + const char *dn, + ID id ) { struct dbcache *db; Datum key; int rc; - Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\" )\n", dn, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\", %ld )\n", + dn, id, 0 ); if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT )) == NULL ) { @@ -195,6 +198,40 @@ bdb2i_dn2id_delete( return( -1 ); } + { + char *pdn = dn_parent( NULL, dn ); + + if( pdn != NULL ) { + ldbm_datum_init( key ); + key.dsize = strlen( pdn ) + 2; + key.dptr = ch_malloc( key.dsize ); + sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn ); + (void) bdb2i_idl_delete_key( be, db, key, id ); + free( key.dptr ); + free( pdn ); + } + } + + { + char **subtree = dn_subtree( NULL, dn ); + + if( subtree != NULL ) { + int i; + for( i=0; subtree[i] != NULL; i++ ) { + ldbm_datum_init( key ); + key.dsize = strlen( subtree[i] ) + 2; + key.dptr = ch_malloc( key.dsize ); + sprintf( key.dptr, "%c%s", DN_SUBTREE_PREFIX, subtree[i] ); + + (void) bdb2i_idl_delete_key( be, db, key, id ); + + free( key.dptr ); + } + + charray_free( subtree ); + } + } + ldbm_datum_init( key ); key.dsize = strlen( dn ) + 2; @@ -219,7 +256,7 @@ bdb2i_dn2id_delete( Entry * bdb2i_dn2entry_rw( BackendDB *be, - char *dn, + const char *dn, Entry **matched, int rw ) diff --git a/servers/slapd/back-bdb2/entry.c b/servers/slapd/back-bdb2/entry.c new file mode 100644 index 0000000000..9238b1c9b2 --- /dev/null +++ b/servers/slapd/back-bdb2/entry.c @@ -0,0 +1,30 @@ +/* entry.c - ldbm backend entry_release routine */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-bdb2.h" +#include "proto-back-bdb2.h" + + +int +bdb2_back_entry_release_rw( + BackendDB *be, + Entry *e, + int rw +) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + + /* free entry and reader or writer lock */ + bdb2i_cache_return_entry_rw( &li->li_cache, e, rw ); + bdb2i_release_add_lock(); + + return 0; +} diff --git a/servers/slapd/back-bdb2/external.h b/servers/slapd/back-bdb2/external.h index 58da13d224..9af5a84ed6 100644 --- a/servers/slapd/back-bdb2/external.h +++ b/servers/slapd/back-bdb2/external.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ #ifndef _BDB2_EXTERNAL_H #define _BDB2_EXTERNAL_H @@ -9,7 +10,7 @@ extern int bdb2_back_close LDAP_P(( BackendInfo *bi )); extern int bdb2_back_destroy LDAP_P(( BackendInfo *bi )); extern int bdb2_back_config LDAP_P(( BackendInfo *bt, - char *fname, int lineno, int argc, char **argv )); + const char *fname, int lineno, int argc, char **argv )); extern int bdb2_back_db_init LDAP_P(( BackendDB *bd )); extern int bdb2_back_db_open LDAP_P(( BackendDB *bd )); @@ -17,7 +18,7 @@ extern int bdb2_back_db_close LDAP_P(( BackendDB *bd )); extern int bdb2_back_db_destroy LDAP_P(( BackendDB *bd )); extern int bdb2_back_db_config LDAP_P(( BackendDB *bd, - char *fname, int lineno, int argc, char **argv )); + const char *fname, int lineno, int argc, char **argv )); extern int bdb2_back_bind LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, @@ -55,8 +56,8 @@ extern int bdb2_back_abandon LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, int msgid )); extern int bdb2_back_group LDAP_P(( BackendDB *bd, - Entry *target, char* gr_ndn, char* op_ndn, - char* objectclassValue, char* groupattrName)); + Entry *target, const char* gr_ndn, const char* op_ndn, + const char* objectclassValue, const char* groupattrName)); /* hooks for slap tools */ extern int bdb2_tool_entry_open LDAP_P(( BackendDB *be, int mode )); diff --git a/servers/slapd/back-bdb2/filterindex.c b/servers/slapd/back-bdb2/filterindex.c index ad546caa48..a9f7452cf4 100644 --- a/servers/slapd/back-bdb2/filterindex.c +++ b/servers/slapd/back-bdb2/filterindex.c @@ -1,4 +1,5 @@ /* filterindex.c - generate the list of candidate entries from a filter */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/group.c b/servers/slapd/back-bdb2/group.c new file mode 100644 index 0000000000..4bc4fc9a45 --- /dev/null +++ b/servers/slapd/back-bdb2/group.c @@ -0,0 +1,182 @@ +/* group.c - bdb2 backend acl group routine */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-bdb2.h" +#include "proto-back-bdb2.h" + + +/* return 0 IFF op_dn is a value in member attribute + * of entry with gr_dn AND that entry has an objectClass + * value of groupOfNames + */ +static int +bdb2i_back_group_internal( + BackendDB *be, + Entry *target, + const char *gr_ndn, + const char *op_ndn, + const char *objectclassValue, + const char *groupattrName +) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + Entry *e; + int rc = 1; + Attribute *attr; + struct berval bv; + + Debug( LDAP_DEBUG_ARGS, + "=> bdb2i_back_group: gr dn: \"%s\"\n", + gr_ndn, 0, 0 ); + Debug( LDAP_DEBUG_ARGS, + "=> bdb2i_back_group: op dn: \"%s\"\n", + op_ndn, 0, 0 ); + Debug( LDAP_DEBUG_ARGS, + "=> bdb2i_back_group: objectClass: \"%s\" attrName: \"%s\"\n", + objectclassValue, groupattrName, 0 ); + + Debug( LDAP_DEBUG_ARGS, + "=> bdb2i_back_group: tr dn: \"%s\"\n", + target->e_ndn, 0, 0 ); + + if (strcmp(target->e_ndn, gr_ndn) == 0) { + /* we already have a LOCKED copy of the entry */ + e = target; + Debug( LDAP_DEBUG_ARGS, + "=> bdb2i_back_group: target is group: \"%s\"\n", + gr_ndn, 0, 0 ); + + } else { + /* can we find group entry with reader lock */ + if ((e = bdb2i_dn2entry_r(be, gr_ndn, NULL )) == NULL) { + Debug( LDAP_DEBUG_ACL, + "=> bdb2i_back_group: cannot find group: \"%s\"\n", + gr_ndn, 0, 0 ); + return( 1 ); + } + + Debug( LDAP_DEBUG_ACL, + "=> bdb2i_back_group: found group: \"%s\"\n", + gr_ndn, 0, 0 ); + } + + /* find it's objectClass and member attribute values + * make sure this is a group entry + * finally test if we can find op_dn in the member attribute value list + */ + + rc = 1; + + if ((attr = attr_find(e->e_attrs, "objectclass")) == NULL) { + Debug( LDAP_DEBUG_ACL, + "<= bdb2i_back_group: failed to find objectClass\n", 0, 0, 0 ); + goto return_results; + } + + bv.bv_val = "ALIAS"; + bv.bv_len = sizeof("ALIAS")-1; + + if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) { + Debug( LDAP_DEBUG_ACL, + "<= bdb2i_back_group: group is an alias\n", 0, 0, 0 ); + goto return_results; + } + + bv.bv_val = "REFERRAL"; + bv.bv_len = sizeof("REFERRAL")-1; + + if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) { + Debug( LDAP_DEBUG_ACL, + "<= bdb2i_back_group: group is a referral\n", 0, 0, 0 ); + goto return_results; + } + + bv.bv_val = (char *) objectclassValue; + bv.bv_len = strlen( bv.bv_val ); + + if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) { + Debug( LDAP_DEBUG_ACL, + "<= bdb2i_back_group: failed to find %s in objectClass\n", + objectclassValue, 0, 0 ); + goto return_results; + } + + if ((attr = attr_find(e->e_attrs, groupattrName)) == NULL) { + Debug( LDAP_DEBUG_ACL, + "<= bdb2i_back_group: failed to find %s\n", + groupattrName, 0, 0 ); + goto return_results; + } + + Debug( LDAP_DEBUG_ACL, + "<= bdb2i_back_group: found objectClass %s and %s\n", + objectclassValue, groupattrName, 0 ); + + + bv.bv_val = (char *) op_ndn; + bv.bv_len = strlen( op_ndn ); + + if (value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 ) { + Debug( LDAP_DEBUG_ACL, + "<= bdb2i_back_group: \"%s\" not in \"%s\": %s\n", + op_ndn, gr_ndn, groupattrName ); + goto return_results; + } + + Debug( LDAP_DEBUG_ACL, + "<= bdb2i_back_group: \"%s\" is in \"%s\": %s\n", + op_ndn, gr_ndn, groupattrName ); + rc = 0; + +return_results: + if( target != e ) { + /* free entry and reader lock */ + bdb2i_cache_return_entry_r( &li->li_cache, e ); + } + + Debug( LDAP_DEBUG_ARGS, "bdb2i_back_group: rc: %d\n", rc, 0, 0 ); + return(rc); +} + + +int +bdb2_back_group( + BackendDB *be, + Entry *target, + const char *gr_ndn, + const char *op_ndn, + const char *objectclassValue, + const char *groupattrName +) +{ + DB_LOCK lock; + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + if ( bdb2i_enter_backend_r( &lock ) != 0 ) { + + return( 1 ); + + } + + ret = bdb2i_back_group_internal( be, target, gr_ndn, op_ndn, + objectclassValue, groupattrName ); + + (void) bdb2i_leave_backend_r( lock ); + bdb2i_stop_timing( be->bd_info, time1, "GRP", NULL, NULL ); + + return( ret ); +} + + diff --git a/servers/slapd/back-bdb2/id2children.c b/servers/slapd/back-bdb2/id2children.c index 903418daa6..8db5c188b3 100644 --- a/servers/slapd/back-bdb2/id2children.c +++ b/servers/slapd/back-bdb2/id2children.c @@ -1,4 +1,5 @@ /* id2children.c - routines to deal with the id2children index */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/id2entry.c b/servers/slapd/back-bdb2/id2entry.c index c7bf18e5c0..1a151fb1d6 100644 --- a/servers/slapd/back-bdb2/id2entry.c +++ b/servers/slapd/back-bdb2/id2entry.c @@ -1,4 +1,5 @@ /* id2entry.c - routines to deal with the id2entry index */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/idl.c b/servers/slapd/back-bdb2/idl.c index f6718dc4b4..c062642d8e 100644 --- a/servers/slapd/back-bdb2/idl.c +++ b/servers/slapd/back-bdb2/idl.c @@ -1,4 +1,5 @@ /* idl.c - ldap id list handling routines */ +/* $OpenLDAP$ */ #include "portable.h" @@ -7,7 +8,6 @@ #include #include -#include "ldap_defaults.h" #include "slap.h" #include "back-bdb2.h" @@ -467,7 +467,8 @@ bdb2i_idl_insert_key( rc = idl_change_first( be, db, key, idl, i, k2, tmp ); break; - case 2: /* id not inserted - already there */ + case 2: /* id not inserted - already there, do nothing */ + rc = 0; break; case 3: /* id not inserted - block is full */ @@ -488,7 +489,8 @@ bdb2i_idl_insert_key( Debug( LDAP_DEBUG_ANY, "idl_fetch_one (%s) returns NULL\n", k2.dptr, 0, 0 ); - break; + /* split the original block */ + goto split; } switch ( (rc = bdb2i_idl_insert( &tmp2, id, @@ -514,14 +516,19 @@ bdb2i_idl_insert_key( case 3: /* split the original block */ break; } + bdb2i_idl_free( tmp2 ); } +split: /* * must split the block, write both new blocks + update * and write the indirect header block. */ + rc = 0; /* optimistic */ + + /* count how many indirect blocks *//* XXX linear count XXX */ for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) ; /* NULL */ @@ -618,7 +625,7 @@ bdb2i_idl_insert_key( int bdb2i_idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids ) { - unsigned int i, j; + unsigned int i; if ( ID_BLOCK_ALLIDS( *idl ) ) { return( 2 ); /* already there */ @@ -648,8 +655,8 @@ bdb2i_idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids ) } /* make a slot for the new id */ - SAFEMEMCPY( &ID_BLOCK_ID(*idl, i), &ID_BLOCK_ID(*idl, i+1), - ID_BLOCK_NIDS(*idl) - i ); + SAFEMEMCPY( &ID_BLOCK_ID(*idl, i+1), &ID_BLOCK_ID(*idl, i), + (ID_BLOCK_NIDS(*idl) - i) * sizeof(ID) ); ID_BLOCK_ID(*idl, i) = id; ID_BLOCK_NIDS(*idl)++; diff --git a/servers/slapd/back-bdb2/index.c b/servers/slapd/back-bdb2/index.c index 0338712c70..6ef1ca2f73 100644 --- a/servers/slapd/back-bdb2/index.c +++ b/servers/slapd/back-bdb2/index.c @@ -1,4 +1,5 @@ /* index.c - routines for dealing with attribute indexes */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/init.c b/servers/slapd/back-bdb2/init.c index 3977fc5e20..0eb5080460 100644 --- a/servers/slapd/back-bdb2/init.c +++ b/servers/slapd/back-bdb2/init.c @@ -1,4 +1,5 @@ /* init.c - initialize bdb2 backend */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/kerberos.c b/servers/slapd/back-bdb2/kerberos.c new file mode 100644 index 0000000000..61a9db0763 --- /dev/null +++ b/servers/slapd/back-bdb2/kerberos.c @@ -0,0 +1,49 @@ +/* kerberos.c - bdb2 backend kerberos bind routines */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#ifdef HAVE_KERBEROS + +#include + +#include +#include +#include + +#include "slap.h" +#include "back-bdb2.h" + +#define LDAP_KRB_PRINCIPAL "ldapserver" + +extern char *ldap_srvtab; +extern Attribute *attr_find(); + +bdb2i_krbv4_ldap_auth( + BackendDB *be, + struct berval *cred, + AUTH_DAT *ad +) +{ + KTEXT_ST k; + KTEXT ktxt = &k; + char instance[INST_SZ]; + int err; + + Debug( LDAP_DEBUG_TRACE, "=> kerberosv4_ldap_auth\n", 0, 0, 0 ); + + SAFEMEMCPY( ktxt->dat, cred->bv_val, cred->bv_len ); + ktxt->length = cred->bv_len; + + strcpy( instance, "*" ); + if ( (err = krb_rd_req( ktxt, LDAP_KRB_PRINCIPAL, instance, 0L, ad, + ldap_srvtab )) != KSUCCESS ) { + Debug( LDAP_DEBUG_ANY, "krb_rd_req failed (%s)\n", + krb_err_txt[err], 0, 0 ); + return( LDAP_INVALID_CREDENTIALS ); + } + + return( LDAP_SUCCESS ); +} + +#endif /* kerberos */ diff --git a/servers/slapd/back-bdb2/modify.c b/servers/slapd/back-bdb2/modify.c index 1e4a62d9a3..817d3ba26f 100644 --- a/servers/slapd/back-bdb2/modify.c +++ b/servers/slapd/back-bdb2/modify.c @@ -1,4 +1,5 @@ /* modify.c - bdb2 backend modify routine */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/modrdn.c b/servers/slapd/back-bdb2/modrdn.c new file mode 100644 index 0000000000..47c260fed7 --- /dev/null +++ b/servers/slapd/back-bdb2/modrdn.c @@ -0,0 +1,510 @@ +/* modrdn.c - bdb2 backend modrdn routine */ +/* $OpenLDAP$ */ + +/* + * LDAP v3 newSuperior support. + * + * Copyright 1999, Juan C. Gomez, All rights reserved. + * This software is not subject to any license of Silicon Graphics + * Inc. or Purdue University. + * + * Redistribution and use in source and binary forms are permitted + * without restriction or fee of any kind as long as this notice + * is preserved. + * + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-bdb2.h" +#include "proto-back-bdb2.h" + +static int +bdb2i_back_modrdn_internal( + BackendDB *be, + Connection *conn, + Operation *op, + char *dn, + char *newrdn, + int deleteoldrdn, + char *newSuperior +) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + Entry *matched = NULL; + char *p_dn = NULL, *p_ndn = NULL; + char *new_dn = NULL, *new_ndn = NULL; + char sep[2]; + Entry *e, *p = NULL; + int rc = -1, manageDSAit; + /* Added to support LDAP v2 correctly (deleteoldrdn thing) */ + char *new_rdn_val = NULL; /* Val of new rdn */ + char *new_rdn_type = NULL; /* Type of new rdn */ + char *old_rdn = NULL; /* Old rdn's attr type & val */ + char *old_rdn_type = NULL; /* Type of old rdn attr. */ + char *old_rdn_val = NULL; /* Old rdn attribute value */ + struct berval add_bv; /* Stores new rdn att */ + struct berval *add_bvals[2]; /* Stores new rdn att */ + struct berval del_bv; /* Stores old rdn att */ + struct berval *del_bvals[2]; /* Stores old rdn att */ + LDAPModList mod[2]; /* Used to delete old rdn */ + /* Added to support newSuperior */ + Entry *np = NULL; /* newSuperior Entry */ + char *np_dn = NULL; /* newSuperior dn */ + char *np_ndn = NULL; /* newSuperior ndn */ + char *new_parent_dn = NULL; /* np_dn, p_dn, or NULL */ + + Debug( LDAP_DEBUG_TRACE, "==>ldbm_back_modrdn(newSuperior=%s)\n", + (newSuperior ? newSuperior : "NULL"), + 0, 0 ); + + /* get entry with writer lock */ + if ( (e = bdb2i_dn2entry_w( be, dn, &matched )) == NULL ) { + char *matched_dn = NULL; + struct berval **refs = NULL; + + if ( matched != NULL ) { + matched_dn = ch_strdup( matched->e_dn ); + refs = is_entry_referral( matched ) + ? get_entry_referrals( be, conn, op, matched ) + : NULL; + bdb2i_cache_return_entry_r( &li->li_cache, matched ); + } else { + refs = default_referral; + } + + send_ldap_result( conn, op, LDAP_REFERRAL, + matched_dn, NULL, refs, NULL ); + + if( matched != NULL ) { + ber_bvecfree( refs ); + free( matched_dn ); + } + + return( -1 ); + } + + if (!manageDSAit && is_entry_referral( e ) ) { + /* entry is a referral, don't allow add */ + struct berval **refs = get_entry_referrals( be, + conn, op, e ); + + Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0, + 0, 0 ); + + send_ldap_result( conn, op, LDAP_REFERRAL, + e->e_dn, NULL, refs, NULL ); + + ber_bvecfree( refs ); + + goto return_results; + } + +#ifdef SLAPD_CHILD_MODIFICATION_WITH_ENTRY_ACL + /* check parent for "children" acl */ + if ( ! access_allowed( be, conn, op, e, + "entry", NULL, ACL_WRITE ) ) + { + Debug( LDAP_DEBUG_TRACE, "no access to entry\n", 0, + 0, 0 ); + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + goto return_results; + } +#endif + + if ( (p_ndn = dn_parent( be, e->e_ndn )) != NULL ) { + /* parent + rdn + separator(s) + null */ + if( (p = bdb2i_dn2entry_w( be, p_ndn, &matched )) == NULL) { + Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", + 0, 0, 0); + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + /* check parent for "children" acl */ + if ( ! access_allowed( be, conn, op, p, + "children", NULL, ACL_WRITE ) ) + { + Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, + 0, 0 ); + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + p_dn = dn_parent( be, e->e_dn ); + + Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: parent dn=%s\n", + p_dn, 0, 0 ); + + + } else { + /* no parent, modrdn entry directly under root */ + if( ! be_isroot( be, op->o_ndn ) ) { + Debug( LDAP_DEBUG_TRACE, "no parent & not root\n", + 0, 0, 0); + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: no parent!, working on root\n", + 0, 0, 0 ); + + } + + new_parent_dn = p_dn; /* New Parent unless newSuperior given */ + + if ( (np_dn = newSuperior) != NULL) { + + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: new parent requested...\n", + 0, 0, 0 ); + + np_ndn = ch_strdup( np_dn ); + (void) dn_normalize_case( np_ndn ); + + /* newSuperior == oldParent?, if so ==> ERROR */ + + /* newSuperior == entry being moved?, if so ==> ERROR */ + + /* Get Entry with dn=newSuperior. Does newSuperior exist? */ + + if( (np = bdb2i_dn2entry_w( be, np_ndn, &matched )) == NULL) { + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: newSup(ndn=%s) not here!\n", + np_ndn, 0, 0); + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: wr to new parent OK np=%p, id=%d\n", + np, np->e_id, 0 ); + + /* check newSuperior for "children" acl */ + if ( !access_allowed( be, conn, op, np, "children", NULL, + ACL_WRITE ) ) + { + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: no wr to newSup children\n", + 0, 0, 0 ); + send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: wr to new parent's children OK\n", + 0, 0 , 0 ); + + + new_parent_dn = np_dn; + + } + + /* Build target dn and make sure target entry doesn't exist already. */ + + build_new_dn( &new_dn, e->e_dn, new_parent_dn, newrdn ); + + + new_ndn = ch_strdup( new_dn ); + (void) dn_normalize_case( new_ndn ); + + Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n", + new_ndn, 0, 0 ); + + /* check for abandon */ + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); + if ( op->o_abandon ) { + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + goto return_results; + } + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + + if ( (bdb2i_dn2id ( be, new_ndn ) ) != NOID ) { + send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + /* Get attribute type and attribute value of our new rdn, we will + * need to add that to our new entry + */ + + if ( (new_rdn_type = rdn_attr_type( newrdn )) == NULL ) { + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: can't figure out type of newrdn\n", + 0, 0, 0 ); + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + + } + + if ( (new_rdn_val = rdn_attr_value( newrdn )) == NULL ) { + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: can't figure out val of newrdn\n", + 0, 0, 0 ); + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + + } + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: new_rdn_val=%s, new_rdn_type=%s\n", + new_rdn_val, new_rdn_type, 0 ); + + /* Retrieve the old rdn from the entry's dn */ + + if ( (old_rdn = dn_rdn( be, dn )) == NULL ) { + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: can't figure out old_rdn from dn\n", + 0, 0, 0 ); + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + + } + + if ( (old_rdn_type = rdn_attr_type( old_rdn )) == NULL ) { + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: can't figure out the old_rdn type\n", + 0, 0, 0 ); + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + + } + + if ( strcasecmp( old_rdn_type, new_rdn_type ) != 0 ) { + + /* Not a big deal but we may say something */ + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: old_rdn_type=%s, new_rdn_type=%s!\n", + old_rdn_type, new_rdn_type, 0 ); + + } + +#ifdef DNS_DN + if ( dn_type( old_rdn ) == DN_X500 ) { +#endif + + Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: DN_X500\n", + 0, 0, 0 ); + + /* Add new attribute value to the entry. + */ + + add_bvals[0] = &add_bv; /* Array of bervals */ + add_bvals[1] = NULL; + + add_bv.bv_val = new_rdn_val; + add_bv.bv_len = strlen(new_rdn_val); + + mod[0].ml_type = new_rdn_type; + mod[0].ml_bvalues = add_bvals; + mod[0].ml_op = LDAP_MOD_SOFTADD; + mod[0].ml_next = NULL; + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: adding new rdn attr val =%s\n", + new_rdn_val, 0, 0 ); + + /* Remove old rdn value if required */ + + if (deleteoldrdn) { + + del_bvals[0] = &del_bv; /* Array of bervals */ + del_bvals[1] = NULL; + /* Get value of old rdn */ + + if ((old_rdn_val = rdn_attr_value( old_rdn )) + == NULL) { + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: can't figure out old_rdn_val from old_rdn\n", + 0, 0, 0 ); + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + + + } + + /* Remove old value of rdn as an attribute. */ + + del_bv.bv_val = old_rdn_val; + del_bv.bv_len = strlen(old_rdn_val); + + mod[0].ml_next = &mod[1]; + mod[1].ml_type = old_rdn_type; + mod[1].ml_bvalues = del_bvals; + mod[1].ml_op = LDAP_MOD_DELETE; + mod[1].ml_next = NULL; + + + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: removing old_rdn_val=%s\n", + old_rdn_val, 0, 0 ); + + }/* if (deleteoldrdn) */ + +#ifdef DNS_DN + } else { + + + Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: DNS DN\n", + 0, 0, 0 ); + /* XXXV3: not sure of what to do here */ + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: not fully implemented...\n", + 0, 0, 0 ); + + } +#endif + + /* check for abandon */ + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); + if ( op->o_abandon ) { + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + goto return_results; + } + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + + /* delete old one */ + if ( bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + (void) bdb2i_cache_delete_entry( &li->li_cache, e ); + + free( e->e_dn ); + free( e->e_ndn ); + e->e_dn = new_dn; + e->e_ndn = new_ndn; + new_dn = NULL; + new_ndn = NULL; + + /* add new one */ + if ( bdb2i_dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + /* modify memory copy of entry */ + if ( bdb2i_back_modify_internal( be, conn, op, dn, &mod[0], e ) + != 0 ) { + + goto return_results; + + } + + (void) bdb2i_cache_update_entry( &li->li_cache, e ); + + /* NOTE: after this you must not free new_dn or new_ndn! + * They are used by cache. + */ + + /* id2entry index */ + if ( bdb2i_id2entry_add( be, e ) != 0 ) { + entry_free( e ); + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + rc = 0; + +return_results: + if( new_dn != NULL ) free( new_dn ); + if( new_ndn != NULL ) free( new_ndn ); + + /* NOTE: + * new_dn and new_ndn are not deallocated because they are used by + * the cache entry. + */ + if( p_dn != NULL ) free( p_dn ); + if( p_ndn != NULL ) free( p_ndn ); + + /* LDAP v2 supporting correct attribute handling. */ + if( new_rdn_type != NULL ) free(new_rdn_type); + if( new_rdn_val != NULL ) free(new_rdn_val); + if( old_rdn != NULL ) free(old_rdn); + if( old_rdn_type != NULL ) free(old_rdn_type); + if( old_rdn_val != NULL ) free(old_rdn_val); + + /* LDAP v3 Support */ + if ( np_dn != NULL ) free( np_dn ); + if ( np_ndn != NULL ) free( np_ndn ); + + if( p != NULL ) { + /* free parent and writer lock */ + bdb2i_cache_return_entry_w( &li->li_cache, p ); + + } + + /* free entry and writer lock */ + bdb2i_cache_return_entry_w( &li->li_cache, e ); + return( rc ); +} + + +int +bdb2_back_modrdn( + BackendDB *be, + Connection *conn, + Operation *op, + char *dn, + char *newrdn, + int deleteoldrdn, + char *newSuperior +) +{ + DB_LOCK lock; + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + if ( bdb2i_enter_backend_w( &lock ) != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + return( -1 ); + + } + + ret = bdb2i_back_modrdn_internal( be, conn, op, dn, + newrdn, deleteoldrdn, + newSuperior ); + + (void) bdb2i_leave_backend_w( lock ); + bdb2i_stop_timing( be->bd_info, time1, "MODRDN", conn, op ); + + return( ret ); +} + + diff --git a/servers/slapd/back-bdb2/nextid.c b/servers/slapd/back-bdb2/nextid.c index 91cb5e360a..c00c67d11d 100644 --- a/servers/slapd/back-bdb2/nextid.c +++ b/servers/slapd/back-bdb2/nextid.c @@ -1,4 +1,5 @@ /* id.c - keep track of the next id to be given out */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/porter.c b/servers/slapd/back-bdb2/porter.c index 8dba543e7c..55f87a63d3 100644 --- a/servers/slapd/back-bdb2/porter.c +++ b/servers/slapd/back-bdb2/porter.c @@ -1,4 +1,5 @@ /* porter.c - port functions of the bdb2 backend */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/proto-back-bdb2.h b/servers/slapd/back-bdb2/proto-back-bdb2.h index 7f1042202d..befba8b8ab 100644 --- a/servers/slapd/back-bdb2/proto-back-bdb2.h +++ b/servers/slapd/back-bdb2/proto-back-bdb2.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ #ifndef _PROTO_BACK_BDB2 #define _PROTO_BACK_BDB2 @@ -37,7 +38,8 @@ Entry * bdb2i_deref_r LDAP_P(( void bdb2i_attr_masks LDAP_P(( struct ldbminfo *li, char *type, int *indexmask, int *syntaxmask )); -void bdb2i_attr_index_config LDAP_P(( struct ldbminfo *li, char *fname, +void bdb2i_attr_index_config LDAP_P(( struct ldbminfo *li, + const char *fname, int lineno, int argc, char **argv, int init )); /* @@ -52,7 +54,7 @@ void bdb2i_cache_return_entry_rw LDAP_P(( struct cache *cache, Entry *e, #define bdb2i_cache_return_entry_w(c, e) bdb2i_cache_return_entry_rw((c), (e), 1) ID bdb2i_cache_find_entry_dn2id LDAP_P(( BackendDB *be, struct cache *cache, - char *dn )); + const char *dn )); Entry * bdb2i_cache_find_entry_id LDAP_P(( struct cache *cache, ID id, int rw )); int bdb2i_cache_delete_entry LDAP_P(( struct cache *cache, Entry *e )); @@ -73,19 +75,19 @@ int bdb2i_cache_delete LDAP_P(( struct dbcache *db, Datum key )); * dn2id.c */ -int bdb2i_dn2id_add LDAP_P(( BackendDB *be, char *dn, ID id )); -ID bdb2i_dn2id LDAP_P(( BackendDB *be, char *dn )); -int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, char *dn )); +int bdb2i_dn2id_add LDAP_P(( BackendDB *be, const char *dn, ID id )); +ID bdb2i_dn2id LDAP_P(( BackendDB *be, const char *dn )); +int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, const char *dn, ID id )); ID_BLOCK * bdb2i_dn2idl LDAP_P(( BackendDB *be, - char *dn, + const char *dn, int prefix )); Entry * bdb2i_dn2entry_rw LDAP_P(( BackendDB *be, - char *dn, + const char *dn, Entry **matched, int rw )); diff --git a/servers/slapd/back-bdb2/search.c b/servers/slapd/back-bdb2/search.c index 9b5dc6d3de..4bec697151 100644 --- a/servers/slapd/back-bdb2/search.c +++ b/servers/slapd/back-bdb2/search.c @@ -1,4 +1,5 @@ /* search.c - bdb2 backend search function */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/startup.c b/servers/slapd/back-bdb2/startup.c new file mode 100644 index 0000000000..3bf3b09d97 --- /dev/null +++ b/servers/slapd/back-bdb2/startup.c @@ -0,0 +1,260 @@ +/* startup.c - startup/shutdown bdb2 backend */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_DIRECT_H +#include +#endif + +#include "slap.h" +#include "back-bdb2.h" + +#include "db.h" + +static void remove_old_locks( char *home ); + + +static void +bdb2i_db_errcall( const char *prefix, char *message ) +{ + Debug( LDAP_DEBUG_ANY, "bdb2_db_errcall(): %s %s", prefix, message, 0 ); +} + + +/* startup/shutdown per backend type */ + +static int +bdb2i_back_startup_internal( + BackendInfo *bi +) +{ + struct ldbtype *lty = (struct ldbtype *) bi->bi_private; + u_int32_t envFlags; + int err = 0; + char *home; + + /* set the flags for a full-feldged transaction schema */ + envFlags = ( DB_CREATE | DB_THREAD | DB_INIT_TXN | DB_INIT_LOG | + DB_INIT_LOCK | DB_INIT_MPOOL ); + + /* make sure, dbhome is an absolute path */ + if ( *lty->lty_dbhome != *LDAP_DIRSEP ) { + char cwd[MAXPATHLEN]; + + (void) getcwd( cwd, MAXPATHLEN ); + sprintf( cwd, "%s" LDAP_DIRSEP "%s", + cwd, lty->lty_dbhome ); + free( lty->lty_dbhome ); + lty->lty_dbhome = ch_strdup( cwd ); + + } + home = lty->lty_dbhome; + + /* general initialization of the environment */ + memset( &bdb2i_dbEnv, 0, sizeof( DB_ENV )); + bdb2i_dbEnv.db_errcall = bdb2i_db_errcall; + bdb2i_dbEnv.db_errpfx = "==>"; + + /* initialize the lock subsystem */ + bdb2i_dbEnv.lk_max = 0; + + /* remove old locking tables */ + remove_old_locks( home ); + + /* initialize the mpool subsystem */ + bdb2i_dbEnv.mp_size = lty->lty_mpsize; + + /* now do the db_appinit */ + if ( ( err = db_appinit( home, NULL, &bdb2i_dbEnv, envFlags )) ) { + char error[BUFSIZ]; + + if ( err < 0 ) sprintf( error, "%ld\n", (long) err ); + else sprintf( error, "%s\n", strerror( err )); + + Debug( LDAP_DEBUG_ANY, + "bdb2i_back_startup(): FATAL error in db_appinit() : %s\n", + error, 0, 0 ); + return( 1 ); + + } + + return 0; +} + + +static int +bdb2i_back_shutdown_internal( + BackendInfo *bi +) +{ + struct ldbtype *lty = (struct ldbtype *) bi->bi_private; + int err; + + /* remove old locking tables */ + bdb2i_dbEnv.db_errpfx = "bdb2i_back_shutdown(): lock_unlink:"; + if ( ( err = lock_unlink( NULL, 1, &bdb2i_dbEnv )) != 0 ) + Debug( LDAP_DEBUG_ANY, "bdb2i_back_shutdown(): lock_unlink: %s\n", + strerror( err ), 0, 0); + + /* remove old memory pool */ + bdb2i_dbEnv.db_errpfx = "bdb2i_back_shutdown(): memp_unlink:"; + if ( ( err = memp_unlink( NULL, 1, &bdb2i_dbEnv )) != 0 ) + Debug( LDAP_DEBUG_ANY, "bdb2i_back_shutdown(): memp_unlink: %s\n", + strerror( err ), 0, 0); + + (void) db_appexit( &bdb2i_dbEnv ); + + return( 0 ); +} + + +int +bdb2i_back_startup( + BackendInfo *bi +) +{ + struct timeval time1; + int ret; + + bdb2i_start_timing( bi, &time1 ); + + ret = bdb2i_back_startup_internal( bi ); + bdb2i_stop_timing( bi, time1, "BE-START", NULL, NULL ); + + return( ret ); +} + + +int +bdb2i_back_shutdown( + BackendInfo *bi +) +{ + struct timeval time1; + int ret; + + bdb2i_start_timing( bi, &time1 ); + + ret = bdb2i_back_shutdown_internal( bi ); + bdb2i_stop_timing( bi, time1, "BE-SHUTDOWN", NULL, NULL ); + + return( ret ); +} + + +/* startup/shutdown per backend database */ + +static int +bdb2i_back_db_startup_internal( + BackendDB *be +) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + + /* if the data directory is not an absolute path, have it relative + to the current working directory (which should not be configured !) */ + if ( *li->li_directory != *LDAP_DIRSEP ) { + char cwd[MAXPATHLEN]; + + (void) getcwd( cwd, MAXPATHLEN ); + sprintf( cwd, "%s" LDAP_DIRSEP "%s", + cwd, li->li_directory ); + + free( li->li_directory ); + li->li_directory = ch_strdup( cwd ); + + } + + /* if there are more index files, add them to the DB file list */ + if ( bdb2i_check_additional_attr_index( li ) != 0 ) + return 1; + + /* now open all DB files */ + if ( bdb2i_txn_open_files( be ) != 0 ) + return 1; + + return 0; +} + + +static int +bdb2i_back_db_shutdown_internal( + BackendDB *be +) +{ + return 0; +} + + +int +bdb2_back_db_startup( + BackendDB *be +) +{ + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + ret = bdb2i_back_db_startup_internal( be ); + bdb2i_stop_timing( be->bd_info, time1, "DB-START", NULL, NULL ); + + return( ret ); +} + + +int +bdb2_back_db_shutdown( + BackendDB *be +) +{ + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + ret = bdb2i_back_db_shutdown_internal( be ); + bdb2i_stop_timing( be->bd_info, time1, "DB-SHUTDOWN", NULL, NULL ); + + return( ret ); +} + + +static void +remove_old_locks( char *home ) +{ + DB_ENV dbEnv; + int err; + + memset( &dbEnv, 0, sizeof( DB_ENV )); + dbEnv.db_errcall = bdb2i_db_errcall; + dbEnv.db_errpfx = "remove_old_locks(): db_appinit:"; + dbEnv.lk_max = 0; + + if ( ( err = db_appinit( home, NULL, &dbEnv, 0 )) != 0 ) + Debug( LDAP_DEBUG_ANY, "remove_old_locks(): db_appinit: %s\n", + strerror( err ), 0, 0); + + dbEnv.db_errpfx = "remove_old_locks(): lock_unlink:"; + if ( ( err = lock_unlink( NULL, 1, &dbEnv )) != 0 ) + Debug( LDAP_DEBUG_ANY, "remove_old_locks(): lock_unlink: %s\n", + strerror( err ), 0, 0); + + dbEnv.db_errpfx = "remove_old_locks(): db_appexit:"; + if ( ( err = db_appexit( &dbEnv )) != 0 ) + Debug( LDAP_DEBUG_ANY, "remove_old_locks(): db_appexit: %s\n", + strerror( err ), 0, 0); + +} + + diff --git a/servers/slapd/back-bdb2/timing.c b/servers/slapd/back-bdb2/timing.c new file mode 100644 index 0000000000..c1d6605674 --- /dev/null +++ b/servers/slapd/back-bdb2/timing.c @@ -0,0 +1,70 @@ +/* timing.c - timing bdb2 backend */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include + +#include +#include +#include + +#include "slap.h" +#include "back-bdb2.h" + + +static char * +bdb2i_elapsed( struct timeval firsttime, struct timeval secondtime ) +{ + long int elapsedmicrosec, elapsedsec; + char elapsed_string[BUFSIZ]; + + elapsedsec = secondtime.tv_sec - firsttime.tv_sec; + elapsedmicrosec = secondtime.tv_usec - firsttime.tv_usec; + if(elapsedmicrosec < 0) { + elapsedmicrosec += 1000000; + elapsedsec -= 1; + } + + sprintf( elapsed_string, "%ld.%.6ld", elapsedsec, elapsedmicrosec ); + return( ch_strdup( elapsed_string )); +} + + +void +bdb2i_uncond_start_timing( + struct timeval *time1 +) +{ + gettimeofday( time1, NULL ); +} + + +void +bdb2i_uncond_stop_timing( + struct timeval time1, + char *func, + Connection *conn, + Operation *op, + int level +) +{ + struct timeval time2; + char *elapsed_time; + char buf[BUFSIZ]; + + *buf = '\0'; + + gettimeofday( &time2, NULL); + elapsed_time = bdb2i_elapsed( time1, time2 ); + + if ( conn != NULL ) sprintf( buf, "conn=%d ", conn->c_connid ); + if ( op != NULL ) sprintf( buf, "%sop=%d ", buf, op->o_opid ); + + Debug( level, "%s%s elapsed=%s\n", buf, func, elapsed_time ); + + free( elapsed_time ); + +} + + diff --git a/servers/slapd/back-bdb2/tools.c b/servers/slapd/back-bdb2/tools.c index 66b018a03a..662381dfb0 100644 --- a/servers/slapd/back-bdb2/tools.c +++ b/servers/slapd/back-bdb2/tools.c @@ -1,4 +1,5 @@ /* tools.c - tools for slap tools */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -184,7 +185,7 @@ ID bdb2_tool_entry_put( rc = bdb2i_cache_store( id2entry, key, data, LDBM_REPLACE ); if( rc != 0 ) { - (void) bdb2i_dn2id_delete( be, e->e_ndn ); + (void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ); return NOID; } diff --git a/servers/slapd/back-bdb2/txn.c b/servers/slapd/back-bdb2/txn.c index 747a754cce..2a711385d1 100644 --- a/servers/slapd/back-bdb2/txn.c +++ b/servers/slapd/back-bdb2/txn.c @@ -1,4 +1,5 @@ /* txn.c - TP support functions of the bdb2 backend */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-bdb2/txn.h b/servers/slapd/back-bdb2/txn.h index 93a43ebc21..9093127ae2 100644 --- a/servers/slapd/back-bdb2/txn.h +++ b/servers/slapd/back-bdb2/txn.h @@ -1,4 +1,5 @@ /* txn.h - Header for TP support functions of the bdb2 backend */ +/* $OpenLDAP$ */ #ifndef _BDB2_TXN_H_ #define _BDB2_TXN_H_ @@ -16,7 +17,6 @@ #include #include -#include "ldap_defaults.h" #include "slap.h" #include "back-bdb2.h" diff --git a/servers/slapd/back-bdb2/unbind.c b/servers/slapd/back-bdb2/unbind.c new file mode 100644 index 0000000000..b2c179dee9 --- /dev/null +++ b/servers/slapd/back-bdb2/unbind.c @@ -0,0 +1,39 @@ +/* unbind.c - handle an ldap unbind operation */ +/* $OpenLDAP$ */ + +#include "portable.h" + +#include +#include + +#include "slap.h" +#include "back-bdb2.h" + +static int +bdb2i_back_unbind_internal( + BackendDB *be, + Connection *conn, + Operation *op +) +{ + return( 0 ); +} + + +int +bdb2_back_unbind( + BackendDB *be, + Connection *conn, + Operation *op +) +{ + struct timeval time1; + int ret; + + bdb2i_start_timing( be->bd_info, &time1 ); + + ret = bdb2i_back_unbind_internal( be, conn, op ); + bdb2i_stop_timing( be->bd_info, time1, "UNBIND", conn, op ); + + return( ret ); +} diff --git a/servers/slapd/back-ldap/Makefile.in b/servers/slapd/back-ldap/Makefile.in index 208c16785f..fe015081fc 100644 --- a/servers/slapd/back-ldap/Makefile.in +++ b/servers/slapd/back-ldap/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + SRCS = init.c config.c search.c bind.c unbind.c add.c compare.c \ delete.c modify.c modrdn.c OBJS = init.lo config.lo search.lo bind.lo unbind.lo add.lo compare.lo \ diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c new file mode 100644 index 0000000000..2ff2b7568c --- /dev/null +++ b/servers/slapd/back-ldap/add.c @@ -0,0 +1,79 @@ +/* add.c - ldap backend add function */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_add( + Backend *be, + Connection *conn, + Operation *op, + Entry *e +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + int i; + Attribute *a; + LDAPMod **attrs; + + lc = ldap_back_getconn(li, conn, op); + if (!lc) + return( -1 ); + + if (!lc->bound) { + ldap_back_dobind(lc, op); + if (!lc->bound) + return( -1 ); + } + + /* Count number of attributes in entry */ + for (i=1, a=e->e_attrs; a; i++, a=a->a_next) + ; + + /* Create array of LDAPMods for ldap_add() */ + attrs = (LDAPMod **)ch_malloc(sizeof(LDAPMod *)*i); + attrs[i-1] = 0; + + for (i=0, a=e->e_attrs; a; i++, a=a->a_next) { + attrs[i] = (LDAPMod *)ch_malloc(sizeof(LDAPMod)); + attrs[i]->mod_op = LDAP_MOD_BVALUES; + attrs[i]->mod_type = a->a_type; + attrs[i]->mod_vals.modv_bvals = a->a_vals; + } + + ldap_add_s(lc->ld, e->e_dn, attrs); + for (--i; i>= 0; --i) + free(attrs[i]); + free(attrs); + return( ldap_back_op_result( lc, op )); +} diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h new file mode 100644 index 0000000000..f3063a8c0c --- /dev/null +++ b/servers/slapd/back-ldap/back-ldap.h @@ -0,0 +1,58 @@ +/* back-ldap.h - ldap backend header file */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#ifndef SLAPD_LDAP_H +#define SLAPD_LDAP_H + +#include "external.h" + +LDAP_BEGIN_DECL + +struct slap_conn; +struct slap_op; + +struct ldapconn { + struct ldapconn *next; + struct slap_conn *conn; + LDAP *ld; + int bound; +}; + +struct ldapinfo { + char *host; + int port; + char *suffix; + ldap_pvt_thread_mutex_t conn_mutex; + struct ldapconn *lcs; +}; + +struct ldapconn *ldap_back_getconn(struct ldapinfo *li, struct slap_conn *conn, + struct slap_op *op); +void ldap_back_dobind(struct ldapconn *lc, Operation *op); +int ldap_back_op_result(struct ldapconn *lc, Operation *op); +int back_ldap_LTX_init_module(int argc, char *argv[]); + +LDAP_END_DECL + +#endif diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c new file mode 100644 index 0000000000..45f9df5c1e --- /dev/null +++ b/servers/slapd/back-ldap/bind.c @@ -0,0 +1,122 @@ +/* bind.c - ldap backend bind function */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_bind( + Backend *be, + Connection *conn, + Operation *op, + char *dn, + int method, + char *mech, + struct berval *cred, + char **edn +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + + *edn = NULL; + + lc = ldap_back_getconn(li, conn, op); + if (!lc) + return( -1 ); + + if (ldap_bind_s(lc->ld, dn, cred->bv_val, method) != LDAP_SUCCESS) + return( ldap_back_op_result(lc, op) ); + + lc->bound = 1; + return( 0 ); +} + +struct ldapconn * +ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) +{ + struct ldapconn *lc; + LDAP *ld; + + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); + for (lc = li->lcs; lc; lc=lc->next) + if (lc->conn == conn) + break; + ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); + + /* Looks like we didn't get a bind. Open a new session... */ + if (!lc) { + ld = ldap_init(li->host, li->port); + if (!ld) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, "ldap_init failed", NULL, NULL ); + return( NULL ); + } + lc = (struct ldapconn *)ch_malloc(sizeof(struct ldapconn)); + lc->conn = conn; + lc->ld = ld; + lc->bound = 0; + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); + lc->next = li->lcs; + li->lcs = lc; + ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); + } + return( lc ); +} + +void +ldap_back_dobind(struct ldapconn *lc, Operation *op) +{ + if (lc->bound) + return; + + if (ldap_bind_s(lc->ld, lc->conn->c_cdn, NULL, LDAP_AUTH_SIMPLE) != + LDAP_SUCCESS) + ldap_back_op_result(lc, op); + else + lc->bound = 1; +} + +int +ldap_back_op_result(struct ldapconn *lc, Operation *op) +{ + int err; + char *msg; + char *match; + + ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, &err); + ldap_get_option(lc->ld, LDAP_OPT_ERROR_STRING, &msg); + ldap_get_option(lc->ld, LDAP_OPT_MATCHED_DN, &match); + send_ldap_result( lc->conn, op, err, match, msg, NULL, NULL ); + free(match); + free(msg); + return( (err==LDAP_SUCCESS) ? 0 : -1 ); +} diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c new file mode 100644 index 0000000000..206437d432 --- /dev/null +++ b/servers/slapd/back-ldap/compare.c @@ -0,0 +1,59 @@ +/* compare.c - ldap backend compare function */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_compare( + Backend *be, + Connection *conn, + Operation *op, + char *dn, + Ava *ava +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + + lc = ldap_back_getconn(li, conn, op); + if (!lc) + return( -1 ); + + if (!lc->bound) { + ldap_back_dobind(lc, op); + if (!lc->bound) + return( -1 ); + } + + ldap_compare_s( lc->ld, dn, ava->ava_type, ava->ava_value.bv_val ); + return( ldap_back_op_result( lc, op ) ); +} diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c new file mode 100644 index 0000000000..6326116f73 --- /dev/null +++ b/servers/slapd/back-ldap/config.c @@ -0,0 +1,74 @@ +/* config.c - ldap backend configuration file routine */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_db_config( + BackendDB *be, + const char *fname, + int lineno, + int argc, + char **argv +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + char *port; + + if ( li == NULL ) { + fprintf( stderr, "%s: line %d: ldap backend info is null!\n", + fname, lineno ); + return( 1 ); + } + + /* server address to query */ + if ( strcasecmp( argv[0], "server" ) == 0 ) { + if (argc != 2) { + fprintf( stderr, + "%s: line %d: missing address in \"server
\" line\n", + fname, lineno ); + return( 1 ); + } + port=strchr(argv[1],':'); + if (port) { + *port++ = '\0'; + li->port = atoi(port); + } + li->host = ch_strdup(argv[1]); + /* anything else */ + } else { + fprintf( stderr, +"%s: line %d: unknown directive \"%s\" in ldap database definition (ignored)\n", + fname, lineno, argv[0] ); + } + return 0; +} diff --git a/servers/slapd/back-ldap/delete.c b/servers/slapd/back-ldap/delete.c new file mode 100644 index 0000000000..b5e00cc2bb --- /dev/null +++ b/servers/slapd/back-ldap/delete.c @@ -0,0 +1,58 @@ +/* delete.c - ldap backend delete function */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_delete( + Backend *be, + Connection *conn, + Operation *op, + char *dn +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + + lc = ldap_back_getconn( li, conn, op ); + if (!lc) + return( -1 ); + + if (!lc->bound) { + ldap_back_dobind(lc, op); + if (!lc->bound) + return( -1 ); + } + + ldap_delete_s( lc->ld, dn ); + return( ldap_back_op_result( lc, op ) ); +} diff --git a/servers/slapd/back-ldap/external.h b/servers/slapd/back-ldap/external.h new file mode 100644 index 0000000000..58b5e77a07 --- /dev/null +++ b/servers/slapd/back-ldap/external.h @@ -0,0 +1,56 @@ +/* $OpenLDAP$ */ +#ifndef _LDAP_EXTERNAL_H +#define _LDAP_EXTERNAL_H + +LDAP_BEGIN_DECL + +extern int ldap_back_initialize LDAP_P(( BackendInfo *bi )); +extern int ldap_back_open LDAP_P(( BackendInfo *bi )); +extern int ldap_back_close LDAP_P(( BackendInfo *bi )); +extern int ldap_back_destroy LDAP_P(( BackendInfo *bi )); + +extern int ldap_back_db_init LDAP_P(( BackendDB *bd )); +extern int ldap_back_db_destroy LDAP_P(( BackendDB *bd )); + +extern int ldap_back_db_config LDAP_P(( BackendDB *bd, + const char *fname, int lineno, int argc, char **argv )); + +extern int ldap_back_bind LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, int method, char* mech, + struct berval *cred, char** edn )); + +extern int ldap_back_conn_destroy LDAP_P(( BackendDB *bd, + Connection *conn )); + +extern int ldap_back_search LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *base, int scope, int deref, int sizelimit, int timelimit, + Filter *filter, char *filterstr, char **attrs, int attrsonly )); + +extern int ldap_back_compare LDAP_P((BackendDB *bd, + Connection *conn, Operation *op, + char *dn, Ava *ava )); + +extern int ldap_back_modify LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, LDAPModList *ml )); + +extern int ldap_back_modrdn LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, char*newrdn, int deleteoldrdn, + char *newSuperior )); + +extern int ldap_back_add LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, Entry *e )); + +extern int ldap_back_delete LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, char *dn )); + +extern int ldap_back_abandon LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, int msgid )); + +LDAP_END_DECL + +#endif /* _LDAP_EXTERNAL_H */ + diff --git a/servers/slapd/back-ldap/init.c b/servers/slapd/back-ldap/init.c index ce0c020fa3..e1d80f76e6 100644 --- a/servers/slapd/back-ldap/init.c +++ b/servers/slapd/back-ldap/init.c @@ -1,4 +1,5 @@ /* init.c - initialize ldap backend */ +/* $OpenLDAP$ */ /* * Copyright 1999, Howard Chu, All rights reserved. diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c new file mode 100644 index 0000000000..c1b7df0337 --- /dev/null +++ b/servers/slapd/back-ldap/modify.c @@ -0,0 +1,71 @@ +/* modify.c - ldap backend modify function */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_modify( + Backend *be, + Connection *conn, + Operation *op, + char *dn, + LDAPModList *ml +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + LDAPMod **mods; + LDAPModList *m; + int i; + + lc = ldap_back_getconn(li, conn, op); + if (!lc) + return( -1 ); + + if (!lc->bound) { + ldap_back_dobind(lc, op); + if (!lc->bound) + return( -1 ); + } + + for (i=1, m=ml->ml_next; m; i++,m=m->ml_next) + ; + mods = (LDAPMod **)ch_malloc((i+1)*sizeof(LDAPMod *)); + mods[i] = 0; + + for (i=0, m=ml; m; i++, m=m->ml_next) + mods[i] = &m->ml_mod; + + ldap_modify_s( lc->ld, dn, mods ); + free(mods); + return( ldap_back_op_result( lc, op )); +} diff --git a/servers/slapd/back-ldap/modrdn.c b/servers/slapd/back-ldap/modrdn.c new file mode 100644 index 0000000000..b2c4cecd3b --- /dev/null +++ b/servers/slapd/back-ldap/modrdn.c @@ -0,0 +1,66 @@ +/* modrdn.c - ldap backend modrdn function */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_modrdn( + Backend *be, + Connection *conn, + Operation *op, + char *dn, + char *newrdn, + int deleteoldrdn, + char *newSuperior +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + + lc = ldap_back_getconn( li, conn, op ); + if (!lc) + return( -1 ); + + if (newSuperior) { + int version = LDAP_VERSION3; + ldap_set_option( lc->ld, LDAP_OPT_PROTOCOL_VERSION, &version); + } + + if (!lc->bound) { + ldap_back_dobind(lc, op); + if (!lc->bound) + return( -1 ); + } + + ldap_rename2_s( lc->ld, dn, newrdn, deleteoldrdn, newSuperior ); + return( ldap_back_op_result( lc, op ) ); +} diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c new file mode 100644 index 0000000000..8eb4a31f0b --- /dev/null +++ b/servers/slapd/back-ldap/search.c @@ -0,0 +1,179 @@ +/* search.c - ldap backend search function */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +static void ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc, + LDAPMessage *e, char **attrs, int attrsonly ); + +int +ldap_back_search( + Backend *be, + Connection *conn, + Operation *op, + char *base, + int scope, + int deref, + int size, + int time, + Filter *filter, + char *filterstr, + char **attrs, + int attrsonly +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc; + struct timeval tv; + LDAPMessage *res, *e; + int i, rc, msgid, sres = LDAP_SUCCESS; + char *match = NULL, *err = NULL; + + lc = ldap_back_getconn(li, conn, op); + if (!lc) + return( -1 ); + + if (deref != -1) + ldap_set_option( lc->ld, LDAP_OPT_DEREF, (void *)&deref); + if (time != -1) + ldap_set_option( lc->ld, LDAP_OPT_TIMELIMIT, (void *)&time); + if (size != -1) + ldap_set_option( lc->ld, LDAP_OPT_SIZELIMIT, (void *)&size); + if (!lc->bound) { + ldap_back_dobind(lc, op); + if (!lc->bound) + return( -1 ); + } + + if ((msgid = ldap_search(lc->ld, base, scope, filterstr, attrs, + attrsonly)) == -1) +fail: return( ldap_back_op_result(lc, op) ); + + /* We pull apart the ber result, stuff it into a slapd entry, and + * let send_search_entry stuff it back into ber format. Slow & ugly, + * but this is necessary for version matching, and for ACL processing. + */ + + for (i=0, rc=0; rc != -1; + rc = ldap_result(lc->ld, LDAP_RES_ANY, 0, &tv, &res)) { + int ab; + + /* check for abandon */ + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); + ab = op->o_abandon; + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + + if (ab) { + ldap_abandon(lc->ld, msgid); + } else if (rc == 0) { + tv.tv_sec = 0; + tv.tv_usec = 100000; + ldap_pvt_thread_yield(); + continue; + } else if (rc == LDAP_RES_SEARCH_ENTRY) { + e = ldap_first_entry(lc->ld,res); + ldap_send_entry(be, op, lc, e, attrs, attrsonly); + i++; + ldap_msgfree(res); + } else { + sres = ldap_result2error(lc->ld, res, 1); + ldap_get_option(lc->ld, LDAP_OPT_ERROR_STRING, &err); + ldap_get_option(lc->ld, LDAP_OPT_MATCHED_DN, &match); + rc = 0; + } + if (ab) + return (0); + else if (rc == 0) + break; + } + + if (rc == -1) + goto fail; + + send_search_result( conn, op, sres, + match, err, NULL, NULL, i ); + if (match) + free(match); + if (err) + free(err); + return( 0 ); +} + +static void +ldap_send_entry( + Backend *be, + Operation *op, + struct ldapconn *lc, + LDAPMessage *e, + char **attrs, + int attrsonly +) +{ + char *a; + Entry ent; + BerElement *ber = NULL; + Attribute *attr, **attrp; + struct berval *dummy = NULL; + + ent.e_dn = ldap_get_dn(lc->ld, e); + ent.e_ndn = ch_strdup( ent.e_dn); + (void) dn_normalize_case( ent.e_ndn ); + ent.e_id = 0; + ent.e_attrs = 0; + ent.e_private = 0; + attrp = &ent.e_attrs; + + for (a = ldap_first_attribute(lc->ld, e, &ber); a; + a = ldap_next_attribute(lc->ld, e, ber)) { + attr = (Attribute *)ch_malloc( sizeof(Attribute) ); + attr->a_next = 0; + attr->a_type = ch_strdup(a); + attr->a_syntax = attr_syntax(a); + attr->a_vals = ldap_get_values_len(lc->ld, e, a); + if (!attr->a_vals) + attr->a_vals = &dummy; + *attrp = attr; + attrp = &attr->a_next; + } + send_search_entry( be, lc->conn, op, &ent, attrs, attrsonly, NULL ); + for (;ent.e_attrs;) { + attr=ent.e_attrs; + ent.e_attrs = attr->a_next; + free(attr->a_type); + if (attr->a_vals != &dummy) + ber_bvecfree(attr->a_vals); + free(attr); + } + if (ber) + ber_free(ber,0); +} diff --git a/servers/slapd/back-ldap/unbind.c b/servers/slapd/back-ldap/unbind.c new file mode 100644 index 0000000000..ac1adcb740 --- /dev/null +++ b/servers/slapd/back-ldap/unbind.c @@ -0,0 +1,62 @@ +/* unbind.c - ldap backend unbind function */ +/* $OpenLDAP$ */ + +/* + * Copyright 1999, Howard Chu, All rights reserved. + * + * Permission is granted to anyone to use this software for any purpose + * on any computer system, and to alter it and redistribute it, subject + * to the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits should appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits should appear in the documentation. + * + * 4. This notice may not be removed or altered. + */ + +#include "portable.h" + +#include + +#include +#include + +#include "slap.h" +#include "back-ldap.h" + +int +ldap_back_conn_destroy( + Backend *be, + Connection *conn +) +{ + struct ldapinfo *li = (struct ldapinfo *) be->be_private; + struct ldapconn *lc, *lp; + + ldap_pvt_thread_mutex_lock( &li->conn_mutex ); + for (lc = li->lcs, lp = (struct ldapconn *)&li->lcs; lc; + lp=lc, lc=lc->next) + if (lc->conn == conn) { + lp->next = lc->next; + break; + } + ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); + + if (lc) { + if (lc->bound) + ldap_unbind(lc->ld); + free(lc); + } + + /* no response to unbind */ + + return 0; +} diff --git a/servers/slapd/back-ldbm/Makefile.in b/servers/slapd/back-ldbm/Makefile.in index 3a88ae1c3b..d6ce016904 100644 --- a/servers/slapd/back-ldbm/Makefile.in +++ b/servers/slapd/back-ldbm/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \ index.c id2children.c nextid.c abandon.c compare.c group.c \ modify.c modrdn.c delete.c init.c config.c bind.c attr.c \ diff --git a/servers/slapd/back-ldbm/abandon.c b/servers/slapd/back-ldbm/abandon.c index 4fe70427b5..27ace1a927 100644 --- a/servers/slapd/back-ldbm/abandon.c +++ b/servers/slapd/back-ldbm/abandon.c @@ -1,4 +1,5 @@ /* abandon.c - ldbm backend abandon routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 8775e29514..edeaf57a10 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -1,4 +1,5 @@ /* add.c - ldap ldbm back-end add routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -252,7 +253,7 @@ ldbm_back_add( if ( id2entry_add( be, e ) != 0 ) { Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0, 0, 0 ); - (void) dn2id_delete( be, e->e_ndn ); + (void) dn2id_delete( be, e->e_ndn, e->e_id ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL, NULL, NULL ); diff --git a/servers/slapd/back-ldbm/alias.c b/servers/slapd/back-ldbm/alias.c new file mode 100644 index 0000000000..ccc68804e3 --- /dev/null +++ b/servers/slapd/back-ldbm/alias.c @@ -0,0 +1,286 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include +#include +#include +#include "slap.h" +#include "back-ldbm.h" +#include "proto-back-ldbm.h" + + +static char* get_alias_dn( + Entry *e, + int *err, + char **errmsg ); + +static char* new_superior( + char *dn, + char *oldSup, + char *newSup ); + +static int dnlist_subordinate( + char** dnlist, + char *dn ); + +Entry *deref_internal_r( + Backend* be, + Entry* alias, + char* dn, + int* err, + Entry** matched, + char** text ) +{ + struct ldbminfo *li = (struct ldbminfo *) be->be_private; + Entry *entry; + Entry *sup; + unsigned depth; + char **dnlist; + + assert( ( alias != NULL && dn == NULL ) || ( alias == NULL && dn != NULL ) ); + + *matched = NULL; + *err = LDAP_SUCCESS; + *text = NULL; + + if( alias == NULL ) { + dn = ch_strdup( dn ); + entry = dn2entry_r( be, dn, &sup ); + + } else { + dn = ch_strdup( alias->e_ndn ); + entry = alias; + sup = NULL; + } + + dnlist = NULL; + charray_add( &dnlist, dn ); + + for( depth=0 ; ; depth++ ) { + if( entry != NULL ) { + Entry *newe; + char *aliasDN; + + /* have entry, may be an alias */ + + if( !is_entry_alias( entry ) ) { + /* entry is not an alias */ + break; + } + + /* entry is alias */ + if( depth > be->be_max_deref_depth ) { + *matched = entry; + entry = NULL; + *err = LDAP_ALIAS_DEREF_PROBLEM; + *text = "maximum deref depth exceeded"; + break; + } + + /* deref entry */ + aliasDN = get_alias_dn( entry, err, text ); + + if( aliasDN == NULL ) { + *matched = entry; + entry = NULL; + break; + } + + /* check if aliasDN is a subordinate of any DN in our list */ + if( dnlist_subordinate( dnlist, aliasDN ) ) { + *matched = entry; + entry = NULL; + *err = LDAP_ALIAS_PROBLEM; + *text = "circular alias"; + break; + } + + /* attempt to dereference alias */ + + newe = dn2entry_r( be, aliasDN, &sup ); + + if( newe != NULL ) { + free( dn ); + cache_return_entry_r(&li->li_cache, entry ); + entry = newe; + dn = ch_strdup( entry->e_ndn ); + charray_add( &dnlist, dn ); + continue; + + } + + if ( sup != NULL ) { + cache_return_entry_r(&li->li_cache, entry ); + entry = NULL; + continue; + } + + /* no newe and no superior, we're done */ + break; + + } else if( sup != NULL ) { + /* have superior, may be an alias */ + Entry *newe; + Entry *newSup; + char *supDN; + char *aliasDN; + + if( !is_entry_alias( sup ) ) { + /* entry is not an alias */ + *matched = sup; + sup = NULL; + break; + } + + /* entry is alias */ + if( depth > be->be_max_deref_depth ) { + *matched = sup; + entry = NULL; + *err = LDAP_ALIAS_DEREF_PROBLEM; + *text = "maximum deref depth exceeded"; + break; + } + + /* deref entry */ + supDN = get_alias_dn( sup, err, text ); + + if( supDN == NULL ) { + *matched = sup; + break; + } + + aliasDN = new_superior( dn, sup->e_ndn, supDN ); + + if( aliasDN == NULL ) { + free(aliasDN); + *matched = sup; + *err = LDAP_ALIAS_PROBLEM; + *text = "superior alias problem"; + break; + } + + /* check if aliasDN is a subordinate of any DN in our list */ + if( dnlist_subordinate( dnlist, aliasDN ) ) { + free(aliasDN); + *matched = entry; + entry = NULL; + *err = LDAP_ALIAS_PROBLEM; + *text = "subordinate circular alias"; + break; + } + + /* attempt to dereference alias */ + newe = dn2entry_r( be, aliasDN, &newSup ); + + if( newe != NULL ) { + free(aliasDN); + free( dn ); + cache_return_entry_r(&li->li_cache, sup ); + entry = newe; + dn = ch_strdup( entry->e_ndn ); + charray_add( &dnlist, dn ); + continue; + + } + + if ( newSup != NULL ) { + free( dn ); + cache_return_entry_r(&li->li_cache, sup ); + sup = newSup; + dn = aliasDN; + continue; + } + + break; + + } else { + /* no newe and no superior, we're done */ + break; + } + } + + free( dn ); + return entry; +} + + +static char* get_alias_dn( + Entry *e, + int *err, + char **errmsg ) +{ + Attribute *a = attr_find( e->e_attrs, "aliasedobjectname" ); + + if( a == NULL ) { + /* + * there was an aliasedobjectname defined but no data. + */ + *err = LDAP_ALIAS_PROBLEM; + *errmsg = "alias missing aliasedObjectName attribute"; + return NULL; + } + + /* + * aliasedObjectName should be SINGLE-VALUED with a single value. + */ + if ( a->a_vals[0] == NULL || a->a_vals[0]->bv_val == NULL ) { + /* + * there was an aliasedobjectname defined but no data. + */ + *err = LDAP_ALIAS_PROBLEM; + *errmsg = "alias missing aliasedObjectName value"; + return NULL; + } + + if( a->a_vals[1] != NULL ) { + *err = LDAP_ALIAS_PROBLEM; + *errmsg = "alias has multivalued aliasedObjectName"; + return NULL; + } + + return a->a_vals[0]->bv_val; +} + +char* new_superior( + char *dn, + char *oldSup, + char *newSup ) +{ + char *newDN; + size_t dnlen, olen, nlen; + assert( dn && oldSup && newSup ); + + dnlen = strlen( dn ); + olen = strlen( oldSup ); + nlen = strlen( newSup ); + + newDN = ch_malloc( dnlen - olen + nlen + 1 ); + + memcpy( newDN, dn, dnlen - olen ); + memcpy( &newDN[dnlen - olen], newSup, nlen ); + newDN[dnlen - olen + nlen] = '\0'; + + return newDN; +} + +static int dnlist_subordinate( + char** dnlist, + char *dn ) +{ + int i; + assert( dnlist ); + + for( i = 0; dnlist[i] != NULL; i++ ) { + if( dn_issuffix( dnlist[i], dn ) ) { + return 1; + } + } + + return 0; +} + diff --git a/servers/slapd/back-ldbm/attr.c b/servers/slapd/back-ldbm/attr.c index ea7f85da1b..37a5cf94b3 100644 --- a/servers/slapd/back-ldbm/attr.c +++ b/servers/slapd/back-ldbm/attr.c @@ -1,4 +1,5 @@ /* attr.c - backend routines for dealing with attributes */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -88,7 +89,7 @@ attr_masks( void attr_index_config( struct ldbminfo *li, - char *fname, + const char *fname, int lineno, int argc, char **argv, diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index 9a68e0e2d1..cf381da96f 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -1,4 +1,5 @@ /* back-ldbm.h - ldap ldbm back-end header file */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index 6a2efc8f0c..1880a8a8cc 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -1,4 +1,5 @@ /* bind.c - ldbm backend bind and unbind routines */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index 66ecb5ba9b..0ef36d7d34 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -1,4 +1,5 @@ /* cache.c - routines to maintain an in-core cache of entries */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -435,14 +436,14 @@ ID cache_find_entry_dn2id( Backend *be, Cache *cache, - char *dn + const char *dn ) { Entry e, *ep; ID id; int count = 0; - e.e_dn = dn; + e.e_dn = (char *) dn; e.e_ndn = ch_strdup( dn ); (void) dn_normalize_case( e.e_ndn ); diff --git a/servers/slapd/back-ldbm/close.c b/servers/slapd/back-ldbm/close.c index 37a5235780..9aa2ca4169 100644 --- a/servers/slapd/back-ldbm/close.c +++ b/servers/slapd/back-ldbm/close.c @@ -1,4 +1,5 @@ /* close.c - close ldbm backend */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index 278a806d6f..96932cecfc 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -1,4 +1,5 @@ /* compare.c - ldbm backend compare routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/config.c b/servers/slapd/back-ldbm/config.c index 80cabd6a47..ef06a4fcc7 100644 --- a/servers/slapd/back-ldbm/config.c +++ b/servers/slapd/back-ldbm/config.c @@ -1,4 +1,5 @@ /* config.c - ldbm backend configuration file routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -18,7 +19,7 @@ int ldbm_back_db_config( Backend *be, - char *fname, + const char *fname, int lineno, int argc, char **argv diff --git a/servers/slapd/back-ldbm/dbcache.c b/servers/slapd/back-ldbm/dbcache.c index 3bec93a529..eecf2c954b 100644 --- a/servers/slapd/back-ldbm/dbcache.c +++ b/servers/slapd/back-ldbm/dbcache.c @@ -1,4 +1,5 @@ /* ldbmcache.c - maintain a cache of open ldbm files */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -19,7 +20,6 @@ #include #endif -#include "ldap_defaults.h" #include "slap.h" #include "back-ldbm.h" diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 7db49948bb..eb3ed850e2 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -1,4 +1,5 @@ /* delete.c - ldbm backend delete routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -24,7 +25,7 @@ ldbm_back_delete( ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - Entry *matched = NULL; + Entry *matched; char *pdn = NULL; Entry *e, *p = NULL; int rootlock = 0; @@ -104,7 +105,7 @@ ldbm_back_delete( /* delete from parent's id2children entry */ if( (pdn = dn_parent( be, e->e_ndn )) != NULL ) { - if( (p = dn2entry_w( be, pdn, &matched )) == NULL) { + if( (p = dn2entry_w( be, pdn, NULL )) == NULL) { Debug( LDAP_DEBUG_TRACE, "<=- ldbm_back_delete: parent does not exist\n", 0, 0, 0); @@ -141,7 +142,7 @@ ldbm_back_delete( } /* delete from dn2id mapping */ - if ( dn2id_delete( be, e->e_ndn ) != 0 ) { + if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) { Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: operations error %s\n", dn, 0, 0); @@ -180,7 +181,5 @@ return_results:; /* free entry and writer lock */ cache_return_entry_w( &li->li_cache, e ); - if ( matched != NULL ) free(matched); - return rc; } diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index 2e1238ec9f..afa1c27de6 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -1,4 +1,5 @@ /* dn2id.c - routines to deal with the dn2id index */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -18,7 +19,7 @@ int dn2id_add( Backend *be, - char *dn, + const char *dn, ID id ) { @@ -28,6 +29,7 @@ dn2id_add( struct ldbminfo *li = (struct ldbminfo *) be->be_private; Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn, id, 0 ); + assert( id != NOID ); if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { @@ -87,7 +89,6 @@ dn2id_add( charray_free( subtree ); } - } ldbm_cache_close( be, db ); @@ -99,7 +100,7 @@ dn2id_add( ID dn2id( Backend *be, - char *dn + const char *dn ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; @@ -142,6 +143,8 @@ dn2id( (void) memcpy( (char *) &id, data.dptr, sizeof(ID) ); + assert( id != NOID ); + ldbm_datum_free( db->dbc_db, data ); Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld\n", id, 0, 0 ); @@ -151,7 +154,7 @@ dn2id( ID_BLOCK * dn2idl( Backend *be, - char *dn, + const char *dn, int prefix ) { @@ -187,14 +190,17 @@ dn2idl( int dn2id_delete( Backend *be, - char *dn + const char *dn, + ID id ) { DBCache *db; Datum key; int rc; - Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\" )\n", dn, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\", %ld )\n", dn, id, 0 ); + + assert( id != NOID ); if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { @@ -204,6 +210,44 @@ dn2id_delete( return( -1 ); } + + { + char *pdn = dn_parent( NULL, dn ); + + if( pdn != NULL ) { + ldbm_datum_init( key ); + key.dsize = strlen( pdn ) + 2; + key.dptr = ch_malloc( key.dsize ); + sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn ); + + (void) idl_delete_key( be, db, key, id ); + + free( key.dptr ); + free( pdn ); + } + } + + { + char **subtree = dn_subtree( NULL, dn ); + + if( subtree != NULL ) { + int i; + for( i=0; subtree[i] != NULL; i++ ) { + ldbm_datum_init( key ); + key.dsize = strlen( subtree[i] ) + 2; + key.dptr = ch_malloc( key.dsize ); + sprintf( key.dptr, "%c%s", + DN_SUBTREE_PREFIX, subtree[i] ); + + (void) idl_delete_key( be, db, key, id ); + + free( key.dptr ); + } + + charray_free( subtree ); + } + } + ldbm_datum_init( key ); key.dsize = strlen( dn ) + 2; @@ -228,12 +272,11 @@ dn2id_delete( Entry * dn2entry_rw( Backend *be, - char *dn, + const char *dn, Entry **matched, int rw ) { - struct ldbminfo *li = (struct ldbminfo *) be->be_private; ID id; Entry *e = NULL; char *pdn; diff --git a/servers/slapd/back-ldbm/entry.c b/servers/slapd/back-ldbm/entry.c index 503aab692a..7ff873b855 100644 --- a/servers/slapd/back-ldbm/entry.c +++ b/servers/slapd/back-ldbm/entry.c @@ -1,4 +1,5 @@ /* entry.c - ldbm backend entry_release routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/external.h b/servers/slapd/back-ldbm/external.h index c35e612d11..e1b8696db6 100644 --- a/servers/slapd/back-ldbm/external.h +++ b/servers/slapd/back-ldbm/external.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -19,7 +20,7 @@ extern int ldbm_back_db_close LDAP_P(( BackendDB *bd )); extern int ldbm_back_db_destroy LDAP_P(( BackendDB *bd )); extern int ldbm_back_db_config LDAP_P(( BackendDB *bd, - char *fname, int lineno, int argc, char **argv )); + const char *fname, int lineno, int argc, char **argv )); extern int ldbm_back_bind LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, @@ -57,8 +58,8 @@ extern int ldbm_back_abandon LDAP_P(( BackendDB *bd, Connection *conn, Operation *op, ber_int_t msgid )); extern int ldbm_back_group LDAP_P(( BackendDB *bd, - Entry *target, char* gr_ndn, char* op_ndn, - char* objectclassValue, char* groupattrName)); + Entry *target, const char* gr_ndn, const char* op_ndn, + const char* objectclassValue, const char* groupattrName)); /* hooks for slap tools */ diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index 1db64e4480..81deb55a60 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -1,4 +1,5 @@ /* filterindex.c - generate the list of candidate entries from a filter */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/group.c b/servers/slapd/back-ldbm/group.c index 252b584166..8dbe75922a 100644 --- a/servers/slapd/back-ldbm/group.c +++ b/servers/slapd/back-ldbm/group.c @@ -1,4 +1,5 @@ /* group.c - ldbm backend acl group routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -24,10 +25,10 @@ int ldbm_back_group( Backend *be, Entry *target, - char *gr_ndn, - char *op_ndn, - char *objectclassValue, - char *groupattrName + const char *gr_ndn, + const char *op_ndn, + const char *objectclassValue, + const char *groupattrName ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; @@ -104,7 +105,7 @@ ldbm_back_group( goto return_results; } - bv.bv_val = objectclassValue; + bv.bv_val = (char *) objectclassValue; bv.bv_len = strlen( bv.bv_val ); if (value_find(attr->a_vals, &bv, attr->a_syntax, 1) != 0) { @@ -125,7 +126,7 @@ ldbm_back_group( "<= ldbm_back_group: found objectClass %s and %s\n", objectclassValue, groupattrName, 0 ); - bv.bv_val = op_ndn; + bv.bv_val = (char *) op_ndn; bv.bv_len = strlen( op_ndn ); if( value_find( attr->a_vals, &bv, attr->a_syntax, 1) != 0 ) diff --git a/servers/slapd/back-ldbm/id2children.c b/servers/slapd/back-ldbm/id2children.c index 00d5bf6988..acbab8fd77 100644 --- a/servers/slapd/back-ldbm/id2children.c +++ b/servers/slapd/back-ldbm/id2children.c @@ -1,4 +1,5 @@ /* id2children.c - routines to deal with the id2children index */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/id2entry.c b/servers/slapd/back-ldbm/id2entry.c index 982e816d6b..53f52d85a5 100644 --- a/servers/slapd/back-ldbm/id2entry.c +++ b/servers/slapd/back-ldbm/id2entry.c @@ -1,4 +1,5 @@ /* id2entry.c - routines to deal with the id2entry index */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index 47c8a305cc..f528fa8665 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -1,4 +1,5 @@ /* idl.c - ldap id list handling routines */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -11,7 +12,6 @@ #include #include -#include "ldap_defaults.h" #include "slap.h" #include "back-ldbm.h" @@ -79,10 +79,11 @@ idl_fetch_one( return NULL; } - idl = idl_dup( (ID_BLOCK *) data.dptr); + idl = idl_dup((ID_BLOCK *) data.dptr); + ldbm_datum_free( db->dbc_db, data ); - return( idl ); + return idl; } @@ -470,7 +471,8 @@ idl_insert_key( rc = idl_change_first( be, db, key, idl, i, k2, tmp ); break; - case 2: /* id not inserted - already there */ + case 2: /* id not inserted - already there, do nothing */ + rc = 0; break; case 3: /* id not inserted - block is full */ @@ -491,7 +493,8 @@ idl_insert_key( Debug( LDAP_DEBUG_ANY, "idl_fetch_one (%s) returns NULL\n", k2.dptr, 0, 0 ); - break; + /* split the original block */ + goto split; } switch ( (rc = idl_insert( &tmp2, id, @@ -517,14 +520,19 @@ idl_insert_key( case 3: /* split the original block */ break; } + idl_free( tmp2 ); } +split: /* * must split the block, write both new blocks + update * and write the indirect header block. */ + rc = 0; /* optimistic */ + + /* count how many indirect blocks *//* XXX linear count XXX */ for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) ; /* NULL */ @@ -651,8 +659,8 @@ idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids ) } /* make a slot for the new id */ - SAFEMEMCPY( &ID_BLOCK_ID(*idl, i), &ID_BLOCK_ID(*idl, i+1), - ID_BLOCK_NIDS(*idl) - i ); + SAFEMEMCPY( &ID_BLOCK_ID(*idl, i+1), &ID_BLOCK_ID(*idl, i), + (ID_BLOCK_NIDS(*idl) - i) * sizeof(ID) ); ID_BLOCK_ID(*idl, i) = id; ID_BLOCK_NIDS(*idl)++; @@ -674,7 +682,7 @@ idl_delete_key ( ) { Datum data; - ID_BLOCK *idl, *tmp; + ID_BLOCK *idl; unsigned i; int j, nids; char *kstr; @@ -725,6 +733,7 @@ idl_delete_key ( for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) { + ID_BLOCK *tmp; ldbm_datum_init( data ); sprintf( kstr, "%c%ld%s", CONT_PREFIX, ID_BLOCK_ID(idl, j), key.dptr ); diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index b44ffab756..12db542582 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -1,4 +1,5 @@ /* index.c - routines for dealing with attribute indexes */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index ab29410fb6..d7b6345e9f 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -1,4 +1,5 @@ /* init.c - initialize ldbm backend */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/kerberos.c b/servers/slapd/back-ldbm/kerberos.c index c8e4a54a0a..7a80877240 100644 --- a/servers/slapd/back-ldbm/kerberos.c +++ b/servers/slapd/back-ldbm/kerberos.c @@ -1,4 +1,5 @@ /* kerberos.c - ldbm backend kerberos bind routines */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 267222b01c..770be8dbc2 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -1,4 +1,5 @@ /* modify.c - ldbm backend modify routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index fae002cec0..08300fbf68 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -1,4 +1,5 @@ /* modrdn.c - ldbm backend modrdn routine */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -46,13 +47,13 @@ ldbm_back_modrdn( char *p_dn = NULL, *p_ndn = NULL; char *new_dn = NULL, *new_ndn = NULL; Entry *e, *p = NULL; - Entry *matched = NULL; + Entry *matched; int rootlock = 0; int rc = -1; /* Added to support LDAP v2 correctly (deleteoldrdn thing) */ char *new_rdn_val = NULL; /* Val of new rdn */ char *new_rdn_type = NULL; /* Type of new rdn */ - char *old_rdn; /* Old rdn's attr type & val */ + char *old_rdn = NULL; /* Old rdn's attr type & val */ char *old_rdn_type = NULL; /* Type of old rdn attr. */ char *old_rdn_val = NULL; /* Old rdn attribute value */ /* Added to support newSuperior */ @@ -133,7 +134,7 @@ ldbm_back_modrdn( * children. */ - if( (p = dn2entry_w( be, p_ndn, &matched )) == NULL) { + if( (p = dn2entry_w( be, p_ndn, NULL )) == NULL) { Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0, 0, 0); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, @@ -195,7 +196,7 @@ ldbm_back_modrdn( /* newSuperior == entry being moved?, if so ==> ERROR */ /* Get Entry with dn=newSuperior. Does newSuperior exist? */ - if( (np = dn2entry_w( be, np_ndn, &matched )) == NULL) { + if( (np = dn2entry_w( be, np_ndn, NULL )) == NULL) { Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: newSup(ndn=%s) not here!\n", np_ndn, 0, 0); @@ -205,7 +206,7 @@ ldbm_back_modrdn( } Debug( LDAP_DEBUG_TRACE, - "ldbm_back_modrdn: wr to new parent OK np=%p, id=%d\n", + "ldbm_back_modrdn: wr to new parent OK np=%p, id=%ld\n", np, np->e_id, 0 ); /* check newSuperior for "children" acl */ @@ -261,44 +262,23 @@ ldbm_back_modrdn( Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n", new_ndn, 0, 0 ); - if (dn2id ( be, new_ndn ) != NOID) { - send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, - NULL, NULL, NULL, NULL ); - goto return_results; - } - - Debug( LDAP_DEBUG_TRACE, - "ldbm_back_modrdn: new ndn=%s does not exist\n", - new_ndn, 0, 0 ); - /* check for abandon */ ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); goto return_results; } - ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - - /* delete old one */ - if ( dn2id_delete( be, e->e_ndn ) != 0 ) { - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, NULL, NULL, NULL ); - goto return_results; - } - (void) cache_delete_entry( &li->li_cache, e ); - free( e->e_dn ); - free( e->e_ndn ); - e->e_dn = new_dn; - e->e_ndn = new_ndn; - - /* add new one */ - if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) { - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + if (dn2id ( be, new_ndn ) != NOID) { + send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, NULL, NULL, NULL, NULL ); goto return_results; } + Debug( LDAP_DEBUG_TRACE, + "ldbm_back_modrdn: new ndn=%s does not exist\n", + new_ndn, 0, 0 ); /* Get attribute type and attribute value of our new rdn, we will * need to add that to our new entry @@ -438,12 +418,44 @@ ldbm_back_modrdn( } #endif + /* check for abandon */ + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); + if ( op->o_abandon ) { + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + goto return_results; + } + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + + /* delete old one */ + if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + } + + (void) cache_delete_entry( &li->li_cache, e ); + + /* XXX: there is no going back! */ + + free( e->e_dn ); + free( e->e_ndn ); + e->e_dn = new_dn; + e->e_ndn = new_ndn; + new_dn = NULL; + new_ndn = NULL; + + /* add new one */ + if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + goto return_results; + } + /* modify memory copy of entry */ if ( ldbm_modify_internal( be, conn, op, dn, &mod[0], e ) != 0 ) { goto return_results; - } (void) cache_update_entry( &li->li_cache, e ); @@ -457,28 +469,20 @@ ldbm_back_modrdn( entry_free( e ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL, NULL, NULL ); - goto return_results_after; + goto return_results; } send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL ); rc = 0; - goto return_results_after; return_results: if( new_dn != NULL ) free( new_dn ); if( new_ndn != NULL ) free( new_ndn ); -return_results_after: - /* NOTE: - * new_dn and new_ndn are not deallocated because they are used by - * the cache entry. - */ if( p_dn != NULL ) free( p_dn ); if( p_ndn != NULL ) free( p_ndn ); - if( matched != NULL ) free( matched ); - /* LDAP v2 supporting correct attribute handling. */ if( new_rdn_type != NULL ) free(new_rdn_type); if( new_rdn_val != NULL ) free(new_rdn_val); diff --git a/servers/slapd/back-ldbm/nextid.c b/servers/slapd/back-ldbm/nextid.c index 7287b3c5ab..ebe6f38971 100644 --- a/servers/slapd/back-ldbm/nextid.c +++ b/servers/slapd/back-ldbm/nextid.c @@ -1,4 +1,5 @@ /* nextid.c - keep track of the next id to be given out */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -21,7 +22,6 @@ static ID next_id_read( Backend *be ) { - struct ldbminfo *li = (struct ldbminfo *) be->be_private; ID id = NOID; Datum key, data; DBCache *db; diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index 90ea6281d2..1b466f4eb6 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -34,8 +35,9 @@ Entry *deref_internal_r LDAP_P(( void attr_masks LDAP_P(( struct ldbminfo *li, char *type, int *indexmask, int *syntaxmask )); -void attr_index_config LDAP_P(( struct ldbminfo *li, char *fname, int lineno, - int argc, char **argv, int init )); +void attr_index_config LDAP_P(( struct ldbminfo *li, + const char *fname, int lineno, + int argc, char **argv, int init )); void attr_index_destroy LDAP_P(( Avlnode *tree )); /* @@ -48,7 +50,7 @@ void cache_return_entry_rw LDAP_P(( Cache *cache, Entry *e, int rw )); #define cache_return_entry_r(c, e) cache_return_entry_rw((c), (e), 0) #define cache_return_entry_w(c, e) cache_return_entry_rw((c), (e), 1) -ID cache_find_entry_dn2id LDAP_P(( Backend *be, Cache *cache, char *dn )); +ID cache_find_entry_dn2id LDAP_P(( Backend *be, Cache *cache, const char *dn )); Entry * cache_find_entry_id LDAP_P(( Cache *cache, ID id, int rw )); int cache_delete_entry LDAP_P(( Cache *cache, Entry *e )); void cache_release_all LDAP_P(( Cache *cache )); @@ -70,12 +72,12 @@ int ldbm_cache_delete LDAP_P(( DBCache *db, Datum key )); * dn2id.c */ -int dn2id_add LDAP_P(( Backend *be, char *dn, ID id )); -ID dn2id LDAP_P(( Backend *be, char *dn )); -ID_BLOCK *dn2idl LDAP_P(( Backend *be, char *dn, int prefix )); -int dn2id_delete LDAP_P(( Backend *be, char *dn )); +int dn2id_add LDAP_P(( Backend *be, const char *dn, ID id )); +ID dn2id LDAP_P(( Backend *be, const char *dn )); +ID_BLOCK *dn2idl LDAP_P(( Backend *be, const char *dn, int prefix )); +int dn2id_delete LDAP_P(( Backend *be, const char *dn, ID id )); -Entry * dn2entry_rw LDAP_P(( Backend *be, char *dn, Entry **matched, int rw )); +Entry * dn2entry_rw LDAP_P(( Backend *be, const char *dn, Entry **matched, int rw )); #define dn2entry_r(be, dn, m) dn2entry_rw((be), (dn), (m), 0) #define dn2entry_w(be, dn, m) dn2entry_rw((be), (dn), (m), 1) diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 32028a6544..2858e24961 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -1,4 +1,5 @@ /* search.c - ldbm backend search function */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -317,7 +318,8 @@ loop_continue: rc = 0; done: - idl_free( candidates ); + if( candidates != NULL ) + idl_free( candidates ); ber_bvecfree( v2refs ); if( realbase ) free( realbase ); @@ -352,7 +354,6 @@ search_candidates( int manageDSAit ) { - struct ldbminfo *li = (struct ldbminfo *) be->be_private; ID_BLOCK *candidates; Filter *f, *rf, *af, *lf; diff --git a/servers/slapd/back-ldbm/startup.c b/servers/slapd/back-ldbm/startup.c index ec4c9faf1b..8137e0bd1b 100644 --- a/servers/slapd/back-ldbm/startup.c +++ b/servers/slapd/back-ldbm/startup.c @@ -1,4 +1,5 @@ /* startup.c - startup ldbm backend */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -12,7 +13,6 @@ #include #include -#include "ldap_defaults.h" #include "slap.h" #include "back-ldbm.h" @@ -49,7 +49,7 @@ ldbm_back_startup( #else struct ldbminfo *li = (struct ldbminfo *) be->be_private; DB_ENV *dbEnv = &li->li_db_env; - int envFlags = DB_CREATE | DB_THREAD; + u_int32_t envFlags = DB_CREATE | DB_THREAD; int err = 0; char *home; diff --git a/servers/slapd/back-ldbm/tools.c b/servers/slapd/back-ldbm/tools.c index 889be2508e..840449e473 100644 --- a/servers/slapd/back-ldbm/tools.c +++ b/servers/slapd/back-ldbm/tools.c @@ -1,4 +1,5 @@ /* tools.c - tools for slap tools */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -184,7 +185,7 @@ ID ldbm_tool_entry_put( rc = ldbm_cache_store( id2entry, key, data, LDBM_REPLACE ); if( rc != 0 ) { - (void) dn2id_delete( be, e->e_ndn ); + (void) dn2id_delete( be, e->e_ndn, e->e_id ); return NOID; } diff --git a/servers/slapd/back-ldbm/unbind.c b/servers/slapd/back-ldbm/unbind.c index abf7fdf1c2..69538da67b 100644 --- a/servers/slapd/back-ldbm/unbind.c +++ b/servers/slapd/back-ldbm/unbind.c @@ -1,4 +1,5 @@ /* unbind.c - handle an ldap unbind operation */ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file diff --git a/servers/slapd/back-passwd/Makefile.in b/servers/slapd/back-passwd/Makefile.in index cc329172e7..090ff008a0 100644 --- a/servers/slapd/back-passwd/Makefile.in +++ b/servers/slapd/back-passwd/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + SRCS = search.c config.c init.c OBJS = search.lo config.lo init.lo diff --git a/servers/slapd/back-passwd/config.c b/servers/slapd/back-passwd/config.c index 5a26ff0fb6..d976856089 100644 --- a/servers/slapd/back-passwd/config.c +++ b/servers/slapd/back-passwd/config.c @@ -1,16 +1,21 @@ /* config.c - passwd backend configuration file routine */ +/* $OpenLDAP$ */ -#include -#include -#include -#include -#include #include "portable.h" + +#include + +#include +#include +#include + #include "slap.h" +#include "external.h" -passwd_back_config( - Backend *be, - char *fname, +int +passwd_back_db_config( + BackendDB *be, + const char *fname, int lineno, int argc, char **argv @@ -23,9 +28,9 @@ passwd_back_config( fprintf( stderr, "%s: line %d: missing filename in \"file \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } - be->be_private = strdup( argv[1] ); + be->be_private = ch_strdup( argv[1] ); #else /* HAVE_SETPWFILE */ fprintf( stderr, "%s: line %d: ignoring \"file\" option (not supported on this platform)\n", @@ -38,4 +43,6 @@ passwd_back_config( "%s: line %d: unknown directive \"%s\" in passwd database definition (ignored)\n", fname, lineno, argv[0] ); } + + return( 0 ); } diff --git a/servers/slapd/back-passwd/external.h b/servers/slapd/back-passwd/external.h new file mode 100644 index 0000000000..92dd26e95d --- /dev/null +++ b/servers/slapd/back-passwd/external.h @@ -0,0 +1,20 @@ +/* $OpenLDAP$ */ +#ifndef _PASSWD_EXTERNAL_H +#define _PASSWD_EXTERNAL_H + +LDAP_BEGIN_DECL + +extern int passwd_back_initialize LDAP_P(( BackendInfo *bi )); + +extern int passwd_back_search LDAP_P(( BackendDB *be, + Connection *c, Operation *o, + char *base, int scope, int deref, int slimit, int tlimit, + Filter *f, char *filterstr, char **attrs, int attrsonly)); + +extern int passwd_back_db_config LDAP_P((BackendDB *bd, + const char *fname, int lineno, int argc, char **argv )); + +LDAP_END_DECL + +#endif /* _PASSWD_EXTERNAL_H */ + diff --git a/servers/slapd/back-passwd/init.c b/servers/slapd/back-passwd/init.c index ea500d7b3c..609231dba4 100644 --- a/servers/slapd/back-passwd/init.c +++ b/servers/slapd/back-passwd/init.c @@ -1,4 +1,5 @@ /* init.c - initialize passwd backend */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 11c1d8e719..68af4b3fa4 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -1,18 +1,25 @@ /* search.c - /etc/passwd backend search function */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include -#include + +#include +#include +#include +#include + #include -#include "portable.h" -#include "slap.h" -extern time_t currenttime; -extern pthread_mutex_t currenttime_mutex; +#include "slap.h" +#include "external.h" +#include -static Entry *pw2entry(); +static Entry *pw2entry( + Backend *be, + struct passwd *pw, + char *rdn); int passwd_back_search( @@ -35,87 +42,184 @@ passwd_back_search( char *s; time_t stoptime; + int sent = 0; + int err = LDAP_SUCCESS; + + char *rdn = NULL; + char *parent = NULL; + char *matched = NULL; + char *user = NULL; + tlimit = (tlimit > be->be_timelimit || tlimit < 1) ? be->be_timelimit : tlimit; stoptime = op->o_time + tlimit; slimit = (slimit > be->be_sizelimit || slimit < 1) ? be->be_sizelimit : slimit; + endpwent(); + #ifdef HAVE_SETPWFILE if ( be->be_private != NULL ) { - endpwent(); (void) setpwfile( (char *) be->be_private ); } #endif /* HAVE_SETPWFILE */ - if ( scope == LDAP_SCOPE_BASE ) { - if ( (s = strchr( base, '@' )) != NULL ) { - *s = '\0'; - } + /* Handle a query for the base of this backend */ + if ( be_issuffix( be, base ) ) { + struct berval val, *vals[2]; - if ( (pw = getpwnam( base )) == NULL ) { - send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, - s != NULL ? s + 1 : NULL, NULL ); - return( -1 ); - } + vals[0] = &val; + vals[1] = NULL; - e = pw2entry( be, pw ); - if ( test_filter( be, conn, op, e, filter ) == 0 ) { - send_search_entry( be, conn, op, e, attrs, attrsonly ); + matched = ch_strdup( base ); + + if( scope != LDAP_SCOPE_ONELEVEL ) { + /* Create an entry corresponding to the base DN */ + e = (Entry *) ch_calloc(1, sizeof(Entry)); + e->e_attrs = NULL; + e->e_dn = ch_strdup( base ); + + /* Use the first attribute of the DN + * as an attribute within the entry itself. + */ + rdn = dn_rdn(NULL, base); + + if( rdn == NULL || (s = strchr(rdn, '=')) == NULL ) { + err = LDAP_INVALID_DN_SYNTAX; + goto done; + } + + val.bv_val = rdn_attr_value(rdn); + val.bv_len = strlen( val.bv_val ); + attr_merge( e, rdn_attr_type(rdn), vals ); + + free(rdn); + rdn = NULL; + + /* Every entry needs an objectclass. We don't really + * know if our hardcoded choice here agrees with the + * DN that was configured for this backend, but it's + * better than nothing. + * + * should be a configuratable item + */ + val.bv_val = "organizationalUnit"; + val.bv_len = strlen( val.bv_val ); + attr_merge( e, "objectClass", vals ); + + if ( test_filter( be, conn, op, e, filter ) == 0 ) { + send_search_entry( be, conn, op, + e, attrs, attrsonly, NULL ); + sent++; + } } - entry_free( e ); - send_ldap_result( conn, op, LDAP_SUCCESS, "", "" ); + if ( scope != LDAP_SCOPE_BASE ) { + /* check all our "children" */ - return( 0 ); - } + for ( pw = getpwent(); pw != NULL; pw = getpwent() ) { + /* check for abandon */ + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); + if ( op->o_abandon ) { + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + endpwent(); + return( -1 ); + } + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); + + /* check time limit */ + if ( slap_get_time() > stoptime ) { + send_ldap_result( conn, op, LDAP_TIMELIMIT_EXCEEDED, + NULL, NULL, NULL, NULL ); + endpwent(); + return( 0 ); + } + + e = pw2entry( be, pw, NULL ); + + if ( test_filter( be, conn, op, e, filter ) == 0 ) { + /* check size limit */ + if ( --slimit == -1 ) { + send_ldap_result( conn, op, LDAP_SIZELIMIT_EXCEEDED, + NULL, NULL, NULL, NULL ); + endpwent(); + return( 0 ); + } - for ( pw = getpwent(); pw != NULL; pw = getpwent() ) { - /* check for abandon */ - pthread_mutex_lock( &op->o_abandonmutex ); - if ( op->o_abandon ) { - pthread_mutex_unlock( &op->o_abandonmutex ); + send_search_entry( be, conn, op, + e, attrs, attrsonly, NULL ); + sent++; + } + + entry_free( e ); + } endpwent(); - return( -1 ); } - pthread_mutex_unlock( &op->o_abandonmutex ); - /* check size limit */ - if ( --slimit == -1 ) { - send_ldap_result( conn, op, LDAP_SIZELIMIT_EXCEEDED, - NULL, NULL ); - endpwent(); - return( 0 ); + } else { + parent = dn_parent( be, base ); + + /* This backend is only one layer deep. Don't answer requests for + * anything deeper than that. + */ + if( !be_issuffix( be, parent ) ) { + int i; + for( i=0; be->be_suffix[i] != NULL; i++ ) { + if( dn_issuffix( base, be->be_suffix[i] ) ) { + matched = ch_strdup( be->be_suffix[i] ); + break; + } + } + err = LDAP_NO_SUCH_OBJECT; + goto done; } - /* check time limit */ - pthread_mutex_lock( ¤ttime_mutex ); - time( ¤ttime ); - if ( currenttime > stoptime ) { - pthread_mutex_unlock( ¤ttime_mutex ); - send_ldap_result( conn, op, LDAP_TIMELIMIT_EXCEEDED, - NULL, NULL ); - endpwent(); - return( 0 ); + if( scope == LDAP_SCOPE_ONELEVEL ) { + goto done; + } + + rdn = dn_rdn( NULL, base ); + + if ( (user = rdn_attr_value(rdn)) == NULL) { + err = LDAP_OPERATIONS_ERROR; + goto done; } - pthread_mutex_unlock( ¤ttime_mutex ); - e = pw2entry( be, pw ); + user = ldap_pvt_str2lower( user ); + + if ( (pw = getpwnam( user )) == NULL ) { + matched = parent; + parent = NULL; + err = LDAP_NO_SUCH_OBJECT; + goto done; + } + + e = pw2entry( be, pw, rdn ); if ( test_filter( be, conn, op, e, filter ) == 0 ) { - send_search_entry( be, conn, op, e, attrs, attrsonly ); + send_search_entry( be, conn, op, + e, attrs, attrsonly, NULL ); + sent++; } entry_free( e ); } - endpwent(); - send_ldap_result( conn, op, LDAP_SUCCESS, "", "" ); + +done: + send_ldap_result( conn, op, + err, err == LDAP_NO_SUCH_OBJECT ? matched : NULL, NULL, + NULL, NULL ); + + if( matched != NULL ) free( matched ); + if( parent != NULL ) free( parent ); + if( rdn != NULL ) free( rdn ); + if( user != NULL ) free( user ); return( 0 ); } static Entry * -pw2entry( Backend *be, struct passwd *pw ) +pw2entry( Backend *be, struct passwd *pw, char *rdn ) { Entry *e; char buf[256]; @@ -126,28 +230,69 @@ pw2entry( Backend *be, struct passwd *pw ) vals[1] = NULL; /* - * from pw we get pw_name and make it uid and cn and sn and - * we get pw_gecos and make it cn and we give it an objectclass - * of person. + * from pw we get pw_name and make it cn + * give it an objectclass of person. */ e = (Entry *) ch_calloc( 1, sizeof(Entry) ); e->e_attrs = NULL; - sprintf( buf, "%s@%s", pw->pw_name, be->be_suffix[0] ); - e->e_dn = strdup( buf ); + /* rdn attribute type should be a configuratable item */ + sprintf( buf, "uid=%s,%s", pw->pw_name, be->be_suffix[0] ); + e->e_dn = ch_strdup( buf ); + e->e_ndn = ch_strdup( buf ); + (void) dn_normalize_case( e->e_ndn ); val.bv_val = pw->pw_name; val.bv_len = strlen( pw->pw_name ); - attr_merge( e, "cn", vals ); - attr_merge( e, "sn", vals ); - attr_merge( e, "uid", vals ); - val.bv_val = pw->pw_gecos; - val.bv_len = strlen( pw->pw_gecos ); - attr_merge( e, "cn", vals ); + attr_merge( e, "uid", vals ); /* required by uidObject */ + attr_merge( e, "cn", vals ); /* required by person */ + attr_merge( e, "sn", vals ); /* required by person */ + +#ifdef HAVE_PW_GECOS + /* + * if gecos is present, add it as a cn. first process it + * according to standard BSD usage. If the processed cn has + * a space, use the tail as the surname. + */ + if (pw->pw_gecos[0]) { + char *s; + + val.bv_val = pw->pw_gecos; + val.bv_len = strlen(val.bv_val); + attr_merge(e, "description", vals); + + s = strchr(val.bv_val, ','); + if (s) + *s = '\0'; + s = strchr(val.bv_val, '&'); + if (s) { + int i = s - val.bv_val; + strncpy(buf, val.bv_val, i); + s = buf+i; + strcpy(s, pw->pw_name); + *s = TOUPPER(*s); + strcat(s, val.bv_val+i+1); + val.bv_val = buf; + } + val.bv_len = strlen(val.bv_val); + if ( strcmp( val.bv_val, pw->pw_name )) + attr_merge( e, "cn", vals ); + if ( (s=strrchr(val.bv_val, ' '))) { + val.bv_val = s + 1; + val.bv_len = strlen(val.bv_val); + attr_merge(e, "sn", vals); + } + } +#endif + + /* objectclasses should be configuratable items */ val.bv_val = "person"; val.bv_len = strlen( val.bv_val ); attr_merge( e, "objectclass", vals ); + val.bv_val = "uidObject"; + val.bv_len = strlen( val.bv_val ); + attr_merge( e, "objectclass", vals ); return( e ); } diff --git a/servers/slapd/back-perl/Makefile.in b/servers/slapd/back-perl/Makefile.in index ac304be956..aaaf32df41 100644 --- a/servers/slapd/back-perl/Makefile.in +++ b/servers/slapd/back-perl/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ########################################################################### # # Copyright 1999, John C. Quillan, All rights reserved. diff --git a/servers/slapd/back-perl/add.c b/servers/slapd/back-perl/add.c index ed30475ac9..707b140f94 100644 --- a/servers/slapd/back-perl/add.c +++ b/servers/slapd/back-perl/add.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1999, John C. Quillan, All rights reserved. * diff --git a/servers/slapd/back-perl/bind.c b/servers/slapd/back-perl/bind.c new file mode 100644 index 0000000000..9d20afd783 --- /dev/null +++ b/servers/slapd/back-perl/bind.c @@ -0,0 +1,82 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1999, John C. Quillan, All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" +/* init.c - initialize shell backend */ + +#include +/* #include + #include +*/ + +#include +#include + +#include "slap.h" +#include "perl_back.h" + + +/********************************************************** + * + * Bind + * + **********************************************************/ +int +perl_back_bind( + Backend *be, + Connection *conn, + Operation *op, + char *dn, + int method, + char *mech, + struct berval *cred, + char** edn +) +{ + int return_code; + int count; + + PerlBackend *perl_back = (PerlBackend *) be->be_private; + + *edn = NULL; + + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); + + { + dSP; ENTER; SAVETMPS; + + PUSHMARK(sp); + XPUSHs( perl_back->pb_obj_ref ); + XPUSHs(sv_2mortal(newSVpv( dn , 0))); + XPUSHs(sv_2mortal(newSVpv( cred->bv_val , cred->bv_len))); + PUTBACK; + + count = perl_call_method("bind", G_SCALAR); + + SPAGAIN; + + if (count != 1) { + croak("Big trouble in back_search\n"); + } + + return_code = POPi; + + + PUTBACK; FREETMPS; LEAVE; + } + + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); + + Debug( LDAP_DEBUG_ANY, "Perl BIND\n", 0, 0, 0 ); + + return ( return_code ); +} + + diff --git a/servers/slapd/back-perl/close.c b/servers/slapd/back-perl/close.c new file mode 100644 index 0000000000..79b62afe2c --- /dev/null +++ b/servers/slapd/back-perl/close.c @@ -0,0 +1,65 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1999, John C. Quillan, All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" +/* init.c - initialize shell backend */ + +#include +/* #include + #include +*/ + +#include +#include + +#include "slap.h" +#include "perl_back.h" + +/********************************************************** + * + * Close + * + **********************************************************/ + +int +perl_back_close( + BackendInfo *bd +) +{ + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); + + perl_destruct(perl_interpreter); + + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); + + return 0; +} + +int +perl_back_destroy( + BackendInfo *bd +) +{ + perl_free(perl_interpreter); + perl_interpreter = NULL; + + ldap_pvt_thread_mutex_destroy( &perl_interpreter_mutex ); + + return 0; +} + +int +perl_back_db_destroy( + BackendDB *be +) +{ + free( be->be_private ); + be->be_private = NULL; +} diff --git a/servers/slapd/back-perl/compare.c b/servers/slapd/back-perl/compare.c new file mode 100644 index 0000000000..4c9f3904ef --- /dev/null +++ b/servers/slapd/back-perl/compare.c @@ -0,0 +1,85 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1999, John C. Quillan, All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + +#include +/* #include + #include +*/ + +#include +#include + +#include "slap.h" +#include "perl_back.h" + +/********************************************************** + * + * Compare + * + **********************************************************/ + +perl_back_compare( + Backend *be, + Connection *conn, + Operation *op, + char *dn, + Ava *ava +) +{ + int return_code; + int count; + + PerlBackend *perl_back = (PerlBackend *)be->be_private; + + send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, + NULL, "not yet implemented", NULL, NULL ); + +#ifdef notdef + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); + + { + dSP; ENTER; SAVETMPS; + + PUSHMARK(sp); + XPUSHs( perl_back->pb_obj_ref ); + XPUSHs(sv_2mortal(newSVpv( dn , 0))); + /* XPUSHs(sv_2mortal(newSVpv( cred->bv_val , cred->bv_len))); */ + PUTBACK; + + count = perl_call_method("bind", G_SCALAR); + + SPAGAIN; + + if (count != 1) { + croak("Big trouble in back_search\n"); + } + + return_code = POPi; + + PUTBACK; FREETMPS; LEAVE; + } + + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); + + if( return_code != 0 ) { + send_ldap_result( conn, op, LDAP_COMPARE_TRUE, NULL, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_COMPARE_FALSE, NULL, NULL ); + } +#endif + + Debug( LDAP_DEBUG_ANY, "Here BIND\n", 0, 0, 0 ); + + return (0); +} + diff --git a/servers/slapd/back-perl/config.c b/servers/slapd/back-perl/config.c index 83067e5c24..f68a0a1282 100644 --- a/servers/slapd/back-perl/config.c +++ b/servers/slapd/back-perl/config.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1999, John C. Quillan, All rights reserved. * @@ -30,7 +31,7 @@ int perl_back_db_config( BackendDB *be, - char *fname, + const char *fname, int lineno, int argc, char **argv diff --git a/servers/slapd/back-perl/delete.c b/servers/slapd/back-perl/delete.c new file mode 100644 index 0000000000..19d2346f9a --- /dev/null +++ b/servers/slapd/back-perl/delete.c @@ -0,0 +1,74 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1999, John C. Quillan, All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + +#include +/* #include +#include +*/ + +#include +#include + +#include "slap.h" +#include "perl_back.h" + +perl_back_delete( + Backend *be, + Connection *conn, + Operation *op, + char *dn +) +{ + int len; + int count; + int return_code; + + PerlBackend *perl_back = (PerlBackend *) be->be_private; + + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); + + { + dSP; ENTER; SAVETMPS; + + PUSHMARK(sp); + XPUSHs( perl_back->pb_obj_ref ); + XPUSHs(sv_2mortal(newSVpv( dn , 0 ))); + + PUTBACK; + + count = perl_call_method("delete", G_SCALAR); + + SPAGAIN; + + if (count != 1) { + croak("Big trouble in perl-back_delete\n"); + } + + return_code = POPi; + + PUTBACK; FREETMPS; LEAVE; + } + + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); + + if( return_code != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + } + + Debug( LDAP_DEBUG_ANY, "Here DELETE\n", 0, 0, 0 ); + return( 0 ); +} diff --git a/servers/slapd/back-perl/external.h b/servers/slapd/back-perl/external.h new file mode 100644 index 0000000000..d41fb13ea5 --- /dev/null +++ b/servers/slapd/back-perl/external.h @@ -0,0 +1,53 @@ +/* $OpenLDAP$ */ +#ifndef _PERL_EXTERNAL_H +#define _PERL_EXTERNAL_H + +LDAP_BEGIN_DECL + +extern int perl_back_initialize LDAP_P(( BackendInfo *bi )); +extern int perl_back_open LDAP_P(( BackendInfo *bi )); +extern int perl_back_close LDAP_P(( BackendInfo *bi )); +extern int perl_back_destroy LDAP_P(( BackendInfo *bi )); + +extern int perl_back_db_init LDAP_P(( BackendDB *bd )); +extern int perl_back_db_destroy LDAP_P(( BackendDB *bd )); + +extern int perl_back_db_config LDAP_P(( BackendDB *bd, + const char *fname, int lineno, int argc, char **argv )); + +extern int perl_back_bind LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, int method, char* mech, + struct berval *cred, char** edn )); + +extern int perl_back_unbind LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op )); + +extern int perl_back_search LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *base, int scope, int deref, int sizelimit, int timelimit, + Filter *filter, char *filterstr, char **attrs, int attrsonly )); + +extern int perl_back_compare LDAP_P((BackendDB *bd, + Connection *conn, Operation *op, + char *dn, Ava *ava )); + +extern int perl_back_modify LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, LDAPModList *ml )); + +extern int perl_back_modrdn LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, char*newrdn, int deleteoldrdn, + char *newSuperior )); + +extern int perl_back_add LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, Entry *e )); + +extern int perl_back_delete LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, char *dn )); + +LDAP_END_DECL + +#endif /* _PERL_EXTERNAL_H */ + diff --git a/servers/slapd/back-perl/init.c b/servers/slapd/back-perl/init.c index c9f30913af..e215acd2e6 100644 --- a/servers/slapd/back-perl/init.c +++ b/servers/slapd/back-perl/init.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1999, John C. Quillan, All rights reserved. * diff --git a/servers/slapd/back-perl/modify.c b/servers/slapd/back-perl/modify.c new file mode 100644 index 0000000000..028b42e136 --- /dev/null +++ b/servers/slapd/back-perl/modify.c @@ -0,0 +1,108 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1999, John C. Quillan, All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + +#include +/* #include + #include +*/ + +#include +#include + +#include "slap.h" +#include "perl_back.h" + +int +perl_back_modify( + Backend *be, + Connection *conn, + Operation *op, + char *dn, + LDAPModList *modlist +) +{ + char test[500]; + int return_code; + int count; + int i; + int err = 0; + char *matched = NULL, *info = NULL; + + PerlBackend *perl_back = (PerlBackend *)be->be_private; + + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); + + { + dSP; ENTER; SAVETMPS; + + PUSHMARK(sp); + XPUSHs( perl_back->pb_obj_ref ); + XPUSHs(sv_2mortal(newSVpv( dn , 0))); + + for (; modlist != NULL; modlist = modlist->ml_next ) { + LDAPMod *mods = &modlist->ml_mod; + + switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) { + case LDAP_MOD_ADD: + XPUSHs(sv_2mortal(newSVpv("ADD", 0 ))); + break; + + case LDAP_MOD_DELETE: + XPUSHs(sv_2mortal(newSVpv("DELETE", 0 ))); + break; + + case LDAP_MOD_REPLACE: + XPUSHs(sv_2mortal(newSVpv("REPLACE", 0 ))); + break; + } + + + XPUSHs(sv_2mortal(newSVpv( mods->mod_type, 0 ))); + + for ( i = 0; + mods->mod_bvalues != NULL && mods->mod_bvalues[i] != NULL; + i++ ) + { + XPUSHs(sv_2mortal(newSVpv( mods->mod_bvalues[i]->bv_val, 0 ))); + } + } + + PUTBACK; + + count = perl_call_method("modify", G_SCALAR); + + SPAGAIN; + + if (count != 1) { + croak("Big trouble in back_search\n"); + } + + return_code = POPi; + + PUTBACK; FREETMPS; LEAVE; + } + + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); + + if( return_code != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + } + + Debug( LDAP_DEBUG_ANY, "Perl MODIFY\n", 0, 0, 0 ); + return( 0 ); +} + diff --git a/servers/slapd/back-perl/modrdn.c b/servers/slapd/back-perl/modrdn.c new file mode 100644 index 0000000000..d74701418f --- /dev/null +++ b/servers/slapd/back-perl/modrdn.c @@ -0,0 +1,97 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1999, John C. Quillan, All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +/* + * LDAP v3 newSuperior support. + * + * Copyright 1999, Juan C. Gomez, All rights reserved. + * This software is not subject to any license of Silicon Graphics + * Inc. or Purdue University. + * + * Redistribution and use in source and binary forms are permitted + * without restriction or fee of any kind as long as this notice + * is preserved. + * + */ + +#include "portable.h" + +#include +/* #include + #include +*/ + +#include +#include + +#include "slap.h" +#include "perl_back.h" + +int +perl_back_modrdn( + Backend *be, + Connection *conn, + Operation *op, + char *dn, + char *newrdn, + int deleteoldrdn, + char *newSuperior +) +{ + int len; + int count; + int return_code; + + PerlBackend *perl_back = (PerlBackend *) be->be_private; + + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); + + { + dSP; ENTER; SAVETMPS; + + PUSHMARK(sp) ; + XPUSHs( perl_back->pb_obj_ref ); + XPUSHs(sv_2mortal(newSVpv( dn , 0 ))); + XPUSHs(sv_2mortal(newSVpv( newrdn , 0 ))); + XPUSHs(sv_2mortal(newSViv( deleteoldrdn ))); + if ( newSuperior != NULL ) { + XPUSHs(sv_2mortal(newSVpv( newSuperior , 0 ))); + } + PUTBACK ; + + count = perl_call_method("modrdn", G_SCALAR); + + SPAGAIN ; + + if (count != 1) { + croak("Big trouble in back_search\n") ; + } + + return_code = POPi; + + PUTBACK; FREETMPS; LEAVE ; + } + + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); + + if( return_code != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + } + + Debug( LDAP_DEBUG_ANY, "Perl MODRDN\n", 0, 0, 0 ); + return( 0 ); +} + + diff --git a/servers/slapd/back-perl/perl_back.h b/servers/slapd/back-perl/perl_back.h new file mode 100644 index 0000000000..6e53a7f25f --- /dev/null +++ b/servers/slapd/back-perl/perl_back.h @@ -0,0 +1,23 @@ +/* $OpenLDAP$ */ +#ifndef PERL_BACK_H +#define PERL_BACK_H 1 + +LDAP_BEGIN_DECL + +/* + */ +#define EVAL_BUF_SIZE 500 + +extern PerlInterpreter *perl_interpreter; +extern ldap_pvt_thread_mutex_t perl_interpreter_mutex; + +typedef struct perl_backend_instance { + char *pb_module_name; + SV *pb_obj_ref; +} PerlBackend; + +LDAP_END_DECL + +#include "external.h" + +#endif diff --git a/servers/slapd/back-perl/search.c b/servers/slapd/back-perl/search.c new file mode 100644 index 0000000000..0feb28852d --- /dev/null +++ b/servers/slapd/back-perl/search.c @@ -0,0 +1,125 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1999, John C. Quillan, All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + +#include +/* #include + #include +*/ + +#include +#include + +#include "slap.h" +#include "perl_back.h" + +/********************************************************** + * + * Search + * + **********************************************************/ +int +perl_back_search( + Backend *be, + Connection *conn, + Operation *op, + char *base, + int scope, + int deref, + int sizelimit, + int timelimit, + Filter *filter, + char *filterstr, + char **attrs, + int attrsonly + ) +{ + char test[500]; + int count ; + int err = 0; + char *matched = NULL, *info = NULL; + PerlBackend *perl_back = (PerlBackend *)be->be_private; + Entry *e; + char *buf; + int i; + int return_code; + + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); + + { + dSP; ENTER; SAVETMPS; + + PUSHMARK(sp) ; + XPUSHs( perl_back->pb_obj_ref ); + XPUSHs(sv_2mortal(newSVpv( filterstr , 0))); + XPUSHs(sv_2mortal(newSViv( sizelimit ))); + XPUSHs(sv_2mortal(newSViv( timelimit ))); + XPUSHs(sv_2mortal(newSViv( attrsonly ))); + + for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) { + XPUSHs(sv_2mortal(newSVpv( attrs[i] , 0))); + } + PUTBACK; + + count = perl_call_method("search", G_ARRAY ); + + SPAGAIN; + + if (count < 1) { + croak("Big trouble in back_search\n") ; + } + + if ( count > 1 ) { + + for ( i = 1; i < count; i++ ) { + + buf = POPp; + + if ( (e = str2entry( buf )) == NULL ) { + Debug( LDAP_DEBUG_ANY, "str2entry(%s) failed\n", buf, 0, 0 ); + + } else { + send_search_entry( be, conn, op, + e, attrs, attrsonly, NULL ); + + entry_free( e ); + } + } + } + + /* + * We grab the return code last because the stack comes + * from perl in reverse order. + * + * ex perl: return ( 0, $res_1, $res_2 ); + * + * ex stack: <$res_2> <$res_1> <0> + */ + + return_code = POPi; + + + + PUTBACK; FREETMPS; LEAVE; + } + + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); + + if( return_code != 0 ) { + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); + + } else { + send_ldap_result( conn, op, LDAP_SUCCESS, + NULL, NULL, NULL, NULL ); + } +} + diff --git a/servers/slapd/back-perl/unbind.c b/servers/slapd/back-perl/unbind.c new file mode 100644 index 0000000000..a79f9062f8 --- /dev/null +++ b/servers/slapd/back-perl/unbind.c @@ -0,0 +1,41 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1999, John C. Quillan, All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + /* init.c - initialize shell backend */ + +#include +/* #include + #include +*/ + +#include +#include + +#include "slap.h" +#include "perl_back.h" + + +/********************************************************** + * + * UnBind + * + **********************************************************/ +int +perl_back_unbind( + Backend *be, + Connection *conn, + Operation *op +) +{ + Debug( LDAP_DEBUG_TRACE, "Perl UNBIND\n", 0, 0, 0 ); + return 0; +} + diff --git a/servers/slapd/back-shell/Makefile.in b/servers/slapd/back-shell/Makefile.in index a84238bd12..e0c052cc3d 100644 --- a/servers/slapd/back-shell/Makefile.in +++ b/servers/slapd/back-shell/Makefile.in @@ -1,3 +1,5 @@ +# $OpenLDAP$ + SRCS = init.c config.c fork.c search.c bind.c unbind.c add.c delete.c \ modify.c modrdn.c compare.c abandon.c result.c OBJS = init.lo config.lo fork.lo search.lo bind.lo unbind.lo add.lo delete.lo \ diff --git a/servers/slapd/back-shell/abandon.c b/servers/slapd/back-shell/abandon.c index fc9d6a40b6..4f2932793e 100644 --- a/servers/slapd/back-shell/abandon.c +++ b/servers/slapd/back-shell/abandon.c @@ -1,14 +1,18 @@ /* abandon.c - shell backend abandon function */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include -#include + +#include +#include +#include + #include "slap.h" #include "shell.h" -void +int shell_back_abandon( Backend *be, Connection *conn, @@ -18,34 +22,42 @@ shell_back_abandon( { struct shellinfo *si = (struct shellinfo *) be->be_private; FILE *rfp, *wfp; - int pid; + pid_t pid; Operation *o; /* no abandon command defined - just kill the process handling it */ if ( si->si_abandon == NULL ) { - pthread_mutex_lock( &conn->c_opsmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_mutex ); pid = -1; for ( o = conn->c_ops; o != NULL; o = o->o_next ) { if ( o->o_msgid == msgid ) { - pid = o->o_private; + pid = (pid_t) o->o_private; break; } } - pthread_mutex_unlock( &conn->c_opsmutex ); + if( pid == -1 ) { + for ( o = conn->c_pending_ops; o != NULL; o = o->o_next ) { + if ( o->o_msgid == msgid ) { + pid = (pid_t) o->o_private; + break; + } + } + } + ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); if ( pid != -1 ) { - Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n", pid, - 0, 0 ); + Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n", + (int) pid, 0, 0 ); kill( pid, SIGTERM ); } else { Debug( LDAP_DEBUG_ARGS, "shell could not find op %d\n", msgid, 0, 0 ); } - return; + return 0; } if ( forkandexec( si->si_abandon, &rfp, &wfp ) == -1 ) { - return; + return 0; } /* write out the request to the abandon process */ @@ -56,4 +68,6 @@ shell_back_abandon( /* no result from abandon */ fclose( rfp ); + + return 0; } diff --git a/servers/slapd/back-shell/add.c b/servers/slapd/back-shell/add.c index 1c189a96d4..293f3a8709 100644 --- a/servers/slapd/back-shell/add.c +++ b/servers/slapd/back-shell/add.c @@ -1,4 +1,5 @@ /* add.c - shell backend add function */ +/* $OpenLDAP$ */ #include "portable.h" @@ -36,7 +37,7 @@ shell_back_add( /* write out the request to the add process */ fprintf( wfp, "ADD\n" ); - fprintf( wfp, "msgid: %ld\n", op->o_msgid ); + fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, be ); ldap_pvt_thread_mutex_lock( &entry2str_mutex ); fprintf( wfp, "%s", entry2str( e, &len ) ); diff --git a/servers/slapd/back-shell/bind.c b/servers/slapd/back-shell/bind.c index dea149e410..44bd6cd5e2 100644 --- a/servers/slapd/back-shell/bind.c +++ b/servers/slapd/back-shell/bind.c @@ -1,9 +1,13 @@ /* bind.c - shell backend bind function */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "shell.h" @@ -14,33 +18,37 @@ shell_back_bind( Operation *op, char *dn, int method, - struct berval *cred + char *mech, + struct berval *cred, + char **edn ) { struct shellinfo *si = (struct shellinfo *) be->be_private; FILE *rfp, *wfp; int rc; + *edn = NULL; + if ( si->si_bind == NULL ) { send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, - "bind not implemented" ); - return; + "bind not implemented", NULL, NULL ); + return( -1 ); } - if ( (op->o_private = forkandexec( si->si_bind, &rfp, &wfp )) - == -1 ) { + if ( (op->o_private = (void *) forkandexec( si->si_bind, &rfp, &wfp )) + == (void *) -1 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, - "could not fork/exec" ); - return; + "could not fork/exec", NULL, NULL ); + return( -1 ); } /* write out the request to the bind process */ fprintf( wfp, "BIND\n" ); - fprintf( wfp, "msgid: %d\n", op->o_msgid ); + fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, be ); fprintf( wfp, "dn: %s\n", dn ); fprintf( wfp, "method: %d\n", method ); - fprintf( wfp, "credlen: %d\n", cred->bv_len ); + fprintf( wfp, "credlen: %lu\n", cred->bv_len ); fprintf( wfp, "cred: %s\n", cred->bv_val ); /* XXX */ fclose( wfp ); diff --git a/servers/slapd/back-shell/compare.c b/servers/slapd/back-shell/compare.c index 48dfbb553b..940f213fc5 100644 --- a/servers/slapd/back-shell/compare.c +++ b/servers/slapd/back-shell/compare.c @@ -1,13 +1,17 @@ /* compare.c - shell backend compare function */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "shell.h" -void +int shell_back_compare( Backend *be, Connection *conn, @@ -21,20 +25,20 @@ shell_back_compare( if ( si->si_compare == NULL ) { send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, - "compare not implemented" ); - return; + "compare not implemented", NULL, NULL ); + return( -1 ); } - if ( (op->o_private = forkandexec( si->si_compare, &rfp, &wfp )) - == -1 ) { + if ( (op->o_private = (void *) forkandexec( si->si_compare, &rfp, &wfp )) + == (void *) -1 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, - "could not fork/exec" ); - return; + "could not fork/exec", NULL, NULL ); + return( -1 ); } /* write out the request to the compare process */ fprintf( wfp, "COMPARE\n" ); - fprintf( wfp, "msgid: %d\n", op->o_msgid ); + fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, be ); fprintf( wfp, "dn: %s\n", dn ); fprintf( wfp, "%s: %s\n", ava->ava_type, ava->ava_value.bv_val ); @@ -44,4 +48,5 @@ shell_back_compare( read_and_send_results( be, conn, op, rfp, NULL, 0 ); fclose( rfp ); + return( 0 ); } diff --git a/servers/slapd/back-shell/config.c b/servers/slapd/back-shell/config.c index 5d2fa1c19a..03c7b7da76 100644 --- a/servers/slapd/back-shell/config.c +++ b/servers/slapd/back-shell/config.c @@ -1,17 +1,20 @@ /* config.c - shell backend configuration file routine */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "shell.h" -extern char **charray_dup(); - -shell_back_config( - Backend *be, - char *fname, +int +shell_back_db_config( + BackendDB *be, + const char *fname, int lineno, int argc, char **argv @@ -22,7 +25,7 @@ shell_back_config( if ( si == NULL ) { fprintf( stderr, "%s: line %d: shell backend info is null!\n", fname, lineno ); - exit( 1 ); + return( 1 ); } /* command + args to exec for binds */ @@ -31,7 +34,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"bind \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_bind = charray_dup( &argv[1] ); @@ -41,7 +44,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"unbind \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_unbind = charray_dup( &argv[1] ); @@ -51,7 +54,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"search \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_search = charray_dup( &argv[1] ); @@ -61,7 +64,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"compare \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_compare = charray_dup( &argv[1] ); @@ -71,7 +74,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"modify \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_modify = charray_dup( &argv[1] ); @@ -81,7 +84,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"modrdn \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_modrdn = charray_dup( &argv[1] ); @@ -91,7 +94,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"add \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_add = charray_dup( &argv[1] ); @@ -101,7 +104,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"delete \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_delete = charray_dup( &argv[1] ); @@ -111,7 +114,7 @@ shell_back_config( fprintf( stderr, "%s: line %d: missing executable in \"abandon \" line\n", fname, lineno ); - exit( 1 ); + return( 1 ); } si->si_abandon = charray_dup( &argv[1] ); @@ -121,4 +124,6 @@ shell_back_config( "%s: line %d: unknown directive \"%s\" in shell database definition (ignored)\n", fname, lineno, argv[0] ); } + + return 0; } diff --git a/servers/slapd/back-shell/delete.c b/servers/slapd/back-shell/delete.c index 0dc3439c00..27f67a2c63 100644 --- a/servers/slapd/back-shell/delete.c +++ b/servers/slapd/back-shell/delete.c @@ -1,13 +1,17 @@ /* delete.c - shell backend delete function */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "shell.h" -void +int shell_back_delete( Backend *be, Connection *conn, @@ -20,20 +24,20 @@ shell_back_delete( if ( si->si_delete == NULL ) { send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, - "delete not implemented" ); - return; + "delete not implemented", NULL, NULL ); + return( -1 ); } - if ( (op->o_private = forkandexec( si->si_delete, &rfp, &wfp )) - == -1 ) { + if ( (op->o_private = (void *) forkandexec( si->si_delete, &rfp, &wfp )) + == (void *) -1 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, - "could not fork/exec" ); - return; + "could not fork/exec", NULL, NULL ); + return( -1 ); } /* write out the request to the delete process */ fprintf( wfp, "DELETE\n" ); - fprintf( wfp, "msgid: %d\n", op->o_msgid ); + fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, be ); fprintf( wfp, "dn: %s\n", dn ); fclose( wfp ); @@ -41,4 +45,5 @@ shell_back_delete( /* read in the results and send them along */ read_and_send_results( be, conn, op, rfp, NULL, 0 ); fclose( rfp ); + return( 0 ); } diff --git a/servers/slapd/back-shell/external.h b/servers/slapd/back-shell/external.h new file mode 100644 index 0000000000..64c2dce5bc --- /dev/null +++ b/servers/slapd/back-shell/external.h @@ -0,0 +1,56 @@ +/* $OpenLDAP$ */ +#ifndef _SHELL_EXTERNAL_H +#define _SHELL_EXTERNAL_H + +LDAP_BEGIN_DECL + +extern int shell_back_initialize LDAP_P(( BackendInfo *bi )); +extern int shell_back_open LDAP_P(( BackendInfo *bi )); +extern int shell_back_close LDAP_P(( BackendInfo *bi )); +extern int shell_back_destroy LDAP_P(( BackendInfo *bi )); + +extern int shell_back_db_init LDAP_P(( BackendDB *bd )); +extern int shell_back_db_destroy LDAP_P(( BackendDB *bd )); + +extern int shell_back_db_config LDAP_P(( BackendDB *bd, + const char *fname, int lineno, int argc, char **argv )); + +extern int shell_back_bind LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, int method, char* mech, + struct berval *cred, char** edn )); + +extern int shell_back_unbind LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op )); + +extern int shell_back_search LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *base, int scope, int deref, int sizelimit, int timelimit, + Filter *filter, char *filterstr, char **attrs, int attrsonly )); + +extern int shell_back_compare LDAP_P((BackendDB *bd, + Connection *conn, Operation *op, + char *dn, Ava *ava )); + +extern int shell_back_modify LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, LDAPModList *ml )); + +extern int shell_back_modrdn LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, + char *dn, char*newrdn, int deleteoldrdn, + char *newSuperior )); + +extern int shell_back_add LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, Entry *e )); + +extern int shell_back_delete LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, char *dn )); + +extern int shell_back_abandon LDAP_P(( BackendDB *bd, + Connection *conn, Operation *op, int msgid )); + +LDAP_END_DECL + +#endif /* _SHELL_EXTERNAL_H */ + diff --git a/servers/slapd/back-shell/fork.c b/servers/slapd/back-shell/fork.c index 1f08097b1a..34adf8b5a3 100644 --- a/servers/slapd/back-shell/fork.c +++ b/servers/slapd/back-shell/fork.c @@ -1,4 +1,5 @@ /* fork.c - fork and exec a process, connecting stdin/out w/pipes */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-shell/init.c b/servers/slapd/back-shell/init.c index 1b15c778c8..57c3742c4e 100644 --- a/servers/slapd/back-shell/init.c +++ b/servers/slapd/back-shell/init.c @@ -1,4 +1,5 @@ /* init.c - initialize shell backend */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-shell/modify.c b/servers/slapd/back-shell/modify.c index d05b79639d..154bd2a6eb 100644 --- a/servers/slapd/back-shell/modify.c +++ b/servers/slapd/back-shell/modify.c @@ -1,19 +1,23 @@ /* modify.c - shell backend modify function */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "shell.h" -void +int shell_back_modify( Backend *be, Connection *conn, Operation *op, char *dn, - LDAPMod *mods + LDAPModList *ml ) { struct shellinfo *si = (struct shellinfo *) be->be_private; @@ -22,41 +26,41 @@ shell_back_modify( if ( si->si_modify == NULL ) { send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, - "modify not implemented" ); - return; + "modify not implemented", NULL, NULL ); + return( -1 ); } - if ( (op->o_private = forkandexec( si->si_modify, &rfp, &wfp )) - == -1 ) { + if ( (op->o_private = (void *) forkandexec( si->si_modify, &rfp, &wfp )) + == (void *) -1 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, - "could not fork/exec" ); - return; + "could not fork/exec", NULL, NULL ); + return( -1 ); } /* write out the request to the modify process */ fprintf( wfp, "MODIFY\n" ); - fprintf( wfp, "msgid: %d\n", op->o_msgid ); + fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, be ); fprintf( wfp, "dn: %s\n", dn ); - for ( ; mods != NULL; mods = mods->mod_next ) { - switch ( mods->mod_op & ~LDAP_MOD_BVALUES ) { + for ( ; ml != NULL; ml = ml->ml_next ) { + switch ( ml->ml_op & ~LDAP_MOD_BVALUES ) { case LDAP_MOD_ADD: - fprintf( wfp, "add: %s", mods->mod_type ); + fprintf( wfp, "add: %s\n", ml->ml_type ); break; case LDAP_MOD_DELETE: - fprintf( wfp, "delete: %s", mods->mod_type ); + fprintf( wfp, "delete: %s\n", ml->ml_type ); break; case LDAP_MOD_REPLACE: - fprintf( wfp, "replace: %s", mods->mod_type ); + fprintf( wfp, "replace: %s\n", ml->ml_type ); break; } - for ( i = 0; mods->mod_bvalues != NULL && mods->mod_bvalues[i] + for ( i = 0; ml->ml_bvalues != NULL && ml->ml_bvalues[i] != NULL; i++ ) { - fprintf( wfp, "%s: %s\n", mods->mod_type, - mods->mod_bvalues[i]->bv_val ); + fprintf( wfp, "%s: %s\n", ml->ml_type, + ml->ml_bvalues[i]->bv_val ); } } fclose( wfp ); @@ -64,4 +68,6 @@ shell_back_modify( /* read in the results and send them along */ read_and_send_results( be, conn, op, rfp, NULL, 0 ); fclose( rfp ); + return( 0 ); + } diff --git a/servers/slapd/back-shell/modrdn.c b/servers/slapd/back-shell/modrdn.c index 9fd793317d..1df37d579c 100644 --- a/servers/slapd/back-shell/modrdn.c +++ b/servers/slapd/back-shell/modrdn.c @@ -1,20 +1,38 @@ /* modrdn.c - shell backend modrdn function */ +/* $OpenLDAP$ */ + +/* + * LDAP v3 newSuperior support. + * + * Copyright 1999, Juan C. Gomez, All rights reserved. + * This software is not subject to any license of Silicon Graphics + * Inc. or Purdue University. + * + * Redistribution and use in source and binary forms are permitted + * without restriction or fee of any kind as long as this notice + * is preserved. + * + */ + +#include "portable.h" #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "shell.h" -void +int shell_back_modrdn( Backend *be, Connection *conn, Operation *op, char *dn, char *newrdn, - int deleteoldrdn + int deleteoldrdn, + char *newSuperior ) { struct shellinfo *si = (struct shellinfo *) be->be_private; @@ -22,27 +40,31 @@ shell_back_modrdn( if ( si->si_modrdn == NULL ) { send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, - "modrdn not implemented" ); - return; + "modrdn not implemented", NULL, NULL ); + return( -1 ); } - if ( (op->o_private = forkandexec( si->si_modrdn, &rfp, &wfp )) - == -1 ) { + if ( (op->o_private = (void *) forkandexec( si->si_modrdn, &rfp, &wfp )) + == (void *) -1 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, - "could not fork/exec" ); - return; + "could not fork/exec", NULL, NULL ); + return( -1 ); } /* write out the request to the modrdn process */ fprintf( wfp, "MODRDN\n" ); - fprintf( wfp, "msgid: %d\n", op->o_msgid ); + fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, be ); fprintf( wfp, "dn: %s\n", dn ); fprintf( wfp, "newrdn: %s\n", newrdn ); fprintf( wfp, "deleteoldrdn: %d\n", deleteoldrdn ? 1 : 0 ); + if (newSuperior != NULL) { + fprintf( wfp, "newSuperior: %s\n", newSuperior ); + } fclose( wfp ); /* read in the results and send them along */ read_and_send_results( be, conn, op, rfp, NULL, 0 ); fclose( rfp ); + return( 0 ); } diff --git a/servers/slapd/back-shell/result.c b/servers/slapd/back-shell/result.c index a10891c212..4d9f39c2f5 100644 --- a/servers/slapd/back-shell/result.c +++ b/servers/slapd/back-shell/result.c @@ -1,4 +1,5 @@ /* result.c - shell backend result reading function */ +/* $OpenLDAP$ */ #include "portable.h" diff --git a/servers/slapd/back-shell/search.c b/servers/slapd/back-shell/search.c index 749b112a94..b2b6587719 100644 --- a/servers/slapd/back-shell/search.c +++ b/servers/slapd/back-shell/search.c @@ -1,15 +1,17 @@ /* search.c - shell backend search function */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "shell.h" -extern Entry *str2entry(); - -void +int shell_back_search( Backend *be, Connection *conn, @@ -26,27 +28,25 @@ shell_back_search( ) { struct shellinfo *si = (struct shellinfo *) be->be_private; - int i, rc, bsize, len; - int err; - char *matched, *info; + int i; FILE *rfp, *wfp; if ( si->si_search == NULL ) { send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, - "search not implemented" ); - return; + "search not implemented", NULL, NULL ); + return( -1 ); } - if ( (op->o_private = forkandexec( si->si_search, &rfp, &wfp )) - == -1 ) { + if ( (op->o_private = (void *) forkandexec( si->si_search, &rfp, &wfp )) + == (void *) -1 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, - "could not fork/exec" ); - return; + "could not fork/exec", NULL, NULL ); + return( -1 ); } /* write out the request to the search process */ fprintf( wfp, "SEARCH\n" ); - fprintf( wfp, "msgid: %d\n", op->o_msgid ); + fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, be ); fprintf( wfp, "base: %s\n", base ); fprintf( wfp, "scope: %d\n", scope ); @@ -66,4 +66,5 @@ shell_back_search( read_and_send_results( be, conn, op, rfp, attrs, attrsonly ); fclose( rfp ); + return( 0 ); } diff --git a/servers/slapd/back-shell/shell.h b/servers/slapd/back-shell/shell.h index 5ef493c045..573f485e8d 100644 --- a/servers/slapd/back-shell/shell.h +++ b/servers/slapd/back-shell/shell.h @@ -1,4 +1,12 @@ /* shell.h - shell backend header file */ +/* $OpenLDAP$ */ + +#ifndef SLAPD_SHELL_H +#define SLAPD_SHELL_H + +#include "external.h" + +LDAP_BEGIN_DECL struct shellinfo { char **si_bind; /* cmd + args to exec for bind */ @@ -11,3 +19,28 @@ struct shellinfo { char **si_delete; /* cmd + args to exec for delete */ char **si_abandon; /* cmd + args to exec for abandon */ }; + +struct slap_backend_db; +struct slap_conn; +struct slap_op; + +extern pid_t forkandexec LDAP_P(( + char **args, + FILE **rfp, + FILE **wfp)); + +extern void print_suffixes LDAP_P(( + FILE *fp, + struct slap_backend_db *bd)); + +extern int read_and_send_results LDAP_P(( + struct slap_backend_db *bd, + struct slap_conn *conn, + struct slap_op *op, + FILE *fp, + char **attrs, + int attrsonly)); + +LDAP_END_DECL + +#endif diff --git a/servers/slapd/back-shell/unbind.c b/servers/slapd/back-shell/unbind.c index 649fe96c13..ca091da436 100644 --- a/servers/slapd/back-shell/unbind.c +++ b/servers/slapd/back-shell/unbind.c @@ -1,20 +1,21 @@ /* unbind.c - shell backend unbind function */ +/* $OpenLDAP$ */ + +#include "portable.h" #include -#include -#include -#include + +#include +#include + #include "slap.h" #include "shell.h" -void +int shell_back_unbind( Backend *be, Connection *conn, - Operation *op, - char *dn, - int method, - struct berval *cred + Operation *op ) { struct shellinfo *si = (struct shellinfo *) be->be_private; @@ -22,24 +23,26 @@ shell_back_unbind( if ( si->si_unbind == NULL ) { send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL, - "unbind not implemented" ); - return; + "unbind not implemented", NULL, NULL ); + return 0; } - if ( (op->o_private = forkandexec( si->si_unbind, &rfp, &wfp )) - == -1 ) { + if ( (op->o_private = (void *) forkandexec( si->si_unbind, &rfp, &wfp )) + == (void *) -1 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, - "could not fork/exec" ); - return; + "could not fork/exec", NULL, NULL ); + return 0; } /* write out the request to the unbind process */ fprintf( wfp, "UNBIND\n" ); - fprintf( wfp, "msgid: %d\n", op->o_msgid ); + fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, be ); - fprintf( wfp, "dn: %s\n", dn ); + fprintf( wfp, "dn: %s\n", (conn->c_dn ? conn->c_dn : "") ); fclose( wfp ); /* no response to unbind */ fclose( rfp ); + + return 0; } diff --git a/servers/slapd/back-tcl/Makefile.in b/servers/slapd/back-tcl/Makefile.in index 48de791460..6a565402e6 100644 --- a/servers/slapd/back-tcl/Makefile.in +++ b/servers/slapd/back-tcl/Makefile.in @@ -1,3 +1,4 @@ +# $OpenLDAP$ ########################################################################### # # Copyright 1999, Ben Collins , All rights reserved. diff --git a/servers/slapd/back-tcl/external.h b/servers/slapd/back-tcl/external.h new file mode 100644 index 0000000000..ece4c51e62 --- /dev/null +++ b/servers/slapd/back-tcl/external.h @@ -0,0 +1,58 @@ +/* $OpenLDAP$ */ + +#ifndef _TCL_EXTERNAL_H +#define _TCL_EXTERNAL_H + +LDAP_BEGIN_DECL + +extern int tcl_back_initialize LDAP_P ((BackendInfo * bi)); +extern int tcl_back_open LDAP_P ((BackendInfo * bi)); +extern int tcl_back_close LDAP_P ((BackendInfo * bi)); +extern int tcl_back_destroy LDAP_P ((BackendInfo * bi)); + +extern int tcl_back_db_init LDAP_P ((BackendDB * bd)); +extern int tcl_back_db_open LDAP_P ((BackendDB * bd)); +extern int tcl_back_db_close LDAP_P ((BackendDB * bd)); +extern int tcl_back_db_destroy LDAP_P ((BackendDB * bd)); + +extern int tcl_back_db_config LDAP_P ((BackendDB * bd, + const char *fname, int lineno, int argc, char **argv)); + +extern int tcl_back_bind LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *dn, int method, char *mech, + struct berval * cred, char **edn)); + +extern int tcl_back_unbind LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op)); + +extern int tcl_back_search LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *base, int scope, int deref, int sizelimit, int timelimit, + Filter * filter, char *filterstr, char **attrs, int attrsonly)); + +extern int tcl_back_compare LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *dn, Ava * ava)); + +extern int tcl_back_modify LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *dn, LDAPModList * ml)); + +extern int tcl_back_modrdn LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, + char *dn, char *newrdn, int deleteoldrdn, + char *newSuperior)); + +extern int tcl_back_add LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, Entry * e)); + +extern int tcl_back_delete LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, char *dn)); + +extern int tcl_back_abandon LDAP_P ((BackendDB * bd, + Connection * conn, Operation * op, int msgid)); + +LDAP_END_DECL + +#endif /* _TCL_EXTERNAL_H */ diff --git a/servers/slapd/back-tcl/tcl_abandon.c b/servers/slapd/back-tcl/tcl_abandon.c new file mode 100644 index 0000000000..5fcf8c5a28 --- /dev/null +++ b/servers/slapd/back-tcl/tcl_abandon.c @@ -0,0 +1,58 @@ +/* $OpenLDAP$ */ +/* abandon.c - tcl abandon routine + * + * Copyright 1999, Ben Collins , All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + +#include + +#include "slap.h" +#include "tcl_back.h" + +int +tcl_back_abandon ( + Backend * be, + Connection * conn, + Operation * op, + int msgid +) +{ + char *suf_tcl, *results, *command; + int i, code, err = 0; + struct tclinfo *ti = (struct tclinfo *) be->be_private; + + if (ti->ti_abandon == NULL) { + return (-1); + } + + for (i = 0; be->be_suffix[i] != NULL; i++); + suf_tcl = Tcl_Merge (i, be->be_suffix); + + command = (char *) ch_malloc (strlen (ti->ti_abandon) + strlen (suf_tcl) + + 20); + sprintf (command, "%s ABANDON {%ld} {%s}", + ti->ti_abandon, op->o_msgid, suf_tcl); + Tcl_Free (suf_tcl); + + ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex); + code = Tcl_GlobalEval (ti->ti_ii->interp, command); + results = (char *) ch_strdup (ti->ti_ii->interp->result); + ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex); + free (command); + + if (code != TCL_OK) { + err = LDAP_OPERATIONS_ERROR; + Debug (LDAP_DEBUG_SHELL, "tcl_abandon_error: %s\n", results, + 0, 0); + } + + free (results); + return (err); +} diff --git a/servers/slapd/back-tcl/tcl_add.c b/servers/slapd/back-tcl/tcl_add.c index e7c83ee036..e2d324bba6 100644 --- a/servers/slapd/back-tcl/tcl_add.c +++ b/servers/slapd/back-tcl/tcl_add.c @@ -1,6 +1,5 @@ +/* $OpenLDAP$ */ /* add.c - tcl add routine - * - * $Id: tcl_add.c,v 1.7 1999/08/02 23:38:43 hallvard Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * diff --git a/servers/slapd/back-tcl/tcl_back.h b/servers/slapd/back-tcl/tcl_back.h new file mode 100644 index 0000000000..cba34eb176 --- /dev/null +++ b/servers/slapd/back-tcl/tcl_back.h @@ -0,0 +1,64 @@ +/* $OpenLDAP$ */ +/* tcl_back.h - tcl backend header (structs, functions) + * + * Copyright 1999, Ben Collins , All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include + +#ifndef SLAPD_TCL_H +#define SLAPD_TCL_H + +#include +#include "external.h" + +extern ldap_pvt_thread_mutex_t tcl_interpreter_mutex; + +struct i_info { + Tcl_Interp *interp; + char *name; + struct i_info *next; + int count; +}; + +extern struct i_info *global_i; + +struct tclinfo { + char *script_path; + struct i_info *ti_ii; + char *ti_bind; + char *ti_unbind; + char *ti_search; + char *ti_compare; + char *ti_modify; + char *ti_modrdn; + char *ti_add; + char *ti_delete; + char *ti_abandon; +}; + +void readtclscript (char *script, Tcl_Interp * my_tcl); +char *tcl_clean_entry (Entry * e); + +int tcl_ldap_debug ( + ClientData clientData, + Tcl_Interp * interp, + int argc, + char *argv[] +); + +int interp_send_results ( + Backend * be, + Connection * conn, + Operation * op, + char *result, + char **attrs, + int attrsonly +); + +#endif diff --git a/servers/slapd/back-tcl/tcl_bind.c b/servers/slapd/back-tcl/tcl_bind.c index dffb75722c..a26da559f9 100644 --- a/servers/slapd/back-tcl/tcl_bind.c +++ b/servers/slapd/back-tcl/tcl_bind.c @@ -1,6 +1,5 @@ +/* $OpenLDAP$ */ /* bind.c - tcl bind routines - * - * $Id: tcl_bind.c,v 1.8 1999/08/02 23:38:43 hallvard Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * diff --git a/servers/slapd/back-tcl/tcl_close.c b/servers/slapd/back-tcl/tcl_close.c new file mode 100644 index 0000000000..4fb893a51e --- /dev/null +++ b/servers/slapd/back-tcl/tcl_close.c @@ -0,0 +1,82 @@ +/* $OpenLDAP$ */ +/* close.c - tcl close routines + * + * Copyright 1999, Ben Collins , All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + +#include + +#include "slap.h" +#include "tcl_back.h" + +int +tcl_back_close ( + BackendInfo * bi +) +{ + Tcl_DeleteInterp (global_i->interp); + + return (0); +} + +int +tcl_back_destroy ( + BackendInfo * bi +) +{ + free (global_i->interp); + free (global_i); + ldap_pvt_thread_mutex_destroy (&tcl_interpreter_mutex); + + return (0); +} + +int +tcl_back_db_close ( + BackendDB * bd +) +{ + struct tclinfo *ti = (struct tclinfo *) bd->be_private; + struct i_info *ti_tmp; + + /* Disable the interp and associated struct */ + ti->ti_ii->count--; + if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) { + /* no more db's using this and it's not the default */ + for (ti_tmp = global_i; ti_tmp->next != ti->ti_ii; ti_tmp + = ti_tmp->next); + /* This bypasses this interp struct in the global hash */ + ti_tmp->next = ti->ti_ii->next; + Tcl_DeleteInterp (ti->ti_ii->interp); + } + return (0); +} + +int +tcl_back_db_destroy ( + BackendDB * bd +) +{ + struct tclinfo *ti = (struct tclinfo *) bd->be_private; + + /* + * Now free up the allocated memory used + */ + ti->ti_ii->count--; + if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) { + free (ti->ti_ii->interp); + free (ti->ti_ii); + free (ti); + } + free (bd->be_private); + bd->be_private = NULL; + + return (0); +} diff --git a/servers/slapd/back-tcl/tcl_compare.c b/servers/slapd/back-tcl/tcl_compare.c index 9e587ad748..06d23f54de 100644 --- a/servers/slapd/back-tcl/tcl_compare.c +++ b/servers/slapd/back-tcl/tcl_compare.c @@ -1,6 +1,5 @@ +/* $OpenLDAP$ */ /* compare.c - tcl compare routines - * - * $Id: tcl_compare.c,v 1.7 1999/08/02 23:38:43 hallvard Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * diff --git a/servers/slapd/back-tcl/tcl_config.c b/servers/slapd/back-tcl/tcl_config.c new file mode 100644 index 0000000000..64174bca83 --- /dev/null +++ b/servers/slapd/back-tcl/tcl_config.c @@ -0,0 +1,182 @@ +/* $OpenLDAP$ */ +/* config.c - tcl backend configuration file routine + * + * Copyright 1999, Ben Collins , All rights reserved. + * + * Redistribution and use in source and binary forms are permitted only + * as authorized by the OpenLDAP Public License. A copy of this + * license is available at http://www.OpenLDAP.org/license.html or + * in file LICENSE in the top-level directory of the distribution. + */ + +#include "portable.h" + +#include + +#include "slap.h" +#include "tcl_back.h" + +struct i_info *global_i; + +int +tcl_back_db_config ( + BackendDB * bd, + const char *fname, + int lineno, + int argc, + char **argv +) +{ + struct tclinfo *ti = (struct tclinfo *) bd->be_private; + int script_loaded = 0; + + if (ti == NULL) { + fprintf (stderr, + "%s: line %d: tcl backend info is null!\n", fname, + lineno); + return (1); + } + if (ti->ti_ii == NULL) { + ti->ti_ii = global_i; + } + + /* Script to load */ + if (strcasecmp (argv[0], "scriptpath") == 0) { + if (argc < 2) { + Debug (LDAP_DEBUG_CONFIG, + "%s: line %d: missing script in \"scriptpath