Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • openldap/openldap
  • hyc/openldap
  • ryan/openldap
  • iboukris/openldap
  • ondra/openldap
  • sshanks-kx/openldap
  • blaggacao/openldap
  • pbrezina/openldap
  • quanah/openldap
  • dragos_h/openldap
  • lorenz/openldap
  • tsaarni/openldap
  • fei.ding/openldap
  • orent/openldap
  • arrowplum/openldap
  • barchiesi/openldap
  • jotik/openldap
  • hamano/openldap
  • ingovoss/openldap
  • henson/openldap
  • jlrine2/openldap
  • howeverAT/openldap
  • nivanova/openldap
  • orbea/openldap
  • rdubner/openldap
  • smckinney/openldap
  • jklowden/openldap
  • dpa-openldap/openldap
  • rouzier/openldap
  • orgads/openldap
  • ffontaine/openldap
  • jiaqingz/openldap
  • dcoutadeur/openldap
  • begeragus/openldap
  • pubellit/openldap
  • glandium/openldap
  • facboy/openldap
  • thesamesam/openldap
  • Johan/openldap
  • fkooman/openldap
  • gburd/openldap
  • h-homma/openldap
  • sgallagher/openldap
  • ahmed_zaki/openldap
  • gnoe/openldap
  • mid/openldap
  • clan/openldap
47 results
Show changes
Commits on Source (168)
Showing with 10077 additions and 3802 deletions
A N N O U N C E M E N T A N N O U N C E M E N T -- OpenLDAP 2.1
LDAP 3.3 The OpenLDAP Project is pleased to announce the availability
of OpenLDAP 2.1, a suite of the Lightweight Directory Access
The University of Michigan is pleased to announce release 3.3 of Protocol servers, clients, utilities, and development tools.
UM-LDAP, an implementation of the Lightweight Directory Access
Protocol. LDAP is a draft Internet standard directory service This release contains the following major enhancements:
protocol that runs over TCP/IP. It can be used to provide a
stand-alone directory service, or to provide lightweight access to * Transactional backend
the X.500 directory. LDAP is defined by RFC 1777 and RFC 1778. * Improved Unicode handling
* Improved DN handlng
This release includes the following components: * Improved Referral handling
* SASL authentication/authorization mapping
- slapd - a stand-alone LDAP directory server * SASL in-directory storage of authentication secrets
- slurpd - a stand-alone LDAP replication server * Enhanced administrative limits/access controls
- ldapd - an LDAP-to-X.500 gateway server * Meta backend (experimental)
- centipede - an LDAP centroid generation and maintenance program * Monitor backend (experimental)
- libldap - an LDAP client library * Virtual "glue" backend (experimental)
- liblber - a lightweight BER/DER encoding/decoding library * LDAP C++ API
- ldif tools - data conversion tools for use with slapd * Updated LDAP C and TCL APIs
- in.xfingerd - a finger-to-LDAP gateway server * LDAPv3 extensions, including:
- go500 - a gopher-to-LDAP gateway server for searching - Enhanced Language Tag/Range Support
- go500gw - a gopher-to-LDAP gateway server for searching and browsing - 'Who am i?' Extended Operation
- rcpt500 - an email-to-LDAP query responder - 'Matched Values' Control
- mail500 - an LDAP-capable mailer
- fax500 - an LDAP-capable mailer that supports remote printing This release includes the following major components:
- LDAP tools - A collection of shell-based LDAP utility programs
* slapd - a stand-alone LDAP directory server
* slurpd - a stand-alone LDAP replication server
* -lldap - a LDAP client library
* -llber - a lightweight BER/DER encoding/decoding library
* LDIF tools - data conversion tools for use with slapd
* LDAP tools - A collection of command line LDAP utility programs
In addition, there are some contributed components: In addition, there are some contributed components:
- web500 - an HTTP-to-LDAP gateway * LDAPC++ - a LDAP C++ SDK
- whois++d - a WHOIS++-to-LDAP gateway * ldapTCL - a LDAP TCL SDK
- saucer - a simple command-line oriented client program
CHANGES This release contains a number of major code changes. It
might be a bit rough around the edges. Use with appropriate
caution.
Changes since release 3.2 of LDAP include
- slurpd has been rewritten as a single process threaded daemon ACKNOWLEDGEMENTS
- ldaptools (ldapsearch, etc) now support the LDIF format
- support for LDAP URLs added to libldap OpenLDAP is developed by a team of volunteers whose use
- improved support for LDAP referrals in libldap the Internet to coordinate their activities. The project is
- preliminary test scripts included managed by the OpenLDAP Foundation.
- support for additional platforms
- various bug fixes and build fixes OpenLDAP LDAP implementation is derived from University of
Michigan LDAP release 3.3.
See the CHANGES file in the distribution for more details.
AVAILABILITY AVAILABILITY
This software is freely available to anyone for any lawful purpose, This software is available under the OpenLDAP Public License,
subject to the U-M copyright notice and disclaimer. The software is an unrestrictive, "free," OSI-approved open source license.
available for anonymous ftp from the following location: For download information is available at:
http://www.OpenLDAP.org/software/download/
ftp://terminator.rs.itd.umich.edu/ldap/ldap-3.3.tar.Z
SUPPORT SUPPORT
The software is provided as is without any express or implied OpenLDAP software is user supported:
warranty, but there is a bug reporting mail address which is
responded to on a best-effort basis: http://www.openldap.org/support/
The OpenLDAP Administrator's Guide, which includes quick
start instructions, is available at:
http://www.openldap.org/doc/admin/
The project maintains a FAQ which you may find useful:
http://www.openldap.org/faq/
ldap-support@umich.edu In addition, there are also a number of discussion lists
related OpenLDAP. A list of mailing lists is available at:
In addition, there is a discussion list for issues relating to this http://www.OpenLDAP.org/lists/
implementation of ldap:
ldap@umich.edu -- discussion list To report bugs, please use project's Issue Tracking System:
ldap-request@umich.edu -- to join the list
Comments or questions about the LDAP protocol in general should be http://www.openldap.org/its/
sent to the IETF ASID discussion group:
ietf-asid@umich.edu -- discussion list The OpenLDAP home page containing lots of interesting information
ietf-asid-request@umich.edu -- to join the list and online documentation is available at this URL:
An LDAP home page containing lots of interesting information and http://www.OpenLDAP.org/
online documentation is available at this URL:
http://www.umich.edu/~rsug/ldap/
SUPPORTED PLATFORMS SUPPORTED PLATFORMS
This release has been ported to many UNIX platforms, including This release has been ported to many UNIX (and UNIX-like) platforms
SunOS 4.1.x, Solaris 2.x, Ultrix 4.3, HP-UX 9.05, AIX 3.2.5, including FreeBSD, Linux, NetBSD, OpenBSD and most commercial UNIX
SCO, FreeBSD, NetBSD, LINUX, IRIX, Digital Unix (OSF/1), and systems. The release has also been ported (in part or in whole) to
NeXTSTEP 3.2. This release has also been ported to VMS. other platforms including Apple's MacOS and Microsoft's Windows 2000.
The client libraries and some clients have also been ported to
MacOS 7.x, MSDOS (some TCP stacks), and MS Windows 3.1/95/NT.
Changes since 3.3b1 OpenLDAP 2.1 Change Log
OpenLDAP 2.1.4 Engineering
Fixed slapd DN normalization (requires DB reload)
Fixed slapd bootParameter validation bug (ITS#1957)
Fixed slapd saslRegex bug (ITS#1978)
Fixed back-monitor time stats (ITS#1984)
Fixed slapd saslRegexp normalization (ITS#1951)
Fixed back-meta undef DN attr bug (ITS#1953)
Fixed back-meta search operation error (ITS#2014)
Fixed ldapmodify LDIF CRLF handling
Fixed back-bdb IDL bugs (ITS#1969, ITS#1977, ITS#2015)
Fixed back-bdb entry return (ITS#1994)
Fixed back-bdb lock_id error detection (ITS#2030)
Fixed slapd inappropriate return of operationsError (ITS#1995)
Fixed slapd group ACL bug (ITS#1978)
Fixed slapd " " handling (ITS#1998)
Fixed IPv6 underallocation bug (ITS#2018)
Fixed libldap gethostbyname init bug (ITS#2019)
Added LDAP SASL auxprop plugin to contrib
Added buffer overrun checks (ITS#1936, ITS#1965, ITS#2009-2011)
Added slapd subschema DN configuration (ITS#1893)
Updated slapd anon update error code (ITS#1987)
Updated slapd/libldap error messages (ITS#1989)
Updated slapd/libldap IPv4 only handling
Updated slapd bind logging (ITS#1809) (ITS#2017)
Updated slapd/libldap IPv6 handling (ITS#2018)
Updated libldap LDAP_OPT_RESTART handling
Updated new logging
Updated OpenLDAPaci syntax/semantics (ITS#2005, ITS#2006)
Updated back-sql
Build Environment
Added OS/390 port
Updated WinNT port
Added DN testing to tests suite
Fixed krbName schema (ITS#1948)
Fixed pkiUser schema (ITS#1959)
Fixed back-shell builds (ITS#1985)
Resolve liblutil/passwd <des.h> conflict (ITS#2016)
Resolved IRIX sc_mask conflict (ITS#2022)
Removed ud(1) and filter template API (ITS#2011)
Removed lint (ITS#2021)
Documentation
Replaced namedref with RFC 3296
Misc manual page updates
OpenLDAP 2.1.3 Release
Fixed slapd access to dn="" bug (ITS#1921)
Fixed slapd structuralObjectClass lastmod bug (ITS#1904)
Fixed slapd krbName bug (ITS#1913)
Fixed slapd schema error alignment bug
Fixed slapd excessive DN logging (ITS#1901)
Fixed slapd matched values malloc bug (ITS#1931)
Fixed slapd TLS data ready bug
Updated slapd SASL proxy policy code
Updated slapd require "strong" check
Added slapd disallow bind_simple_unprotected directive
Added slapd SASL setpass support (ITS#1943)
Added slapd IPv4/v6 only options
Updated back-bdb entry locking
Fixed liblutil passwd cleartext bug
Fixed back-ldap/meta mapping bug (ITS#1787)
Added back-monitor added monitorContext support
Fixed back-perl ad_cname bug (ITS#1882)
Fixed libldap ldap_controls_dup() malloc bug (ITS#1898)
Fixed libldap openssl compat bug (ITS#1924)
Fixed ucgendat EOF bug (ITS#1917)
Removed lint
Build Environment
Added cc missing check
Added monitor backend test
Updated <ac/socket.h> SHUT_RDWR
Fixed SASL-less build issues
Fixed back-perl build issues (ITS#1827)
Fixed libldap_r references.c issue (ITS#1922)
Added -ldb-4 detection (ITS#1888)
Disabled back-sql (ITS#1920)
Documentation
Numerous manual page updates
OpenLDAP 2.1.2 Release
Initial release for "general" use.
Various Make-template files - update by doing 'make depend'
include/disptmpl.h - add LDAP_DISP_OPT_HTMLBODYONLY option
libraries/liblber/io.c - under MacOS, limit tcpwrite() calls to a
maximum of 64K bytes; ber_flush() int/long fix
libraries/libldap/friendly.c - don't use errno on MacOS or DOS
libraries/libldap/regex.c - fix re_exec() to that ".*" matches ""
libraries/libldap/result.c - eliminate memory leak in wait4msg()
libraries/libldap/request.c - eliminate double-free impurity
libraries/libldap/tmplout.c - add LDAP_DISP_OPT_HTMLBODYONLY option
libraries/libldap/ufn.c - purify: avoid bad frees; plug memory leaks
libraries/libldif/line64.c - str_parse_line() now 0-terminates base64 vals.
libraries/macintosh/* - tcpwrite()/OpenTransport bug fixes
- better error checking for MacTCP driver opens
- don't use old routine names any more
libraries/msdos/winsock/* - various bugs fixes & improvements
servers/slapd/modify.c - fix bug causing unnormalized attr names
servers/slapd/monitor.c - return new "version" attribute
servers/slapd/regex.c - fix re_exec() to that ".*" matches ""
servers/slapd/tools/ldbmcat.c - make -n option work (don't open file "-n" )
servers/slapd/tools/ldif2id2entry.c - include ids in stored entries
servers/slapd/schema.c - log some information useful in tracking
down schema-check problems
servers/slapd/dn.c - dn_upcase() was not returning anything (doh!)
servers/slapd/backend.c - pass unbind request to all backends
servers/slapd/unbind.c - pass unbind request to all backends
servers/slapd/Version.c - remove leading spaces from Versionstr[]
servers/slapd/back-ldbm/unbind.c - make arguments consistent
servers/slapd/back-ldbm/bind.c - fix bug which allowed anyone to bind as
anyone else using kerberos, if there was
at least one krbName in an entry
servers/slurpd/replog.c - do all replog copying with buffered i/o
servers/slurpd/fm.c - fix inconsistency in arguments
servers/slurpd/main.c - fix inconsistency in arguments
clients/tools/ldapdelete.c - add -K flag - only does LDAP_AUTH_KRBV41
clients/tools/ldapmodify.c - add -K flag - only does LDAP_AUTH_KRBV41
clients/tools/ldapmodrdn.c - add -K flag - only does LDAP_AUTH_KRBV41
clients/tools/ldapsearch.c - add -K flag - only does LDAP_AUTH_KRBV41
doc/man/man1/ldapdelete.1 - add -K flag - only does LDAP_AUTH_KRBV41
doc/man/man1/ldapmodify.1 - add -K flag - only does LDAP_AUTH_KRBV41
doc/man/man1/ldapmodrdn.1 - add -K flag - only does LDAP_AUTH_KRBV41
doc/man/man1/ldapsearch.1 - add -K flag - only does LDAP_AUTH_KRBV41
doc/man/man3/ldap_entry2text.3 - document LDAP_DISP_OPT_HTMLBODYONLY option
doc/man/man8/slapd.8 - add BUGS section and document modrdn bug
----------------------------------------------------------------------------
Changes since 3.2
Makefile - added support for IRIX (SGI)
- make depend improvements
tests/ - all new test scripts -- make test
include/lber.h - use short include file names #ifdef WINSOCK
include/ldap.h - change LDAPCache struct definition to reduce
cache overhead
- use short include file names #ifdef WINSOCK
- LDAP URL support
- add lr_conn to LDAPRequest (needed by abandon)
- add LDAP_OPT_RESTART for select() restart
- revised Debug() macro #ifdef WINSOCK
include/ldbm.h - under NDBM, use O_RDWR instead of O_CREAT
- in LDBM_WRCREAT and LDBM_NEWDB
include/proto-lber.h - changes for WIN32
include/proto-ldap.h - changes for WIN32
- added LDAP URL routines
include/disptmpl.h - changes for WIN32
include/ldif.h - includes for new libldif library
include/srchpref.h - changes for WIN32
libraries/liblber/decode.c - vararg changes for WIN32
libraries/liblber/encode.c - vararg changes for WIN32
libraries/libldap/abandon.c - make ldap_abandon() work with referrals
libraries/libldap/bind.c - added new ldap_set_rebind_proc() routine
libraries/libldap/cache.c - reduce cache overhead
- fix small cache size infinite loop bug
- clarify debugging messages
libraries/libldap/charset.c - new routines: ldap_translate_from_t61,
ldap_translate_to_t61,
ldap_enable_translation
libraries/libldap/cldap.c - changes to support referral re-bind w/auth
libraries/libldap/getfilter.c - ldap_build_filter: don't use NULL value
libraries/libldap/kbind.c - changes to support referral re-bind w/auth
libraries/libldap/ldap-int.h - changes to support referral re-bind w/auth
- rename do_select() to do_ldap_select()
libraries/libldap/open.c - changes to support referral re-bind w/auth
- ld_options = LDAP_OPT_REFERRALS by default
libraries/libldap/os-ip.c - include <sys/time.h> to fix HP/UX gcc builds
- rename do_select() to do_ldap_select()
libraries/libldap/result.c - wait4msg debugging now shows timeout values
- changes to support referral re-bind w/auth
- rename do_select() to do_ldap_select()
- buf fix in ldap_msgdelete() -- update prev
- support LDAP_OPT_RESTART option
libraries/libldap/request.c - changes to support referral re-bind w/auth
- initialize new lr_conn field (for abandon)
libraries/libldap/test.c - changes to support referral re-bind w/auth
libraries/libldap/tmplout.c - searchact uses "-dnt" and "-dnb", not "-dn"
libraries/libldap/url.c - new routines: ldap_is_ldap_url,
ldap_parse_url, ldap_url_search
ldap_url_search_s, ldap_url_search_st
libraries/libldif/ - new library that contains line64 routines
clients/tools/ldapmodify.c - preferred input format is now slapd.replog
clients/tools/ldapsearch.c - added -L option (output in LDIF format)
- don't print initial blank line when -f used
- support "-f -" for reading filters from stdin
clients/ud/*.c - various bug fixes & auth. streamlining
doc/man/man3/ldap.3 - add several new routines
doc/man/man3/ldap_bind.3/.links - add new ldap_set_rebind_proc() routine
doc/man/man3/ldap_charset.3/.links - add new routines
doc/man/man3/ldap_disptmpl.3 - added missing *'s in ldap_init... arg. lists
doc/man/man3/ldap_result.3 - add details r.e. timeout parameter
doc/man/man3/ldap_open.3 - document LDAP_OPT_REFERRALS default to on
doc/man/man3/ldap_url.3/.links - document new LDAP URL routines
Make-common.dist and .um - add LDBMINCLUDE variable
- use ISODEPACKAGE and ICRELEASE in place of
ICR1 and XTISODE defines
- remove LDAP_DNS stuff
build/Make-append - add LDBMINCLUDE variable
- add NO_SETPROCTITLE to SERVERDEFS
- use ISODEPACKAGE and ICRELEASE in place of
ICR1 and XTISODE defines
build/mkdep - use compiler passed in, not always cc
- remove system dependencies when gcc is used
build/platforms/attsvr4-cc/ - AT&T SVR4 support
build/platforms/irix-cc/ - SGI IRIX support
build/platforms/irix-gcc/ - SGI IRIX support
servers/ldapd/common.h - add missing extern function declarations
servers/ldapd/association.c - use ISODEPACKAGE test instead of ICR1, etc.
servers/ldapd/certificate.c - add missing extern declaration
servers/ldapd/error.c - use ISODEPACKAGE test instead of ICR1, etc.
servers/ldapd/kerberos.c - use ISODEPACKAGE test instead of ICR1, etc.
servers/ldapd/request.c - use ISODEPACKAGE test instead of ICR1, etc.
servers/ldapd/main.c - set proctitle to calling host (bug fix)
- CLDAP: don't timeout/exit prematurely
servers/ldapd/proctitle.c - don't compile file if NO_SETPROCTITLE is on
servers/ldapd/Make-template - don't try to make depend if don't have isode
servers/ldap - bug fixes, support ICR3
servers/slapd/tools/ldif.c - use correct pointer when calling realloc
servers/slapd/tools/edb2ldif.c - properly #ifdef code to handle potential
lack of file_attr_dir and turbo disk stuff
- add RDN attribute values to entries
- don't pre-pend './' to EDB files on cmd. line
servers/slapd/tools/ldapsyntax.c- use static buffer to speed things up
servers/slapd/tools/Make-template - don't try to make depend some tools
- if we don't have isode
servers/slapd - fix acl handling
servers/slapd - fix race condition setting o_dn
servers/slapd - bug fixes
servers/slurpd - complete re-write
tests/ - new - test scripts to verify basic
functionality of libraries, slapd, slurpd
----------------------------------------------------------------------------
Changes since 3.2b3
slapd admin guide - document ldbmtest changes
- clarify quick-start instructions
include/ldapconfig.h.dist - move likely-to-change things to top
Make-common.dist - add phonetic algorithm config lines
build/Make-append - add def for phonetic algorithm config lines
libraries/libldbm/ldbm.c - fix bug with gdbm cache size handling
libraries/liblber/encode.c - cap lengths at 32-bits for Alpha compatibility
libraries/libldap/disptmpl.c - recognize both "addact" and "adddnact"
libraries/libldap/getdn.c - handle \ escapes in DNs better
clients/tools/ldapsearch.c - added -S option to sort results
- print results as they are received (if no -S)
servers/slapd/* - added function prototypes
servers/slapd/phonetic.c - make phonetic alg settable in Make-common
servers/slapd/tools/ldbmtest.c - fix bugs, use dbcache routines (like slapd)
- add 'b' and 'B' commands
servers/slapd/tools/edb2ldif.c - include quipu/config.h & quipu/entry.h
- this fixes TURBO_DISK problems
servers/ldapd/* - misc. fixes for VMS and OSF/1
- added function prototypes
----------------------------------------------------------------------------
Changes since 3.2b2
servers/slapd/* - lots of changes/fixes/improvements
servers/slapd/tools/* - add ldif program
- add centipede program
- numerous fixes/improvements
clients/tools/ldapmodify.c - add -b option (read binary vals from a file)
- add trailing \ feature for iattr, etc.
clients/tools/ldapsearch.c - add -z sizelimit and -l timelimit options
- add -B (allow non-ascii values_ option
- change /tmp template used with -t
include/lber.h - add LBER_MAX_INCOMING_SIZE option
libraries/liblber/io.c - support LBER_MAX_INCOMING_SIZE option
- new ber_init() and ber_reset() routines
libraries/libldap/* - various improvements to LDAP_REFERRALS code
- minor changes for Mac re-port
libraries/libldap/disptmpl.c - "addact" is now "adddnact"
libraries/libldap/cache.c - we now cache compare results that have error
of LDAP_NO_SUCH_ATTRIBUTE
libraries/libldap/open.c - support :port on ldap_open() hosts
libraries/libldap/charset.c - new T.61 to ISO-8859 conversion support
- thanks to enrique.silvestre@uv.es
libraries/libldap/kbind.c - a few changes for MS Windows
libraries/msdos/winsock/* - a few changes for Kerberos support
servers/ldapd/modify.c - added support for JPEG non-file attrs.
- added support for octetstring attrs.
servers/ldapd/syntax.c - DN syntax fixes (OID. and replace {ASN} w/#)
- don't escape '$' in DeliveryMethod attrs.
- added support for JPEG non-file attrs.
- added support for octetstring attrs.
----------------------------------------------------------------------------
Changes since 3.2b1
servers/slapd/ - add better database concurrency
- remove multiple dn support
- add stats logging
- fix syslogging
- add include config file option
- add dbcachesize option
- add abandon
- add lastmod/creator attrs
- add monitoring capability
- normalize dns properly
- base 64 value encoding support
- add schema checking
- fix various bugs
- add srvtab config option
servers/slapd/tools - whole new set of db creation/conversion tools
clients/finger/main.c - added -c option & use of FINGER_RDNCOUNT
clients/gopher/go500.c - added -c option & use of GO500_RDNCOUNT
clients/gopher/go500gw.c - added -c option & use of GO500GW_RDNCOUNT
- removed non-functional -s option
clients/rcpt500/main.c - added -c option & use of RCPT500_RDNCOUNT
clients/rcpt500/query.c - use rdncount instead of hard-coded 2
include/ldapconfig.h.edit - added _RDNCOUNT #defines
libraries/libldap/tmplout.c - made rdncount of 0 show all DN components
libraries/libldap/getdn.c - added ldap_is_dns_dn() routine
libraries/libldap/* - many #ifndef NO_REFERRALS changes
- new ldap_init() routine
----------------------------------------------------------------------------
Changes since 3.1 final
General/various files - incorporated changes for Borland C 3.1
Makefile - added support for NeXTSTEP
libraries/liblber/io.c - add ability to save ldap session to a file
include/lber.h - add ability to save ldap session to a file
build/platforms/nextstep-cc/Make-platform
- added -all_load option for ld
build/platforms/sunos5-cc/Make-platform
- define SYSEXITSPATH as for sunos5-gcc
build/uname.sh - new replacement uname for NeXTSTEP, etc.
clients/finger/main.c - don't use fprintf for entry2text
clients/gopher/go500.c - use GO500_HOSTNAME (bug fix)
- don't use fprintf for entry2text
clients/gopher/go500gw.c - use GO500GW_HOSTNAME (bug fix)
- don't use fprintf for entry2text
clients/mail500/main.c - improved error logging
- fixed "errors-to is a group" bug
- don't look in people space for groups
- don't bounce loop messages back to sender
- misc. fixes
clients/tools/ldapdelete.c - add -c option to continue after errors occur
clients/tools/ldapmodify.c - add -c option to continue after errors occur
clients/tools/ldapmodrdn.c - add -c option to continue after errors occur
clients/tools/ldapsearch.c - added -t option to write values to tmp files
- added -A option for "attributes only"
clients/ud/print.c - make sure ldap_count_values() returns > 0
- before trying to use returned values
doc/man/man1/ldapdelete.1 - updated to mention new -c option
doc/man/man1/ldapmodify.1 - updated to mention new -c option
doc/man/man1/ldapmodrdn.1 - updated to mention new -c option
doc/man/man1/ldapsearch.1 - updated to mention new -A & -t options
doc/man/man3/ldap_friendly.3 - fixed typo in ldap_free_friendlymap()
doc/man/man5/ldapfilter.conf.5 - add missing part of example config file
include/disptmpl.h - appended 'L' to long #defined contants
- added entry2html family of routines
include/lber.h - added sb_options to allow copy to file
- added ber_wptr to re-start partial writes
include/ldap.h - added debug levels for sldapd
- added LDAP_SYSLOG to send debug using syslog
include/ldapconfig.h.edit - added GO500GW_HOSTNAME
include/ldapconfig.h.dist - added GO500GW_HOSTNAME
include/portable.h - select() macro fix for HP/UX /bin/cc
include/proto-lber.h - Borland C fixes
- added ber_bvdup() prototype
include/sysexits-compat.h - new file, in case we ever need it
libraries/libavl/* - new library; used in sldapd
libraries/liblber/decode.c - new 'o' feature for ber_scanf()
- new ber_bvdup() routine
- Borland C fixes
libraries/liblber/encode.c - Borland C fixes
libraries/liblber/io.c - ensure that write size <= 64K under VMS
- use ber_wptr to restart partial writes
- added LBER_TO_FILE/FILE_ONLY option support
libraries/libldap/abandon.c - use correct message id in abandon requests
libraries/libldap/cache.c - use time() in a more portable manner
libraries/libldap/cldap.c - retry correct number of times (off by one)
libraries/libldap/error.c - define empty ldap_perror if NO_USERINTERFACE
libraries/libldap/getdn.c - ldap_dn2ufn() now returns dn if no '='
- ldap_explode_dn handles DNs without '='
libraries/libldap/open.c - "host" can now be a space-separated list
libraries/libldap/sort.c - make function declarations more portable
libraries/libldap/srchpref.c - fixed memory leak in options parsing
libraries/libldap/test.c - added -t & -T options for ber output to file
- added 'E' command to explode a DN
libraries/libldap/tmplout.c - added entry2html()
- added entry2html_search()
- added entry2vals()
- remove extraneous ber_free when not using tmpl
- fix non-ASCII core dump bugs
libraries/libldap/ldapfriendly - added EE & RU
libraries/libldap/ldapfilter.conf
- remove '\' inside [] in reg exprs.
- add web500gw to filter tags
- added xax500-auth section
libraries/libldap/ldapsearchprefs.conf
- changed xax500 tags
libraries/libldap/ldaptemplates.conf
- added co to Country template
- add missing types & options to comments
- add "Last Modified" attrs. to all templates
- make "Last Modified" attrs. read-only
libraries/libldbm/* - new library; used in sldapd
libraries/liblthread/* - new library; used in sldapd
libraries/msdos/README.WSA - updated to include Borland C instructions
libraries/vms/README.VMS - fixed pathname typo
servers/ldapd/add.c - make BER tags unsigned long everywhere
servers/ldapd/certificate.c - make parsing consistent with printing code
servers/ldapd/main.c - moved openlog() after detach() call
servers/ldapd/modify.c - correct tag usage in ber_first/next loop
- output all debugging to stderr
- pass and use Sockbuf * in modify_result() call
servers/ldapd/result.c - change to always use DER encoding
servers/ldapd/search.c - change to always use DER encoding
servers/ldapd/syntax.c - add support for telexNumber
servers/sldapd - all new "standalone LDAP server"
----------------------------------------------------------------------------
Changes since 3.1b8
Make-common - added note r.e. -DNO_USERINTERFACE
servers/ldapd/association.c - don't include filio.h under AIX
build/platforms/aix-cc and -gcc - add _BSD to defines
include/portable.h - define OPENLOG_OPTIONS
clients/*/*.c - use OPENLOG_OPTIONS
servers/ldapd/main.c - use OPENLOG_OPTIONS
servers/ldapd/syntax.c - add iattr support (from craig watkins)
----------------------------------------------------------------------------
Changes since 3.1b7
Many System V portability fixes....
A few fixes for VMS....
Makefile - support Linux & NetBSD
Make-common - add support for NEXOR version of isode
- add ISODEBASELIBS
include/Make-template - make ldapconfig.h depend on Makefile
include/ldapconfig.h.edit - add RCPT500_LISTLIMIT, RCPT500_UFN
- add GO500_TIMEOUT, GO500_UFN
- add FINGER_UFN, FINGER_TIMEOUT,
- add GO500GW_UFN
- change *_DEREF to be LDAP_DEREF_FINDING
include/regex.h - use NEED_BSDREGEX
include/portable.h - SYSV changes & general re-vamping
include/disptmpl.h - fix typo in ldap_name2template() prototype
- add LDAP_SYN_RFC822ADDR
libraries/liblber/io.c - make ber_alloc actually use BER
libraries/libldap/cldap.c - preserve old log DN if NULL is passed
libraries/libldap/regex.c - use NEED_BSDREGEX
libraries/libldap/disptmpl.c - add support for LDAP_SYN_RFC822ADDR
libraries/libldap/tmplout.c - add support for LDAP_SYN_RFC822ADDR
libraries/libldap/getfilter.c - always #include "regex.h"
servers/ldapd/main.c - don't check openlog return code
servers/ldapd/request.c - only do syslog if dosyslog is set
servers/ldapd/syntax.c - add support for user certificates (from ER)
servers/ldapd/certificate.c - add support for user certificates (new file)
clients/finger/main.c - add -t disptmplfile option
- add -p port option
- add ufn support
clients/gopher/go500.c - add -t disptmplfile option
- add ufn support
clients/gopher/go500gw.c - add -t disptmplfile option
- add ufn support
clients/mail500/main.c - add -t disptmplfile option
- add support for mail to -owner
clients/rcpt500/main.c,query.c - add support for RCPT500_LISTLIMIT
- support -p ldapport option
- add ufn support
clients/tools/ldapsearch.c - recognize -w option properly
clients/tools/ldapdelete.c - recognize -k option properly
clients/tools/ldapmodrdn.c - new program
clients/ud/edit.c - use execlp() instead of execle()
clients/ud/main.c - include sys/ioctl.h under NetBSD
clients/ud/print.c - updated time2text() from libldap/tmplout.c
contrib/saucer - new contributed client from Eric Rosenquist
build/platforms - added netbsd-cc & netbsd-gcc
- updated sunos5-cc and sunos5-gcc
- added missing CC=gcc in hpux-gcc
- added vms
build/Make-append - change ISODELIBS
doc/man/man8/rcpt500.8 - new manual page
doc/man/man3/ldap.3 - add (3) to routine names in INDEX section
doc/man/man3/ldap_search.3 - remove reference to ldap_parse(3)
doc/man/man3/ldap_modrdn.3 - new manual page
doc/man/man3/ldap_modrdn.3.links- new links file
doc/man/man3/ldap_disptmpl.3 - re-word ldap_octemplate description
- document LDAP_SYN_RFC822ADDR
doc/man/man5/ldap_searchprefs.5 - fix formatting
doc/man/man5/ldaptemplatesconf.5- document "mail" syntax type
doc/man/* - use ETCDIR everywhere (was %ETCDIR%)
-------
ldap-3.1b7 CHANGES file - summary of major changes to each component
since the last release
source tree - completely reorganized for your convenience
- makes full use of ansi-style prototypes
- supports non-ansi compilers through unproto utility
configuration - all client configuration has been moved to ldapconfig.h.edit
(no need to edit multiple source code files)
build procedure - completely revamped for your convenience
- automaticly figures out your platform/compiler
- supports multiple objects from a single source tree
liblbdap - added support for display templates
- added support for search preferences
- added ldap_sort routines for sorting entries
- rearranged some routines/source files to allow
better incremental linking to reduce code bloat
- added support for CLDAP
liblber - added O option to ber_scanf: allocate octet string w/length
- big tags (greater than 31) now supported
- distinguished encoding rules supported (runtime choice
between ber and der)
in.xfingerd - now uses display template routines
- now uses ldap sorting routines
- editable configuration info moved to ldapconfig.h.edit
go500 - now uses display template routines
- now uses ldap sorting routines
- editable configuration info moved to ldapconfig.h.edit
go500gw - now uses display template routines
- now uses ldap sorting routines
- editable configuration info moved to ldapconfig.h.edit
rcpt500 - now uses display template routines
- now uses ldap sorting routines
- editable configuration info moved to ldapconfig.h.edit
mail500 - addition of a new "vacation" feature
- editable configuration info moved to ldapconfig.h.edit
ldap tools - new addition of some shell-based tools
whois++ g/w - moved to contrib/ directory
web500 - new addition, in contrib/ directory
ldapd - lots of bug fixes
- bring CLDAP code in line with latest Internet Draft
documentation - library man pages have been completely re-done, split
into separate manuals, with new pages for each set of
routines.
- new man pages for most client programs (more on the way)
windows ldap - support for Win32 (unfinished?)
- added VERSIONINFO resource to dll
- check for > 64K response packet and don't crash
macintosh ldap - support Apple's new Universal Header files
Copyright (c) 1992-1996 Regents of the University of Michigan. Copyright 1998-2002 The OpenLDAP Foundation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted only as authorized by the OpenLDAP
Public License. A copy of this license is available at
http://www.OpenLDAP.org/license.html or in file LICENSE in the
top-level directory of the distribution.
OpenLDAP is a registered trademark of the OpenLDAP Foundation.
Individual files and/or contributed packages may be copyright by
other parties and subject to additional restrictions.
This work is derived from the University of Michigan LDAP v3.3
distribution. Information concerning this software is available
at: http://www.umich.edu/~dirsvcs/ldap/
This work also contains materials derived from public sources.
Additional information about OpenLDAP can be obtained at:
http://www.openldap.org/
---
Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms are permitted Redistribution and use in source and binary forms are permitted
......
Making and Installing the U-M LDAP Distribution Making and Installing the OpenLDAP Distribution
===============================================
** It is recommended that you read or at least skim through ALL of the This file provides brief instructions on how to build and install
** instructions in this file before attempting to build the software. OpenLDAP on UNIX (and UNIX-like) system. More detailed information
and instructions can be found in The OpenLDAP Administrator's Guide
(available from http://www.openldap.org/doc/).
If you want to build binaries for more than one platform from a single It is recommended that you read, or at least skim through, ALL of the
source tree, skip ahead to the "Building LDAP For More Than One Platform" instructions in this file before attempting to build the software.
section near the end of this file. If you are planning to run slapd,
you should read the "SLAPD and SLURPD Administrator's Guide", found in
the doc/guides/ directory within the distribution.
If you simply want to build LDAP for a single machine platform, follow It is also recommended you review the Frequently Asked Questions
these steps: (http://www.openldap.org/faq/) pages, in particular the Installation
section (http://www.openldap.org/faq/index.cgi?file=8) and Platform
Hints (http://www.openldap.org/faq/index.cgi?file=9) should be
examined.
1. untar the distribution and cd to the top: Making and Installing the OpenLDAP Distribution
-----------------------------------------------
% zcat ldap-3.3.tar.Z | tar xf - 1. Unpack the distribution and change directory:
% cd ldap-3.3
If you are reading this file, you probably have already done this! % tar xfz openldap-VERSION.tgz
% cd openldap-VERSION
(replacing VERSION with the appropriate version string). If you
are reading this file, you probably have already done this!
2. edit the files Make-common and include/ldapconfig.h.edit to configure 2. Type:
the software for your site (the files are well-commented):
% vi Make-common % ./configure --help
% vi include/ldapconfig.h.edit
Note that you should NOT need to edit the Makefile located at the to list available configuration options.
top of the distribution.
If you just want to see if things will build, you can leave the The configure script uses environmental variables for determining
configuration alone and change it later. compiler/linker options including:
If you have the ISODE package built and want to build the Variable Description Example
LDAP-to-X.500 server (ldapd), be sure to uncomment the appropriate CC C compiler gcc
lines near the end of the Make-common file. By default only the CFLAGS C flags -O -g
stand-alone server, LDAP libraries and client software are built. CPPFLAGS cpp flags -I/path/include -Ddef
LDFLAGS ld flags -L/usr/local/lib
LIBS libraries -llib
PATH command path /usr/local/bin:/usr/bin:/bin
3. make the software: 3. Configure the build system
% make % [env settings] ./configure [options]
If all goes well, then make will figure out what platform you are on, If all goes well, the configure script with automatically detect
pick a compiler to use, construct Makefiles, and build everything. the appropriate settings. However, you may need to specify
If you see a message like "unknown platform..." LDAP has probably not options and/or environment variables to obtain desired results.
been set up to build on your machine. See the file build/PORTS for
hints on what to do in that case.
Note that if your make does not use the Bourne (sh) shell by 4. Build dependencies
default when executing internal scripts (reportedly the case on SGI
machines at least), you will need to run the make explicitly from
within a Bourne shell. If you a syntax error such as "Missing ]"
when you do the make under your usual shell, try this:
% sh % make depend
$ make
If you don't like the some of the platform-specific options chosen 5. Build the system
by the automatic build process (such as the compiler to use, etc),
you can intervene and edit them before anything is actually compiled
by explicitly doing a "make platform" step, editing the .make-platform
file (actually a link to the file to be edited), and then doing a
regular make:
% make platform % make
% vi .make-platform
% make
If you want to choose the build platform yourself from among those that If all goes well, the system will build as configured. If not,
the distribution supports, cd to the appropriate directory underneath return to step 3 after reviewing the configuration settings. You
build/platforms and make from there. For example, if you are on a may want to consult the Platform Hints subsection of the FAQ if
machine running SunOS 4.1.4 and you want to force the use of the cc you have not done so already.
compiler, you would do this:
% cd build/platforms/sunos4-cc 6. Test the standalone system
% make
If you want to run some simple tests after the build is complete, you This step requires the standalone LDAP server, slapd(8), with
can do this: BDB and/or LDBM support.
% make test % make test
4. install the binaries and man pages. You may need to be superuser to If all goes well, the system has been built as configured. If
do this (depending on where you are installing things): not, return to step 4 after reviewing your configuration
settings. You may want to consult the Installation section of
the FAQ if you have not done so already.
% su 7. install the binaries and man pages. You may need to be come the
# make install super-user (e.g. root) to do this (depending on where you are
installing things):
That's it! See the man pages for the individual clients for information % su root -c 'make install'
on configuring and using them. Eventually you will probably want to
edit the configuration files used by the various clients (installed in
the LDAP etc directory). The files are:
ldapfilter.conf - search filter configuration 8. That's it!
ldapfriendly - mapping of X.500 names to human-friendly names
ldapsearchprefs.conf - search object definitions
ldaptemplates.conf - display template definitions
There are section 5 man pages for all of these files. See the OpenLDAP Administrator's Guide and the manual pages for the
individual applications for configuration and use information. You may
also want to edit the configuration files used by the various
components. These configuration files are located in the OpenLDAP
configuration directory (normally /usr/local/etc/openldap).
ldap.conf client defaults
slapd.conf Standalone LDAP daemon
schema/*.schema Schema Definitions
Building LDAP For More Than One Platform End of OpenLDAP INSTALL file.
It is now possible to build LDAP for more than one platform from the same $OpenLDAP: pkg/openldap-guide/release/install.sdf,v 1.16 2002/02/18
source tree. This is accomplished by some rules in the Makefiles that 17:09:26 kurt Exp $
create a shadow (linked) directory tree where the binaries are placed.
Follow these steps for each different platform:
1. move to the directory that matches the platform and compiler you
want to build for and type make. The directories are all located
underneath the build/platforms directory. If your platform is not
there, you may need to do a port - see the build/PORTS file for
more information. For a Sun running SunOS 4.1.4, you might do
this:
% cd build/platforms/sunos4-cc
% make links
This will create a linked source area.
2. move to the new directory and make as for a single platform. Follow steps
1-4 above to accomplish this. For example:
% cd obj-sunos4-cc
% make
That's all there is to it. You can also create the linked source area(s)
by just typing "make links" at the top of the distribution, in which case
the Makefile will try to automatically determine the platform and
compiler.
End of LDAP INSTALL file.
UM-LDAP 3.3 README file OpenLDAP 2.1 README
This is the UM-LDAP version 3.3 distribution. For a description of For a description of what this distribution contains, see the
what this distribution contains, see the ANNOUNCEMENT file in this ANNOUNCEMENT file in this directory. For a description of
directory. For a description of changes from previous releases, changes from previous releases, see the CHANGES file in this
see the CHANGES file in this directory. For a more detailed directory.
description of how to make and install the distribution, see the
INSTALL file in this directory. For more information on making and
installing slapd, see the "SLAPD and SLURPD Administrator's Guide"
in the doc/guides/ directory.
MAKING AND INSTALLING THE DISTRIBUTION This is 2.1 release. 2.1 releases includes significant changes
from prior releases.
REQUIRED SOFTWARE
Build OpenLDAP requires a number of software packages to be
preinstalled. Additional information regarding prerequisite
software can be found in the OpenLDAP Administrator's Guide.
You should be able to make and install the distribution with a pretty Base system (libraries and tools):
standard default configuration by typing the following commands Standard C compiler (required)
Cyrus SASL 1.5 (recommended)
OpenSSL 0.9 (recommended)
POSIX REGEX software (required)
% make SLAPD:
% su BDB backend requires Sleepycat Berkeley DB 4.0 or better
# make install LDBM backend supports this and other compatible database managers
in this directory. This should produce something that basically SLURPD:
works. LTHREAD compatible thread package
[POSIX threads, Mach Cthreads, select others]
You will probably want to do a little configuration to suit your CLIENTS/CONTRIB ware:
site, though. There are two files you might want to edit: Depends on package. See per package README.
Make-common This file contains definitions for
where things will be installed, where
to find various things, etc. If you
want to build an ldap server, you'll
definitely need to edit this file
include/ldapconfig.h.edit This file contains #defines used MAKING AND INSTALLING THE DISTRIBUTION
by many parts of the distribution. Please see the INSTALL file for basic instructions. More
You'll at least want to change detailed instructions can be found in the OpenLDAP
DEFAULT_BASE. Admnistrator's Guide (see DOCUMENTATION section).
See the INSTALL file in this directory for more information.
DOCUMENTATION DOCUMENTATION
There are man pages for most programs in the distribution and
routines in the various libraries. See ldap(3) for details.
There are man pages for most programs in the distribution and The OpenLDAP website is available and contains the latest LDAP
routines in the various libraries. See ldap(3) for details. news, releases announcements, pointers to other LDAP resources,
etc.. It is located at:
http://www.OpenLDAP.org/
There is a postscript version of an administrator's guide for The OpenLDAP Administrator's Guide and other documentation
slapd in doc/guides/slapd.ps. is available at:
http://www.openldap.org/doc/
There is an LDAP homepage available that contains the latest The OpenLDAP Software FAQ is available at:
LDAP news, releases announcements, pointers to other LDAP resources, http://www.openldap.org/faq/index.cgi
etc. You can access it at this URL:
http://www.umich.edu/~rsug/ldap/
FEEDBACK / PROBLEM REPORTS SUPPORT / FEEDBACK / PROBLEM REPORTS / DISCUSSIONS
OpenLDAP is user supported. If you have problems, please
review the OpenLDAP FAQ <http://www.openldap.org/faq/> and
archives of the OpenLDAP-software and OpenLDAP-bugs mailing
lists <http://www.openldap.org/lists/>. If you cannot find
the answer, please enquire on the OpenLDAP-software list.
We would appreciate any feedback you can provide. If you have Issues, such as bug reports, should be reported using our
problems, report them to this address: our Issue Tracking System <http://www.OpenLDAP.org/its/> or
by sending mail to OpenLDAP-its@OpenLDAP.org. Do not use
this system for software enquiries. Please direct these
to an appropriate mailing list.
ldap-support@umich.edu ---
$OpenLDAP$
# ltmain.sh - Provide generalized library-building support services.
# NOTE: Changing this file will not affect anything until you rerun configure.
#
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is distributed with OpenLDAP Software, which contains a
# configuration script generated by Autoconf, and is distributable
# under the same distributions terms as OpenLDAP inself.
# See the OpenLDAP COPYRIGHT and LICENSE file for details.
# Check that we have a working $echo.
if test "X$1" = X--no-reexec; then
# Discard the --no-reexec flag, and continue.
shift
elif test "X$1" = X--fallback-echo; then
# Avoid inline document here, it may be left over
:
elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
# Yippee, $echo works!
:
else
# Restart under the correct shell, and then maybe $echo will work.
exec $SHELL "$0" --no-reexec ${1+"$@"}
fi
if test "X$1" = X--fallback-echo; then
# used as fallback echo
shift
cat <<EOF
$*
EOF
exit 0
fi
# The name of this program.
progname=`$echo "$0" | sed 's%^.*/%%'`
modename="$progname"
# Constants.
PROGRAM=ltmain.sh
PACKAGE=libtool
VERSION=1.4.2
TIMESTAMP=" (1.922.2.53 2001/09/11 03:18:52)"
default_mode=
help="Try \`$progname --help' for more information."
magic="%%%MAGIC variable%%%"
mkdir="mkdir"
mv="mv -f"
rm="rm -f"
# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
Xsed='sed -e 1s/^X//'
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
# test EBCDIC or ASCII
case `echo '' | od -x` in
*15*) # EBCDIC based system
SP2NL='tr \100 \025'
NL2SP='tr \025 \100'
;;
*) # Assume ASCII based system
SP2NL='tr \040 \012'
NL2SP='tr \015\012 \040\040'
;;
esac
# NLS nuisances.
# Only set LANG and LC_ALL to C if already set.
# These must not be set unconditionally because not all systems understand
# e.g. LANG=C (notably SCO).
# We save the old values to restore during execute mode.
if test "${LC_ALL+set}" = set; then
save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
fi
if test "${LANG+set}" = set; then
save_LANG="$LANG"; LANG=C; export LANG
fi
# Make sure IFS has a sensible default
: ${IFS=" "}
if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
echo "$modename: not configured to build any kind of library" 1>&2
echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
exit 1
fi
# Global variables.
mode=$default_mode
nonopt=
prev=
prevopt=
run=
show="$echo"
show_help=
execute_dlfiles=
lo2o="s/\\.lo\$/.${objext}/"
o2lo="s/\\.${objext}\$/.lo/"
# Parse our command line options once, thoroughly.
while test $# -gt 0
do
arg="$1"
shift
case $arg in
-*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
# If the previous option needs an argument, assign it.
if test -n "$prev"; then
case $prev in
execute_dlfiles)
execute_dlfiles="$execute_dlfiles $arg"
;;
*)
eval "$prev=\$arg"
;;
esac
prev=
prevopt=
continue
fi
# Have we seen a non-optional argument yet?
case $arg in
--help)
show_help=yes
;;
--version)
echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
exit 0
;;
--config)
sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
exit 0
;;
--debug)
echo "$progname: enabling shell trace mode"
set -x
;;
--dry-run | -n)
run=:
;;
--features)
echo "host: $host"
if test "$build_libtool_libs" = yes; then
echo "enable shared libraries"
else
echo "disable shared libraries"
fi
if test "$build_old_libs" = yes; then
echo "enable static libraries"
else
echo "disable static libraries"
fi
exit 0
;;
--finish) mode="finish" ;;
--mode) prevopt="--mode" prev=mode ;;
--mode=*) mode="$optarg" ;;
--quiet | --silent)
show=:
;;
-dlopen)
prevopt="-dlopen"
prev=execute_dlfiles
;;
-*)
$echo "$modename: unrecognized option \`$arg'" 1>&2
$echo "$help" 1>&2
exit 1
;;
*)
nonopt="$arg"
break
;;
esac
done
if test -n "$prevopt"; then
$echo "$modename: option \`$prevopt' requires an argument" 1>&2
$echo "$help" 1>&2
exit 1
fi
# If this variable is set in any of the actions, the command in it
# will be execed at the end. This prevents here-documents from being
# left over by shells.
exec_cmd=
if test -z "$show_help"; then
# Infer the operation mode.
if test -z "$mode"; then
case $nonopt in
*cc | *++ | gcc* | *-gcc*)
mode=link
for arg
do
case $arg in
-c)
mode=compile
break
;;
esac
done
;;
*db | *dbx | *strace | *truss)
mode=execute
;;
*install*|cp|mv)
mode=install
;;
*rm)
mode=uninstall
;;
*)
# If we have no mode, but dlfiles were specified, then do execute mode.
test -n "$execute_dlfiles" && mode=execute
# Just use the default operation mode.
if test -z "$mode"; then
if test -n "$nonopt"; then
$echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
else
$echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
fi
fi
;;
esac
fi
# Only execute mode is allowed to have -dlopen flags.
if test -n "$execute_dlfiles" && test "$mode" != execute; then
$echo "$modename: unrecognized option \`-dlopen'" 1>&2
$echo "$help" 1>&2
exit 1
fi
# Change the help message to a mode-specific one.
generic_help="$help"
help="Try \`$modename --help --mode=$mode' for more information."
# These modes are in order of execution frequency so that they run quickly.
case $mode in
# libtool compile mode
compile)
modename="$modename: compile"
# Get the compilation command and the source file.
base_compile=
prev=
lastarg=
srcfile="$nonopt"
suppress_output=
user_target=no
for arg
do
case $prev in
"") ;;
xcompiler)
# Aesthetically quote the previous argument.
prev=
lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
case $arg in
# Double-quote args containing other shell metacharacters.
# Many Bourne shells cannot handle close brackets correctly
# in scan sets, so we specify it separately.
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
arg="\"$arg\""
;;
esac
# Add the previous argument to base_compile.
if test -z "$base_compile"; then
base_compile="$lastarg"
else
base_compile="$base_compile $lastarg"
fi
continue
;;
esac
# Accept any command-line options.
case $arg in
-o)
if test "$user_target" != "no"; then
$echo "$modename: you cannot specify \`-o' more than once" 1>&2
exit 1
fi
user_target=next
;;
-static)
build_old_libs=yes
continue
;;
-prefer-pic)
pic_mode=yes
continue
;;
-prefer-non-pic)
pic_mode=no
continue
;;
-Xcompiler)
prev=xcompiler
continue
;;
-Wc,*)
args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
lastarg=
save_ifs="$IFS"; IFS=','
for arg in $args; do
IFS="$save_ifs"
# Double-quote args containing other shell metacharacters.
# Many Bourne shells cannot handle close brackets correctly
# in scan sets, so we specify it separately.
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
arg="\"$arg\""
;;
esac
lastarg="$lastarg $arg"
done
IFS="$save_ifs"
lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
# Add the arguments to base_compile.
if test -z "$base_compile"; then
base_compile="$lastarg"
else
base_compile="$base_compile $lastarg"
fi
continue
;;
esac
case $user_target in
next)
# The next one is the -o target name
user_target=yes
continue
;;
yes)
# We got the output file
user_target=set
libobj="$arg"
continue
;;
esac
# Accept the current argument as the source file.
lastarg="$srcfile"
srcfile="$arg"
# Aesthetically quote the previous argument.
# Backslashify any backslashes, double quotes, and dollar signs.
# These are the only characters that are still specially
# interpreted inside of double-quoted scrings.
lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
# Double-quote args containing other shell metacharacters.
# Many Bourne shells cannot handle close brackets correctly
# in scan sets, so we specify it separately.
case $lastarg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
lastarg="\"$lastarg\""
;;
esac
# Add the previous argument to base_compile.
if test -z "$base_compile"; then
base_compile="$lastarg"
else
base_compile="$base_compile $lastarg"
fi
done
case $user_target in
set)
;;
no)
# Get the name of the library object.
libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
;;
*)
$echo "$modename: you must specify a target with \`-o'" 1>&2
exit 1
;;
esac
# Recognize several different file suffixes.
# If the user specifies -o file.o, it is replaced with file.lo
xform='[cCFSfmso]'
case $libobj in
*.ada) xform=ada ;;
*.adb) xform=adb ;;
*.ads) xform=ads ;;
*.asm) xform=asm ;;
*.c++) xform=c++ ;;
*.cc) xform=cc ;;
*.cpp) xform=cpp ;;
*.cxx) xform=cxx ;;
*.f90) xform=f90 ;;
*.for) xform=for ;;
esac
libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
case $libobj in
*.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
*)
$echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
exit 1
;;
esac
if test -z "$base_compile"; then
$echo "$modename: you must specify a compilation command" 1>&2
$echo "$help" 1>&2
exit 1
fi
# Delete any leftover library objects.
if test "$build_old_libs" = yes; then
removelist="$obj $libobj"
else
removelist="$libobj"
fi
$run $rm $removelist
trap "$run $rm $removelist; exit 1" 1 2 15
# On Cygwin there's no "real" PIC flag so we must build both object types
case $host_os in
cygwin* | mingw* | pw32* | os2*)
pic_mode=default
;;
esac
if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then
# non-PIC code in shared libraries is not supported
pic_mode=default
fi
# Calculate the filename of the output object if compiler does
# not support -o with -c
if test "$compiler_c_o" = no; then
output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
lockfile="$output_obj.lock"
removelist="$removelist $output_obj $lockfile"
trap "$run $rm $removelist; exit 1" 1 2 15
else
need_locks=no
lockfile=
fi
# Lock this critical section if it is needed
# We use this script file to make the link, it avoids creating a new file
if test "$need_locks" = yes; then
until $run ln "$0" "$lockfile" 2>/dev/null; do
$show "Waiting for $lockfile to be removed"
sleep 2
done
elif test "$need_locks" = warn; then
if test -f "$lockfile"; then
echo "\
*** ERROR, $lockfile exists and contains:
`cat $lockfile 2>/dev/null`
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together. If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
$run $rm $removelist
exit 1
fi
echo $srcfile > "$lockfile"
fi
if test -n "$fix_srcfile_path"; then
eval srcfile=\"$fix_srcfile_path\"
fi
# Only build a PIC object if we are building libtool libraries.
if test "$build_libtool_libs" = yes; then
# Without this assignment, base_compile gets emptied.
fbsd_hideous_sh_bug=$base_compile
if test "$pic_mode" != no; then
# All platforms use -DPIC, to notify preprocessed assembler code.
command="$base_compile $srcfile $pic_flag -DPIC"
else
# Don't build PIC code
command="$base_compile $srcfile"
fi
if test "$build_old_libs" = yes; then
lo_libobj="$libobj"
dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
if test "X$dir" = "X$libobj"; then
dir="$objdir"
else
dir="$dir/$objdir"
fi
libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
if test -d "$dir"; then
$show "$rm $libobj"
$run $rm $libobj
else
$show "$mkdir $dir"
$run $mkdir $dir
status=$?
if test $status -ne 0 && test ! -d $dir; then
exit $status
fi
fi
fi
if test "$compiler_o_lo" = yes; then
output_obj="$libobj"
command="$command -o $output_obj"
elif test "$compiler_c_o" = yes; then
output_obj="$obj"
command="$command -o $output_obj"
fi
$run $rm "$output_obj"
$show "$command"
if $run eval "$command"; then :
else
test -n "$output_obj" && $run $rm $removelist
exit 1
fi
if test "$need_locks" = warn &&
test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
echo "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`
but it should contain:
$srcfile
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together. If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
$run $rm $removelist
exit 1
fi
# Just move the object if needed, then go on to compile the next one
if test x"$output_obj" != x"$libobj"; then
$show "$mv $output_obj $libobj"
if $run $mv $output_obj $libobj; then :
else
error=$?
$run $rm $removelist
exit $error
fi
fi
# If we have no pic_flag, then copy the object into place and finish.
if (test -z "$pic_flag" || test "$pic_mode" != default) &&
test "$build_old_libs" = yes; then
# Rename the .lo from within objdir to obj
if test -f $obj; then
$show $rm $obj
$run $rm $obj
fi
$show "$mv $libobj $obj"
if $run $mv $libobj $obj; then :
else
error=$?
$run $rm $removelist
exit $error
fi
xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
if test "X$xdir" = "X$obj"; then
xdir="."
else
xdir="$xdir"
fi
baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"`
libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
# Now arrange that obj and lo_libobj become the same file
$show "(cd $xdir && $LN_S $baseobj $libobj)"
if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
# Unlock the critical section if it was locked
if test "$need_locks" != no; then
$run $rm "$lockfile"
fi
exit 0
else
error=$?
$run $rm $removelist
exit $error
fi
fi
# Allow error messages only from the first compilation.
suppress_output=' >/dev/null 2>&1'
fi
# Only build a position-dependent object if we build old libraries.
if test "$build_old_libs" = yes; then
if test "$pic_mode" != yes; then
# Don't build PIC code
command="$base_compile $srcfile"
else
# All platforms use -DPIC, to notify preprocessed assembler code.
command="$base_compile $srcfile $pic_flag -DPIC"
fi
if test "$compiler_c_o" = yes; then
command="$command -o $obj"
output_obj="$obj"
fi
# Suppress compiler output if we already did a PIC compilation.
command="$command$suppress_output"
$run $rm "$output_obj"
$show "$command"
if $run eval "$command"; then :
else
$run $rm $removelist
exit 1
fi
if test "$need_locks" = warn &&
test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
echo "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`
but it should contain:
$srcfile
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together. If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
$run $rm $removelist
exit 1
fi
# Just move the object if needed
if test x"$output_obj" != x"$obj"; then
$show "$mv $output_obj $obj"
if $run $mv $output_obj $obj; then :
else
error=$?
$run $rm $removelist
exit $error
fi
fi
# Create an invalid libtool object if no PIC, so that we do not
# accidentally link it into a program.
if test "$build_libtool_libs" != yes; then
$show "echo timestamp > $libobj"
$run eval "echo timestamp > \$libobj" || exit $?
else
# Move the .lo from within objdir
$show "$mv $libobj $lo_libobj"
if $run $mv $libobj $lo_libobj; then :
else
error=$?
$run $rm $removelist
exit $error
fi
fi
fi
# Unlock the critical section if it was locked
if test "$need_locks" != no; then
$run $rm "$lockfile"
fi
exit 0
;;
# libtool link mode
link | relink)
modename="$modename: link"
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
# It is impossible to link a dll without this setting, and
# we shouldn't force the makefile maintainer to figure out
# which system we are compiling for in order to pass an extra
# flag for every libtool invokation.
# allow_undefined=no
# FIXME: Unfortunately, there are problems with the above when trying
# to make a dll which has undefined symbols, in which case not
# even a static library is built. For now, we need to specify
# -no-undefined on the libtool link line when we can be certain
# that all symbols are satisfied, otherwise we get a static library.
allow_undefined=yes
;;
*)
allow_undefined=yes
;;
esac
libtool_args="$nonopt"
compile_command="$nonopt"
finalize_command="$nonopt"
compile_rpath=
finalize_rpath=
compile_shlibpath=
finalize_shlibpath=
convenience=
old_convenience=
deplibs=
old_deplibs=
compiler_flags=
linker_flags=
dllsearchpath=
lib_search_path=`pwd`
avoid_version=no
dlfiles=
dlprefiles=
dlself=no
export_dynamic=no
export_symbols=
export_symbols_regex=
generated=
libobjs=
ltlibs=
module=no
no_install=no
objs=
prefer_static_libs=no
preload=no
prev=
prevarg=
release=
rpath=
xrpath=
perm_rpath=
temp_rpath=
thread_safe=no
vinfo=
# We need to know -static, to get the right output filenames.
for arg
do
case $arg in
-all-static | -static)
if test "X$arg" = "X-all-static"; then
if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
$echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
fi
if test -n "$link_static_flag"; then
dlopen_self=$dlopen_self_static
fi
else
if test -z "$pic_flag" && test -n "$link_static_flag"; then
dlopen_self=$dlopen_self_static
fi
fi
build_libtool_libs=no
build_old_libs=yes
prefer_static_libs=yes
break
;;
esac
done
# See if our shared archives depend on static archives.
test -n "$old_archive_from_new_cmds" && build_old_libs=yes
# Go through the arguments, transforming them on the way.
while test $# -gt 0; do
arg="$1"
shift
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
;;
*) qarg=$arg ;;
esac
libtool_args="$libtool_args $qarg"
# If the previous option needs an argument, assign it.
if test -n "$prev"; then
case $prev in
output)
compile_command="$compile_command @OUTPUT@"
finalize_command="$finalize_command @OUTPUT@"
;;
esac
case $prev in
dlfiles|dlprefiles)
if test "$preload" = no; then
# Add the symbol object into the linking commands.
compile_command="$compile_command @SYMFILE@"
finalize_command="$finalize_command @SYMFILE@"
preload=yes
fi
case $arg in
*.la | *.lo) ;; # We handle these cases below.
force)
if test "$dlself" = no; then
dlself=needless
export_dynamic=yes
fi
prev=
continue
;;
self)
if test "$prev" = dlprefiles; then
dlself=yes
elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
dlself=yes
else
dlself=needless
export_dynamic=yes
fi
prev=
continue
;;
*)
if test "$prev" = dlfiles; then
dlfiles="$dlfiles $arg"
else
dlprefiles="$dlprefiles $arg"
fi
prev=
continue
;;
esac
;;
expsyms)
export_symbols="$arg"
if test ! -f "$arg"; then
$echo "$modename: symbol file \`$arg' does not exist"
exit 1
fi
prev=
continue
;;
expsyms_regex)
export_symbols_regex="$arg"
prev=
continue
;;
release)
release="-$arg"
prev=
continue
;;
rpath | xrpath)
# We need an absolute path.
case $arg in
[\\/]* | [A-Za-z]:[\\/]*) ;;
*)
$echo "$modename: only absolute run-paths are allowed" 1>&2
exit 1
;;
esac
if test "$prev" = rpath; then
case "$rpath " in
*" $arg "*) ;;
*) rpath="$rpath $arg" ;;
esac
else
case "$xrpath " in
*" $arg "*) ;;
*) xrpath="$xrpath $arg" ;;
esac
fi
prev=
continue
;;
xcompiler)
compiler_flags="$compiler_flags $qarg"
prev=
compile_command="$compile_command $qarg"
finalize_command="$finalize_command $qarg"
continue
;;
xlinker)
linker_flags="$linker_flags $qarg"
compiler_flags="$compiler_flags $wl$qarg"
prev=
compile_command="$compile_command $wl$qarg"
finalize_command="$finalize_command $wl$qarg"
continue
;;
*)
eval "$prev=\"\$arg\""
prev=
continue
;;
esac
fi # test -n $prev
prevarg="$arg"
case $arg in
-all-static)
if test -n "$link_static_flag"; then
compile_command="$compile_command $link_static_flag"
finalize_command="$finalize_command $link_static_flag"
fi
continue
;;
-allow-undefined)
# FIXME: remove this flag sometime in the future.
$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
continue
;;
-avoid-version)
avoid_version=yes
continue
;;
-dlopen)
prev=dlfiles
continue
;;
-dlpreopen)
prev=dlprefiles
continue
;;
-export-dynamic)
export_dynamic=yes
continue
;;
-export-symbols | -export-symbols-regex)
if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
$echo "$modename: more than one -exported-symbols argument is not allowed"
exit 1
fi
if test "X$arg" = "X-export-symbols"; then
prev=expsyms
else
prev=expsyms_regex
fi
continue
;;
# The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
# so, if we see these flags be careful not to treat them like -L
-L[A-Z][A-Z]*:*)
case $with_gcc/$host in
no/*-*-irix*)
compile_command="$compile_command $arg"
finalize_command="$finalize_command $arg"
;;
esac
continue
;;
-L*)
dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
# We need an absolute path.
case $dir in
[\\/]* | [A-Za-z]:[\\/]*) ;;
*)
absdir=`cd "$dir" && pwd`
if test -z "$absdir"; then
$echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
exit 1
fi
dir="$absdir"
;;
esac
case "$deplibs " in
*" -L$dir "*) ;;
*)
deplibs="$deplibs -L$dir"
lib_search_path="$lib_search_path $dir"
;;
esac
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
case :$dllsearchpath: in
*":$dir:"*) ;;
*) dllsearchpath="$dllsearchpath:$dir";;
esac
;;
esac
continue
;;
-l*)
if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
case $host in
*-*-cygwin* | *-*-pw32* | *-*-beos*)
# These systems don't actually have a C or math library (as such)
continue
;;
*-*-mingw* | *-*-os2*)
# These systems don't actually have a C library (as such)
test "X$arg" = "X-lc" && continue
;;
*-*-openbsd*)
# Do not include libc due to us having libc/libc_r.
test "X$arg" = "X-lc" && continue
;;
esac
elif test "X$arg" = "X-lc_r"; then
case $host in
*-*-openbsd*)
# Do not include libc_r directly, use -pthread flag.
continue
;;
esac
fi
deplibs="$deplibs $arg"
continue
;;
-module)
module=yes
continue
;;
-no-fast-install)
fast_install=no
continue
;;
-no-install)
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
# The PATH hackery in wrapper scripts is required on Windows
# in order for the loader to find any dlls it needs.
$echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
$echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
fast_install=no
;;
*) no_install=yes ;;
esac
continue
;;
-no-undefined)
allow_undefined=no
continue
;;
-o) prev=output ;;
-release)
prev=release
continue
;;
-rpath)
prev=rpath
continue
;;
-R)
prev=xrpath
continue
;;
-R*)
dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
# We need an absolute path.
case $dir in
[\\/]* | [A-Za-z]:[\\/]*) ;;
*)
$echo "$modename: only absolute run-paths are allowed" 1>&2
exit 1
;;
esac
case "$xrpath " in
*" $dir "*) ;;
*) xrpath="$xrpath $dir" ;;
esac
continue
;;
-static)
# The effects of -static are defined in a previous loop.
# We used to do the same as -all-static on platforms that
# didn't have a PIC flag, but the assumption that the effects
# would be equivalent was wrong. It would break on at least
# Digital Unix and AIX.
continue
;;
-thread-safe)
thread_safe=yes
continue
;;
-version-info)
prev=vinfo
continue
;;
-Wc,*)
args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
arg=
save_ifs="$IFS"; IFS=','
for flag in $args; do
IFS="$save_ifs"
case $flag in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
flag="\"$flag\""
;;
esac
arg="$arg $wl$flag"
compiler_flags="$compiler_flags $flag"
done
IFS="$save_ifs"
arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
;;
-Wl,*)
args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
arg=
save_ifs="$IFS"; IFS=','
for flag in $args; do
IFS="$save_ifs"
case $flag in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
flag="\"$flag\""
;;
esac
arg="$arg $wl$flag"
compiler_flags="$compiler_flags $wl$flag"
linker_flags="$linker_flags $flag"
done
IFS="$save_ifs"
arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
;;
-Xcompiler)
prev=xcompiler
continue
;;
-Xlinker)
prev=xlinker
continue
;;
# Some other compiler flag.
-* | +*)
# Unknown arguments in both finalize_command and compile_command need
# to be aesthetically quoted because they are evaled later.
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
arg="\"$arg\""
;;
esac
;;
*.lo | *.$objext)
# A library or standard object.
if test "$prev" = dlfiles; then
# This file was specified with -dlopen.
if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
dlfiles="$dlfiles $arg"
prev=
continue
else
# If libtool objects are unsupported, then we need to preload.
prev=dlprefiles
fi
fi
if test "$prev" = dlprefiles; then
# Preload the old-style object.
dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
prev=
else
case $arg in
*.lo) libobjs="$libobjs $arg" ;;
*) objs="$objs $arg" ;;
esac
fi
;;
*.$libext)
# An archive.
deplibs="$deplibs $arg"
old_deplibs="$old_deplibs $arg"
continue
;;
*.la)
# A libtool-controlled library.
if test "$prev" = dlfiles; then
# This library was specified with -dlopen.
dlfiles="$dlfiles $arg"
prev=
elif test "$prev" = dlprefiles; then
# The library was specified with -dlpreopen.
dlprefiles="$dlprefiles $arg"
prev=
else
deplibs="$deplibs $arg"
fi
continue
;;
# Some other compiler argument.
*)
# Unknown arguments in both finalize_command and compile_command need
# to be aesthetically quoted because they are evaled later.
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
arg="\"$arg\""
;;
esac
;;
esac # arg
# Now actually substitute the argument into the commands.
if test -n "$arg"; then
compile_command="$compile_command $arg"
finalize_command="$finalize_command $arg"
fi
done # argument parsing loop
if test -n "$prev"; then
$echo "$modename: the \`$prevarg' option requires an argument" 1>&2
$echo "$help" 1>&2
exit 1
fi
if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
eval arg=\"$export_dynamic_flag_spec\"
compile_command="$compile_command $arg"
finalize_command="$finalize_command $arg"
fi
# calculate the name of the file, without its directory
outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
libobjs_save="$libobjs"
if test -n "$shlibpath_var"; then
# get the directories listed in $shlibpath_var
eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
else
shlib_search_path=
fi
eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
if test "X$output_objdir" = "X$output"; then
output_objdir="$objdir"
else
output_objdir="$output_objdir/$objdir"
fi
# Create the object directory.
if test ! -d $output_objdir; then
$show "$mkdir $output_objdir"
$run $mkdir $output_objdir
status=$?
if test $status -ne 0 && test ! -d $output_objdir; then
exit $status
fi
fi
# Determine the type of output
case $output in
"")
$echo "$modename: you must specify an output file" 1>&2
$echo "$help" 1>&2
exit 1
;;
*.$libext) linkmode=oldlib ;;
*.lo | *.$objext) linkmode=obj ;;
*.la) linkmode=lib ;;
*) linkmode=prog ;; # Anything else should be a program.
esac
specialdeplibs=
libs=
# Find all interdependent deplibs by searching for libraries
# that are linked more than once (e.g. -la -lb -la)
for deplib in $deplibs; do
case "$libs " in
*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
esac
libs="$libs $deplib"
done
deplibs=
newdependency_libs=
newlib_search_path=
need_relink=no # whether we're linking any uninstalled libtool libraries
notinst_deplibs= # not-installed libtool libraries
notinst_path= # paths that contain not-installed libtool libraries
case $linkmode in
lib)
passes="conv link"
for file in $dlfiles $dlprefiles; do
case $file in
*.la) ;;
*)
$echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
exit 1
;;
esac
done
;;
prog)
compile_deplibs=
finalize_deplibs=
alldeplibs=no
newdlfiles=
newdlprefiles=
passes="conv scan dlopen dlpreopen link"
;;
*) passes="conv"
;;
esac
for pass in $passes; do
if test $linkmode = prog; then
# Determine which files to process
case $pass in
dlopen)
libs="$dlfiles"
save_deplibs="$deplibs" # Collect dlpreopened libraries
deplibs=
;;
dlpreopen) libs="$dlprefiles" ;;
link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
esac
fi
for deplib in $libs; do
lib=
found=no
case $deplib in
-l*)
if test $linkmode = oldlib && test $linkmode = obj; then
$echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2
continue
fi
if test $pass = conv; then
deplibs="$deplib $deplibs"
continue
fi
name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
# Search the libtool library
lib="$searchdir/lib${name}.la"
if test -f "$lib"; then
found=yes
break
fi
done
if test "$found" != yes; then
# deplib doesn't seem to be a libtool library
if test "$linkmode,$pass" = "prog,link"; then
compile_deplibs="$deplib $compile_deplibs"
finalize_deplibs="$deplib $finalize_deplibs"
else
deplibs="$deplib $deplibs"
test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs"
fi
continue
fi
;; # -l
-L*)
case $linkmode in
lib)
deplibs="$deplib $deplibs"
test $pass = conv && continue
newdependency_libs="$deplib $newdependency_libs"
newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
;;
prog)
if test $pass = conv; then
deplibs="$deplib $deplibs"
continue
fi
if test $pass = scan; then
deplibs="$deplib $deplibs"
newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
else
compile_deplibs="$deplib $compile_deplibs"
finalize_deplibs="$deplib $finalize_deplibs"
fi
;;
*)
$echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2
;;
esac # linkmode
continue
;; # -L
-R*)
if test $pass = link; then
dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
# Make sure the xrpath contains only unique directories.
case "$xrpath " in
*" $dir "*) ;;
*) xrpath="$xrpath $dir" ;;
esac
fi
deplibs="$deplib $deplibs"
continue
;;
*.la) lib="$deplib" ;;
*.$libext)
if test $pass = conv; then
deplibs="$deplib $deplibs"
continue
fi
case $linkmode in
lib)
if test "$deplibs_check_method" != pass_all; then
echo
echo "*** Warning: This library needs some functionality provided by $deplib."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
echo "*** shared version of the library, which you do not appear to have."
else
echo
echo "*** Warning: Linking the shared library $output against the"
echo "*** static library $deplib is not portable!"
deplibs="$deplib $deplibs"
fi
continue
;;
prog)
if test $pass != link; then
deplibs="$deplib $deplibs"
else
compile_deplibs="$deplib $compile_deplibs"
finalize_deplibs="$deplib $finalize_deplibs"
fi
continue
;;
esac # linkmode
;; # *.$libext
*.lo | *.$objext)
if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
# If there is no dlopen support or we're linking statically,
# we need to preload.
newdlprefiles="$newdlprefiles $deplib"
compile_deplibs="$deplib $compile_deplibs"
finalize_deplibs="$deplib $finalize_deplibs"
else
newdlfiles="$newdlfiles $deplib"
fi
continue
;;
%DEPLIBS%)
alldeplibs=yes
continue
;;
esac # case $deplib
if test $found = yes || test -f "$lib"; then :
else
$echo "$modename: cannot find the library \`$lib'" 1>&2
exit 1
fi
# Check to see that this really is a libtool archive.
if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
else
$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
exit 1
fi
ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
test "X$ladir" = "X$lib" && ladir="."
dlname=
dlopen=
dlpreopen=
libdir=
library_names=
old_library=
# If the library was installed with an old release of libtool,
# it will not redefine variable installed.
installed=yes
# Read the .la file
case $lib in
*/* | *\\*) . $lib ;;
*) . ./$lib ;;
esac
if test "$linkmode,$pass" = "lib,link" ||
test "$linkmode,$pass" = "prog,scan" ||
{ test $linkmode = oldlib && test $linkmode = obj; }; then
# Add dl[pre]opened files of deplib
test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
fi
if test $pass = conv; then
# Only check for convenience libraries
deplibs="$lib $deplibs"
if test -z "$libdir"; then
if test -z "$old_library"; then
$echo "$modename: cannot find name of link library for \`$lib'" 1>&2
exit 1
fi
# It is a libtool convenience library, so add in its objects.
convenience="$convenience $ladir/$objdir/$old_library"
old_convenience="$old_convenience $ladir/$objdir/$old_library"
tmp_libs=
for deplib in $dependency_libs; do
deplibs="$deplib $deplibs"
case "$tmp_libs " in
*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
esac
tmp_libs="$tmp_libs $deplib"
done
elif test $linkmode != prog && test $linkmode != lib; then
$echo "$modename: \`$lib' is not a convenience library" 1>&2
exit 1
fi
continue
fi # $pass = conv
# Get the name of the library we link against.
linklib=
for l in $old_library $library_names; do
linklib="$l"
done
if test -z "$linklib"; then
$echo "$modename: cannot find name of link library for \`$lib'" 1>&2
exit 1
fi
# This library was specified with -dlopen.
if test $pass = dlopen; then
if test -z "$libdir"; then
$echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
exit 1
fi
if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
# If there is no dlname, no dlopen support or we're linking
# statically, we need to preload.
dlprefiles="$dlprefiles $lib"
else
newdlfiles="$newdlfiles $lib"
fi
continue
fi # $pass = dlopen
# We need an absolute path.
case $ladir in
[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
*)
abs_ladir=`cd "$ladir" && pwd`
if test -z "$abs_ladir"; then
$echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
$echo "$modename: passing it literally to the linker, although it might fail" 1>&2
abs_ladir="$ladir"
fi
;;
esac
laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
# Find the relevant object directory and library name.
if test "X$installed" = Xyes; then
if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
$echo "$modename: warning: library \`$lib' was moved." 1>&2
dir="$ladir"
absdir="$abs_ladir"
libdir="$abs_ladir"
else
dir="$libdir"
absdir="$libdir"
fi
else
dir="$ladir/$objdir"
absdir="$abs_ladir/$objdir"
# Remove this search path later
notinst_path="$notinst_path $abs_ladir"
fi # $installed = yes
name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
# This library was specified with -dlpreopen.
if test $pass = dlpreopen; then
if test -z "$libdir"; then
$echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
exit 1
fi
# Prefer using a static library (so that no silly _DYNAMIC symbols
# are required to link).
if test -n "$old_library"; then
newdlprefiles="$newdlprefiles $dir/$old_library"
# Otherwise, use the dlname, so that lt_dlopen finds it.
elif test -n "$dlname"; then
newdlprefiles="$newdlprefiles $dir/$dlname"
else
newdlprefiles="$newdlprefiles $dir/$linklib"
fi
fi # $pass = dlpreopen
if test -z "$libdir"; then
# Link the convenience library
if test $linkmode = lib; then
deplibs="$dir/$old_library $deplibs"
elif test "$linkmode,$pass" = "prog,link"; then
compile_deplibs="$dir/$old_library $compile_deplibs"
finalize_deplibs="$dir/$old_library $finalize_deplibs"
else
deplibs="$lib $deplibs"
fi
continue
fi
if test $linkmode = prog && test $pass != link; then
newlib_search_path="$newlib_search_path $ladir"
deplibs="$lib $deplibs"
linkalldeplibs=no
if test "$link_all_deplibs" != no || test -z "$library_names" ||
test "$build_libtool_libs" = no; then
linkalldeplibs=yes
fi
tmp_libs=
for deplib in $dependency_libs; do
case $deplib in
-L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
esac
# Need to link against all dependency_libs?
if test $linkalldeplibs = yes; then
deplibs="$deplib $deplibs"
else
# Need to hardcode shared library paths
# or/and link against static libraries
newdependency_libs="$deplib $newdependency_libs"
fi
case "$tmp_libs " in
*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
esac
tmp_libs="$tmp_libs $deplib"
done # for deplib
continue
fi # $linkmode = prog...
link_static=no # Whether the deplib will be linked statically
if test -n "$library_names" &&
{ test "$prefer_static_libs" = no || test -z "$old_library"; }; then
# Link against this shared library
if test "$linkmode,$pass" = "prog,link" ||
{ test $linkmode = lib && test $hardcode_into_libs = yes; }; then
# Hardcode the library path.
# Skip directories that are in the system default run-time
# search path.
case " $sys_lib_dlsearch_path " in
*" $absdir "*) ;;
*)
case "$compile_rpath " in
*" $absdir "*) ;;
*) compile_rpath="$compile_rpath $absdir"
esac
;;
esac
case " $sys_lib_dlsearch_path " in
*" $libdir "*) ;;
*)
case "$finalize_rpath " in
*" $libdir "*) ;;
*) finalize_rpath="$finalize_rpath $libdir"
esac
;;
esac
if test $linkmode = prog; then
# We need to hardcode the library path
if test -n "$shlibpath_var"; then
# Make sure the rpath contains only unique directories.
case "$temp_rpath " in
*" $dir "*) ;;
*" $absdir "*) ;;
*) temp_rpath="$temp_rpath $dir" ;;
esac
fi
fi
fi # $linkmode,$pass = prog,link...
if test "$alldeplibs" = yes &&
{ test "$deplibs_check_method" = pass_all ||
{ test "$build_libtool_libs" = yes &&
test -n "$library_names"; }; }; then
# We only need to search for static libraries
continue
fi
if test "$installed" = no; then
notinst_deplibs="$notinst_deplibs $lib"
need_relink=yes
fi
if test -n "$old_archive_from_expsyms_cmds"; then
# figure out the soname
set dummy $library_names
realname="$2"
shift; shift
libname=`eval \\$echo \"$libname_spec\"`
# use dlname if we got it. it's perfectly good, no?
if test -n "$dlname"; then
soname="$dlname"
elif test -n "$soname_spec"; then
# bleh windows
case $host in
*cygwin*)
major=`expr $current - $age`
versuffix="-$major"
;;
esac
eval soname=\"$soname_spec\"
else
soname="$realname"
fi
# Make a new name for the extract_expsyms_cmds to use
soroot="$soname"
soname=`echo $soroot | sed -e 's/^.*\///'`
newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a"
# If the library has no export list, then create one now
if test -f "$output_objdir/$soname-def"; then :
else
$show "extracting exported symbol list from \`$soname'"
save_ifs="$IFS"; IFS='~'
eval cmds=\"$extract_expsyms_cmds\"
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
fi
# Create $newlib
if test -f "$output_objdir/$newlib"; then :; else
$show "generating import library for \`$soname'"
save_ifs="$IFS"; IFS='~'
eval cmds=\"$old_archive_from_expsyms_cmds\"
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
fi
# make sure the library variables are pointing to the new library
dir=$output_objdir
linklib=$newlib
fi # test -n $old_archive_from_expsyms_cmds
if test $linkmode = prog || test "$mode" != relink; then
add_shlibpath=
add_dir=
add=
lib_linked=yes
case $hardcode_action in
immediate | unsupported)
if test "$hardcode_direct" = no; then
add="$dir/$linklib"
elif test "$hardcode_minus_L" = no; then
case $host in
*-*-sunos*) add_shlibpath="$dir" ;;
esac
add_dir="-L$dir"
add="-l$name"
elif test "$hardcode_shlibpath_var" = no; then
add_shlibpath="$dir"
add="-l$name"
else
lib_linked=no
fi
;;
relink)
if test "$hardcode_direct" = yes; then
add="$dir/$linklib"
elif test "$hardcode_minus_L" = yes; then
add_dir="-L$dir"
add="-l$name"
elif test "$hardcode_shlibpath_var" = yes; then
add_shlibpath="$dir"
add="-l$name"
else
lib_linked=no
fi
;;
*) lib_linked=no ;;
esac
if test "$lib_linked" != yes; then
$echo "$modename: configuration error: unsupported hardcode properties"
exit 1
fi
if test -n "$add_shlibpath"; then
case :$compile_shlibpath: in
*":$add_shlibpath:"*) ;;
*) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
esac
fi
if test $linkmode = prog; then
test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
test -n "$add" && compile_deplibs="$add $compile_deplibs"
else
test -n "$add_dir" && deplibs="$add_dir $deplibs"
test -n "$add" && deplibs="$add $deplibs"
if test "$hardcode_direct" != yes && \
test "$hardcode_minus_L" != yes && \
test "$hardcode_shlibpath_var" = yes; then
case :$finalize_shlibpath: in
*":$libdir:"*) ;;
*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
esac
fi
fi
fi
if test $linkmode = prog || test "$mode" = relink; then
add_shlibpath=
add_dir=
add=
# Finalize command for both is simple: just hardcode it.
if test "$hardcode_direct" = yes; then
add="$libdir/$linklib"
elif test "$hardcode_minus_L" = yes; then
add_dir="-L$libdir"
add="-l$name"
elif test "$hardcode_shlibpath_var" = yes; then
case :$finalize_shlibpath: in
*":$libdir:"*) ;;
*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
esac
add="-l$name"
else
# We cannot seem to hardcode it, guess we'll fake it.
add_dir="-L$libdir"
add="-l$name"
fi
if test $linkmode = prog; then
test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
else
test -n "$add_dir" && deplibs="$add_dir $deplibs"
test -n "$add" && deplibs="$add $deplibs"
fi
fi
elif test $linkmode = prog; then
if test "$alldeplibs" = yes &&
{ test "$deplibs_check_method" = pass_all ||
{ test "$build_libtool_libs" = yes &&
test -n "$library_names"; }; }; then
# We only need to search for static libraries
continue
fi
# Try to link the static library
# Here we assume that one of hardcode_direct or hardcode_minus_L
# is not unsupported. This is valid on all known static and
# shared platforms.
if test "$hardcode_direct" != unsupported; then
test -n "$old_library" && linklib="$old_library"
compile_deplibs="$dir/$linklib $compile_deplibs"
finalize_deplibs="$dir/$linklib $finalize_deplibs"
else
compile_deplibs="-l$name -L$dir $compile_deplibs"
finalize_deplibs="-l$name -L$dir $finalize_deplibs"
fi
elif test "$build_libtool_libs" = yes; then
# Not a shared library
if test "$deplibs_check_method" != pass_all; then
# We're trying link a shared library against a static one
# but the system doesn't support it.
# Just print a warning and add the library to dependency_libs so
# that the program can be linked against the static library.
echo
echo "*** Warning: This library needs some functionality provided by $lib."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
echo "*** shared version of the library, which you do not appear to have."
if test "$module" = yes; then
echo "*** Therefore, libtool will create a static module, that should work "
echo "*** as long as the dlopening application is linked with the -dlopen flag."
if test -z "$global_symbol_pipe"; then
echo
echo "*** However, this would only work if libtool was able to extract symbol"
echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
echo "*** not find such a program. So, this module is probably useless."
echo "*** \`nm' from GNU binutils and a full rebuild may help."
fi
if test "$build_old_libs" = no; then
build_libtool_libs=module
build_old_libs=yes
else
build_libtool_libs=no
fi
fi
else
convenience="$convenience $dir/$old_library"
old_convenience="$old_convenience $dir/$old_library"
deplibs="$dir/$old_library $deplibs"
link_static=yes
fi
fi # link shared/static library?
if test $linkmode = lib; then
if test -n "$dependency_libs" &&
{ test $hardcode_into_libs != yes || test $build_old_libs = yes ||
test $link_static = yes; }; then
# Extract -R from dependency_libs
temp_deplibs=
for libdir in $dependency_libs; do
case $libdir in
-R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
case " $xrpath " in
*" $temp_xrpath "*) ;;
*) xrpath="$xrpath $temp_xrpath";;
esac;;
*) temp_deplibs="$temp_deplibs $libdir";;
esac
done
dependency_libs="$temp_deplibs"
fi
newlib_search_path="$newlib_search_path $absdir"
# Link against this library
test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
# ... and its dependency_libs
tmp_libs=
for deplib in $dependency_libs; do
newdependency_libs="$deplib $newdependency_libs"
case "$tmp_libs " in
*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
esac
tmp_libs="$tmp_libs $deplib"
done
if test $link_all_deplibs != no; then
# Add the search paths of all dependency libraries
for deplib in $dependency_libs; do
case $deplib in
-L*) path="$deplib" ;;
*.la)
dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
test "X$dir" = "X$deplib" && dir="."
# We need an absolute path.
case $dir in
[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
*)
absdir=`cd "$dir" && pwd`
if test -z "$absdir"; then
$echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
absdir="$dir"
fi
;;
esac
if grep "^installed=no" $deplib > /dev/null; then
path="-L$absdir/$objdir"
else
eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
if test -z "$libdir"; then
$echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
exit 1
fi
if test "$absdir" != "$libdir"; then
$echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
fi
path="-L$absdir"
fi
;;
*) continue ;;
esac
case " $deplibs " in
*" $path "*) ;;
*) deplibs="$deplibs $path" ;;
esac
done
fi # link_all_deplibs != no
fi # linkmode = lib
done # for deplib in $libs
if test $pass = dlpreopen; then
# Link the dlpreopened libraries before other libraries
for deplib in $save_deplibs; do
deplibs="$deplib $deplibs"
done
fi
if test $pass != dlopen; then
test $pass != scan && dependency_libs="$newdependency_libs"
if test $pass != conv; then
# Make sure lib_search_path contains only unique directories.
lib_search_path=
for dir in $newlib_search_path; do
case "$lib_search_path " in
*" $dir "*) ;;
*) lib_search_path="$lib_search_path $dir" ;;
esac
done
newlib_search_path=
fi
if test "$linkmode,$pass" != "prog,link"; then
vars="deplibs"
else
vars="compile_deplibs finalize_deplibs"
fi
for var in $vars dependency_libs; do
# Add libraries to $var in reverse order
eval tmp_libs=\"\$$var\"
new_libs=
for deplib in $tmp_libs; do
case $deplib in
-L*) new_libs="$deplib $new_libs" ;;
*)
case " $specialdeplibs " in
*" $deplib "*) new_libs="$deplib $new_libs" ;;
*)
case " $new_libs " in
*" $deplib "*) ;;
*) new_libs="$deplib $new_libs" ;;
esac
;;
esac
;;
esac
done
tmp_libs=
for deplib in $new_libs; do
case $deplib in
-L*)
case " $tmp_libs " in
*" $deplib "*) ;;
*) tmp_libs="$tmp_libs $deplib" ;;
esac
;;
*) tmp_libs="$tmp_libs $deplib" ;;
esac
done
eval $var=\"$tmp_libs\"
done # for var
fi
if test "$pass" = "conv" &&
{ test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then
libs="$deplibs" # reset libs
deplibs=
fi
done # for pass
if test $linkmode = prog; then
dlfiles="$newdlfiles"
dlprefiles="$newdlprefiles"
fi
case $linkmode in
oldlib)
if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
fi
if test -n "$rpath"; then
$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
fi
if test -n "$xrpath"; then
$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
fi
if test -n "$vinfo"; then
$echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
fi
if test -n "$release"; then
$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
fi
if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
fi
# Now set the variables for building old libraries.
build_libtool_libs=no
oldlibs="$output"
objs="$objs$old_deplibs"
;;
lib)
# Make sure we only generate libraries of the form `libNAME.la'.
case $outputname in
lib*)
name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
eval libname=\"$libname_spec\"
;;
*)
if test "$module" = no; then
$echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
$echo "$help" 1>&2
exit 1
fi
if test "$need_lib_prefix" != no; then
# Add the "lib" prefix for modules if required
name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
eval libname=\"$libname_spec\"
else
libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
fi
;;
esac
if test -n "$objs"; then
if test "$deplibs_check_method" != pass_all; then
$echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
exit 1
else
echo
echo "*** Warning: Linking the shared library $output against the non-libtool"
echo "*** objects $objs is not portable!"
libobjs="$libobjs $objs"
fi
fi
if test "$dlself" != no; then
$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
fi
set dummy $rpath
if test $# -gt 2; then
$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
fi
install_libdir="$2"
oldlibs=
if test -z "$rpath"; then
if test "$build_libtool_libs" = yes; then
# Building a libtool convenience library.
libext=al
oldlibs="$output_objdir/$libname.$libext $oldlibs"
build_libtool_libs=convenience
build_old_libs=yes
fi
if test -n "$vinfo"; then
$echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
fi
if test -n "$release"; then
$echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
fi
else
# Parse the version information argument.
save_ifs="$IFS"; IFS=':'
set dummy $vinfo 0 0 0
IFS="$save_ifs"
if test -n "$8"; then
$echo "$modename: too many parameters to \`-version-info'" 1>&2
$echo "$help" 1>&2
exit 1
fi
current="$2"
revision="$3"
age="$4"
# Check that each of the things are valid numbers.
case $current in
0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
*)
$echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
exit 1
;;
esac
case $revision in
0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
*)
$echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
exit 1
;;
esac
case $age in
0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
*)
$echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
exit 1
;;
esac
if test $age -gt $current; then
$echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
exit 1
fi
# Calculate the version variables.
major=
versuffix=
verstring=
case $version_type in
none) ;;
darwin)
# Like Linux, but with the current version available in
# verstring for coding it into the library header
major=.`expr $current - $age`
versuffix="$major.$age.$revision"
# Darwin ld doesn't like 0 for these options...
minor_current=`expr $current + 1`
verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
;;
freebsd-aout)
major=".$current"
versuffix=".$current.$revision";
;;
freebsd-elf)
major=".$current"
versuffix=".$current";
;;
irix)
major=`expr $current - $age + 1`
verstring="sgi$major.$revision"
# Add in all the interfaces that we are compatible with.
loop=$revision
while test $loop != 0; do
iface=`expr $revision - $loop`
loop=`expr $loop - 1`
verstring="sgi$major.$iface:$verstring"
done
# Before this point, $major must not contain `.'.
major=.$major
versuffix="$major.$revision"
;;
linux)
major=.`expr $current - $age`
versuffix="$major.$age.$revision"
;;
osf)
major=`expr $current - $age`
versuffix=".$current.$age.$revision"
verstring="$current.$age.$revision"
# Add in all the interfaces that we are compatible with.
loop=$age
while test $loop != 0; do
iface=`expr $current - $loop`
loop=`expr $loop - 1`
verstring="$verstring:${iface}.0"
done
# Make executables depend on our current version.
verstring="$verstring:${current}.0"
;;
sunos)
major=".$current"
versuffix=".$current.$revision"
;;
windows)
# Use '-' rather than '.', since we only want one
# extension on DOS 8.3 filesystems.
major=`expr $current - $age`
versuffix="-$major"
;;
*)
$echo "$modename: unknown library version type \`$version_type'" 1>&2
echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
exit 1
;;
esac
# Clear the version info if we defaulted, and they specified a release.
if test -z "$vinfo" && test -n "$release"; then
major=
verstring="0.0"
case $version_type in
darwin)
# we can't check for "0.0" in archive_cmds due to quoting
# problems, so we reset it completely
verstring=""
;;
*)
verstring="0.0"
;;
esac
if test "$need_version" = no; then
versuffix=
else
versuffix=".0.0"
fi
fi
# Remove version info from name if versioning should be avoided
if test "$avoid_version" = yes && test "$need_version" = no; then
major=
versuffix=
verstring=""
fi
# Check to see if the archive will have undefined symbols.
if test "$allow_undefined" = yes; then
if test "$allow_undefined_flag" = unsupported; then
$echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
build_libtool_libs=no
build_old_libs=yes
fi
else
# Don't allow undefined symbols.
allow_undefined_flag="$no_undefined_flag"
fi
fi
if test "$mode" != relink; then
# Remove our outputs.
$show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
$run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
fi
# Now set the variables for building old libraries.
if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
oldlibs="$oldlibs $output_objdir/$libname.$libext"
# Transform .lo files to .o files.
oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
fi
# Eliminate all temporary directories.
for path in $notinst_path; do
lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'`
deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'`
dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'`
done
if test -n "$xrpath"; then
# If the user specified any rpath flags, then add them.
temp_xrpath=
for libdir in $xrpath; do
temp_xrpath="$temp_xrpath -R$libdir"
case "$finalize_rpath " in
*" $libdir "*) ;;
*) finalize_rpath="$finalize_rpath $libdir" ;;
esac
done
if test $hardcode_into_libs != yes || test $build_old_libs = yes; then
dependency_libs="$temp_xrpath $dependency_libs"
fi
fi
# Make sure dlfiles contains only unique files that won't be dlpreopened
old_dlfiles="$dlfiles"
dlfiles=
for lib in $old_dlfiles; do
case " $dlprefiles $dlfiles " in
*" $lib "*) ;;
*) dlfiles="$dlfiles $lib" ;;
esac
done
# Make sure dlprefiles contains only unique files
old_dlprefiles="$dlprefiles"
dlprefiles=
for lib in $old_dlprefiles; do
case "$dlprefiles " in
*" $lib "*) ;;
*) dlprefiles="$dlprefiles $lib" ;;
esac
done
if test "$build_libtool_libs" = yes; then
if test -n "$rpath"; then
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
# these systems don't actually have a c library (as such)!
;;
*-*-rhapsody* | *-*-darwin1.[012])
# Rhapsody C library is in the System framework
deplibs="$deplibs -framework System"
;;
*-*-netbsd*)
# Don't link with libc until the a.out ld.so is fixed.
;;
*-*-openbsd*)
# Do not include libc due to us having libc/libc_r.
;;
*)
# Add libc to deplibs on all other systems if necessary.
if test $build_libtool_need_lc = "yes"; then
deplibs="$deplibs -lc"
fi
;;
esac
fi
# Transform deplibs into only deplibs that can be linked in shared.
name_save=$name
libname_save=$libname
release_save=$release
versuffix_save=$versuffix
major_save=$major
# I'm not sure if I'm treating the release correctly. I think
# release should show up in the -l (ie -lgmp5) so we don't want to
# add it in twice. Is that correct?
release=""
versuffix=""
major=""
newdeplibs=
droppeddeps=no
case $deplibs_check_method in
pass_all)
# Don't check for shared/static. Everything works.
# This might be a little naive. We might want to check
# whether the library exists or not. But this is on
# osf3 & osf4 and I'm not really sure... Just
# implementing what was already the behaviour.
newdeplibs=$deplibs
;;
test_compile)
# This code stresses the "libraries are programs" paradigm to its
# limits. Maybe even breaks it. We compile a program, linking it
# against the deplibs as a proxy for the library. Then we can check
# whether they linked in statically or dynamically with ldd.
$rm conftest.c
cat > conftest.c <<EOF
int main() { return 0; }
EOF
$rm conftest
$CC -o conftest conftest.c $deplibs
if test $? -eq 0 ; then
ldd_output=`ldd conftest`
for i in $deplibs; do
name="`expr $i : '-l\(.*\)'`"
# If $name is empty we are operating on a -L argument.
if test -n "$name" && test "$name" != "0"; then
libname=`eval \\$echo \"$libname_spec\"`
deplib_matches=`eval \\$echo \"$library_names_spec\"`
set dummy $deplib_matches
deplib_match=$2
if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
newdeplibs="$newdeplibs $i"
else
droppeddeps=yes
echo
echo "*** Warning: This library needs some functionality provided by $i."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
echo "*** shared version of the library, which you do not appear to have."
fi
else
newdeplibs="$newdeplibs $i"
fi
done
else
# Error occured in the first compile. Let's try to salvage the situation:
# Compile a seperate program for each library.
for i in $deplibs; do
name="`expr $i : '-l\(.*\)'`"
# If $name is empty we are operating on a -L argument.
if test -n "$name" && test "$name" != "0"; then
$rm conftest
$CC -o conftest conftest.c $i
# Did it work?
if test $? -eq 0 ; then
ldd_output=`ldd conftest`
libname=`eval \\$echo \"$libname_spec\"`
deplib_matches=`eval \\$echo \"$library_names_spec\"`
set dummy $deplib_matches
deplib_match=$2
if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
newdeplibs="$newdeplibs $i"
else
droppeddeps=yes
echo
echo "*** Warning: This library needs some functionality provided by $i."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
echo "*** shared version of the library, which you do not appear to have."
fi
else
droppeddeps=yes
echo
echo "*** Warning! Library $i is needed by this library but I was not able to"
echo "*** make it link in! You will probably need to install it or some"
echo "*** library that it depends on before this library will be fully"
echo "*** functional. Installing it before continuing would be even better."
fi
else
newdeplibs="$newdeplibs $i"
fi
done
fi
;;
file_magic*)
set dummy $deplibs_check_method
file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
for a_deplib in $deplibs; do
name="`expr $a_deplib : '-l\(.*\)'`"
# If $name is empty we are operating on a -L argument.
if test -n "$name" && test "$name" != "0"; then
libname=`eval \\$echo \"$libname_spec\"`
for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
for potent_lib in $potential_libs; do
# Follow soft links.
if ls -lLd "$potent_lib" 2>/dev/null \
| grep " -> " >/dev/null; then
continue
fi
# The statement above tries to avoid entering an
# endless loop below, in case of cyclic links.
# We might still enter an endless loop, since a link
# loop can be closed while we follow links,
# but so what?
potlib="$potent_lib"
while test -h "$potlib" 2>/dev/null; do
potliblink=`ls -ld $potlib | sed 's/.* -> //'`
case $potliblink in
[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
esac
done
if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
| sed 10q \
| egrep "$file_magic_regex" > /dev/null; then
newdeplibs="$newdeplibs $a_deplib"
a_deplib=""
break 2
fi
done
done
if test -n "$a_deplib" ; then
droppeddeps=yes
echo
echo "*** Warning: This library needs some functionality provided by $a_deplib."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
echo "*** shared version of the library, which you do not appear to have."
fi
else
# Add a -L argument.
newdeplibs="$newdeplibs $a_deplib"
fi
done # Gone through all deplibs.
;;
match_pattern*)
set dummy $deplibs_check_method
match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
for a_deplib in $deplibs; do
name="`expr $a_deplib : '-l\(.*\)'`"
# If $name is empty we are operating on a -L argument.
if test -n "$name" && test "$name" != "0"; then
libname=`eval \\$echo \"$libname_spec\"`
for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
for potent_lib in $potential_libs; do
if eval echo \"$potent_lib\" 2>/dev/null \
| sed 10q \
| egrep "$match_pattern_regex" > /dev/null; then
newdeplibs="$newdeplibs $a_deplib"
a_deplib=""
break 2
fi
done
done
if test -n "$a_deplib" ; then
droppeddeps=yes
echo
echo "*** Warning: This library needs some functionality provided by $a_deplib."
echo "*** I have the capability to make that library automatically link in when"
echo "*** you link to this library. But I can only do this if you have a"
echo "*** shared version of the library, which you do not appear to have."
fi
else
# Add a -L argument.
newdeplibs="$newdeplibs $a_deplib"
fi
done # Gone through all deplibs.
;;
none | unknown | *)
newdeplibs=""
if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
-e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' |
grep . >/dev/null; then
echo
if test "X$deplibs_check_method" = "Xnone"; then
echo "*** Warning: inter-library dependencies are not supported in this platform."
else
echo "*** Warning: inter-library dependencies are not known to be supported."
fi
echo "*** All declared inter-library dependencies are being dropped."
droppeddeps=yes
fi
;;
esac
versuffix=$versuffix_save
major=$major_save
release=$release_save
libname=$libname_save
name=$name_save
case $host in
*-*-rhapsody* | *-*-darwin1.[012])
# On Rhapsody replace the C library is the System framework
newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
;;
esac
if test "$droppeddeps" = yes; then
if test "$module" = yes; then
echo
echo "*** Warning: libtool could not satisfy all declared inter-library"
echo "*** dependencies of module $libname. Therefore, libtool will create"
echo "*** a static module, that should work as long as the dlopening"
echo "*** application is linked with the -dlopen flag."
if test -z "$global_symbol_pipe"; then
echo
echo "*** However, this would only work if libtool was able to extract symbol"
echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
echo "*** not find such a program. So, this module is probably useless."
echo "*** \`nm' from GNU binutils and a full rebuild may help."
fi
if test "$build_old_libs" = no; then
oldlibs="$output_objdir/$libname.$libext"
build_libtool_libs=module
build_old_libs=yes
else
build_libtool_libs=no
fi
else
echo "*** The inter-library dependencies that have been dropped here will be"
echo "*** automatically added whenever a program is linked with this library"
echo "*** or is declared to -dlopen it."
if test $allow_undefined = no; then
echo
echo "*** Since this library must not contain undefined symbols,"
echo "*** because either the platform does not support them or"
echo "*** it was explicitly requested with -no-undefined,"
echo "*** libtool will only create a static version of it."
if test "$build_old_libs" = no; then
oldlibs="$output_objdir/$libname.$libext"
build_libtool_libs=module
build_old_libs=yes
else
build_libtool_libs=no
fi
fi
fi
fi
# Done checking deplibs!
deplibs=$newdeplibs
fi
# All the library-specific variables (install_libdir is set above).
library_names=
old_library=
dlname=
# Test again, we may have decided not to build it any more
if test "$build_libtool_libs" = yes; then
if test $hardcode_into_libs = yes; then
# Hardcode the library paths
hardcode_libdirs=
dep_rpath=
rpath="$finalize_rpath"
test "$mode" != relink && rpath="$compile_rpath$rpath"
for libdir in $rpath; do
if test -n "$hardcode_libdir_flag_spec"; then
if test -n "$hardcode_libdir_separator"; then
if test -z "$hardcode_libdirs"; then
hardcode_libdirs="$libdir"
else
# Just accumulate the unique libdirs.
case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
*"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
;;
*)
hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
;;
esac
fi
else
eval flag=\"$hardcode_libdir_flag_spec\"
dep_rpath="$dep_rpath $flag"
fi
elif test -n "$runpath_var"; then
case "$perm_rpath " in
*" $libdir "*) ;;
*) perm_rpath="$perm_rpath $libdir" ;;
esac
fi
done
# Substitute the hardcoded libdirs into the rpath.
if test -n "$hardcode_libdir_separator" &&
test -n "$hardcode_libdirs"; then
libdir="$hardcode_libdirs"
eval dep_rpath=\"$hardcode_libdir_flag_spec\"
fi
if test -n "$runpath_var" && test -n "$perm_rpath"; then
# We should set the runpath_var.
rpath=
for dir in $perm_rpath; do
rpath="$rpath$dir:"
done
eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
fi
test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
fi
shlibpath="$finalize_shlibpath"
test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
if test -n "$shlibpath"; then
eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
fi
# Get the real and link names of the library.
eval library_names=\"$library_names_spec\"
set dummy $library_names
realname="$2"
shift; shift
if test -n "$soname_spec"; then
eval soname=\"$soname_spec\"
else
soname="$realname"
fi
test -z "$dlname" && dlname=$soname
lib="$output_objdir/$realname"
for link
do
linknames="$linknames $link"
done
# Ensure that we have .o objects for linkers which dislike .lo
# (e.g. aix) in case we are running --disable-static
for obj in $libobjs; do
xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
if test "X$xdir" = "X$obj"; then
xdir="."
else
xdir="$xdir"
fi
baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
if test ! -f $xdir/$oldobj; then
$show "(cd $xdir && ${LN_S} $baseobj $oldobj)"
$run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $?
fi
done
# Use standard objects if they are pic
test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
# Prepare the list of exported symbols
if test -z "$export_symbols"; then
if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
$show "generating symbol list for \`$libname.la'"
export_symbols="$output_objdir/$libname.exp"
$run $rm $export_symbols
eval cmds=\"$export_symbols_cmds\"
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
if test -n "$export_symbols_regex"; then
$show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
$run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
$show "$mv \"${export_symbols}T\" \"$export_symbols\""
$run eval '$mv "${export_symbols}T" "$export_symbols"'
fi
fi
fi
if test -n "$export_symbols" && test -n "$include_expsyms"; then
$run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
fi
if test -n "$convenience"; then
if test -n "$whole_archive_flag_spec"; then
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
else
gentop="$output_objdir/${outputname}x"
$show "${rm}r $gentop"
$run ${rm}r "$gentop"
$show "mkdir $gentop"
$run mkdir "$gentop"
status=$?
if test $status -ne 0 && test ! -d "$gentop"; then
exit $status
fi
generated="$generated $gentop"
for xlib in $convenience; do
# Extract the objects.
case $xlib in
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
*) xabs=`pwd`"/$xlib" ;;
esac
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
xdir="$gentop/$xlib"
$show "${rm}r $xdir"
$run ${rm}r "$xdir"
$show "mkdir $xdir"
$run mkdir "$xdir"
status=$?
if test $status -ne 0 && test ! -d "$xdir"; then
exit $status
fi
$show "(cd $xdir && $AR x $xabs)"
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
done
fi
fi
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
eval flag=\"$thread_safe_flag_spec\"
linker_flags="$linker_flags $flag"
fi
# Make a backup of the uninstalled library when relinking
if test "$mode" = relink; then
$run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
fi
# Do each of the archive commands.
if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
eval cmds=\"$archive_expsym_cmds\"
else
eval cmds=\"$archive_cmds\"
fi
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
# Restore the uninstalled library and exit
if test "$mode" = relink; then
$run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
exit 0
fi
# Create links to the real library.
for linkname in $linknames; do
if test "$realname" != "$linkname"; then
$show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
$run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
fi
done
# If -module or -export-dynamic was specified, set the dlname.
if test "$module" = yes || test "$export_dynamic" = yes; then
# On all known operating systems, these are identical.
dlname="$soname"
fi
fi
;;
obj)
if test -n "$deplibs"; then
$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
fi
if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
fi
if test -n "$rpath"; then
$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
fi
if test -n "$xrpath"; then
$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
fi
if test -n "$vinfo"; then
$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
fi
if test -n "$release"; then
$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
fi
case $output in
*.lo)
if test -n "$objs$old_deplibs"; then
$echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
exit 1
fi
libobj="$output"
obj=`$echo "X$output" | $Xsed -e "$lo2o"`
;;
*)
libobj=
obj="$output"
;;
esac
# Delete the old objects.
$run $rm $obj $libobj
# Objects from convenience libraries. This assumes
# single-version convenience libraries. Whenever we create
# different ones for PIC/non-PIC, this we'll have to duplicate
# the extraction.
reload_conv_objs=
gentop=
# reload_cmds runs $LD directly, so let us get rid of
# -Wl from whole_archive_flag_spec
wl=
if test -n "$convenience"; then
if test -n "$whole_archive_flag_spec"; then
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
else
gentop="$output_objdir/${obj}x"
$show "${rm}r $gentop"
$run ${rm}r "$gentop"
$show "mkdir $gentop"
$run mkdir "$gentop"
status=$?
if test $status -ne 0 && test ! -d "$gentop"; then
exit $status
fi
generated="$generated $gentop"
for xlib in $convenience; do
# Extract the objects.
case $xlib in
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
*) xabs=`pwd`"/$xlib" ;;
esac
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
xdir="$gentop/$xlib"
$show "${rm}r $xdir"
$run ${rm}r "$xdir"
$show "mkdir $xdir"
$run mkdir "$xdir"
status=$?
if test $status -ne 0 && test ! -d "$xdir"; then
exit $status
fi
$show "(cd $xdir && $AR x $xabs)"
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
done
fi
fi
# Create the old-style object.
reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
output="$obj"
eval cmds=\"$reload_cmds\"
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
# Exit if we aren't doing a library object file.
if test -z "$libobj"; then
if test -n "$gentop"; then
$show "${rm}r $gentop"
$run ${rm}r $gentop
fi
exit 0
fi
if test "$build_libtool_libs" != yes; then
if test -n "$gentop"; then
$show "${rm}r $gentop"
$run ${rm}r $gentop
fi
# Create an invalid libtool object if no PIC, so that we don't
# accidentally link it into a program.
$show "echo timestamp > $libobj"
$run eval "echo timestamp > $libobj" || exit $?
exit 0
fi
if test -n "$pic_flag" || test "$pic_mode" != default; then
# Only do commands if we really have different PIC objects.
reload_objs="$libobjs $reload_conv_objs"
output="$libobj"
eval cmds=\"$reload_cmds\"
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
else
# Just create a symlink.
$show $rm $libobj
$run $rm $libobj
xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
if test "X$xdir" = "X$libobj"; then
xdir="."
else
xdir="$xdir"
fi
baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
$show "(cd $xdir && $LN_S $oldobj $baseobj)"
$run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $?
fi
if test -n "$gentop"; then
$show "${rm}r $gentop"
$run ${rm}r $gentop
fi
exit 0
;;
prog)
case $host in
*cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;;
esac
if test -n "$vinfo"; then
$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
fi
if test -n "$release"; then
$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
fi
if test "$preload" = yes; then
if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
test "$dlopen_self_static" = unknown; then
$echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
fi
fi
case $host in
*-*-rhapsody* | *-*-darwin1.[012])
# On Rhapsody replace the C library is the System framework
compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
;;
esac
compile_command="$compile_command $compile_deplibs"
finalize_command="$finalize_command $finalize_deplibs"
if test -n "$rpath$xrpath"; then
# If the user specified any rpath flags, then add them.
for libdir in $rpath $xrpath; do
# This is the magic to use -rpath.
case "$finalize_rpath " in
*" $libdir "*) ;;
*) finalize_rpath="$finalize_rpath $libdir" ;;
esac
done
fi
# Now hardcode the library paths
rpath=
hardcode_libdirs=
for libdir in $compile_rpath $finalize_rpath; do
if test -n "$hardcode_libdir_flag_spec"; then
if test -n "$hardcode_libdir_separator"; then
if test -z "$hardcode_libdirs"; then
hardcode_libdirs="$libdir"
else
# Just accumulate the unique libdirs.
case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
*"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
;;
*)
hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
;;
esac
fi
else
eval flag=\"$hardcode_libdir_flag_spec\"
rpath="$rpath $flag"
fi
elif test -n "$runpath_var"; then
case "$perm_rpath " in
*" $libdir "*) ;;
*) perm_rpath="$perm_rpath $libdir" ;;
esac
fi
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
case :$dllsearchpath: in
*":$libdir:"*) ;;
*) dllsearchpath="$dllsearchpath:$libdir";;
esac
;;
esac
done
# Substitute the hardcoded libdirs into the rpath.
if test -n "$hardcode_libdir_separator" &&
test -n "$hardcode_libdirs"; then
libdir="$hardcode_libdirs"
eval rpath=\" $hardcode_libdir_flag_spec\"
fi
compile_rpath="$rpath"
rpath=
hardcode_libdirs=
for libdir in $finalize_rpath; do
if test -n "$hardcode_libdir_flag_spec"; then
if test -n "$hardcode_libdir_separator"; then
if test -z "$hardcode_libdirs"; then
hardcode_libdirs="$libdir"
else
# Just accumulate the unique libdirs.
case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
*"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
;;
*)
hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
;;
esac
fi
else
eval flag=\"$hardcode_libdir_flag_spec\"
rpath="$rpath $flag"
fi
elif test -n "$runpath_var"; then
case "$finalize_perm_rpath " in
*" $libdir "*) ;;
*) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
esac
fi
done
# Substitute the hardcoded libdirs into the rpath.
if test -n "$hardcode_libdir_separator" &&
test -n "$hardcode_libdirs"; then
libdir="$hardcode_libdirs"
eval rpath=\" $hardcode_libdir_flag_spec\"
fi
finalize_rpath="$rpath"
if test -n "$libobjs" && test "$build_old_libs" = yes; then
# Transform all the library objects into standard objects.
compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
fi
dlsyms=
if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
if test -n "$NM" && test -n "$global_symbol_pipe"; then
dlsyms="${outputname}S.c"
else
$echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
fi
fi
if test -n "$dlsyms"; then
case $dlsyms in
"") ;;
*.c)
# Discover the nlist of each of the dlfiles.
nlist="$output_objdir/${outputname}.nm"
$show "$rm $nlist ${nlist}S ${nlist}T"
$run $rm "$nlist" "${nlist}S" "${nlist}T"
# Parse the name list into a source file.
$show "creating $output_objdir/$dlsyms"
test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
#ifdef __cplusplus
extern \"C\" {
#endif
/* Prevent the only kind of declaration conflicts we can make. */
#define lt_preloaded_symbols some_other_symbol
/* External symbol declarations for the compiler. */\
"
if test "$dlself" = yes; then
$show "generating symbol list for \`$output'"
test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
# Add our own program objects to the symbol list.
progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
for arg in $progfiles; do
$show "extracting global C symbols from \`$arg'"
$run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
done
if test -n "$exclude_expsyms"; then
$run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
$run eval '$mv "$nlist"T "$nlist"'
fi
if test -n "$export_symbols_regex"; then
$run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'
$run eval '$mv "$nlist"T "$nlist"'
fi
# Prepare the list of exported symbols
if test -z "$export_symbols"; then
export_symbols="$output_objdir/$output.exp"
$run $rm $export_symbols
$run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
else
$run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
$run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
$run eval 'mv "$nlist"T "$nlist"'
fi
fi
for arg in $dlprefiles; do
$show "extracting global C symbols from \`$arg'"
name=`echo "$arg" | sed -e 's%^.*/%%'`
$run eval 'echo ": $name " >> "$nlist"'
$run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
done
if test -z "$run"; then
# Make sure we have at least an empty file.
test -f "$nlist" || : > "$nlist"
if test -n "$exclude_expsyms"; then
egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
$mv "$nlist"T "$nlist"
fi
# Try sorting and uniquifying the output.
if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
:
else
grep -v "^: " < "$nlist" > "$nlist"S
fi
if test -f "$nlist"S; then
eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
else
echo '/* NONE */' >> "$output_objdir/$dlsyms"
fi
$echo >> "$output_objdir/$dlsyms" "\
#undef lt_preloaded_symbols
#if defined (__STDC__) && __STDC__
# define lt_ptr void *
#else
# define lt_ptr char *
# define const
#endif
/* The mapping between symbol names and symbols. */
const struct {
const char *name;
lt_ptr address;
}
lt_preloaded_symbols[] =
{\
"
eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
$echo >> "$output_objdir/$dlsyms" "\
{0, (lt_ptr) 0}
};
/* This works around a problem in FreeBSD linker */
#ifdef FREEBSD_WORKAROUND
static const void *lt_preloaded_setup() {
return lt_preloaded_symbols;
}
#endif
#ifdef __cplusplus
}
#endif\
"
fi
pic_flag_for_symtable=
case $host in
# compiling the symbol table file with pic_flag works around
# a FreeBSD bug that causes programs to crash when -lm is
# linked before any other PIC object. But we must not use
# pic_flag when linking with -static. The problem exists in
# FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
*-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
case "$compile_command " in
*" -static "*) ;;
*) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
esac;;
*-*-hpux*)
case "$compile_command " in
*" -static "*) ;;
*) pic_flag_for_symtable=" $pic_flag -DPIC";;
esac
esac
# Now compile the dynamic symbol file.
$show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
$run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
# Clean up the generated files.
$show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
$run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
# Transform the symbol file into the correct name.
compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
;;
*)
$echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
exit 1
;;
esac
else
# We keep going just in case the user didn't refer to
# lt_preloaded_symbols. The linker will fail if global_symbol_pipe
# really was required.
# Nullify the symbol file.
compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
fi
if test $need_relink = no || test "$build_libtool_libs" != yes; then
# Replace the output file specification.
compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
link_command="$compile_command$compile_rpath"
# We have no uninstalled library dependencies, so finalize right now.
$show "$link_command"
$run eval "$link_command"
status=$?
# Delete the generated files.
if test -n "$dlsyms"; then
$show "$rm $output_objdir/${outputname}S.${objext}"
$run $rm "$output_objdir/${outputname}S.${objext}"
fi
exit $status
fi
if test -n "$shlibpath_var"; then
# We should set the shlibpath_var
rpath=
for dir in $temp_rpath; do
case $dir in
[\\/]* | [A-Za-z]:[\\/]*)
# Absolute path.
rpath="$rpath$dir:"
;;
*)
# Relative path: add a thisdir entry.
rpath="$rpath\$thisdir/$dir:"
;;
esac
done
temp_rpath="$rpath"
fi
if test -n "$compile_shlibpath$finalize_shlibpath"; then
compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
fi
if test -n "$finalize_shlibpath"; then
finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
fi
compile_var=
finalize_var=
if test -n "$runpath_var"; then
if test -n "$perm_rpath"; then
# We should set the runpath_var.
rpath=
for dir in $perm_rpath; do
rpath="$rpath$dir:"
done
compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
fi
if test -n "$finalize_perm_rpath"; then
# We should set the runpath_var.
rpath=
for dir in $finalize_perm_rpath; do
rpath="$rpath$dir:"
done
finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
fi
fi
if test "$no_install" = yes; then
# We don't need to create a wrapper script.
link_command="$compile_var$compile_command$compile_rpath"
# Replace the output file specification.
link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
# Delete the old output file.
$run $rm $output
# Link the executable and exit
$show "$link_command"
$run eval "$link_command" || exit $?
exit 0
fi
if test "$hardcode_action" = relink; then
# Fast installation is not supported
link_command="$compile_var$compile_command$compile_rpath"
relink_command="$finalize_var$finalize_command$finalize_rpath"
$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
$echo "$modename: \`$output' will be relinked during installation" 1>&2
else
if test "$fast_install" != no; then
link_command="$finalize_var$compile_command$finalize_rpath"
if test "$fast_install" = yes; then
relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
else
# fast_install is set to needless
relink_command=
fi
else
link_command="$compile_var$compile_command$compile_rpath"
relink_command="$finalize_var$finalize_command$finalize_rpath"
fi
fi
# Replace the output file specification.
link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
# Delete the old output files.
$run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
$show "$link_command"
$run eval "$link_command" || exit $?
# Now create the wrapper script.
$show "creating $output"
# Quote the relink command for shipping.
if test -n "$relink_command"; then
# Preserve any variables that may affect compiler behavior
for var in $variables_saved_for_relink; do
if eval test -z \"\${$var+set}\"; then
relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
elif eval var_value=\$$var; test -z "$var_value"; then
relink_command="$var=; export $var; $relink_command"
else
var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
relink_command="$var=\"$var_value\"; export $var; $relink_command"
fi
done
relink_command="cd `pwd`; $relink_command"
relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
fi
# Quote $echo for shipping.
if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
case $0 in
[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";;
*) qecho="$SHELL `pwd`/$0 --fallback-echo";;
esac
qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
else
qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
fi
# Only actually do things if our run command is non-null.
if test -z "$run"; then
# win32 will think the script is a binary if it has
# a .exe suffix, so we strip it off here.
case $output in
*.exe) output=`echo $output|sed 's,.exe$,,'` ;;
esac
# test for cygwin because mv fails w/o .exe extensions
case $host in
*cygwin*) exeext=.exe ;;
*) exeext= ;;
esac
$rm $output
trap "$rm $output; exit 1" 1 2 15
$echo > $output "\
#! $SHELL
# $output - temporary wrapper script for $objdir/$outputname
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
#
# The $output program cannot be directly executed until all the libtool
# libraries that it depends on are installed.
#
# This wrapper script should never be moved out of the build directory.
# If it is, it will not operate correctly.
# Sed substitution that helps us do robust quoting. It backslashifies
# metacharacters that are still active within double-quoted strings.
Xsed='sed -e 1s/^X//'
sed_quote_subst='$sed_quote_subst'
# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
relink_command=\"$relink_command\"
# This environment variable determines our operation mode.
if test \"\$libtool_install_magic\" = \"$magic\"; then
# install mode needs the following variable:
notinst_deplibs='$notinst_deplibs'
else
# When we are sourced in execute mode, \$file and \$echo are already set.
if test \"\$libtool_execute_magic\" != \"$magic\"; then
echo=\"$qecho\"
file=\"\$0\"
# Make sure echo works.
if test \"X\$1\" = X--no-reexec; then
# Discard the --no-reexec flag, and continue.
shift
elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
# Yippee, \$echo works!
:
else
# Restart under the correct shell, and then maybe \$echo will work.
exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
fi
fi\
"
$echo >> $output "\
# Find the directory that this script lives in.
thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
test \"x\$thisdir\" = \"x\$file\" && thisdir=.
# Follow symbolic links until we get to the real thisdir.
file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
while test -n \"\$file\"; do
destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
# If there was a directory component, then change thisdir.
if test \"x\$destdir\" != \"x\$file\"; then
case \"\$destdir\" in
[\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
*) thisdir=\"\$thisdir/\$destdir\" ;;
esac
fi
file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
done
# Try to get the absolute directory name.
absdir=\`cd \"\$thisdir\" && pwd\`
test -n \"\$absdir\" && thisdir=\"\$absdir\"
"
if test "$fast_install" = yes; then
echo >> $output "\
program=lt-'$outputname'$exeext
progdir=\"\$thisdir/$objdir\"
if test ! -f \"\$progdir/\$program\" || \\
{ file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
test \"X\$file\" != \"X\$progdir/\$program\"; }; then
file=\"\$\$-\$program\"
if test ! -d \"\$progdir\"; then
$mkdir \"\$progdir\"
else
$rm \"\$progdir/\$file\"
fi"
echo >> $output "\
# relink executable if necessary
if test -n \"\$relink_command\"; then
if relink_command_output=\`eval \$relink_command 2>&1\`; then :
else
$echo \"\$relink_command_output\" >&2
$rm \"\$progdir/\$file\"
exit 1
fi
fi
$mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
{ $rm \"\$progdir/\$program\";
$mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
$rm \"\$progdir/\$file\"
fi"
else
echo >> $output "\
program='$outputname'
progdir=\"\$thisdir/$objdir\"
"
fi
echo >> $output "\
if test -f \"\$progdir/\$program\"; then"
# Export our shlibpath_var if we have one.
if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
$echo >> $output "\
# Add our own library path to $shlibpath_var
$shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
# Some systems cannot cope with colon-terminated $shlibpath_var
# The second colon is a workaround for a bug in BeOS R4 sed
$shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
export $shlibpath_var
"
fi
# fixup the dll searchpath if we need to.
if test -n "$dllsearchpath"; then
$echo >> $output "\
# Add the dll search path components to the executable PATH
PATH=$dllsearchpath:\$PATH
"
fi
$echo >> $output "\
if test \"\$libtool_execute_magic\" != \"$magic\"; then
# Run the actual program with our arguments.
"
case $host in
# win32 systems need to use the prog path for dll
# lookup to work
*-*-cygwin* | *-*-pw32*)
$echo >> $output "\
exec \$progdir/\$program \${1+\"\$@\"}
"
;;
# Backslashes separate directories on plain windows
*-*-mingw | *-*-os2*)
$echo >> $output "\
exec \$progdir\\\\\$program \${1+\"\$@\"}
"
;;
*)
$echo >> $output "\
# Export the path to the program.
PATH=\"\$progdir:\$PATH\"
export PATH
exec \$program \${1+\"\$@\"}
"
;;
esac
$echo >> $output "\
\$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
exit 1
fi
else
# The program doesn't exist.
\$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
\$echo \"This script is just a wrapper for \$program.\" 1>&2
echo \"See the $PACKAGE documentation for more information.\" 1>&2
exit 1
fi
fi\
"
chmod +x $output
fi
exit 0
;;
esac
# See if we need to build an old-fashioned archive.
for oldlib in $oldlibs; do
if test "$build_libtool_libs" = convenience; then
oldobjs="$libobjs_save"
addlibs="$convenience"
build_libtool_libs=no
else
if test "$build_libtool_libs" = module; then
oldobjs="$libobjs_save"
build_libtool_libs=no
else
oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
fi
addlibs="$old_convenience"
fi
if test -n "$addlibs"; then
gentop="$output_objdir/${outputname}x"
$show "${rm}r $gentop"
$run ${rm}r "$gentop"
$show "mkdir $gentop"
$run mkdir "$gentop"
status=$?
if test $status -ne 0 && test ! -d "$gentop"; then
exit $status
fi
generated="$generated $gentop"
# Add in members from convenience archives.
for xlib in $addlibs; do
# Extract the objects.
case $xlib in
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
*) xabs=`pwd`"/$xlib" ;;
esac
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
xdir="$gentop/$xlib"
$show "${rm}r $xdir"
$run ${rm}r "$xdir"
$show "mkdir $xdir"
$run mkdir "$xdir"
status=$?
if test $status -ne 0 && test ! -d "$xdir"; then
exit $status
fi
$show "(cd $xdir && $AR x $xabs)"
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
done
fi
# Do each command in the archive commands.
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
eval cmds=\"$old_archive_from_new_cmds\"
else
# Ensure that we have .o objects in place in case we decided
# not to build a shared library, and have fallen back to building
# static libs even though --disable-static was passed!
for oldobj in $oldobjs; do
if test ! -f $oldobj; then
xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'`
if test "X$xdir" = "X$oldobj"; then
xdir="."
else
xdir="$xdir"
fi
baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'`
obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
$show "(cd $xdir && ${LN_S} $obj $baseobj)"
$run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $?
fi
done
eval cmds=\"$old_archive_cmds\"
fi
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
done
if test -n "$generated"; then
$show "${rm}r$generated"
$run ${rm}r$generated
fi
# Now create the libtool archive.
case $output in
*.la)
old_library=
test "$build_old_libs" = yes && old_library="$libname.$libext"
$show "creating $output"
# Preserve any variables that may affect compiler behavior
for var in $variables_saved_for_relink; do
if eval test -z \"\${$var+set}\"; then
relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
elif eval var_value=\$$var; test -z "$var_value"; then
relink_command="$var=; export $var; $relink_command"
else
var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
relink_command="$var=\"$var_value\"; export $var; $relink_command"
fi
done
# Quote the link command for shipping.
relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args"
relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
# Only create the output if not a dry run.
if test -z "$run"; then
for installed in no yes; do
if test "$installed" = yes; then
if test -z "$install_libdir"; then
break
fi
output="$output_objdir/$outputname"i
# Replace all uninstalled libtool libraries with the installed ones
newdependency_libs=
for deplib in $dependency_libs; do
case $deplib in
*.la)
name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
if test -z "$libdir"; then
$echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
exit 1
fi
newdependency_libs="$newdependency_libs $libdir/$name"
;;
*) newdependency_libs="$newdependency_libs $deplib" ;;
esac
done
dependency_libs="$newdependency_libs"
newdlfiles=
for lib in $dlfiles; do
name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
if test -z "$libdir"; then
$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
exit 1
fi
newdlfiles="$newdlfiles $libdir/$name"
done
dlfiles="$newdlfiles"
newdlprefiles=
for lib in $dlprefiles; do
name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
if test -z "$libdir"; then
$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
exit 1
fi
newdlprefiles="$newdlprefiles $libdir/$name"
done
dlprefiles="$newdlprefiles"
fi
$rm $output
# place dlname in correct position for cygwin
tdlname=$dlname
case $host,$output,$installed,$module,$dlname in
*cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
esac
$echo > $output "\
# $outputname - a libtool library file
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='$tdlname'
# Names of this library.
library_names='$library_names'
# The name of the static archive.
old_library='$old_library'
# Libraries that this one depends upon.
dependency_libs='$dependency_libs'
# Version information for $libname.
current=$current
age=$age
revision=$revision
# Is this an already installed library?
installed=$installed
# Files to dlopen/dlpreopen
dlopen='$dlfiles'
dlpreopen='$dlprefiles'
# Directory that this library needs to be installed in:
libdir='$install_libdir'"
if test "$installed" = no && test $need_relink = yes; then
$echo >> $output "\
relink_command=\"$relink_command\""
fi
done
fi
# Do a symbolic link so that the libtool archive can be found in
# LD_LIBRARY_PATH before the program is installed.
$show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
$run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
;;
esac
exit 0
;;
# libtool install mode
install)
modename="$modename: install"
# There may be an optional sh(1) argument at the beginning of
# install_prog (especially on Windows NT).
if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
# Allow the use of GNU shtool's install command.
$echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
# Aesthetically quote it.
arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
arg="\"$arg\""
;;
esac
install_prog="$arg "
arg="$1"
shift
else
install_prog=
arg="$nonopt"
fi
# The real first argument should be the name of the installation program.
# Aesthetically quote it.
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
arg="\"$arg\""
;;
esac
install_prog="$install_prog$arg"
# We need to accept at least all the BSD install flags.
dest=
files=
opts=
prev=
install_type=
isdir=no
stripme=
for arg
do
if test -n "$dest"; then
files="$files $dest"
dest="$arg"
continue
fi
case $arg in
-d) isdir=yes ;;
-f) prev="-f" ;;
-g) prev="-g" ;;
-m) prev="-m" ;;
-o) prev="-o" ;;
-s)
stripme=" -s"
continue
;;
-*) ;;
*)
# If the previous option needed an argument, then skip it.
if test -n "$prev"; then
prev=
else
dest="$arg"
continue
fi
;;
esac
# Aesthetically quote the argument.
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
case $arg in
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
arg="\"$arg\""
;;
esac
install_prog="$install_prog $arg"
done
if test -z "$install_prog"; then
$echo "$modename: you must specify an install program" 1>&2
$echo "$help" 1>&2
exit 1
fi
if test -n "$prev"; then
$echo "$modename: the \`$prev' option requires an argument" 1>&2
$echo "$help" 1>&2
exit 1
fi
if test -z "$files"; then
if test -z "$dest"; then
$echo "$modename: no file or destination specified" 1>&2
else
$echo "$modename: you must specify a destination" 1>&2
fi
$echo "$help" 1>&2
exit 1
fi
# Strip any trailing slash from the destination.
dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
# Check to see that the destination is a directory.
test -d "$dest" && isdir=yes
if test "$isdir" = yes; then
destdir="$dest"
destname=
else
destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
test "X$destdir" = "X$dest" && destdir=.
destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
# Not a directory, so check to see that there is only one file specified.
set dummy $files
if test $# -gt 2; then
$echo "$modename: \`$dest' is not a directory" 1>&2
$echo "$help" 1>&2
exit 1
fi
fi
case $destdir in
[\\/]* | [A-Za-z]:[\\/]*) ;;
*)
for file in $files; do
case $file in
*.lo) ;;
*)
$echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
$echo "$help" 1>&2
exit 1
;;
esac
done
;;
esac
# This variable tells wrapper scripts just to set variables rather
# than running their programs.
libtool_install_magic="$magic"
staticlibs=
future_libdirs=
current_libdirs=
for file in $files; do
# Do each installation.
case $file in
*.$libext)
# Do the static libraries later.
staticlibs="$staticlibs $file"
;;
*.la)
# Check to see that this really is a libtool archive.
if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
else
$echo "$modename: \`$file' is not a valid libtool archive" 1>&2
$echo "$help" 1>&2
exit 1
fi
library_names=
old_library=
relink_command=
# If there is no directory component, then add one.
case $file in
*/* | *\\*) . $file ;;
*) . ./$file ;;
esac
# Add the libdir to current_libdirs if it is the destination.
if test "X$destdir" = "X$libdir"; then
case "$current_libdirs " in
*" $libdir "*) ;;
*) current_libdirs="$current_libdirs $libdir" ;;
esac
else
# Note the libdir as a future libdir.
case "$future_libdirs " in
*" $libdir "*) ;;
*) future_libdirs="$future_libdirs $libdir" ;;
esac
fi
dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
test "X$dir" = "X$file/" && dir=
dir="$dir$objdir"
if test -n "$relink_command"; then
$echo "$modename: warning: relinking \`$file'" 1>&2
$show "$relink_command"
if $run eval "$relink_command"; then :
else
$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
continue
fi
fi
# See the names of the shared library.
set dummy $library_names
if test -n "$2"; then
realname="$2"
shift
shift
srcname="$realname"
test -n "$relink_command" && srcname="$realname"T
# Install the shared library and build the symlinks.
$show "$install_prog $dir/$srcname $destdir/$realname"
$run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
if test -n "$stripme" && test -n "$striplib"; then
$show "$striplib $destdir/$realname"
$run eval "$striplib $destdir/$realname" || exit $?
fi
if test $# -gt 0; then
# Delete the old symlinks, and create new ones.
for linkname
do
if test "$linkname" != "$realname"; then
$show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
$run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
fi
done
fi
# Do each command in the postinstall commands.
lib="$destdir/$realname"
eval cmds=\"$postinstall_cmds\"
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
fi
# Install the pseudo-library for information purposes.
name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
instname="$dir/$name"i
$show "$install_prog $instname $destdir/$name"
$run eval "$install_prog $instname $destdir/$name" || exit $?
# Maybe install the static library, too.
test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
;;
*.lo)
# Install (i.e. copy) a libtool object.
# Figure out destination file name, if it wasn't already specified.
if test -n "$destname"; then
destfile="$destdir/$destname"
else
destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
destfile="$destdir/$destfile"
fi
# Deduce the name of the destination old-style object file.
case $destfile in
*.lo)
staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
;;
*.$objext)
staticdest="$destfile"
destfile=
;;
*)
$echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
$echo "$help" 1>&2
exit 1
;;
esac
# Install the libtool object if requested.
if test -n "$destfile"; then
$show "$install_prog $file $destfile"
$run eval "$install_prog $file $destfile" || exit $?
fi
# Install the old object if enabled.
if test "$build_old_libs" = yes; then
# Deduce the name of the old-style object file.
staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
$show "$install_prog $staticobj $staticdest"
$run eval "$install_prog \$staticobj \$staticdest" || exit $?
fi
exit 0
;;
*)
# Figure out destination file name, if it wasn't already specified.
if test -n "$destname"; then
destfile="$destdir/$destname"
else
destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
destfile="$destdir/$destfile"
fi
# Do a test to see if this is really a libtool program.
if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
notinst_deplibs=
relink_command=
# If there is no directory component, then add one.
case $file in
*/* | *\\*) . $file ;;
*) . ./$file ;;
esac
# Check the variables that should have been set.
if test -z "$notinst_deplibs"; then
$echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
exit 1
fi
finalize=yes
for lib in $notinst_deplibs; do
# Check to see that each library is installed.
libdir=
if test -f "$lib"; then
# If there is no directory component, then add one.
case $lib in
*/* | *\\*) . $lib ;;
*) . ./$lib ;;
esac
fi
libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
if test -n "$libdir" && test ! -f "$libfile"; then
$echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
finalize=no
fi
done
relink_command=
# If there is no directory component, then add one.
case $file in
*/* | *\\*) . $file ;;
*) . ./$file ;;
esac
outputname=
if test "$fast_install" = no && test -n "$relink_command"; then
if test "$finalize" = yes && test -z "$run"; then
tmpdir="/tmp"
test -n "$TMPDIR" && tmpdir="$TMPDIR"
tmpdir="$tmpdir/libtool-$$"
if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
else
$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
continue
fi
file=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
outputname="$tmpdir/$file"
# Replace the output file specification.
relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
$show "$relink_command"
if $run eval "$relink_command"; then :
else
$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
${rm}r "$tmpdir"
continue
fi
file="$outputname"
else
$echo "$modename: warning: cannot relink \`$file'" 1>&2
fi
else
# Install the binary that we compiled earlier.
file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
fi
fi
# remove .exe since cygwin /usr/bin/install will append another
# one anyways
case $install_prog,$host in
/usr/bin/install*,*cygwin*)
case $file:$destfile in
*.exe:*.exe)
# this is ok
;;
*.exe:*)
destfile=$destfile.exe
;;
*:*.exe)
destfile=`echo $destfile | sed -e 's,.exe$,,'`
;;
esac
;;
esac
$show "$install_prog$stripme $file $destfile"
$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
test -n "$outputname" && ${rm}r "$tmpdir"
;;
esac
done
for file in $staticlibs; do
name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
# Set up the ranlib parameters.
oldlib="$destdir/$name"
$show "$install_prog $file $oldlib"
$run eval "$install_prog \$file \$oldlib" || exit $?
if test -n "$stripme" && test -n "$striplib"; then
$show "$old_striplib $oldlib"
$run eval "$old_striplib $oldlib" || exit $?
fi
# Do each command in the postinstall commands.
eval cmds=\"$old_postinstall_cmds\"
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || exit $?
done
IFS="$save_ifs"
done
if test -n "$future_libdirs"; then
$echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
fi
if test -n "$current_libdirs"; then
# Maybe just do a dry run.
test -n "$run" && current_libdirs=" -n$current_libdirs"
exec_cmd='$SHELL $0 --finish$current_libdirs'
else
exit 0
fi
;;
# libtool finish mode
finish)
modename="$modename: finish"
libdirs="$nonopt"
admincmds=
if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
for dir
do
libdirs="$libdirs $dir"
done
for libdir in $libdirs; do
if test -n "$finish_cmds"; then
# Do each command in the finish commands.
eval cmds=\"$finish_cmds\"
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd" || admincmds="$admincmds
$cmd"
done
IFS="$save_ifs"
fi
if test -n "$finish_eval"; then
# Do the single finish_eval.
eval cmds=\"$finish_eval\"
$run eval "$cmds" || admincmds="$admincmds
$cmds"
fi
done
fi
# Exit here if they wanted silent mode.
test "$show" = ":" && exit 0
echo "----------------------------------------------------------------------"
echo "Libraries have been installed in:"
for libdir in $libdirs; do
echo " $libdir"
done
echo
echo "If you ever happen to want to link against installed libraries"
echo "in a given directory, LIBDIR, you must either use libtool, and"
echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
echo "flag during linking and do at least one of the following:"
if test -n "$shlibpath_var"; then
echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
echo " during execution"
fi
if test -n "$runpath_var"; then
echo " - add LIBDIR to the \`$runpath_var' environment variable"
echo " during linking"
fi
if test -n "$hardcode_libdir_flag_spec"; then
libdir=LIBDIR
eval flag=\"$hardcode_libdir_flag_spec\"
echo " - use the \`$flag' linker flag"
fi
if test -n "$admincmds"; then
echo " - have your system administrator run these commands:$admincmds"
fi
if test -f /etc/ld.so.conf; then
echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
fi
echo
echo "See any operating system documentation about shared libraries for"
echo "more information, such as the ld(1) and ld.so(8) manual pages."
echo "----------------------------------------------------------------------"
exit 0
;;
# libtool execute mode
execute)
modename="$modename: execute"
# The first argument is the command name.
cmd="$nonopt"
if test -z "$cmd"; then
$echo "$modename: you must specify a COMMAND" 1>&2
$echo "$help"
exit 1
fi
# Handle -dlopen flags immediately.
for file in $execute_dlfiles; do
if test ! -f "$file"; then
$echo "$modename: \`$file' is not a file" 1>&2
$echo "$help" 1>&2
exit 1
fi
dir=
case $file in
*.la)
# Check to see that this really is a libtool archive.
if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
else
$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
$echo "$help" 1>&2
exit 1
fi
# Read the libtool library.
dlname=
library_names=
# If there is no directory component, then add one.
case $file in
*/* | *\\*) . $file ;;
*) . ./$file ;;
esac
# Skip this library if it cannot be dlopened.
if test -z "$dlname"; then
# Warn if it was a shared library.
test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
continue
fi
dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
test "X$dir" = "X$file" && dir=.
if test -f "$dir/$objdir/$dlname"; then
dir="$dir/$objdir"
else
$echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
exit 1
fi
;;
*.lo)
# Just add the directory containing the .lo file.
dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
test "X$dir" = "X$file" && dir=.
;;
*)
$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
continue
;;
esac
# Get the absolute pathname.
absdir=`cd "$dir" && pwd`
test -n "$absdir" && dir="$absdir"
# Now add the directory to shlibpath_var.
if eval "test -z \"\$$shlibpath_var\""; then
eval "$shlibpath_var=\"\$dir\""
else
eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
fi
done
# This variable tells wrapper scripts just to set shlibpath_var
# rather than running their programs.
libtool_execute_magic="$magic"
# Check if any of the arguments is a wrapper script.
args=
for file
do
case $file in
-*) ;;
*)
# Do a test to see if this is really a libtool program.
if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
# If there is no directory component, then add one.
case $file in
*/* | *\\*) . $file ;;
*) . ./$file ;;
esac
# Transform arg to wrapped name.
file="$progdir/$program"
fi
;;
esac
# Quote arguments (to preserve shell metacharacters).
file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
args="$args \"$file\""
done
if test -z "$run"; then
if test -n "$shlibpath_var"; then
# Export the shlibpath_var.
eval "export $shlibpath_var"
fi
# Restore saved enviroment variables
if test "${save_LC_ALL+set}" = set; then
LC_ALL="$save_LC_ALL"; export LC_ALL
fi
if test "${save_LANG+set}" = set; then
LANG="$save_LANG"; export LANG
fi
# Now prepare to actually exec the command.
exec_cmd='"$cmd"$args'
else
# Display what would be done.
if test -n "$shlibpath_var"; then
eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
$echo "export $shlibpath_var"
fi
$echo "$cmd$args"
exit 0
fi
;;
# libtool clean and uninstall mode
clean | uninstall)
modename="$modename: $mode"
rm="$nonopt"
files=
rmforce=
exit_status=0
# This variable tells wrapper scripts just to set variables rather
# than running their programs.
libtool_install_magic="$magic"
for arg
do
case $arg in
-f) rm="$rm $arg"; rmforce=yes ;;
-*) rm="$rm $arg" ;;
*) files="$files $arg" ;;
esac
done
if test -z "$rm"; then
$echo "$modename: you must specify an RM program" 1>&2
$echo "$help" 1>&2
exit 1
fi
rmdirs=
for file in $files; do
dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
if test "X$dir" = "X$file"; then
dir=.
objdir="$objdir"
else
objdir="$dir/$objdir"
fi
name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
test $mode = uninstall && objdir="$dir"
# Remember objdir for removal later, being careful to avoid duplicates
if test $mode = clean; then
case " $rmdirs " in
*" $objdir "*) ;;
*) rmdirs="$rmdirs $objdir" ;;
esac
fi
# Don't error if the file doesn't exist and rm -f was used.
if (test -L "$file") >/dev/null 2>&1 \
|| (test -h "$file") >/dev/null 2>&1 \
|| test -f "$file"; then
:
elif test -d "$file"; then
exit_status=1
continue
elif test "$rmforce" = yes; then
continue
fi
rmfiles="$file"
case $name in
*.la)
# Possibly a libtool archive, so verify it.
if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
. $dir/$name
# Delete the libtool libraries and symlinks.
for n in $library_names; do
rmfiles="$rmfiles $objdir/$n"
done
test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
test $mode = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
if test $mode = uninstall; then
if test -n "$library_names"; then
# Do each command in the postuninstall commands.
eval cmds=\"$postuninstall_cmds\"
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd"
if test $? != 0 && test "$rmforce" != yes; then
exit_status=1
fi
done
IFS="$save_ifs"
fi
if test -n "$old_library"; then
# Do each command in the old_postuninstall commands.
eval cmds=\"$old_postuninstall_cmds\"
save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
$show "$cmd"
$run eval "$cmd"
if test $? != 0 && test "$rmforce" != yes; then
exit_status=1
fi
done
IFS="$save_ifs"
fi
# FIXME: should reinstall the best remaining shared library.
fi
fi
;;
*.lo)
if test "$build_old_libs" = yes; then
oldobj=`$echo "X$name" | $Xsed -e "$lo2o"`
rmfiles="$rmfiles $dir/$oldobj"
fi
;;
*)
# Do a test to see if this is a libtool program.
if test $mode = clean &&
(sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
relink_command=
. $dir/$file
rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
if test "$fast_install" = yes && test -n "$relink_command"; then
rmfiles="$rmfiles $objdir/lt-$name"
fi
fi
;;
esac
$show "$rm $rmfiles"
$run $rm $rmfiles || exit_status=1
done
# Try to remove the ${objdir}s in the directories where we deleted files
for dir in $rmdirs; do
if test -d "$dir"; then
$show "rmdir $dir"
$run rmdir $dir >/dev/null 2>&1
fi
done
exit $exit_status
;;
"")
$echo "$modename: you must specify a MODE" 1>&2
$echo "$generic_help" 1>&2
exit 1
;;
esac
if test -z "$exec_cmd"; then
$echo "$modename: invalid operation mode \`$mode'" 1>&2
$echo "$generic_help" 1>&2
exit 1
fi
fi # test -z "$show_help"
if test -n "$exec_cmd"; then
eval exec $exec_cmd
exit 1
fi
# We need to display help for each of the modes.
case $mode in
"") $echo \
"Usage: $modename [OPTION]... [MODE-ARG]...
Provide generalized library-building support services.
--config show all configuration variables
--debug enable verbose shell tracing
-n, --dry-run display commands without modifying any files
--features display basic configuration information and exit
--finish same as \`--mode=finish'
--help display this help message and exit
--mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]
--quiet same as \`--silent'
--silent don't print informational messages
--version print version information
MODE must be one of the following:
clean remove files from the build directory
compile compile a source file into a libtool object
execute automatically set library path, then run a program
finish complete the installation of libtool libraries
install install libraries or executables
link create a library or an executable
uninstall remove libraries from an installed directory
MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for
a more detailed description of MODE."
exit 0
;;
clean)
$echo \
"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
Remove files from the build directory.
RM is the name of the program to use to delete files associated with each FILE
(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
to RM.
If FILE is a libtool library, object or program, all the files associated
with it are deleted. Otherwise, only FILE itself is deleted using RM."
;;
compile)
$echo \
"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
Compile a source file into a libtool library object.
This mode accepts the following additional options:
-o OUTPUT-FILE set the output file name to OUTPUT-FILE
-prefer-pic try to building PIC objects only
-prefer-non-pic try to building non-PIC objects only
-static always build a \`.o' file suitable for static linking
COMPILE-COMMAND is a command to be used in creating a \`standard' object file
from the given SOURCEFILE.
The output file name is determined by removing the directory component from
SOURCEFILE, then substituting the C source code suffix \`.c' with the
library object suffix, \`.lo'."
;;
execute)
$echo \
"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
Automatically set library path, then run a program.
This mode accepts the following additional options:
-dlopen FILE add the directory containing FILE to the library path
This mode sets the library path environment variable according to \`-dlopen'
flags.
If any of the ARGS are libtool executable wrappers, then they are translated
into their corresponding uninstalled binary, and any of their required library
directories are added to the library path.
Then, COMMAND is executed, with ARGS as arguments."
;;
finish)
$echo \
"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
Complete the installation of libtool libraries.
Each LIBDIR is a directory that contains libtool libraries.
The commands that this mode executes may require superuser privileges. Use
the \`--dry-run' option if you just want to see what would be executed."
;;
install)
$echo \
"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
Install executables or libraries.
INSTALL-COMMAND is the installation command. The first component should be
either the \`install' or \`cp' program.
The rest of the components are interpreted as arguments to that command (only
BSD-compatible install options are recognized)."
;;
link)
$echo \
"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
Link object files or libraries together to form another library, or to
create an executable program.
LINK-COMMAND is a command using the C compiler that you would use to create
a program from several object files.
The following components of LINK-COMMAND are treated specially:
-all-static do not do any dynamic linking at all
-avoid-version do not add a version suffix if possible
-dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
-dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
-export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
-export-symbols SYMFILE
try to export only the symbols listed in SYMFILE
-export-symbols-regex REGEX
try to export only the symbols matching REGEX
-LLIBDIR search LIBDIR for required installed libraries
-lNAME OUTPUT-FILE requires the installed library libNAME
-module build a library that can dlopened
-no-fast-install disable the fast-install mode
-no-install link a not-installable executable
-no-undefined declare that a library does not refer to external symbols
-o OUTPUT-FILE create OUTPUT-FILE from the specified objects
-release RELEASE specify package release information
-rpath LIBDIR the created library will eventually be installed in LIBDIR
-R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
-static do not do any dynamic linking of libtool libraries
-version-info CURRENT[:REVISION[:AGE]]
specify library version info [each variable defaults to 0]
All other options (arguments beginning with \`-') are ignored.
Every other argument is treated as a filename. Files ending in \`.la' are
treated as uninstalled libtool libraries, other files are standard or library
object files.
If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
only library objects (\`.lo' files) may be specified, and \`-rpath' is
required, except when creating a convenience library.
If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
using \`ar' and \`ranlib', or on Windows using \`lib'.
If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
is created, otherwise an executable program is created."
;;
uninstall)
$echo \
"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
Remove libraries from an installation directory.
RM is the name of the program to use to delete files associated with each FILE
(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
to RM.
If FILE is a libtool library, all the files associated with it are deleted.
Otherwise, only FILE itself is deleted using RM."
;;
*)
$echo "$modename: invalid operation mode \`$mode'" 1>&2
$echo "$help" 1>&2
exit 1
;;
esac
echo
$echo "Try \`$modename --help' for more information about other modes."
exit 0
# Local Variables:
# mode:shell-script
# sh-indentation:2
# End:
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "apitest"=..\libraries\libldap\apitest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "apitest_r"=..\libraries\libldap_r\apitest_r.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap_r
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "backbdb"="..\servers\slapd\back-bdb\backbdb.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "backldbm"="..\servers\slapd\back-ldbm\backldbm.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "backmon"="..\servers\slapd\back-monitor\backmon.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "build"=.\build.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name apitest
End Project Dependency
Begin Project Dependency
Project_Dep_Name apitest_r
End Project Dependency
Begin Project Dependency
Project_Dep_Name dtest
End Project Dependency
Begin Project Dependency
Project_Dep_Name etest
End Project Dependency
Begin Project Dependency
Project_Dep_Name ldapdelete
End Project Dependency
Begin Project Dependency
Project_Dep_Name ldapmodify
End Project Dependency
Begin Project Dependency
Project_Dep_Name ldapmodrdn
End Project Dependency
Begin Project Dependency
Project_Dep_Name ldappasswd
End Project Dependency
Begin Project Dependency
Project_Dep_Name ldapsearch
End Project Dependency
Begin Project Dependency
Project_Dep_Name ldif
End Project Dependency
Begin Project Dependency
Project_Dep_Name testavl
End Project Dependency
Begin Project Dependency
Project_Dep_Name ud
End Project Dependency
Begin Project Dependency
Project_Dep_Name slapcat
End Project Dependency
Begin Project Dependency
Project_Dep_Name slapadd
End Project Dependency
Begin Project Dependency
Project_Dep_Name slapindex
End Project Dependency
Begin Project Dependency
Project_Dep_Name slapd
End Project Dependency
Begin Project Dependency
Project_Dep_Name ltest
End Project Dependency
Begin Project Dependency
Project_Dep_Name ltest_r
End Project Dependency
Begin Project Dependency
Project_Dep_Name passwd
End Project Dependency
Begin Project Dependency
Project_Dep_Name ucgendat
End Project Dependency
Begin Project Dependency
Project_Dep_Name dntest
End Project Dependency
Begin Project Dependency
Project_Dep_Name ftest
End Project Dependency
}}}
###############################################################################
Project: "dntest"=..\libraries\libldap\dntest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
}}}
###############################################################################
Project: "dtest"=..\libraries\liblber\dtest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "etest"=..\libraries\liblber\etest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "ftest"=..\libraries\libldap\ftest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
}}}
###############################################################################
Project: "ldapcompare"=..\clients\tools\ldapcompare.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "ldapdelete"=..\clients\tools\ldapdelete.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "ldapmodify"=..\clients\tools\ldapmodify.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldif
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "ldapmodrdn"=..\clients\tools\ldapmodrdn.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "ldappasswd"=..\clients\tools\ldappasswd.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "ldapsearch"=..\clients\tools\ldapsearch.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldif
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "libavl"=..\libraries\libavl\libavl.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "liblber"=..\libraries\liblber\liblber.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "libldap"=..\libraries\libldap\libldap.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "libldap_r"=..\libraries\libldap_r\libldap_r.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "libldbm"=..\libraries\libldbm\libldbm.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "libldif"=..\libraries\libldif\libldif.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "liblunicode"=..\libraries\liblunicode\liblunicode.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "liblutil"=..\libraries\liblutil\liblutil.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "libslapd"=..\servers\slapd\libslapd.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "ltest"=..\libraries\libldap\ltest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "ltest_r"=..\libraries\libldap_r\ltest_r.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap_r
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "passwd"=..\libraries\liblutil\passwd.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
}}}
###############################################################################
Project: "setup"=..\include\setup.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "slapadd"=..\servers\slapd\tools\slapadd.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name backldbm
End Project Dependency
Begin Project Dependency
Project_Dep_Name libavl
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldap_r
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldbm
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldif
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name libslapd
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblunicode
End Project Dependency
Begin Project Dependency
Project_Dep_Name backbdb
End Project Dependency
Begin Project Dependency
Project_Dep_Name backmon
End Project Dependency
}}}
###############################################################################
Project: "slapcat"=..\servers\slapd\tools\slapcat.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libavl
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldap_r
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldbm
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldif
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name libslapd
End Project Dependency
Begin Project Dependency
Project_Dep_Name backldbm
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblunicode
End Project Dependency
Begin Project Dependency
Project_Dep_Name backbdb
End Project Dependency
Begin Project Dependency
Project_Dep_Name backmon
End Project Dependency
}}}
###############################################################################
Project: "slapd"=..\servers\slapd\slapd.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name backldbm
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldap_r
End Project Dependency
Begin Project Dependency
Project_Dep_Name libavl
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldif
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldbm
End Project Dependency
Begin Project Dependency
Project_Dep_Name libslapd
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblunicode
End Project Dependency
Begin Project Dependency
Project_Dep_Name backbdb
End Project Dependency
Begin Project Dependency
Project_Dep_Name backmon
End Project Dependency
}}}
###############################################################################
Project: "slapindex"=..\servers\slapd\tools\slapindex.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name backldbm
End Project Dependency
Begin Project Dependency
Project_Dep_Name libavl
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldap_r
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldbm
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldif
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
Begin Project Dependency
Project_Dep_Name libslapd
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblunicode
End Project Dependency
Begin Project Dependency
Project_Dep_Name backbdb
End Project Dependency
Begin Project Dependency
Project_Dep_Name backmon
End Project Dependency
}}}
###############################################################################
Project: "testavl"=..\libraries\libavl\testavl.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libavl
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
}}}
###############################################################################
Project: "ucgendat"=..\libraries\liblunicode\ucgendat.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name setup
End Project Dependency
}}}
###############################################################################
Project: "ud"=..\clients\ud\ud.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
# $OpenLDAP$
## Copyright 1998-2002 The OpenLDAP Foundation
## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory
## of this package for details.
##---------------------------------------------------------------------------
##
## Makefile Template for Manual Pages
##
MANDIR=$(mandir)/man$(MANSECT)
TMP_SUFFIX=tmp
all-common:
PAGES=`cd $(srcdir); echo *.$(MANSECT)`; \
for page in $$PAGES; do \
$(SED) -e "s%LDVERSION%$(VERSION)%" \
-e 's%ETCDIR%$(sysconfdir)%' \
-e 's%LOCALSTATEDIR%$(localstatedir)%' \
-e 's%SYSCONFDIR%$(sysconfdir)%' \
-e 's%DATADIR%$(datadir)%' \
-e 's%SBINDIR%$(sbindir)%' \
-e 's%BINDIR%$(bindir)%' \
-e 's%LIBDIR%$(libdir)%' \
-e 's%LIBEXECDIR%$(libexecdir)%' \
-e 's%RELEASEDATE%$(RELEASEDATE)%' \
$(srcdir)/$$page > $$page.$(TMP_SUFFIX); \
done
install-common:
-$(MKDIR) $(DESTDIR)$(MANDIR)
PAGES=`cd $(srcdir); echo *.$(MANSECT)`; \
for page in $$PAGES; do \
echo "installing $(MANDIR)/$$page"; \
$(RM) $(DESTDIR)$(MANDIR)/$$page; \
$(INSTALL) $(INSTALLFLAGS) -m 644 $$page.$(TMP_SUFFIX) $(DESTDIR)$(MANDIR)/$$page; \
if test -f "$(srcdir)/$$page.links" ; then \
for link in `$(CAT) $(srcdir)/$$page.links`; do \
echo "installing $(MANDIR)/$$link as link to $$page"; \
$(RM) $(DESTDIR)$(MANDIR)/$$link ; \
$(LN_S) $$page $(DESTDIR)$(MANDIR)/$$link; \
done; \
fi; \
done
clean-common: FORCE
$(RM) *.tmp all-common
Makefile: $(top_srcdir)/build/man.mk
#! /bin/sh
# $OpenLDAP$
## Copyright 1998-2002 The OpenLDAP Foundation
## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory
## of this package for details.
#
# Make a release
# mkrelease RELNAME CVSTAG CVSMODULES
# where CVSTAG is the tag to export from the current CVSROOT
#
set -e # exit immediately if any errors occur
if test $# != 3 ; then
echo 'usage: mkrelease RELNAME CVSTAG CVSMODULES ...'
exit 1
fi
RELNAME=openldap-$1
shift
CVSTAG=$1
shift
if test -e $RELNAME ; then
echo "error: $RELNAME exists"
exit 1
fi
echo Release: $RELNAME
echo CVS Tag: $CVSTAG
echo Modules: $*
cvs -q export -r $CVSTAG -d $RELNAME $*
if test ! -d $RELNAME ; then
echo "error: $RELNAME doesn't exists"
exit 1
fi
if test ! -e $RELNAME/build/version.sh ; then
echo "No build version"
exit 1
fi
. $RELNAME/build/version.sh
tar cf $RELNAME.tar $RELNAME
gzip -9 -c $RELNAME.tar > $RELNAME.tgz
md5 $RELNAME.tgz > $RELNAME.md5
rm -f $RELNAME.tar
ls -l $RELNAME.*
echo "Made $OL_STRING as $RELNAME.tgz"
dnl $OpenLDAP$
dnl
dnl Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
dnl All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted only as authorized by the OpenLDAP
dnl Public License. A copy of this license is available at
dnl http://www.OpenLDAP.org/license.html or in file LICENSE in the
dnl top-level directory of the distribution.
dnl
dnl OpenLDAP Autoconf Macros
dnl
dnl --------------------------------------------------------------------
dnl Restricted form of AC_ARG_ENABLE that limits user options
dnl
dnl $1 = option name
dnl $2 = help-string
dnl $3 = default value (auto)
dnl $4 = allowed values (auto yes no)
AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
AC_ARG_ENABLE($1,changequote(<,>)<$2 [>ifelse($3,,auto,$3)<]>changequote([,]),[
ol_arg=invalid
for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
if test "$enableval" = "$ol_val" ; then
ol_arg="$ol_val"
fi
done
if test "$ol_arg" = "invalid" ; then
AC_MSG_ERROR(bad value $enableval for --enable-$1)
fi
ol_enable_$1="$ol_arg"
],
[ ol_enable_$1=ifelse($3,,"auto","$3")])dnl
dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
# end --enable-$1
])dnl
dnl
dnl --------------------------------------------------------------------
dnl Restricted form of AC_ARG_WITH that limits user options
dnl
dnl $1 = option name
dnl $2 = help-string
dnl $3 = default value (no)
dnl $4 = allowed values (yes or no)
AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
AC_ARG_WITH($1,changequote(<,>)<$2 [>ifelse($3,,yes,$3)<]>changequote([,]),[
ol_arg=invalid
for ol_val in ifelse($4,,[yes no],[$4]) ; do
if test "$withval" = "$ol_val" ; then
ol_arg="$ol_val"
fi
done
if test "$ol_arg" = "invalid" ; then
AC_MSG_ERROR(bad value $withval for --with-$1)
fi
ol_with_$1="$ol_arg"
],
[ ol_with_$1=ifelse($3,,"no","$3")])dnl
dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
# end --with-$1
])dnl
dnl
dnl ====================================================================
dnl
AC_DEFUN(AC_COMPILE_CHECK_SIZEOF,
[changequote(<<, >>)dnl
dnl The name to #define.
define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
dnl The cache variable name.
define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
changequote([, ])dnl
AC_MSG_CHECKING(size of $1)
AC_CACHE_VAL(AC_CV_NAME,
[for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
AC_TRY_COMPILE([#include "confdefs.h"
#include <sys/types.h>
$2
], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
if test x$AC_CV_NAME != x ; then break; fi
done
])
if test x$AC_CV_NAME = x ; then
AC_MSG_ERROR([cannot determine a size for $1])
fi
AC_MSG_RESULT($AC_CV_NAME)
AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
undefine([AC_TYPE_NAME])dnl
undefine([AC_CV_NAME])dnl
])
dnl ====================================================================
dnl check if hard links are supported.
dnl
AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
AC_MSG_CHECKING(whether ln works)
AC_CACHE_VAL(ol_cv_prog_LN_H,
[rm -f conftest.src conftest.dst
echo "conftest" > conftest.src
if ln conftest.src conftest.dst 2>/dev/null
then
ol_cv_prog_LN_H="ln"
else
ol_cv_prog_LN_H="cp"
fi
rm -f conftest.src conftest.dst
])dnl
LN_H="$ol_cv_prog_LN_H"
if test "$ol_cv_prog_LN_H" = "ln"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_SUBST(LN_H)dnl
])dnl
dnl
dnl ====================================================================
dnl Check for dependency generation flag
AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
OL_MKDEP=
OL_MKDEP_FLAGS=
if test -z "${MKDEP}"; then
OL_MKDEP="${CC-cc}"
if test -z "${MKDEP_FLAGS}"; then
AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
ol_cv_mkdep=no
for flag in "-M" "-xM"; do
cat > conftest.c <<EOF
noCode;
EOF
if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
| egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
then
if test ! -f conftest."${ac_object}" ; then
ol_cv_mkdep=$flag
OL_MKDEP_FLAGS="$flag"
break
fi
fi
done
rm -f conftest*
])
else
cc_cv_mkdep=yes
OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
fi
else
cc_cv_mkdep=yes
OL_MKDEP="${MKDEP}"
OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
fi
AC_SUBST(OL_MKDEP)
AC_SUBST(OL_MKDEP_FLAGS)
])
dnl
dnl ====================================================================
dnl Check if system uses EBCDIC instead of ASCII
AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
AC_TRY_CPP([
#if !('M' == 0xd4)
#include <__ASCII__/generate_error.h>
#endif
],
[ol_cv_cpp_ebcdic=yes],
[ol_cv_cpp_ebcdic=no])])
if test $ol_cv_cpp_ebcdic = yes ; then
AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
fi
])
dnl
dnl --------------------------------------------------------------------
dnl OpenLDAP version of STDC header check w/ EBCDIC support
AC_DEFUN(OL_HEADER_STDC,
[AC_REQUIRE_CPP()dnl
AC_REQUIRE([OL_CPP_EBCDIC])dnl
AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
[AC_TRY_CPP([#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
if test $ol_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
fi
if test $ol_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
fi
if test $ol_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
AC_TRY_RUN([#include <ctype.h>
#ifndef HAVE_EBCDIC
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int main () { int i; for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
], , ol_cv_header_stdc=no, :)
fi])
if test $ol_cv_header_stdc = yes; then
AC_DEFINE(STDC_HEADERS)
fi
ac_cv_header_stdc=disable
])
dnl
dnl ====================================================================
dnl Check if struct passwd has pw_gecos
AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
AC_TRY_COMPILE([#include <pwd.h>],[
struct passwd pwd;
pwd.pw_gecos = pwd.pw_name;
],
[ol_cv_struct_passwd_pw_gecos=yes],
[ol_cv_struct_passwd_pw_gecos=no])])
if test $ol_cv_struct_passwd_pw_gecos = yes ; then
AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
fi
])
dnl
dnl --------------------------------------------------------------------
dnl Check if struct passwd has pw_passwd
AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
AC_TRY_COMPILE([#include <pwd.h>],[
struct passwd pwd;
pwd.pw_passwd = pwd.pw_name;
],
[ol_cv_struct_passwd_pw_passwd=yes],
[ol_cv_struct_passwd_pw_passwd=no])])
if test $ol_cv_struct_passwd_pw_passwd = yes ; then
AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
fi
])
dnl
dnl ====================================================================
dnl Berkeley DB macros
dnl
dnl --------------------------------------------------------------------
dnl Try to link
AC_DEFUN([OL_BERKELEY_DB_TRY],
[if test $ol_cv_lib_db = no ; then
AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
[
ol_DB_LIB=ifelse($2,,,$2)
ol_LIBS=$LIBS
LIBS="$ol_DB_LIB $LIBS"
AC_TRY_LINK([
#ifdef HAVE_DB_185_H
# include <db_185.h>
#else
# include <db.h>
#endif
#ifndef DB_VERSION_MAJOR
# define DB_VERSION_MAJOR 1
#endif
#ifndef NULL
#define NULL ((void*)0)
#endif
],[
#if DB_VERSION_MAJOR > 1
{
char *version;
int major, minor, patch;
version = db_version( &major, &minor, &patch );
if( major != DB_VERSION_MAJOR ||
minor < DB_VERSION_MINOR )
{
printf("Berkeley DB version mismatch\n"
"\texpected: %s\n\tgot: %s\n",
DB_VERSION_STRING, version);
return 1;
}
}
#endif
#if DB_VERSION_MAJOR > 2
db_env_create( NULL, 0 );
#elif DB_VERSION_MAJOR > 1
db_appexit( NULL );
#else
(void) dbopen( NULL, 0, 0, 0, NULL);
#endif
],[$1=yes],[$1=no])
LIBS="$ol_LIBS"
])
if test $$1 = yes ; then
ol_cv_lib_db=ifelse($2,,yes,$2)
fi
fi
])
dnl
dnl --------------------------------------------------------------------
dnl Try to locate appropriate library
AC_DEFUN([OL_BERKELEY_DB_LINK],
[ol_cv_lib_db=no
OL_BERKELEY_DB_TRY(ol_cv_db_none)
OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
])
dnl
dnl --------------------------------------------------------------------
dnl Check if Berkeley DB supports DB_THREAD
AC_DEFUN([OL_BERKELEY_DB_THREAD],
[AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
ol_LIBS="$LIBS"
if test $ol_cv_lib_db != yes ; then
LIBS="$ol_cv_lib_db"
fi
AC_TRY_RUN([
#ifdef HAVE_DB_185_H
choke me;
#else
#include <db.h>
#endif
#ifndef NULL
#define NULL ((void *)0)
#endif
main()
{
int rc;
u_int32_t flags = DB_CREATE |
#ifdef DB_PRIVATE
DB_PRIVATE |
#endif
DB_THREAD;
#if DB_VERSION_MAJOR > 2
DB_ENV *env = NULL;
rc = db_env_create( &env, 0 );
flags |= DB_INIT_MPOOL;
#ifdef DB_MPOOL_PRIVATE
flags |= DB_MPOOL_PRIVATE;
#endif
if( rc ) {
printf("BerkeleyDB: %s\n", db_strerror(rc) );
return rc;
}
#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
rc = env->open( env, NULL, flags, 0 );
#else
rc = env->open( env, NULL, NULL, flags, 0 );
#endif
if ( rc == 0 ) {
rc = env->close( env, 0 );
}
if( rc ) {
printf("BerkeleyDB: %s\n", db_strerror(rc) );
return rc;
}
#else
DB_ENV env;
memset( &env, '\0', sizeof(env) );
rc = db_appinit( NULL, NULL, &env, flags );
if( rc == 0 ) {
db_appexit( &env );
}
unlink("__db_mpool.share");
unlink("__db_lock.share");
#endif
return rc;
}],
[ol_cv_berkeley_db_thread=yes],
[ol_cv_berkeley_db_thread=no],
[ol_cv_berkeley_db_thread=cross])
LIBS="$ol_LIBS"
if test $ol_cv_berkeley_db_thread != no ; then
AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
[define if Berkeley DB has DB_THREAD support])
fi
])])dnl
dnl
dnl --------------------------------------------------------------------
dnl Find any DB
AC_DEFUN([OL_BERKELEY_DB],
[ol_cv_berkeley_db=no
AC_CHECK_HEADERS(db.h)
if test $ac_cv_header_db_h = yes; then
OL_BERKELEY_DB_LINK
if test "$ol_cv_lib_db" != no ; then
ol_cv_berkeley_db=yes
OL_BERKELEY_DB_THREAD
fi
fi
])
dnl --------------------------------------------------------------------
dnl Check for version compatility with back-bdb
AC_DEFUN([OL_BDB_COMPAT],
[AC_CACHE_CHECK([Berkeley DB version for BDB backend], [ol_cv_bdb_compat],[
AC_EGREP_CPP(__db_version_compat,[
#include <db.h>
/* this check could be improved */
#ifndef DB_VERSION_MAJOR
# define DB_VERSION_MAJOR 1
#endif
/* require 4.0 or later */
#if DB_VERSION_MAJOR >= 4
__db_version_compat
#endif
], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
])
dnl --------------------------------------------------------------------
dnl Find old Berkeley DB 1.85/1.86
AC_DEFUN([OL_BERKELEY_COMPAT_DB],
[AC_CHECK_HEADERS(db_185.h db.h)
if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
AC_EGREP_CPP(__db_version_1,[
#if HAVE_DB_185_H
# include <db_185.h>
#else
# include <db.h>
#endif
/* this check could be improved */
#ifndef DB_VERSION_MAJOR
# define DB_VERSION_MAJOR 1
#endif
#if DB_VERSION_MAJOR == 1
__db_version_1
#endif
], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
if test $ol_cv_header_db1 = yes ; then
OL_BERKELEY_DB_LINK
if test "$ol_cv_lib_db" != no ; then
ol_cv_berkeley_db=yes
fi
fi
fi
])
dnl
dnl ====================================================================
dnl Check if GDBM library exists
dnl Check for gdbm_open in standard libraries or -lgdbm
dnl
dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
dnl 'yes' implies gdbm_open is in $LIBS
dnl
dnl uses:
dnl AC_CHECK_FUNC(gdbm_open)
dnl AC_CHECK_LIB(gdbm,gdbm_open)
dnl
AC_DEFUN([OL_LIB_GDBM],
[AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
[ ol_LIBS="$LIBS"
AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
])
LIBS="$ol_LIBS"
])
])dnl
dnl
dnl --------------------------------------------------------------------
dnl Check if GDBM exists
dnl
dnl defines ol_cv_gdbm to 'yes' or 'no'
dnl
dnl uses:
dnl OL_LIB_GDBM
dnl AC_CHECK_HEADERS(gdbm.h)
dnl
AC_DEFUN([OL_GDBM],
[AC_REQUIRE([OL_LIB_GDBM])
AC_CHECK_HEADERS(gdbm.h)
AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
ol_cv_gdbm=no
else
ol_cv_gdbm=yes
fi
])
if test $ol_cv_gdbm = yes ; then
AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
fi
])dnl
dnl
dnl ====================================================================
dnl Check if MDBM library exists
dnl Check for mdbm_open in standard libraries or -lmdbm
dnl
dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
dnl 'yes' implies mdbm_open is in $LIBS
dnl
dnl uses:
dnl AC_CHECK_FUNC(mdbm_set_chain)
dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
dnl
AC_DEFUN([OL_LIB_MDBM],
[AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
[ ol_LIBS="$LIBS"
AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
])
LIBS="$ol_LIBS"
])
])dnl
dnl
dnl --------------------------------------------------------------------
dnl Check if MDBM exists
dnl
dnl defines ol_cv_mdbm to 'yes' or 'no'
dnl
dnl uses:
dnl OL_LIB_MDBM
dnl AC_CHECK_HEADERS(mdbm.h)
dnl
AC_DEFUN([OL_MDBM],
[AC_REQUIRE([OL_LIB_MDBM])
AC_CHECK_HEADERS(mdbm.h)
AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
ol_cv_mdbm=no
else
ol_cv_mdbm=yes
fi
])
if test $ol_cv_mdbm = yes ; then
AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
fi
])dnl
dnl
dnl ====================================================================
dnl Check if NDBM library exists
dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
dnl
dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
dnl 'yes' implies ndbm_open is in $LIBS
dnl
dnl uses:
dnl AC_CHECK_FUNC(dbm_open)
dnl AC_CHECK_LIB(ndbm,dbm_open)
dnl AC_CHECK_LIB(dbm,dbm_open)
dnl
dnl restrictions:
dnl should also check SVR4 case: dbm_open() in -lucb but that
dnl would requiring dealing with -L/usr/ucblib
dnl
AC_DEFUN([OL_LIB_NDBM],
[AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
[ ol_LIBS="$LIBS"
AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
[ol_cv_lib_ndbm=no])dnl
])
])
LIBS="$ol_LIBS"
])
])dnl
dnl
dnl --------------------------------------------------------------------
dnl Check if NDBM exists
dnl
dnl defines ol_cv_ndbm to 'yes' or 'no'
dnl
dnl uses:
dnl OL_LIB_NDBM
dnl AC_CHECK_HEADERS(ndbm.h)
dnl
dnl restrictions:
dnl Doesn't handle SVR4 case (see above)
dnl
AC_DEFUN([OL_NDBM],
[AC_REQUIRE([OL_LIB_NDBM])
AC_CHECK_HEADERS(ndbm.h)
AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
ol_cv_ndbm=no
else
ol_cv_ndbm=yes
fi
])
if test $ol_cv_ndbm = yes ; then
AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
fi
])dnl
dnl
dnl ====================================================================
dnl Check POSIX Thread version
dnl
dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
dnl 'unknown' implies that the version could not be detected
dnl or that pthreads.h does exist. Existance of pthreads.h
dnl should be tested separately.
dnl
AC_DEFUN([OL_POSIX_THREAD_VERSION],
[AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
AC_EGREP_CPP(pthread_version_final,[
# include <pthread.h>
/* this check could be improved */
# ifdef PTHREAD_ONCE_INIT
pthread_version_final;
# endif
], ol_pthread_final=yes, ol_pthread_final=no)
AC_EGREP_CPP(pthread_version_draft4,[
# include <pthread.h>
/* this check could be improved */
# ifdef pthread_once_init
pthread_version_draft4;
# endif
], ol_pthread_draft4=yes, ol_pthread_draft4=no)
if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
ol_cv_pthread_version=final
elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
ol_cv_pthread_version=draft4
else
ol_cv_pthread_version=unknown
fi
])
])dnl
dnl
dnl --------------------------------------------------------------------
AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
[/* pthread test headers */
#include <pthread.h>
#ifndef NULL
#define NULL (void*)0
#endif
static void *task(p)
void *p;
{
return (void *) (p == NULL);
}
])
AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
/* pthread test function */
pthread_t t;
int status;
int detach = 1;
#ifdef HAVE_PTHREADS_FINAL
/* Final pthreads */
pthread_attr_t attr;
status = pthread_attr_init(&attr);
if( status ) return status;
#if defined( PTHREAD_CREATE_JOINABLE ) || defined( PTHREAD_UNDETACHED )
if( !detach ) {
#if defined( PTHREAD_CREATE_JOINABLE )
status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
#else
status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_UNDETACHED);
#endif
#ifdef PTHREAD_CREATE_DETACHED
} else {
status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
#endif
}
if( status ) return status;
#endif
status = pthread_create( &t, &attr, task, NULL );
if( status ) return status;
#if !defined( PTHREAD_CREATE_JOINABLE ) && !defined( PTHREAD_UNDETACHED )
if( detach ) {
/* give thread a chance to complete */
/* it should remain joinable and hence detachable */
sleep( 1 );
status = pthread_detach( t );
if( status ) return status;
}
#endif
#else
/* Draft 4 pthreads */
status = pthread_create( &t, pthread_attr_default, task, NULL );
if( status ) return status;
if( detach ) {
/* give thread a chance to complete */
/* it should remain joinable and hence detachable */
sleep( 1 );
status = pthread_detach( &t );
if( status ) return status;
}
#endif
#ifdef HAVE_LINUX_THREADS
pthread_kill_other_threads_np();
#endif
return 0;
])
AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
[OL_PTHREAD_TEST_INCLUDES
int main(argc, argv)
int argc;
char **argv;
{
OL_PTHREAD_TEST_FUNCTION
}
])
dnl --------------------------------------------------------------------
AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
if test "$ol_link_threads" = no ; then
# try $1
AC_CACHE_CHECK([for pthread link with $1], [$2], [
# save the flags
ol_LIBS="$LIBS"
LIBS="$1 $LIBS"
AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
[$2=yes], [$2=no],
[AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
[$2=yes], [$2=no])])
# restore the LIBS
LIBS="$ol_LIBS"
])
if test $$2 = yes ; then
ol_link_pthreads="$1"
ol_link_threads=posix
fi
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 <pthread.h>
#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 for NT Threads
AC_DEFUN([OL_NT_THREADS], [
AC_CHECK_FUNC(_beginthread)
if test $ac_cv_func__beginthread = yes ; then
AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
ol_cv_nt_threads=yes
fi
])
dnl ====================================================================
dnl Check LinuxThreads 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_LINUX_THREADS], [
AC_CACHE_CHECK([for LinuxThreads pthread.h],
[ol_cv_header_linux_threads],
[AC_EGREP_CPP(pthread_kill_other_threads_np,
[#include <pthread.h>],
[ol_cv_header_linux_threads=yes],
[ol_cv_header_linux_threads=no])
])
if test $ol_cv_header_linux_threads = yes; then
AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
fi
])dnl
dnl --------------------------------------------------------------------
dnl Check LinuxThreads Implementation
dnl
dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
dnl 'no' implies pthreads implementation is not LinuxThreads.
dnl
AC_DEFUN([OL_SYS_LINUX_THREADS], [
AC_CHECK_FUNCS(pthread_kill_other_threads_np)
AC_CACHE_CHECK([for LinuxThreads implementation],
[ol_cv_sys_linux_threads],
[ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
])dnl
dnl
dnl --------------------------------------------------------------------
dnl Check LinuxThreads consistency
AC_DEFUN([OL_LINUX_THREADS], [
AC_REQUIRE([OL_HEADER_LINUX_THREADS])
AC_REQUIRE([OL_SYS_LINUX_THREADS])
AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
if test $ol_cv_header_linux_threads = yes -a \
$ol_cv_sys_linux_threads = yes; then
ol_cv_linux_threads=yes
elif test $ol_cv_header_linux_threads = no -a \
$ol_cv_sys_linux_threads = no; then
ol_cv_linux_threads=no
else
ol_cv_linux_threads=error
fi
])
])dnl
dnl
dnl ====================================================================
dnl Check for POSIX Regex
AC_DEFUN([OL_POSIX_REGEX], [
AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
AC_TRY_RUN([
#include <sys/types.h>
#include <regex.h>
static char *pattern, *string;
main()
{
int rc;
regex_t re;
pattern = "^A";
if(regcomp(&re, pattern, 0)) {
return -1;
}
string = "ALL MATCH";
rc = regexec(&re, string, 0, (void*)0, 0);
regfree(&re);
return rc;
}],
[ol_cv_c_posix_regex=yes],
[ol_cv_c_posix_regex=no],
[ol_cv_c_posix_regex=cross])])
])
dnl
dnl ====================================================================
dnl Check if toupper() requires islower() to be called first
AC_DEFUN([OL_C_UPPER_LOWER],
[AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
AC_TRY_RUN([
#include <ctype.h>
main()
{
if ('C' == toupper('C'))
exit(0);
else
exit(1);
}],
[ol_cv_c_upper_lower=no],
[ol_cv_c_upper_lower=yes],
[ol_cv_c_upper_lower=safe])])
if test $ol_cv_c_upper_lower != no ; then
AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
fi
])
dnl
dnl ====================================================================
dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
dnl Reported by Keith Bostic.
AC_DEFUN([OL_SYS_ERRLIST],
[AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
AC_TRY_COMPILE([
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#ifdef WINNT
#include <stdlib.h>
#endif ],
[char *c = (char *) *sys_errlist],
[ol_cv_dcl_sys_errlist=yes
ol_cv_have_sys_errlist=yes],
[ol_cv_dcl_sys_errlist=no])])
#
# It's possible (for near-UNIX clones) that sys_errlist doesn't exist
if test $ol_cv_dcl_sys_errlist = no ; then
AC_DEFINE(DECL_SYS_ERRLIST,1,
[define if sys_errlist is not declared in stdio.h or errno.h])
AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
AC_TRY_LINK([#include <errno.h>],
[char *c = (char *) *sys_errlist],
[ol_cv_have_sys_errlist=yes],
[ol_cv_have_sys_errlist=no])])
fi
if test $ol_cv_have_sys_errlist = yes ; then
AC_DEFINE(HAVE_SYS_ERRLIST,1,
[define if you actually have sys_errlist in your libs])
fi
])dnl
dnl
dnl ====================================================================
dnl Early MIPS compilers (used in Ultrix 4.2) don't like
dnl "int x; int *volatile a = &x; *a = 0;"
dnl -- borrowed from PDKSH
AC_DEFUN(OL_C_VOLATILE,
[AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
[AC_TRY_COMPILE([int x, y, z;],
[volatile int a; int * volatile b = x ? &y : &z;
/* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
*b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
if test $ol_cv_c_volatile = yes; then
:
else
AC_DEFINE(volatile,,[define as empty if volatile is not supported])
fi
])dnl
dnl
dnl ====================================================================
dnl Look for fetch(3)
AC_DEFUN([OL_LIB_FETCH],
[ol_LIBS=$LIBS
LIBS="-lfetch -lcom_err $LIBS"
AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
AC_TRY_LINK([
#include <sys/param.h>
#include <stdio.h>
#include <fetch.h>],
[struct url *u = fetchParseURL("file:///"); ],
[ol_cv_lib_fetch=yes],
[ol_cv_lib_fetch=no])])
LIBS=$ol_LIBS
if test $ol_cv_lib_fetch != no ; then
ol_link_fetch="-lfetch -lcom_err"
AC_DEFINE(HAVE_FETCH,1,
[define if you actually have FreeBSD fetch(3)])
fi
])dnl
dnl
dnl ====================================================================
dnl Define sig_atomic_t if not defined in signal.h
AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
[AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
[AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
if test $ol_cv_type_sig_atomic_t = no; then
AC_DEFINE(sig_atomic_t,int,
[define to atomic type if sig_atomic_t is not available])
fi
])dnl
dnl
dnl ====================================================================
dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
AC_DEFUN(OL_TYPE_SOCKLEN_T,
[AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
[AC_TRY_COMPILE([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
], [socklen_t len;],
ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
if test $ol_cv_type_socklen_t = no; then
AC_DEFINE(socklen_t, int,
[define to int if socklen_t is not available])
fi
])dnl
dnl
dnl ====================================================================
dnl Define inet_aton is available
AC_DEFUN(OL_FUNC_INET_ATON,
[AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
[AC_TRY_LINK([
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
# ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
# endif
# include <netinet/in.h>
# ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
# endif
#endif
], [struct in_addr in;
int rc = inet_aton( "255.255.255.255", &in );],
ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
if test $ol_cv_func_inet_aton != no; then
AC_DEFINE(HAVE_INET_ATON, 1,
[define to you inet_aton(3) is available])
fi
])dnl
dnl
dnl ====================================================================
dnl check no of arguments for ctime_r
AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
[AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
[AC_TRY_COMPILE([#include <time.h>],
[time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
ol_cv_func_ctime_r_nargs3=yes,
ol_cv_func_ctime_r_nargs3=no)
AC_TRY_COMPILE([#include <time.h>],
[time_t ti; char *buffer; ctime_r(&ti,buffer);],
ol_cv_func_ctime_r_nargs2=yes,
ol_cv_func_ctime_r_nargs2=no)
if test $ol_cv_func_ctime_r_nargs3 = yes -a \
$ol_cv_func_ctime_r_nargs2 = no ; then
ol_cv_func_ctime_r_nargs=3
elif test $ol_cv_func_ctime_r_nargs3 = no -a \
$ol_cv_func_ctime_r_nargs2 = yes ; then
ol_cv_func_ctime_r_nargs=2
else
ol_cv_func_ctime_r_nargs=0
fi
])
if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
[set to the number of arguments ctime_r() expects])
fi
])dnl
dnl
dnl --------------------------------------------------------------------
dnl check return type of ctime_r()
AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
[AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
[AC_TRY_COMPILE([#include <time.h>],
[extern int (ctime_r)();],
ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
])
if test $ol_cv_func_ctime_r_type = "int" ; then
AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
fi
])dnl
dnl ====================================================================
dnl check no of arguments for gethostbyname_r
AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
[AC_CACHE_CHECK(number of arguments of gethostbyname_r,
ol_cv_func_gethostbyname_r_nargs,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define BUFSIZE (sizeof(struct hostent)+10)],
[struct hostent hent; char buffer[BUFSIZE];
int bufsize=BUFSIZE;int h_errno;
(void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
buffer, bufsize, &h_errno);],
ol_cv_func_gethostbyname_r_nargs5=yes,
ol_cv_func_gethostbyname_r_nargs5=no)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define BUFSIZE (sizeof(struct hostent)+10)],
[struct hostent hent;struct hostent *rhent;
char buffer[BUFSIZE];
int bufsize=BUFSIZE;int h_errno;
(void)gethostbyname_r("localhost", &hent, buffer, bufsize,
&rhent, &h_errno);],
ol_cv_func_gethostbyname_r_nargs6=yes,
ol_cv_func_gethostbyname_r_nargs6=no)
if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
$ol_cv_func_gethostbyname_r_nargs6 = no ; then
ol_cv_func_gethostbyname_r_nargs=5
elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
$ol_cv_func_gethostbyname_r_nargs6 = yes ; then
ol_cv_func_gethostbyname_r_nargs=6
else
ol_cv_func_gethostbyname_r_nargs=0
fi
])
if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
$ol_cv_func_gethostbyname_r_nargs,
[set to the number of arguments gethostbyname_r() expects])
fi
])dnl
dnl
dnl check no of arguments for gethostbyaddr_r
AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
[AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
[ol_cv_func_gethostbyaddr_r_nargs],
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define BUFSIZE (sizeof(struct hostent)+10)],
[struct hostent hent; char buffer[BUFSIZE];
struct in_addr add;
size_t alen=sizeof(struct in_addr);
int bufsize=BUFSIZE;int h_errno;
(void)gethostbyaddr_r( (void *)&(add.s_addr),
alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
ol_cv_func_gethostbyaddr_r_nargs7=yes,
ol_cv_func_gethostbyaddr_r_nargs7=no)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define BUFSIZE (sizeof(struct hostent)+10)],
[struct hostent hent;
struct hostent *rhent; char buffer[BUFSIZE];
struct in_addr add;
size_t alen=sizeof(struct in_addr);
int bufsize=BUFSIZE;int h_errno;
(void)gethostbyaddr_r( (void *)&(add.s_addr),
alen, AF_INET, &hent, buffer, bufsize,
&rhent, &h_errno);],
ol_cv_func_gethostbyaddr_r_nargs8=yes,
ol_cv_func_gethostbyaddr_r_nargs8=no)
if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
$ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
ol_cv_func_gethostbyaddr_r_nargs=7
elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
$ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
ol_cv_func_gethostbyaddr_r_nargs=8
else
ol_cv_func_gethostbyaddr_r_nargs=0
fi
])
if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
$ol_cv_func_gethostbyaddr_r_nargs,
[set to the number of arguments gethostbyaddr_r() expects])
fi
])dnl
dnl
dnl --------------------------------------------------------------------
dnl Check for Cyrus SASL version compatility, need 2.1.3 or newer
AC_DEFUN([OL_SASL_COMPAT],
[AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
AC_EGREP_CPP(__sasl_compat,[
#ifdef HAVE_SASL_SASL_H
#include <sasl/sasl.h>
#else
#include <sasl.h>
#endif
/* require 2.1.3 or later */
#if SASL_VERSION_MAJOR == 1 && SASL_VERSION_MINOR >= 5
char *__sasl_compat = "1.5.x okay";
#elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
__sasl_compat "2.2+ or better okay (we guess)";
#elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
&& SASL_VERSION_STEP >=3
__sasl_compat = "2.1.3+ or better okay";
#endif
], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
])
# $OpenLDAP$
## Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted only as authorized by the OpenLDAP
## Public License. A copy of this license is available at
## http://www.OpenLDAP.org/license.html or in file LICENSE in the
## top-level directory of the distribution.
##
PACKAGE= @PACKAGE@
VERSION= @VERSION@
RELEASEDATE= @OPENLDAP_RELEASE_DATE@
@SET_MAKE@
SHELL = /bin/sh
top_builddir = @top_builddir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
ldap_subdir = @ldap_subdir@
bindir = @bindir@
datadir = @datadir@$(ldap_subdir)
includedir = @includedir@
infodir = @infodir@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
moduledir = @libexecdir@$(ldap_subdir)
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@$(ldap_subdir)
schemadir = $(sysconfdir)/schema
PLAT = @PLAT@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
BUILD_LIBS_DYNAMIC = @BUILD_LIBS_DYNAMIC@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
LINT = lint
5LINT = 5lint
MKDEP = $(top_srcdir)/build/mkdep $(MKDEPFLAG) \
-d "$(srcdir)" -c "$(MKDEP_CC)" -m "$(MKDEP_CFLAGS)"
MKDEP_CC = @OL_MKDEP@
MKDEP_CFLAGS = @OL_MKDEP_FLAGS@
MKVERSION = $(top_srcdir)/build/mkversion -v "$(VERSION)"
SHTOOL = $(top_srcdir)/build/shtool
LIBTOOL = @LIBTOOL@
LIBVERSION = @OPENLDAP_LIBVERSION@
LTVERSION = -version-info $(LIBVERSION)
# libtool --only flag for libraries: platform specific
NT_LTONLY_LIB = --only-$(BUILD_LIBS_DYNAMIC)
LTONLY_LIB = $(@PLAT@_LTONLY_LIB)
# libtool --only flag for modules: depends on linkage of module
# The BUILD_MOD_DYNAMIC macro is defined in each backend Makefile.in file
LTONLY_MOD = # --only-$(BUILD_MOD_DYNAMIC)
# platform-specific libtool flags
NT_LTFLAGS_LIB = -no-undefined -avoid-version -rpath $(libdir)
NT_LTFLAGS_MOD = -no-undefined -avoid-version -rpath $(moduledir)
UNIX_LTFLAGS_LIB = $(LTVERSION) -rpath $(libdir)
UNIX_LTFLAGS_MOD = $(LTVERSION) -rpath $(moduledir)
# libtool flags
LTFLAGS = $(@PLAT@_LTFLAGS)
LTFLAGS_LIB = $(@PLAT@_LTFLAGS_LIB)
LTFLAGS_MOD = $(@PLAT@_LTFLAGS_MOD)
# LIB_DEFS defined in liblber and libldap Makefile.in files.
# MOD_DEFS defined in backend Makefile.in files.
# platform-specific LINK_LIBS defined in various Makefile.in files.
# LINK_LIBS referenced in library and module link commands.
LINK_LIBS = $(@PLAT@_LINK_LIBS)
LTLINK = $(LIBTOOL) --mode=link \
$(CC) -static $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS)
LTCOMPILE_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=compile \
$(CC) $(LT_CFLAGS) $(LT_CPPFLAGS) $(LIB_DEFS) -c
LTLINK_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=link \
$(CC) $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS_LIB)
LTCOMPILE_MOD = $(LIBTOOL) $(LTONLY_MOD) --mode=compile \
$(CC) $(LT_CFLAGS) $(LT_CPPFLAGS) $(MOD_DEFS) -c
LTLINK_MOD = $(LIBTOOL) $(LTONLY_MOD) --mode=link \
$(CC) $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS_MOD)
LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
LTFINISH = $(LIBTOOL) --mode=finish
# Misc UNIX commands used in build environment
AR = @AR@
AWK = @AWK@
BASENAME = basename
CAT = cat
CHMOD = chmod
DATE = date
HOSTNAME = $(SHTOOL) echo -e "%h%d"
LN = ln
LN_H = @LN_H@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
MKDIR = $(SHTOOL) mkdir -p
MV = mv
PWD = pwd
RANLIB = @RANLIB@
RM = rm -f
SED = sed
# Misc UNIX commands used in programs
EDITOR = @EDITOR@
SENDMAIL = @SENDMAIL@
# For manual pages
# MANCOMPRESS=@MANCOMPRESS@
# MANCOMPRESSSUFFIX=@MANCOMPRESSSUFFIX@
MANCOMPRESS=$(CAT)
MANCOMPRESSSUFFIX=
INCLUDEDIR= $(top_srcdir)/include
LDAP_INCPATH= -I$(LDAP_INCDIR) -I$(INCLUDEDIR)
LDAP_LIBDIR= $(top_builddir)/libraries
LUTIL_LIBS = @LUTIL_LIBS@
LDIF_LIBS = @LDIF_LIBS@
LDBM_LIBS = @LDBM_LIBS@
LTHREAD_LIBS = @LTHREAD_LIBS@
LDAP_LIBLBER_LA = $(LDAP_LIBDIR)/liblber/liblber.la
LDAP_LIBLDAP_LA = $(LDAP_LIBDIR)/libldap/libldap.la
LDAP_LIBLDAP_R_LA = $(LDAP_LIBDIR)/libldap_r/libldap_r.la
LDAP_LIBAVL_A = $(LDAP_LIBDIR)/libavl/libavl.a
LDAP_LIBLDBM_A = $(LDAP_LIBDIR)/libldbm/libldbm.a
LDAP_LIBLDIF_A = $(LDAP_LIBDIR)/libldif/libldif.a
LDAP_LIBREWRITE_A = $(LDAP_LIBDIR)/librewrite/librewrite.a
LDAP_LIBLUNICODE_A = $(LDAP_LIBDIR)/liblunicode/liblunicode.a
LDAP_LIBLUTIL_A = $(LDAP_LIBDIR)/liblutil/liblutil.a
LDAP_L = $(LDAP_LIBLUTIL_A) $(LDAP_LIBLDIF_A) \
$(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA)
SLURPD_L = $(LDAP_LIBLDIF_A) $(LDAP_LIBLUTIL_A) \
$(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
SLAPD_L = $(LDAP_LIBAVL_A) $(LDAP_LIBLDBM_A) \
$(LDAP_LIBLUNICODE_A) $(LDAP_LIBREWRITE_A) \
$(SLURPD_L)
WRAP_LIBS = @WRAP_LIBS@
# AutoConfig generated
AC_CC = @CC@
AC_CFLAGS = @CFLAGS@
AC_DEFS = @CPPFLAGS@ # @DEFS@
AC_LDFLAGS = @LDFLAGS@
AC_LIBS = @LIBS@
KRB4_LIBS = @KRB4_LIBS@
KRB5_LIBS = @KRB5_LIBS@
KRB_LIBS = @KRB4_LIBS@ @KRB5_LIBS@
SASL_LIBS = @SASL_LIBS@
TLS_LIBS = @TLS_LIBS@
AUTH_LIBS = @AUTH_LIBS@
SECURITY_LIBS = $(SASL_LIBS) $(KRB_LIBS) $(TLS_LIBS) $(AUTH_LIBS)
MODULES_CPPFLAGS = @SLAPD_MODULES_CPPFLAGS@
MODULES_LDFLAGS = @SLAPD_MODULES_LDFLAGS@
MODULES_LIBS = @MODULES_LIBS@
TERMCAP_LIBS = @TERMCAP_LIBS@
SLAPD_PERL_LDFLAGS = @SLAPD_PERL_LDFLAGS@
SLAPD_SQL_LDFLAGS = @SLAPD_SQL_LDFLAGS@
SLAPD_SQL_INCLUDES = @SLAPD_SQL_INCLUDES@
SLAPD_SQL_LIBS = @SLAPD_SQL_LIBS@
SLAPD_LIBS = @SLAPD_LIBS@ @SLAPD_PERL_LDFLAGS@ @SLAPD_SQL_LDFLAGS@ @SLAPD_SQL_LIBS@ @SLAPD_SLP_LIBS@
SLURPD_LIBS = @SLURPD_LIBS@
# Our Defaults
CC = $(AC_CC)
DEFS = $(LDAP_INCPATH) $(XINCPATH) $(XDEFS) $(AC_DEFS) $(DEFINES)
CFLAGS = $(AC_CFLAGS) $(DEFS)
LDFLAGS = $(LDAP_LIBPATH) $(AC_LDFLAGS) $(XLDFLAGS)
LIBS = $(XLIBS) $(XXLIBS) $(AC_LIBS) $(XXXLIBS)
LT_CFLAGS = $(AC_CFLAGS)
LT_CPPFLAGS = $(DEFS)
all: all-common all-local FORCE
install: install-common install-local FORCE
clean: clean-common clean-local FORCE
veryclean: veryclean-common veryclean-local FORCE
depend: depend-common depend-local FORCE
# empty common rules
all-common:
install-common:
clean-common:
veryclean-common: clean-common FORCE
depend-common:
lint-common:
lint5-common:
# empty local rules
all-local:
install-local:
clean-local:
veryclean-local: clean-local FORCE
depend-local:
lint-local:
lint5-local:
veryclean: FORCE
$(RM) Makefile
$(RM) -r .libs
Makefile: Makefile.in $(top_srcdir)/build/top.mk
pathtest:
$(SHTOOL) --version
# empty rule for forcing rules
FORCE:
##---------------------------------------------------------------------------
#! /bin/sh
# $OpenLDAP$
## Copyright 2000-2002 The OpenLDAP Foundation
## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory
## of this package for details.
#
ol_package=OpenLDAP
ol_major=2
ol_minor=1
ol_patch=X
ol_api_inc=20103
ol_api_lib=2:103:0
if test $ol_patch != X ; then
ol_version=${ol_major}.${ol_minor}.${ol_patch}
ol_type=Release
elif test $ol_minor != X ; then
ol_version=${ol_major}.${ol_minor}.${ol_patch}
ol_type=Engineering
else
ol_version=${ol_major}.${ol_minor}
ol_type=Devel
ol_api_lib=0:0:0
fi
ol_string="${ol_package} ${ol_version}-${ol_type}"
echo OL_PACKAGE=\"${ol_package}\"
echo OL_MAJOR=$ol_major
echo OL_MINOR=$ol_minor
echo OL_PATCH=$ol_patch
echo OL_API_INC=$ol_api_inc
echo OL_API_LIB=$ol_api_lib
echo OL_VERSION=$ol_version
echo OL_TYPE=$ol_type
echo OL_STRING=\"${ol_string}\"
# $OpenLDAP$
## Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
## COPYING RESTRICTIONS APPLY, See COPYRIGHT file
##
## Clients Makefile.in for OpenLDAP
SUBDIRS = tools
/*
* Copyright (c) 1990,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.
*/
#include "lber.h"
#include "ldap.h"
#include "disptmpl.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <syslog.h>
#include <sys/resource.h>
#include <sys/wait.h>
#ifdef aix
#include <sys/select.h>
#endif /* aix */
#include <signal.h>
#include "portable.h"
#include "ldapconfig.h"
#ifdef USE_SYSCONF
#include <unistd.h>
#endif /* USE_SYSCONF */
int dosyslog = 1;
char *ldaphost = LDAPHOST;
int ldapport = LDAP_PORT;
char *base = FINGER_BASE;
int deref;
char *filterfile = FILTERFILE;
char *templatefile = TEMPLATEFILE;
int rdncount = FINGER_RDNCOUNT;
static do_query();
static do_search();
static do_read();
static print_attr();
static usage( name )
char *name;
{
fprintf( stderr, "usage: %s [-l] [-x ldaphost] [-p ldapport] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
exit( 1 );
}
main (argc, argv)
int argc;
char **argv;
{
int i;
char *myname;
unsigned long mypeer = -1;
struct hostent *hp;
struct sockaddr_in peername;
int peernamelen;
int interactive = 0;
extern char *optarg;
deref = FINGER_DEREF;
while ( (i = getopt( argc, argv, "f:ilp:t:x:p:c:" )) != EOF ) {
switch( i ) {
case 'f': /* ldap filter file */
filterfile = strdup( optarg );
break;
case 'i': /* interactive */
interactive = 1;
break;
case 'l': /* don't do syslogging */
dosyslog = 0;
break;
case 't': /* ldap template file */
templatefile = strdup( optarg );
break;
case 'x': /* specify ldap host */
ldaphost = strdup( optarg );
break;
case 'p': /* specify ldap port */
ldapport = atoi( optarg );
break;
case 'c': /* specify number of DN components to show */
rdncount = atoi( optarg );
break;
default:
usage( argv[0] );
}
}
if ( !interactive ) {
peernamelen = sizeof(peername);
if ( getpeername( 0, (struct sockaddr *)&peername,
&peernamelen ) != 0 ) {
perror( "getpeername" );
exit( 1 );
}
mypeer = (unsigned long) peername.sin_addr.s_addr;
}
#ifdef FINGER_BANNER
if ( FINGER_BANNER != NULL && strcmp( FINGER_BANNER, "" ) != 0 ) {
printf( FINGER_BANNER );
fflush( stdout );
}
#endif
if ( (myname = strrchr( argv[0], '/' )) == NULL )
myname = strdup( argv[0] );
else
myname = strdup( myname + 1 );
if ( dosyslog ) {
#ifdef LOG_LOCAL4
openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL4 );
#else
openlog( myname, OPENLOG_OPTIONS );
#endif
}
if ( dosyslog && mypeer != -1 ) {
struct in_addr addr;
hp = gethostbyaddr( (char *) &mypeer, sizeof(mypeer), AF_INET );
addr.s_addr = mypeer;
syslog( LOG_INFO, "connection from %s (%s)", (hp == NULL) ?
"unknown" : hp->h_name, inet_ntoa( addr ) );
}
do_query();
return( 0 );
}
static do_query()
{
char buf[256];
int len, rc, tblsize;
struct timeval timeout;
fd_set readfds;
LDAP *ld;
if ( (ld = ldap_open( ldaphost, ldapport )) == NULL ) {
fprintf( stderr, FINGER_UNAVAILABLE );
perror( "ldap_open" );
exit( 1 );
}
ld->ld_sizelimit = FINGER_SIZELIMIT;
ld->ld_deref = deref;
if ( ldap_simple_bind_s( ld, FINGER_BINDDN, NULL ) != LDAP_SUCCESS ) {
fprintf( stderr, FINGER_UNAVAILABLE );
ldap_perror( ld, "ldap_simple_bind_s" );
exit( 1 );
}
#ifdef USE_SYSCONF
tblsize = sysconf( _SC_OPEN_MAX );
#else /* USE_SYSCONF */
tblsize = getdtablesize();
#endif /* USE_SYSCONF */
timeout.tv_sec = FINGER_TIMEOUT;
timeout.tv_usec = 0;
FD_ZERO( &readfds );
FD_SET( fileno( stdin ), &readfds );
if ( (rc = select( tblsize, &readfds, 0, 0, &timeout )) <= 0 ) {
if ( rc < 0 )
perror( "select" );
else
fprintf( stderr, "connection timed out on input\r\n" );
exit( 1 );
}
if ( fgets( buf, sizeof(buf), stdin ) == NULL )
exit( 1 );
len = strlen( buf );
/* strip off \r \n */
if ( buf[len - 1] == '\n' ) {
buf[len - 1] = '\0';
len--;
}
if ( buf[len - 1] == '\r' ) {
buf[len - 1] = '\0';
len--;
}
if ( len == 0 ) {
printf( "No campus-wide login information available. Info for this machine only:\r\n" );
fflush( stdout );
execl( FINGER_CMD, FINGER_CMD, NULL );
} else {
char *p;
/* skip and ignore stinking /w */
if ( strncmp( buf, "/W ", 2 ) == 0 ) {
p = buf + 2;
} else {
p = buf;
}
for ( ; *p && isspace( *p ); p++ )
; /* NULL */
do_search( ld, p );
}
}
static void
spaces2dots( s )
char *s;
{
for ( ; *s; s++ ) {
if ( *s == ' ' ) {
*s = '.';
}
}
}
static do_search( ld, buf )
LDAP *ld;
char *buf;
{
char *dn, *rdn;
char **title;
int rc, matches, i, ufn;
struct timeval tv;
LDAPFiltInfo *fi;
LDAPMessage *result, *e;
static char *attrs[] = { "cn", "title", "objectClass", "joinable",
#ifdef FINGER_SORT_ATTR
FINGER_SORT_ATTR,
#endif
0 };
extern int strcasecmp();
ufn = 0;
#ifdef FINGER_UFN
if ( strchr( buf, ',' ) != NULL ) {
ldap_ufn_setprefix( ld, base );
tv.tv_sec = FINGER_TIMEOUT;
tv.tv_usec = 0;
ldap_ufn_timeout( (void *) &tv );
if ( (rc = ldap_ufn_search_s( ld, buf, attrs, 0, &result ))
!= LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED ) {
fprintf( stderr, FINGER_UNAVAILABLE );
ldap_perror( ld, "ldap_search_st" );
exit( 1 );
}
matches = ldap_count_entries( ld, result );
ufn = 1;
} else {
#endif
if ( (ld->ld_filtd = ldap_init_getfilter( filterfile ))
== NULL ) {
fprintf( stderr, "Cannot open filter file (%s)\n",
filterfile );
exit( 1 );
}
for ( fi = ldap_getfirstfilter( ld->ld_filtd, "finger", buf );
fi != NULL;
fi = ldap_getnextfilter( ld->ld_filtd ) )
{
tv.tv_sec = FINGER_TIMEOUT;
tv.tv_usec = 0;
if ( (rc = ldap_search_st( ld, base, LDAP_SCOPE_SUBTREE,
fi->lfi_filter, attrs, 0, &tv, &result ))
!= LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED
&& rc != LDAP_TIMELIMIT_EXCEEDED )
{
fprintf( stderr, FINGER_UNAVAILABLE );
ldap_perror( ld, "ldap_search_st" );
exit( 1 );
}
if ( (matches = ldap_count_entries( ld, result )) != 0 )
break;
ldap_msgfree( result );
result = NULL;
}
#ifdef FINGER_UFN
}
#endif
if ( rc == LDAP_SIZELIMIT_EXCEEDED ) {
printf( "(Partial results - a size limit was exceeded)\r\n" );
} else if ( rc == LDAP_TIMELIMIT_EXCEEDED ) {
printf( "(Partial results - a time limit was exceeded)\r\n" );
}
if ( matches == 0 ) {
printf( FINGER_NOMATCH );
fflush( stdout );
} else if ( matches < 0 ) {
fprintf( stderr, "error return from ldap_count_entries\r\n" );
exit( 1 );
} else if ( matches <= FINGER_LISTLIMIT ) {
printf( "%d %s match%s found for \"%s\":\r\n", matches,
ufn ? "UFN" : fi->lfi_desc, matches > 1 ? "es" : "", buf );
fflush( stdout );
for ( e = ldap_first_entry( ld, result ); e != NULL; ) {
do_read( ld, e );
e = ldap_next_entry( ld, e );
if ( e != NULL ) {
printf( "--------------------\r\n" );
}
}
} else {
printf( "%d %s matches for \"%s\":\r\n", matches,
ufn ? "UFN" : fi->lfi_desc, buf );
fflush( stdout );
#ifdef FINGER_SORT_ATTR
ldap_sort_entries( ld, &result, FINGER_SORT_ATTR, strcasecmp );
#endif
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
char *p;
dn = ldap_get_dn( ld, e );
rdn = dn;
if ( (p = strchr( dn, ',' )) != NULL )
*p = '\0';
while ( *rdn && *rdn != '=' )
rdn++;
if ( *rdn )
rdn++;
/* hack attack */
for ( i = 0; buf[i] != '\0'; i++ ) {
if ( buf[i] == '.' || buf[i] == '_' )
buf[i] = ' ';
}
if ( strcasecmp( rdn, buf ) == 0 ) {
char **cn;
int i, last;
cn = ldap_get_values( ld, e, "cn" );
for ( i = 0; cn[i] != NULL; i++ ) {
last = strlen( cn[i] ) - 1;
if ( isdigit( cn[i][last] ) ) {
rdn = strdup( cn[i] );
break;
}
}
}
title = ldap_get_values( ld, e, "title" );
spaces2dots( rdn );
printf( " %-20s %s\r\n", rdn,
title ? title[0] : "" );
if ( title != NULL ) {
for ( i = 1; title[i] != NULL; i++ )
printf( " %-20s %s\r\n", "",
title[i] );
}
fflush( stdout );
if ( title != NULL )
ldap_value_free( title );
free( dn );
}
}
if ( result != NULL ) {
ldap_msgfree( result );
}
ldap_unbind( ld );
}
static int
entry2textwrite( void *fp, char *buf, int len )
{
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
}
static do_read( ld, e )
LDAP *ld;
LDAPMessage *e;
{
static struct ldap_disptmpl *tmpllist;
static char *defattrs[] = { "mail", NULL };
static char *mailvals[] = FINGER_NOEMAIL;
static char **defvals[] = { mailvals, NULL };
ldap_init_templates( templatefile, &tmpllist );
if ( ldap_entry2text_search( ld, NULL, base, e, tmpllist, defattrs,
defvals, entry2textwrite, (void *)stdout, "\r\n", rdncount,
LDAP_DISP_OPT_DOSEARCHACTIONS ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_entry2text_search" );
exit( 1 );
}
if ( tmpllist != NULL ) {
ldap_free_templates( tmpllist );
}
}
This is the README file for mail500, a mailer that does X.500 lookups
via LDAP.
If you are planning to run mail500 at your site, there are several
things you will have to tailor in main.c:
LDAPHOST - The host running an LDAP server
base[] - The array telling mail500 where/how to search for
things. See the explanation below.
*** WHAT mail500 DOES: ***
mail500 is designed to be invoked as a mailer (e.g., from sendmail),
similar to the way /bin/mail works. It takes a few required arguments
and then a list of addresses to deliver to. It expects to find the
message to deliver on its standard input. It looks up the addresses in
X.500 to figure out where to route the mail, and then execs sendmail to
do the actual delivery. It supports simple aliases, groups, and
mailing lists, the details of which are given below.
*** HOW IT WORKS (from the sendmail side): ***
The idea is that you might have a rule like this in your sendmail.cf
file somewhere in rule set 0:
R$*<@umich.edu>$* $#mail500$@umich.edu$:<$1>
This rule says that any address that ends in @umich.edu will cause
the mail500 mailer to be called to deliver the mail. You probably
also want to do something to prevent addresses like terminator!tim@umich.edu
or tim%terminator.rs.itd.umich.edu@umich.edu from being passed to mail500.
At U-M, we do this by adding rules like this to rule set 9 where we
strip off our local names:
R<@umich.edu>$*:$* $>10<@>$1:$2
R$+%$+<@umich.edu> $>10$1%$2<@>
R$+!$+<@umich.edu> $>10$1!$2<@>
See the sample sendmail.cf in this directory for more details.
The mail500 mailer should be defined similar to this in the
sendmail.cf file:
Mmail500, P=/usr/local/etc/mail500, F=DFMSmnXuh, A=mail500 -f $f -h $h -m $n@$w $u
This defines how mail500 will be treated by sendmail and what
arguments it will have when it's called. The various flags specified
by the F=... parameter are explained in your local sendmail book (with
any luck). The arguments to mail500 are as follows:
-f Who the mail is from. This will be used as the address
to which any errors should be sent (unless the address
specifies a mailing list - see below). Normally, sendmail
defines the $f macro to be the sender.
-h The domain for which the mail is destined. This is passed
in to mail500 via the $h macro, which is set by the
$@ metasymbol in the rule added to rule set 0 above.
It's normally used when searching for groups.
-m The mailer-daemon address. If errors have to be sent,
this is the address they will come from. $n is normally
set to mailer-daemon and $w is normally the local host
name.
The final argument $u is used to stand for the addresses to which to
deliver the mail.
*** HOW IT WORKS (from the mail500 side): ***
When mail500 gets invoked with one or more names to which to
deliver mail, it searches for each name in X.500. Where it searches,
and what kind(s) of search(es) it does are compile-time configurable
by changing the base array in main.c. For example, the configuration
we use at U-M is like this:
Base base[] =
{ "ou=People, o=University of Michigan, c=US", 0
"uid=%s", "cn=%s", NULL,
"ou=System Groups, ou=Groups, o=University of Michigan, c=US", 1
"(&(cn=%s)(associatedDomain=%h))", NULL, NULL,
"ou=User Groups, ou=Groups, o=University of Michigan, c=US", 1
"(&(cn=%s)(associatedDomain=%h))", NULL, NULL,
NULL
};
which means that in delivering mail to "name" mail500 would do the
the following searches, stopping if it found anything at any step:
Search (18) [2]: c=US@o=University of Michigan@ou=People
Search subtree (uid=name)
Search (18) [3]: c=US@o=University of Michigan@ou=People
Search subtree (cn=name)
Search (18) [4]: c=US@o=University of Michigan@ou=Groups@ou=System Groups
Search subtree & ((cn=name)(associatedDomain=umich.edu))
Search (18) [5]: c=US@o=University of Michigan@ou=Groups@ou=User Groups
Search subtree & ((cn=name)(associatedDomain=umich.edu))
Notice that when specifying a filter %s is replaced by the name,
or user portion of the address while %h is replaced by whatever is
passed in to mail500 via the -h option (typically the host portion
of the address).
You can also specify whether you want search results that matched
because the entry's RDN matched the search to be given preference
or not. At U-M, we only give such preference in the mail group
portion of the searches. Beware with this option: the algorithm
used to decide whether an entry's RDN matched the search is very
simple-minded, and may not always be correct.
There is currently no limit on the number of areas searched (the base
array can be as large as you want), and an arbitrary limit of 2 filters
for each base. If you want more than that, simply changing the 3 in
the typedef for Base should do the trick.
*** HOW IT WORKS (from the X.500 side): ***
In X.500, there are several new attribute types and one new object
class defined that mail500 makes use of. At its most basic, for normal
entries mail500 will deliver to the value(s) listed in the
rfc822Mailbox attribute of the entry. For example, at U-M my entry has
the attribute
mail= tim@terminator.rs.itd.umich.edu
So mail sent to tim@umich.edu will be delivered via mail500 to that
address. If there were multiple values for the mail attribute, multiple
copies of the mail would be sent.
A new object class, rfc822MailGroup, and several new attributes have
been defined to handle email groups/mailing lists. To use this, you
will need to add this to your local oidtable.oc:
# object class for representing rfc 822 mailgroups
rfc822MailGroup: umichObjectClass.2 : \
top : \
cn : \
rfc822Mailbox, member, memberOfGroup, owner, \
errorsTo, rfc822ErrorsTo, requestsTo, rfc822RequestsTo,
joinable, associatedDomain, \
description, multiLineDescription, \
userPassword, krbName, \
telecommunicationAttributeSet, postalAttributeSet
And you will need to add these to your local oidtable.at:
# attrs for rfc822mailgroups
multiLineDescription: umichAttributeType.2 : CaseIgnoreList
rfc822ErrorsTo: umichAttributeType.26 : CaseIgnoreIA5String
rfc822RequestsTo: umichAttributeType.27 : CaseIgnoreIA5String
joinable: umichAttributeType.28 : Boolean
memberOfGroup: umichAttributeType.29 : DN
errorsTo: umichAttributeType.30 : DN
requestsTo: umichAttributeType.31 : DN
The idea was to define a kind of hybrid mail group that could handle
people who were in X.500 or not. So, for example, members of a group
can be specified via the member attribute (for X.500 members) or the
rfc822MailBox attribute (for non-X.500 members). Similarly for the
errorsTo and rfc822ErrorsTo, and the requestsTo and rfc822RequestsTo
attributes.
To create a real mailing list, with a list maintainer, all you have to
do is create an rfc822MailGroup and fill in the errorsTo or
rfc822ErrorsTo attributes (or both). That will cause any errors
encountered when delivering mail to the group to go to the addresses
listed (or X.500 entry via it's mail attribute).
If you fill in the requestsTo or rfc822RequestsTo (or both) attributes,
mail sent to groupname-request will be sent to the addresses listed
there. mail500 does this automatically, so you don't have to explicitly
add the groupname-request alias to your group.
To allow users to join a group, there is the joinable flag. If TRUE,
mail500 will search for entries that have a memberOfGroup attribute
equal to the DN of the group, using the same algorithm it used to find
the group in the first place (i.e. the DNs and filters listed in the
base array). This allows people to join (or subscribe to) a group
without having to modify the group entry directly. If joinable is
FALSE, the search is not done.
Finally, keep in mind that this is somewhat experimental at the moment.
We are using it in production at U-M, but your mileage may vary...
/*
* 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.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <memory.h>
#include <sys/types.h>
#include <sys/time.h>
#include <syslog.h>
#include <sys/param.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sysexits.h>
#include "portable.h"
#include "lber.h"
#include "ldap.h"
#include "ldapconfig.h"
#define USER 0x01
#define GROUP_ERRORS 0x02
#define GROUP_REQUEST 0x04
#define GROUP_MEMBERS 0x08
#define GROUP_OWNER 0x10
#define ERROR "error"
#define ERRORS "errors"
#define REQUEST "request"
#define REQUESTS "requests"
#define MEMBERS "members"
#define OWNER "owner"
#define OWNERS "owners"
LDAP *ld;
char *vacationhost = NULL;
char *errorsfrom = NULL;
char *mailfrom = NULL;
char *host = NULL;
char *ldaphost = LDAPHOST;
int hostlen = 0;
int debug;
typedef struct errs {
int e_code;
#define E_USERUNKNOWN 1
#define E_AMBIGUOUS 2
#define E_NOEMAIL 3
#define E_NOREQUEST 4
#define E_NOERRORS 5
#define E_BADMEMBER 6
#define E_JOINMEMBERNOEMAIL 7
#define E_MEMBERNOEMAIL 8
#define E_LOOP 9
#define E_NOMEMBERS 10
#define E_NOOWNER 11
#define E_GROUPUNKNOWN 12
char *e_addr;
union {
char *e_u_loop;
LDAPMessage *e_u_msg;
} e_union;
#define e_msg e_union.e_u_msg
#define e_loop e_union.e_u_loop
} Error;
typedef struct groupto {
char *g_dn;
char *g_errorsto;
char **g_members;
} Group;
typedef struct baseinfo {
char *b_dn; /* dn to start searching at */
char b_rdnpref; /* give rdn's preference when searching? */
int b_search; /* ORed with the type of thing the address */
/* looks like (USER, GROUP_ERRORS, etc.) */
/* to see if this should be searched */
char *b_filter[3]; /* filter to apply - name substituted for %s */
/* (up to three of them) */
} Base;
Base base[] =
{ "ou=People, o=University of Michigan, c=US",
0, USER,
"uid=%s", "cn=%s", NULL,
"ou=System Groups, ou=Groups, o=University of Michigan, c=US",
1, 0xff,
"(&(cn=%s)(associatedDomain=%h))", NULL, NULL,
"ou=User Groups, ou=Groups, o=University of Michigan, c=US",
1, 0xff,
"(&(cn=%s)(associatedDomain=%h))", NULL, NULL,
NULL
};
char *sendmailargs[] = { MAIL500_SENDMAIL, "-oMrX.500", "-odi", "-oi", "-f", NULL, NULL };
static char *attrs[] = { "objectClass", "title", "postaladdress",
"telephoneNumber", "mail", "description", "owner",
"errorsTo", "rfc822ErrorsTo", "requestsTo",
"rfc822RequestsTo", "joinable", "cn", "member",
"moderator", "onVacation", "uid",
"suppressNoEmailError", NULL };
static do_address();
static do_group();
static do_group_members();
static send_message();
static send_errors();
static do_noemail();
static do_ambiguous();
static add_to();
static isgroup();
static add_error();
static add_group();
static unbind_and_exit();
static group_loop();
static send_group();
static has_attributes();
static char **get_attributes_mail_dn();
static char *canonical();
main (argc, argv)
int argc;
char **argv;
{
char *myname;
char **tolist;
Error *errlist;
Group *togroups;
int numto, ngroups, numerr, nargs;
int i, j;
FILE *fp;
extern int optind, errno;
extern char *optarg;
if ( (myname = strrchr( argv[0], '/' )) == NULL )
myname = strdup( argv[0] );
else
myname = strdup( myname + 1 );
#ifdef LOG_MAIL
openlog( myname, OPENLOG_OPTIONS, LOG_MAIL );
#else
openlog( myname, OPENLOG_OPTIONS );
#endif
while ( (i = getopt( argc, argv, "d:f:h:l:m:v:" )) != EOF ) {
switch( i ) {
case 'd': /* turn on debugging */
debug = atoi( optarg );
break;
case 'f': /* who it's from & where errors should go */
mailfrom = strdup( optarg );
for ( j = 0; sendmailargs[j] != NULL; j++ ) {
if ( strcmp( sendmailargs[j], "-f" ) == 0 ) {
sendmailargs[j+1] = mailfrom;
break;
}
}
break;
case 'h': /* hostname */
host = strdup( optarg );
hostlen = strlen(host);
break;
case 'l': /* ldap host */
ldaphost = strdup( optarg );
break;
/* mailer-daemon address - who we should */
case 'm': /* say errors come from */
errorsfrom = strdup( optarg );
break;
case 'v': /* vacation host */
vacationhost = strdup( optarg );
break;
default:
syslog( LOG_ALERT, "unknown option" );
break;
}
}
if ( mailfrom == NULL ) {
syslog( LOG_ALERT, "required argument -f not present" );
exit( EX_TEMPFAIL );
}
if ( errorsfrom == NULL ) {
syslog( LOG_ALERT, "required argument -m not present" );
exit( EX_TEMPFAIL );
}
if ( host == NULL ) {
syslog( LOG_ALERT, "required argument -h not present" );
exit( EX_TEMPFAIL );
}
if ( connect_to_x500() != 0 )
exit( EX_TEMPFAIL );
setuid( geteuid() );
if ( debug ) {
char buf[1024];
int i;
syslog( LOG_ALERT, "running as %d", geteuid() );
strcpy( buf, argv[0] );
for ( i = 1; i < argc; i++ ) {
strcat( buf, " " );
strcat( buf, argv[i] );
}
syslog( LOG_ALERT, "args: (%s)", buf );
}
tolist = NULL;
numto = 0;
add_to( &tolist, &numto, sendmailargs );
nargs = numto;
ngroups = numerr = 0;
togroups = NULL;
errlist = NULL;
for ( i = optind; i < argc; i++ ) {
char *s;
int type;
for ( j = 0; argv[i][j] != '\0'; j++ ) {
if ( argv[i][j] == '.' || argv[i][j] == '_' )
argv[i][j] = ' ';
}
type = USER;
if ( (s = strrchr( argv[i], '-' )) != NULL ) {
s++;
if ((strcasecmp(s, ERROR) == 0) ||
(strcasecmp(s, ERRORS) == 0)) {
type = GROUP_ERRORS;
*(--s) = '\0';
} else if ((strcasecmp(s, REQUEST) == 0) ||
(strcasecmp(s, REQUESTS) == 0)) {
type = GROUP_REQUEST;
*(--s) = '\0';
} else if ( strcasecmp( s, MEMBERS ) == 0 ) {
type = GROUP_MEMBERS;
*(--s) = '\0';
} else if ((strcasecmp(s, OWNER) == 0) ||
(strcasecmp(s, OWNERS) == 0)) {
type = GROUP_OWNER;
*(--s) = '\0';
}
}
do_address( argv[i], &tolist, &numto, &togroups, &ngroups,
&errlist, &numerr, type );
}
/*
* If we have both errors and successful deliveries to make or if
* if there are any groups to deliver to, we basically need to read
* the message twice. So, we have to put it in a tmp file.
*/
if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
int fd;
char buf[BUFSIZ];
umask( 077 );
if ( (fp = tmpfile()) == NULL ) {
syslog( LOG_ALERT, "could not open tmp file" );
unbind_and_exit( EX_TEMPFAIL );
}
/* copy the message to a temp file */
while ( fgets( buf, sizeof(buf), stdin ) != NULL ) {
if ( fputs( buf, fp ) == EOF ) {
syslog( LOG_ALERT, "error writing tmpfile" );
unbind_and_exit( EX_TEMPFAIL );
}
}
if ( dup2( fileno( fp ), 0 ) == -1 ) {
syslog( LOG_ALERT, "could not dup2 tmpfile" );
unbind_and_exit( EX_TEMPFAIL );
}
fclose( fp );
}
/* deal with errors */
if ( numerr > 0 ) {
if ( debug ) {
syslog( LOG_ALERT, "sending errors" );
}
(void) rewind( stdin );
send_errors( errlist, numerr );
}
(void) ldap_unbind( ld );
/* send to groups with errorsTo */
if ( ngroups > 0 ) {
if ( debug ) {
syslog( LOG_ALERT, "sending to groups with errorsto" );
}
(void) rewind( stdin );
send_group( togroups, ngroups );
}
/* send to expanded aliases and groups w/o errorsTo */
if ( numto > nargs ) {
if ( debug ) {
syslog( LOG_ALERT, "sending to aliases and groups" );
}
(void) rewind( stdin );
send_message( tolist );
}
return( EX_OK );
}
connect_to_x500()
{
if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
syslog( LOG_ALERT, "ldap_open failed" );
return( -1 );
}
ld->ld_sizelimit = MAIL500_MAXAMBIGUOUS;
ld->ld_deref = LDAP_DEREF_ALWAYS;
if ( ldap_simple_bind_s( ld, MAIL500_BINDDN, NULL ) != LDAP_SUCCESS ) {
syslog( LOG_ALERT, "ldap_simple_bind_s failed" );
return( -1 );
}
return( 0 );
}
static
mailcmp( a, b )
char *a;
char *b;
{
int i;
for ( i = 0; a[i] != '\0'; i++ ) {
if ( a[i] != b[i] ) {
switch ( a[i] ) {
case ' ':
case '.':
case '_':
if ( b[i] == ' ' || b[i] == '.' || b[i] == '_' )
break;
return( 1 );
default:
return( 1 );
}
}
}
return( 0 );
}
static
do_address( name, to, nto, togroups, ngroups, err, nerr, type )
char *name;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
int type;
{
int rc, b, f, match;
LDAPMessage *e, *res;
struct timeval timeout;
char *dn;
char filter[1024];
char realfilter[1024];
char **mail, **onvacation = NULL, **uid = NULL;
/*
* Look up the name in X.500, add the appropriate addresses found
* to the to list, or to the err list in case of error. Groups are
* handled by the do_group routine, individuals are handled here.
* When looking up name, we follow the bases hierarchy, looking
* in base[0] first, then base[1], etc. For each base, there is
* a set of search filters to try, in order. If something goes
* wrong here trying to contact X.500, we exit with EX_TEMPFAIL.
* If the b_rdnpref flag is set, then we give preference to entries
* that matched name because it's their rdn, otherwise not.
*/
timeout.tv_sec = MAIL500_TIMEOUT;
timeout.tv_usec = 0;
for ( b = 0, match = 0; !match && base[b].b_dn != NULL; b++ ) {
if ( ! (base[b].b_search & type) ) {
continue;
}
for ( f = 0; base[b].b_filter[f] != NULL; f++ ) {
char *format, *p, *s, *d;
char *argv[3];
int argc;
for ( argc = 0; argc < 3; argc++ ) {
argv[argc] = NULL;
}
format = strdup( base[b].b_filter[f] );
for ( argc = 0, p = format; *p; p++ ) {
if ( *p == '%' ) {
switch ( *++p ) {
case 's': /* %s is the name */
argv[argc] = name;
break;
case 'h': /* %h is the host */
*p = 's';
argv[argc] = host;
break;
default:
syslog( LOG_ALERT,
"unknown format %c", *p );
break;
}
argc++;
}
}
/* three names ought to do... */
sprintf( filter, format, argv[0], argv[1], argv[2] );
free( format );
for ( s = filter, d = realfilter; *s; s++, d++ ) {
if ( *s == '*' ) {
*d++ = '\\';
}
*d = *s;
}
*d = '\0';
res = NULL;
rc = ldap_search_st( ld, base[b].b_dn,
LDAP_SCOPE_SUBTREE, realfilter, attrs, 0, &timeout,
&res );
/* some other trouble - try again later */
if ( rc != LDAP_SUCCESS &&
rc != LDAP_SIZELIMIT_EXCEEDED ) {
syslog( LOG_ALERT, "return 0x%x from X.500",
rc );
unbind_and_exit( EX_TEMPFAIL );
}
if ( (match = ldap_count_entries( ld, res )) != 0 )
break;
ldap_msgfree( res );
}
if ( match )
break;
}
/* trouble - try again later */
if ( match == -1 ) {
syslog( LOG_ALERT, "error parsing result from X.500" );
unbind_and_exit( EX_TEMPFAIL );
}
/* no matches - bounce with user unknown */
if ( match == 0 ) {
if ( type == USER ) {
add_error( err, nerr, E_USERUNKNOWN, name, NULLMSG );
} else {
add_error( err, nerr, E_GROUPUNKNOWN, name, NULLMSG );
}
return;
}
/* more than one match - bounce with ambiguous user? */
if ( match > 1 ) {
LDAPMessage *next, *tmpres = NULL;
char *dn;
char **xdn;
/* not giving rdn preference - bounce with ambiguous user */
if ( base[b].b_rdnpref == 0 ) {
add_error( err, nerr, E_AMBIGUOUS, name, res );
return;
}
/*
* giving rdn preference - see if any entries were matched
* because of their rdn. If so, collect them to deal with
* later (== 1 we deliver, > 1 we bounce).
*/
for ( e = ldap_first_entry( ld, res ); e != NULL; e = next ) {
next = ldap_next_entry( ld, e );
dn = ldap_get_dn( ld, e );
xdn = ldap_explode_dn( dn, 1 );
/* XXX bad, but how else can we do it? XXX */
if ( strcasecmp( xdn[0], name ) == 0 ) {
ldap_delete_result_entry( &res, e );
ldap_add_result_entry( &tmpres, e );
}
ldap_value_free( xdn );
free( dn );
}
/* nothing matched by rdn - go ahead and bounce */
if ( tmpres == NULL ) {
add_error( err, nerr, E_AMBIGUOUS, name, res );
return;
/* more than one matched by rdn - bounce with rdn matches */
} else if ( (match = ldap_count_entries( ld, tmpres )) > 1 ) {
add_error( err, nerr, E_AMBIGUOUS, name, tmpres );
return;
/* trouble... */
} else if ( match < 0 ) {
syslog( LOG_ALERT, "error parsing result from X.500" );
unbind_and_exit( EX_TEMPFAIL );
}
/* otherwise one matched by rdn - send to it */
ldap_msgfree( res );
res = tmpres;
}
/*
* if we get this far, it means that we found a single match for
* name. for a user, we deliver to the mail attribute or bounce
* with address and phone if no mail attr. for a group, we
* deliver to all members or bounce to rfc822ErrorsTo if no members.
*/
/* trouble */
if ( (e = ldap_first_entry( ld, res )) == NULL ) {
syslog( LOG_ALERT, "error parsing entry from X.500" );
unbind_and_exit( EX_TEMPFAIL );
}
dn = ldap_get_dn( ld, e );
if ( type == GROUP_ERRORS ) {
/* sent to group-errors - resend to [rfc822]ErrorsTo attr */
do_group_errors( e, dn, to, nto, err, nerr );
} else if ( type == GROUP_REQUEST ) {
/* sent to group-request - resend to [rfc822]RequestsTo attr */
do_group_request( e, dn, to, nto, err, nerr );
} else if ( type == GROUP_MEMBERS ) {
/* sent to group-members - expand */
do_group_members( e, dn, to, nto, togroups, ngroups, err,
nerr );
} else if ( type == GROUP_OWNER ) {
/* sent to group-owner - resend to owner attr */
do_group_owner( e, dn, to, nto, err, nerr );
} else if ( isgroup( e ) ) {
/*
* sent to group - resend from [rfc822]ErrorsTo if it's there,
* otherwise, expand the group
*/
do_group( e, dn, to, nto, togroups, ngroups, err, nerr );
ldap_msgfree( res );
} else {
/*
* sent to user - mail attribute => add it to the to list,
* otherwise bounce
*/
if ( (mail = ldap_get_values( ld, e, "mail" )) != NULL ) {
char buf[1024];
char *h;
int i, j;
/* try to detect simple mail loops */
sprintf( buf, "%s@%s", name, host );
for ( i = 0; mail[i] != NULL; i++ ) {
/*
* address is the same as the one we're
* sending to - mail loop. syslog the
* problem, bounce a message back to the
* sender (who else?), and delete the bogus
* addr from the list.
*/
if ( (h = strchr( mail[i], '@' )) != NULL ) {
h++;
if ( strcasecmp( h, host ) == 0 ) {
syslog( LOG_ALERT,
"potential loop detected (%s)",
mail[i] );
}
}
if ( mailcmp( buf, mail[i] ) == 0 ) {
syslog( LOG_ALERT,
"loop detected (%s)", mail[i] );
/* remove the bogus address */
for ( j = i; mail[j] != NULL; j++ ) {
mail[j] = mail[j+1];
}
}
}
if ( mail[0] != NULL ) {
add_to( to, nto, mail );
} else {
add_error( err, nerr, E_NOEMAIL, name, res );
}
ldap_value_free( mail );
} else {
add_error( err, nerr, E_NOEMAIL, name, res );
}
/*
* If the user is on vacation, send a copy of the mail to
* the vacation server. The address is constructed from
* the vacationhost (set in a command line argument) and
* the uid (XXX this should be more general XXX).
*/
if ( vacationhost != NULL && (onvacation = ldap_get_values( ld,
e, "onVacation" )) != NULL && strcasecmp( onvacation[0],
"TRUE" ) == 0 ) {
char buf[1024];
char *vaddr[2];
if ( (uid = ldap_get_values( ld, e, "uid" )) != NULL ) {
sprintf( buf, "%s@%s", uid[0], vacationhost );
vaddr[0] = buf;
vaddr[1] = NULL;
add_to( to, nto, vaddr );
} else {
syslog( LOG_ALERT,
"user without a uid on vacation (%s)",
name );
}
}
}
if ( onvacation != NULL ) {
ldap_value_free( onvacation );
}
if ( uid != NULL ) {
ldap_value_free( uid );
}
free( dn );
return;
}
static
do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
{
int i;
char **moderator;
/*
* If this group has an rfc822ErrorsTo attribute, we need to
* arrange for errors involving this group to go there, not
* to the sender. Since sendmail only has the concept of a
* single sender, we arrange for errors to go to groupname-errors,
* which we then handle specially when (if) it comes back to us
* by expanding to all the rfc822ErrorsTo addresses. If it has no
* rfc822ErrorsTo attribute, we call do_group_members() to expand
* the group.
*/
if ( group_loop( dn ) ) {
return( -1 );
}
/*
* check for moderated groups - if the group has a moderator
* attribute, we check to see if the from address is one of
* the moderator values. if so, continue on. if not, arrange
* to send the mail to the moderator(s). need to do this before
* we change the from below.
*/
if ( (moderator = ldap_get_values( ld, e, "moderator" )) != NULL ) {
/* check if it came from any of the group's moderators */
for ( i = 0; moderator[i] != NULL; i++ ) {
if ( strcasecmp( moderator[i], mailfrom ) == 0 )
break;
}
/* not from the moderator? */
if ( moderator[i] == NULL ) {
add_to( to, nto, moderator );
ldap_value_free( moderator );
return( 0 );
}
/* else from the moderator - fall through and deliver it */
}
if ( has_attributes( e, "rfc822ErrorsTo", "errorsTo" ) ) {
add_group( dn, togroups, ngroups );
return( 0 );
}
do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr );
return( 0 );
}
/* ARGSUSED */
static
do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
{
int i, rc, anymembers;
char *ndn;
char **mail, **member, **joinable, **suppress;
char filter[1024];
LDAPMessage *ee, *res;
struct timeval timeout;
/*
* if all has gone according to plan, we've already arranged for
* errors to go to the [rfc822]ErrorsTo attributes (if they exist),
* so all we have to do here is arrange to send to the
* rfc822Mailbox attribute, the member attribute, and anyone who
* has joined the group by setting memberOfGroup equal to the
* group dn.
*/
/* add members in the group itself - mail attribute */
anymembers = 0;
if ( (mail = ldap_get_values( ld, e, "mail" )) != NULL ) {
anymembers = 1;
add_to( to, nto, mail );
ldap_value_free( mail );
}
/* add members in the group itself - member attribute */
if ( (member = ldap_get_values( ld, e, "member" )) != NULL ) {
suppress = ldap_get_values( ld, e, "suppressNoEmailError" );
anymembers = 1;
for ( i = 0; member[i] != NULL; i++ ) {
if ( strcasecmp( dn, member[i] ) == 0 ) {
syslog( LOG_ALERT, "group (%s) contains itself",
dn );
continue;
}
add_member( dn, member[i], to, nto, togroups,
ngroups, err, nerr, suppress );
}
if ( suppress ) {
ldap_value_free( suppress );
}
ldap_value_free( member );
}
/* add members who have joined by setting memberOfGroup */
if ( (joinable = ldap_get_values( ld, e, "joinable" )) != NULL ) {
if ( strcasecmp( joinable[0], "FALSE" ) == 0 ) {
if ( ! anymembers ) {
add_error( err, nerr, E_NOMEMBERS, dn,
NULLMSG );
}
ldap_value_free( joinable );
return;
}
ldap_value_free( joinable );
sprintf( filter, "(memberOfGroup=%s)", dn );
timeout.tv_sec = MAIL500_TIMEOUT;
timeout.tv_usec = 0;
/* for each subtree to look in... */
ld->ld_sizelimit = MAIL500_MAXGROUPMEMBERS;
for ( i = 0; base[i].b_dn != NULL; i++ ) {
/* find entries that have joined this group... */
rc = ldap_search_st( ld, base[i].b_dn,
LDAP_SCOPE_SUBTREE, filter, attrs, 0, &timeout,
&res );
if ( rc == LDAP_SIZELIMIT_EXCEEDED ||
rc == LDAP_TIMELIMIT_EXCEEDED ) {
syslog( LOG_ALERT,
"group search limit exceeded %d", rc );
unbind_and_exit( EX_TEMPFAIL );
}
if ( rc != LDAP_SUCCESS ) {
syslog( LOG_ALERT, "group search return 0x%x",
rc );
unbind_and_exit( EX_TEMPFAIL );
}
/* for each entry that has joined... */
for ( ee = ldap_first_entry( ld, res ); ee != NULL;
ee = ldap_next_entry( ld, ee ) ) {
anymembers = 1;
if ( isgroup( ee ) ) {
ndn = ldap_get_dn( ld, ee );
if ( do_group( e, ndn, to, nto,
togroups, ngroups, err, nerr )
== -1 ) {
syslog( LOG_ALERT,
"group loop (%s) (%s)",
dn, ndn );
}
free( ndn );
continue;
}
/* add them to the to list */
if ( (mail = ldap_get_values( ld, ee, "mail" ))
!= NULL ) {
add_to( to, nto, mail );
ldap_value_free( mail );
/* else generate a bounce */
} else {
ndn = ldap_get_dn( ld, ee );
add_error( err, nerr,
E_JOINMEMBERNOEMAIL, ndn, NULLMSG );
free( ndn );
}
}
ldap_msgfree( res );
}
ld->ld_sizelimit = MAIL500_MAXAMBIGUOUS;
}
if ( ! anymembers ) {
add_error( err, nerr, E_NOMEMBERS, dn, NULLMSG );
}
return;
}
add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr, suppress )
char *gdn;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
char **suppress;
{
char *ndn;
char **mail;
int i, rc;
LDAPMessage *res, *e;
struct timeval timeout;
timeout.tv_sec = MAIL500_TIMEOUT;
timeout.tv_usec = 0;
if ( (rc = ldap_search_st( ld, dn, LDAP_SCOPE_BASE, "(objectclass=*)",
attrs, 0, &timeout, &res )) != LDAP_SUCCESS ) {
if ( rc == LDAP_NO_SUCH_OBJECT ) {
add_error( err, nerr, E_BADMEMBER, dn, NULLMSG );
return;
} else {
syslog( LOG_ALERT, "member search return 0x%x", rc );
unbind_and_exit( EX_TEMPFAIL );
}
}
if ( (e = ldap_first_entry( ld, res )) == NULL ) {
syslog( LOG_ALERT, "member search error parsing entry" );
unbind_and_exit( EX_TEMPFAIL );
}
ndn = ldap_get_dn( ld, e );
/* allow groups within groups */
if ( isgroup( e ) ) {
if ( do_group( e, ndn, to, nto, togroups, ngroups, err, nerr )
== -1 ) {
syslog( LOG_ALERT, "group loop (%s) (%s)", gdn, ndn );
}
free( ndn );
return;
}
/* send to the member's mail attribute */
if ( (mail = ldap_get_values( ld, e, "mail" )) != NULL ) {
add_to( to, nto, mail );
ldap_value_free( mail );
/* else generate a bounce */
} else {
if ( suppress == NULL || strcasecmp( suppress[0], "FALSE" )
== 0 ) {
add_error( err, nerr, E_MEMBERNOEMAIL, ndn, NULLMSG );
}
}
free( ndn );
return;
}
do_group_request( e, dn, to, nto, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Error **err;
int *nerr;
{
char **requeststo;
if ( (requeststo = get_attributes_mail_dn( e, "rfc822RequestsTo",
"requestsTo" )) != NULL ) {
add_to( to, nto, requeststo );
ldap_value_free( requeststo );
} else {
add_error( err, nerr, E_NOREQUEST, dn, NULLMSG );
}
return;
}
do_group_errors( e, dn, to, nto, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Error **err;
int *nerr;
{
char **errorsto;
if ( (errorsto = get_attributes_mail_dn( e, "rfc822ErrorsTo",
"errorsTo" )) != NULL ) {
add_to( to, nto, errorsto );
ldap_value_free( errorsto );
} else {
add_error( err, nerr, E_NOERRORS, dn, NULLMSG );
}
return;
}
do_group_owner( e, dn, to, nto, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Error **err;
int *nerr;
{
char **owner;
if ( (owner = get_attributes_mail_dn( e, "", "owner" )) != NULL ) {
add_to( to, nto, owner );
ldap_value_free( owner );
} else {
add_error( err, nerr, E_NOOWNER, dn, NULLMSG );
}
return;
}
static
send_message( to )
char **to;
{
int pid;
#ifndef USE_WAITPID
WAITSTATUSTYPE status;
#endif
if ( debug ) {
char buf[1024];
int i;
strcpy( buf, to[0] );
for ( i = 1; to[i] != NULL; i++ ) {
strcat( buf, " " );
strcat( buf, to[i] );
}
syslog( LOG_ALERT, "send_message execing sendmail: (%s)", buf );
}
/* parent */
if ( pid = fork() ) {
#ifdef USE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
wait4( pid, &status, WAIT_FLAGS, 0 );
#endif
/* child */
} else {
/* to includes sendmailargs */
execv( MAIL500_SENDMAIL, to );
syslog( LOG_ALERT, "execv failed" );
exit( EX_TEMPFAIL );
}
}
static
send_group( group, ngroup )
Group *group;
int ngroup;
{
int i, pid;
char **argv;
int argc;
char *iargv[7];
#ifndef USE_WAITPID
WAITSTATUSTYPE status;
#endif
for ( i = 0; i < ngroup; i++ ) {
(void) rewind( stdin );
iargv[0] = MAIL500_SENDMAIL;
iargv[1] = "-f";
iargv[2] = group[i].g_errorsto;
iargv[3] = "-oMrX.500";
iargv[4] = "-odi";
iargv[5] = "-oi";
iargv[6] = NULL;
argv = NULL;
argc = 0;
add_to( &argv, &argc, iargv );
add_to( &argv, &argc, group[i].g_members );
if ( debug ) {
char buf[1024];
int i;
strcpy( buf, argv[0] );
for ( i = 1; i < argc; i++ ) {
strcat( buf, " " );
strcat( buf, argv[i] );
}
syslog( LOG_ALERT, "execing sendmail: (%s)", buf );
}
/* parent */
if ( pid = fork() ) {
#ifdef USE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
wait4( pid, &status, WAIT_FLAGS, 0 );
#endif
/* child */
} else {
execv( MAIL500_SENDMAIL, argv );
syslog( LOG_ALERT, "execv failed" );
exit( EX_TEMPFAIL );
}
}
return;
}
static
send_errors( err, nerr )
Error *err;
int nerr;
{
int pid, i, namelen;
FILE *fp;
int fd[2];
char *argv[8];
char buf[1024];
#ifndef USE_WAITPID
WAITSTATUSTYPE status;
#endif
argv[0] = MAIL500_SENDMAIL;
argv[1] = "-oMrX.500";
argv[2] = "-odi";
argv[3] = "-oi";
argv[4] = "-f";
argv[5] = errorsfrom;
argv[6] = mailfrom;
argv[7] = NULL;
if ( debug ) {
int i;
strcpy( buf, argv[0] );
for ( i = 1; argv[i] != NULL; i++ ) {
strcat( buf, " " );
strcat( buf, argv[i] );
}
syslog( LOG_ALERT, "execing sendmail: (%s)", buf );
}
if ( pipe( fd ) == -1 ) {
syslog( LOG_ALERT, "cannot create pipe" );
exit( EX_TEMPFAIL );
}
if ( pid = fork() ) {
if ( (fp = fdopen( fd[1], "w" )) == NULL ) {
syslog( LOG_ALERT, "cannot fdopen pipe" );
exit( EX_TEMPFAIL );
}
fprintf( fp, "To: %s\n", mailfrom );
fprintf( fp, "From: %s\n", errorsfrom );
fprintf( fp, "Subject: undeliverable mail\n" );
fprintf( fp, "\n" );
fprintf( fp, "The following errors occurred when trying to deliver the attached mail:\n" );
for ( i = 0; i < nerr; i++ ) {
namelen = strlen( err[i].e_addr );
fprintf( fp, "\n" );
switch ( err[i].e_code ) {
case E_USERUNKNOWN:
fprintf( fp, "%s: User unknown\n", err[i].e_addr );
break;
case E_GROUPUNKNOWN:
fprintf( fp, "%s: Group unknown\n", err[i].e_addr );
break;
case E_BADMEMBER:
fprintf( fp, "%s: Group member does not exist\n",
err[i].e_addr );
fprintf( fp, "This could be because the distinguished name of the person has changed\n" );
fprintf( fp, "If this is the case, the problem can be solved by removing and\n" );
fprintf( fp, "then re-adding the person to the group.\n" );
break;
case E_NOREQUEST:
fprintf( fp, "%s: Group exists but has no request address\n",
err[i].e_addr );
break;
case E_NOERRORS:
fprintf( fp, "%s: Group exists but has no errors-to address\n",
err[i].e_addr );
break;
case E_NOOWNER:
fprintf( fp, "%s: Group exists but has no owner\n",
err[i].e_addr );
break;
case E_AMBIGUOUS:
do_ambiguous( fp, &err[i], namelen );
break;
case E_NOEMAIL:
do_noemail( fp, &err[i], namelen );
break;
case E_MEMBERNOEMAIL:
fprintf( fp, "%s: Group member exists but does not have an email address\n",
err[i].e_addr );
break;
case E_JOINMEMBERNOEMAIL:
fprintf( fp, "%s: User has joined group but does not have an email address\n",
err[i].e_addr );
break;
case E_LOOP:
fprintf( fp, "%s: User has created a mail loop by adding address %s to their X.500 entry\n",
err[i].e_addr, err[i].e_loop );
break;
case E_NOMEMBERS:
fprintf( fp, "%s: Group has no members\n",
err[i].e_addr );
break;
default:
syslog( LOG_ALERT, "unknown error %d", err[i].e_code );
unbind_and_exit( EX_TEMPFAIL );
break;
}
}
fprintf( fp, "\n------- The original message sent:\n\n" );
while ( fgets( buf, sizeof(buf), stdin ) != NULL ) {
fputs( buf, fp );
}
fclose( fp );
#ifdef USE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
wait4( pid, &status, WAIT_FLAGS, 0 );
#endif
} else {
dup2( fd[0], 0 );
execv( MAIL500_SENDMAIL, argv );
syslog( LOG_ALERT, "execv failed" );
exit( EX_TEMPFAIL );
}
return;
}
static
do_noemail( fp, err, namelen )
FILE *fp;
Error *err;
int namelen;
{
int i, last;
char *dn, *rdn;
char **ufn, **vals;
fprintf(fp, "%s: User has no email address registered.\n",
err->e_addr );
fprintf( fp, "%*s Name, title, postal address and phone for '%s':\n\n",
namelen, " ", err->e_addr );
/* name */
dn = ldap_get_dn( ld, err->e_msg );
ufn = ldap_explode_dn( dn, 1 );
rdn = strdup( ufn[0] );
if ( strcasecmp( rdn, err->e_addr ) == 0 ) {
if ( (vals = ldap_get_values( ld, err->e_msg, "cn" ))
!= NULL ) {
for ( i = 0; vals[i]; i++ ) {
last = strlen( vals[i] ) - 1;
if ( isdigit( vals[i][last] ) ) {
rdn = strdup( vals[i] );
break;
}
}
ldap_value_free( vals );
}
}
fprintf( fp, "%*s %s\n", namelen, " ", rdn );
free( dn );
free( rdn );
ldap_value_free( ufn );
/* titles or descriptions */
if ( (vals = ldap_get_values( ld, err->e_msg, "title" )) == NULL &&
(vals = ldap_get_values( ld, err->e_msg, "description" ))
== NULL ) {
fprintf( fp, "%*s No title or description registered\n",
namelen, " " );
} else {
for ( i = 0; vals[i] != NULL; i++ ) {
fprintf( fp, "%*s %s\n", namelen, " ", vals[i] );
}
ldap_value_free( vals );
}
/* postal address */
if ( (vals = ldap_get_values( ld, err->e_msg, "postalAddress" ))
== NULL ) {
fprintf( fp, "%*s No postal address registered\n", namelen,
" " );
} else {
fprintf( fp, "%*s ", namelen, " " );
for ( i = 0; vals[0][i] != '\0'; i++ ) {
if ( vals[0][i] == '$' ) {
fprintf( fp, "\n%*s ", namelen, " " );
while ( isspace( vals[0][i+1] ) )
i++;
} else {
fprintf( fp, "%c", vals[0][i] );
}
}
fprintf( fp, "\n" );
ldap_value_free( vals );
}
/* telephone number */
if ( (vals = ldap_get_values( ld, err->e_msg, "telephoneNumber" ))
== NULL ) {
fprintf( fp, "%*s No phone number registered\n", namelen,
" " );
} else {
for ( i = 0; vals[i] != NULL; i++ ) {
fprintf( fp, "%*s %s\n", namelen, " ", vals[i] );
}
ldap_value_free( vals );
}
}
/* ARGSUSED */
static
do_ambiguous( fp, err, namelen )
FILE *fp;
Error *err;
int namelen;
{
int i, last;
char *dn, *rdn;
char **ufn, **vals;
LDAPMessage *e;
i = ldap_result2error( ld, err->e_msg, 0 );
fprintf( fp, "%s: Ambiguous user. %s%d matches found:\n\n",
err->e_addr, i == LDAP_SIZELIMIT_EXCEEDED ? "First " : "",
ldap_count_entries( ld, err->e_msg ) );
for ( e = ldap_first_entry( ld, err->e_msg ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
dn = ldap_get_dn( ld, e );
ufn = ldap_explode_dn( dn, 1 );
rdn = strdup( ufn[0] );
if ( strcasecmp( rdn, err->e_addr ) == 0 ) {
if ( (vals = ldap_get_values( ld, e, "cn" )) != NULL ) {
for ( i = 0; vals[i]; i++ ) {
last = strlen( vals[i] ) - 1;
if ( isdigit( vals[i][last] ) ) {
rdn = strdup( vals[i] );
break;
}
}
ldap_value_free( vals );
}
}
if ( isgroup( e ) ) {
vals = ldap_get_values( ld, e, "description" );
} else {
vals = ldap_get_values( ld, e, "title" );
}
fprintf( fp, " %-20s %s\n", rdn, vals ? vals[0] : "" );
for ( i = 1; vals && vals[i] != NULL; i++ ) {
fprintf( fp, " %s\n", vals[i] );
}
free( dn );
free( rdn );
ldap_value_free( ufn );
if ( vals != NULL )
ldap_value_free( vals );
}
}
static
count_values( list )
char **list;
{
int i;
for ( i = 0; list && list[i] != NULL; i++ )
; /* NULL */
return( i );
}
static
add_to( list, nlist, new )
char ***list;
int *nlist;
char **new;
{
int i, nnew, oldnlist;
nnew = count_values( new );
oldnlist = *nlist;
if ( *list == NULL || *nlist == 0 ) {
*list = (char **) malloc( (nnew + 1) * sizeof(char *) );
*nlist = nnew;
} else {
*list = (char **) realloc( *list, *nlist * sizeof(char *) +
nnew * sizeof(char *) + sizeof(char *) );
*nlist += nnew;
}
for ( i = 0; i < nnew; i++ )
(*list)[i + oldnlist] = strdup( new[i] );
(*list)[*nlist] = NULL;
return;
}
static
isgroup( e )
LDAPMessage *e;
{
int i;
char **oclist;
oclist = ldap_get_values( ld, e, "objectClass" );
for ( i = 0; oclist[i] != NULL; i++ ) {
if ( strcasecmp( oclist[i], "rfc822MailGroup" ) == 0 ) {
ldap_value_free( oclist );
return( 1 );
}
}
ldap_value_free( oclist );
return( 0 );
}
static
add_error( err, nerr, code, addr, msg )
Error **err;
int *nerr;
int code;
char *addr;
LDAPMessage *msg;
{
if ( *nerr == 0 ) {
*err = (Error *) malloc( sizeof(Error) );
} else {
*err = (Error *) realloc( *err, (*nerr + 1) * sizeof(Error) );
}
(*err)[*nerr].e_code = code;
(*err)[*nerr].e_addr = strdup( addr );
(*err)[*nerr].e_msg = msg;
(*nerr)++;
return;
}
static
add_group( dn, list, nlist )
char *dn;
Group **list;
int *nlist;
{
int i, namelen;
char **ufn;
for ( i = 0; i < *nlist; i++ ) {
if ( strcmp( dn, (*list)[i].g_dn ) == 0 ) {
syslog( LOG_ALERT, "group loop 2 detected (%s)", dn );
return;
}
}
ufn = ldap_explode_dn( dn, 1 );
namelen = strlen( ufn[0] );
if ( *nlist == 0 ) {
*list = (Group *) malloc( sizeof(Group) );
} else {
*list = (Group *) realloc( *list, (*nlist + 1) *
sizeof(Group) );
}
/* send errors to groupname-errors@host */
(*list)[*nlist].g_errorsto = (char *) malloc( namelen + sizeof(ERRORS)
+ hostlen + 2 );
sprintf( (*list)[*nlist].g_errorsto, "%s-%s@%s", ufn[0], ERRORS, host );
(void) canonical( (*list)[*nlist].g_errorsto );
/* send to groupname-members@host - make it a list for send_group */
(*list)[*nlist].g_members = (char **) malloc( 2 * sizeof(char *) );
(*list)[*nlist].g_members[0] = (char *) malloc( namelen +
sizeof(MEMBERS) + hostlen + 2 );
sprintf( (*list)[*nlist].g_members[0], "%s-%s@%s", ufn[0], MEMBERS,
host );
(void) canonical( (*list)[*nlist].g_members[0] );
(*list)[*nlist].g_members[1] = NULL;
/* save the group's dn so we can check for loops above */
(*list)[*nlist].g_dn = strdup( dn );
(*nlist)++;
ldap_value_free( ufn );
return;
}
static
unbind_and_exit( rc )
int rc;
{
int i;
if ( (i = ldap_unbind( ld )) != LDAP_SUCCESS )
syslog( LOG_ALERT, "ldap_unbind failed %d\n", i );
exit( rc );
}
static char *
canonical( s )
char *s;
{
char *saves = s;
for ( ; *s != '\0'; s++ ) {
if ( *s == ' ' )
*s = '.';
}
return( saves );
}
static
group_loop( dn )
char *dn;
{
int i;
static char **groups;
static int ngroups;
for ( i = 0; i < ngroups; i++ ) {
if ( strcmp( dn, groups[i] ) == 0 )
return( 1 );
}
if ( ngroups == 0 )
groups = (char **) malloc( sizeof(char *) );
else
groups = (char **) realloc( groups,
(ngroups + 1) * sizeof(char *) );
groups[ngroups++] = strdup( dn );
return( 0 );
}
static
has_attributes( e, attr1, attr2 )
LDAPMessage *e;
char *attr1;
char *attr2;
{
char **attr;
if ( (attr = ldap_get_values( ld, e, attr1 )) != NULL ) {
ldap_value_free( attr );
return( 1 );
}
if ( (attr = ldap_get_values( ld, e, attr2 )) != NULL ) {
ldap_value_free( attr );
return( 1 );
}
return( 0 );
}
static char **
get_attributes_mail_dn( e, attr1, attr2 )
LDAPMessage *e;
char *attr1;
char *attr2; /* this one is dn-valued */
{
LDAPMessage *ee, *res;
char **vals, **dnlist, **mail, **grname, **graddr;
char *dn;
int nto = 0, i, rc;
struct timeval timeout;
dn = ldap_get_dn( ld, e );
vals = ldap_get_values( ld, e, attr1 );
for ( nto = 0; vals != NULL && vals[nto] != NULL; nto++ )
; /* NULL */
if ( (dnlist = ldap_get_values( ld, e, attr2 )) != NULL ) {
timeout.tv_sec = MAIL500_TIMEOUT;
timeout.tv_usec = 0;
for ( i = 0; dnlist[i] != NULL; i++ ) {
if ( (rc = ldap_search_st( ld, dnlist[i],
LDAP_SCOPE_BASE, "(objectclass=*)", attrs, 0,
&timeout, &res )) != LDAP_SUCCESS ) {
if ( rc != LDAP_NO_SUCH_OBJECT ) {
unbind_and_exit( EX_TEMPFAIL );
}
syslog( LOG_ALERT, "bad (%s) dn (%s)", attr2,
dnlist[i] );
continue;
}
if ( (ee = ldap_first_entry( ld, res )) == NULL ) {
syslog( LOG_ALERT, "error parsing x500 entry" );
continue;
}
if ( isgroup(ee) ) {
char *graddr[2];
grname = ldap_explode_dn( dnlist[i], 1 );
/* groupname + host + @ + null */
graddr[0] = (char *) malloc( strlen( grname[0] )
+ strlen( host ) + 2 );
graddr[1] = NULL;
sprintf( graddr[0], "%s@%s", grname[0], host);
(void) canonical( graddr[0] );
add_to( &vals, &nto, graddr );
free( graddr[0] );
ldap_value_free( grname );
} else if ( (mail = ldap_get_values( ld, ee, "mail" ))
!= NULL ) {
add_to( &vals, &nto, mail );
ldap_value_free( mail );
}
ldap_msgfree( res );
}
}
return( vals );
}
# Mostly rfc1123 compliant sendmail.cf
#
# Mail sendmail-admins-request@itd.umich.edu to join
# sendmail-admins@itd.umich.edu. sendmail-admins carries information
# regarding this sendmail.cf, including announcements of changes
# and discussions of interest to admins.
#
DWtotalrecall
Dw$W.rs.itd.umich.edu
DBcunyvm.cuny.edu
DUdestroyer.rs.itd.umich.edu
DV2.2
De$j sendmail ($v/$V) ready at $b
Dj$w
DlFrom $g $d
Dnmailer-daemon
Do.:%@!^=/[]
Dq$?x\"$x\" <$g>$|$g$.
OA/etc/aliases
OQ/var/spool/mqueue
OH/usr/lib/sendmail.hf
OS/usr/lib/sendmail.st
OP
OD
OX10
Ox5
Ou1
Og1
Odb
OF0600
OL9
Oo
Or15m
Os
OT3d
H?P?Return-Path: <$g>
HReceived: $?sfrom $s $.by $j ($v/$V)
$?rwith $r $.id $i; $b
H?D?Resent-Date: $a
H?F?Resent-From: $q
H?M?Resent-Message-Id: <$t.$i@$j>
H?M?Message-Id: <$t.$i@$j>
H?D?Date: $a
H?x?Full-Name: $x
H?F?From: $q
Troot uucp daemon
Pspecial-delivery=100
Pfirst-class=0
Pjunk=-100
# Organization:
#
# ruleset 3 and friends
# focus addresses, don't screw with them
# ruleset 0 and friends
# beat the hell out of addresses, convert them to
# their deliverable form
# mailers and associated rulesets
# * focused addresses are body addresses, and should be
# left as they are
# * unfocused addresses are envelope addresses, and should
# be converted to the mailers format
# ruleset 4
# remove focus on all addresses
# All addresses are passed through this rule. It functions by finding
# the host to delivery to, and marking it with <>
S3
R$*<$+>$* $2 remove comments
R$+:$*; $@ $1:$2; done if list
R$*@$+ $: $>5$1@$2 focus rfc822 addresses
R$+!$+ $: $>6$1!$2 focus uucp
R$*<@$+>$* $: $1<@$[$2$]>$3 canonicalize
R$*<$+>$* $@ $1<$2>$3 done if focused
R$+%$+ $: $1@$2 a%b -> a@b
R$+@$+%$+ $1%$2@$3 a@b%c -> a%b@c
R$+@$+ $: $>3$1@$2 try again...
# Find the "next hop" in normal rfc822 syntax. These rules
# all return upon marking the next hop with <>
S5
R@$+,@$+:$+ $@ <@$1>,@$2:$3 @a,@b:@c -> <@a>,@b:c
R@$+:$+ $@ <@$1>:$2 @a:b -> <@a>:b
R$+@$+ $@ $1<@$2> a@b -> a<@b>
# Focus bang style addresses. Won't change already focused addresses.
# Strips .uucp in bang paths, and converts domain syntax to rfc822 adresses.
S6
R$*<$+>$* $@ $1<$2>$3 already focused
R$+!$+ $: <$1!>$2 a!b -> <a!>b
R<$+.uucp!>$+ <$1!>$2 <a.uucp!>b -> <a!>b
# Find a mailer. This involves finding the "real" host to deliver to,
# by removing our local name, and/or doing a "domain forward"
S0
R$+ $: $>7$1 deliverable format
R$*<$+>$* $: $>11$1<$2>$3 domain forward
R<$+!>$+ $: $>12<$1!>$2 route uucp
R$*<@$+.bitnet>$* $#inet$@$B$:$1<@$2.bitnet>$3
R$*<@umich.edu>$* $#mail500$@umich.edu$:<$1>
R$*<@itd.umich.edu>$* $#mail500$@itd.umich.edu$:<$1>
#R<$+!>$+ $#uux$@$U$:<$1!>$2
R<$+!>$+ $#unet$@$U$:<$1!>$2
R$*<@$+>$* $#inet$@$2$:$1<@$2>$3
R$+ $#local$:$1
# Find the delivery address. Convert to standard-internal form,
# remove local name.
S7
R<$-.$+!>$+ $3<@$1.$2> <a.b!>c -> c<@a.b>
R$*<@$-.uucp>$* $>8$1@$2.uucp$3 *.uucp to !
R$*<$+>$* $: $>9$1<$2>$3 strip local name
# Convert rfc822 syntax to a uucp "bang path". This works well
# on normal a@b address and route-addrs. It will also do something
# to list syntax address, but it's not clear how correct it is.
S8
R@$+,@$+:$+ @$1!$2:$3 @a,@b:c -> @a!b:c
R@$+:$+@$+ $1!$3!$2 @a:b@c -> a!c!b
R@$+:$+!$+ $1!$2!$3 @a:b!c -> a!b!c
R$+@$+ $2!$1 a@b -> b!c
R$+ $: $>3$1 refocus
# Remove local names. You won't see things like a.b!u or u@b.uucp.
# Add new rules here to accept more than just the default locally.
S9
R$*<@$w>$* $>10$1<@>$2 remove local name
R<$W!>$+ $>10<!>$1
R<@umich.edu>$*:$* $>10<@>$1:$2
R$+%$+<@umich.edu> $>10$1%$2<@>
R$+!$+<@umich.edu> $>10$1!$2<@>
# Called only from above. Refocus and loop.
S10
R<@>,$+ $>3$1
R<@>:$+ $>3$1
R$+<@> $>3$1
R<!>$+ $>3$1
R$*<$+>$* $: $>7$1<$2>$3
# Convert domain names to uucp names, and refocus
S11
#R$*<@inquiry.org>$* $: $>8$1@inquiry$2
# Route uucp addresses, if we're not connected to them. We rely on the
# domain-path operator to down case addresses.
S12
R<$+!>$+ $: <${$1$}!>$2 pathalias route
R<$+!$+!>$+ <$1!>$2!$3 <a!b!>c -> <a!>b!c
Muux, P=/usr/bin/uux, F=DFMhu, S=13, R=14,
A=uux - -gC -b -r -a$f $h!rmail ($u)
Munet, P=[IPC], F=mDFMhuX, S=13, R=14, A=IPC $h, E=\r\n
Minet, P=[IPC], F=mDFMuX, S=15, R=15, A=IPC $h, E=\r\n
Mlocal, P=/bin/mail, F=rlsDFMmn, S=16, R=16, A=mail -d $u
Mprog, P=/bin/sh, F=lsDFMe, S=16, R=16, A=sh -c $u
Mmail500, P=/usr/local/etc/mail500, F=DFMSmnXuh,
A=mail500 -f $f -h $h -m $n@$w $u
# UUCP mailers require that the sender be in ! format.
# XXX Do we add our name to other people's paths?
S13
R$*<@$+>$* $: $>8$1@$2$3
#R<$w!>$+ $@ <$W!>$1
R<$+!>$+ $@ <$1!>$2
R$+:$*; $@ $1:$2;
R<> $@
#R$+ $@ <$W!>$1
R$+ $@ <$w!>$1
# Only add our name to local mail. Anything that's focused, leave alone.
S14
R$*<$+>$* $@ $1<$2>$3
R$+:$*; $@ $1:$2;
#R$+ $@ <$W!>$1
R$+ $@ <$w!>$1
# SMTP mailers require that addresses be in rfc822 format. If there's no
# @ in the address, add one.
S15
R<$W!>$+ $1<@$w>
R<$-.$+!>$+ $3<@$1.$2>
R$*<@$+>$* $@ $1<@$2>$3
R<$+!>$+ $@ $1!$2<@$w>
R$+:$*; $@ $1:$2;
R<> $@
R$+ $@ $1<@$w>
# Local and prog mailer
S16
R$+ $@ $1
#
# Called on all outgoing addresses. Used to remove the <> focus
#
S4
R$*<$+>$* $@ $1$2$3 defocus
/*
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/signal.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include <ac/errno.h>
#include <sys/stat.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#include <ldap.h>
#include "ldif.h"
#include "lutil.h"
#include "lutil_ldap.h"
#include "ldap_defaults.h"
static void
usage( const char *s )
{
fprintf( stderr,
"usage: %s [options] DN <attr:value|attr::b64value>\n"
"where:\n"
" DN\tDistinguished Name\n"
" attr\tassertion attribute\n"
" value\tassertion value\n"
" b64value\tbase64 encoding of assertion value\n"
"Common options:\n"
" -d level set LDAP debugging level to `level'\n"
" -D binddn bind DN\n"
" -h host LDAP server\n"
" -H URI LDAP Uniform Resource Indentifier(s)\n"
" -I use SASL Interactive mode\n"
" -k use Kerberos authentication\n"
" -K like -k, but do only step 1 of the Kerberos bind\n"
" -M enable Manage DSA IT control (-MM to make critical)\n"
" -n show what would be done but don't actually compare\n"
" -O props SASL security properties\n"
" -p port port on LDAP server\n"
" -P version procotol version (default: 3)\n"
" -z Quiet mode, don't print anything, use return values\n"
" -Q use SASL Quiet mode\n"
" -R realm SASL realm\n"
" -U authcid SASL authentication identity\n"
" -v run in verbose mode (diagnostics to standard output)\n"
" -w passwd bind passwd (for simple authentication)\n"
" -W prompt for bind passwd\n"
" -x Simple authentication\n"
" -X authzid SASL authorization identity (\"dn:<dn>\" or \"u:<user>\")\n"
" -Y mech SASL mechanism\n"
" -Z Start TLS request (-ZZ to require successful response)\n"
, s );
exit( EXIT_FAILURE );
}
static int docompare LDAP_P((
LDAP *ld,
char *dn,
char *attr,
struct berval *bvalue,
int quiet,
LDAPControl **sctrls,
LDAPControl **cctrls));
static char *prog = NULL;
static char *binddn = NULL;
static struct berval passwd = { 0, NULL };
static char *ldaphost = NULL;
static char *ldapuri = NULL;
static int ldapport = 0;
#ifdef HAVE_CYRUS_SASL
static unsigned sasl_flags = LDAP_SASL_AUTOMATIC;
static char *sasl_realm = NULL;
static char *sasl_authc_id = NULL;
static char *sasl_authz_id = NULL;
static char *sasl_mech = NULL;
static char *sasl_secprops = NULL;
#endif
static int use_tls = 0;
static int verbose, not;
int
main( int argc, char **argv )
{
char *compdn = NULL, *attrs = NULL;
char *sep;
int rc, i, manageDSAit, quiet;
int referrals, debug;
int authmethod, version, want_bindpw;
LDAP *ld = NULL;
struct berval bvalue = { 0, NULL };
debug = verbose = not = referrals =
manageDSAit = want_bindpw = quiet = 0;
version = -1;
authmethod = -1;
prog = lutil_progname( "ldapcompare", argc, argv );
while (( i = getopt( argc, argv,
"Cd:D:h:H:IkKMnO:p:P:qQR:U:vw:WxX:Y:zZ")) != EOF )
{
switch( i ) {
/* Common Options */
case 'C':
referrals++;
break;
case 'd':
debug |= atoi( optarg );
break;
case 'D': /* bind DN */
if( binddn != NULL ) {
fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE;
}
binddn = strdup( optarg );
break;
case 'h': /* ldap host */
if( ldapuri != NULL ) {
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE;
}
if( ldaphost != NULL ) {
fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE;
}
ldaphost = strdup( optarg );
break;
case 'H': /* ldap URI */
if( ldaphost != NULL ) {
fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE;
}
if( ldapport ) {
fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE;
}
if( ldapuri != NULL ) {
fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE;
}
ldapuri = strdup( optarg );
break;
case 'I':
#ifdef HAVE_CYRUS_SASL
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -I incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_flags = LDAP_SASL_INTERACTIVE;
break;
#else
fprintf( stderr, "%s: was not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
case 'k': /* kerberos bind */
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
if( version > LDAP_VERSION2 ) {
fprintf( stderr, "%s: -k incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 ) {
fprintf( stderr, "%s: -k incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_KRBV4;
#else
fprintf( stderr, "%s: not compiled with Kerberos support\n", prog );
return EXIT_FAILURE;
#endif
break;
case 'K': /* kerberos bind, part one only */
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
if( version > LDAP_VERSION2 ) {
fprintf( stderr, "%s: -k incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 ) {
fprintf( stderr, "%s: incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_KRBV41;
#else
fprintf( stderr, "%s: not compiled with Kerberos support\n", prog );
return( EXIT_FAILURE );
#endif
break;
case 'M':
/* enable Manage DSA IT */
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -M incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
manageDSAit++;
version = LDAP_VERSION3;
break;
case 'n': /* print compares, don't actually do them */
++not;
break;
case 'O':
#ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) {
fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -O incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_secprops = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'p':
if( ldapport ) {
fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE;
}
ldapport = atoi( optarg );
break;
case 'P':
switch( atoi(optarg) ) {
case 2:
if( version == LDAP_VERSION3 ) {
fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION2;
break;
case 3:
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION3;
break;
default:
fprintf( stderr, "%s: protocol version should be 2 or 3\n",
prog );
usage( prog );
return( EXIT_FAILURE );
} break;
case 'Q':
#ifdef HAVE_CYRUS_SASL
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Q incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_flags = LDAP_SASL_QUIET;
break;
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
case 'R':
#ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) {
fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -R incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_realm = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'U':
#ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) {
fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -U incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_authc_id = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'v': /* verbose mode */
verbose++;
break;
case 'w': /* password */
passwd.bv_val = strdup( optarg );
{
char* p;
for( p = optarg; *p != '\0'; p++ ) {
*p = '\0';
}
}
passwd.bv_len = strlen( passwd.bv_val );
break;
case 'W':
want_bindpw++;
break;
case 'Y':
#ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) {
fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Y incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible with authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_mech = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'x':
if( authmethod != -1 && authmethod != LDAP_AUTH_SIMPLE ) {
fprintf( stderr, "%s: incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SIMPLE;
break;
case 'X':
#ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) {
fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -X incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: -X incompatible with "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_authz_id = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'z':
quiet++;
break;
case 'Z':
#ifdef HAVE_TLS
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Z incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION3;
use_tls++;
#else
fprintf( stderr, "%s: not compiled with TLS support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
default:
fprintf( stderr, "%s: unrecognized option -%c\n",
prog, optopt );
usage( argv[0] );
}
}
if (version == -1) {
version = LDAP_VERSION3;
}
if (authmethod == -1 && version > LDAP_VERSION2) {
#ifdef HAVE_CYRUS_SASL
authmethod = LDAP_AUTH_SASL;
#else
authmethod = LDAP_AUTH_SIMPLE;
#endif
}
if ( argc - optind != 2 ) {
usage( argv[ 0 ] );
}
compdn = argv[optind++];
attrs = argv[optind++];
/* user passed in only 2 args, the last one better be in
* the form attr:value or attr::b64value
*/
sep = strchr(attrs, ':');
if (!sep) {
usage( argv[ 0 ] );
}
*sep++='\0';
if ( *sep != ':' ) {
bvalue.bv_val = strdup( sep );
bvalue.bv_len = strlen( bvalue.bv_val );
} else {
/* it's base64 encoded. */
bvalue.bv_val = malloc( strlen( &sep[1] ));
bvalue.bv_len = lutil_b64_pton( &sep[1],
bvalue.bv_val, strlen( &sep[1] ));
if (bvalue.bv_len == -1) {
fprintf(stderr, "base64 decode error\n");
exit(-1);
}
}
if ( debug ) {
if( ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug )
!= LBER_OPT_SUCCESS )
{
fprintf( stderr,
"Could not set LBER_OPT_DEBUG_LEVEL %d\n", debug );
}
if( ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug )
!= LDAP_OPT_SUCCESS )
{
fprintf( stderr,
"Could not set LDAP_OPT_DEBUG_LEVEL %d\n", debug );
}
ldif_debug = debug;
}
#ifdef SIGPIPE
(void) SIGNAL( SIGPIPE, SIG_IGN );
#endif
if( ( ldaphost != NULL || ldapport ) && ( ldapuri == NULL ) ) {
if ( verbose ) {
fprintf( stderr, "ldap_init( %s, %d )\n",
ldaphost != NULL ? ldaphost : "<DEFAULT>",
ldapport );
}
ld = ldap_init( ldaphost, ldapport );
if( ld == NULL ) {
perror("ldapcompare: ldap_init");
return EXIT_FAILURE;
}
} else {
if ( verbose ) {
fprintf( stderr, "ldap_initialize( %s )\n",
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
}
rc = ldap_initialize( &ld, ldapuri );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr,
"Could not create LDAP session handle (%d): %s\n",
rc, ldap_err2string(rc) );
return EXIT_FAILURE;
}
}
/* referrals */
if (ldap_set_option( ld, LDAP_OPT_REFERRALS,
referrals ? LDAP_OPT_ON : LDAP_OPT_OFF ) != LDAP_OPT_SUCCESS )
{
fprintf( stderr, "Could not set LDAP_OPT_REFERRALS %s\n",
referrals ? "on" : "off" );
return EXIT_FAILURE;
}
if (version == -1 ) {
version = LDAP_VERSION3;
}
if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version )
!= LDAP_OPT_SUCCESS )
{
fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n",
version );
return EXIT_FAILURE;
}
if ( use_tls && ( ldap_start_tls_s( ld, NULL, NULL ) != LDAP_SUCCESS )) {
ldap_perror( ld, "ldap_start_tls" );
if ( use_tls > 1 ) {
return EXIT_FAILURE;
}
}
if (want_bindpw) {
passwd.bv_val = getpassphrase("Enter LDAP Password: ");
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
}
if ( authmethod == LDAP_AUTH_SASL ) {
#ifdef HAVE_CYRUS_SASL
void *defaults;
if( sasl_secprops != NULL ) {
rc = ldap_set_option( ld, LDAP_OPT_X_SASL_SECPROPS,
(void *) sasl_secprops );
if( rc != LDAP_OPT_SUCCESS ) {
fprintf( stderr,
"Could not set LDAP_OPT_X_SASL_SECPROPS: %s\n",
sasl_secprops );
return EXIT_FAILURE;
}
}
defaults = lutil_sasl_defaults( ld,
sasl_mech,
sasl_realm,
sasl_authc_id,
passwd.bv_val,
sasl_authz_id );
rc = ldap_sasl_interactive_bind_s( ld, binddn,
sasl_mech, NULL, NULL,
sasl_flags, lutil_sasl_interact, defaults );
if( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_sasl_interactive_bind_s" );
return EXIT_FAILURE;
}
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog, argv[0] );
return EXIT_FAILURE;
#endif
} else {
if ( ldap_bind_s( ld, binddn, passwd.bv_val, authmethod )
!= LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
return EXIT_FAILURE;
}
}
if ( manageDSAit ) {
int err;
LDAPControl c;
LDAPControl *ctrls[2];
ctrls[0] = &c;
ctrls[1] = NULL;
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
c.ldctl_value.bv_val = NULL;
c.ldctl_value.bv_len = 0;
c.ldctl_iscritical = manageDSAit > 1;
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
if( err != LDAP_OPT_SUCCESS ) {
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
c.ldctl_iscritical ? "critical " : "" );
if( c.ldctl_iscritical ) {
return EXIT_FAILURE;
}
}
}
if ( verbose ) {
fprintf( stderr, "DN:%s, attr:%s, value:%s\n",
compdn, attrs, sep );
}
rc = docompare( ld, compdn, attrs, &bvalue, quiet, NULL, NULL );
free( bvalue.bv_val );
ldap_unbind( ld );
return rc;
}
static int docompare(
LDAP *ld,
char *dn,
char *attr,
struct berval *bvalue,
int quiet,
LDAPControl **sctrls,
LDAPControl **cctrls )
{
int rc;
if ( not ) {
return LDAP_SUCCESS;
}
rc = ldap_compare_ext_s( ld, dn, attr, bvalue,
sctrls, cctrls );
if ( rc == -1 ) {
ldap_perror( ld, "ldap_result" );
return( rc );
}
/* if we were told to be quiet, use the return value. */
if ( !quiet ) {
if ( rc == LDAP_COMPARE_TRUE ) {
rc = 0;
printf("TRUE\n");
} else if ( rc == LDAP_COMPARE_FALSE ) {
rc = 0;
printf("FALSE\n");
} else {
ldap_perror( ld, "ldap_compare" );
}
}
return( rc );
}
/* ldapdelete.c - simple program to delete an entry using LDAP */ /* ldapdelete.c - simple program to delete an entry using LDAP */
/* $OpenLDAP$ */
/*
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <lber.h>
#include <ldap.h>
#include "ldapconfig.h" #include <ac/stdlib.h>
#include <ac/ctype.h>
static char *binddn = LDAPDELETE_BINDDN; #include <ac/signal.h>
static char *base = LDAPDELETE_BASE; #include <ac/string.h>
static char *passwd = NULL; #include <ac/unistd.h>
static char *ldaphost = LDAPHOST;
static int ldapport = LDAP_PORT; #include <ldap.h>
static int not, verbose, contoper; #include "lutil.h"
static LDAP *ld; #include "lutil_ldap.h"
#include "ldap_defaults.h"
#ifdef LDAP_DEBUG static char *prog;
extern int ldap_debug, lber_debug; static char *binddn = NULL;
#endif /* LDAP_DEBUG */ static struct berval passwd = { 0, NULL };
static char *ldapuri = NULL;
static char *ldaphost = NULL;
static int ldapport = 0;
static int prune = 0;
#ifdef HAVE_CYRUS_SASL
static unsigned sasl_flags = LDAP_SASL_AUTOMATIC;
static char *sasl_mech = NULL;
static char *sasl_realm = NULL;
static char *sasl_authc_id = NULL;
static char *sasl_authz_id = NULL;
static char *sasl_secprops = NULL;
#endif
static int use_tls = 0;
static int not, verbose, contoper;
static LDAP *ld = NULL;
#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \ static int dodelete LDAP_P((
realloc( ptr, size )) LDAP *ld,
const char *dn));
static int deletechildren LDAP_P((
LDAP *ld,
const char *dn ));
main( argc, argv ) static void
int argc; usage( const char *s )
char **argv;
{ {
char *usage = "usage: %s [-n] [-v] [-k] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n"; fprintf( stderr,
char *p, buf[ 4096 ]; "Delete entries from an LDAP server\n\n"
FILE *fp; "usage: %s [options] [dn]...\n"
int i, rc, kerberos, linenum, authmethod; " dn: list of DNs to delete. If not given, it will be readed from stdin\n"
" or from the file specified with \"-f file\".\n"
"Delete Options:\n"
" -r delete recursively\n"
extern char *optarg; "Common options:\n"
extern int optind; " -d level set LDAP debugging level to `level'\n"
" -D binddn bind DN\n"
" -f file read operations from `file'\n"
" -h host LDAP server\n"
" -H URI LDAP Uniform Resource Indentifier(s)\n"
" -I use SASL Interactive mode\n"
" -k use Kerberos authentication\n"
" -K like -k, but do only step 1 of the Kerberos bind\n"
" -M enable Manage DSA IT control (-MM to make critical)\n"
" -n show what would be done but don't actually do it\n"
" -O props SASL security properties\n"
" -p port port on LDAP server\n"
" -P version procotol version (default: 3)\n"
" -Q use SASL Quiet mode\n"
" -R realm SASL realm\n"
" -U authcid SASL authentication identity\n"
" -v run in verbose mode (diagnostics to standard output)\n"
" -w passwd bind passwd (for simple authentication)\n"
" -W prompt for bind passwd\n"
" -x Simple authentication\n"
" -X authzid SASL authorization identity (\"dn:<dn>\" or \"u:<user>\")\n"
" -Y mech SASL mechanism\n"
" -Z Start TLS request (-ZZ to require successful response)\n"
, s );
exit( EXIT_FAILURE );
}
kerberos = not = verbose = contoper = 0;
int
main( int argc, char **argv )
{
char buf[ 4096 ];
FILE *fp;
int i, rc, authmethod, referrals, want_bindpw, version, debug, manageDSAit;
not = verbose = contoper = want_bindpw = debug = manageDSAit = referrals = 0;
fp = NULL; fp = NULL;
authmethod = -1;
version = -1;
prog = lutil_progname( "ldapdelete", argc, argv );
while (( i = getopt( argc, argv, "nvkKch:p:D:w:d:f:" )) != EOF ) { while (( i = getopt( argc, argv, "cf:r"
"Cd:D:h:H:IkKMnO:p:P:QR:U:vw:WxX:Y:Z" )) != EOF )
{
switch( i ) { switch( i ) {
case 'k': /* kerberos bind */ /* Delete Specific Options */
kerberos = 2;
break;
case 'K': /* kerberos bind, part one only */
kerberos = 1;
break;
case 'c': /* continuous operation mode */ case 'c': /* continuous operation mode */
++contoper; ++contoper;
break; break;
case 'h': /* ldap host */
ldaphost = strdup( optarg );
break;
case 'D': /* bind DN */
binddn = strdup( optarg );
break;
case 'w': /* password */
passwd = strdup( optarg );
break;
case 'f': /* read DNs from a file */ case 'f': /* read DNs from a file */
if( fp != NULL ) {
fprintf( stderr, "%s: -f previously specified\n", prog );
return EXIT_FAILURE;
}
if (( fp = fopen( optarg, "r" )) == NULL ) { if (( fp = fopen( optarg, "r" )) == NULL ) {
perror( optarg ); perror( optarg );
exit( 1 ); exit( EXIT_FAILURE );
} }
break; break;
case 'r':
prune = 1;
break;
/* Common Options */
case 'C':
referrals++;
break;
case 'd': case 'd':
#ifdef LDAP_DEBUG debug |= atoi( optarg );
ldap_debug = lber_debug = atoi( optarg ); /* */
#else /* LDAP_DEBUG */
fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
#endif /* LDAP_DEBUG */
break; break;
case 'p': case 'D': /* bind DN */
ldapport = atoi( optarg ); if( binddn != NULL ) {
fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE;
}
binddn = strdup( optarg );
break; break;
case 'h': /* ldap host */
if( ldapuri != NULL ) {
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE;
}
if( ldaphost != NULL ) {
fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE;
}
ldaphost = strdup( optarg );
break;
case 'H': /* ldap URI */
if( ldaphost != NULL ) {
fprintf( stderr, "%s: -H incompatible with -h\n", prog );
return EXIT_FAILURE;
}
if( ldapport ) {
fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE;
}
if( ldapuri != NULL ) {
fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE;
}
ldapuri = strdup( optarg );
break;
case 'I':
#ifdef HAVE_CYRUS_SASL
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -I incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_flags = LDAP_SASL_INTERACTIVE;
break;
#else
fprintf( stderr, "%s: was not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
case 'k': /* kerberos bind */
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
if( version > LDAP_VERSION2 ) {
fprintf( stderr, "%s: -k incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 ) {
fprintf( stderr, "%s: -k incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_KRBV4;
#else
fprintf( stderr, "%s: not compiled with Kerberos support\n", prog );
return EXIT_FAILURE;
#endif
break;
case 'K': /* kerberos bind, part one only */
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
if( version > LDAP_VERSION2 ) {
fprintf( stderr, "%s: -k incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 ) {
fprintf( stderr, "%s: incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_KRBV41;
#else
fprintf( stderr, "%s: not compiled with Kerberos support\n", prog );
return( EXIT_FAILURE );
#endif
break;
case 'M':
/* enable Manage DSA IT */
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -M incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
manageDSAit++;
version = LDAP_VERSION3;
break;
case 'n': /* print deletes, don't actually do them */ case 'n': /* print deletes, don't actually do them */
++not; ++not;
break; break;
case 'O':
#ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) {
fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -O incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_secprops = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'p':
if( ldapport ) {
fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE;
}
ldapport = atoi( optarg );
break;
case 'P':
switch( atoi(optarg) ) {
case 2:
if( version == LDAP_VERSION3 ) {
fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION2;
break;
case 3:
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION3;
break;
default:
fprintf( stderr, "%s: protocol version should be 2 or 3\n",
prog );
usage( prog );
return( EXIT_FAILURE );
} break;
case 'Q':
#ifdef HAVE_CYRUS_SASL
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Q incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_flags = LDAP_SASL_QUIET;
break;
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
case 'R':
#ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) {
fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -R incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_realm = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'U':
#ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) {
fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -U incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_authc_id = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'v': /* verbose mode */ case 'v': /* verbose mode */
verbose++; verbose++;
break; break;
case 'w': /* password */
passwd.bv_val = strdup( optarg );
{
char* p;
for( p = optarg; *p != '\0'; p++ ) {
*p = '\0';
}
}
passwd.bv_len = strlen( passwd.bv_val );
break;
case 'W':
want_bindpw++;
break;
case 'Y':
#ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) {
fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Y incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible with authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_mech = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'x':
if( authmethod != -1 && authmethod != LDAP_AUTH_SIMPLE ) {
fprintf( stderr, "%s: incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SIMPLE;
break;
case 'X':
#ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) {
fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -X incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: -X incompatible with "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_authz_id = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'Z':
#ifdef HAVE_TLS
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Z incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION3;
use_tls++;
#else
fprintf( stderr, "%s: not compiled with TLS support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
default: default:
fprintf( stderr, usage, argv[0] ); fprintf( stderr, "%s: unrecognized option -%c\n",
exit( 1 ); prog, optopt );
usage( prog );
return( EXIT_FAILURE );
} }
} }
if (version == -1) {
version = LDAP_VERSION3;
}
if (authmethod == -1 && version > LDAP_VERSION2) {
#ifdef HAVE_CYRUS_SASL
authmethod = LDAP_AUTH_SASL;
#else
authmethod = LDAP_AUTH_SIMPLE;
#endif
}
if ( fp == NULL ) { if ( fp == NULL ) {
if ( optind >= argc ) { if ( optind >= argc ) {
fp = stdin; fp = stdin;
} }
} }
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) { if ( debug ) {
perror( "ldap_open" ); if( ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug ) != LBER_OPT_SUCCESS ) {
exit( 1 ); fprintf( stderr, "Could not set LBER_OPT_DEBUG_LEVEL %d\n", debug );
} }
if( ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug ) != LDAP_OPT_SUCCESS ) {
fprintf( stderr, "Could not set LDAP_OPT_DEBUG_LEVEL %d\n", debug );
}
}
ld->ld_deref = LDAP_DEREF_NEVER; /* prudent, but probably unnecessary */ #ifdef SIGPIPE
(void) SIGNAL( SIGPIPE, SIG_IGN );
#endif
if ( !kerberos ) { if( ( ldaphost != NULL || ldapport ) && ( ldapuri == NULL ) ) {
authmethod = LDAP_AUTH_SIMPLE; if ( verbose ) {
} else if ( kerberos == 1 ) { fprintf( stderr, "ldap_init( %s, %d )\n",
authmethod = LDAP_AUTH_KRBV41; ldaphost != NULL ? ldaphost : "<DEFAULT>",
} else { ldapport );
authmethod = LDAP_AUTH_KRBV4; }
}
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( 1 );
}
if ( fp == NULL ) { ld = ldap_init( ldaphost, ldapport );
for ( ; optind < argc; ++optind ) { if( ld == NULL ) {
rc = dodelete( ld, argv[ optind ] ); perror("ldapdelete: ldap_init");
return EXIT_FAILURE;
}
} else {
if ( verbose ) {
fprintf( stderr, "ldap_initialize( %s )\n",
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
}
rc = ldap_initialize( &ld, ldapuri );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
rc, ldap_err2string(rc) );
return EXIT_FAILURE;
}
}
{
/* this seems prudent for searches below */
int deref = LDAP_DEREF_NEVER;
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
}
/* chase referrals */
if( ldap_set_option( ld, LDAP_OPT_REFERRALS,
referrals ? LDAP_OPT_ON : LDAP_OPT_OFF ) != LDAP_OPT_SUCCESS )
{
fprintf( stderr, "Could not set LDAP_OPT_REFERRALS %s\n",
referrals ? "on" : "off" );
return EXIT_FAILURE;
} }
} else {
if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version )
!= LDAP_OPT_SUCCESS )
{
fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n",
version );
return EXIT_FAILURE;
}
if ( use_tls && ( ldap_start_tls_s( ld, NULL, NULL ) != LDAP_SUCCESS )) {
ldap_perror( ld, "ldap_start_tls" );
if ( use_tls > 1 ) {
return EXIT_FAILURE;
}
}
if (want_bindpw) {
passwd.bv_val = getpassphrase("Enter LDAP Password: ");
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
}
if ( authmethod == LDAP_AUTH_SASL ) {
#ifdef HAVE_CYRUS_SASL
void *defaults;
if( sasl_secprops != NULL ) {
rc = ldap_set_option( ld, LDAP_OPT_X_SASL_SECPROPS,
(void *) sasl_secprops );
if( rc != LDAP_OPT_SUCCESS ) {
fprintf( stderr,
"Could not set LDAP_OPT_X_SASL_SECPROPS: %s\n",
sasl_secprops );
return( EXIT_FAILURE );
}
}
defaults = lutil_sasl_defaults( ld,
sasl_mech,
sasl_realm,
sasl_authc_id,
passwd.bv_val,
sasl_authz_id );
rc = ldap_sasl_interactive_bind_s( ld, binddn,
sasl_mech, NULL, NULL,
sasl_flags, lutil_sasl_interact, defaults );
if( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_sasl_interactive_bind_s" );
return( EXIT_FAILURE );
}
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
}
else {
if ( ldap_bind_s( ld, binddn, passwd.bv_val, authmethod )
!= LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
return( EXIT_FAILURE );
}
}
if ( manageDSAit ) {
int err;
LDAPControl c;
LDAPControl *ctrls[2];
ctrls[0] = &c;
ctrls[1] = NULL;
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
c.ldctl_value.bv_val = NULL;
c.ldctl_value.bv_len = 0;
c.ldctl_iscritical = manageDSAit > 1;
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
if( err != LDAP_OPT_SUCCESS ) {
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
c.ldctl_iscritical ? "critical " : "" );
if( c.ldctl_iscritical ) {
exit( EXIT_FAILURE );
}
}
}
rc = 0; rc = 0;
while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) {
buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ if ( fp == NULL ) {
if ( *buf != '\0' ) { for ( ; optind < argc; ++optind ) {
rc = dodelete( ld, buf ); rc = dodelete( ld, argv[ optind ] );
}
/* Stop on error and no -c option */
if( rc != 0 && contoper == 0) break;
}
} else {
while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) {
buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */
if ( *buf != '\0' ) {
rc = dodelete( ld, buf );
}
}
} }
}
ldap_unbind( ld ); ldap_unbind( ld );
exit( rc ); return( rc );
} }
dodelete( ld, dn ) static int dodelete(
LDAP *ld; LDAP *ld,
char *dn; const char *dn)
{ {
int rc; int id;
int rc, code;
char *matcheddn = NULL, *text = NULL, **refs = NULL;
LDAPMessage *res;
if ( verbose ) { if ( verbose ) {
printf( "%sdeleting entry %s\n", not ? "!" : "", dn ); printf( "%sdeleting entry \"%s\"\n",
} (not ? "!" : ""), dn );
if ( not ) { }
rc = LDAP_SUCCESS;
} else { if ( not ) {
if (( rc = ldap_delete_s( ld, dn )) != LDAP_SUCCESS ) { return LDAP_SUCCESS;
ldap_perror( ld, "ldap_delete" ); }
} else if ( verbose ) {
printf( "entry removed\n" ); /* If prune is on, remove a whole subtree. Delete the children of the
* DN recursively, then the DN requested.
*/
if ( prune ) deletechildren( ld, dn );
rc = ldap_delete_ext( ld, dn, NULL, NULL, &id );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: ldap_delete_ext: %s (%d)\n",
prog, ldap_err2string( rc ), rc );
return rc;
}
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, NULL, &res );
if ( rc < 0 ) {
ldap_perror( ld, "ldapdelete: ldap_result" );
return rc;
}
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, NULL, 1 );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: ldap_parse_result: %s (%d)\n",
prog, ldap_err2string( rc ), rc );
return rc;
}
if( verbose || code != LDAP_SUCCESS ||
(matcheddn && *matcheddn) || (text && *text) || (refs && *refs) )
{
printf( "Delete Result: %s (%d)\n", ldap_err2string( code ), code );
if( text && *text ) {
printf( "Additional info: %s\n", text );
}
if( matcheddn && *matcheddn ) {
printf( "Matched DN: %s\n", matcheddn );
}
if( refs ) {
int i;
for( i=0; refs[i]; i++ ) {
printf("Referral: %s\n", refs[i] );
}
}
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );
return code;
}
/*
* Delete all the children of an entry recursively until leaf nodes are reached.
*
*/
static int deletechildren(
LDAP *ld,
const char *dn )
{
LDAPMessage *res, *e;
int entries;
int rc;
static char *attrs[] = { "1.1", NULL };
if ( verbose ) printf ( "deleting children of: %s\n", dn );
/*
* Do a one level search at dn for children. For each, delete its children.
*/
rc = ldap_search_ext_s( ld, dn, LDAP_SCOPE_ONELEVEL, NULL, attrs, 1,
NULL, NULL, NULL, -1, &res );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search" );
return( rc );
}
entries = ldap_count_entries( ld, res );
if ( entries > 0 ) {
int i;
for (e = ldap_first_entry( ld, res ), i = 0; e != NULL;
e = ldap_next_entry( ld, e ), i++ )
{
char *dn = ldap_get_dn( ld, e );
if( dn == NULL ) {
ldap_perror( ld, "ldap_prune" );
ldap_get_option( ld, LDAP_OPT_ERROR_NUMBER, &rc );
ber_memfree( dn );
return rc;
}
rc = deletechildren( ld, dn );
if ( rc == -1 ) {
ldap_perror( ld, "ldap_prune" );
ber_memfree( dn );
return rc;
}
if ( verbose ) {
printf( "\tremoving %s\n", dn );
}
rc = ldap_delete_s( ld, dn );
if ( rc == -1 ) {
ldap_perror( ld, "ldap_delete" );
ber_memfree( dn );
return rc;
}
if ( verbose ) {
printf( "\t%s removed\n", dn );
}
ber_memfree( dn );
}
} }
}
return( rc ); ldap_msgfree( res );
return rc;
} }
/* $OpenLDAP$ */
/*
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* ldapmodify.c - generic program to modify or add entries using LDAP */ /* ldapmodify.c - generic program to modify or add entries using LDAP */
#include "portable.h"
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <stdlib.h> #include <ac/stdlib.h>
#include <ctype.h>
#include <sys/types.h> #include <ac/ctype.h>
#include <ac/signal.h>
#include <ac/string.h>
#include <ac/unistd.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h> #include <sys/file.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h> #include <fcntl.h>
#ifndef VMS #endif
#include <unistd.h>
#endif /* VMS */
#include <lber.h>
#include <ldap.h> #include <ldap.h>
#include <ldif.h>
#include "ldapconfig.h" #include "lutil.h"
#include "lutil_ldap.h"
#include "ldif.h"
#include "ldap_defaults.h"
#include "ldap_log.h"
static char *prog; static char *prog;
static char *binddn = LDAPMODIFY_BINDDN; static char *binddn = NULL;
static char *passwd = NULL; static struct berval passwd = { 0, NULL };
static char *ldaphost = LDAPHOST; static char *ldapuri = NULL;
static int ldapport = LDAP_PORT; static char *ldaphost = NULL;
static int new, replace, not, verbose, contoper, force, valsfromfiles; static int ldapport = 0;
static LDAP *ld; #ifdef HAVE_CYRUS_SASL
static unsigned sasl_flags = LDAP_SASL_AUTOMATIC;
#ifdef LDAP_DEBUG static char *sasl_realm = NULL;
extern int ldap_debug, lber_debug; static char *sasl_authc_id = NULL;
#endif /* LDAP_DEBUG */ static char *sasl_authz_id = NULL;
static char *sasl_mech = NULL;
#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \ static char *sasl_secprops = NULL;
realloc( ptr, size )) #endif
static int use_tls = 0;
static int ldapadd, not, verbose, contoper, force;
static LDAP *ld = NULL;
#define LDAPMOD_MAXLINE 4096 #define LDAPMOD_MAXLINE 4096
/* strings found in replog/LDIF entries (mostly lifted from slurpd/slurp.h) */ /* strings found in replog/LDIF entries (mostly lifted from slurpd/slurp.h) */
#define T_VERSION_STR "version"
#define T_REPLICA_STR "replica" #define T_REPLICA_STR "replica"
#define T_DN_STR "dn" #define T_DN_STR "dn"
#define T_CHANGETYPESTR "changetype" #define T_CHANGETYPESTR "changetype"
...@@ -42,228 +64,740 @@ extern int ldap_debug, lber_debug; ...@@ -42,228 +64,740 @@ extern int ldap_debug, lber_debug;
#define T_MODIFYCTSTR "modify" #define T_MODIFYCTSTR "modify"
#define T_DELETECTSTR "delete" #define T_DELETECTSTR "delete"
#define T_MODRDNCTSTR "modrdn" #define T_MODRDNCTSTR "modrdn"
#define T_MODDNCTSTR "moddn"
#define T_RENAMECTSTR "rename"
#define T_MODOPADDSTR "add" #define T_MODOPADDSTR "add"
#define T_MODOPREPLACESTR "replace" #define T_MODOPREPLACESTR "replace"
#define T_MODOPDELETESTR "delete" #define T_MODOPDELETESTR "delete"
#define T_MODSEPSTR "-" #define T_MODSEPSTR "-"
#define T_NEWRDNSTR "newrdn" #define T_NEWRDNSTR "newrdn"
#define T_DELETEOLDRDNSTR "deleteoldrdn" #define T_DELETEOLDRDNSTR "deleteoldrdn"
#define T_NEWSUPSTR "newsuperior"
static void usage LDAP_P(( const char *prog )) LDAP_GCCATTR((noreturn));
static int process_ldif_rec LDAP_P(( char *rbuf, int count ));
static void addmodifyop LDAP_P((
LDAPMod ***pmodsp, int modop,
const char *attr,
struct berval *value ));
static int domodify LDAP_P((
const char *dn,
LDAPMod **pmods,
int newentry ));
static int dodelete LDAP_P((
const char *dn ));
static int dorename LDAP_P((
const char *dn,
const char *newrdn,
const char *newsup,
int deleteoldrdn ));
static char *read_one_record LDAP_P(( FILE *fp ));
static void
usage( const char *prog )
{
fprintf( stderr,
"Add or modify entries from an LDAP server\n\n"
"usage: %s [options]\n"
" The list of desired operations are read from stdin or from the file\n"
" specified by \"-f file\".\n"
"Add or modify options:\n"
" -a add values (default%s)\n"
" -c continuous operation mode (do not stop on errors)\n"
" -f file read operations from `file'\n"
" -F force all changes records to be used\n"
" -S file write skipped modifications to `file'\n"
"Common options:\n"
" -d level set LDAP debugging level to `level'\n"
" -D binddn bind DN\n"
" -h host LDAP server\n"
" -H URI LDAP Uniform Resource Indentifier(s)\n"
" -I use SASL Interactive mode\n"
" -k use Kerberos authentication\n"
" -K like -k, but do only step 1 of the Kerberos bind\n"
" -M enable Manage DSA IT control (-MM to make critical)\n"
" -n show what would be done but don't actually update\n"
" -O props SASL security properties\n"
" -p port port on LDAP server\n"
" -P version procotol version (default: 3)\n"
" -Q use SASL Quiet mode\n"
" -R realm SASL realm\n"
" -U authcid SASL authentication identity\n"
" -v run in verbose mode (diagnostics to standard output)\n"
" -w passwd bind passwd (for simple authentication)\n"
" -W prompt for bind passwd\n"
" -x Simple authentication\n"
" -X authzid SASL authorization identity (\"dn:<dn>\" or \"u:<user>\")\n"
" -Y mech SASL mechanism\n"
" -Z Start TLS request (-ZZ to require successful response)\n"
, prog, (strcmp( prog, "ldapadd" ) ? " is to replace" : "") );
exit( EXIT_FAILURE );
}
#ifdef NEEDPROTOS int
static int process_ldapmod_rec( char *rbuf ); main( int argc, char **argv )
static int process_ldif_rec( char *rbuf );
static void addmodifyop( LDAPMod ***pmodsp, int modop, char *attr,
char *value, int vlen );
static int domodify( char *dn, LDAPMod **pmods, int newentry );
static int dodelete( char *dn );
static int domodrdn( char *dn, char *newrdn, int deleteoldrdn );
static void freepmods( LDAPMod **pmods );
static int fromfile( char *path, struct berval *bv );
static char *read_one_record( FILE *fp );
#else /* NEEDPROTOS */
static int process_ldapmod_rec();
static int process_ldif_rec();
static void addmodifyop();
static int domodify();
static int dodelete();
static int domodrdn();
static void freepmods();
static int fromfile();
static char *read_one_record();
#endif /* NEEDPROTOS */
main( argc, argv )
int argc;
char **argv;
{ {
char *infile, *rbuf, *start, *p, *q; char *infile, *rejfile, *rbuf, *start, *rejbuf = NULL;
FILE *fp; FILE *fp, *rejfp;
int rc, i, kerberos, use_ldif, authmethod; char *matched_msg = NULL, *error_msg = NULL;
char *usage = "usage: %s [-abcknrvF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n"; int rc, i, authmethod, version, want_bindpw, debug, manageDSAit, referrals;
int count, len;
extern char *optarg; prog = lutil_progname( "ldapmodify", argc, argv );
extern int optind;
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) { /* Print usage when no parameters */
prog = argv[ 0 ]; if( argc < 2 ) usage( prog );
} else {
++prog;
}
new = ( strcmp( prog, "ldapadd" ) == 0 );
infile = NULL; /* strncmp instead of strcmp since NT binaries carry .exe extension */
kerberos = not = verbose = valsfromfiles = 0; ldapadd = ( strncmp( prog, "ldapadd", sizeof("ldapadd")-1 ) == 0 );
while (( i = getopt( argc, argv, "FabckKnrtvh:p:D:w:d:f:" )) != EOF ) { infile = NULL;
rejfile = NULL;
not = verbose = want_bindpw = debug = manageDSAit = referrals = 0;
authmethod = -1;
version = -1;
while (( i = getopt( argc, argv, "acrf:F"
"Cd:D:h:H:IkKMnO:p:P:QR:S:U:vw:WxX:Y:Z" )) != EOF )
{
switch( i ) { switch( i ) {
/* Modify Options */
case 'a': /* add */ case 'a': /* add */
new = 1; ldapadd = 1;
break;
case 'b': /* read values from files (for binary attributes) */
valsfromfiles = 1;
break; break;
case 'c': /* continuous operation */ case 'c': /* continuous operation */
contoper = 1; contoper = 1;
break; break;
case 'r': /* default is to replace rather than add values */ case 'f': /* read from file */
replace = 1; if( infile != NULL ) {
break; fprintf( stderr, "%s: -f previously specified\n", prog );
case 'k': /* kerberos bind */ return EXIT_FAILURE;
kerberos = 2; }
break; infile = strdup( optarg );
case 'K': /* kerberos bind, part 1 only */
kerberos = 1;
break; break;
case 'F': /* force all changes records to be used */ case 'F': /* force all changes records to be used */
force = 1; force = 1;
break; break;
case 'h': /* ldap host */
ldaphost = strdup( optarg ); /* Common Options */
case 'C':
referrals++;
break;
case 'd':
debug |= atoi( optarg );
break; break;
case 'D': /* bind DN */ case 'D': /* bind DN */
if( binddn != NULL ) {
fprintf( stderr, "%s: -D previously specified\n", prog );
return EXIT_FAILURE;
}
binddn = strdup( optarg ); binddn = strdup( optarg );
break; break;
case 'w': /* password */ case 'h': /* ldap host */
passwd = strdup( optarg ); if( ldapuri != NULL ) {
fprintf( stderr, "%s: -h incompatible with -H\n", prog );
return EXIT_FAILURE;
}
if( ldaphost != NULL ) {
fprintf( stderr, "%s: -h previously specified\n", prog );
return EXIT_FAILURE;
}
ldaphost = strdup( optarg );
break; break;
case 'd': case 'H': /* ldap URI */
#ifdef LDAP_DEBUG if( ldaphost != NULL ) {
ldap_debug = lber_debug = atoi( optarg ); /* */ fprintf( stderr, "%s: -H incompatible with -h\n", prog );
#else /* LDAP_DEBUG */ return EXIT_FAILURE;
fprintf( stderr, "%s: compile with -DLDAP_DEBUG for debugging\n", }
prog ); if( ldapport ) {
#endif /* LDAP_DEBUG */ fprintf( stderr, "%s: -H incompatible with -p\n", prog );
return EXIT_FAILURE;
}
if( ldapuri != NULL ) {
fprintf( stderr, "%s: -H previously specified\n", prog );
return EXIT_FAILURE;
}
ldapuri = strdup( optarg );
break; break;
case 'f': /* read from file */ case 'I':
infile = strdup( optarg ); #ifdef HAVE_CYRUS_SASL
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -I incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_flags = LDAP_SASL_INTERACTIVE;
break;
#else
fprintf( stderr, "%s: was not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
case 'k': /* kerberos bind */
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
if( version > LDAP_VERSION2 ) {
fprintf( stderr, "%s: -k incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 ) {
fprintf( stderr, "%s: -k incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_KRBV4;
#else
fprintf( stderr, "%s: not compiled with Kerberos support\n", prog );
return EXIT_FAILURE;
#endif
break; break;
case 'p': case 'K': /* kerberos bind, part one only */
ldapport = atoi( optarg ); #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
if( version > LDAP_VERSION2 ) {
fprintf( stderr, "%s: -k incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 ) {
fprintf( stderr, "%s: incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_KRBV41;
#else
fprintf( stderr, "%s: not compiled with Kerberos support\n", prog );
return( EXIT_FAILURE );
#endif
break; break;
case 'n': /* print adds, don't actually do them */ case 'M':
/* enable Manage DSA IT */
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -M incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
manageDSAit++;
version = LDAP_VERSION3;
break;
case 'n': /* print deletes, don't actually do them */
++not; ++not;
break; break;
case 'O':
#ifdef HAVE_CYRUS_SASL
if( sasl_secprops != NULL ) {
fprintf( stderr, "%s: -O previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -O incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_secprops = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'p':
if( ldapport ) {
fprintf( stderr, "%s: -p previously specified\n", prog );
return EXIT_FAILURE;
}
ldapport = atoi( optarg );
break;
case 'P':
switch( atoi(optarg) ) {
case 2:
if( version == LDAP_VERSION3 ) {
fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION2;
break;
case 3:
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION3;
break;
default:
fprintf( stderr, "%s: protocol version should be 2 or 3\n",
prog );
usage( prog );
return( EXIT_FAILURE );
} break;
case 'Q':
#ifdef HAVE_CYRUS_SASL
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Q incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_flags = LDAP_SASL_QUIET;
break;
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
case 'r': /* replace (obsolete) */
break;
case 'R':
#ifdef HAVE_CYRUS_SASL
if( sasl_realm != NULL ) {
fprintf( stderr, "%s: -R previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -R incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_realm = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'S': /* skipped modifications to file */
if( rejfile != NULL ) {
fprintf( stderr, "%s: -S previously specified\n", prog );
return EXIT_FAILURE;
}
rejfile = strdup( optarg );
break;
case 'U':
#ifdef HAVE_CYRUS_SASL
if( sasl_authc_id != NULL ) {
fprintf( stderr, "%s: -U previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -U incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible previous "
"authentication choice\n",
prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_authc_id = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'v': /* verbose mode */ case 'v': /* verbose mode */
verbose++; verbose++;
break; break;
case 'w': /* password */
passwd.bv_val = strdup( optarg );
{
char* p;
for( p = optarg; *p != '\0'; p++ ) {
*p = '\0';
}
}
passwd.bv_len = strlen( passwd.bv_val );
break;
case 'W':
want_bindpw++;
break;
case 'Y':
#ifdef HAVE_CYRUS_SASL
if( sasl_mech != NULL ) {
fprintf( stderr, "%s: -Y previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Y incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: incompatible with authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_mech = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'x':
if( authmethod != -1 && authmethod != LDAP_AUTH_SIMPLE ) {
fprintf( stderr, "%s: incompatible with previous "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SIMPLE;
break;
case 'X':
#ifdef HAVE_CYRUS_SASL
if( sasl_authz_id != NULL ) {
fprintf( stderr, "%s: -X previously specified\n", prog );
return EXIT_FAILURE;
}
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -X incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
fprintf( stderr, "%s: -X incompatible with "
"authentication choice\n", prog );
return EXIT_FAILURE;
}
authmethod = LDAP_AUTH_SASL;
version = LDAP_VERSION3;
sasl_authz_id = strdup( optarg );
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
case 'Z':
#ifdef HAVE_TLS
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -Z incompatible with version %d\n",
prog, version );
return EXIT_FAILURE;
}
version = LDAP_VERSION3;
use_tls++;
#else
fprintf( stderr, "%s: not compiled with TLS support\n",
prog );
return( EXIT_FAILURE );
#endif
break;
default: default:
fprintf( stderr, usage, prog ); fprintf( stderr, "%s: unrecognized option -%c\n",
exit( 1 ); prog, optopt );
usage( prog );
} }
} }
if ( argc - optind != 0 ) { if (version == -1) {
fprintf( stderr, usage, prog ); version = LDAP_VERSION3;
exit( 1 ); }
if (authmethod == -1 && version > LDAP_VERSION2) {
#ifdef HAVE_CYRUS_SASL
authmethod = LDAP_AUTH_SASL;
#else
authmethod = LDAP_AUTH_SIMPLE;
#endif
}
if ( argc != optind )
usage( prog );
if ( rejfile != NULL ) {
if (( rejfp = fopen( rejfile, "w" )) == NULL ) {
perror( rejfile );
return( EXIT_FAILURE );
}
} else {
rejfp = NULL;
} }
if ( infile != NULL ) { if ( infile != NULL ) {
if (( fp = fopen( infile, "r" )) == NULL ) { if (( fp = fopen( infile, "r" )) == NULL ) {
perror( infile ); perror( infile );
exit( 1 ); return( EXIT_FAILURE );
} }
} else { } else {
fp = stdin; fp = stdin;
} }
if ( debug ) {
if( ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug ) != LBER_OPT_SUCCESS ) {
fprintf( stderr, "Could not set LBER_OPT_DEBUG_LEVEL %d\n", debug );
}
if( ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug ) != LDAP_OPT_SUCCESS ) {
fprintf( stderr, "Could not set LDAP_OPT_DEBUG_LEVEL %d\n", debug );
}
ldif_debug = debug;
}
#ifdef SIGPIPE
(void) SIGNAL( SIGPIPE, SIG_IGN );
#endif
if ( !not ) { if ( !not ) {
if (( ld = ldap_open( ldaphost, ldapport )) == NULL ) { if( ( ldaphost != NULL || ldapport ) && ( ldapuri == NULL ) ) {
perror( "ldap_open" ); if ( verbose ) {
exit( 1 ); fprintf( stderr, "ldap_init( %s, %d )\n",
} ldaphost != NULL ? ldaphost : "<DEFAULT>",
ldapport );
}
ld->ld_deref = LDAP_DEREF_NEVER; /* this seems prudent */ ld = ldap_init( ldaphost, ldapport );
if( ld == NULL ) {
perror("ldapmodify: ldap_init");
return EXIT_FAILURE;
}
if ( !kerberos ) {
authmethod = LDAP_AUTH_SIMPLE;
} else if ( kerberos == 1 ) {
authmethod = LDAP_AUTH_KRBV41;
} else { } else {
authmethod = LDAP_AUTH_KRBV4; if ( verbose ) {
fprintf( stderr, "ldap_initialize( %s )\n",
ldapuri != NULL ? ldapuri : "<DEFAULT>" );
}
rc = ldap_initialize( &ld, ldapuri );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr, "Could not create LDAP session handle (%d): %s\n",
rc, ldap_err2string(rc) );
return EXIT_FAILURE;
}
}
/* referrals */
if( ldap_set_option( ld, LDAP_OPT_REFERRALS,
referrals ? LDAP_OPT_ON : LDAP_OPT_OFF ) != LDAP_OPT_SUCCESS )
{
fprintf( stderr, "Could not set LDAP_OPT_REFERRALS %s\n",
referrals ? "on" : "off" );
return EXIT_FAILURE;
}
if (version == -1 ) {
version = LDAP_VERSION3;
}
if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version )
!= LDAP_OPT_SUCCESS )
{
fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n",
version );
return EXIT_FAILURE;
} }
if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" ); if ( use_tls && ( ldap_start_tls_s( ld, NULL, NULL ) != LDAP_SUCCESS )) {
exit( 1 ); ldap_perror( ld, "ldap_start_tls" );
if ( use_tls > 1 ) {
return( EXIT_FAILURE );
}
}
if (want_bindpw) {
passwd.bv_val = getpassphrase("Enter LDAP Password: ");
passwd.bv_len = passwd.bv_val ? strlen( passwd.bv_val ) : 0;
}
if ( authmethod == LDAP_AUTH_SASL ) {
#ifdef HAVE_CYRUS_SASL
void *defaults;
if( sasl_secprops != NULL ) {
rc = ldap_set_option( ld, LDAP_OPT_X_SASL_SECPROPS,
(void *) sasl_secprops );
if( rc != LDAP_OPT_SUCCESS ) {
fprintf( stderr,
"Could not set LDAP_OPT_X_SASL_SECPROPS: %s\n",
sasl_secprops );
return( EXIT_FAILURE );
}
}
defaults = lutil_sasl_defaults( ld,
sasl_mech,
sasl_realm,
sasl_authc_id,
passwd.bv_val,
sasl_authz_id );
rc = ldap_sasl_interactive_bind_s( ld, binddn,
sasl_mech, NULL, NULL,
sasl_flags, lutil_sasl_interact, defaults );
if( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_sasl_interactive_bind_s" );
return( EXIT_FAILURE );
}
#else
fprintf( stderr, "%s: not compiled with SASL support\n",
prog );
return( EXIT_FAILURE );
#endif
} }
else {
if ( ldap_bind_s( ld, binddn, passwd.bv_val, authmethod )
!= LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
return( EXIT_FAILURE );
}
}
} }
rc = 0; rc = 0;
if ( manageDSAit ) {
int err;
LDAPControl c;
LDAPControl *ctrls[2];
ctrls[0] = &c;
ctrls[1] = NULL;
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
c.ldctl_value.bv_val = NULL;
c.ldctl_value.bv_len = 0;
c.ldctl_iscritical = manageDSAit > 1;
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
if( err != LDAP_OPT_SUCCESS ) {
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
c.ldctl_iscritical ? "critical " : "" );
if( c.ldctl_iscritical ) {
exit( EXIT_FAILURE );
}
}
}
count = 0;
while (( rc == 0 || contoper ) && while (( rc == 0 || contoper ) &&
( rbuf = read_one_record( fp )) != NULL ) { ( rbuf = read_one_record( fp )) != NULL ) {
/* count++;
* we assume record is ldif/slapd.replog if the first line
* has a colon that appears to the left of any equal signs, OR
* if the first line consists entirely of digits (an entry id)
*/
use_ldif = ( p = strchr( rbuf, ':' )) != NULL &&
( q = strchr( rbuf, '\n' )) != NULL && p < q &&
(( q = strchr( rbuf, '=' )) == NULL || p < q );
start = rbuf; start = rbuf;
if ( !use_ldif && ( q = strchr( rbuf, '\n' )) != NULL ) { if ( rejfp ) {
for ( p = rbuf; p < q; ++p ) { len = strlen( rbuf );
if ( !isdigit( *p )) { if (( rejbuf = (char *)malloc( len+1 )) == NULL ) {
break; perror( "realloc" );
exit( EXIT_FAILURE );
} }
} memcpy( rejbuf, rbuf, len+1 );
if ( p >= q ) {
use_ldif = 1;
start = q + 1;
}
} }
if ( use_ldif ) { rc = process_ldif_rec( start, count );
rc = process_ldif_rec( start );
} else { if ( rc && rejfp ) {
rc = process_ldapmod_rec( start ); fprintf(rejfp, "# Error: %s (%d)", ldap_err2string(rc), rc);
}
free( rbuf ); ldap_get_option(ld, LDAP_OPT_MATCHED_DN, &matched_msg);
if ( matched_msg != NULL && *matched_msg != '\0' ) {
fprintf( rejfp, ", matched DN: %s", matched_msg );
}
ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &error_msg);
if ( error_msg != NULL && *error_msg != '\0' ) {
fprintf( rejfp, ", additional info: %s", error_msg );
}
fprintf( rejfp, "\n%s\n", rejbuf );
}
if (rejfp)
free( rejbuf );
free( rbuf );
} }
if ( !not ) { if ( !not ) {
ldap_unbind( ld ); ldap_unbind( ld );
} }
exit( rc ); if ( rejfp != NULL ) {
fclose( rejfp );
}
return( rc );
} }
static int static int
process_ldif_rec( char *rbuf ) process_ldif_rec( char *rbuf, int count )
{ {
char *line, *dn, *type, *value, *newrdn, *p; char *line, *dn, *type, *newrdn, *newsup, *p;
int rc, linenum, vlen, modop, replicaport; int rc, linenum, modop, replicaport;
int expect_modop, expect_sep, expect_ct, expect_newrdn; int expect_modop, expect_sep, expect_ct, expect_newrdn, expect_newsup;
int expect_deleteoldrdn, deleteoldrdn; int expect_deleteoldrdn, deleteoldrdn;
int saw_replica, use_record, new_entry, delete_entry, got_all; int saw_replica, use_record, new_entry, delete_entry, got_all;
LDAPMod **pmods; LDAPMod **pmods;
int version;
struct berval val;
new_entry = new; new_entry = ldapadd;
rc = got_all = saw_replica = delete_entry = expect_modop = 0; rc = got_all = saw_replica = delete_entry = modop = expect_modop = 0;
expect_deleteoldrdn = expect_newrdn = expect_sep = expect_ct = 0; expect_deleteoldrdn = expect_newrdn = expect_newsup = 0;
expect_sep = expect_ct = 0;
linenum = 0; linenum = 0;
version = 0;
deleteoldrdn = 1; deleteoldrdn = 1;
use_record = force; use_record = force;
pmods = NULL; pmods = NULL;
dn = newrdn = NULL; dn = newrdn = newsup = NULL;
while ( rc == 0 && ( line = str_getline( &rbuf )) != NULL ) { while ( rc == 0 && ( line = ldif_getline( &rbuf )) != NULL ) {
++linenum; ++linenum;
if ( expect_sep && strcasecmp( line, T_MODSEPSTR ) == 0 ) { if ( expect_sep && strcasecmp( line, T_MODSEPSTR ) == 0 ) {
expect_sep = 0; expect_sep = 0;
expect_ct = 1; expect_ct = 1;
continue; continue;
} }
if ( str_parse_line( line, &type, &value, &vlen ) < 0 ) { if ( ldif_parse_line( line, &type, &val.bv_val, &val.bv_len ) < 0 ) {
fprintf( stderr, "%s: invalid format (line %d of entry: %s\n", fprintf( stderr, "%s: invalid format (line %d) entry: \"%s\"\n",
prog, linenum, dn == NULL ? "" : dn ); prog, linenum, dn == NULL ? "" : dn );
rc = LDAP_PARAM_ERROR; rc = LDAP_PARAM_ERROR;
break; break;
...@@ -272,53 +806,85 @@ process_ldif_rec( char *rbuf ) ...@@ -272,53 +806,85 @@ process_ldif_rec( char *rbuf )
if ( dn == NULL ) { if ( dn == NULL ) {
if ( !use_record && strcasecmp( type, T_REPLICA_STR ) == 0 ) { if ( !use_record && strcasecmp( type, T_REPLICA_STR ) == 0 ) {
++saw_replica; ++saw_replica;
if (( p = strchr( value, ':' )) == NULL ) { if (( p = strchr( val.bv_val, ':' )) == NULL ) {
replicaport = LDAP_PORT; replicaport = 0;
} else { } else {
*p++ = '\0'; *p++ = '\0';
replicaport = atoi( p ); replicaport = atoi( p );
} }
if ( strcasecmp( value, ldaphost ) == 0 && if ( ldaphost != NULL && strcasecmp( val.bv_val, ldaphost ) == 0 &&
replicaport == ldapport ) { replicaport == ldapport ) {
use_record = 1; use_record = 1;
} }
} else if ( count == 1 && linenum == 1 &&
strcasecmp( type, T_VERSION_STR ) == 0 )
{
if( val.bv_len == 0 || atoi(val.bv_val) != 1 ) {
fprintf( stderr, "%s: invalid version %s, line %d (ignored)\n",
prog, val.bv_val == NULL ? "(null)" : val.bv_val, linenum );
}
version++;
} else if ( strcasecmp( type, T_DN_STR ) == 0 ) { } else if ( strcasecmp( type, T_DN_STR ) == 0 ) {
if (( dn = strdup( value )) == NULL ) { if (( dn = strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
perror( "strdup" ); perror( "strdup" );
exit( 1 ); exit( EXIT_FAILURE );
} }
expect_ct = 1; expect_ct = 1;
} }
continue; /* skip all lines until we see "dn:" */ goto end_line; /* skip all lines until we see "dn:" */
} }
if ( expect_ct ) { if ( expect_ct ) {
expect_ct = 0; expect_ct = 0;
if ( !use_record && saw_replica ) { if ( !use_record && saw_replica ) {
printf( "%s: skipping change record for entry: %s\n\t(LDAP host/port does not match replica: lines)\n", printf( "%s: skipping change record for entry: %s\n"
"\t(LDAP host/port does not match replica: lines)\n",
prog, dn ); prog, dn );
free( dn ); free( dn );
ber_memfree( type );
ber_memfree( val.bv_val );
return( 0 ); return( 0 );
} }
if ( strcasecmp( type, T_CHANGETYPESTR ) == 0 ) { if ( strcasecmp( type, T_CHANGETYPESTR ) == 0 ) {
if ( strcasecmp( value, T_MODIFYCTSTR ) == 0 ) { #ifdef LIBERAL_CHANGETYPE_MODOP
/* trim trailing spaces (and log warning ...) */
int icnt;
for ( icnt = val.bv_len; --icnt > 0; ) {
if ( !isspace( (unsigned char) val.bv_val[icnt] ) ) {
break;
}
}
if ( ++icnt != val.bv_len ) {
fprintf( stderr, "%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n",
prog, T_CHANGETYPESTR, val.bv_val, linenum, dn );
val.bv_val[icnt] = '\0';
}
#endif /* LIBERAL_CHANGETYPE_MODOP */
if ( strcasecmp( val.bv_val, T_MODIFYCTSTR ) == 0 ) {
new_entry = 0; new_entry = 0;
expect_modop = 1; expect_modop = 1;
} else if ( strcasecmp( value, T_ADDCTSTR ) == 0 ) { } else if ( strcasecmp( val.bv_val, T_ADDCTSTR ) == 0 ) {
new_entry = 1; new_entry = 1;
} else if ( strcasecmp( value, T_MODRDNCTSTR ) == 0 ) { } else if ( strcasecmp( val.bv_val, T_MODRDNCTSTR ) == 0
|| strcasecmp( val.bv_val, T_MODDNCTSTR ) == 0
|| strcasecmp( val.bv_val, T_RENAMECTSTR ) == 0)
{
expect_newrdn = 1; expect_newrdn = 1;
} else if ( strcasecmp( value, T_DELETECTSTR ) == 0 ) { } else if ( strcasecmp( val.bv_val, T_DELETECTSTR ) == 0 ) {
got_all = delete_entry = 1; got_all = delete_entry = 1;
} else { } else {
fprintf( stderr, fprintf( stderr,
"%s: unknown %s \"%s\" (line %d of entry: %s)\n", "%s: unknown %s \"%s\" (line %d of entry \"%s\")\n",
prog, T_CHANGETYPESTR, value, linenum, dn ); prog, T_CHANGETYPESTR, val.bv_val, linenum, dn );
rc = LDAP_PARAM_ERROR; rc = LDAP_PARAM_ERROR;
} }
continue; goto end_line;
} else if ( new ) { /* missing changetype => add */ } else if ( ldapadd ) { /* missing changetype => add */
new_entry = 1; new_entry = 1;
modop = LDAP_MOD_ADD; modop = LDAP_MOD_ADD;
} else { } else {
...@@ -327,60 +893,104 @@ process_ldif_rec( char *rbuf ) ...@@ -327,60 +893,104 @@ process_ldif_rec( char *rbuf )
} }
if ( expect_modop ) { if ( expect_modop ) {
#ifdef LIBERAL_CHANGETYPE_MODOP
/* trim trailing spaces (and log warning ...) */
int icnt;
for ( icnt = val.bv_len; --icnt > 0; ) {
if ( !isspace( (unsigned char) val.bv_val[icnt] ) ) {
break;
}
}
if ( ++icnt != val.bv_len ) {
fprintf( stderr, "%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n",
prog, type, val.bv_val, linenum, dn );
val.bv_val[icnt] = '\0';
}
#endif /* LIBERAL_CHANGETYPE_MODOP */
expect_modop = 0; expect_modop = 0;
expect_sep = 1; expect_sep = 1;
if ( strcasecmp( type, T_MODOPADDSTR ) == 0 ) { if ( strcasecmp( type, T_MODOPADDSTR ) == 0 ) {
modop = LDAP_MOD_ADD; modop = LDAP_MOD_ADD;
continue; goto end_line;
} else if ( strcasecmp( type, T_MODOPREPLACESTR ) == 0 ) { } else if ( strcasecmp( type, T_MODOPREPLACESTR ) == 0 ) {
modop = LDAP_MOD_REPLACE; modop = LDAP_MOD_REPLACE;
continue; addmodifyop( &pmods, modop, val.bv_val, NULL );
goto end_line;
} else if ( strcasecmp( type, T_MODOPDELETESTR ) == 0 ) { } else if ( strcasecmp( type, T_MODOPDELETESTR ) == 0 ) {
modop = LDAP_MOD_DELETE; modop = LDAP_MOD_DELETE;
addmodifyop( &pmods, modop, value, NULL, 0 ); addmodifyop( &pmods, modop, val.bv_val, NULL );
continue; goto end_line;
} else { /* no modify op: use default */ } else { /* no modify op: use default */
modop = replace ? LDAP_MOD_REPLACE : LDAP_MOD_ADD; modop = ldapadd ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
} }
} }
if ( expect_newrdn ) { if ( expect_newrdn ) {
if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) { if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) {
if (( newrdn = strdup( value )) == NULL ) { if (( newrdn = strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
perror( "strdup" ); perror( "strdup" );
exit( 1 ); exit( EXIT_FAILURE );
} }
expect_deleteoldrdn = 1; expect_deleteoldrdn = 1;
expect_newrdn = 0; expect_newrdn = 0;
} else { } else {
fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry %s)\n", fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n",
prog, T_NEWRDNSTR, type, linenum, dn ); prog, T_NEWRDNSTR, type, linenum, dn );
rc = LDAP_PARAM_ERROR; rc = LDAP_PARAM_ERROR;
} }
} else if ( expect_deleteoldrdn ) { } else if ( expect_deleteoldrdn ) {
if ( strcasecmp( type, T_DELETEOLDRDNSTR ) == 0 ) { if ( strcasecmp( type, T_DELETEOLDRDNSTR ) == 0 ) {
deleteoldrdn = ( *value == '0' ) ? 0 : 1; deleteoldrdn = ( *val.bv_val == '0' ) ? 0 : 1;
expect_deleteoldrdn = 0;
expect_newsup = 1;
got_all = 1; got_all = 1;
} else { } else {
fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry %s)\n", fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n",
prog, T_DELETEOLDRDNSTR, type, linenum, dn ); prog, T_DELETEOLDRDNSTR, type, linenum, dn );
rc = LDAP_PARAM_ERROR; rc = LDAP_PARAM_ERROR;
} }
} else if ( expect_newsup ) {
if ( strcasecmp( type, T_NEWSUPSTR ) == 0 ) {
if (( newsup = strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
perror( "strdup" );
exit( EXIT_FAILURE );
}
expect_newsup = 0;
} else {
fprintf( stderr, "%s: expecting \"%s:\" but saw \"%s:\" (line %d of entry \"%s\")\n",
prog, T_NEWSUPSTR, type, linenum, dn );
rc = LDAP_PARAM_ERROR;
}
} else if ( got_all ) { } else if ( got_all ) {
fprintf( stderr, fprintf( stderr,
"%s: extra lines at end (line %d of entry %s)\n", "%s: extra lines at end (line %d of entry \"%s\")\n",
prog, linenum, dn ); prog, linenum, dn );
rc = LDAP_PARAM_ERROR; rc = LDAP_PARAM_ERROR;
} else { } else {
addmodifyop( &pmods, modop, type, value, vlen ); addmodifyop( &pmods, modop, type, val.bv_val == NULL ? NULL : &val );
} }
end_line:
ber_memfree( type );
ber_memfree( val.bv_val );
} }
if( linenum == 0 ) {
return 0;
}
if( version && linenum == 1 ) {
return 0;
}
if ( rc == 0 ) { if ( rc == 0 ) {
if ( delete_entry ) { if ( delete_entry ) {
rc = dodelete( dn ); rc = dodelete( dn );
} else if ( newrdn != NULL ) { } else if ( newrdn != NULL ) {
rc = domodrdn( dn, newrdn, deleteoldrdn ); rc = dorename( dn, newrdn, newsup, deleteoldrdn );
} else { } else {
rc = domodify( dn, pmods, new_entry ); rc = domodify( dn, pmods, new_entry );
} }
...@@ -397,209 +1007,110 @@ process_ldif_rec( char *rbuf ) ...@@ -397,209 +1007,110 @@ process_ldif_rec( char *rbuf )
free( newrdn ); free( newrdn );
} }
if ( pmods != NULL ) { if ( pmods != NULL ) {
freepmods( pmods ); ldap_mods_free( pmods, 1 );
} }
return( rc ); return( rc );
} }
static int static void
process_ldapmod_rec( char *rbuf ) addmodifyop(
LDAPMod ***pmodsp,
int modop,
const char *attr,
struct berval *val )
{ {
char *line, *dn, *p, *q, *attr, *value; LDAPMod **pmods;
int rc, linenum, modop; int i, j;
LDAPMod **pmods;
pmods = *pmodsp;
pmods = NULL; modop |= LDAP_MOD_BVALUES;
dn = NULL;
linenum = 0; i = 0;
line = rbuf; if ( pmods != NULL ) {
rc = 0; for ( ; pmods[ i ] != NULL; ++i ) {
if ( strcasecmp( pmods[ i ]->mod_type, attr ) == 0 &&
while ( rc == 0 && rbuf != NULL && *rbuf != '\0' ) { pmods[ i ]->mod_op == modop )
++linenum; {
if (( p = strchr( rbuf, '\n' )) == NULL ) { break;
rbuf = NULL; }
} else { }
if ( *(p-1) == '\\' ) { /* lines ending in '\' are continued */
strcpy( p - 1, p );
rbuf = p;
continue;
}
*p++ = '\0';
rbuf = p;
} }
if ( dn == NULL ) { /* first line contains DN */ if ( pmods == NULL || pmods[ i ] == NULL ) {
if (( dn = strdup( line )) == NULL ) { if (( pmods = (LDAPMod **)ber_memrealloc( pmods, (i + 2) *
perror( "strdup" ); sizeof( LDAPMod * ))) == NULL )
exit( 1 ); {
} perror( "realloc" );
} else { exit( EXIT_FAILURE );
if (( p = strchr( line, '=' )) == NULL ) {
value = NULL;
p = line + strlen( line );
} else {
*p++ = '\0';
value = p;
}
for ( attr = line; *attr != '\0' && isspace( *attr ); ++attr ) {
; /* skip attribute leading white space */
}
for ( q = p - 1; q > attr && isspace( *q ); --q ) {
*q = '\0'; /* remove attribute trailing white space */
}
if ( value != NULL ) {
while ( isspace( *value )) {
++value; /* skip value leading white space */
}
for ( q = value + strlen( value ) - 1; q > value &&
isspace( *q ); --q ) {
*q = '\0'; /* remove value trailing white space */
}
if ( *value == '\0' ) {
value = NULL;
} }
} *pmodsp = pmods;
pmods[ i + 1 ] = NULL;
if ( value == NULL && new ) { pmods[ i ] = (LDAPMod *)ber_memcalloc( 1, sizeof( LDAPMod ));
fprintf( stderr, "%s: missing value on line %d (attr is %s)\n", if ( pmods[ i ] == NULL ) {
prog, linenum, attr ); perror( "calloc" );
rc = LDAP_PARAM_ERROR; exit( EXIT_FAILURE );
} else {
switch ( *attr ) {
case '-':
modop = LDAP_MOD_DELETE;
++attr;
break;
case '+':
modop = LDAP_MOD_ADD;
++attr;
break;
default:
modop = replace ? LDAP_MOD_REPLACE : LDAP_MOD_ADD;
} }
addmodifyop( &pmods, modop, attr, value, pmods[ i ]->mod_op = modop;
( value == NULL ) ? 0 : strlen( value )); pmods[ i ]->mod_type = ber_strdup( attr );
} if ( pmods[ i ]->mod_type == NULL ) {
} perror( "strdup" );
exit( EXIT_FAILURE );
line = rbuf; }
}
if ( rc == 0 ) {
if ( dn == NULL ) {
rc = LDAP_PARAM_ERROR;
} else if (( rc = domodify( dn, pmods, new )) == LDAP_SUCCESS ) {
rc = 0;
}
}
if ( pmods != NULL ) {
freepmods( pmods );
}
if ( dn != NULL ) {
free( dn );
}
return( rc );
}
static void
addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
{
LDAPMod **pmods;
int i, j;
struct berval *bvp;
pmods = *pmodsp;
modop |= LDAP_MOD_BVALUES;
i = 0;
if ( pmods != NULL ) {
for ( ; pmods[ i ] != NULL; ++i ) {
if ( strcasecmp( pmods[ i ]->mod_type, attr ) == 0 &&
pmods[ i ]->mod_op == modop ) {
break;
}
} }
}
if ( pmods == NULL || pmods[ i ] == NULL ) { if ( val != NULL ) {
if (( pmods = (LDAPMod **)safe_realloc( pmods, (i + 2) * j = 0;
sizeof( LDAPMod * ))) == NULL ) { if ( pmods[ i ]->mod_bvalues != NULL ) {
perror( "safe_realloc" ); for ( ; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
exit( 1 ); /* Empty */;
} }
*pmodsp = pmods; }
pmods[ i + 1 ] = NULL;
if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod )))
== NULL ) {
perror( "calloc" );
exit( 1 );
}
pmods[ i ]->mod_op = modop;
if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) {
perror( "strdup" );
exit( 1 );
}
}
if ( value != NULL ) { pmods[ i ]->mod_bvalues = (struct berval **) ber_memrealloc(
j = 0; pmods[ i ]->mod_bvalues, (j + 2) * sizeof( struct berval * ));
if ( pmods[ i ]->mod_bvalues != NULL ) { if ( pmods[ i ]->mod_bvalues == NULL ) {
for ( ; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) { perror( "ber_realloc" );
; exit( EXIT_FAILURE );
} }
}
if (( pmods[ i ]->mod_bvalues =
(struct berval **)safe_realloc( pmods[ i ]->mod_bvalues,
(j + 2) * sizeof( struct berval * ))) == NULL ) {
perror( "safe_realloc" );
exit( 1 );
}
pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
if (( bvp = (struct berval *)malloc( sizeof( struct berval )))
== NULL ) {
perror( "malloc" );
exit( 1 );
}
pmods[ i ]->mod_bvalues[ j ] = bvp;
if ( valsfromfiles && *value == '/' ) { /* get value from file */ pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
if ( fromfile( value, bvp ) < 0 ) { pmods[ i ]->mod_bvalues[ j ] = ber_bvdup( val );
exit( 1 ); if ( pmods[ i ]->mod_bvalues[ j ] == NULL ) {
} perror( "ber_bvdup" );
} else { exit( EXIT_FAILURE );
bvp->bv_len = vlen; }
if (( bvp->bv_val = (char *)malloc( vlen + 1 )) == NULL ) {
perror( "malloc" );
exit( 1 );
}
SAFEMEMCPY( bvp->bv_val, value, vlen );
bvp->bv_val[ vlen ] = '\0';
} }
}
} }
static int static int
domodify( char *dn, LDAPMod **pmods, int newentry ) domodify(
const char *dn,
LDAPMod **pmods,
int newentry )
{ {
int i, j, k, notascii, op; int i, j, k, notascii, op;
struct berval *bvp; struct berval *bvp;
if ( pmods == NULL ) { if ( pmods == NULL ) {
fprintf( stderr, "%s: no attributes to change or add (entry %s)\n", fprintf( stderr, "%s: no attributes to change or add (entry=\"%s\")\n",
prog, dn ); prog, dn );
return( LDAP_PARAM_ERROR ); return( LDAP_PARAM_ERROR );
}
for ( i = 0; pmods[ i ] != NULL; ++i ) {
op = pmods[ i ]->mod_op & ~LDAP_MOD_BVALUES;
if( op == LDAP_MOD_ADD && ( pmods[i]->mod_bvalues == NULL )) {
fprintf( stderr,
"%s: attribute \"%s\" has no values (entry=\"%s\")\n",
prog, pmods[i]->mod_type, dn );
return LDAP_PARAM_ERROR;
}
} }
if ( verbose ) { if ( verbose ) {
...@@ -612,7 +1123,7 @@ domodify( char *dn, LDAPMod **pmods, int newentry ) ...@@ -612,7 +1123,7 @@ domodify( char *dn, LDAPMod **pmods, int newentry )
for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) { for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
bvp = pmods[ i ]->mod_bvalues[ j ]; bvp = pmods[ i ]->mod_bvalues[ j ];
notascii = 0; notascii = 0;
for ( k = 0; k < bvp->bv_len; ++k ) { for ( k = 0; (unsigned long) k < bvp->bv_len; ++k ) {
if ( !isascii( bvp->bv_val[ k ] )) { if ( !isascii( bvp->bv_val[ k ] )) {
notascii = 1; notascii = 1;
break; break;
...@@ -629,9 +1140,9 @@ domodify( char *dn, LDAPMod **pmods, int newentry ) ...@@ -629,9 +1140,9 @@ domodify( char *dn, LDAPMod **pmods, int newentry )
} }
if ( newentry ) { if ( newentry ) {
printf( "%sadding new entry %s\n", not ? "!" : "", dn ); printf( "%sadding new entry \"%s\"\n", not ? "!" : "", dn );
} else { } else {
printf( "%smodifying entry %s\n", not ? "!" : "", dn ); printf( "%smodifying entry \"%s\"\n", not ? "!" : "", dn );
} }
if ( !not ) { if ( !not ) {
...@@ -641,7 +1152,9 @@ domodify( char *dn, LDAPMod **pmods, int newentry ) ...@@ -641,7 +1152,9 @@ domodify( char *dn, LDAPMod **pmods, int newentry )
i = ldap_modify_s( ld, dn, pmods ); i = ldap_modify_s( ld, dn, pmods );
} }
if ( i != LDAP_SUCCESS ) { if ( i != LDAP_SUCCESS ) {
ldap_perror( ld, newentry ? "ldap_add" : "ldap_modify" ); /* print error message about failed update including DN */
fprintf( stderr, "%s: update failed: %s\n", prog, dn );
ldap_perror( ld, newentry ? "ldap_add" : "ldap_modify" );
} else if ( verbose ) { } else if ( verbose ) {
printf( "modify complete\n" ); printf( "modify complete\n" );
} }
...@@ -656,14 +1169,16 @@ domodify( char *dn, LDAPMod **pmods, int newentry ) ...@@ -656,14 +1169,16 @@ domodify( char *dn, LDAPMod **pmods, int newentry )
static int static int
dodelete( char *dn ) dodelete(
const char *dn )
{ {
int rc; int rc;
printf( "%sdeleting entry %s\n", not ? "!" : "", dn ); printf( "%sdeleting entry \"%s\"\n", not ? "!" : "", dn );
if ( !not ) { if ( !not ) {
if (( rc = ldap_delete_s( ld, dn )) != LDAP_SUCCESS ) { if (( rc = ldap_delete_s( ld, dn )) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_delete" ); fprintf( stderr, "%s: delete failed: %s\n", prog, dn );
ldap_perror( ld, "ldap_delete" );
} else if ( verbose ) { } else if ( verbose ) {
printf( "delete complete" ); printf( "delete complete" );
} }
...@@ -678,20 +1193,26 @@ dodelete( char *dn ) ...@@ -678,20 +1193,26 @@ dodelete( char *dn )
static int static int
domodrdn( char *dn, char *newrdn, int deleteoldrdn ) dorename(
const char *dn,
const char *newrdn,
const char* newsup,
int deleteoldrdn )
{ {
int rc; int rc;
printf( "%smodifying rdn of entry \"%s\"\n", not ? "!" : "", dn );
if ( verbose ) { if ( verbose ) {
printf( "new RDN: %s (%skeep existing values)\n", printf( "\tnew RDN: \"%s\" (%skeep existing values)\n",
newrdn, deleteoldrdn ? "do not " : "" ); newrdn, deleteoldrdn ? "do not " : "" );
} }
printf( "%smodifying rdn of entry %s\n", not ? "!" : "", dn );
if ( !not ) { if ( !not ) {
if (( rc = ldap_modrdn2_s( ld, dn, newrdn, deleteoldrdn )) if (( rc = ldap_rename2_s( ld, dn, newrdn, newsup, deleteoldrdn ))
!= LDAP_SUCCESS ) { != LDAP_SUCCESS )
ldap_perror( ld, "ldap_modrdn" ); {
fprintf( stderr, "%s: rename failed: %s\n", prog, dn );
ldap_perror( ld, "ldap_modrdn" );
} else { } else {
printf( "modrdn completed\n" ); printf( "modrdn completed\n" );
} }
...@@ -705,93 +1226,38 @@ domodrdn( char *dn, char *newrdn, int deleteoldrdn ) ...@@ -705,93 +1226,38 @@ domodrdn( char *dn, char *newrdn, int deleteoldrdn )
} }
static void
freepmods( LDAPMod **pmods )
{
int i;
for ( i = 0; pmods[ i ] != NULL; ++i ) {
if ( pmods[ i ]->mod_bvalues != NULL ) {
ber_bvecfree( pmods[ i ]->mod_bvalues );
}
if ( pmods[ i ]->mod_type != NULL ) {
free( pmods[ i ]->mod_type );
}
free( pmods[ i ] );
}
free( pmods );
}
static int
fromfile( char *path, struct berval *bv )
{
FILE *fp;
long rlen;
int eof;
if (( fp = fopen( path, "r" )) == NULL ) {
perror( path );
return( -1 );
}
if ( fseek( fp, 0L, SEEK_END ) != 0 ) {
perror( path );
fclose( fp );
return( -1 );
}
bv->bv_len = ftell( fp );
if (( bv->bv_val = (char *)malloc( bv->bv_len )) == NULL ) {
perror( "malloc" );
fclose( fp );
return( -1 );
}
if ( fseek( fp, 0L, SEEK_SET ) != 0 ) {
perror( path );
fclose( fp );
return( -1 );
}
rlen = fread( bv->bv_val, 1, bv->bv_len, fp );
eof = feof( fp );
fclose( fp );
if ( rlen != bv->bv_len ) {
perror( path );
free( bv->bv_val );
return( -1 );
}
return( bv->bv_len );
}
static char * static char *
read_one_record( FILE *fp ) read_one_record( FILE *fp )
{ {
int len;
char *buf, line[ LDAPMOD_MAXLINE ]; char *buf, line[ LDAPMOD_MAXLINE ];
int lcur, lmax; int lcur, lmax;
lcur = lmax = 0; lcur = lmax = 0;
buf = NULL; buf = NULL;
while (( fgets( line, sizeof(line), fp ) != NULL ) && while ( fgets( line, sizeof(line), fp ) != NULL ) {
(( len = strlen( line )) > 1 )) { int len = strlen( line );
if ( lcur + len + 1 > lmax ) {
lmax = LDAPMOD_MAXLINE if( len < 2 || ( len == 2 && *line == '\r' )) {
* (( lcur + len + 1 ) / LDAPMOD_MAXLINE + 1 ); if( buf == NULL ) {
if (( buf = (char *)safe_realloc( buf, lmax )) == NULL ) { continue;
perror( "safe_realloc" ); } else {
exit( 1 ); break;
} }
} }
strcpy( buf + lcur, line );
lcur += len; if ( lcur + len + 1 > lmax ) {
lmax = LDAPMOD_MAXLINE
* (( lcur + len + 1 ) / LDAPMOD_MAXLINE + 1 );
if (( buf = (char *)realloc( buf, lmax )) == NULL ) {
perror( "realloc" );
exit( EXIT_FAILURE );
}
}
strcpy( buf + lcur, line );
lcur += len;
} }
return( buf ); return( buf );
......