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
Showing
with 36169 additions and 0 deletions
/* common.h - common definitions for the ldap client tools */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* ACKNOWLEDGEMENTS:
* This file was initially created by Hallvard B. Furuseth based (in
* part) upon argument parsing code for individual tools located in
* this directory.
*/
#ifndef _CLIENT_TOOLS_COMMON_H_
#define _CLIENT_TOOLS_COMMON_H_
LDAP_BEGIN_DECL
typedef enum tool_type_t {
TOOL_SEARCH = 0x01U,
TOOL_COMPARE = 0x02U,
TOOL_ADD = 0x04U,
TOOL_DELETE = 0x08U,
TOOL_MODIFY = 0x10U,
TOOL_MODRDN = 0x20U,
TOOL_EXOP = 0x40U,
TOOL_WHOAMI = TOOL_EXOP | 0x100U,
TOOL_PASSWD = TOOL_EXOP | 0x200U,
TOOL_WRITE = (TOOL_ADD|TOOL_DELETE|TOOL_MODIFY|TOOL_MODRDN),
TOOL_READ = (TOOL_SEARCH|TOOL_COMPARE),
TOOL_ALL = 0xFFU
} tool_type_t;
/* input-related vars */
/* misc. parameters */
extern tool_type_t tool_type;
extern int contoper;
extern int debug;
extern char *infile;
extern int dont;
extern int referrals;
extern int verbose;
extern int ldif;
extern ber_len_t ldif_wrap;
extern char *prog;
/* connection */
extern char *ldapuri;
extern char *ldaphost;
extern int ldapport;
extern int use_tls;
extern int protocol;
extern int version;
/* authc/authz */
extern int authmethod;
extern char *binddn;
extern int want_bindpw;
extern struct berval passwd;
extern char *pw_file;
#ifdef HAVE_CYRUS_SASL
extern unsigned sasl_flags;
extern char *sasl_realm;
extern char *sasl_authc_id;
extern char *sasl_authz_id;
extern char *sasl_mech;
extern char *sasl_secprops;
#endif
/* controls */
extern char *assertion;
extern char *authzid;
extern int manageDIT;
extern int manageDSAit;
extern int noop;
extern int ppolicy;
extern int preread, postread;
extern ber_int_t pr_morePagedResults;
extern struct berval pr_cookie;
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
extern int chaining;
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
extern ber_int_t vlvPos;
extern ber_int_t vlvCount;
extern struct berval *vlvContext;
/* options */
extern struct timeval nettimeout;
/* Defined in common.c, set in main() */
extern const char __Version[];
/* Defined in main program */
extern const char options[];
void usage LDAP_P(( void )) LDAP_GCCATTR((noreturn));
int handle_private_option LDAP_P(( int i ));
/* Defined in common.c */
void tool_init LDAP_P(( tool_type_t type ));
void tool_common_usage LDAP_P(( void ));
void tool_args LDAP_P(( int, char ** ));
LDAP *tool_conn_setup LDAP_P(( int dont, void (*private_setup)( LDAP * ) ));
void tool_bind LDAP_P(( LDAP * ));
void tool_unbind LDAP_P(( LDAP * ));
void tool_destroy LDAP_P(( void ));
void tool_exit LDAP_P(( LDAP *ld, int status )) LDAP_GCCATTR((noreturn));
void tool_server_controls LDAP_P(( LDAP *, LDAPControl *, int ));
int tool_check_abandon LDAP_P(( LDAP *ld, int msgid ));
void tool_perror LDAP_P((
const char *func,
int err,
const char *extra,
const char *matched,
const char *info,
char **refs ));
void tool_print_ctrls LDAP_P(( LDAP *ld, LDAPControl **ctrls ));
int tool_write_ldif LDAP_P(( int type, char *name, char *value, ber_len_t vallen ));
int tool_is_oid LDAP_P(( const char *s ));
LDAP_END_DECL
#endif /* _CLIENT_TOOLS_COMMON_H_ */
/* ldapcompare.c -- LDAP compare tool */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*/
/* Portions Copyright 2002, F5 Networks, Inc, All rights reserved.
* This software is not subject to any license of F5 Networks.
* This is free software; you can redistribute and use it
* under the same terms as OpenLDAP itself.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by Jeff Costlow (F5 Networks)
* based, in part, on existing LDAP tools and adapted for inclusion
* into OpenLDAP Software by Kurt D. Zeilenga.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include <ac/errno.h>
#include <ac/socket.h>
#include <ac/time.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 "lutil.h"
#include "lutil_ldap.h"
#include "ldap_defaults.h"
#include "common.h"
static int quiet = 0;
void
usage( void )
{
fprintf( stderr, _("usage: %s [options] DN <attr:value|attr::b64value>\n"), prog);
fprintf( stderr, _("where:\n"));
fprintf( stderr, _(" DN\tDistinguished Name\n"));
fprintf( stderr, _(" attr\tassertion attribute\n"));
fprintf( stderr, _(" value\tassertion value\n"));
fprintf( stderr, _(" b64value\tbase64 encoding of assertion value\n"));
fprintf( stderr, _("Compare options:\n"));
fprintf( stderr, _(" -E [!]<ext>[=<extparam>] compare extensions (! indicates criticality)\n"));
fprintf( stderr, _(" !dontUseCopy (Don't Use Copy)\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
fprintf( stderr, _(" -z Quiet mode,"
" don't print anything, use return values\n"));
tool_common_usage();
exit( EXIT_FAILURE );
}
static int docompare LDAP_P((
LDAP *ld,
char *dn,
char *attr,
struct berval *bvalue,
int quiet,
LDAPControl **sctrls,
LDAPControl **cctrls));
const char options[] = "z"
"Cd:D:e:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
#ifdef LDAP_CONTROL_DONTUSECOPY
int dontUseCopy = 0;
#endif
int
handle_private_option( int i )
{
char *control, *cvalue;
int crit;
switch ( i ) {
case 'E': /* compare extensions */
if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
prog, protocol );
exit( EXIT_FAILURE );
}
/* should be extended to support comma separated list of
* [!]key[=value] parameters, e.g. -E !foo,bar=567
*/
crit = 0;
cvalue = NULL;
if( optarg[0] == '!' ) {
crit = 1;
optarg++;
}
control = ber_strdup( optarg );
if ( (cvalue = strchr( control, '=' )) != NULL ) {
*cvalue++ = '\0';
}
#ifdef LDAP_CONTROL_DONTUSECOPY
if ( strcasecmp( control, "dontUseCopy" ) == 0 ) {
if( dontUseCopy ) {
fprintf( stderr,
_("dontUseCopy control previously specified\n"));
exit( EXIT_FAILURE );
}
if( cvalue != NULL ) {
fprintf( stderr,
_("dontUseCopy: no control value expected\n") );
usage();
}
if( !crit ) {
fprintf( stderr,
_("dontUseCopy: critical flag required\n") );
usage();
}
dontUseCopy = 1 + crit;
} else
#endif
{
fprintf( stderr,
_("Invalid compare extension name: %s\n"), control );
usage();
}
break;
case 'z':
quiet = 1;
break;
default:
return 0;
}
return 1;
}
int
main( int argc, char **argv )
{
char *compdn = NULL, *attrs = NULL;
char *sep;
int rc;
LDAP *ld = NULL;
struct berval bvalue = { 0, NULL };
int i = 0;
LDAPControl c[1];
tool_init( TOOL_COMPARE );
prog = lutil_progname( "ldapcompare", argc, argv );
tool_args( argc, argv );
if ( argc - optind != 2 ) {
usage();
}
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();
}
*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],
(unsigned char *) bvalue.bv_val, strlen( &sep[1] ));
if (bvalue.bv_len == (ber_len_t)-1) {
fprintf(stderr, _("base64 decode error\n"));
exit(-1);
}
}
ld = tool_conn_setup( 0, 0 );
tool_bind( ld );
if ( 0
#ifdef LDAP_CONTROL_DONTUSECOPY
|| dontUseCopy
#endif
)
{
#ifdef LDAP_CONTROL_DONTUSECOPY
if ( dontUseCopy ) {
c[i].ldctl_oid = LDAP_CONTROL_DONTUSECOPY;
c[i].ldctl_value.bv_val = NULL;
c[i].ldctl_value.bv_len = 0;
c[i].ldctl_iscritical = dontUseCopy > 1;
i++;
}
#endif
}
tool_server_controls( ld, c, i );
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 );
tool_exit( ld, rc );
}
static int docompare(
LDAP *ld,
char *dn,
char *attr,
struct berval *bvalue,
int quiet,
LDAPControl **sctrls,
LDAPControl **cctrls )
{
int rc, msgid, code;
LDAPMessage *res;
char *matcheddn;
char *text;
char **refs;
LDAPControl **ctrls = NULL;
if ( dont ) {
return LDAP_SUCCESS;
}
rc = ldap_compare_ext( ld, dn, attr, bvalue,
sctrls, cctrls, &msgid );
if ( rc == -1 ) {
return( rc );
}
for ( ; ; ) {
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 100000;
if ( tool_check_abandon( ld, msgid ) ) {
return LDAP_CANCELLED;
}
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
if ( rc < 0 ) {
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
return rc;
}
if ( rc != 0 ) {
break;
}
}
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, &ctrls, 1 );
if( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: ldap_parse_result: %s (%d)\n",
prog, ldap_err2string( rc ), rc );
return rc;
}
if ( !quiet && ( verbose || ( code != LDAP_SUCCESS && code != LDAP_COMPARE_TRUE && code != LDAP_COMPARE_FALSE )||
(matcheddn && *matcheddn) || (text && *text) || (refs && *refs) ) )
{
printf( _("Compare 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] );
}
}
}
/* if we were told to be quiet, use the return value. */
if ( !quiet ) {
if ( code == LDAP_COMPARE_TRUE ) {
printf(_("TRUE\n"));
} else if ( code == LDAP_COMPARE_FALSE ) {
printf(_("FALSE\n"));
} else {
printf(_("UNDEFINED\n"));
}
}
if ( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );
return( code );
}
/* ldapdelete.c - simple program to delete an entry using LDAP */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by the University of Michigan
* (as part of U-MICH LDAP). Additional significant contributors
* include:
* Kurt D. Zeilenga
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include <ac/socket.h>
#include <ac/time.h>
#include <ldap.h>
#include "lutil.h"
#include "lutil_ldap.h"
#include "ldap_defaults.h"
#include "common.h"
static int prune = 0;
static int sizelimit = -1;
static int dodelete LDAP_P((
LDAP *ld,
const char *dn));
static int deletechildren LDAP_P((
LDAP *ld,
const char *dn,
int subentries ));
void
usage( void )
{
fprintf( stderr, _("Delete entries from an LDAP server\n\n"));
fprintf( stderr, _("usage: %s [options] [dn]...\n"), prog);
fprintf( stderr, _(" dn: list of DNs to delete. If not given, it will be readed from stdin\n"));
fprintf( stderr, _(" or from the file specified with \"-f file\".\n"));
fprintf( stderr, _("Delete Options:\n"));
fprintf( stderr, _(" -c continuous operation mode (do not stop on errors)\n"));
fprintf( stderr, _(" -f file read operations from `file'\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
fprintf( stderr, _(" -r delete recursively\n"));
tool_common_usage();
exit( EXIT_FAILURE );
}
const char options[] = "r"
"cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:z:Z";
int
handle_private_option( int i )
{
int ival;
char *next;
switch ( i ) {
#if 0
int crit;
char *control, *cvalue;
case 'E': /* delete extensions */
if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
prog, protocol );
exit( EXIT_FAILURE );
}
/* should be extended to support comma separated list of
* [!]key[=value] parameters, e.g. -E !foo,bar=567
*/
crit = 0;
cvalue = NULL;
if( optarg[0] == '!' ) {
crit = 1;
optarg++;
}
control = strdup( optarg );
if ( (cvalue = strchr( control, '=' )) != NULL ) {
*cvalue++ = '\0';
}
fprintf( stderr, _("Invalid delete extension name: %s\n"), control );
usage();
#endif
case 'r':
prune = 1;
break;
case 'z': /* size limit */
if ( strcasecmp( optarg, "none" ) == 0 ) {
sizelimit = 0;
} else if ( strcasecmp( optarg, "max" ) == 0 ) {
sizelimit = LDAP_MAXINT;
} else {
ival = strtol( optarg, &next, 10 );
if ( next == NULL || next[0] != '\0' ) {
fprintf( stderr,
_("Unable to parse size limit \"%s\"\n"), optarg );
exit( EXIT_FAILURE );
}
sizelimit = ival;
}
if( sizelimit < 0 || sizelimit > LDAP_MAXINT ) {
fprintf( stderr, _("%s: invalid sizelimit (%d) specified\n"),
prog, sizelimit );
exit( EXIT_FAILURE );
}
break;
default:
return 0;
}
return 1;
}
static void
private_conn_setup( LDAP *ld )
{
/* this seems prudent for searches below */
int deref = LDAP_DEREF_NEVER;
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
}
int
main( int argc, char **argv )
{
char buf[ 4096 ];
FILE *fp = NULL;
LDAP *ld;
int rc, retval;
tool_init( TOOL_DELETE );
prog = lutil_progname( "ldapdelete", argc, argv );
tool_args( argc, argv );
if ( infile != NULL ) {
if (( fp = fopen( infile, "r" )) == NULL ) {
perror( optarg );
exit( EXIT_FAILURE );
}
} else {
if ( optind >= argc ) {
fp = stdin;
}
}
ld = tool_conn_setup( 0, &private_conn_setup );
tool_bind( ld );
tool_server_controls( ld, NULL, 0 );
retval = rc = 0;
if ( fp == NULL ) {
for ( ; optind < argc; ++optind ) {
rc = dodelete( ld, argv[ optind ] );
/* Stop on error and no -c option */
if( rc != 0 ) {
retval = rc;
if( 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 );
if ( rc != 0 )
retval = rc;
}
}
if ( fp != stdin )
fclose( fp );
}
tool_exit( ld, retval );
}
static int dodelete(
LDAP *ld,
const char *dn)
{
int id;
int rc, code;
char *matcheddn = NULL, *text = NULL, **refs = NULL;
LDAPControl **ctrls = NULL;
LDAPMessage *res;
int subentries = 0;
if ( verbose ) {
printf( _("%sdeleting entry \"%s\"\n"),
(dont ? "!" : ""), dn );
}
if ( dont ) {
return LDAP_SUCCESS;
}
/* If prune is on, remove a whole subtree. Delete the children of the
* DN recursively, then the DN requested.
*/
if ( prune ) {
retry:;
deletechildren( ld, dn, subentries );
}
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;
}
for ( ; ; ) {
struct timeval tv;
if ( tool_check_abandon( ld, id ) ) {
return LDAP_CANCELLED;
}
tv.tv_sec = 0;
tv.tv_usec = 100000;
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
if ( rc < 0 ) {
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
return rc;
}
if ( rc != 0 ) {
break;
}
}
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, &ctrls, 1 );
switch ( rc ) {
case LDAP_SUCCESS:
break;
case LDAP_NOT_ALLOWED_ON_NONLEAF:
if ( prune && !subentries ) {
subentries = 1;
goto retry;
}
/* fallthru */
default:
fprintf( stderr, "%s: ldap_parse_result: %s (%d)\n",
prog, ldap_err2string( rc ), rc );
return rc;
}
if( code != LDAP_SUCCESS ) {
tool_perror( "ldap_delete", code, NULL, matcheddn, text, refs );
} else if ( verbose &&
((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] );
}
}
}
if (ctrls) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
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 *base,
int subentries )
{
LDAPMessage *res, *e;
int entries;
int rc = LDAP_SUCCESS, srch_rc;
static char *attrs[] = { LDAP_NO_ATTRS, NULL };
LDAPControl c, *ctrls[2], **ctrlsp = NULL;
BerElement *ber = NULL;
if ( verbose ) printf ( _("deleting children of: %s\n"), base );
if ( subentries ) {
/*
* Do a one level search at base for subentry children.
*/
if ((ber = ber_alloc_t(LBER_USE_DER)) == NULL) {
return EXIT_FAILURE;
}
rc = ber_printf( ber, "b", 1 );
if ( rc == -1 ) {
ber_free( ber, 1 );
fprintf( stderr, _("Subentries control encoding error!\n"));
return EXIT_FAILURE;
}
if ( ber_flatten2( ber, &c.ldctl_value, 0 ) == -1 ) {
return EXIT_FAILURE;
}
c.ldctl_oid = LDAP_CONTROL_SUBENTRIES;
c.ldctl_iscritical = 1;
ctrls[0] = &c;
ctrls[1] = NULL;
ctrlsp = ctrls;
}
/*
* Do a one level search at base for children. For each, delete its children.
*/
more:;
srch_rc = ldap_search_ext_s( ld, base, LDAP_SCOPE_ONELEVEL, NULL, attrs, 1,
ctrlsp, NULL, NULL, sizelimit, &res );
switch ( srch_rc ) {
case LDAP_SUCCESS:
case LDAP_SIZELIMIT_EXCEEDED:
break;
default:
tool_perror( "ldap_search", srch_rc, NULL, NULL, NULL, NULL );
return( srch_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_get_option( ld, LDAP_OPT_RESULT_CODE, &rc );
tool_perror( "ldap_prune", rc, NULL, NULL, NULL, NULL );
ber_memfree( dn );
return rc;
}
rc = deletechildren( ld, dn, 0 );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_prune", rc, NULL, NULL, NULL, NULL );
ber_memfree( dn );
return rc;
}
if ( verbose ) {
printf( _("\tremoving %s\n"), dn );
}
rc = ldap_delete_ext_s( ld, dn, NULL, NULL );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_delete", rc, NULL, NULL, NULL, NULL );
ber_memfree( dn );
return rc;
}
if ( verbose ) {
printf( _("\t%s removed\n"), dn );
}
ber_memfree( dn );
}
}
ldap_msgfree( res );
if ( srch_rc == LDAP_SIZELIMIT_EXCEEDED ) {
goto more;
}
return rc;
}
/* ldapexop.c -- a tool for performing well-known extended operations */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 2005-2020 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by Pierangelo Masarati for inclusion
* in OpenLDAP Software based, in part, on other client tools.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ldap.h>
#include "ldif.h"
#include "lutil.h"
#include "lutil_ldap.h"
#include "ldap_defaults.h"
#include "common.h"
void
usage( void )
{
fprintf( stderr, _("Issue LDAP extended operations\n\n"));
fprintf( stderr, _("usage: %s [options] <oid|oid:data|oid::b64data>\n"), prog);
fprintf( stderr, _(" %s [options] whoami\n"), prog);
fprintf( stderr, _(" %s [options] cancel <id>\n"), prog);
fprintf( stderr, _(" %s [options] refresh <DN> [<ttl>]\n"), prog);
tool_common_usage();
exit( EXIT_FAILURE );
}
const char options[] = ""
"d:D:e:h:H:InNO:o:p:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
{
switch ( i ) {
default:
return 0;
}
return 1;
}
int
main( int argc, char *argv[] )
{
int rc;
LDAP *ld = NULL;
char *matcheddn = NULL, *text = NULL, **refs = NULL;
LDAPControl **ctrls = NULL;
int id, code;
LDAPMessage *res = NULL;
tool_init( TOOL_EXOP );
prog = lutil_progname( "ldapexop", argc, argv );
/* LDAPv3 only */
protocol = LDAP_VERSION3;
tool_args( argc, argv );
if ( argc - optind < 1 ) {
usage();
}
ld = tool_conn_setup( 0, 0 );
tool_bind( ld );
argv += optind;
argc -= optind;
if ( strcasecmp( argv[ 0 ], "whoami" ) == 0 ) {
tool_server_controls( ld, NULL, 0 );
rc = ldap_whoami( ld, NULL, NULL, &id );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_extended_operation", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
} else if ( strcasecmp( argv[ 0 ], "cancel" ) == 0 ) {
int cancelid;
switch ( argc ) {
case 2:
if ( lutil_atoi( &cancelid, argv[ 1 ] ) != 0 || cancelid < 0 ) {
fprintf( stderr, "invalid cancelid=%s\n\n", argv[ 1 ] );
usage();
}
break;
default:
fprintf( stderr, "need cancelid\n\n" );
usage();
}
rc = ldap_cancel( ld, cancelid, NULL, NULL, &id );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_cancel", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
} else if ( strcasecmp( argv[ 0 ], "passwd" ) == 0 ) {
fprintf( stderr, "use ldappasswd(1) instead.\n\n" );
usage();
/* TODO? */
} else if ( strcasecmp( argv[ 0 ], "refresh" ) == 0 ) {
int ttl = 3600;
struct berval dn;
switch ( argc ) {
case 3:
ttl = atoi( argv[ 2 ] );
case 2:
dn.bv_val = argv[ 1 ];
dn.bv_len = strlen( dn.bv_val );
break;
default:
fprintf( stderr, _("need DN [ttl]\n\n") );
usage();
}
tool_server_controls( ld, NULL, 0 );
rc = ldap_refresh( ld, &dn, ttl, NULL, NULL, &id );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_extended_operation", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
} else {
char *p;
if ( argc != 1 ) {
usage();
}
p = strchr( argv[ 0 ], ':' );
if ( p == argv[ 0 ] ) {
usage();
}
if ( p != NULL )
*p++ = '\0';
if ( tool_is_oid( argv[ 0 ] ) ) {
struct berval reqdata;
struct berval type;
struct berval value;
int freeval;
if ( p != NULL ) {
p[ -1 ] = ':';
ldif_parse_line2( argv[ 0 ], &type, &value, &freeval );
p[ -1 ] = '\0';
if ( freeval ) {
reqdata = value;
} else {
ber_dupbv( &reqdata, &value );
}
}
tool_server_controls( ld, NULL, 0 );
rc = ldap_extended_operation( ld, argv[ 0 ], p ? &reqdata : NULL, NULL, NULL, &id );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_extended_operation", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
} else {
fprintf( stderr, "unknown exop \"%s\"\n\n", argv[ 0 ] );
usage();
}
}
for ( ; ; ) {
struct timeval tv;
if ( tool_check_abandon( ld, id ) ) {
tool_exit( ld, LDAP_CANCELLED );
}
tv.tv_sec = 0;
tv.tv_usec = 100000;
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
if ( rc < 0 ) {
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
if ( rc != 0 ) {
break;
}
}
rc = ldap_parse_result( ld, res,
&code, &matcheddn, &text, &refs, &ctrls, 0 );
if ( rc == LDAP_SUCCESS ) {
rc = code;
}
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_result", rc, NULL, matcheddn, text, refs );
rc = EXIT_FAILURE;
goto skip;
}
if ( strcasecmp( argv[ 0 ], "whoami" ) == 0 ) {
char *retoid = NULL;
struct berval *retdata = NULL;
rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 0 );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
if ( retdata != NULL ) {
if ( retdata->bv_len == 0 ) {
printf(_("anonymous\n") );
} else {
printf("%s\n", retdata->bv_val );
}
}
ber_memfree( retoid );
ber_bvfree( retdata );
} else if ( strcasecmp( argv[ 0 ], "cancel" ) == 0 ) {
/* no extended response; returns specific errors */
assert( 0 );
} else if ( strcasecmp( argv[ 0 ], "passwd" ) == 0 ) {
/* TODO */
} else if ( strcasecmp( argv[ 0 ], "refresh" ) == 0 ) {
int newttl;
rc = ldap_parse_refresh( ld, res, &newttl );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_refresh", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
printf( "newttl=%d\n", newttl );
} else if ( tool_is_oid( argv[ 0 ] ) ) {
char *retoid = NULL;
struct berval *retdata = NULL;
if( ldif < 2 ) {
printf(_("# extended operation response\n"));
}
rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 0 );
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
if ( ldif < 2 && retoid != NULL ) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"oid", retoid, strlen(retoid) );
}
ber_memfree( retoid );
if( retdata != NULL ) {
if ( ldif < 2 ) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_BINARY,
"data", retdata->bv_val, retdata->bv_len );
}
ber_bvfree( retdata );
}
}
if( verbose || code != LDAP_SUCCESS ||
( matcheddn && *matcheddn ) || ( text && *text ) || refs ) {
printf( _("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] );
}
}
}
if (ctrls) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );
skip:
/* disconnect from server */
if ( res )
ldap_msgfree( res );
tool_exit( ld, code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE );
}
/* ldapmodify.c - generic program to modify or add entries using LDAP */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* Portions Copyright 2006 Howard Chu.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by the University of Michigan
* (as part of U-MICH LDAP). Additional significant contributors
* include:
* Kurt D. Zeilenga
* Norbert Klasen
* Howard Chu
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include <ac/socket.h>
#include <ac/time.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <ldap.h>
#include "lutil.h"
#include "lutil_ldap.h"
#include "ldif.h"
#include "ldap_defaults.h"
#include "ldap_pvt.h"
#include "lber_pvt.h"
#include "common.h"
static int ldapadd;
static char *rejfile = NULL;
static LDAP *ld = NULL;
#define M_SEP 0x7f
/* strings found in LDIF entries */
static struct berval BV_VERSION = BER_BVC("version");
static struct berval BV_DN = BER_BVC("dn");
static struct berval BV_CONTROL = BER_BVC("control");
static struct berval BV_CHANGETYPE = BER_BVC("changetype");
static struct berval BV_ADDCT = BER_BVC("add");
static struct berval BV_MODIFYCT = BER_BVC("modify");
static struct berval BV_DELETECT = BER_BVC("delete");
static struct berval BV_MODRDNCT = BER_BVC("modrdn");
static struct berval BV_MODDNCT = BER_BVC("moddn");
static struct berval BV_RENAMECT = BER_BVC("rename");
static struct berval BV_MODOPADD = BER_BVC("add");
static struct berval BV_MODOPREPLACE = BER_BVC("replace");
static struct berval BV_MODOPDELETE = BER_BVC("delete");
static struct berval BV_MODOPINCREMENT = BER_BVC("increment");
static struct berval BV_NEWRDN = BER_BVC("newrdn");
static struct berval BV_DELETEOLDRDN = BER_BVC("deleteoldrdn");
static struct berval BV_NEWSUP = BER_BVC("newsuperior");
#define BV_CASEMATCH(a, b) \
((a)->bv_len == (b)->bv_len && 0 == strcasecmp((a)->bv_val, (b)->bv_val))
static int process_ldif_rec LDAP_P(( char *rbuf, unsigned long lineno ));
static int parse_ldif_control LDAP_P(( struct berval *val, LDAPControl ***pctrls ));
static int domodify LDAP_P((
const char *dn,
LDAPMod **pmods,
LDAPControl **pctrls,
int newentry ));
static int dodelete LDAP_P((
const char *dn,
LDAPControl **pctrls ));
static int dorename LDAP_P((
const char *dn,
const char *newrdn,
const char *newsup,
int deleteoldrdn,
LDAPControl **pctrls ));
static int process_response(
LDAP *ld,
int msgid,
int res,
const char *dn );
#ifdef LDAP_X_TXN
static int txn = 0;
static int txnabort = 0;
struct berval *txn_id = NULL;
#endif
void
usage( void )
{
fprintf( stderr, _("Add or modify entries from an LDAP server\n\n"));
fprintf( stderr, _("usage: %s [options]\n"), prog);
fprintf( stderr, _(" The list of desired operations are read from stdin"
" or from the file\n"));
fprintf( stderr, _(" specified by \"-f file\".\n"));
fprintf( stderr, _("Add or modify options:\n"));
fprintf( stderr, _(" -a add values (%s)\n"),
(ldapadd ? _("default") : _("default is to replace")));
fprintf( stderr, _(" -c continuous operation mode (do not stop on errors)\n"));
fprintf( stderr, _(" -E [!]ext=extparam modify extensions"
" (! indicate s criticality)\n"));
fprintf( stderr, _(" -f file read operations from `file'\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
#ifdef LDAP_X_TXN
fprintf( stderr,
_(" [!]txn=<commit|abort> (transaction)\n"));
#endif
fprintf( stderr, _(" -S file write skipped modifications to `file'\n"));
tool_common_usage();
exit( EXIT_FAILURE );
}
const char options[] = "aE:rS:"
"cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
{
char *control, *cvalue;
int crit;
switch ( i ) {
case 'E': /* modify extensions */
if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
prog, protocol );
exit( EXIT_FAILURE );
}
/* should be extended to support comma separated list of
* [!]key[=value] parameters, e.g. -E !foo,bar=567
*/
crit = 0;
cvalue = NULL;
if( optarg[0] == '!' ) {
crit = 1;
optarg++;
}
control = ber_strdup( optarg );
if ( (cvalue = strchr( control, '=' )) != NULL ) {
*cvalue++ = '\0';
}
#ifdef LDAP_X_TXN
if( strcasecmp( control, "txn" ) == 0 ) {
/* Transaction */
if( txn ) {
fprintf( stderr,
_("txn control previously specified\n"));
exit( EXIT_FAILURE );
}
if( cvalue != NULL ) {
if( strcasecmp( cvalue, "abort" ) == 0 ) {
txnabort=1;
} else if( strcasecmp( cvalue, "commit" ) != 0 ) {
fprintf( stderr, _("Invalid value for txn control, %s\n"),
cvalue );
exit( EXIT_FAILURE );
}
}
txn = 1 + crit;
} else
#endif
{
fprintf( stderr, _("Invalid modify extension name: %s\n"),
control );
usage();
}
break;
case 'a': /* add */
ldapadd = 1;
break;
case 'r': /* replace (obsolete) */
break;
case 'S': /* skipped modifications to file */
if( rejfile != NULL ) {
fprintf( stderr, _("%s: -S previously specified\n"), prog );
exit( EXIT_FAILURE );
}
rejfile = ber_strdup( optarg );
break;
default:
return 0;
}
return 1;
}
int
main( int argc, char **argv )
{
char *rbuf = NULL, *rejbuf = NULL;
FILE *rejfp;
struct LDIFFP *ldiffp = NULL, ldifdummy = {0};
char *matched_msg, *error_msg;
int rc, retval, ldifrc;
int len;
int i = 0, lmax = 0;
unsigned long lineno, nextline = 0;
LDAPControl c[1];
prog = lutil_progname( "ldapmodify", argc, argv );
/* strncmp instead of strcmp since NT binaries carry .exe extension */
ldapadd = ( strncasecmp( prog, "ldapadd", sizeof("ldapadd")-1 ) == 0 );
tool_init( ldapadd ? TOOL_ADD : TOOL_MODIFY );
tool_args( argc, argv );
if ( argc != optind ) usage();
if ( rejfile != NULL ) {
if (( rejfp = fopen( rejfile, "w" )) == NULL ) {
perror( rejfile );
retval = EXIT_FAILURE;
goto fail;
}
} else {
rejfp = NULL;
}
if ( infile != NULL ) {
if (( ldiffp = ldif_open( infile, "r" )) == NULL ) {
perror( infile );
retval = EXIT_FAILURE;
goto fail;
}
} else {
ldifdummy.fp = stdin;
ldiffp = &ldifdummy;
}
if ( debug ) ldif_debug = debug;
ld = tool_conn_setup( dont, 0 );
if ( !dont ) {
tool_bind( ld );
}
#ifdef LDAP_X_TXN
if( txn ) {
/* start transaction */
rc = ldap_txn_start_s( ld, NULL, NULL, &txn_id );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_txn_start_s", rc, NULL, NULL, NULL, NULL );
if( txn > 1 ) {
retval = EXIT_FAILURE;
goto fail;
}
txn = 0;
}
}
#endif
if ( 0
#ifdef LDAP_X_TXN
|| txn
#endif
)
{
#ifdef LDAP_X_TXN
if( txn ) {
c[i].ldctl_oid = LDAP_CONTROL_X_TXN_SPEC;
c[i].ldctl_value = *txn_id;
c[i].ldctl_iscritical = 1;
i++;
}
#endif
}
tool_server_controls( ld, c, i );
rc = 0;
retval = 0;
lineno = 1;
while (( rc == 0 || contoper ) && ( ldifrc = ldif_read_record( ldiffp, &nextline,
&rbuf, &lmax )) > 0 )
{
if ( rejfp ) {
len = strlen( rbuf );
if (( rejbuf = (char *)ber_memalloc( len+1 )) == NULL ) {
perror( "malloc" );
retval = EXIT_FAILURE;
goto fail;
}
memcpy( rejbuf, rbuf, len+1 );
}
rc = process_ldif_rec( rbuf, lineno );
lineno = nextline+1;
if ( rc ) retval = rc;
if ( rc && rejfp ) {
fprintf(rejfp, _("# Error: %s (%d)"), ldap_err2string(rc), rc);
matched_msg = NULL;
ldap_get_option(ld, LDAP_OPT_MATCHED_DN, &matched_msg);
if ( matched_msg != NULL ) {
if ( *matched_msg != '\0' ) {
fprintf( rejfp, _(", matched DN: %s"), matched_msg );
}
ldap_memfree( matched_msg );
}
error_msg = NULL;
ldap_get_option(ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, &error_msg);
if ( error_msg != NULL ) {
if ( *error_msg != '\0' ) {
fprintf( rejfp, _(", additional info: %s"), error_msg );
}
ldap_memfree( error_msg );
}
fprintf( rejfp, "\n%s\n", rejbuf );
}
if (rejfp) ber_memfree( rejbuf );
}
ber_memfree( rbuf );
if ( ldifrc < 0 )
retval = LDAP_OTHER;
#ifdef LDAP_X_TXN
if( retval == 0 && txn ) {
rc = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, NULL );
if ( rc != LDAP_OPT_SUCCESS ) {
fprintf( stderr, "Could not unset controls for ldap_txn_end\n");
}
/* create transaction */
rc = ldap_txn_end_s( ld, !txnabort, txn_id, NULL, NULL, NULL );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_txn_end_s", rc, NULL, NULL, NULL, NULL );
retval = rc;
}
}
#endif
fail:;
if ( rejfp != NULL ) {
fclose( rejfp );
}
if ( ldiffp != NULL && ldiffp != &ldifdummy ) {
ldif_close( ldiffp );
}
tool_exit( ld, retval );
}
static int
process_ldif_rec( char *rbuf, unsigned long linenum )
{
char *line, *dn, *newrdn, *newsup;
int rc, modop;
int expect_modop, expect_sep;
int deleteoldrdn;
int new_entry, delete_entry, got_all;
LDAPMod **pmods, *lm = NULL;
int version;
LDAPControl **pctrls;
int i, j, k, lines, idn, nmods;
struct berval *btype, *vals, **bvl, bv;
char *freeval;
unsigned char *mops = NULL;
new_entry = ldapadd;
rc = got_all = delete_entry = modop = expect_modop = 0;
expect_sep = 0;
version = 0;
deleteoldrdn = 1;
pmods = NULL;
pctrls = NULL;
dn = newrdn = newsup = NULL;
lines = ldif_countlines( rbuf );
btype = ber_memcalloc( 1, (lines+1)*2*sizeof(struct berval)+lines );
if ( !btype )
return LDAP_NO_MEMORY;
vals = btype+lines+1;
freeval = (char *)(vals+lines+1);
i = -1;
while ( rc == 0 && ( line = ldif_getline( &rbuf )) != NULL ) {
int freev;
if ( *line == '\n' || *line == '\0' ) {
break;
}
++i;
if ( line[0] == '-' && !line[1] ) {
BER_BVZERO( btype+i );
freeval[i] = 0;
continue;
}
if ( ( rc = ldif_parse_line2( line, btype+i, vals+i, &freev ) ) < 0 ) {
fprintf( stderr, _("%s: invalid format (line %lu) entry: \"%s\"\n"),
prog, linenum+i, dn == NULL ? "" : dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
freeval[i] = freev;
if ( dn == NULL ) {
if ( linenum+i == 1 && BV_CASEMATCH( btype+i, &BV_VERSION )) {
int v;
if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) {
fprintf( stderr,
_("%s: invalid version %s, line %lu (ignored)\n"),
prog, vals[i].bv_val, linenum );
}
version++;
} else if ( BV_CASEMATCH( btype+i, &BV_DN )) {
dn = vals[i].bv_val;
idn = i;
}
/* skip all lines until we see "dn:" */
}
}
/* check to make sure there was a dn: line */
if ( !dn ) {
rc = 0;
goto leave;
}
lines = i+1;
if( lines == 0 ) {
rc = 0;
goto leave;
}
if( version && lines == 1 ) {
rc = 0;
goto leave;
}
i = idn+1;
/* Check for "control" tag after dn and before changetype. */
if ( BV_CASEMATCH( btype+i, &BV_CONTROL )) {
/* Parse and add it to the list of controls */
rc = parse_ldif_control( vals+i, &pctrls );
if (rc != 0) {
fprintf( stderr,
_("%s: Error processing %s line, line %lu: %s\n"),
prog, BV_CONTROL.bv_val, linenum+i, ldap_err2string(rc) );
}
i++;
if ( i>= lines ) {
short_input:
fprintf( stderr,
_("%s: Expecting more input after %s line, line %lu\n"),
prog, btype[i-1].bv_val, linenum+i );
rc = LDAP_PARAM_ERROR;
goto leave;
}
}
/* Check for changetype */
if ( BV_CASEMATCH( btype+i, &BV_CHANGETYPE )) {
#ifdef LIBERAL_CHANGETYPE_MODOP
/* trim trailing spaces (and log warning ...) */
int icnt;
for ( icnt = vals[i].bv_len; --icnt > 0; ) {
if ( !isspace( (unsigned char) vals[i].bv_val[icnt] ) ) {
break;
}
}
if ( ++icnt != vals[i].bv_len ) {
fprintf( stderr, _("%s: illegal trailing space after"
" \"%s: %s\" trimmed (line %lu, entry \"%s\")\n"),
prog, BV_CHANGETYPE.bv_val, vals[i].bv_val, linenum+i, dn );
vals[i].bv_val[icnt] = '\0';
}
#endif /* LIBERAL_CHANGETYPE_MODOP */
if ( BV_CASEMATCH( vals+i, &BV_MODIFYCT )) {
new_entry = 0;
expect_modop = 1;
} else if ( BV_CASEMATCH( vals+i, &BV_ADDCT )) {
new_entry = 1;
modop = LDAP_MOD_ADD;
} else if ( BV_CASEMATCH( vals+i, &BV_MODRDNCT )
|| BV_CASEMATCH( vals+i, &BV_MODDNCT )
|| BV_CASEMATCH( vals+i, &BV_RENAMECT ))
{
i++;
if ( i >= lines )
goto short_input;
if ( !BV_CASEMATCH( btype+i, &BV_NEWRDN )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %lu, entry \"%s\")\n"),
prog, BV_NEWRDN.bv_val, btype[i].bv_val, linenum+i, dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
newrdn = vals[i].bv_val;
i++;
if ( i >= lines )
goto short_input;
if ( !BV_CASEMATCH( btype+i, &BV_DELETEOLDRDN )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %lu, entry \"%s\")\n"),
prog, BV_DELETEOLDRDN.bv_val, btype[i].bv_val, linenum+i, dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
deleteoldrdn = ( vals[i].bv_val[0] == '0' ) ? 0 : 1;
i++;
if ( i < lines ) {
if ( !BV_CASEMATCH( btype+i, &BV_NEWSUP )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %lu, entry \"%s\")\n"),
prog, BV_NEWSUP.bv_val, btype[i].bv_val, linenum+i, dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
newsup = vals[i].bv_val;
i++;
}
got_all = 1;
} else if ( BV_CASEMATCH( vals+i, &BV_DELETECT )) {
got_all = delete_entry = 1;
} else {
fprintf( stderr,
_("%s: unknown %s \"%s\" (line %lu, entry \"%s\")\n"),
prog, BV_CHANGETYPE.bv_val, vals[i].bv_val, linenum+i, dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
i++;
} else if ( ldapadd ) { /* missing changetype => add */
new_entry = 1;
modop = LDAP_MOD_ADD;
} else {
expect_modop = 1; /* missing changetype => modify */
}
if ( got_all ) {
if ( i < lines ) {
fprintf( stderr,
_("%s: extra lines at end (line %lu, entry \"%s\")\n"),
prog, linenum+i, dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
goto doit;
}
nmods = lines - i;
idn = i;
if ( new_entry ) {
int fv;
/* Make sure all attributes with multiple values are contiguous */
for (; i<lines; i++) {
for (j=i+1; j<lines; j++) {
if ( !btype[j].bv_val ) {
fprintf( stderr,
_("%s: missing attributeDescription (line %lu, entry \"%s\")\n"),
prog, linenum+j, dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
if ( BV_CASEMATCH( btype+i, btype+j )) {
nmods--;
/* out of order, move intervening attributes down */
if ( j != i+1 ) {
bv = vals[j];
fv = freeval[j];
for (k=j; k>i; k--) {
btype[k] = btype[k-1];
vals[k] = vals[k-1];
freeval[k] = freeval[k-1];
}
k++;
btype[k] = btype[i];
vals[k] = bv;
freeval[k] = fv;
}
i++;
}
}
}
/* Allocate space for array of mods, array of pointers to mods,
* and array of pointers to values, allowing for NULL terminators
* for the pointer arrays...
*/
lm = ber_memalloc( nmods * sizeof(LDAPMod) +
(nmods+1) * sizeof(LDAPMod*) +
(lines + nmods - idn) * sizeof(struct berval *));
pmods = (LDAPMod **)(lm+nmods);
bvl = (struct berval **)(pmods+nmods+1);
j = 0;
k = -1;
BER_BVZERO(&bv);
for (i=idn; i<lines; i++) {
if ( BV_CASEMATCH( btype+i, &BV_DN )) {
fprintf( stderr, _("%s: attributeDescription \"%s\":"
" (possible missing newline"
" after line %lu, entry \"%s\"?)\n"),
prog, btype[i].bv_val, linenum+i - 1, dn );
}
if ( !BV_CASEMATCH( btype+i, &bv )) {
bvl[k++] = NULL;
bv = btype[i];
lm[j].mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES;
lm[j].mod_type = bv.bv_val;
lm[j].mod_bvalues = bvl+k;
pmods[j] = lm+j;
j++;
}
bvl[k++] = vals+i;
}
bvl[k] = NULL;
pmods[j] = NULL;
goto doit;
}
mops = ber_memalloc( lines+1 );
mops[lines] = M_SEP;
mops[i-1] = M_SEP;
for ( ; i<lines; i++ ) {
if ( expect_modop ) {
#ifdef LIBERAL_CHANGETYPE_MODOP
/* trim trailing spaces (and log warning ...) */
int icnt;
for ( icnt = vals[i].bv_len; --icnt > 0; ) {
if ( !isspace( (unsigned char) vals[i].bv_val[icnt] ) ) break;
}
if ( ++icnt != vals[i].bv_len ) {
fprintf( stderr, _("%s: illegal trailing space after"
" \"%s: %s\" trimmed (line %lu, entry \"%s\")\n"),
prog, type, vals[i].bv_val, linenum+i, dn );
vals[i].bv_val[icnt] = '\0';
}
#endif /* LIBERAL_CHANGETYPE_MODOP */
expect_modop = 0;
expect_sep = 1;
if ( BV_CASEMATCH( btype+i, &BV_MODOPADD )) {
modop = LDAP_MOD_ADD;
mops[i] = M_SEP;
nmods--;
} else if ( BV_CASEMATCH( btype+i, &BV_MODOPREPLACE )) {
/* defer handling these since they might have no values.
* Use the BVALUES flag to signal that these were
* deferred. If values are provided later, this
* flag will be switched off.
*/
modop = LDAP_MOD_REPLACE;
mops[i] = modop | LDAP_MOD_BVALUES;
btype[i] = vals[i];
} else if ( BV_CASEMATCH( btype+i, &BV_MODOPDELETE )) {
modop = LDAP_MOD_DELETE;
mops[i] = modop | LDAP_MOD_BVALUES;
btype[i] = vals[i];
} else if ( BV_CASEMATCH( btype+i, &BV_MODOPINCREMENT )) {
modop = LDAP_MOD_INCREMENT;
mops[i] = M_SEP;
nmods--;
} else { /* no modify op: invalid LDIF */
fprintf( stderr, _("%s: modify operation type is missing at"
" line %lu, entry \"%s\"\n"),
prog, linenum+i, dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
bv = vals[i];
} else if ( expect_sep && BER_BVISEMPTY( btype+i )) {
mops[i] = M_SEP;
expect_sep = 0;
expect_modop = 1;
nmods--;
} else {
if ( !BV_CASEMATCH( btype+i, &bv )) {
fprintf( stderr, _("%s: wrong attributeType at"
" line %lu, entry \"%s\"\n"),
prog, linenum+i, dn );
rc = LDAP_PARAM_ERROR;
goto leave;
}
mops[i] = modop;
/* If prev op was deferred and matches this type,
* clear the flag
*/
if ( (mops[i-1] & LDAP_MOD_BVALUES)
&& BV_CASEMATCH( btype+i, btype+i-1 ))
{
mops[i-1] = M_SEP;
nmods--;
}
}
}
#if 0 /* we should faithfully encode the LDIF, not combine */
/* Make sure all modops with multiple values are contiguous */
for (i=idn; i<lines; i++) {
if ( mops[i] == M_SEP )
continue;
for (j=i+1; j<lines; j++) {
if ( mops[j] == M_SEP || mops[i] != mops[j] )
continue;
if ( BV_CASEMATCH( btype+i, btype+j )) {
nmods--;
/* out of order, move intervening attributes down */
if ( j != i+1 ) {
int c;
struct berval bv;
char fv;
c = mops[j];
bv = vals[j];
fv = freeval[j];
for (k=j; k>i; k--) {
btype[k] = btype[k-1];
vals[k] = vals[k-1];
freeval[k] = freeval[k-1];
mops[k] = mops[k-1];
}
k++;
btype[k] = btype[i];
vals[k] = bv;
freeval[k] = fv;
mops[k] = c;
}
i++;
}
}
}
#endif
/* Allocate space for array of mods, array of pointers to mods,
* and array of pointers to values, allowing for NULL terminators
* for the pointer arrays...
*/
lm = ber_memalloc( nmods * sizeof(LDAPMod) +
(nmods+1) * sizeof(LDAPMod*) +
(lines + nmods - idn) * sizeof(struct berval *));
pmods = (LDAPMod **)(lm+nmods);
bvl = (struct berval **)(pmods+nmods+1);
j = 0;
k = -1;
BER_BVZERO(&bv);
mops[idn-1] = M_SEP;
for (i=idn; i<lines; i++) {
if ( mops[i] == M_SEP )
continue;
if ( mops[i] != mops[i-1] || !BV_CASEMATCH( btype+i, &bv )) {
bvl[k++] = NULL;
bv = btype[i];
lm[j].mod_op = mops[i] | LDAP_MOD_BVALUES;
lm[j].mod_type = bv.bv_val;
if ( mops[i] & LDAP_MOD_BVALUES ) {
lm[j].mod_bvalues = NULL;
} else {
lm[j].mod_bvalues = bvl+k;
}
pmods[j] = lm+j;
j++;
}
bvl[k++] = vals+i;
}
bvl[k] = NULL;
pmods[j] = NULL;
doit:
/* If default controls are set (as with -M option) and controls are
specified in the LDIF file, we must add the default controls to
the list of controls sent with the ldap operation.
*/
if ( rc == 0 ) {
if (pctrls) {
LDAPControl **defctrls = NULL; /* Default server controls */
LDAPControl **newctrls = NULL;
ldap_get_option(ld, LDAP_OPT_SERVER_CONTROLS, &defctrls);
if (defctrls) {
int npc=0; /* Num of LDIF controls */
int ndefc=0; /* Num of default controls */
while (pctrls[npc]) npc++; /* Count LDIF controls */
while (defctrls[ndefc]) ndefc++; /* Count default controls */
newctrls = ber_memrealloc(pctrls,
(npc+ndefc+1)*sizeof(LDAPControl*));
if (newctrls == NULL) {
rc = LDAP_NO_MEMORY;
} else {
int i;
pctrls = newctrls;
for (i=npc; i<npc+ndefc; i++) {
pctrls[i] = ldap_control_dup(defctrls[i-npc]);
if (pctrls[i] == NULL) {
rc = LDAP_NO_MEMORY;
break;
}
}
pctrls[npc+ndefc] = NULL;
}
ldap_controls_free(defctrls); /* Must be freed by library */
}
}
}
if ( rc == 0 ) {
if ( delete_entry ) {
rc = dodelete( dn, pctrls );
} else if ( newrdn != NULL ) {
rc = dorename( dn, newrdn, newsup, deleteoldrdn, pctrls );
} else {
rc = domodify( dn, pmods, pctrls, new_entry );
}
if ( rc == LDAP_SUCCESS ) {
rc = 0;
}
}
leave:
if (pctrls != NULL) {
ldap_controls_free( pctrls );
}
if ( lm != NULL ) {
ber_memfree( lm );
}
if ( mops != NULL ) {
ber_memfree( mops );
}
for (i=lines-1; i>=0; i--)
if ( freeval[i] ) ber_memfree( vals[i].bv_val );
ber_memfree( btype );
return( rc );
}
/* Parse an LDIF control line of the form
control: oid [true/false] [: value] or
control: oid [true/false] [:: base64-value] or
control: oid [true/false] [:< url]
The control is added to the list of controls in *ppctrls.
*/
static int
parse_ldif_control(
struct berval *bval,
LDAPControl ***ppctrls )
{
char *oid = NULL;
int criticality = 0; /* Default is false if not present */
int i, rc=0;
char *s, *oidStart;
LDAPControl *newctrl = NULL;
LDAPControl **pctrls = NULL;
struct berval type, bv = BER_BVNULL;
int freeval = 0;
if (ppctrls) pctrls = *ppctrls;
/* OID should come first. Validate and extract it. */
s = bval->bv_val;
if (*s == 0) return ( LDAP_PARAM_ERROR );
oidStart = s;
while (isdigit((unsigned char)*s) || *s == '.') {
s++; /* OID should be digits or . */
}
if (s == oidStart) {
return ( LDAP_PARAM_ERROR ); /* OID was not present */
}
if (*s) { /* End of OID should be space or NULL */
if (!isspace((unsigned char)*s)) {
return ( LDAP_PARAM_ERROR ); /* else OID contained invalid chars */
}
*s++ = 0; /* Replace space with null to terminate */
}
oid = ber_strdup(oidStart);
if (oid == NULL) return ( LDAP_NO_MEMORY );
/* Optional Criticality field is next. */
while (*s && isspace((unsigned char)*s)) {
s++; /* Skip white space before criticality */
}
if (strncasecmp(s, "true", 4) == 0) {
criticality = 1;
s += 4;
}
else if (strncasecmp(s, "false", 5) == 0) {
criticality = 0;
s += 5;
}
/* Optional value field is next */
while (*s && isspace((unsigned char)*s)) {
s++; /* Skip white space before value */
}
if (*s) {
if (*s != ':') { /* If value is present, must start with : */
rc = LDAP_PARAM_ERROR;
goto cleanup;
}
/* Back up so value is in the form
a: value
a:: base64-value
a:< url
Then we can use ldif_parse_line2 to extract and decode the value
*/
s--;
*s = 'a';
rc = ldif_parse_line2(s, &type, &bv, &freeval);
if (rc < 0) {
rc = LDAP_PARAM_ERROR;
goto cleanup;
}
}
/* Create a new LDAPControl structure. */
newctrl = (LDAPControl *)ber_memalloc(sizeof(LDAPControl));
if ( newctrl == NULL ) {
rc = LDAP_NO_MEMORY;
goto cleanup;
}
newctrl->ldctl_oid = oid;
oid = NULL;
newctrl->ldctl_iscritical = criticality;
if ( freeval )
newctrl->ldctl_value = bv;
else
ber_dupbv( &newctrl->ldctl_value, &bv );
/* Add the new control to the passed-in list of controls. */
i = 0;
if (pctrls) {
while ( pctrls[i] ) { /* Count the # of controls passed in */
i++;
}
}
/* Allocate 1 more slot for the new control and 1 for the NULL. */
pctrls = (LDAPControl **) ber_memrealloc(pctrls,
(i+2)*(sizeof(LDAPControl *)));
if (pctrls == NULL) {
rc = LDAP_NO_MEMORY;
goto cleanup;
}
pctrls[i] = newctrl;
newctrl = NULL;
pctrls[i+1] = NULL;
*ppctrls = pctrls;
cleanup:
if (newctrl) {
if (newctrl->ldctl_oid) ber_memfree(newctrl->ldctl_oid);
if (newctrl->ldctl_value.bv_val) {
ber_memfree(newctrl->ldctl_value.bv_val);
}
ber_memfree(newctrl);
}
if (oid) ber_memfree(oid);
return( rc );
}
static int
domodify(
const char *dn,
LDAPMod **pmods,
LDAPControl **pctrls,
int newentry )
{
int rc, i, j, k, notascii, op;
struct berval *bvp;
if ( dn == NULL ) {
fprintf( stderr, _("%s: no DN specified\n"), prog );
return( LDAP_PARAM_ERROR );
}
if ( pmods == NULL ) {
/* implement "touch" (empty sequence)
* modify operation (note that there
* is no symmetry with the UNIX command,
* since \"touch\" on a non-existent entry
* will fail)*/
printf( "warning: no attributes to %sadd (entry=\"%s\")\n",
newentry ? "" : "change or ", dn );
} else {
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 ) {
for ( i = 0; pmods[ i ] != NULL; ++i ) {
op = pmods[ i ]->mod_op & ~LDAP_MOD_BVALUES;
printf( "%s %s:\n",
op == LDAP_MOD_REPLACE ? _("replace") :
op == LDAP_MOD_ADD ? _("add") :
op == LDAP_MOD_INCREMENT ? _("increment") :
op == LDAP_MOD_DELETE ? _("delete") :
_("unknown"),
pmods[ i ]->mod_type );
if ( pmods[ i ]->mod_bvalues != NULL ) {
for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
bvp = pmods[ i ]->mod_bvalues[ j ];
notascii = 0;
for ( k = 0; (unsigned long) k < bvp->bv_len; ++k ) {
if ( !isascii( bvp->bv_val[ k ] )) {
notascii = 1;
break;
}
}
if ( notascii ) {
printf( _("\tNOT ASCII (%ld bytes)\n"), bvp->bv_len );
} else {
printf( "\t%s\n", bvp->bv_val );
}
}
}
}
}
}
if ( newentry ) {
printf( "%sadding new entry \"%s\"\n", dont ? "!" : "", dn );
} else {
printf( "%smodifying entry \"%s\"\n", dont ? "!" : "", dn );
}
if ( !dont ) {
int msgid;
if ( newentry ) {
rc = ldap_add_ext( ld, dn, pmods, pctrls, NULL, &msgid );
} else {
rc = ldap_modify_ext( ld, dn, pmods, pctrls, NULL, &msgid );
}
if ( rc != LDAP_SUCCESS ) {
/* print error message about failed update including DN */
fprintf( stderr, _("%s: update failed: %s\n"), prog, dn );
tool_perror( newentry ? "ldap_add" : "ldap_modify",
rc, NULL, NULL, NULL, NULL );
goto done;
}
rc = process_response( ld, msgid,
newentry ? LDAP_RES_ADD : LDAP_RES_MODIFY, dn );
if ( verbose && rc == LDAP_SUCCESS ) {
printf( _("modify complete\n") );
}
} else {
rc = LDAP_SUCCESS;
}
done:
putchar( '\n' );
return rc;
}
static int
dodelete(
const char *dn,
LDAPControl **pctrls )
{
int rc;
int msgid;
printf( _("%sdeleting entry \"%s\"\n"), dont ? "!" : "", dn );
if ( !dont ) {
rc = ldap_delete_ext( ld, dn, pctrls, NULL, &msgid );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, _("%s: delete failed: %s\n"), prog, dn );
tool_perror( "ldap_delete", rc, NULL, NULL, NULL, NULL );
goto done;
}
rc = process_response( ld, msgid, LDAP_RES_DELETE, dn );
if ( verbose && rc == LDAP_SUCCESS ) {
printf( _("delete complete\n") );
}
} else {
rc = LDAP_SUCCESS;
}
done:
putchar( '\n' );
return( rc );
}
static int
dorename(
const char *dn,
const char *newrdn,
const char* newsup,
int deleteoldrdn,
LDAPControl **pctrls )
{
int rc;
int msgid;
printf( _("%smodifying rdn of entry \"%s\"\n"), dont ? "!" : "", dn );
if ( verbose ) {
printf( _("\tnew RDN: \"%s\" (%skeep existing values)\n"),
newrdn, deleteoldrdn ? _("do not ") : "" );
}
if ( !dont ) {
rc = ldap_rename( ld, dn, newrdn, newsup, deleteoldrdn,
pctrls, NULL, &msgid );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, _("%s: rename failed: %s\n"), prog, dn );
tool_perror( "ldap_rename", rc, NULL, NULL, NULL, NULL );
goto done;
}
rc = process_response( ld, msgid, LDAP_RES_RENAME, dn );
if ( verbose && rc == LDAP_SUCCESS ) {
printf( _("rename complete\n") );
}
} else {
rc = LDAP_SUCCESS;
}
done:
putchar( '\n' );
return( rc );
}
static const char *
res2str( int res ) {
switch ( res ) {
case LDAP_RES_ADD:
return "ldap_add";
case LDAP_RES_DELETE:
return "ldap_delete";
case LDAP_RES_MODIFY:
return "ldap_modify";
case LDAP_RES_MODRDN:
return "ldap_rename";
default:
assert( 0 );
}
return "ldap_unknown";
}
static int process_response(
LDAP *ld,
int msgid,
int op,
const char *dn )
{
LDAPMessage *res;
int rc = LDAP_OTHER, msgtype;
struct timeval tv = { 0, 0 };
int err;
char *text = NULL, *matched = NULL, **refs = NULL;
LDAPControl **ctrls = NULL;
for ( ; ; ) {
tv.tv_sec = 0;
tv.tv_usec = 100000;
rc = ldap_result( ld, msgid, LDAP_MSG_ALL, &tv, &res );
if ( tool_check_abandon( ld, msgid ) ) {
return LDAP_CANCELLED;
}
if ( rc == -1 ) {
ldap_get_option( ld, LDAP_OPT_RESULT_CODE, &rc );
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
return rc;
}
if ( rc != 0 ) {
break;
}
}
msgtype = ldap_msgtype( res );
rc = ldap_parse_result( ld, res, &err, &matched, &text, &refs, &ctrls, 1 );
if ( rc == LDAP_SUCCESS ) rc = err;
#ifdef LDAP_X_TXN
if ( rc == LDAP_X_TXN_SPECIFY_OKAY ) {
rc = LDAP_SUCCESS;
} else
#endif
if ( rc != LDAP_SUCCESS ) {
tool_perror( res2str( op ), rc, NULL, matched, text, refs );
} else if ( msgtype != op ) {
fprintf( stderr, "%s: msgtype: expected %d got %d\n",
res2str( op ), op, msgtype );
rc = LDAP_OTHER;
}
if ( text ) ldap_memfree( text );
if ( matched ) ldap_memfree( matched );
if ( refs ) ber_memvfree( (void **)refs );
if ( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
return rc;
}
/* ldapmodrdn.c - generic program to modify an entry's RDN using LDAP */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright 1999, Juan C. Gomez, All rights reserved.
* This software is not subject to any license of Silicon Graphics
* Inc. or Purdue University.
*
* Redistribution and use in source and binary forms are permitted
* without restriction or fee of any kind as long as this notice
* is preserved.
*/
/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by the University of Michigan
* (as part of U-MICH LDAP). Additional significant contributors
* include:
* Kurt D. Zeilenga
* Juan C Gomez
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include <ac/socket.h>
#include <ac/time.h>
#include <ldap.h>
#include "lutil.h"
#include "lutil_ldap.h"
#include "ldap_defaults.h"
#include "common.h"
static char *newSuperior = NULL;
static int remove_old_RDN = 0;
static int domodrdn(
LDAP *ld,
char *dn,
char *rdn,
char *newSuperior,
int remove ); /* flag: remove old RDN */
void
usage( void )
{
fprintf( stderr, _("Rename LDAP entries\n\n"));
fprintf( stderr, _("usage: %s [options] [dn rdn]\n"), prog);
fprintf( stderr, _(" dn rdn: If given, rdn will replace the RDN of the entry specified by DN\n"));
fprintf( stderr, _(" If not given, the list of modifications is read from stdin or\n"));
fprintf( stderr, _(" from the file specified by \"-f file\" (see man page).\n"));
fprintf( stderr, _("Rename options:\n"));
fprintf( stderr, _(" -c continuous operation mode (do not stop on errors)\n"));
fprintf( stderr, _(" -f file read operations from `file'\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
fprintf( stderr, _(" -r remove old RDN\n"));
fprintf( stderr, _(" -s newsup new superior entry\n"));
tool_common_usage();
exit( EXIT_FAILURE );
}
const char options[] = "rs:"
"cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
{
switch ( i ) {
#if 0
int crit;
char *control, *cvalue;
case 'E': /* modrdn extensions */
if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
prog, version );
exit( EXIT_FAILURE );
}
/* should be extended to support comma separated list of
* [!]key[=value] parameters, e.g. -E !foo,bar=567
*/
crit = 0;
cvalue = NULL;
if( optarg[0] == '!' ) {
crit = 1;
optarg++;
}
control = strdup( optarg );
if ( (cvalue = strchr( control, '=' )) != NULL ) {
*cvalue++ = '\0';
}
fprintf( stderr, _("Invalid modrdn extension name: %s\n"), control );
usage();
#endif
case 'r': /* remove old RDN */
remove_old_RDN++;
break;
case 's': /* newSuperior */
if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, _("%s: -X incompatible with LDAPv%d\n"),
prog, protocol );
exit( EXIT_FAILURE );
}
newSuperior = strdup( optarg );
protocol = LDAP_VERSION3;
break;
default:
return 0;
}
return 1;
}
int
main(int argc, char **argv)
{
char *entrydn = NULL, *rdn = NULL, buf[ 4096 ];
FILE *fp = NULL;
LDAP *ld = NULL;
int rc, retval, havedn;
tool_init( TOOL_MODRDN );
prog = lutil_progname( "ldapmodrdn", argc, argv );
tool_args( argc, argv );
havedn = 0;
if (argc - optind == 2) {
if (( rdn = strdup( argv[argc - 1] )) == NULL ) {
perror( "strdup" );
retval = EXIT_FAILURE;
goto fail;
}
if (( entrydn = strdup( argv[argc - 2] )) == NULL ) {
perror( "strdup" );
retval = EXIT_FAILURE;
goto fail;
}
++havedn;
} else if ( argc - optind != 0 ) {
fprintf( stderr, _("%s: invalid number of arguments (%d), only two allowed\n"), prog, argc-optind );
usage();
}
if ( infile != NULL ) {
if (( fp = fopen( infile, "r" )) == NULL ) {
perror( infile );
retval = EXIT_FAILURE;
goto fail;
}
} else {
fp = stdin;
}
ld = tool_conn_setup( 0, 0 );
tool_bind( ld );
tool_server_controls( ld, NULL, 0 );
retval = rc = 0;
if (havedn)
retval = domodrdn( ld, entrydn, rdn, newSuperior, remove_old_RDN );
else while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) {
if ( *buf != '\n' ) { /* blank lines optional, skip */
buf[ strlen( buf ) - 1 ] = '\0'; /* remove nl */
if ( havedn ) { /* have DN, get RDN */
if (( rdn = strdup( buf )) == NULL ) {
perror( "strdup" );
retval = EXIT_FAILURE;
goto fail;
}
rc = domodrdn(ld, entrydn, rdn, newSuperior, remove_old_RDN );
if ( rc != 0 )
retval = rc;
havedn = 0;
free( rdn ); rdn = NULL;
free( entrydn ); entrydn = NULL;
} else if ( !havedn ) { /* don't have DN yet */
if (( entrydn = strdup( buf )) == NULL ) {
retval = EXIT_FAILURE;
goto fail;
}
++havedn;
}
}
}
fail:
if ( fp && fp != stdin ) fclose( fp );
if ( entrydn ) free( entrydn );
if ( rdn ) free( rdn );
tool_exit( ld, retval );
}
static int domodrdn(
LDAP *ld,
char *dn,
char *rdn,
char *newSuperior,
int remove ) /* flag: remove old RDN */
{
int rc, code, id;
char *matcheddn=NULL, *text=NULL, **refs=NULL;
LDAPControl **ctrls = NULL;
LDAPMessage *res;
if ( verbose ) {
printf( _("Renaming \"%s\"\n"), dn );
printf( _("\tnew rdn=\"%s\" (%s old rdn)\n"),
rdn, remove ? _("delete") : _("keep") );
if( newSuperior != NULL ) {
printf(_("\tnew parent=\"%s\"\n"), newSuperior);
}
}
if( dont ) return LDAP_SUCCESS;
rc = ldap_rename( ld, dn, rdn, newSuperior, remove,
NULL, NULL, &id );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: ldap_rename: %s (%d)\n",
prog, ldap_err2string( rc ), rc );
return rc;
}
for ( ; ; ) {
struct timeval tv = { 0, 0 };
if ( tool_check_abandon( ld, id ) ) {
return LDAP_CANCELLED;
}
tv.tv_sec = 0;
tv.tv_usec = 100000;
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
if ( rc < 0 ) {
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
return rc;
}
if ( rc != 0 ) {
break;
}
}
rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, &ctrls, 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( _("Rename 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] );
}
}
}
if (ctrls) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );
return code;
}
/* ldappasswd -- a tool for change LDAP passwords */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*/
/* ACKNOWLEDGEMENTS:
* The original ldappasswd(1) tool was developed by Dave Storey (F5
* Network), based on other OpenLDAP client tools (which are, of
* course, based on U-MICH LDAP). This version was rewritten
* by Kurt D. Zeilenga (based on other OpenLDAP client tools).
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ldap.h>
#include "lutil.h"
#include "lutil_ldap.h"
#include "ldap_defaults.h"
#include "common.h"
static struct berval newpw = { 0, NULL };
static struct berval oldpw = { 0, NULL };
static int want_newpw = 0;
static int want_oldpw = 0;
static char *oldpwfile = NULL;
static char *newpwfile = NULL;
void
usage( void )
{
fprintf( stderr, _("Change password of an LDAP user\n\n"));
fprintf( stderr,_("usage: %s [options] [user]\n"), prog);
fprintf( stderr, _(" user: the authentication identity, commonly a DN\n"));
fprintf( stderr, _("Password change options:\n"));
fprintf( stderr, _(" -a secret old password\n"));
fprintf( stderr, _(" -A prompt for old password\n"));
fprintf( stderr, _(" -t file read file for old password\n"));
fprintf( stderr, _(" -s secret new password\n"));
fprintf( stderr, _(" -S prompt for new password\n"));
fprintf( stderr, _(" -T file read file for new password\n"));
tool_common_usage();
exit( EXIT_FAILURE );
}
const char options[] = "a:As:St:T:"
"d:D:e:h:H:InNO:o:p:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
{
switch ( i ) {
#if 0
case 'E': /* passwd extensions */ {
int crit;
char *control, *cvalue;
if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
prog, protocol );
exit( EXIT_FAILURE );
}
/* should be extended to support comma separated list of
* [!]key[=value] parameters, e.g. -E !foo,bar=567
*/
crit = 0;
cvalue = NULL;
if( optarg[0] == '!' ) {
crit = 1;
optarg++;
}
control = strdup( optarg );
if ( (cvalue = strchr( control, '=' )) != NULL ) {
*cvalue++ = '\0';
}
fprintf( stderr, _("Invalid passwd extension name: %s\n"), control );
usage();
}
#endif
case 'a': /* old password (secret) */
oldpw.bv_val = strdup( optarg );
{
char* p;
for( p = optarg; *p != '\0'; p++ ) {
*p = '\0';
}
}
oldpw.bv_len = strlen( oldpw.bv_val );
break;
case 'A': /* prompt for old password */
want_oldpw++;
break;
case 's': /* new password (secret) */
newpw.bv_val = strdup (optarg);
{
char* p;
for( p = optarg; *p != '\0'; p++ ) {
*p = '\0';
}
}
newpw.bv_len = strlen( newpw.bv_val );
break;
case 'S': /* prompt for user password */
want_newpw++;
break;
case 't':
oldpwfile = optarg;
break;
case 'T':
newpwfile = optarg;
break;
default:
return 0;
}
return 1;
}
int
main( int argc, char *argv[] )
{
int rc;
char *user = NULL;
LDAP *ld = NULL;
struct berval bv = {0, NULL};
BerElement *ber = NULL;
int id, code = LDAP_OTHER;
LDAPMessage *res;
char *matcheddn = NULL, *text = NULL, **refs = NULL;
char *retoid = NULL;
struct berval *retdata = NULL;
LDAPControl **ctrls = NULL;
tool_init( TOOL_PASSWD );
prog = lutil_progname( "ldappasswd", argc, argv );
/* LDAPv3 only */
protocol = LDAP_VERSION3;
tool_args( argc, argv );
if( argc - optind > 1 ) {
usage();
} else if ( argc - optind == 1 ) {
user = strdup( argv[optind] );
} else {
user = NULL;
}
if( oldpwfile ) {
rc = lutil_get_filed_password( oldpwfile, &oldpw );
if( rc ) {
rc = EXIT_FAILURE;
goto done;
}
}
if( want_oldpw && oldpw.bv_val == NULL ) {
/* prompt for old password */
char *ckoldpw;
oldpw.bv_val = strdup(getpassphrase(_("Old password: ")));
ckoldpw = getpassphrase(_("Re-enter old password: "));
if( oldpw.bv_val == NULL || ckoldpw == NULL ||
strcmp( oldpw.bv_val, ckoldpw ))
{
fprintf( stderr, _("passwords do not match\n") );
rc = EXIT_FAILURE;
goto done;
}
oldpw.bv_len = strlen( oldpw.bv_val );
}
if( newpwfile ) {
rc = lutil_get_filed_password( newpwfile, &newpw );
if( rc ) {
rc = EXIT_FAILURE;
goto done;
}
}
if( want_newpw && newpw.bv_val == NULL ) {
/* prompt for new password */
char *cknewpw;
newpw.bv_val = strdup(getpassphrase(_("New password: ")));
cknewpw = getpassphrase(_("Re-enter new password: "));
if( newpw.bv_val == NULL || cknewpw == NULL ||
strcmp( newpw.bv_val, cknewpw ))
{
fprintf( stderr, _("passwords do not match\n") );
rc = EXIT_FAILURE;
goto done;
}
newpw.bv_len = strlen( newpw.bv_val );
}
ld = tool_conn_setup( 0, 0 );
tool_bind( ld );
if( user != NULL || oldpw.bv_val != NULL || newpw.bv_val != NULL ) {
/* build the password modify request data */
ber = ber_alloc_t( LBER_USE_DER );
if( ber == NULL ) {
perror( "ber_alloc_t" );
rc = EXIT_FAILURE;
goto done;
}
ber_printf( ber, "{" /*}*/ );
if( user != NULL ) {
ber_printf( ber, "ts",
LDAP_TAG_EXOP_MODIFY_PASSWD_ID, user );
free(user);
}
if( oldpw.bv_val != NULL ) {
ber_printf( ber, "tO",
LDAP_TAG_EXOP_MODIFY_PASSWD_OLD, &oldpw );
free(oldpw.bv_val);
}
if( newpw.bv_val != NULL ) {
ber_printf( ber, "tO",
LDAP_TAG_EXOP_MODIFY_PASSWD_NEW, &newpw );
free(newpw.bv_val);
}
ber_printf( ber, /*{*/ "N}" );
rc = ber_flatten2( ber, &bv, 0 );
if( rc < 0 ) {
perror( "ber_flatten2" );
rc = EXIT_FAILURE;
goto done;
}
}
if ( dont ) {
rc = LDAP_SUCCESS;
goto done;
}
tool_server_controls( ld, NULL, 0);
rc = ldap_extended_operation( ld,
LDAP_EXOP_MODIFY_PASSWD, bv.bv_val ? &bv : NULL,
NULL, NULL, &id );
ber_free( ber, 1 );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_extended_operation", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto done;
}
for ( ; ; ) {
struct timeval tv;
if ( tool_check_abandon( ld, id ) ) {
tool_exit( ld, LDAP_CANCELLED );
}
tv.tv_sec = 0;
tv.tv_usec = 100000;
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
if ( rc < 0 ) {
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
tool_exit( ld, rc );
}
if ( rc != 0 ) {
break;
}
}
rc = ldap_parse_result( ld, res,
&code, &matcheddn, &text, &refs, &ctrls, 0 );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_result", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto done;
}
rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 1 );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto done;
}
if( retdata != NULL ) {
ber_tag_t tag;
char *s;
ber = ber_init( retdata );
if( ber == NULL ) {
perror( "ber_init" );
rc = EXIT_FAILURE;
goto done;
}
/* we should check the tag */
tag = ber_scanf( ber, "{a}", &s);
if( tag == LBER_ERROR ) {
perror( "ber_scanf" );
} else {
printf(_("New password: %s\n"), s);
ber_memfree( s );
}
ber_free( ber, 1 );
} else if ( code == LDAP_SUCCESS && newpw.bv_val == NULL ) {
tool_perror( "ldap_parse_extended_result", LDAP_DECODING_ERROR,
" new password expected", NULL, NULL, NULL );
}
if( verbose || code != LDAP_SUCCESS ||
( matcheddn && *matcheddn ) || ( text && *text ) || refs || ctrls )
{
printf( _("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] );
}
}
if( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );
ber_memfree( retoid );
ber_bvfree( retdata );
rc = ( code == LDAP_SUCCESS ) ? EXIT_SUCCESS : EXIT_FAILURE;
done:
/* disconnect from server */
tool_exit( ld, rc );
}
/* ldapsearch -- a tool for searching LDAP directories */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by the University of Michigan
* (as part of U-MICH LDAP). Additional significant contributors
* include:
* Jong Hyuk Choi
* Lynn Moss
* Mikhail Sahalaev
* Kurt D. Zeilenga
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include <ac/errno.h>
#include <ac/time.h>
#include <sys/stat.h>
#include <ac/signal.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"
#include "ldap_pvt.h"
#include "common.h"
#if !LDAP_DEPRECATED
/*
* NOTE: we use this deprecated function only because
* we want ldapsearch to provide some client-side sorting
* capability.
*/
/* from ldap.h */
typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P(( /* deprecated */
LDAP_CONST char *left,
LDAP_CONST char *right ));
LDAP_F( int ) /* deprecated */
ldap_sort_entries LDAP_P(( LDAP *ld,
LDAPMessage **chain,
LDAP_CONST char *attr,
LDAP_SORT_AD_CMP_PROC *cmp ));
#endif
static int scope = LDAP_SCOPE_SUBTREE;
static int deref = -1;
static int attrsonly;
static int timelimit = -1;
static int sizelimit = -1;
static char *control;
static char *def_tmpdir;
static char *def_urlpre;
#if defined(__CYGWIN__) || defined(__MINGW32__)
/* Turn off commandline globbing, otherwise you cannot search for
* attribute '*'
*/
int _CRT_glob = 0;
#endif
void
usage( void )
{
fprintf( stderr, _("usage: %s [options] [filter [attributes...]]\nwhere:\n"), prog);
fprintf( stderr, _(" filter\tRFC 4515 compliant LDAP search filter\n"));
fprintf( stderr, _(" attributes\twhitespace-separated list of attribute descriptions\n"));
fprintf( stderr, _(" which may include:\n"));
fprintf( stderr, _(" 1.1 no attributes\n"));
fprintf( stderr, _(" * all user attributes\n"));
fprintf( stderr, _(" + all operational attributes\n"));
fprintf( stderr, _("Search options:\n"));
fprintf( stderr, _(" -a deref one of never (default), always, search, or find\n"));
fprintf( stderr, _(" -A retrieve attribute names only (no values)\n"));
fprintf( stderr, _(" -b basedn base dn for search\n"));
fprintf( stderr, _(" -c continuous operation mode (do not stop on errors)\n"));
fprintf( stderr, _(" -E [!]<ext>[=<extparam>] search extensions (! indicates criticality)\n"));
fprintf( stderr, _(" [!]domainScope (domain scope)\n"));
fprintf( stderr, _(" !dontUseCopy (Don't Use Copy)\n"));
fprintf( stderr, _(" [!]mv=<filter> (RFC 3876 matched values filter)\n"));
fprintf( stderr, _(" [!]pr=<size>[/prompt|noprompt] (RFC 2696 paged results/prompt)\n"));
fprintf( stderr, _(" [!]sss=[-]<attr[:OID]>[/[-]<attr[:OID]>...]\n"));
fprintf( stderr, _(" (RFC 2891 server side sorting)\n"));
fprintf( stderr, _(" [!]subentries[=true|false] (RFC 3672 subentries)\n"));
fprintf( stderr, _(" [!]sync=ro[/<cookie>] (RFC 4533 LDAP Sync refreshOnly)\n"));
fprintf( stderr, _(" rp[/<cookie>][/<slimit>] (refreshAndPersist)\n"));
fprintf( stderr, _(" [!]vlv=<before>/<after>(/<offset>/<count>|:<value>)\n"));
fprintf( stderr, _(" (ldapv3-vlv-09 virtual list views)\n"));
#ifdef LDAP_CONTROL_X_DEREF
fprintf( stderr, _(" [!]deref=derefAttr:attr[,...][;derefAttr:attr[,...][;...]]\n"));
#endif
fprintf( stderr, _(" [!]<oid>[=:<b64value>] (generic control; no response handling)\n"));
fprintf( stderr, _(" -f file read operations from `file'\n"));
fprintf( stderr, _(" -F prefix URL prefix for files (default: %s)\n"), def_urlpre);
fprintf( stderr, _(" -l limit time limit (in seconds, or \"none\" or \"max\") for search\n"));
fprintf( stderr, _(" -L print responses in LDIFv1 format\n"));
fprintf( stderr, _(" -LL print responses in LDIF format without comments\n"));
fprintf( stderr, _(" -LLL print responses in LDIF format without comments\n"));
fprintf( stderr, _(" and version\n"));
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
fprintf( stderr, _(" -s scope one of base, one, sub or children (search scope)\n"));
fprintf( stderr, _(" -S attr sort the results by attribute `attr'\n"));
fprintf( stderr, _(" -t write binary values to files in temporary directory\n"));
fprintf( stderr, _(" -tt write all values to files in temporary directory\n"));
fprintf( stderr, _(" -T path write files to directory specified by path (default: %s)\n"), def_tmpdir);
fprintf( stderr, _(" -u include User Friendly entry names in the output\n"));
fprintf( stderr, _(" -z limit size limit (in entries, or \"none\" or \"max\") for search\n"));
tool_common_usage();
exit( EXIT_FAILURE );
}
static void print_entry LDAP_P((
LDAP *ld,
LDAPMessage *entry,
int attrsonly));
static void print_reference(
LDAP *ld,
LDAPMessage *reference );
static void print_extended(
LDAP *ld,
LDAPMessage *extended );
static void print_partial(
LDAP *ld,
LDAPMessage *partial );
static int print_result(
LDAP *ld,
LDAPMessage *result,
int search );
static int dosearch LDAP_P((
LDAP *ld,
char *base,
int scope,
char *filtpatt,
char *value,
char **attrs,
int attrsonly,
LDAPControl **sctrls,
LDAPControl **cctrls,
struct timeval *timeout,
int sizelimit ));
static char *tmpdir = NULL;
static char *urlpre = NULL;
static char *base = NULL;
static char *sortattr = NULL;
static int includeufn, vals2tmp = 0;
static int subentries = 0, valuesReturnFilter = 0;
static char *vrFilter = NULL;
#ifdef LDAP_CONTROL_DONTUSECOPY
static int dontUseCopy = 0;
#endif
static int domainScope = 0;
static int sss = 0;
static LDAPSortKey **sss_keys = NULL;
static int vlv = 0;
static LDAPVLVInfo vlvInfo;
static struct berval vlvValue;
static int ldapsync = 0;
static struct berval sync_cookie = { 0, NULL };
static int sync_slimit = -1;
/* cookie and morePagedResults moved to common.c */
static int pagedResults = 0;
static int pagePrompt = 1;
static ber_int_t pageSize = 0;
static ber_int_t entriesLeft = 0;
static int npagedresponses;
static int npagedentries;
static int npagedreferences;
static int npagedextended;
static int npagedpartial;
static LDAPControl *c = NULL;
static int nctrls = 0;
static int save_nctrls = 0;
#ifdef LDAP_CONTROL_X_DEREF
static int derefcrit;
static LDAPDerefSpec *ds;
static struct berval derefval;
#endif
static int
ctrl_add( void )
{
LDAPControl *tmpc;
nctrls++;
tmpc = realloc( c, sizeof( LDAPControl ) * nctrls );
if ( tmpc == NULL ) {
nctrls--;
fprintf( stderr,
_("unable to make room for control; out of memory?\n"));
return -1;
}
c = tmpc;
return 0;
}
static void
urlize(char *url)
{
char *p;
if (*LDAP_DIRSEP != '/') {
for (p = url; *p; p++) {
if (*p == *LDAP_DIRSEP)
*p = '/';
}
}
}
static int
parse_vlv(char *cvalue)
{
char *keyp, *key2;
int num1, num2;
keyp = cvalue;
if ( sscanf( keyp, "%d/%d", &num1, &num2 ) != 2 ) {
fprintf( stderr,
_("VLV control value \"%s\" invalid\n"),
cvalue );
return -1;
}
vlvInfo.ldvlv_before_count = num1;
vlvInfo.ldvlv_after_count = num2;
keyp = strchr( keyp, '/' ) + 1;
key2 = strchr( keyp, '/' );
if ( key2 ) {
keyp = key2 + 1;
if ( sscanf( keyp, "%d/%d", &num1, &num2 ) != 2 ) {
fprintf( stderr,
_("VLV control value \"%s\" invalid\n"),
cvalue );
return -1;
}
vlvInfo.ldvlv_offset = num1;
vlvInfo.ldvlv_count = num2;
vlvInfo.ldvlv_attrvalue = NULL;
} else {
key2 = strchr( keyp, ':' );
if ( !key2 ) {
fprintf( stderr,
_("VLV control value \"%s\" invalid\n"),
cvalue );
return -1;
}
ber_str2bv( key2+1, 0, 0, &vlvValue );
vlvInfo.ldvlv_attrvalue = &vlvValue;
}
return 0;
}
const char options[] = "a:Ab:cE:F:l:Ls:S:tT:uz:"
"Cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
{
int crit, ival;
char *cvalue, *next;
switch ( i ) {
case 'a': /* set alias deref option */
if ( strcasecmp( optarg, "never" ) == 0 ) {
deref = LDAP_DEREF_NEVER;
} else if ( strncasecmp( optarg, "search", sizeof("search")-1 ) == 0 ) {
deref = LDAP_DEREF_SEARCHING;
} else if ( strncasecmp( optarg, "find", sizeof("find")-1 ) == 0 ) {
deref = LDAP_DEREF_FINDING;
} else if ( strcasecmp( optarg, "always" ) == 0 ) {
deref = LDAP_DEREF_ALWAYS;
} else {
fprintf( stderr,
_("alias deref should be never, search, find, or always\n") );
usage();
}
break;
case 'A': /* retrieve attribute names only -- no values */
++attrsonly;
break;
case 'b': /* search base */
base = ber_strdup( optarg );
break;
case 'E': /* search extensions */
if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
prog, protocol );
exit( EXIT_FAILURE );
}
/* should be extended to support comma separated list of
* [!]key[=value] parameters, e.g. -E !foo,bar=567
*/
crit = 0;
cvalue = NULL;
if( optarg[0] == '!' ) {
crit = 1;
optarg++;
}
control = ber_strdup( optarg );
if ( (cvalue = strchr( control, '=' )) != NULL ) {
*cvalue++ = '\0';
}
if ( strcasecmp( control, "mv" ) == 0 ) {
/* ValuesReturnFilter control */
if( valuesReturnFilter ) {
fprintf( stderr,
_("ValuesReturnFilter previously specified\n"));
exit( EXIT_FAILURE );
}
valuesReturnFilter= 1 + crit;
if ( cvalue == NULL ) {
fprintf( stderr,
_("missing filter in ValuesReturnFilter control\n"));
exit( EXIT_FAILURE );
}
vrFilter = cvalue;
protocol = LDAP_VERSION3;
} else if ( strcasecmp( control, "pr" ) == 0 ) {
int num, tmp;
/* PagedResults control */
if ( pagedResults != 0 ) {
fprintf( stderr,
_("PagedResultsControl previously specified\n") );
exit( EXIT_FAILURE );
}
if ( vlv != 0 ) {
fprintf( stderr,
_("PagedResultsControl incompatible with VLV\n") );
exit( EXIT_FAILURE );
}
if( cvalue != NULL ) {
char *promptp;
promptp = strchr( cvalue, '/' );
if ( promptp != NULL ) {
*promptp++ = '\0';
if ( strcasecmp( promptp, "prompt" ) == 0 ) {
pagePrompt = 1;
} else if ( strcasecmp( promptp, "noprompt" ) == 0) {
pagePrompt = 0;
} else {
fprintf( stderr,
_("Invalid value for PagedResultsControl,"
" %s/%s.\n"), cvalue, promptp );
exit( EXIT_FAILURE );
}
}
num = sscanf( cvalue, "%d", &tmp );
if ( num != 1 ) {
fprintf( stderr,
_("Invalid value for PagedResultsControl, %s.\n"),
cvalue );
exit( EXIT_FAILURE );
}
} else {
fprintf(stderr, _("Invalid value for PagedResultsControl.\n"));
exit( EXIT_FAILURE );
}
pageSize = (ber_int_t) tmp;
pagedResults = 1 + crit;
#ifdef LDAP_CONTROL_DONTUSECOPY
} else if ( strcasecmp( control, "dontUseCopy" ) == 0 ) {
if( dontUseCopy ) {
fprintf( stderr,
_("dontUseCopy control previously specified\n"));
exit( EXIT_FAILURE );
}
if( cvalue != NULL ) {
fprintf( stderr,
_("dontUseCopy: no control value expected\n") );
usage();
}
if( !crit ) {
fprintf( stderr,
_("dontUseCopy: critical flag required\n") );
usage();
}
dontUseCopy = 1 + crit;
#endif
} else if ( strcasecmp( control, "domainScope" ) == 0 ) {
if( domainScope ) {
fprintf( stderr,
_("domainScope control previously specified\n"));
exit( EXIT_FAILURE );
}
if( cvalue != NULL ) {
fprintf( stderr,
_("domainScope: no control value expected\n") );
usage();
}
domainScope = 1 + crit;
} else if ( strcasecmp( control, "sss" ) == 0 ) {
char *keyp;
if( sss ) {
fprintf( stderr,
_("server side sorting control previously specified\n"));
exit( EXIT_FAILURE );
}
if( cvalue == NULL ) {
fprintf( stderr,
_("missing specification of sss control\n") );
exit( EXIT_FAILURE );
}
keyp = cvalue;
while ( ( keyp = strchr(keyp, '/') ) != NULL ) {
*keyp++ = ' ';
}
if ( ldap_create_sort_keylist( &sss_keys, cvalue )) {
fprintf( stderr,
_("server side sorting control value \"%s\" invalid\n"),
cvalue );
exit( EXIT_FAILURE );
}
sss = 1 + crit;
} else if ( strcasecmp( control, "subentries" ) == 0 ) {
if( subentries ) {
fprintf( stderr,
_("subentries control previously specified\n"));
exit( EXIT_FAILURE );
}
if( cvalue == NULL || strcasecmp( cvalue, "true") == 0 ) {
subentries = 2;
} else if ( strcasecmp( cvalue, "false") == 0 ) {
subentries = 1;
} else {
fprintf( stderr,
_("subentries control value \"%s\" invalid\n"),
cvalue );
exit( EXIT_FAILURE );
}
if( crit ) subentries *= -1;
} else if ( strcasecmp( control, "sync" ) == 0 ) {
char *cookiep;
char *slimitp;
if ( ldapsync ) {
fprintf( stderr, _("sync control previously specified\n") );
exit( EXIT_FAILURE );
}
if ( cvalue == NULL ) {
fprintf( stderr, _("missing specification of sync control\n"));
exit( EXIT_FAILURE );
}
if ( strncasecmp( cvalue, "ro", 2 ) == 0 ) {
ldapsync = LDAP_SYNC_REFRESH_ONLY;
cookiep = strchr( cvalue, '/' );
if ( cookiep != NULL ) {
cookiep++;
if ( *cookiep != '\0' ) {
ber_str2bv( cookiep, 0, 0, &sync_cookie );
}
}
} else if ( strncasecmp( cvalue, "rp", 2 ) == 0 ) {
ldapsync = LDAP_SYNC_REFRESH_AND_PERSIST;
cookiep = strchr( cvalue, '/' );
if ( cookiep != NULL ) {
*cookiep++ = '\0';
cvalue = cookiep;
}
slimitp = strchr( cvalue, '/' );
if ( slimitp != NULL ) {
*slimitp++ = '\0';
}
if ( cookiep != NULL && *cookiep != '\0' )
ber_str2bv( cookiep, 0, 0, &sync_cookie );
if ( slimitp != NULL && *slimitp != '\0' ) {
ival = strtol( slimitp, &next, 10 );
if ( next == NULL || next[0] != '\0' ) {
fprintf( stderr, _("Unable to parse sync control value \"%s\"\n"), slimitp );
exit( EXIT_FAILURE );
}
sync_slimit = ival;
}
} else {
fprintf( stderr, _("sync control value \"%s\" invalid\n"),
cvalue );
exit( EXIT_FAILURE );
}
if ( crit ) ldapsync *= -1;
} else if ( strcasecmp( control, "vlv" ) == 0 ) {
if( vlv ) {
fprintf( stderr,
_("virtual list view control previously specified\n"));
exit( EXIT_FAILURE );
}
if ( pagedResults != 0 ) {
fprintf( stderr,
_("PagedResultsControl incompatible with VLV\n") );
exit( EXIT_FAILURE );
}
if( cvalue == NULL ) {
fprintf( stderr,
_("missing specification of vlv control\n") );
exit( EXIT_FAILURE );
}
if ( parse_vlv( cvalue ))
exit( EXIT_FAILURE );
vlv = 1 + crit;
#ifdef LDAP_CONTROL_X_DEREF
} else if ( strcasecmp( control, "deref" ) == 0 ) {
int ispecs;
char **specs;
/* cvalue is something like
*
* derefAttr:attr[,attr[...]][;derefAttr:attr[,attr[...]]]"
*/
specs = ldap_str2charray( cvalue, ";" );
if ( specs == NULL ) {
fprintf( stderr, _("deref specs \"%s\" invalid\n"),
cvalue );
exit( EXIT_FAILURE );
}
for ( ispecs = 0; specs[ ispecs ] != NULL; ispecs++ )
/* count'em */ ;
ds = ldap_memcalloc( ispecs + 1, sizeof( LDAPDerefSpec ) );
if ( ds == NULL ) {
perror( "malloc" );
exit( EXIT_FAILURE );
}
for ( ispecs = 0; specs[ ispecs ] != NULL; ispecs++ ) {
char *ptr;
ptr = strchr( specs[ ispecs ], ':' );
if ( ptr == NULL ) {
fprintf( stderr, _("deref specs \"%s\" invalid\n"),
cvalue );
exit( EXIT_FAILURE );
}
ds[ ispecs ].derefAttr = specs[ ispecs ];
*ptr++ = '\0';
ds[ ispecs ].attributes = ldap_str2charray( ptr, "," );
}
derefcrit = 1 + crit;
ldap_memfree( specs );
#endif /* LDAP_CONTROL_X_DEREF */
} else if ( tool_is_oid( control ) ) {
if ( ctrl_add() ) {
exit( EXIT_FAILURE );
}
/* OID */
c[ nctrls - 1 ].ldctl_oid = control;
/* value */
if ( cvalue == NULL ) {
c[ nctrls - 1 ].ldctl_value.bv_val = NULL;
c[ nctrls - 1 ].ldctl_value.bv_len = 0;
} else if ( cvalue[ 0 ] == ':' ) {
struct berval type;
struct berval value;
int freeval;
char save_c;
cvalue++;
/* dummy type "x"
* to use ldif_parse_line2() */
save_c = cvalue[ -2 ];
cvalue[ -2 ] = 'x';
ldif_parse_line2( &cvalue[ -2 ], &type,
&value, &freeval );
cvalue[ -2 ] = save_c;
if ( freeval ) {
c[ nctrls - 1 ].ldctl_value = value;
} else {
ber_dupbv( &c[ nctrls - 1 ].ldctl_value, &value );
}
} else {
fprintf( stderr, "unable to parse %s control value\n", control );
exit( EXIT_FAILURE );
}
/* criticality */
c[ nctrls - 1 ].ldctl_iscritical = crit;
} else {
fprintf( stderr, _("Invalid search extension name: %s\n"),
control );
usage();
}
break;
case 'F': /* uri prefix */
if( urlpre ) free( urlpre );
urlpre = strdup( optarg );
break;
case 'l': /* time limit */
if ( strcasecmp( optarg, "none" ) == 0 ) {
timelimit = 0;
} else if ( strcasecmp( optarg, "max" ) == 0 ) {
timelimit = LDAP_MAXINT;
} else {
ival = strtol( optarg, &next, 10 );
if ( next == NULL || next[0] != '\0' ) {
fprintf( stderr,
_("Unable to parse time limit \"%s\"\n"), optarg );
exit( EXIT_FAILURE );
}
timelimit = ival;
}
if( timelimit < 0 || timelimit > LDAP_MAXINT ) {
fprintf( stderr, _("%s: invalid timelimit (%d) specified\n"),
prog, timelimit );
exit( EXIT_FAILURE );
}
break;
case 'L': /* print entries in LDIF format */
++ldif;
break;
case 's': /* search scope */
if ( strncasecmp( optarg, "base", sizeof("base")-1 ) == 0 ) {
scope = LDAP_SCOPE_BASE;
} else if ( strncasecmp( optarg, "one", sizeof("one")-1 ) == 0 ) {
scope = LDAP_SCOPE_ONELEVEL;
} else if (( strcasecmp( optarg, "subordinate" ) == 0 )
|| ( strcasecmp( optarg, "children" ) == 0 ))
{
scope = LDAP_SCOPE_SUBORDINATE;
} else if ( strncasecmp( optarg, "sub", sizeof("sub")-1 ) == 0 ) {
scope = LDAP_SCOPE_SUBTREE;
} else {
fprintf( stderr, _("scope should be base, one, or sub\n") );
usage();
}
break;
case 'S': /* sort attribute */
sortattr = strdup( optarg );
break;
case 't': /* write attribute values to TMPDIR files */
++vals2tmp;
break;
case 'T': /* tmpdir */
if( tmpdir ) free( tmpdir );
tmpdir = strdup( optarg );
break;
case 'u': /* include UFN */
++includeufn;
break;
case 'z': /* size limit */
if ( strcasecmp( optarg, "none" ) == 0 ) {
sizelimit = 0;
} else if ( strcasecmp( optarg, "max" ) == 0 ) {
sizelimit = LDAP_MAXINT;
} else {
ival = strtol( optarg, &next, 10 );
if ( next == NULL || next[0] != '\0' ) {
fprintf( stderr,
_("Unable to parse size limit \"%s\"\n"), optarg );
exit( EXIT_FAILURE );
}
sizelimit = ival;
}
if( sizelimit < 0 || sizelimit > LDAP_MAXINT ) {
fprintf( stderr, _("%s: invalid sizelimit (%d) specified\n"),
prog, sizelimit );
exit( EXIT_FAILURE );
}
break;
default:
return 0;
}
return 1;
}
static void
private_conn_setup( LDAP *ld )
{
if (deref != -1 &&
ldap_set_option( ld, LDAP_OPT_DEREF, (void *) &deref )
!= LDAP_OPT_SUCCESS )
{
fprintf( stderr, _("Could not set LDAP_OPT_DEREF %d\n"), deref );
tool_exit( ld, EXIT_FAILURE );
}
}
int
main( int argc, char **argv )
{
char *filtpattern, **attrs = NULL, line[BUFSIZ];
FILE *fp = NULL;
int rc, rc1, i, first;
LDAP *ld = NULL;
BerElement *seber = NULL, *vrber = NULL;
BerElement *syncber = NULL;
struct berval *syncbvalp = NULL;
int err;
tool_init( TOOL_SEARCH );
npagedresponses = npagedentries = npagedreferences =
npagedextended = npagedpartial = 0;
prog = lutil_progname( "ldapsearch", argc, argv );
if((def_tmpdir = getenv("TMPDIR")) == NULL &&
(def_tmpdir = getenv("TMP")) == NULL &&
(def_tmpdir = getenv("TEMP")) == NULL )
{
def_tmpdir = LDAP_TMPDIR;
}
if ( !*def_tmpdir )
def_tmpdir = LDAP_TMPDIR;
def_urlpre = malloc( sizeof("file:////") + strlen(def_tmpdir) );
if( def_urlpre == NULL ) {
perror( "malloc" );
return EXIT_FAILURE;
}
sprintf( def_urlpre, "file:///%s/",
def_tmpdir[0] == *LDAP_DIRSEP ? &def_tmpdir[1] : def_tmpdir );
urlize( def_urlpre );
tool_args( argc, argv );
if ( vlv && !sss ) {
fprintf( stderr,
_("VLV control requires server side sort control\n" ));
return EXIT_FAILURE;
}
if (( argc - optind < 1 ) ||
( *argv[optind] != '(' /*')'*/ &&
( strchr( argv[optind], '=' ) == NULL ) ) )
{
filtpattern = "(objectclass=*)";
} else {
filtpattern = argv[optind++];
}
if ( argv[optind] != NULL ) {
attrs = &argv[optind];
}
if ( infile != NULL ) {
int percent = 0;
if ( infile[0] == '-' && infile[1] == '\0' ) {
fp = stdin;
} else if (( fp = fopen( infile, "r" )) == NULL ) {
perror( infile );
return EXIT_FAILURE;
}
for( i=0 ; filtpattern[i] ; i++ ) {
if( filtpattern[i] == '%' ) {
if( percent ) {
fprintf( stderr, _("Bad filter pattern \"%s\"\n"),
filtpattern );
return EXIT_FAILURE;
}
percent++;
if( filtpattern[i+1] != 's' ) {
fprintf( stderr, _("Bad filter pattern \"%s\"\n"),
filtpattern );
return EXIT_FAILURE;
}
}
}
}
if ( tmpdir == NULL ) {
tmpdir = def_tmpdir;
if ( urlpre == NULL )
urlpre = def_urlpre;
}
if( urlpre == NULL ) {
urlpre = malloc( sizeof("file:////") + strlen(tmpdir) );
if( urlpre == NULL ) {
perror( "malloc" );
return EXIT_FAILURE;
}
sprintf( urlpre, "file:///%s/",
tmpdir[0] == *LDAP_DIRSEP ? &tmpdir[1] : tmpdir );
urlize( urlpre );
}
if ( debug )
ldif_debug = debug;
ld = tool_conn_setup( 0, &private_conn_setup );
tool_bind( ld );
getNextPage:
/* fp may have been closed, need to reopen if code jumps
* back here to getNextPage.
*/
if ( !fp && infile ) {
if (( fp = fopen( infile, "r" )) == NULL ) {
perror( infile );
tool_exit( ld, EXIT_FAILURE );
}
}
save_nctrls = nctrls;
i = nctrls;
if ( nctrls > 0
#ifdef LDAP_CONTROL_DONTUSECOPY
|| dontUseCopy
#endif
#ifdef LDAP_CONTROL_X_DEREF
|| derefcrit
#endif
|| domainScope
|| pagedResults
|| ldapsync
|| sss
|| subentries
|| valuesReturnFilter
|| vlv )
{
#ifdef LDAP_CONTROL_DONTUSECOPY
if ( dontUseCopy ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
c[i].ldctl_oid = LDAP_CONTROL_DONTUSECOPY;
c[i].ldctl_value.bv_val = NULL;
c[i].ldctl_value.bv_len = 0;
c[i].ldctl_iscritical = dontUseCopy > 1;
i++;
}
#endif
if ( domainScope ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
c[i].ldctl_oid = LDAP_CONTROL_X_DOMAIN_SCOPE;
c[i].ldctl_value.bv_val = NULL;
c[i].ldctl_value.bv_len = 0;
c[i].ldctl_iscritical = domainScope > 1;
i++;
}
if ( subentries ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
if (( seber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
tool_exit( ld, EXIT_FAILURE );
}
err = ber_printf( seber, "b", abs(subentries) == 1 ? 0 : 1 );
if ( err == -1 ) {
ber_free( seber, 1 );
fprintf( stderr, _("Subentries control encoding error!\n") );
tool_exit( ld, EXIT_FAILURE );
}
if ( ber_flatten2( seber, &c[i].ldctl_value, 0 ) == -1 ) {
tool_exit( ld, EXIT_FAILURE );
}
c[i].ldctl_oid = LDAP_CONTROL_SUBENTRIES;
c[i].ldctl_iscritical = subentries < 1;
i++;
}
if ( ldapsync ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
if (( syncber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
tool_exit( ld, EXIT_FAILURE );
}
if ( sync_cookie.bv_len == 0 ) {
err = ber_printf( syncber, "{e}", abs(ldapsync) );
} else {
err = ber_printf( syncber, "{eO}", abs(ldapsync),
&sync_cookie );
}
if ( err == -1 ) {
ber_free( syncber, 1 );
fprintf( stderr, _("ldap sync control encoding error!\n") );
tool_exit( ld, EXIT_FAILURE );
}
if ( ber_flatten( syncber, &syncbvalp ) == -1 ) {
tool_exit( ld, EXIT_FAILURE );
}
c[i].ldctl_oid = LDAP_CONTROL_SYNC;
c[i].ldctl_value = (*syncbvalp);
c[i].ldctl_iscritical = ldapsync < 0;
i++;
}
if ( valuesReturnFilter ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
if (( vrber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
tool_exit( ld, EXIT_FAILURE );
}
if ( ( err = ldap_put_vrFilter( vrber, vrFilter ) ) == -1 ) {
ber_free( vrber, 1 );
fprintf( stderr, _("Bad ValuesReturnFilter: %s\n"), vrFilter );
tool_exit( ld, EXIT_FAILURE );
}
if ( ber_flatten2( vrber, &c[i].ldctl_value, 0 ) == -1 ) {
tool_exit( ld, EXIT_FAILURE );
}
c[i].ldctl_oid = LDAP_CONTROL_VALUESRETURNFILTER;
c[i].ldctl_iscritical = valuesReturnFilter > 1;
i++;
}
if ( pagedResults ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
if ( ldap_create_page_control_value( ld,
pageSize, &pr_cookie, &c[i].ldctl_value ) )
{
tool_exit( ld, EXIT_FAILURE );
}
if ( pr_cookie.bv_val != NULL ) {
ber_memfree( pr_cookie.bv_val );
pr_cookie.bv_val = NULL;
pr_cookie.bv_len = 0;
}
c[i].ldctl_oid = LDAP_CONTROL_PAGEDRESULTS;
c[i].ldctl_iscritical = pagedResults > 1;
i++;
}
if ( sss ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
if ( ldap_create_sort_control_value( ld,
sss_keys, &c[i].ldctl_value ) )
{
tool_exit( ld, EXIT_FAILURE );
}
c[i].ldctl_oid = LDAP_CONTROL_SORTREQUEST;
c[i].ldctl_iscritical = sss > 1;
i++;
}
if ( vlv ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
if ( ldap_create_vlv_control_value( ld,
&vlvInfo, &c[i].ldctl_value ) )
{
tool_exit( ld, EXIT_FAILURE );
}
c[i].ldctl_oid = LDAP_CONTROL_VLVREQUEST;
c[i].ldctl_iscritical = sss > 1;
i++;
}
#ifdef LDAP_CONTROL_X_DEREF
if ( derefcrit ) {
if ( derefval.bv_val == NULL ) {
int i;
assert( ds != NULL );
if ( ldap_create_deref_control_value( ld, ds, &derefval ) != LDAP_SUCCESS ) {
tool_exit( ld, EXIT_FAILURE );
}
for ( i = 0; ds[ i ].derefAttr != NULL; i++ ) {
ldap_memfree( ds[ i ].derefAttr );
ldap_charray_free( ds[ i ].attributes );
}
ldap_memfree( ds );
ds = NULL;
}
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
c[ i ].ldctl_iscritical = derefcrit > 1;
c[ i ].ldctl_oid = LDAP_CONTROL_X_DEREF;
c[ i ].ldctl_value = derefval;
i++;
}
#endif /* LDAP_CONTROL_X_DEREF */
}
tool_server_controls( ld, c, i );
if ( seber ) ber_free( seber, 1 );
if ( vrber ) ber_free( vrber, 1 );
/* step back to the original number of controls, so that
* those set while parsing args are preserved */
nctrls = save_nctrls;
if ( verbose ) {
fprintf( stderr, _("filter%s: %s\nrequesting: "),
infile != NULL ? _(" pattern") : "",
filtpattern );
if ( attrs == NULL ) {
fprintf( stderr, _("All userApplication attributes") );
} else {
for ( i = 0; attrs[ i ] != NULL; ++i ) {
fprintf( stderr, "%s ", attrs[ i ] );
}
}
fprintf( stderr, "\n" );
}
if ( ldif == 0 ) {
printf( _("# extended LDIF\n") );
} else if ( ldif < 3 ) {
printf( _("version: %d\n\n"), 1 );
}
if (ldif < 2 ) {
char *realbase = base;
if ( realbase == NULL ) {
ldap_get_option( ld, LDAP_OPT_DEFBASE, (void **)(char *)&realbase );
}
printf( "#\n" );
printf(_("# LDAPv%d\n"), protocol);
printf(_("# base <%s>%s with scope %s\n"),
realbase ? realbase : "",
( realbase == NULL || realbase != base ) ? " (default)" : "",
((scope == LDAP_SCOPE_BASE) ? "baseObject"
: ((scope == LDAP_SCOPE_ONELEVEL) ? "oneLevel"
: ((scope == LDAP_SCOPE_SUBORDINATE) ? "children"
: "subtree" ))));
printf(_("# filter%s: %s\n"), infile != NULL ? _(" pattern") : "",
filtpattern);
printf(_("# requesting: "));
if ( attrs == NULL ) {
printf( _("ALL") );
} else {
for ( i = 0; attrs[ i ] != NULL; ++i ) {
printf( "%s ", attrs[ i ] );
}
}
if ( manageDSAit ) {
printf(_("\n# with manageDSAit %scontrol"),
manageDSAit > 1 ? _("critical ") : "" );
}
if ( noop ) {
printf(_("\n# with noop %scontrol"),
noop > 1 ? _("critical ") : "" );
}
if ( subentries ) {
printf(_("\n# with subentries %scontrol: %s"),
subentries < 0 ? _("critical ") : "",
abs(subentries) == 1 ? "false" : "true" );
}
if ( valuesReturnFilter ) {
printf(_("\n# with valuesReturnFilter %scontrol: %s"),
valuesReturnFilter > 1 ? _("critical ") : "", vrFilter );
}
if ( pagedResults ) {
printf(_("\n# with pagedResults %scontrol: size=%d"),
(pagedResults > 1) ? _("critical ") : "",
pageSize );
}
if ( sss ) {
printf(_("\n# with server side sorting %scontrol"),
sss > 1 ? _("critical ") : "" );
}
if ( vlv ) {
printf(_("\n# with virtual list view %scontrol: %d/%d"),
vlv > 1 ? _("critical ") : "",
vlvInfo.ldvlv_before_count, vlvInfo.ldvlv_after_count);
if ( vlvInfo.ldvlv_attrvalue )
printf(":%s", vlvInfo.ldvlv_attrvalue->bv_val );
else
printf("/%d/%d", vlvInfo.ldvlv_offset, vlvInfo.ldvlv_count );
}
#ifdef LDAP_CONTROL_X_DEREF
if ( derefcrit ) {
printf(_("\n# with dereference %scontrol"),
derefcrit > 1 ? _("critical ") : "" );
}
#endif
printf( _("\n#\n\n") );
if ( realbase && realbase != base ) {
ldap_memfree( realbase );
}
}
if ( infile == NULL ) {
rc = dosearch( ld, base, scope, NULL, filtpattern,
attrs, attrsonly, NULL, NULL, NULL, sizelimit );
} else {
rc = 0;
first = 1;
while ( fgets( line, sizeof( line ), fp ) != NULL ) {
line[ strlen( line ) - 1 ] = '\0';
if ( !first ) {
putchar( '\n' );
} else {
first = 0;
}
rc1 = dosearch( ld, base, scope, filtpattern, line,
attrs, attrsonly, NULL, NULL, NULL, sizelimit );
if ( rc1 != 0 ) {
rc = rc1;
if ( !contoper )
break;
}
}
if ( fp != stdin ) {
fclose( fp );
fp = NULL;
}
}
if (( rc == LDAP_SUCCESS ) && pageSize && pr_morePagedResults ) {
char buf[12];
int i, moreEntries, tmpSize;
/* Loop to get the next pages when
* enter is pressed on the terminal.
*/
if ( pagePrompt != 0 ) {
if ( entriesLeft > 0 ) {
printf( _("Estimate entries: %d\n"), entriesLeft );
}
printf( _("Press [size] Enter for the next {%d|size} entries.\n"),
(int)pageSize );
i = 0;
moreEntries = getchar();
while ( moreEntries != EOF && moreEntries != '\n' ) {
if ( i < (int)sizeof(buf) - 1 ) {
buf[i] = moreEntries;
i++;
}
moreEntries = getchar();
}
buf[i] = '\0';
if ( i > 0 && isdigit( (unsigned char)buf[0] ) ) {
int num = sscanf( buf, "%d", &tmpSize );
if ( num != 1 ) {
fprintf( stderr,
_("Invalid value for PagedResultsControl, %s.\n"), buf);
tool_exit( ld, EXIT_FAILURE );
}
pageSize = (ber_int_t)tmpSize;
}
}
goto getNextPage;
}
if (( rc == LDAP_SUCCESS ) && vlv ) {
char buf[BUFSIZ];
int i, moreEntries;
/* Loop to get the next window when
* enter is pressed on the terminal.
*/
printf( _("Press [before/after(/offset/count|:value)] Enter for the next window.\n"));
i = 0;
moreEntries = getchar();
while ( moreEntries != EOF && moreEntries != '\n' ) {
if ( i < (int)sizeof(buf) - 1 ) {
buf[i] = moreEntries;
i++;
}
moreEntries = getchar();
}
buf[i] = '\0';
if ( buf[0] ) {
i = parse_vlv( strdup( buf ));
if ( i )
tool_exit( ld, EXIT_FAILURE );
} else {
vlvInfo.ldvlv_attrvalue = NULL;
vlvInfo.ldvlv_count = vlvCount;
vlvInfo.ldvlv_offset += vlvInfo.ldvlv_after_count;
}
if ( vlvInfo.ldvlv_context )
ber_bvfree( vlvInfo.ldvlv_context );
vlvInfo.ldvlv_context = vlvContext;
goto getNextPage;
}
if ( base != NULL ) {
ber_memfree( base );
}
if ( control != NULL ) {
ber_memfree( control );
}
if ( sss_keys != NULL ) {
ldap_free_sort_keylist( sss_keys );
}
if ( derefval.bv_val != NULL ) {
ldap_memfree( derefval.bv_val );
}
if ( urlpre != NULL ) {
if ( def_urlpre != urlpre )
free( def_urlpre );
free( urlpre );
}
if ( c ) {
for ( ; save_nctrls-- > 0; ) {
ber_memfree( c[ save_nctrls ].ldctl_value.bv_val );
}
free( c );
c = NULL;
}
tool_exit( ld, rc );
}
static int dosearch(
LDAP *ld,
char *base,
int scope,
char *filtpatt,
char *value,
char **attrs,
int attrsonly,
LDAPControl **sctrls,
LDAPControl **cctrls,
struct timeval *timeout,
int sizelimit )
{
char *filter;
int rc, rc2 = LDAP_OTHER;
int nresponses;
int nentries;
int nreferences;
int nextended;
int npartial;
LDAPMessage *res, *msg;
ber_int_t msgid;
char *retoid = NULL;
struct berval *retdata = NULL;
int nresponses_psearch = -1;
int cancel_msgid = -1;
struct timeval tv, *tvp = NULL;
struct timeval tv_timelimit, *tv_timelimitp = NULL;
if( filtpatt != NULL ) {
size_t max_fsize = strlen( filtpatt ) + strlen( value ) + 1, outlen;
filter = malloc( max_fsize );
if( filter == NULL ) {
perror( "malloc" );
return EXIT_FAILURE;
}
outlen = snprintf( filter, max_fsize, filtpatt, value );
if( outlen >= max_fsize ) {
fprintf( stderr, "Bad filter pattern: \"%s\"\n", filtpatt );
free( filter );
return EXIT_FAILURE;
}
if ( verbose ) {
fprintf( stderr, _("filter: %s\n"), filter );
}
if( ldif < 2 ) {
printf( _("#\n# filter: %s\n#\n"), filter );
}
} else {
filter = value;
}
if ( dont ) {
if ( filtpatt != NULL ) {
free( filter );
}
return LDAP_SUCCESS;
}
if ( timelimit > 0 ) {
tv_timelimit.tv_sec = timelimit;
tv_timelimit.tv_usec = 0;
tv_timelimitp = &tv_timelimit;
}
rc = ldap_search_ext( ld, base, scope, filter, attrs, attrsonly,
sctrls, cctrls, tv_timelimitp, sizelimit, &msgid );
if ( filtpatt != NULL ) {
free( filter );
}
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_search_ext", rc, NULL, NULL, NULL, NULL );
return( rc );
}
nresponses = nentries = nreferences = nextended = npartial = 0;
res = NULL;
if ( timelimit > 0 ) {
/* disable timeout */
tv.tv_sec = -1;
tv.tv_usec = 0;
tvp = &tv;
}
while ((rc = ldap_result( ld, LDAP_RES_ANY,
sortattr ? LDAP_MSG_ALL : LDAP_MSG_ONE,
tvp, &res )) > 0 )
{
if ( tool_check_abandon( ld, msgid ) ) {
return -1;
}
if( sortattr ) {
(void) ldap_sort_entries( ld, &res,
( *sortattr == '\0' ) ? NULL : sortattr, strcasecmp );
}
for ( msg = ldap_first_message( ld, res );
msg != NULL;
msg = ldap_next_message( ld, msg ) )
{
if ( nresponses++ ) putchar('\n');
if ( nresponses_psearch >= 0 )
nresponses_psearch++;
switch( ldap_msgtype( msg ) ) {
case LDAP_RES_SEARCH_ENTRY:
nentries++;
print_entry( ld, msg, attrsonly );
break;
case LDAP_RES_SEARCH_REFERENCE:
nreferences++;
print_reference( ld, msg );
break;
case LDAP_RES_EXTENDED:
nextended++;
print_extended( ld, msg );
if ( ldap_msgid( msg ) == 0 ) {
/* unsolicited extended operation */
goto done;
}
if ( cancel_msgid != -1 &&
cancel_msgid == ldap_msgid( msg ) ) {
printf(_("Cancelled \n"));
printf(_("cancel_msgid = %d\n"), cancel_msgid);
goto done;
}
break;
case LDAP_RES_SEARCH_RESULT:
/* pagedResults stuff is dealt with
* in tool_print_ctrls(), called by
* print_results(). */
rc2 = print_result( ld, msg, 1 );
if ( ldapsync == LDAP_SYNC_REFRESH_AND_PERSIST ) {
break;
}
goto done;
case LDAP_RES_INTERMEDIATE:
npartial++;
ldap_parse_intermediate( ld, msg,
&retoid, &retdata, NULL, 0 );
nresponses_psearch = 0;
if ( strcmp( retoid, LDAP_SYNC_INFO ) == 0 ) {
printf(_("# SyncInfo Received\n"));
ldap_memfree( retoid );
ber_bvfree( retdata );
break;
}
print_partial( ld, msg );
ldap_memfree( retoid );
ber_bvfree( retdata );
goto done;
}
if ( ldapsync && sync_slimit != -1 &&
nresponses_psearch >= sync_slimit ) {
BerElement *msgidber = NULL;
struct berval *msgidvalp = NULL;
msgidber = ber_alloc_t(LBER_USE_DER);
ber_printf(msgidber, "{i}", msgid);
ber_flatten(msgidber, &msgidvalp);
ldap_extended_operation(ld, LDAP_EXOP_CANCEL,
msgidvalp, NULL, NULL, &cancel_msgid);
nresponses_psearch = -1;
}
}
ldap_msgfree( res );
fflush( stdout );
}
done:
if ( tvp == NULL && rc != LDAP_RES_SEARCH_RESULT ) {
ldap_get_option( ld, LDAP_OPT_RESULT_CODE, (void *)&rc2 );
}
ldap_msgfree( res );
if ( pagedResults ) {
npagedresponses += nresponses;
npagedentries += nentries;
npagedextended += nextended;
npagedpartial += npartial;
npagedreferences += nreferences;
if ( ( pr_morePagedResults == 0 ) && ( ldif < 2 ) ) {
printf( _("\n# numResponses: %d\n"), npagedresponses );
if( npagedentries ) {
printf( _("# numEntries: %d\n"), npagedentries );
}
if( npagedextended ) {
printf( _("# numExtended: %d\n"), npagedextended );
}
if( npagedpartial ) {
printf( _("# numPartial: %d\n"), npagedpartial );
}
if( npagedreferences ) {
printf( _("# numReferences: %d\n"), npagedreferences );
}
}
} else if ( ldif < 2 ) {
printf( _("\n# numResponses: %d\n"), nresponses );
if( nentries ) printf( _("# numEntries: %d\n"), nentries );
if( nextended ) printf( _("# numExtended: %d\n"), nextended );
if( npartial ) printf( _("# numPartial: %d\n"), npartial );
if( nreferences ) printf( _("# numReferences: %d\n"), nreferences );
}
if ( rc != LDAP_RES_SEARCH_RESULT ) {
tool_perror( "ldap_result", rc2, NULL, NULL, NULL, NULL );
}
return( rc2 );
}
/* This is the proposed new way of doing things.
* It is more efficient, but the API is non-standard.
*/
static void
print_entry(
LDAP *ld,
LDAPMessage *entry,
int attrsonly)
{
char *ufn = NULL;
char tmpfname[ 256 ];
char url[ 256 ];
int i, rc;
BerElement *ber = NULL;
struct berval bv, *bvals, **bvp = &bvals;
LDAPControl **ctrls = NULL;
FILE *tmpfp;
rc = ldap_get_dn_ber( ld, entry, &ber, &bv );
if ( ldif < 2 ) {
ufn = ldap_dn2ufn( bv.bv_val );
tool_write_ldif( LDIF_PUT_COMMENT, NULL, ufn, ufn ? strlen( ufn ) : 0 );
}
tool_write_ldif( LDIF_PUT_VALUE, "dn", bv.bv_val, bv.bv_len );
rc = ldap_get_entry_controls( ld, entry, &ctrls );
if( rc != LDAP_SUCCESS ) {
fprintf(stderr, _("print_entry: %d\n"), rc );
tool_perror( "ldap_get_entry_controls", rc, NULL, NULL, NULL, NULL );
tool_exit( ld, EXIT_FAILURE );
}
if( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
if ( includeufn ) {
if( ufn == NULL ) {
ufn = ldap_dn2ufn( bv.bv_val );
}
tool_write_ldif( LDIF_PUT_VALUE, "ufn", ufn, ufn ? strlen( ufn ) : 0 );
}
if( ufn != NULL ) ldap_memfree( ufn );
if ( attrsonly ) bvp = NULL;
for ( rc = ldap_get_attribute_ber( ld, entry, ber, &bv, bvp );
rc == LDAP_SUCCESS;
rc = ldap_get_attribute_ber( ld, entry, ber, &bv, bvp ) )
{
if (bv.bv_val == NULL) break;
if ( attrsonly ) {
tool_write_ldif( LDIF_PUT_NOVALUE, bv.bv_val, NULL, 0 );
} else if ( bvals ) {
for ( i = 0; bvals[i].bv_val != NULL; i++ ) {
if ( vals2tmp > 1 || ( vals2tmp &&
ldif_is_not_printable( bvals[i].bv_val, bvals[i].bv_len )))
{
int tmpfd;
/* write value to file */
snprintf( tmpfname, sizeof tmpfname,
"%s" LDAP_DIRSEP "ldapsearch-%s-XXXXXX",
tmpdir, bv.bv_val );
tmpfp = NULL;
tmpfd = mkstemp( tmpfname );
if ( tmpfd < 0 ) {
perror( tmpfname );
continue;
}
if (( tmpfp = fdopen( tmpfd, "w")) == NULL ) {
perror( tmpfname );
continue;
}
if ( fwrite( bvals[ i ].bv_val,
bvals[ i ].bv_len, 1, tmpfp ) == 0 )
{
perror( tmpfname );
fclose( tmpfp );
continue;
}
fclose( tmpfp );
snprintf( url, sizeof url, "%s%s", urlpre,
&tmpfname[strlen(tmpdir) + sizeof(LDAP_DIRSEP) - 1] );
urlize( url );
tool_write_ldif( LDIF_PUT_URL, bv.bv_val, url, strlen( url ));
} else {
tool_write_ldif( LDIF_PUT_VALUE, bv.bv_val,
bvals[ i ].bv_val, bvals[ i ].bv_len );
}
}
ber_memfree( bvals );
}
}
if( ber != NULL ) {
ber_free( ber, 0 );
}
}
static void print_reference(
LDAP *ld,
LDAPMessage *reference )
{
int rc;
char **refs = NULL;
LDAPControl **ctrls;
if( ldif < 2 ) {
printf(_("# search reference\n"));
}
rc = ldap_parse_reference( ld, reference, &refs, &ctrls, 0 );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_reference", rc, NULL, NULL, NULL, NULL );
tool_exit( ld, EXIT_FAILURE );
}
if( refs ) {
int i;
for( i=0; refs[i] != NULL; i++ ) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"ref", refs[i], strlen(refs[i]) );
}
ber_memvfree( (void **) refs );
}
if( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
}
static void print_extended(
LDAP *ld,
LDAPMessage *extended )
{
int rc;
char *retoid = NULL;
struct berval *retdata = NULL;
if( ldif < 2 ) {
printf(_("# extended result response\n"));
}
rc = ldap_parse_extended_result( ld, extended,
&retoid, &retdata, 0 );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL );
tool_exit( ld, EXIT_FAILURE );
}
if ( ldif < 2 ) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"extended", retoid, retoid ? strlen(retoid) : 0 );
}
ber_memfree( retoid );
if(retdata) {
if ( ldif < 2 ) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_BINARY,
"data", retdata->bv_val, retdata->bv_len );
}
ber_bvfree( retdata );
}
print_result( ld, extended, 0 );
}
static void print_partial(
LDAP *ld,
LDAPMessage *partial )
{
int rc;
char *retoid = NULL;
struct berval *retdata = NULL;
LDAPControl **ctrls = NULL;
if( ldif < 2 ) {
printf(_("# extended partial response\n"));
}
rc = ldap_parse_intermediate( ld, partial,
&retoid, &retdata, &ctrls, 0 );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_intermediate", rc, NULL, NULL, NULL, NULL );
tool_exit( ld, EXIT_FAILURE );
}
if ( ldif < 2 ) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"partial", retoid, retoid ? strlen(retoid) : 0 );
}
ber_memfree( retoid );
if( retdata ) {
if ( ldif < 2 ) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_BINARY,
"data", retdata->bv_val, retdata->bv_len );
}
ber_bvfree( retdata );
}
if( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
}
static int print_result(
LDAP *ld,
LDAPMessage *result, int search )
{
int rc;
int err;
char *matcheddn = NULL;
char *text = NULL;
char **refs = NULL;
LDAPControl **ctrls = NULL;
if( search ) {
if ( ldif < 2 ) {
printf(_("# search result\n"));
}
if ( ldif < 1 ) {
printf("%s: %d\n", _("search"), ldap_msgid(result) );
}
}
rc = ldap_parse_result( ld, result,
&err, &matcheddn, &text, &refs, &ctrls, 0 );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_result", rc, NULL, NULL, NULL, NULL );
tool_exit( ld, EXIT_FAILURE );
}
if( !ldif ) {
printf( _("result: %d %s\n"), err, ldap_err2string(err) );
} else if ( err != LDAP_SUCCESS ) {
fprintf( stderr, "%s (%d)\n", ldap_err2string(err), err );
}
if( matcheddn ) {
if( *matcheddn ) {
if( !ldif ) {
tool_write_ldif( LDIF_PUT_VALUE,
"matchedDN", matcheddn, strlen(matcheddn) );
} else {
fprintf( stderr, _("Matched DN: %s\n"), matcheddn );
}
}
ber_memfree( matcheddn );
}
if( text ) {
if( *text ) {
if( !ldif ) {
if ( err == LDAP_PARTIAL_RESULTS ) {
char *line;
for ( line = text; line != NULL; ) {
char *next = strchr( line, '\n' );
tool_write_ldif( LDIF_PUT_TEXT,
"text", line,
next ? (size_t) (next - line) : strlen( line ));
line = next ? next + 1 : NULL;
}
} else {
tool_write_ldif( LDIF_PUT_TEXT, "text",
text, strlen(text) );
}
} else {
fprintf( stderr, _("Additional information: %s\n"), text );
}
}
ber_memfree( text );
}
if( refs ) {
int i;
for( i=0; refs[i] != NULL; i++ ) {
if( !ldif ) {
tool_write_ldif( LDIF_PUT_VALUE, "ref", refs[i], strlen(refs[i]) );
} else {
fprintf( stderr, _("Referral: %s\n"), refs[i] );
}
}
ber_memvfree( (void **) refs );
}
pr_morePagedResults = 0;
if( ctrls ) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
return err;
}
/* ldapurl -- a tool for generating LDAP URLs */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 2008-2020 The OpenLDAP Foundation.
* Portions Copyright 2008 Pierangelo Masarati, SysNet
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by Pierangelo Masarati
* for inclusion in OpenLDAP software.
*/
#include "portable.h"
#include <ac/stdlib.h>
#include <stdio.h>
#include <ac/unistd.h>
#include "ldap.h"
#include "ldap_pvt.h"
#include "lutil.h"
static int
usage(void)
{
fprintf( stderr, _("usage: %s [options]\n\n"), "ldapurl" );
fprintf( stderr, _("generates RFC 4516 LDAP URL with extensions\n\n" ) );
fprintf( stderr, _("URL options:\n"));
fprintf( stderr, _(" -a attrs comma separated list of attributes\n" ) );
fprintf( stderr, _(" -b base (RFC 4514 LDAP DN)\n" ) );
fprintf( stderr, _(" -E ext (format: \"ext=value\"; multiple occurrences allowed)\n" ) );
fprintf( stderr, _(" -f filter (RFC 4515 LDAP filter)\n" ) );
fprintf( stderr, _(" -h host \n" ) );
fprintf( stderr, _(" -p port (default: 389 for ldap, 636 for ldaps)\n" ) );
fprintf( stderr, _(" -s scope (RFC 4511 searchScope and extensions)\n" ) );
fprintf( stderr, _(" -S scheme (RFC 4516 LDAP URL scheme and extensions)\n" ) );
exit( EXIT_FAILURE );
}
static int
do_uri_create( LDAPURLDesc *lud )
{
char *uri;
if ( lud->lud_scheme == NULL ) {
lud->lud_scheme = "ldap";
}
if ( lud->lud_port == -1 ) {
if ( strcasecmp( lud->lud_scheme, "ldap" ) == 0 ) {
lud->lud_port = LDAP_PORT;
} else if ( strcasecmp( lud->lud_scheme, "ldaps" ) == 0 ) {
lud->lud_port = LDAPS_PORT;
} else if ( strcasecmp( lud->lud_scheme, "ldapi" ) == 0 ) {
lud->lud_port = 0;
} else {
/* forgiving... */
lud->lud_port = 0;
}
}
if ( lud->lud_scope == -1 ) {
lud->lud_scope = LDAP_SCOPE_DEFAULT;
}
uri = ldap_url_desc2str( lud );
if ( lud->lud_attrs != NULL ) {
ldap_charray_free( lud->lud_attrs );
lud->lud_attrs = NULL;
}
if ( lud->lud_exts != NULL ) {
free( lud->lud_exts );
lud->lud_exts = NULL;
}
if ( uri == NULL ) {
fprintf( stderr, "unable to generate URI\n" );
exit( EXIT_FAILURE );
}
printf( "%s\n", uri );
free( uri );
return 0;
}
static int
do_uri_explode( const char *uri )
{
LDAPURLDesc *lud;
int rc;
rc = ldap_url_parse( uri, &lud );
if ( rc != LDAP_URL_SUCCESS ) {
fprintf( stderr, "unable to parse URI \"%s\"\n", uri );
return 1;
}
if ( lud->lud_scheme != NULL && lud->lud_scheme[0] != '\0' ) {
printf( "scheme: %s\n", lud->lud_scheme );
}
if ( lud->lud_host != NULL && lud->lud_host[0] != '\0' ) {
printf( "host: %s\n", lud->lud_host );
}
if ( lud->lud_port != 0 ) {
printf( "port: %d\n", lud->lud_port );
}
if ( lud->lud_dn != NULL && lud->lud_dn[0] != '\0' ) {
printf( "dn: %s\n", lud->lud_dn );
}
if ( lud->lud_attrs != NULL ) {
int i;
for ( i = 0; lud->lud_attrs[i] != NULL; i++ ) {
printf( "selector: %s\n", lud->lud_attrs[i] );
}
}
if ( lud->lud_scope != LDAP_SCOPE_DEFAULT ) {
printf( "scope: %s\n", ldap_pvt_scope2str( lud->lud_scope ) );
}
if ( lud->lud_filter != NULL && lud->lud_filter[0] != '\0' ) {
printf( "filter: %s\n", lud->lud_filter );
}
if ( lud->lud_exts != NULL ) {
int i;
for ( i = 0; lud->lud_exts[i] != NULL; i++ ) {
printf( "extension: %s\n", lud->lud_exts[i] );
}
}
ldap_free_urldesc( lud );
return 0;
}
int
main( int argc, char *argv[])
{
LDAPURLDesc lud = { 0 };
char *uri = NULL;
int gotlud = 0;
int nexts = 0;
lud.lud_port = -1;
lud.lud_scope = -1;
while ( 1 ) {
int opt = getopt( argc, argv, "S:h:p:b:a:s:f:E:H:" );
if ( opt == EOF ) {
break;
}
if ( opt == 'H' ) {
if ( gotlud ) {
fprintf( stderr, "option -H incompatible with previous options\n" );
usage();
}
if ( uri != NULL ) {
fprintf( stderr, "URI already provided\n" );
usage();
}
uri = optarg;
continue;
}
switch ( opt ) {
case 'S':
case 'h':
case 'p':
case 'b':
case 'a':
case 's':
case 'f':
case 'E':
if ( uri != NULL ) {
fprintf( stderr, "option -%c incompatible with -H\n", opt );
usage();
}
gotlud++;
}
switch ( opt ) {
case 'S':
if ( lud.lud_scheme != NULL ) {
fprintf( stderr, "scheme already provided\n" );
usage();
}
lud.lud_scheme = optarg;
break;
case 'h':
if ( lud.lud_host != NULL ) {
fprintf( stderr, "host already provided\n" );
usage();
}
lud.lud_host = optarg;
break;
case 'p':
if ( lud.lud_port != -1 ) {
fprintf( stderr, "port already provided\n" );
usage();
}
if ( lutil_atoi( &lud.lud_port, optarg ) ) {
fprintf( stderr, "unable to parse port \"%s\"\n", optarg );
usage();
}
break;
case 'b':
if ( lud.lud_dn != NULL ) {
fprintf( stderr, "base already provided\n" );
usage();
}
lud.lud_dn = optarg;
break;
case 'a':
if ( lud.lud_attrs != NULL ) {
fprintf( stderr, "attrs already provided\n" );
usage();
}
lud.lud_attrs = ldap_str2charray( optarg, "," );
if ( lud.lud_attrs == NULL ) {
fprintf( stderr, "unable to parse attrs list \"%s\"\n", optarg );
usage();
}
break;
case 's':
if ( lud.lud_scope != -1 ) {
fprintf( stderr, "scope already provided\n" );
usage();
}
lud.lud_scope = ldap_pvt_str2scope( optarg );
if ( lud.lud_scope == -1 ) {
fprintf( stderr, "unable to parse scope \"%s\"\n", optarg );
usage();
}
break;
case 'f':
if ( lud.lud_filter != NULL ) {
fprintf( stderr, "filter already provided\n" );
usage();
}
lud.lud_filter = optarg;
break;
case 'E':
lud.lud_exts = (char **)realloc( lud.lud_exts,
sizeof( char * ) * ( nexts + 2 ) );
lud.lud_exts[ nexts++ ] = optarg;
lud.lud_exts[ nexts ] = NULL;
break;
default:
assert( opt != 'H' );
usage();
}
}
if ( uri != NULL ) {
return do_uri_explode( uri );
}
return do_uri_create( &lud );
}
/* ldapwhoami.c -- a tool for asking the directory "Who Am I?" */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 1998-2001 Net Boolean Incorporated.
* Portions Copyright 2001-2003 IBM Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*/
/* ACKNOWLEDGEMENTS:
* This work was originally developed by Kurt D. Zeilenga for inclusion
* in OpenLDAP Software based, in part, on other client tools.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ldap.h>
#include "lutil.h"
#include "lutil_ldap.h"
#include "ldap_defaults.h"
#include "common.h"
void
usage( void )
{
fprintf( stderr, _("Issue LDAP Who am I? operation to request user's authzid\n\n"));
fprintf( stderr, _("usage: %s [options]\n"), prog);
tool_common_usage();
exit( EXIT_FAILURE );
}
const char options[] = ""
"d:D:e:h:H:InNO:o:p:QR:U:vVw:WxX:y:Y:Z";
int
handle_private_option( int i )
{
switch ( i ) {
#if 0
char *control, *cvalue;
int crit;
case 'E': /* whoami extension */
if( protocol == LDAP_VERSION2 ) {
fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
prog, protocol );
exit( EXIT_FAILURE );
}
/* should be extended to support comma separated list of
* [!]key[=value] parameters, e.g. -E !foo,bar=567
*/
crit = 0;
cvalue = NULL;
if( optarg[0] == '!' ) {
crit = 1;
optarg++;
}
control = strdup( optarg );
if ( (cvalue = strchr( control, '=' )) != NULL ) {
*cvalue++ = '\0';
}
fprintf( stderr, _("Invalid whoami extension name: %s\n"), control );
usage();
#endif
default:
return 0;
}
return 1;
}
int
main( int argc, char *argv[] )
{
int rc;
LDAP *ld = NULL;
char *matcheddn = NULL, *text = NULL, **refs = NULL;
struct berval *authzid = NULL;
int id, code = 0;
LDAPMessage *res = NULL;
LDAPControl **ctrls = NULL;
tool_init( TOOL_WHOAMI );
prog = lutil_progname( "ldapwhoami", argc, argv );
/* LDAPv3 only */
protocol = LDAP_VERSION3;
tool_args( argc, argv );
if( argc - optind > 0 ) {
usage();
}
ld = tool_conn_setup( 0, 0 );
tool_bind( ld );
if ( dont ) {
rc = LDAP_SUCCESS;
goto skip;
}
tool_server_controls( ld, NULL, 0 );
rc = ldap_whoami( ld, NULL, NULL, &id );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_whoami", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
for ( ; ; ) {
struct timeval tv;
if ( tool_check_abandon( ld, id ) ) {
tool_exit( ld, LDAP_CANCELLED );
}
tv.tv_sec = 0;
tv.tv_usec = 100000;
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
if ( rc < 0 ) {
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
tool_exit( ld, rc );
}
if ( rc != 0 ) {
break;
}
}
rc = ldap_parse_result( ld, res,
&code, &matcheddn, &text, &refs, &ctrls, 0 );
if ( rc == LDAP_SUCCESS ) {
rc = code;
}
if ( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_result", rc, NULL, matcheddn, text, refs );
rc = EXIT_FAILURE;
goto skip;
}
rc = ldap_parse_whoami( ld, res, &authzid );
if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_whoami", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE;
goto skip;
}
if( authzid != NULL ) {
if( authzid->bv_len == 0 ) {
printf(_("anonymous\n") );
} else {
printf("%s\n", authzid->bv_val );
}
}
skip:
ldap_msgfree(res);
if ( verbose || code != LDAP_SUCCESS ||
( matcheddn && *matcheddn ) || ( text && *text ) || refs || ctrls )
{
printf( _("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] );
}
}
if (ctrls) {
tool_print_ctrls( ld, ctrls );
ldap_controls_free( ctrls );
}
}
ber_memfree( text );
ber_memfree( matcheddn );
ber_memvfree( (void **) refs );
ber_bvfree( authzid );
/* disconnect from server */
tool_exit( ld, code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE );
}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
dnl $OpenLDAP$
dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
dnl
dnl Copyright 1998-2020 The OpenLDAP Foundation.
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.
dnl
dnl A copy of this license is available in the file LICENSE in the
dnl top-level directory of the distribution or, alternatively, at
dnl <http://www.OpenLDAP.org/license.html>.
dnl
dnl ----------------------------------------------------------------
dnl Disable config.cache!
define([AC_CACHE_LOAD], )dnl
define([AC_CACHE_SAVE], )dnl
dnl ----------------------------------------------------------------
dnl Disable libtool 1.5 support for languages we don't use
define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
define([AC_LIBTOOL_LANG_GCJ_CONFIG], [:])dnl
dnl ================================================================
dnl Configure.in for OpenLDAP
AC_COPYRIGHT([[Copyright 1998-2020 The OpenLDAP Foundation. All rights reserved.
Restrictions apply, see COPYRIGHT and LICENSE files.]])
AC_REVISION([$Id$])
AC_INIT([OpenLDAP],,[http://www.openldap.org/its/])
m4_define([AC_PACKAGE_BUGREPORT],[<http://www.openldap.org/its/>])
AC_CONFIG_SRCDIR(build/version.sh)dnl
dnl ----------------------------------------------------------------
dnl OpenLDAP Autoconf Macros
builtin(include, build/openldap.m4)dnl
dnl ================================================================
AC_CONFIG_AUX_DIR(build)dnl
eval `$ac_aux_dir/version.sh`
if test -z "$OL_STRING"; then
AC_MSG_ERROR([could not determine version])
fi
if test -f "$ac_aux_dir/shtool" && test ! -d $ac_aux_dir/shtool; then
ac_cv_shtool="$ac_aux_dir/shtool"
else
AC_MSG_ERROR([no shtool found in $ac_aux_dir])
fi
SHTOOL="$ac_cv_shtool"
dnl AC_SUBST(SHTOOL)dnl
TB="" TN=""
if test -t 1; then
TB="`$SHTOOL echo -e '%B' 2>/dev/null`"
TN="`$SHTOOL echo -e '%b' 2>/dev/null`"
fi
OPENLDAP_REPO=""
if test -d $ac_aux_dir/../.git; then
OPENLDAP_REPO="(from Git clone) "
elif test -d $ac_aux_dir/CVS; then
OPENLDAP_REPO="(from CVS checkout) "
fi
echo "Configuring ${TB}${OL_STRING}${TN} ${OPENLDAP_REPO}..."
dnl Determine host platform
dnl we try not to use this for much
AC_CANONICAL_TARGET([])
AM_INIT_AUTOMAKE([$OL_PACKAGE],[$OL_VERSION], [no defines])dnl
AC_SUBST(PACKAGE)dnl
AC_SUBST(VERSION)dnl
AC_DEFINE_UNQUOTED(OPENLDAP_PACKAGE,"$PACKAGE",Package)
AC_DEFINE_UNQUOTED(OPENLDAP_VERSION,"$VERSION",Version)
AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION,$OL_API_INC,Version)
AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_MAJOR,$OL_MAJOR,Major)
AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_MINOR,$OL_MINOR,Minor)
AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_PATCH,$OL_PATCH,Patch)
OPENLDAP_LIBRELEASE=$OL_API_LIB_RELEASE
AC_SUBST(OPENLDAP_LIBRELEASE)dnl
OPENLDAP_LIBVERSION=$OL_API_LIB_VERSION
AC_SUBST(OPENLDAP_LIBVERSION)dnl
OPENLDAP_RELEASE_DATE="$OL_RELEASE_DATE"
AC_SUBST(OPENLDAP_RELEASE_DATE)dnl
dnl We use autoconf features new to 2.59. Later versions like won't work.
dnl aclocal.m4 should be built using aclocal from automake 1.5
dnl libtool 1.5 should be installed.
AC_PREREQ(2.59)dnl Required Autoconf version
AH_TOP([
/* begin of portable.h.pre */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
#ifndef _LDAP_PORTABLE_H
#define _LDAP_PORTABLE_H
/* define this if needed to get reentrant functions */
#ifndef REENTRANT
#undef REENTRANT
#endif
#ifndef _REENTRANT
#undef _REENTRANT
#endif
/* define this if needed to get threadsafe functions */
#ifndef THREADSAFE
#undef THREADSAFE
#endif
#ifndef _THREADSAFE
#undef _THREADSAFE
#endif
#ifndef THREAD_SAFE
#undef THREAD_SAFE
#endif
#ifndef _THREAD_SAFE
#undef _THREAD_SAFE
#endif
#ifndef _SGI_MP_SOURCE
#undef _SGI_MP_SOURCE
#endif
/* end of portable.h.pre */
])
AH_BOTTOM([
/* begin of portable.h.post */
#ifdef _WIN32
/* don't suck in all of the win32 api */
# define WIN32_LEAN_AND_MEAN 1
#endif
#ifndef LDAP_NEEDS_PROTOTYPES
/* force LDAP_P to always include prototypes */
#define LDAP_NEEDS_PROTOTYPES 1
#endif
#ifndef LDAP_REL_ENG
#if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL)
#define LDAP_DEVEL
#endif
#if defined(LDAP_DEVEL) && !defined(LDAP_TEST)
#define LDAP_TEST
#endif
#endif
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif
#ifdef HAVE_EBCDIC
/* ASCII/EBCDIC converting replacements for stdio funcs
* vsnprintf and snprintf are used too, but they are already
* checked by the configure script
*/
#define fputs ber_pvt_fputs
#define fgets ber_pvt_fgets
#define printf ber_pvt_printf
#define fprintf ber_pvt_fprintf
#define vfprintf ber_pvt_vfprintf
#define vsprintf ber_pvt_vsprintf
#endif
#include "ac/fdset.h"
#include "ldap_cdefs.h"
#include "ldap_features.h"
#include "ac/assert.h"
#include "ac/localize.h"
#endif /* _LDAP_PORTABLE_H */
/* end of portable.h.post */
])
AC_CONFIG_HEADERS([include/portable.h:include/portable.hin])
AC_CONFIG_HEADERS([include/ldap_features.h:include/ldap_features.hin])
AC_CONFIG_HEADERS([include/lber_types.h:include/lber_types.hin])
dnl ================================================================
dnl Start Args
AC_MSG_CHECKING(configure arguments)
AC_PREFIX_DEFAULT(/usr/local)
top_builddir=`pwd`
AC_SUBST(top_builddir)dnl
dnl ----------------------------------------------------------------
dnl --with-subdir
ldap_subdir="/openldap"
AC_ARG_WITH(subdir,
[ --with-subdir=DIR change default subdirectory used for installs],
[case "$withval" in
no) ldap_subdir=""
;;
yes)
;;
/*|\\*)
ldap_subdir="$withval"
;;
*)
ldap_subdir="/$withval"
;;
esac
])dnl
AC_SUBST(ldap_subdir)dnl
dnl ----------------------------------------------------------------
dnl General "enable" options
dnl set default to traditional to enable the original debug style
OL_ARG_ENABLE(debug,[ --enable-debug enable debugging], yes, [no yes traditional])dnl
OL_ARG_ENABLE(dynamic,[ --enable-dynamic enable linking built binaries with dynamic libs], no)dnl
OL_ARG_ENABLE(syslog,[ --enable-syslog enable syslog support], auto)dnl
OL_ARG_ENABLE(proctitle,[ --enable-proctitle enable proctitle support], yes)dnl
dnl OL_ARG_ENABLE(referrals,[ --enable-referrals enable LDAPv2+ Referrals (experimental)], no)dnl
ol_enable_referrals=${ol_enable_referrals-no}
OL_ARG_ENABLE(ipv6,[ --enable-ipv6 enable IPv6 support], auto)dnl
OL_ARG_ENABLE(local,[ --enable-local enable AF_LOCAL (AF_UNIX) socket support], auto)dnl
dnl ----------------------------------------------------------------
dnl General "with" options
OL_ARG_WITH(cyrus_sasl,[ --with-cyrus-sasl with Cyrus SASL support],
auto, [auto yes no] )
OL_ARG_WITH(fetch,[ --with-fetch with fetch(3) URL support],
auto, [auto yes no] )
OL_ARG_WITH(threads,[ --with-threads with threads],
auto, [auto nt posix mach pth lwp yes no manual] )
OL_ARG_WITH(tls,[ --with-tls with TLS/SSL support auto|openssl|gnutls|moznss],
auto, [auto openssl gnutls moznss yes no] )
OL_ARG_WITH(yielding_select,
[ --with-yielding-select with implicitly yielding select],
auto, [auto yes no manual] )
OL_ARG_WITH(mp,
[ --with-mp with multiple precision statistics auto|longlong|long|bignum|gmp],
auto, [auto longlong long bignum gmp yes no])
OL_ARG_WITH(odbc,
[ --with-odbc with specific ODBC support iodbc|unixodbc|odbc32|auto],
auto, [auto iodbc unixodbc odbc32] )
dnl ----------------------------------------------------------------
dnl Server options
dnl ----------------------------------------------------------------
dnl ----------------------------------------------------------------
dnl SLAPD OPTIONS
AC_ARG_ENABLE(xxslapdoptions,[
SLAPD (Standalone LDAP Daemon) Options:])
OL_ARG_ENABLE(slapd,[ --enable-slapd enable building slapd], yes)dnl
OL_ARG_ENABLE(dynacl,[ --enable-dynacl enable run-time loadable ACL support (experimental)], no)dnl
OL_ARG_ENABLE(aci,[ --enable-aci enable per-object ACIs (experimental)], no, [no yes mod])dnl
OL_ARG_ENABLE(cleartext,[ --enable-cleartext enable cleartext passwords], yes)dnl
OL_ARG_ENABLE(crypt,[ --enable-crypt enable crypt(3) passwords], no)dnl
OL_ARG_ENABLE(lmpasswd,[ --enable-lmpasswd enable LAN Manager passwords], no)dnl
OL_ARG_ENABLE(spasswd,[ --enable-spasswd enable (Cyrus) SASL password verification], no)dnl
OL_ARG_ENABLE(modules,[ --enable-modules enable dynamic module support], no)dnl
OL_ARG_ENABLE(rewrite,[ --enable-rewrite enable DN rewriting in back-ldap and rwm overlay], auto)dnl
OL_ARG_ENABLE(rlookups,[ --enable-rlookups enable reverse lookups of client hostnames], no)dnl
OL_ARG_ENABLE(slapi,[ --enable-slapi enable SLAPI support (experimental)], no)dnl
OL_ARG_ENABLE(slp,[ --enable-slp enable SLPv2 support], no)dnl
OL_ARG_ENABLE(wrappers,[ --enable-wrappers enable tcp wrapper support], no)dnl
dnl ----------------------------------------------------------------
dnl SLAPD Backend Options
Backends="bdb \
dnssrv \
hdb \
ldap \
mdb \
meta \
monitor \
ndb \
null \
passwd \
perl \
relay \
shell \
sock \
sql"
AC_ARG_ENABLE(xxslapbackends,[
SLAPD Backend Options:])
OL_ARG_ENABLE(backends,[ --enable-backends enable all available backends],
--, [no yes mod])dnl
OL_ARG_ENABLE(bdb,[ --enable-bdb enable Berkeley DB backend],
yes, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(dnssrv,[ --enable-dnssrv enable dnssrv backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(hdb,[ --enable-hdb enable Hierarchical DB backend],
yes, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(ldap,[ --enable-ldap enable ldap backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(mdb,[ --enable-mdb enable mdb database backend],
yes, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(meta,[ --enable-meta enable metadirectory backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(monitor,[ --enable-monitor enable monitor backend],
yes, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(ndb,[ --enable-ndb enable MySQL NDB Cluster backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(null,[ --enable-null enable null backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(passwd,[ --enable-passwd enable passwd backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(perl,[ --enable-perl enable perl backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(relay,[ --enable-relay enable relay backend],
yes, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(shell,[ --enable-shell enable shell backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(sock,[ --enable-sock enable sock backend],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(sql,[ --enable-sql enable sql backend],
no, [no yes mod], ol_enable_backends)dnl
dnl ----------------------------------------------------------------
dnl SLAPD Overlay Options
Overlays="accesslog \
auditlog \
collect \
constraint \
dds \
deref \
dyngroup \
dynlist \
memberof \
ppolicy \
proxycache \
refint \
retcode \
rwm \
seqmod \
sssvlv \
syncprov \
translucent \
unique \
valsort"
AC_ARG_ENABLE(xxslapoverlays,[
SLAPD Overlay Options:])
OL_ARG_ENABLE(overlays,[ --enable-overlays enable all available overlays],
--, [no yes mod])dnl
OL_ARG_ENABLE(accesslog,[ --enable-accesslog In-Directory Access Logging overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(auditlog,[ --enable-auditlog Audit Logging overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(collect,[ --enable-collect Collect overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(constraint,[ --enable-constraint Attribute Constraint overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(dds,[ --enable-dds Dynamic Directory Services overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(deref,[ --enable-deref Dereference overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(dyngroup,[ --enable-dyngroup Dynamic Group overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(dynlist,[ --enable-dynlist Dynamic List overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(memberof,[ --enable-memberof Reverse Group Membership overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(ppolicy,[ --enable-ppolicy Password Policy overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(proxycache,[ --enable-proxycache Proxy Cache overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(refint,[ --enable-refint Referential Integrity overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(retcode,[ --enable-retcode Return Code testing overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(rwm,[ --enable-rwm Rewrite/Remap overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(seqmod,[ --enable-seqmod Sequential Modify overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(sssvlv,[ --enable-sssvlv ServerSideSort/VLV overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(syncprov,[ --enable-syncprov Syncrepl Provider overlay],
yes, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(translucent,[ --enable-translucent Translucent Proxy overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(unique,[ --enable-unique Attribute Uniqueness overlay],
no, [no yes mod], ol_enable_overlays)
OL_ARG_ENABLE(valsort,[ --enable-valsort Value Sorting overlay],
no, [no yes mod], ol_enable_overlays)
dnl ----------------------------------------------------------------
AC_ARG_ENABLE(xxliboptions,[
Library Generation & Linking Options])
AC_ENABLE_STATIC
AC_ENABLE_SHARED
dnl ----------------------------------------------------------------
# validate options
if test $ol_enable_slapd = no ; then
dnl SLAPD was specificallly disabled
if test $ol_enable_slapi = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-slapi argument])
fi
case "$ol_enable_backends" in yes | mod)
AC_MSG_WARN([slapd disabled, ignoring --enable-backends argument])
esac
for i in $Backends; do
eval "ol_tmp=\$ol_enable_$i"
if test $ol_tmp != no ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-$i argument])
eval "ol_enable_$i=no"
fi
done
if test $ol_enable_modules = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-modules argument])
fi
if test $ol_enable_wrappers = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-wrappers argument])
fi
if test $ol_enable_rlookups = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-rlookups argument])
fi
if test $ol_enable_dynacl = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-dynacl argument])
fi
if test $ol_enable_aci != no ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-aci argument])
fi
if test $ol_enable_rewrite = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-rewrite argument])
fi
dnl overlays
case "$ol_enable_overlays" in yes | mod)
AC_MSG_WARN([slapd disabled, ignoring --enable-overlays argument])
esac
for i in $Overlays; do
eval "ol_tmp=\$ol_enable_$i"
if test $ol_tmp != no ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-$i argument])
eval "ol_enable_$i=no"
fi
done
# force settings to no
ol_enable_slapi=no
ol_enable_backends=
ol_enable_overlays=
ol_enable_modules=no
ol_enable_rlookups=no
ol_enable_dynacl=no
ol_enable_aci=no
ol_enable_wrappers=no
ol_enable_rewrite=no
elif test $ol_enable_modules != yes &&
test $ol_enable_bdb = no &&
test $ol_enable_dnssrv = no &&
test $ol_enable_hdb = no &&
test $ol_enable_ldap = no &&
test $ol_enable_mdb = no &&
test $ol_enable_meta = no &&
test $ol_enable_monitor = no &&
test $ol_enable_ndb = no &&
test $ol_enable_null = no &&
test $ol_enable_passwd = no &&
test $ol_enable_perl = no &&
test $ol_enable_relay = no &&
test $ol_enable_shell = no &&
test $ol_enable_sock = no &&
test $ol_enable_sql = no ; then
dnl no slapd backend
if test $ol_enable_slapd = yes ; then
AC_MSG_ERROR([slapd requires a backend])
else
AC_MSG_WARN([skipping slapd, no backend specified])
ol_enable_slapd=no
fi
fi
if test $ol_enable_meta/$ol_enable_ldap = yes/no ; then
AC_MSG_ERROR([--enable-meta requires --enable-ldap])
fi
if test $ol_enable_lmpasswd = yes ; then
if test $ol_with_tls = no ; then
AC_MSG_ERROR([LAN Manager passwords require OpenSSL])
fi
fi
if test $ol_enable_spasswd = yes ; then
if test $ol_with_cyrus_sasl = no ; then
AC_MSG_ERROR([options require --with-cyrus-sasl])
fi
ol_with_cyrus_sasl=yes
fi
AC_MSG_RESULT(done)
dnl ----------------------------------------------------------------
dnl Initialize vars
LDAP_LIBS=
BDB_LIBS=
SLAPD_NDB_LIBS=
SLAPD_NDB_INCS=
LTHREAD_LIBS=
LUTIL_LIBS=
SLAPD_LIBS=
BUILD_SLAPD=no
BUILD_THREAD=no
BUILD_SLAPI=no
SLAPD_SLAPI_DEPEND=
BUILD_BDB=no
BUILD_DNSSRV=no
BUILD_HDB=no
BUILD_LDAP=no
BUILD_MDB=no
BUILD_META=no
BUILD_MONITOR=no
BUILD_NDB=no
BUILD_NULL=no
BUILD_PASSWD=no
BUILD_PERL=no
BUILD_RELAY=no
BUILD_SHELL=no
BUILD_SOCK=no
BUILD_SQL=no
BUILD_ACCESSLOG=no
BUILD_AUDITLOG=no
BUILD_CONSTRAINT=no
BUILD_DDS=no
BUILD_DENYOP=no
BUILD_DEREF=no
BUILD_DYNGROUP=no
BUILD_DYNLIST=no
BUILD_LASTMOD=no
BUILD_MEMBEROF=no
BUILD_PPOLICY=no
BUILD_PROXYCACHE=no
BUILD_REFINT=no
BUILD_RETCODE=no
BUILD_RWM=no
BUILD_SEQMOD=no
BUILD_SSSVLV=no
BUILD_SYNCPROV=no
BUILD_TRANSLUCENT=no
BUILD_UNIQUE=no
BUILD_VALSORT=no
SLAPD_STATIC_OVERLAYS=
SLAPD_DYNAMIC_OVERLAYS=
SLAPD_MODULES_LDFLAGS=
SLAPD_MODULES_CPPFLAGS=
SLAPD_STATIC_BACKENDS=back-ldif
SLAPD_DYNAMIC_BACKENDS=
SLAPD_PERL_LDFLAGS=
MOD_PERL_LDFLAGS=
PERL_CPPFLAGS=
SLAPD_SQL_LDFLAGS=
SLAPD_SQL_LIBS=
SLAPD_SQL_INCLUDES=
KRB4_LIBS=
KRB5_LIBS=
SASL_LIBS=
TLS_LIBS=
MODULES_LIBS=
SLAPI_LIBS=
LIBSLAPI=
AUTH_LIBS=
SLAPD_SLP_LIBS=
SLAPD_GMP_LIBS=
dnl ================================================================
dnl Checks for programs
AC_DEFINE(HAVE_MKVERSION, 1, [define this if you have mkversion])
dnl ----------------------------------------------------------------
dnl
dnl Determine which C translator to use
dnl
dnl AIX Thread requires we use cc_r or xlc_r.
dnl But only do this IF AIX and CC is not set
dnl and threads are auto|yes|posix.
dnl
dnl If we find cc_r|xlc_r, force pthreads and assume
dnl pthread_create is in $LIBS (ie: don't bring in
dnl any additional thread libraries)
dnl If we do not find cc_r|xlc_r, disable threads
ol_aix_threads=no
case "$target" in
*-*-aix*) dnl all AIX is not a good idea.
if test -z "$CC" ; then
case "$ol_with_threads" in
auto | yes | posix) ol_aix_threads=yes ;;
esac
fi
;;
esac
if test $ol_aix_threads = yes ; then
if test -z "${CC}" ; then
AC_CHECK_PROGS(CC,cc_r xlc_r cc)
if test "$CC" = cc ; then
dnl no CC! don't allow --with-threads
if test $ol_with_threads != auto ; then
AC_MSG_ERROR([--with-threads requires cc_r (or other suitable compiler) on AIX])
else
AC_MSG_WARN([disabling threads, no cc_r on AIX])
fi
ol_with_threads=no
fi
fi
case ${CC} in cc_r | xlc_r)
ol_with_threads=posix
ol_cv_pthread_create=yes
;;
esac
fi
if test -z "${CC}"; then
AC_CHECK_PROGS(CC,cc gcc,missing)
if test "${CC}" = "missing" ; then
AC_MSG_ERROR([Unable to locate cc(1) or suitable replacement. Check PATH or set CC.])
fi
fi
if test -z "${AR}"; then
AC_CHECK_PROGS(AR,ar gar,missing)
if test "${AR}" = "missing" ; then
AC_MSG_ERROR([Unable to locate ar(1) or suitable replacement. Check PATH or set AR.])
fi
fi
AC_LIBTOOL_WIN32_DLL
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
dnl ----------------------------------------------------------------
dnl Perl
ol_link_perl=no
if test $ol_enable_perl != no ; then
AC_PATH_PROG(PERLBIN, perl, /usr/bin/perl)
if test "no$PERLBIN" = "no" ; then
if test $ol_enable_perl = yes ; then
AC_MSG_ERROR([could not locate perl])
fi
else
PERL_CPPFLAGS="`$PERLBIN -MExtUtils::Embed -e ccopts`"
PERL_LDFLAGS="`$PERLBIN -MExtUtils::Embed -e ldopts|sed -e 's/ -lc / /' -e 's/ -lc$//'`"
if test x"$ol_enable_perl" = "xyes" ; then
SLAPD_PERL_LDFLAGS="$PERL_LDFLAGS"
else
MOD_PERL_LDFLAGS="$PERL_LDFLAGS"
fi
dnl should check perl version
ol_link_perl=yes
fi
fi
AC_PROG_CPP
OL_MSVC
dnl ----------------------------------------------------------------
dnl Checks for Windows NT
case $host_os in
*mingw32* ) ac_cv_mingw32=yes ;;
*cygwin* ) ac_cv_cygwin=yes ;;
*interix* ) ac_cv_interix=yes ;;
esac
dnl ----------------------------------------------------------------
dnl Checks for file extensions
AC_EXEEXT
AC_OBJEXT
AC_DEFINE_UNQUOTED(EXEEXT, "${EXEEXT}", [defined to be the EXE extension])
dnl ----------------------------------------------------------------
dnl BeOS requires -lbe -lroot -lnet
AC_CHECK_LIB(be, be_app, [LIBS="$LIBS -lbe -lroot -lnet"], :, [-lroot -lnet])
dnl ----------------------------------------------------------------
dnl OpenLDAP requires STDC features
AC_PROG_CC
if test "X${ac_cv_prog_cc_stdc}" = "Xno" ; then
AC_MSG_ERROR([OpenLDAP requires compiler to support STDC constructs.])
fi
dnl ----------------------------------------------------------------
dnl Check cc depend flags
OL_MKDEPEND
if test "${ol_cv_mkdep}" = no ; then
# this will soon become an error
AC_MSG_WARN([do not know how to generate dependencies])
fi
dnl ----------------------------------------------------------------
dnl Check for AIX security library
AC_CHECK_LIB(s, afopen, [
AUTH_LIBS=-ls
AC_DEFINE(HAVE_AIX_SECURITY,1,[define if you have AIX security lib])
])
dnl ----------------------------------------------------------------
dnl Check for IBM OS/390
case "$target" in
*-ibm-openedition)
ac_cv_func_getopt=no
AC_DEFINE(BOTH_STRINGS_H,1,[define to use both <string.h> and <strings.h>])
;;
esac
dnl ----------------------------------------------------------------
dnl Check for module support
ol_link_modules=no
WITH_MODULES_ENABLED=no
if test $ol_enable_modules != no ; then
AC_CHECK_HEADERS(ltdl.h)
if test $ac_cv_header_ltdl_h = no ; then
AC_MSG_ERROR([could not locate libtool ltdl.h])
fi
AC_CHECK_LIB(ltdl, lt_dlinit, [
MODULES_LIBS=-lltdl
AC_DEFINE(HAVE_LIBLTDL,1,[define if you have libtool -ltdl])
])
if test "$ac_cv_lib_ltdl_lt_dlinit" = no ; then
AC_MSG_ERROR([could not locate libtool -lltdl])
fi
ol_link_modules=yes
WITH_MODULES_ENABLED=yes
else
for i in $Backends; do
eval "ol_tmp=\$ol_enable_$i"
if test $ol_tmp = mod ; then
AC_MSG_WARN([building static $i backend])
eval "ol_enable_$i=yes"
fi
done
for i in $Overlays; do
eval "ol_tmp=\$ol_enable_$i"
if test $ol_tmp = mod ; then
AC_MSG_WARN([building static $i overlay])
eval "ol_enable_$i=yes"
fi
done
fi
dnl ----------------------------------------------------------------
dnl Checks for header files.
OL_HEADER_STDC
if test $ol_cv_header_stdc != yes; then
AC_MSG_WARN([could not locate Standard C compliant headers])
fi
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_HEADER_TIOCGWINSZ
AC_CHECK_HEADERS( \
arpa/inet.h \
arpa/nameser.h \
assert.h \
bits/types.h \
conio.h \
crypt.h \
direct.h \
errno.h \
fcntl.h \
filio.h \
getopt.h \
grp.h \
io.h \
libutil.h \
limits.h \
locale.h \
malloc.h \
memory.h \
psap.h \
pwd.h \
process.h \
sgtty.h \
shadow.h \
stddef.h \
string.h \
strings.h \
sysexits.h \
sys/file.h \
sys/filio.h \
sys/fstyp.h \
sys/errno.h \
sys/ioctl.h \
sys/param.h \
sys/privgrp.h \
sys/resource.h \
sys/select.h \
sys/socket.h \
sys/stat.h \
sys/syslog.h \
sys/time.h \
sys/types.h \
sys/uio.h \
sys/vmount.h \
syslog.h \
termios.h \
unistd.h \
utime.h \
)
dnl Only check Winsock on MinGW
if test "$ac_cv_mingw32" = yes \
-o "$ac_cv_interix" = yes \
-o "$ol_cv_msvc" = yes
then
AC_CHECK_HEADERS( winsock.h winsock2.h )
fi
AC_CHECK_HEADERS( resolv.h, [], [],
[$ac_includes_default
#include <netinet/in.h>
])
AC_CHECK_HEADERS( netinet/tcp.h, [], [],
[$ac_includes_default
#include <netinet/in.h>
])
AC_CHECK_HEADERS( sys/ucred.h, [], [],
[$ac_includes_default
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
])
dnl ----------------------------------------------------------------
dnl Checks for libraries
AC_CHECK_FUNCS( sigaction sigset )
dnl HP-UX requires -lV3
dnl this is not needed on newer versions of HP-UX
if test $ac_cv_func_sigaction = no && test $ac_cv_func_sigaction = no ; then
AC_CHECK_LIB(V3, sigset)
fi
if test $ol_cv_msvc = yes ; then
ol_cv_winsock=yes
fi
dnl The following is INTENTIONALLY scripted out because shell does not
dnl support variable names with the '@' character, which is what
dnl autoconf would try to generate if one merely used AC_SEARCH_LIBS
if test "$ac_cv_header_winsock_h" = yes; then
AC_CACHE_CHECK([for winsock], [ol_cv_winsock],[
save_LIBS="$LIBS"
for curlib in none ws2_32 wsock32; do
if test $curlib != none ; then
LIBS="$save_LIBS -l$curlib"
fi
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock.h>
]], [[
socket(0,0,0);
select(0,NULL,NULL,NULL,NULL);
closesocket(0);
gethostname(NULL,0);
]])],[ol_cv_winsock=$curlib],[ol_cv_winsock=no])
test "$ol_cv_winsock" != no && break
done
LIBS="$save_LIBS"
])
if test $ol_cv_winsock != no ; then
AC_DEFINE(HAVE_WINSOCK, 1, [define if you have winsock])
ac_cv_func_socket=yes
ac_cv_func_select=yes
ac_cv_func_closesocket=yes
ac_cv_func_gethostname=yes
if test $ol_cv_winsock != none -a $ol_cv_winsock != yes ; then
LIBS="$LIBS -l$ol_cv_winsock"
fi
if test $ol_cv_winsock = ws2_32 -o $ol_cv_winsock = yes ; then
AC_DEFINE(HAVE_WINSOCK2, 1, [define if you have winsock2])
fi
fi
fi
dnl Find socket()
dnl Likely combinations:
dnl -lsocket [ -lnsl_s | -lnsl ]
dnl -linet
AC_CHECK_FUNC(socket, :, [
dnl hopefully we won't include too many libraries
AC_CHECK_LIB(socket, main)
AC_CHECK_LIB(net, socket)
AC_CHECK_LIB(nsl_s, main)
AC_CHECK_LIB(nsl, main)
AC_CHECK_LIB(inet, socket)
AC_CHECK_LIB(gen, main)
])
dnl require select
AC_CHECK_FUNC(select, :, AC_MSG_ERROR([select() required.]))
if test "${ac_cv_header_winsock_h}" != yes; then
dnl Select arg types
dnl (if this detection becomes permenent, it and the select() detection
dnl should be done before the yielding select test)
AC_FUNC_SELECT_ARGTYPES
fi
dnl check to see if system call automatically restart
dnl AC_SYS_RESTARTABLE_SYSCALLS
dnl ----------------------------------------------------------------
AC_CHECK_FUNCS( poll )
if test $ac_cv_func_poll = yes; then
AC_CHECK_HEADERS( poll.h sys/poll.h )
fi
dnl ----------------------------------------------------------------
AC_CHECK_HEADERS( sys/epoll.h )
if test "${ac_cv_header_sys_epoll_h}" = yes; then
AC_MSG_CHECKING(for epoll system call)
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv)
{
int epfd = epoll_create(256);
exit (epfd == -1 ? 1 : 0);
}]])],[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_EPOLL,1, [define if your system supports epoll])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
fi
dnl ----------------------------------------------------------------
AC_CHECK_HEADERS( sys/devpoll.h )
dnl "/dev/poll" needs <sys/poll.h> as well...
if test "${ac_cv_header_sys_devpoll_h}" = yes \
-a "${ac_cv_header_poll_h}" = yes ; \
then
AC_MSG_CHECKING(for /dev/poll)
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv)
{
int devpollfd = open("/dev/poll", /* O_RDWR */ 2);
exit (devpollfd == -1 ? 1 : 0);
}]])],[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DEVPOLL,1, [define if your system supports /dev/poll])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
fi
dnl ----------------------------------------------------------------
OL_STRERROR
dnl ----------------------------------------------------------------
dnl require POSIX regex
AC_CHECK_HEADERS( regex.h, [], [],
[$ac_includes_default
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
])
if test "$ac_cv_header_regex_h" != yes ; then
AC_MSG_ERROR([POSIX regex.h required.])
fi
AC_SEARCH_LIBS(regfree, [regex gnuregex],
:, AC_MSG_ERROR([POSIX regex required.]))
OL_POSIX_REGEX
if test "$ol_cv_c_posix_regex" = no ; then
AC_MSG_ERROR([broken POSIX regex!])
fi
dnl ----------------------------------------------------------------
dnl UUID Support
have_uuid=no
AC_CHECK_HEADERS(sys/uuid.h)
dnl The HAVE_UUID_TO_STR code path also needs uuid_create
if test $ac_cv_header_sys_uuid_h = yes ; then
save_LIBS="$LIBS"
AC_SEARCH_LIBS([uuid_to_str], [uuid], [have_uuid=yes], :)
AC_SEARCH_LIBS([uuid_create], [uuid], :, [have_uuid=no])
LIBS="$save_LIBS"
if test $have_uuid = yes ; then
AC_DEFINE(HAVE_UUID_TO_STR,1,
[define if you have uuid_to_str()])
test "$ac_cv_search_uuid_to_str" = "none required" || \
SLAPD_LIBS="$SLAPD_LIBS $ac_cv_search_uuid_to_str"
fi
fi
dnl Look for uuid_generate
dnl The HAVE_UUID_GENERATE code path also needs uuid_unparse_lower
if test $have_uuid = no ; then
AC_CHECK_HEADERS(uuid/uuid.h)
if test $ac_cv_header_uuid_uuid_h = yes ; then
save_LIBS="$LIBS"
AC_SEARCH_LIBS([uuid_generate], [uuid], [have_uuid=yes], :)
AC_SEARCH_LIBS([uuid_unparse_lower], [uuid], :, [have_uuid=no])
LIBS="$save_LIBS"
if test $have_uuid = yes ; then
AC_DEFINE(HAVE_UUID_GENERATE,1,
[define if you have uuid_generate()])
test "$ac_cv_search_uuid_generate" = "none required" || \
SLAPD_LIBS="$SLAPD_LIBS $ac_cv_search_uuid_generate"
fi
fi
fi
dnl For windows, check for the need of RPCRT for UUID function support
if test $have_uuid = no ; then
AC_MSG_CHECKING(to see if -lrpcrt4 is needed for win32 UUID support)
save_LIBS="$LIBS"
LIBS="$LIBS -lrpcrt4"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
int __stdcall UuidCreate(void *);
int __stdcall UuidToStringA(void *,void **);
]], [[
UuidCreate(0);
UuidToStringA(0,0);
]])],[need_rpcrt=yes],[need_rpcrt=no])
if test $need_rpcrt = yes; then
SLAPD_LIBS="$SLAPD_LIBS -lrpcrt4"
fi
LIBS="$save_LIBS"
AC_MSG_RESULT($need_rpcrt)
fi
dnl ----------------------------------------------------------------
dnl Check for resolver routines
OL_RESOLVER_LINK
ol_link_dnssrv=no
if test "$ol_cv_lib_resolver" != no ; then
AC_DEFINE(HAVE_RES_QUERY,1,
[define if you have res_query()])
if test "$ol_enable_dnssrv" != no ; then
ol_link_dnssrv=yes
fi
if test "$ol_cv_lib_resolver" != yes ; then
LIBS="$ol_cv_lib_resolver $LIBS"
fi
fi
if test "$ol_enable_dnssrv" = yes || test "$ol_enable_dnssrv" = mod ; then
if test "$ol_link_dnssrv" = no ; then
AC_MSG_ERROR([DNSSRV requires res_query()])
fi
else
ol_enable_dnssrv=no
fi
AC_CHECK_FUNCS( hstrerror )
dnl ----------------------------------------------------------------
dnl PF_INET6 support requires getaddrinfo and INET6_ADDRSTRLEN
dnl PF_LOCAL may use getaddrinfo in available
AC_CHECK_FUNCS( getaddrinfo getnameinfo gai_strerror inet_ntop )
ol_link_ipv6=no
if test $ac_cv_func_getaddrinfo = no || test $ac_cv_func_inet_ntop = no ; then
if test $ol_enable_ipv6 = yes ; then
AC_MSG_ERROR([IPv6 support requires getaddrinfo() and inet_ntop()])
fi
elif test $ol_enable_ipv6 != no ; then
AC_CACHE_CHECK([INET6_ADDRSTRLEN],[ol_cv_inet6_addrstrlen],[
AC_EGREP_CPP(__has_inet6_addrstrlen__,[
# include <netinet/in.h>
# ifdef INET6_ADDRSTRLEN
__has_inet6_addrstrlen__;
# endif
], [ol_cv_inet6_addrstrlen=yes], [ol_cv_inet6_addrstrlen=no])])
AC_CACHE_CHECK([struct sockaddr_storage],ol_cv_struct_sockaddr_storage,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
]], [[
struct sockaddr_storage ss;
]])],[ol_cv_struct_sockaddr_storage=yes],[ol_cv_struct_sockaddr_storage=no])])
if test $ol_cv_inet6_addrstrlen = yes &&
test $ol_cv_struct_sockaddr_storage = yes ; then
ol_link_ipv6=yes
elif test $ol_enable_ipv6 = yes &&
test $ol_cv_inet6_addrstrlen = no ; then
AC_MSG_ERROR([IPv6 support requires INET6_ADDRSTRLEN])
elif test $ol_enable_ipv6 = yes &&
test $ol_cv_struct_sockaddr_storage = no ; then
AC_MSG_ERROR([IPv6 support requires struct sockaddr_storage])
fi
fi
if test $ol_enable_local != no ; then
AC_CHECK_HEADERS( sys/un.h )
if test $ol_enable_local = auto ; then
ol_enable_local=$ac_cv_header_sys_un_h
elif test $ac_cv_header_sys_un_h = no ; then
AC_MSG_ERROR([AF_LOCAL domain support requires sys/un.h])
fi
fi
dnl ----------------------------------------------------------------
dnl TLS/SSL
if test $ol_with_tls = yes ; then
ol_with_tls=auto
fi
ol_link_tls=no
if test $ol_with_tls = openssl || test $ol_with_tls = auto ; then
AC_CHECK_HEADERS(openssl/ssl.h)
if test $ac_cv_header_openssl_ssl_h = yes ; then
AC_CHECK_LIB(ssl, SSL_CTX_set_msg_callback,
[have_openssl=yes
need_rsaref=no], [have_openssl=no],
[-lcrypto])
if test $have_openssl = no ; then
AC_CHECK_LIB(ssl, ssl3_accept,
[have_openssl=yes
need_rsaref=yes], [have_openssl=no],
[-lcrypto -lRSAglue -lrsaref])
fi
if test $have_openssl = yes ; then
ol_with_tls=openssl
ol_link_tls=yes
AC_DEFINE(HAVE_OPENSSL, 1,
[define if you have OpenSSL])
if test $need_rsaref = yes; then
AC_DEFINE(HAVE_RSAREF, 1,
[define if OpenSSL needs RSAref])
TLS_LIBS="-lssl -lcrypto -lRSAglue -lrsaref"
else
TLS_LIBS="-lssl -lcrypto"
fi
OL_SSL_COMPAT
if test $ol_cv_ssl_crl_compat = yes ; then
AC_DEFINE(HAVE_OPENSSL_CRL, 1,
[define if you have OpenSSL with CRL checking capability])
fi
fi
fi
fi
if test $ol_link_tls = no ; then
if test $ol_with_tls = gnutls || test $ol_with_tls = auto ; then
AC_CHECK_HEADERS(gnutls/gnutls.h)
if test $ac_cv_header_gnutls_gnutls_h = yes ; then
AC_PREPROC_IFELSE(
[[#include <gnutls/gnutls.h>]
[#if GNUTLS_VERSION_NUMBER < 0x020c00]
[#error "GnuTLS 2.12.0 or newer required"]
[#endif]],
, [AC_MSG_FAILURE([GnuTLS is too old])])
AC_CHECK_LIB(gnutls, gnutls_init,
[have_gnutls=yes], [have_gnutls=no])
if test $have_gnutls = yes ; then
ol_with_tls=gnutls
ol_link_tls=yes
TLS_LIBS="-lgnutls"
AC_DEFINE(HAVE_GNUTLS, 1,
[define if you have GNUtls])
fi
fi
fi
fi
dnl NOTE: caller must specify -I/path/to/nspr4 and -I/path/to/nss3
dnl and -L/path/to/nspr4 libs and -L/path/to/nss3 libs if those libs
dnl are not in the default system location
if test $ol_link_tls = no ; then
if test $ol_with_tls = moznss || test $ol_with_tls = auto ; then
have_moznss=no
AC_CHECK_HEADERS([nssutil.h])
if test "$ac_cv_header_nssutil_h" = yes ; then
AC_CHECK_LIB([nss3], [NSS_Initialize],
[ have_moznss=yes ], [ have_moznss=no ])
fi
if test "$have_moznss" = yes ; then
ol_with_tls=moznss
ol_link_tls=yes
AC_DEFINE(HAVE_MOZNSS, 1,
[define if you have MozNSS])
TLS_LIBS="-lssl3 -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4"
else
if test $ol_with_tls = moznss ; then
AC_MSG_ERROR([MozNSS not found - please specify the location to the NSPR and NSS header files in CPPFLAGS and the location to the NSPR and NSS libraries in LDFLAGS (if not in the system location)])
fi
fi
fi
fi
WITH_TLS=no
if test $ol_link_tls = yes ; then
AC_DEFINE(HAVE_TLS, 1, [define if you have TLS])
WITH_TLS=yes
elif test $ol_with_tls = auto ; then
AC_MSG_WARN([Could not locate TLS/SSL package])
AC_MSG_WARN([TLS data protection not supported!])
elif test $ol_with_tls != no ; then
AC_MSG_ERROR([Could not locate TLS/SSL package])
else
AC_MSG_WARN([TLS data protection not supported!])
fi
dnl ----------------------------------------------------------------
dnl LAN Manger password checking requires DES from OpenSSL
if test $ol_enable_lmpasswd != no; then
if test $ol_link_tls != yes ; then
AC_MSG_ERROR([LAN Manager passwords require OpenSSL])
fi
AC_DEFINE(SLAPD_LMHASH, 1, [define to support LAN Manager passwords])
fi
dnl ----------------------------------------------------------------
dnl Threads?
ol_link_threads=no
case $ol_with_threads in auto | yes | nt)
OL_NT_THREADS
if test "$ol_cv_nt_threads" = yes ; then
ol_link_threads=nt
ol_with_threads=found
ol_with_yielding_select=yes
AC_DEFINE(HAVE_NT_SERVICE_MANAGER,1,[if you have NT Service Manager])
AC_DEFINE(HAVE_NT_EVENT_LOG,1,[if you have NT Event Log])
fi
if test $ol_with_threads = nt ; then
AC_MSG_ERROR([could not locate NT Threads])
fi
;;
esac
case $ol_with_threads in auto | yes | posix)
AC_CHECK_HEADERS(pthread.h)
if test $ac_cv_header_pthread_h = yes ; then
OL_POSIX_THREAD_VERSION
if test $ol_cv_pthread_version != 0 ; then
AC_DEFINE_UNQUOTED(HAVE_PTHREADS,$ol_cv_pthread_version,
[define to pthreads API spec revision])
else
AC_MSG_ERROR([unknown pthread version])
fi
# consider threads found
ol_with_threads=found
OL_HEADER_LINUX_THREADS
OL_HEADER_GNU_PTH_PTHREAD_H
if test $ol_cv_header_gnu_pth_pthread_h = no ; then
AC_CHECK_HEADERS(sched.h)
fi
dnl Now the hard part, how to link?
dnl
dnl currently supported checks:
dnl
dnl Check for no flags
dnl pthread_create() in $LIBS
dnl
dnl Check special pthread (final) flags
dnl [skipped] pthread_create() with -mt (Solaris) [disabled]
dnl pthread_create() with -kthread (FreeBSD)
dnl pthread_create() with -pthread (FreeBSD/Digital Unix)
dnl pthread_create() with -pthreads (?)
dnl pthread_create() with -mthreads (AIX)
dnl pthread_create() with -thread (?)
dnl
dnl Check pthread (final) libraries
dnl pthread_mutex_unlock() in -lpthread -lmach -lexc -lc_r (OSF/1)
dnl pthread_mutex_lock() in -lpthread -lmach -lexc (OSF/1)
dnl [skipped] pthread_mutex_trylock() in -lpthread -lexc (OSF/1)
dnl pthread_join() -Wl,-woff,85 -lpthread (IRIX)
dnl pthread_create() in -lpthread (many)
dnl pthread_create() in -lc_r (FreeBSD)
dnl
dnl Check pthread (draft4) flags (depreciated)
dnl pthread_create() with -threads (OSF/1)
dnl
dnl Check pthread (draft4) libraries (depreciated)
dnl pthread_mutex_unlock() in -lpthreads -lmach -lexc -lc_r (OSF/1)
dnl pthread_mutex_lock() in -lpthreads -lmach -lexc (OSF/1)
dnl pthread_mutex_trylock() in -lpthreads -lexc (OSF/1)
dnl pthread_create() in -lpthreads (many)
dnl
dnl pthread_create in $LIBS
AC_CACHE_CHECK([for pthread_create in default libraries],
ol_cv_pthread_create,[
AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
[ol_cv_pthread_create=yes],
[ol_cv_pthread_create=no],
[AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
[ol_cv_pthread_create=yes],
[ol_cv_pthread_create=no])])])
if test $ol_cv_pthread_create != no ; then
ol_link_threads=posix
ol_link_pthreads=""
fi
dnl OL_PTHREAD_TRY([-mt], [ol_cv_pthread_mt])
OL_PTHREAD_TRY([-kthread], [ol_cv_pthread_kthread])
OL_PTHREAD_TRY([-pthread], [ol_cv_pthread_pthread])
OL_PTHREAD_TRY([-pthreads], [ol_cv_pthread_pthreads])
OL_PTHREAD_TRY([-mthreads], [ol_cv_pthread_mthreads])
OL_PTHREAD_TRY([-thread], [ol_cv_pthread_thread])
OL_PTHREAD_TRY([-lpthread -lmach -lexc -lc_r],
[ol_cv_pthread_lpthread_lmach_lexc_lc_r])
OL_PTHREAD_TRY([-lpthread -lmach -lexc],
[ol_cv_pthread_lpthread_lmach_lexc])
dnl OL_PTHREAD_TRY([-lpthread -lexc],
dnl [ol_cv_pthread_lpthread_lexc])
OL_PTHREAD_TRY([-lpthread -Wl,-woff,85],
[ol_cv_pthread_lib_lpthread_woff])
OL_PTHREAD_TRY([-lpthread], [ol_cv_pthread_lpthread])
OL_PTHREAD_TRY([-lc_r], [ol_cv_pthread_lc_r])
OL_PTHREAD_TRY([-threads], [ol_cv_pthread_threads])
OL_PTHREAD_TRY([-lpthreads -lmach -lexc -lc_r],
[ol_cv_pthread_lpthreads_lmach_lexc_lc_r])
OL_PTHREAD_TRY([-lpthreads -lmach -lexc],
[ol_cv_pthread_lpthreads_lmach_lexc])
OL_PTHREAD_TRY([-lpthreads -lexc],
[ol_cv_pthread_lpthreads_lexc])
OL_PTHREAD_TRY([-lpthreads],[ol_cv_pthread_lib_lpthreads])
if test $ol_link_threads != no ; then
LTHREAD_LIBS="$LTHREAD_LIBS $ol_link_pthreads"
dnl save flags
save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
LIBS="$LTHREAD_LIBS $LIBS"
dnl All POSIX Thread (final) implementations should have
dnl sched_yield instead of pthread yield.
dnl check for both, and thr_yield for Solaris
AC_CHECK_FUNCS(sched_yield pthread_yield thr_yield)
if test $ac_cv_func_sched_yield = no &&
test $ac_cv_func_pthread_yield = no &&
test $ac_cv_func_thr_yield = no ; then
dnl Digital UNIX has sched_yield() in -lrt
AC_CHECK_LIB(rt, sched_yield,
[LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
AC_DEFINE(HAVE_SCHED_YIELD,1,
[Define if you have the sched_yield function.])
ac_cv_func_sched_yield=yes],
[ac_cv_func_sched_yield=no])
fi
if test $ac_cv_func_sched_yield = no &&
test $ac_cv_func_pthread_yield = no &&
test "$ac_cv_func_thr_yield" = no ; then
AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
fi
dnl Check functions for compatibility
AC_CHECK_FUNCS(pthread_kill)
dnl Check for pthread_rwlock_destroy with <pthread.h>
dnl as pthread_rwlock_t may not be defined.
AC_CACHE_CHECK([for pthread_rwlock_destroy with <pthread.h>],
[ol_cv_func_pthread_rwlock_destroy], [
dnl save the flags
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <pthread.h>
pthread_rwlock_t rwlock;
]], [[pthread_rwlock_destroy(&rwlock);]])],[ol_cv_func_pthread_rwlock_destroy=yes],[ol_cv_func_pthread_rwlock_destroy=no])
])
if test $ol_cv_func_pthread_rwlock_destroy = yes ; then
AC_DEFINE(HAVE_PTHREAD_RWLOCK_DESTROY,1,
[define if you have pthread_rwlock_destroy function])
fi
dnl Check for pthread_detach with <pthread.h> inclusion
dnl as it's symbol may have been mangled.
AC_CACHE_CHECK([for pthread_detach with <pthread.h>],
[ol_cv_func_pthread_detach], [
dnl save the flags
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <pthread.h>
#ifndef NULL
#define NULL (void*)0
#endif
]], [[pthread_detach(NULL);]])],[ol_cv_func_pthread_detach=yes],[ol_cv_func_pthread_detach=no])
])
if test $ol_cv_func_pthread_detach = no ; then
AC_MSG_ERROR([could not locate pthread_detach()])
fi
AC_DEFINE(HAVE_PTHREAD_DETACH,1,
[define if you have pthread_detach function])
dnl Check for setconcurreny functions
AC_CHECK_FUNCS( \
pthread_setconcurrency \
pthread_getconcurrency \
thr_setconcurrency \
thr_getconcurrency \
)
OL_SYS_LINUX_THREADS
OL_LINUX_THREADS
if test $ol_cv_linux_threads = error; then
AC_MSG_ERROR([LinuxThreads header/library mismatch]);
fi
AC_CACHE_CHECK([if pthread_create() works],
ol_cv_pthread_create_works,[
AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
[ol_cv_pthread_create_works=yes],
[ol_cv_pthread_create_works=no],
[dnl assume yes
ol_cv_pthread_create_works=yes])])
if test $ol_cv_pthread_create_works = no ; then
AC_MSG_ERROR([pthread_create is not usable, check environment settings])
fi
ol_replace_broken_yield=no
dnl case "$target" in
dnl *-*-linux*)
dnl AC_CHECK_FUNCS(nanosleep)
dnl ol_replace_broken_yield=yes
dnl ;;
dnl esac
if test $ol_replace_broken_yield = yes ; then
AC_DEFINE([REPLACE_BROKEN_YIELD],1,
[define if sched_yield yields the entire process])
fi
dnl Check if select causes an yield
if test $ol_with_yielding_select = auto ; then
AC_CACHE_CHECK([if select yields when using pthreads],
ol_cv_pthread_select_yields,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#ifndef NULL
#define NULL (void*) 0
#endif
static int fildes[2];
static void *task(p)
void *p;
{
int i;
struct timeval tv;
fd_set rfds;
tv.tv_sec=10;
tv.tv_usec=0;
FD_ZERO(&rfds);
FD_SET(fildes[0], &rfds);
/* we're not interested in any fds */
i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
if(i < 0) {
perror("select");
exit(10);
}
exit(0); /* if we exit here, the select blocked the whole process */
}
int main(argc, argv)
int argc;
char **argv;
{
pthread_t t;
/* create a pipe to select */
if(pipe(&fildes[0])) {
perror("select");
exit(1);
}
#ifdef HAVE_PTHREAD_SETCONCURRENCY
(void) pthread_setconcurrency(2);
#else
#ifdef HAVE_THR_SETCONCURRENCY
/* Set Solaris LWP concurrency to 2 */
thr_setconcurrency(2);
#endif
#endif
#if HAVE_PTHREADS < 6
pthread_create(&t, pthread_attr_default, task, NULL);
#else
pthread_create(&t, NULL, task, NULL);
#endif
/* make sure task runs first */
#ifdef HAVE_THR_YIELD
thr_yield();
#elif defined( HAVE_SCHED_YIELD )
sched_yield();
#elif defined( HAVE_PTHREAD_YIELD )
pthread_yield();
#endif
exit(2);
}]])],[ol_cv_pthread_select_yields=no],[ol_cv_pthread_select_yields=yes],[ol_cv_pthread_select_yields=cross])])
if test $ol_cv_pthread_select_yields = cross ; then
AC_MSG_ERROR([crossing compiling: use --with-yielding_select=yes|no|manual])
fi
if test $ol_cv_pthread_select_yields = yes ; then
ol_with_yielding_select=yes
fi
fi
dnl restore flags
CPPFLAGS="$save_CPPFLAGS"
LIBS="$save_LIBS"
else
AC_MSG_ERROR([could not locate usable POSIX Threads])
fi
fi
if test $ol_with_threads = posix ; then
AC_MSG_ERROR([could not locate POSIX Threads])
fi
;;
esac
case $ol_with_threads in auto | yes | mach)
dnl check for Mach CThreads
AC_CHECK_HEADERS(mach/cthreads.h cthreads.h)
if test $ac_cv_header_mach_cthreads_h = yes ; then
ol_with_threads=found
dnl check for cthreads support in current $LIBS
AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
if test $ol_link_threads = no ; then
dnl try -all_load
dnl this test needs work
AC_CACHE_CHECK([for cthread_fork with -all_load],
[ol_cv_cthread_all_load], [
dnl save the flags
save_LIBS="$LIBS"
LIBS="-all_load $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mach/cthreads.h>]], [[
cthread_fork((void *)0, (void *)0);
]])],[ol_cv_cthread_all_load=yes],[ol_cv_cthread_all_load=no])
dnl restore the LIBS
LIBS="$save_LIBS"
])
if test $ol_cv_cthread_all_load = yes ; then
LTHREAD_LIBS="$LTHREAD_LIBS -all_load"
ol_link_threads=mach
ol_with_threads=found
fi
fi
elif test $ac_cv_header_cthreads_h = yes ; then
dnl Hurd variant of Mach Cthreads
dnl uses <cthreads.h> and -lthreads
ol_with_threads=found
dnl save the flags
save_LIBS="$LIBS"
LIBS="$LIBS -lthreads"
AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
LIBS="$save_LIBS"
if test $ol_link_threads = yes ; then
LTHREAD_LIBS="-lthreads"
ol_link_threads=mach
ol_with_threads=found
else
AC_MSG_ERROR([could not link with Mach CThreads])
fi
elif test $ol_with_threads = mach ; then
AC_MSG_ERROR([could not locate Mach CThreads])
fi
if test $ol_link_threads = mach ; then
AC_DEFINE(HAVE_MACH_CTHREADS,1,
[define if you have Mach Cthreads])
elif test $ol_with_threads = found ; then
AC_MSG_ERROR([could not link with Mach CThreads])
fi
;;
esac
case $ol_with_threads in auto | yes | pth)
AC_CHECK_HEADERS(pth.h)
if test $ac_cv_header_pth_h = yes ; then
AC_CHECK_LIB(pth, pth_version, [have_pth=yes], [have_pth=no])
if test $have_pth = yes ; then
AC_DEFINE(HAVE_GNU_PTH,1,[if you have GNU Pth])
LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
ol_link_threads=pth
ol_with_threads=found
if test $ol_with_yielding_select = auto ; then
ol_with_yielding_select=yes
fi
fi
fi
;;
esac
case $ol_with_threads in auto | yes | lwp)
dnl check for SunOS5 LWP
AC_CHECK_HEADERS(thread.h synch.h)
if test $ac_cv_header_thread_h = yes &&
test $ac_cv_header_synch_h = yes ; then
AC_CHECK_LIB(thread, thr_create, [have_thr=yes], [have_thr=no])
if test $have_thr = yes ; then
AC_DEFINE(HAVE_THR,1,
[if you have Solaris LWP (thr) package])
LTHREAD_LIBS="$LTHREAD_LIBS -lthread"
ol_link_threads=thr
if test $ol_with_yielding_select = auto ; then
ol_with_yielding_select=yes
fi
dnl Check for setconcurreny functions
AC_CHECK_FUNCS( \
thr_setconcurrency \
thr_getconcurrency \
)
fi
fi
;;
esac
if test $ol_with_yielding_select = yes ; then
AC_DEFINE(HAVE_YIELDING_SELECT,1,
[define if select implicitly yields])
fi
if test $ol_with_threads = manual ; then
dnl User thinks he can manually configure threads.
ol_link_threads=yes
AC_MSG_WARN([thread defines and link options must be set manually])
AC_CHECK_HEADERS(pthread.h sched.h)
AC_CHECK_FUNCS(sched_yield pthread_yield)
OL_HEADER_LINUX_THREADS
AC_CHECK_HEADERS(mach/cthreads.h)
AC_CHECK_HEADERS(thread.h synch.h)
fi
if test $ol_link_threads != no && test $ol_link_threads != nt ; then
dnl needed to get reentrant/threadsafe versions
dnl
AC_DEFINE(REENTRANT,1)
AC_DEFINE(_REENTRANT,1)
AC_DEFINE(THREAD_SAFE,1)
AC_DEFINE(_THREAD_SAFE,1)
AC_DEFINE(THREADSAFE,1)
AC_DEFINE(_THREADSAFE,1)
AC_DEFINE(_SGI_MP_SOURCE,1)
dnl The errno declaration may dependent upon _REENTRANT.
dnl If it does, we must link with thread support.
AC_CACHE_CHECK([for thread specific errno],
[ol_cv_errno_thread_specific], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[errno = 0;]])],[ol_cv_errno_thread_specific=yes],[ol_cv_errno_thread_specific=no])
])
dnl The h_errno declaration may dependent upon _REENTRANT.
dnl If it does, we must link with thread support.
AC_CACHE_CHECK([for thread specific h_errno],
[ol_cv_h_errno_thread_specific], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[h_errno = 0;]])],[ol_cv_h_errno_thread_specific=yes],[ol_cv_h_errno_thread_specific=no])
])
if test $ol_cv_errno_thread_specific != yes ||
test $ol_cv_h_errno_thread_specific != yes ; then
LIBS="$LTHREAD_LIBS $LIBS"
LTHREAD_LIBS=""
fi
dnl When in thread environment, use
dnl #if defined( HAVE_REENTRANT_FUNCTIONS ) || defined( HAVE_FUNC_R )
dnl func_r(...);
dnl #else
dnl # if defined( HAVE_THREADS )
dnl /* lock */
dnl # endif
dnl func(...);
dnl # if defined( HAVE_THREADS )
dnl /* unlock */
dnl # endif
dnl #endif
dnl
dnl HAVE_REENTRANT_FUNCTIONS is derived from:
dnl _POSIX_REENTRANT_FUNCTIONS
dnl _POSIX_THREAD_SAFE_FUNCTIONS
dnl _POSIX_THREADSAFE_FUNCTIONS
dnl
dnl and is currently defined in <ldap_pvt_thread.h>
dnl
dnl HAVE_THREADS is defined by <ldap_pvt_thread.h> iff -UNO_THREADS
dnl
dnl libldap/*.c should only include <ldap_pvt_thread.h> iff
dnl LDAP_R_COMPILE is defined. ie:
dnl #ifdef LDAP_R_COMPILE
dnl # include <ldap_pvt_thread.h>
dnl #endif
dnl
dnl LDAP_R_COMPILE is defined by libldap_r/Makefile.in
dnl specifically for compiling the threadsafe version of
dnl the ldap library (-lldap_r).
dnl
dnl dnl check for reentrant/threadsafe functions
dnl dnl
dnl dnl note: these should only be used when linking
dnl dnl with $LTHREAD_LIBS
dnl dnl
dnl save_CPPFLAGS="$CPPFLAGS"
dnl save_LIBS="$LIBS"
dnl LIBS="$LTHREAD_LIBS $LIBS"
dnl AC_CHECK_FUNCS( \
dnl gmtime_r \
dnl gethostbyaddr_r gethostbyname_r \
dnl feof_unlocked unlocked_feof \
dnl putc_unlocked unlocked_putc \
dnl flockfile ftrylockfile \
dnl )
dnl CPPFLAGS="$save_CPPFLAGS"
dnl LIBS="$save_LIBS"
fi
if test $ol_link_threads = no ; then
if test $ol_with_threads = yes ; then
AC_MSG_ERROR([no suitable thread support])
fi
if test $ol_with_threads = auto ; then
AC_MSG_WARN([no suitable thread support, disabling threads])
ol_with_threads=no
fi
AC_DEFINE(NO_THREADS,1,
[define if you have (or want) no threads])
LTHREAD_LIBS=""
BUILD_THREAD=no
else
BUILD_THREAD=yes
fi
if test $ol_link_threads != no ; then
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE,1,
[define to 1 if library is thread safe])
fi
dnl ----------------------------------------------------------------
dnl Tests for reentrant functions necessary to build -lldap_r
AC_CHECK_FUNCS( \
ctime_r \
gmtime_r localtime_r \
gethostbyname_r gethostbyaddr_r \
)
if test "$ac_cv_func_ctime_r" = no ; then
ol_cv_func_ctime_r_nargs=0
else
OL_FUNC_CTIME_R_NARGS
dnl OL_FUNC_CTIME_R_TYPE
fi
if test "$ac_cv_func_gethostbyname_r" = yes ; then
OL_FUNC_GETHOSTBYNAME_R_NARGS
else
ol_cv_func_gethostbyname_r_nargs=0
fi
if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
OL_FUNC_GETHOSTBYADDR_R_NARGS
else
ol_cv_func_gethostbyaddr_r_nargs=0
fi
dnl ----------------------------------------------------------------
ol_link_bdb=no
if test $ol_enable_bdb/$ol_enable_hdb != no/no; then
OL_BERKELEY_DB
if test $ol_cv_berkeley_db = no ; then
AC_MSG_ERROR(BDB/HDB: BerkeleyDB not available)
fi
AC_DEFINE(HAVE_BERKELEY_DB,1,
[define this if Berkeley DB is available])
dnl $ol_cv_lib_db should be yes or -ldb
dnl (it could be no, but that would be an error
if test $ol_cv_lib_db != yes ; then
BDB_LIBS="$BDB_LIBS $ol_cv_lib_db"
fi
dnl link BDB library to slapd when there is a
dnl static BDB based backend in use
if test $ol_enable_bdb/$ol_enable_hdb != mod/mod ; then
if test $ol_enable_bdb = yes -o $ol_enable_hdb = yes ; then
SLAPD_LIBS="$SLAPD_LIBS \$(BDB_LIBS)"
fi
fi
ol_link_bdb=yes
fi
dnl ----------------------------------------------------------------
if test $ol_enable_dynamic = yes && test $enable_shared = yes ; then
BUILD_LIBS_DYNAMIC=shared
AC_DEFINE(LDAP_LIBS_DYNAMIC, 1, [define if LDAP libs are dynamic])
LTSTATIC=""
else
BUILD_LIBS_DYNAMIC=static
LTSTATIC="-static"
fi
AC_SUBST(LTSTATIC)dnl
dnl ----------------------------------------------------------------
if test $ol_enable_wrappers != no ; then
AC_CHECK_HEADERS(tcpd.h,[
AC_MSG_CHECKING([for TCP wrappers library])
save_LIBS="$LIBS"
LIBS="$LIBS -lwrap"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <tcpd.h>
int allow_severity = 0;
int deny_severity = 0;
struct request_info *req;
]], [[
hosts_access(req)
]])],[AC_MSG_RESULT([-lwrap])
have_wrappers=yes
LIBS="$save_LIBS"],[
dnl try with -lnsl
LIBS="$LIBS -lnsl"
AC_TRY_LINK([
#include <tcpd.h>
int allow_severity = 0;
int deny_severity = 0;
struct request_info *req;
],[
hosts_access(req)
],[AC_MSG_RESULT([-lwrap -lnsl])
have_wrappers=yes
LIBS="$save_LIBS -lnsl"],[
AC_MSG_RESULT(no)
have_wrappers=no
LIBS=$save_LIBS])])],[have_wrappers=no])
if test $have_wrappers = yes ; then
AC_DEFINE(HAVE_TCPD,1, [define if you have -lwrap])
WRAP_LIBS="-lwrap"
elif test $ol_enable_wrappers = yes ; then
AC_MSG_ERROR([could not find TCP wrappers, select apppropriate options or disable])
else
AC_MSG_WARN([could not find TCP wrappers, support disabled])
WRAP_LIBS=""
fi
fi
dnl ----------------------------------------------------------------
if test $ol_enable_syslog != no ; then
AC_CHECK_FUNC(openlog)
if test $ac_cv_func_openlog = no && test $ol_enable_syslog = yes; then
AC_MSG_ERROR(could not find syslog, select appropriate options or disable)
fi
ol_enable_syslog=$ac_cv_func_openlog
fi
dnl ----------------------------------------------------------------
dnl SQL
ol_link_sql=no
if test $ol_enable_sql != no ; then
AC_CHECK_HEADERS(sql.h sqlext.h,[],[
AC_MSG_ERROR([could not locate SQL headers])
])
sql_LIBS="$LIBS"
LIBS="$LTHREAD_LIBS $LIBS"
if test $ol_with_odbc = auto ; then
ol_with_odbc="iodbc unixodbc odbc32"
fi
for odbc in $ol_with_odbc ; do
if test $ol_link_sql = no ; then
case $odbc in
iodbc)
AC_CHECK_LIB(iodbc, SQLDriverConnect, [have_iodbc=yes], [have_iodbc=no])
if test $have_iodbc = yes ; then
ol_link_sql="-liodbc"
fi
;;
unixodbc)
AC_CHECK_LIB(odbc, SQLDriverConnect, [have_odbc=yes], [have_odbc=no])
if test $have_odbc = yes ; then
ol_link_sql="-lodbc"
fi
;;
odbc32)
AC_CHECK_LIB(odbc32, SQLDriverConnect, [have_odbc32=yes], [have_odbc32=no])
dnl The windows API uses __stdcall which cannot be detected by AC_CHECK_LIB
if test $have_odbc32 = no ; then
AC_MSG_CHECKING([for SQLDriverConnect in -lodbc32 with windows.h])
save_LIBS="$LIBS"
LIBS="$LIBS -lodbc32"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <windows.h>
#include <sqlext.h>
]], [[
SQLDriverConnect(NULL,NULL,NULL,0,NULL,0,NULL,0);
]])],[have_odbc32=yes], [have_odbc32=no])
LIBS="$save_LIBS"
AC_MSG_RESULT($have_odbc32)
fi
if test $have_odbc32 = yes ; then
ol_link_sql="-lodbc32"
fi
;;
*)
AC_MSG_ERROR([unknown ODBC library])
;;
esac
fi
done
LIBS="$sql_LIBS"
if test $ol_link_sql != no ; then
SLAPD_SQL_LIBS="$ol_link_sql"
elif test $ol_enable_sql != auto ; then
AC_MSG_ERROR([could not locate suitable ODBC library])
fi
fi
dnl ----------------------------------------------------------------
dnl MySQL NDBapi
dnl Note: uses C++, but we don't want to add C++ test overhead to
dnl the rest of the libtool machinery.
ol_link_ndb=no
if test $ol_enable_ndb != no ; then
AC_CHECK_PROG(MYSQL,mysql_config,yes)
if test "$MYSQL" != yes ; then
AC_MSG_ERROR([could not locate mysql_config])
fi
SQL_INC=`mysql_config --include`
SLAPD_NDB_INCS="$SQL_INC $SQL_INC/storage/ndb $SQL_INC/storage/ndb/ndbapi"
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$SLAPD_NDB_INCS"
AC_MSG_CHECKING(for NdbApi.hpp)
AC_PREPROC_IFELSE(
[AC_LANG_SOURCE([[#include <NdbApi.hpp>]])],
AC_MSG_RESULT(yes),
AC_MSG_ERROR([could not locate NdbApi headers])
)
CPPFLAGS="$save_CPPFLAGS"
SQL_LIB=`mysql_config --libs_r`
SLAPD_NDB_LIBS="$SQL_LIB -lndbclient -lstdc++"
save_LDFLAGS="$LDFLAGS"
save_LIBS="$LIBS"
LDFLAGS="$SQL_LIB"
AC_CHECK_LIB(ndbclient,ndb_init,[: ok],[
AC_MSG_ERROR([could not locate ndbclient library])
],[-lstdc++])
LIBS="$save_LIBS"
LDFLAGS="$save_LDFLAGS"
if test "$ol_enable_ndb" = yes ; then
SLAPD_LIBS="$SLAPD_LIBS \$(SLAPD_NDB_LIBS)"
fi
fi
dnl ----------------------------------------------------------------
dnl
dnl Check for Cyrus SASL
dnl
WITH_SASL=no
ol_link_sasl=no
ol_link_spasswd=no
if test $ol_with_cyrus_sasl != no ; then
AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
if test $ac_cv_header_sasl_sasl_h = yes ||
test $ac_cv_header_sasl_h = yes; then
AC_CHECK_LIB(sasl2, sasl_client_init,
[ol_link_sasl="-lsasl2"],
[AC_CHECK_LIB(sasl, sasl_client_init,
[ol_link_sasl="-lsasl"])])
fi
if test $ol_link_sasl = no ; then
if test $ol_with_cyrus_sasl != auto ; then
AC_MSG_ERROR([Could not locate Cyrus SASL])
else
AC_MSG_WARN([Could not locate Cyrus SASL])
AC_MSG_WARN([SASL authentication not supported!])
if test $ol_link_tls = no ; then
AC_MSG_WARN([Strong authentication not supported!])
fi
fi
else
OL_SASL_COMPAT
if test $ol_cv_sasl_compat = no ; then
ol_link_sasl=no
AC_MSG_ERROR([Cyrus SASL library located but is incompatible])
fi
AC_DEFINE(HAVE_CYRUS_SASL,1,[define if you have Cyrus SASL])
SASL_LIBS="$ol_link_sasl"
if test $ol_enable_spasswd != no ; then
ol_link_spasswd=yes
fi
ac_save_LIBS="$LIBS"
LIBS="$LIBS $ol_link_sasl"
AC_CHECK_FUNC(sasl_version, [AC_DEFINE(HAVE_SASL_VERSION,1,
[define if your SASL library has sasl_version()])])
LIBS="$ac_save_LIBS"
WITH_SASL=yes
fi
else
AC_MSG_WARN([SASL authentication not supported!])
if test $ol_link_tls = no ; then
AC_MSG_WARN([Strong authentication not supported!])
fi
fi
dnl ----------------------------------------------------------------
dnl Check for entropy sources
if test $cross_compiling != yes && test "$ac_cv_mingw32" != yes ; then
dev=no
if test -r /dev/urandom ; then
dev="/dev/urandom";
elif test -r /idev/urandom ; then
dev="/idev/urandom";
elif test -r /dev/srandom ; then
dev="/dev/srandom";
elif test -r /dev/random ; then
dev="/dev/random";
elif test -r /idev/random ; then
dev="/idev/random";
fi
if test $dev != no ; then
AC_DEFINE_UNQUOTED(URANDOM_DEVICE,"$dev",[set to urandom device])
fi
fi
dnl ----------------------------------------------------------------
dnl
dnl Check for fetch URL support
dnl should be extended to support other fetch URL APIs
dnl
ol_link_fetch=no
if test $ol_with_fetch != no ; then
OL_LIB_FETCH
if test $ol_cv_lib_fetch != no ; then
LIBS="$LIBS $ol_link_fetch"
ol_link_fetch=freebsd
elif test $ol_with_fetch != auto ; then
AC_MSG_ERROR(no suitable API for --with-fetch=$ol_with_fetch)
fi
fi
dnl ----------------------------------------------------------------
dnl FreeBSD (and others) have crypt(3) in -lcrypt
if test $ol_enable_crypt != no ; then
save_LIBS="$LIBS"
LIBS="$TLS_LIBS $LIBS"
AC_CHECK_FUNC(crypt, [have_crypt=yes], [
LIBS="$save_LIBS"
AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
have_crypt=yes], [have_crypt=no])])
LIBS="$save_LIBS"
if test $have_crypt = yes ; then
AC_DEFINE(HAVE_CRYPT,1, [define if crypt(3) is available])
else
AC_MSG_WARN([could not find crypt])
if test $ol_enable_crypt = yes ; then
AC_MSG_ERROR([could not find crypt, select appropriate options or disable])
fi
AC_MSG_WARN([disabling crypt support])
ol_enable_crypt=no
fi
fi
dnl ----------------------------------------------------------------
dnl FreeBSD (and others) have setproctitle(3) in -lutil
if test $ol_enable_proctitle != no ; then
AC_CHECK_FUNC(setproctitle, [have_setproctitle=yes], [
AC_CHECK_LIB(util, setproctitle,
[have_setproctitle=yes
LUTIL_LIBS="$LUTIL_LIBS -lutil"],
[have_setproctitle=no
AC_LIBOBJ(setproctitle)
LIBSRCS="$LIBSRCS setproctitle.c"])])
if test $have_setproctitle = yes ; then
AC_DEFINE(HAVE_SETPROCTITLE,1,
[define if setproctitle(3) is available])
fi
fi
dnl ----------------------------------------------------------------
if test $ol_enable_slp != no ; then
AC_CHECK_HEADERS( slp.h )
if test $ac_cv_header_slp_h = yes ; then
AC_CHECK_LIB(slp, SLPOpen, [have_slp=yes], [have_slp=no])
if test $have_slp = yes ; then
AC_DEFINE(HAVE_SLP, 1, [define if you have -lslp])
SLAPD_SLP_LIBS=-lslp
fi
elif test $ol_enable_slp = yes ; then
AC_MSG_ERROR([SLP not found])
fi
fi
dnl ----------------------------------------------------------------
dnl Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_TYPE(mode_t, int)
AC_CHECK_TYPE(off_t, long)
AC_CHECK_TYPE(pid_t, int)
AC_CHECK_TYPE(ssize_t, [signed int])
AC_CHECK_TYPE(caddr_t, [char *])
AC_CHECK_TYPE(size_t, unsigned)
AC_CHECK_TYPES([long long])
AC_CHECK_TYPES([ptrdiff_t])
AC_CHECK_TYPE([socklen_t],,, [$ac_includes_default
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK2
#include <ws2tcpip.h>
#endif])
dnl socklen_t-like type in accept(), default socklen_t or int:
dnl - The OS might define socklen_t without using it. POSIX moved from
dnl int to size_t to socklen_t, hoping to stay at a 32-bit type, and
dnl HP-UX now has selectors for what to use.
dnl - On Solaris 2.8 the prototype has void *len, but the default is OK.
AC_MSG_CHECKING([the type of arg 3 to accept()])
AC_CACHE_VAL(ol_cv_type_ber_socklen_t, [
set socklen_t int unsigned "unsigned long" long size_t
test "$ac_cv_type_socklen_t" = yes || shift
ol_cv_type_ber_socklen_t=$1 guessing="guessing "
for lentype in "$@" ; do for addrtype in "struct sockaddr" void ; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes_default
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
extern int accept(int s, $addrtype *ap, $lentype *lp);
], [
accept(0, (struct sockaddr *) 0, ($lentype *) 0);
])], [ol_cv_type_ber_socklen_t=$lentype guessing= ; break 2])
done ; done])
AC_MSG_RESULT([$guessing$ol_cv_type_ber_socklen_t *])
AC_DEFINE_UNQUOTED(ber_socklen_t, $ol_cv_type_ber_socklen_t,
[Define to the type of arg 3 for `accept'.])
dnl Modules should use ber_socklen_t, not socklen_t. Define socklen_t
dnl for the time being anyway, for backwards compatibility.
if test "$ac_cv_type_socklen_t" != yes; then
AC_DEFINE_UNQUOTED([socklen_t], [$ol_cv_type_ber_socklen_t],
[Define like ber_socklen_t if <sys/socket.h> does not define.])
fi
AC_TYPE_SIGNAL
AC_CHECK_TYPE([sig_atomic_t],,
[AC_DEFINE_UNQUOTED([sig_atomic_t], [int],
[Define to `int' if <signal.h> does not define.])],
[$ac_includes_default
#include <signal.h>
])
AC_TYPE_UID_T
AC_HEADER_TIME
AC_STRUCT_TM
AC_CHECK_MEMBERS([struct stat.st_blksize])
AC_CHECK_MEMBERS([struct passwd.pw_gecos],,,[$ac_includes_default
#include <pwd.h>])
AC_CHECK_MEMBERS([struct passwd.pw_passwd],,,[$ac_includes_default
#include <pwd.h>])
OL_C_UPPER_LOWER
AC_C_CONST
OL_C_VOLATILE
if test $cross_compiling = yes ; then
AC_MSG_WARN([Crossing compiling... all bets are off!])
AC_DEFINE(CROSS_COMPILING, 1, [define if cross compiling])
else
AC_C_BIGENDIAN
fi
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(wchar_t)
if test "$ac_cv_sizeof_int" -lt 4 ; then
AC_MSG_WARN([OpenLDAP requires 'int' to be 32 bits or greater.])
AC_DEFINE(LBER_INT_T,long,[define to 32-bit or greater integer type])
else
AC_DEFINE(LBER_INT_T,int,[define to 32-bit or greater integer type])
fi
AC_DEFINE(LBER_LEN_T,long,[define to large integer type])
AC_DEFINE(LBER_SOCKET_T,int,[define to socket descriptor type])
AC_DEFINE(LBER_TAG_T,long,[define to large integer type])
dnl ----------------------------------------------------------------
dnl Check for multiple precision support
if test $ol_with_mp = longlong || test $ol_with_mp = auto ; then
if test $ac_cv_sizeof_long_long -gt 4 ; then
ol_with_mp=longlong
AC_DEFINE(USE_MP_LONG_LONG,1,[define to use 'long long' for MP])
elif test $ol_with_mp = longlong ; then
AC_MSG_ERROR([long long unusable for multiple precision])
fi
fi
if test $ol_with_mp = long || test $ol_with_mp = auto ; then
if test $ac_cv_sizeof_long -gt 4 ; then
ol_with_mp=long
AC_DEFINE(USE_MP_LONG,1,[define to use 'long' for MP])
elif test $ol_with_mp = long ; then
AC_MSG_ERROR([long unusable for multiple precision])
fi
fi
if test $ol_with_mp = bignum || test $ol_with_mp = auto ; then
AC_CHECK_HEADERS(openssl/bn.h)
AC_CHECK_HEADERS(openssl/crypto.h)
if test "$ac_cv_header_openssl_bn_h" = "yes" &&
test "$ac_cv_header_openssl_crypto_h" = "yes" &&
test "$ol_with_tls" = "found" ; then
ol_with_mp=bignum
AC_DEFINE(USE_MP_BIGNUM,1,[define to use OpenSSL BIGNUM for MP])
elif test $ol_with_mp = bignum ; then
AC_MSG_ERROR([bignum not available])
fi
fi
if test $ol_with_mp = gmp || test $ol_with_mp = auto ; then
AC_CHECK_HEADERS(gmp.h)
AC_CHECK_LIB(gmp, __gmpz_add_ui)
if test $ac_cv_header_gmp_h = yes && test $ac_cv_lib_gmp___gmpz_add_ui = yes ; then
AC_DEFINE(USE_MP_GMP,1,[define to use GMP for MP])
ol_with_mp=gmp
elif test $ol_with_mp = gmp ; then
AC_MSG_ERROR([gmp not available])
fi
fi
if test $ol_with_mp = auto ; then
ol_with_mp=no
fi
dnl ----------------------------------------------------------------
dnl Checks for library functions.
AC_FUNC_MEMCMP
if test $ac_cv_func_memcmp_working = no ; then
AC_DEFINE(NEED_MEMCMP_REPLACEMENT,1,
[define if memcmp is not 8-bit clean or is otherwise broken])
fi
AC_FUNC_STRFTIME
OL_FUNC_INET_ATON
dnl Check for NT specific routines
AC_CHECK_FUNC(_spawnlp, AC_DEFINE(HAVE_SPAWNLP,1,[if you have spawnlp()]))
AC_CHECK_FUNC(_snprintf, [ac_cv_func_snprintf=yes
AC_DEFINE(snprintf, _snprintf, [define to snprintf routine])
])
AC_CHECK_FUNCS(vsnprintf _vsnprintf)
if test $ac_cv_func_vsnprintf = no -a $ac_cv_func__vsnprintf = yes ; then
ac_cv_func_vsnprintf=yes
AC_DEFINE(vsnprintf, _vsnprintf, [define to vsnprintf routine])
fi
AC_FUNC_VPRINTF
if test $ac_cv_func_vprintf = yes ; then
dnl check for vsnprintf
AC_CHECK_FUNCS(snprintf vsnprintf)
fi
AC_CHECK_FUNCS( \
bcopy \
closesocket \
chroot \
endgrent \
endpwent \
fcntl \
flock \
fstat \
getdtablesize \
geteuid \
getgrgid \
gethostname \
getpassphrase \
getpwuid \
getpwnam \
getspnam \
gettimeofday \
initgroups \
inet_ntoa_b \
ioctl \
lockf \
memcpy \
memmove \
memrchr \
mkstemp \
mktemp \
pipe \
read \
recv \
recvfrom \
setpwfile \
setgid \
setegid \
setsid \
setuid \
seteuid \
signal \
strdup \
strpbrk \
strrchr \
strsep \
strstr \
strtol \
strtoul \
strtoq \
strtouq \
strtoll \
strtoull \
strspn \
sysconf \
waitpid \
wait4 \
write \
send \
sendmsg \
sendto \
)
dnl We actually may need to replace more than this.
AC_REPLACE_FUNCS(getopt getpeereid)
if test "$ac_cv_func_getopt" != yes; then
LIBSRCS="$LIBSRCS getopt.c"
fi
if test "$ac_cv_func_getpeereid" != yes; then
AC_CHECK_FUNCS( getpeerucred )
if test "$ac_cv_func_getpeerucred" != yes ; then
AC_CHECK_MEMBERS([struct msghdr.msg_accrightslen],,,
[$ac_includes_default
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif])
if test "$ac_cv_member_struct_msghdr_msg_accrightslen" != yes; then
AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
[$ac_includes_default
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif])
fi
AC_CHECK_MEMBERS([struct stat.st_fstype, struct stat.st_vfstype])
if test "$ac_cv_member_struct_stat_st_fstype" = yes; then
AC_COMPILE_IFELSE([struct stat st; char *ptr=st.st_fstype;],
AC_DEFINE([HAVE_STRUCT_STAT_ST_FSTYPE_CHAR],1,[define to 1 if st_fstype is char *]),
AC_DEFINE([HAVE_STRUCT_STAT_ST_FSTYPE_INT],1,[define to 1 if st_fstype is int]))
fi
fi
LIBSRCS="$LIBSRCS getpeereid.c"
fi
if test "$ac_cv_func_snprintf" != yes ||
test "$ac_cv_func_vsnprintf" != yes; then
if test "$ac_cv_func_snprintf" != yes; then
AC_DEFINE(snprintf, ber_pvt_snprintf, [define to snprintf routine])
fi
if test "$ac_cv_func_vsnprintf" != yes; then
AC_DEFINE(vsnprintf, ber_pvt_vsnprintf, [define to snprintf routine])
fi
fi
dnl ----------------------------------------------------------------
dnl Sort out defines
if test "$ol_enable_slapi" != no ; then
dnl This check is done also if --enable-modules is used;
dnl it is duplicated here, 'cause it'd be cached anyway
AC_CHECK_HEADERS(ltdl.h)
if test $ac_cv_header_ltdl_h != yes ; then
AC_MSG_ERROR([could not locate <ltdl.h>])
fi
AC_CHECK_LIB(ltdl, lt_dlinit, [
SLAPI_LIBS=-lltdl
LIBSLAPI=slapi/libslapi.la
AC_DEFINE(HAVE_LIBLTDL,1,[define if you have libtool -ltdl])
],[AC_MSG_ERROR([could not locate libtool -lltdl])])
AC_DEFINE(LDAP_SLAPI,1, [define this to add SLAPI code])
fi
if test "$ol_enable_debug" != no ; then
if test "$ol_enable_debug" = traditional; then
AC_DEFINE(OLD_DEBUG,1,
[define to use the original debug style])
fi
AC_DEFINE(LDAP_DEBUG,1,
[define this to add debugging code])
fi
if test "$ol_enable_syslog" = yes ; then
AC_DEFINE(LDAP_SYSLOG,1,
[define this to add syslog code])
fi
if test "$ol_enable_proctitle" != no ; then
AC_DEFINE(LDAP_PROCTITLE,1,
[define this for LDAP process title support])
fi
if test "$ol_enable_referrals" != no ; then
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS,LDAP_VENDOR_VERSION,
[define to LDAP VENDOR VERSION])
fi
if test "$ol_enable_local" != no; then
AC_DEFINE(LDAP_PF_LOCAL,1,[define to support PF_LOCAL])
fi
if test "$ol_link_ipv6" != no; then
AC_DEFINE(LDAP_PF_INET6,1,[define to support PF_INET6])
fi
if test "$ol_enable_cleartext" != no ; then
AC_DEFINE(SLAPD_CLEARTEXT,1,[define to support cleartext passwords])
fi
if test "$ol_enable_crypt" != no ; then
AC_DEFINE(SLAPD_CRYPT,1,[define to support crypt(3) passwords])
fi
if test "$ol_link_spasswd" != no ; then
AC_DEFINE(SLAPD_SPASSWD,1,[define to support SASL passwords])
fi
if test "$ol_enable_rlookups" != no ; then
AC_DEFINE(SLAPD_RLOOKUPS,1,[define to support reverse lookups])
fi
if test "$ol_enable_aci" != no ; then
if test $ol_enable_dynacl = no ; then
ol_enable_dynacl=yes
AC_MSG_WARN([ACIs need dynacl])
fi
if test "$ol_enable_aci" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
dnl remove this after moving servers/slapd/aci.c in contrib/slapd-modules/acl
AC_MSG_ERROR([ACI build as dynamic module not supported (yet)])
else
MFLAG=SLAPD_MOD_STATIC
fi
WITH_ACI_ENABLED=$ol_enable_aci
AC_DEFINE_UNQUOTED(SLAPD_ACI_ENABLED,$MFLAG,[define to support per-object ACIs])
else
WITH_ACI_ENABLED=no
fi
if test "$ol_enable_dynacl" != no ; then
AC_DEFINE(SLAP_DYNACL,1,[define to support run-time loadable ACL])
fi
if test "$ol_link_modules" != no ; then
AC_DEFINE(SLAPD_MODULES,1,[define to support modules])
BUILD_SLAPD=yes
SLAPD_MODULES_LDFLAGS="-dlopen self"
fi
AC_DEFINE(SLAPD_MOD_STATIC,1,[statically linked module])
AC_DEFINE(SLAPD_MOD_DYNAMIC,2,[dynamically linked module])
dnl back-monitor goes first (well, after back-config)
if test "$ol_enable_monitor" != no ; then
BUILD_SLAPD=yes
BUILD_MONITOR=$ol_enable_monitor
if test "$ol_enable_monitor" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-monitor"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-monitor"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_MONITOR,$MFLAG,[define to support cn=Monitor backend])
fi
if test "$ol_enable_bdb" != no ; then
BUILD_SLAPD=yes
BUILD_BDB=$ol_enable_bdb
if test "$ol_enable_bdb" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-bdb"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-bdb"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_BDB,$MFLAG,[define to support BDB backend])
fi
if test "$ol_enable_dnssrv" != no ; then
BUILD_SLAPD=yes
BUILD_DNSSRV=$ol_enable_dnssrv
if test "$ol_enable_dnssrv" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-dnssrv"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-dnssrv"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_DNSSRV,$MFLAG,[define to support DNS SRV backend])
fi
if test "$ol_enable_hdb" != no ; then
BUILD_SLAPD=yes
BUILD_HDB=$ol_enable_hdb
if test "$ol_enable_hdb" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-hdb"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-hdb"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_HDB,$MFLAG,[define to support HDB backend])
fi
if test "$ol_enable_ldap" != no ; then
BUILD_SLAPD=yes
BUILD_LDAP=$ol_enable_ldap
if test "$ol_enable_ldap" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-ldap"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-ldap"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_LDAP,$MFLAG,[define to support LDAP backend])
fi
if test "$ol_enable_mdb" != no ; then
BUILD_SLAPD=yes
BUILD_MDB=$ol_enable_mdb
if test "$ol_enable_mdb" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-mdb"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-mdb"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_MDB,$MFLAG,[define to support MDB backend])
fi
if test "$ol_enable_meta" != no ; then
BUILD_SLAPD=yes
BUILD_META=$ol_enable_meta
BUILD_REWRITE=yes
if test "$ol_enable_meta" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-meta"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-meta"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_META,$MFLAG,[define to support LDAP Metadirectory backend])
fi
if test "$ol_enable_ndb" != no ; then
BUILD_SLAPD=yes
BUILD_NDB=$ol_enable_ndb
if test "$ol_enable_ndb" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-ndb"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-ndb"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_NDB,$MFLAG,[define to support NDB backend])
fi
if test "$ol_enable_null" != no ; then
BUILD_SLAPD=yes
BUILD_NULL=$ol_enable_null
if test "$ol_enable_null" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-null"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-null"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_NULL,$MFLAG,[define to support NULL backend])
fi
if test "$ol_enable_passwd" != no ; then
BUILD_SLAPD=yes
BUILD_PASSWD=$ol_enable_passwd
if test "$ol_enable_passwd" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-passwd"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-passwd"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_PASSWD,$MFLAG,[define to support PASSWD backend])
fi
if test "$ol_link_perl" != no ; then
BUILD_SLAPD=yes
BUILD_PERL=$ol_enable_perl
if test "$ol_enable_perl" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-perl"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-perl"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_PERL,$MFLAG,[define to support PERL backend])
fi
if test "$ol_enable_relay" != no ; then
BUILD_SLAPD=yes
BUILD_RELAY=$ol_enable_relay
if test "$ol_enable_relay" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-relay"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-relay"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_RELAY,$MFLAG,[define to support relay backend])
fi
if test "$ol_enable_shell" != no ; then
if test "$ol_link_threads" != no ; then
AC_MSG_WARN([Use of --without-threads is recommended with back-shell])
fi
BUILD_SLAPD=yes
BUILD_SHELL=$ol_enable_shell
if test "$ol_enable_shell" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-shell"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-shell"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_SHELL,$MFLAG,[define to support SHELL backend])
fi
if test "$ol_enable_sock" != no ; then
BUILD_SLAPD=yes
BUILD_SOCK=$ol_enable_sock
if test "$ol_enable_sock" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-sock"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-sock"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_SOCK,$MFLAG,[define to support SOCK backend])
fi
if test "$ol_link_sql" != no ; then
BUILD_SLAPD=yes
BUILD_SQL=$ol_enable_sql
if test "$ol_enable_sql" = mod; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-sql"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-sql"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_SQL,$MFLAG,[define to support SQL backend])
fi
if test "$ol_enable_accesslog" != no ; then
BUILD_ACCESSLOG=$ol_enable_accesslog
if test "$ol_enable_accesslog" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS accesslog.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS accesslog.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_ACCESSLOG,$MFLAG,[define for In-Directory Access Logging overlay])
fi
if test "$ol_enable_auditlog" != no ; then
BUILD_AUDITLOG=$ol_enable_auditlog
if test "$ol_enable_auditlog" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS auditlog.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS auditlog.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_AUDITLOG,$MFLAG,[define for Audit Logging overlay])
fi
if test "$ol_enable_collect" != no ; then
BUILD_COLLECT=$ol_enable_collect
if test "$ol_enable_collect" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS collect.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS collect.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_COLLECT,$MFLAG,[define for Collect overlay])
fi
if test "$ol_enable_constraint" != no ; then
BUILD_CONSTRAINT=$ol_enable_constraint
if test "$ol_enable_constraint" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS constraint.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS constraint.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_CONSTRAINT,$MFLAG,[define for Attribute Constraint overlay])
fi
if test "$ol_enable_dds" != no ; then
BUILD_DDS=$ol_enable_dds
if test "$ol_enable_dds" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dds.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dds.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_DDS,$MFLAG,[define for Dynamic Directory Services overlay])
fi
if test "$ol_enable_deref" != no ; then
BUILD_DEREF=$ol_enable_deref
if test "$ol_enable_deref" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS deref.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS deref.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_DEREF,$MFLAG,[define for Dynamic Directory Services overlay])
fi
if test "$ol_enable_dyngroup" != no ; then
BUILD_DYNGROUP=$ol_enable_dyngroup
if test "$ol_enable_dyngroup" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dyngroup.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dyngroup.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_DYNGROUP,$MFLAG,[define for Dynamic Group overlay])
fi
if test "$ol_enable_dynlist" != no ; then
BUILD_DYNLIST=$ol_enable_dynlist
if test "$ol_enable_dynlist" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dynlist.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dynlist.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_DYNLIST,$MFLAG,[define for Dynamic List overlay])
fi
if test "$ol_enable_memberof" != no ; then
BUILD_MEMBEROF=$ol_enable_memberof
if test "$ol_enable_memberof" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS memberof.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS memberof.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_MEMBEROF,$MFLAG,[define for Reverse Group Membership overlay])
fi
if test "$ol_enable_ppolicy" != no ; then
BUILD_PPOLICY=$ol_enable_ppolicy
if test "$ol_enable_ppolicy" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS ppolicy.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS ppolicy.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_PPOLICY,$MFLAG,[define for Password Policy overlay])
fi
if test "$ol_enable_proxycache" != no ; then
BUILD_PROXYCACHE=$ol_enable_proxycache
if test "$ol_enable_proxycache" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS pcache.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS pcache.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_PROXYCACHE,$MFLAG,[define for Proxy Cache overlay])
fi
if test "$ol_enable_refint" != no ; then
BUILD_REFINT=$ol_enable_refint
if test "$ol_enable_refint" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS refint.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS refint.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_REFINT,$MFLAG,[define for Referential Integrity overlay])
fi
if test "$ol_enable_retcode" != no ; then
BUILD_RETCODE=$ol_enable_retcode
if test "$ol_enable_retcode" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS retcode.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS retcode.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_RETCODE,$MFLAG,[define for Referential Integrity overlay])
fi
if test "$ol_enable_rwm" != no ; then
BUILD_REWRITE=yes
BUILD_RWM=$ol_enable_rwm
if test "$ol_enable_rwm" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS rwm.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS rwm_x.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_RWM,$MFLAG,[define for Rewrite/Remap overlay])
fi
if test "$ol_enable_seqmod" != no ; then
BUILD_SEQMOD=$ol_enable_seqmod
if test "$ol_enable_seqmod" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS seqmod.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS seqmod.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_SEQMOD,$MFLAG,[define for Sequential Modify overlay])
fi
if test "$ol_enable_sssvlv" != no ; then
BUILD_SSSVLV=$ol_enable_sssvlv
if test "$ol_enable_sssvlv" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS sssvlv.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS sssvlv.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_SSSVLV,$MFLAG,[define for ServerSideSort/VLV overlay])
fi
if test "$ol_enable_syncprov" != no ; then
BUILD_SYNCPROV=$ol_enable_syncprov
if test "$ol_enable_syncprov" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS syncprov.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS syncprov.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_SYNCPROV,$MFLAG,[define for Syncrepl Provider overlay])
fi
if test "$ol_enable_translucent" != no ; then
BUILD_TRANSLUCENT=$ol_enable_translucent
if test "$ol_enable_translucent" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS translucent.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS translucent.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_TRANSLUCENT,$MFLAG,[define for Translucent Proxy overlay])
fi
if test "$ol_enable_unique" != no ; then
BUILD_UNIQUE=$ol_enable_unique
if test "$ol_enable_unique" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS unique.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS unique.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_UNIQUE,$MFLAG,[define for Attribute Uniqueness overlay])
fi
if test "$ol_enable_valsort" != no ; then
BUILD_VALSORT=$ol_enable_valsort
if test "$ol_enable_valsort" = mod ; then
MFLAG=SLAPD_MOD_DYNAMIC
SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS valsort.la"
else
MFLAG=SLAPD_MOD_STATIC
SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS valsort.o"
fi
AC_DEFINE_UNQUOTED(SLAPD_OVER_VALSORT,$MFLAG,[define for Value Sorting overlay])
fi
if test "$ol_enable_rewrite" != no ; then
AC_DEFINE(ENABLE_REWRITE,1,[define to enable rewriting in back-ldap and back-meta])
BUILD_REWRITE=yes
fi
if test "$ol_enable_slapi" != no ; then
AC_DEFINE(ENABLE_SLAPI,1,[define to enable slapi library])
BUILD_SLAPI=yes
SLAPD_SLAPI_DEPEND=libslapi.a
fi
dnl ----------------------------------------------------------------
dnl
dnl For Windows build, we don't want to include -dlopen flags.
dnl They hurt more than they help.
dnl
if test "$ac_cv_mingw32" = yes -o $ol_cv_msvc = yes ; then
PLAT=NT
SLAPD_MODULES_LDFLAGS=
else
PLAT=UNIX
fi
AC_SUBST(LIBSRCS)
AC_SUBST(PLAT)
AC_SUBST(WITH_SASL)
AC_SUBST(WITH_TLS)
AC_SUBST(WITH_MODULES_ENABLED)
AC_SUBST(WITH_ACI_ENABLED)
AC_SUBST(BUILD_THREAD)
AC_SUBST(BUILD_LIBS_DYNAMIC)
AC_SUBST(BUILD_SLAPD)
dnl slapi
AC_SUBST(BUILD_SLAPI)
AC_SUBST(SLAPD_SLAPI_DEPEND)
dnl backends
AC_SUBST(BUILD_BDB)
AC_SUBST(BUILD_DNSSRV)
AC_SUBST(BUILD_HDB)
AC_SUBST(BUILD_LDAP)
AC_SUBST(BUILD_MDB)
AC_SUBST(BUILD_META)
AC_SUBST(BUILD_MONITOR)
AC_SUBST(BUILD_NDB)
AC_SUBST(BUILD_NULL)
AC_SUBST(BUILD_PASSWD)
AC_SUBST(BUILD_RELAY)
AC_SUBST(BUILD_PERL)
AC_SUBST(BUILD_SHELL)
AC_SUBST(BUILD_SOCK)
AC_SUBST(BUILD_SQL)
dnl overlays
AC_SUBST(BUILD_ACCESSLOG)
AC_SUBST(BUILD_AUDITLOG)
AC_SUBST(BUILD_COLLECT)
AC_SUBST(BUILD_CONSTRAINT)
AC_SUBST(BUILD_DDS)
AC_SUBST(BUILD_DENYOP)
AC_SUBST(BUILD_DEREF)
AC_SUBST(BUILD_DYNGROUP)
AC_SUBST(BUILD_DYNLIST)
AC_SUBST(BUILD_LASTMOD)
AC_SUBST(BUILD_MEMBEROF)
AC_SUBST(BUILD_PPOLICY)
AC_SUBST(BUILD_PROXYCACHE)
AC_SUBST(BUILD_REFINT)
AC_SUBST(BUILD_RETCODE)
AC_SUBST(BUILD_RWM)
AC_SUBST(BUILD_SEQMOD)
AC_SUBST(BUILD_SSSVLV)
AC_SUBST(BUILD_SYNCPROV)
AC_SUBST(BUILD_TRANSLUCENT)
AC_SUBST(BUILD_UNIQUE)
AC_SUBST(BUILD_VALSORT)
AC_SUBST(LDAP_LIBS)
AC_SUBST(SLAPD_LIBS)
AC_SUBST(BDB_LIBS)
AC_SUBST(SLAPD_NDB_LIBS)
AC_SUBST(SLAPD_NDB_INCS)
AC_SUBST(LTHREAD_LIBS)
AC_SUBST(LUTIL_LIBS)
AC_SUBST(WRAP_LIBS)
AC_SUBST(SLAPD_MODULES_CPPFLAGS)
AC_SUBST(SLAPD_MODULES_LDFLAGS)
AC_SUBST(SLAPD_NO_STATIC)
AC_SUBST(SLAPD_STATIC_BACKENDS)
AC_SUBST(SLAPD_DYNAMIC_BACKENDS)
AC_SUBST(SLAPD_STATIC_OVERLAYS)
AC_SUBST(SLAPD_DYNAMIC_OVERLAYS)
AC_SUBST(PERL_CPPFLAGS)
AC_SUBST(SLAPD_PERL_LDFLAGS)
AC_SUBST(MOD_PERL_LDFLAGS)
AC_SUBST(KRB4_LIBS)
AC_SUBST(KRB5_LIBS)
AC_SUBST(SASL_LIBS)
AC_SUBST(TLS_LIBS)
AC_SUBST(MODULES_LIBS)
AC_SUBST(SLAPI_LIBS)
AC_SUBST(LIBSLAPI)
AC_SUBST(AUTH_LIBS)
AC_SUBST(SLAPD_SLP_LIBS)
AC_SUBST(SLAPD_GMP_LIBS)
AC_SUBST(SLAPD_SQL_LDFLAGS)
AC_SUBST(SLAPD_SQL_LIBS)
AC_SUBST(SLAPD_SQL_INCLUDES)
dnl ----------------------------------------------------------------
dnl final help output
AC_ARG_WITH(xxinstall,[
See INSTALL file for further details.])
dnl ----------------------------------------------------------------
dnl final output
dnl
AC_CONFIG_FILES([Makefile:build/top.mk:Makefile.in:build/dir.mk]
[doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk]
[doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk]
[doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk]
[doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk]
[doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk]
[doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk]
[clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk]
[clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk]
[include/Makefile:build/top.mk:include/Makefile.in]
[libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk]
[libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk:build/lib-shared.mk]
[libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk:build/lib-shared.mk]
[libraries/libldap_r/Makefile:build/top.mk:libraries/libldap_r/Makefile.in:build/lib.mk:build/lib-shared.mk]
[libraries/liblunicode/Makefile:build/top.mk:libraries/liblunicode/Makefile.in:build/lib.mk:build/lib-static.mk]
[libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk]
[libraries/librewrite/Makefile:build/top.mk:libraries/librewrite/Makefile.in:build/lib.mk:build/lib-static.mk]
[servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk]
[servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk]
[servers/slapd/back-bdb/Makefile:build/top.mk:servers/slapd/back-bdb/Makefile.in:build/mod.mk]
[servers/slapd/back-dnssrv/Makefile:build/top.mk:servers/slapd/back-dnssrv/Makefile.in:build/mod.mk]
[servers/slapd/back-hdb/Makefile:build/top.mk:servers/slapd/back-hdb/Makefile.in:build/mod.mk]
[servers/slapd/back-ldap/Makefile:build/top.mk:servers/slapd/back-ldap/Makefile.in:build/mod.mk]
[servers/slapd/back-ldif/Makefile:build/top.mk:servers/slapd/back-ldif/Makefile.in:build/mod.mk]
[servers/slapd/back-mdb/Makefile:build/top.mk:servers/slapd/back-mdb/Makefile.in:build/mod.mk]
[servers/slapd/back-meta/Makefile:build/top.mk:servers/slapd/back-meta/Makefile.in:build/mod.mk]
[servers/slapd/back-monitor/Makefile:build/top.mk:servers/slapd/back-monitor/Makefile.in:build/mod.mk]
[servers/slapd/back-ndb/Makefile:build/top.mk:servers/slapd/back-ndb/Makefile.in:build/mod.mk]
[servers/slapd/back-null/Makefile:build/top.mk:servers/slapd/back-null/Makefile.in:build/mod.mk]
[servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/mod.mk]
[servers/slapd/back-perl/Makefile:build/top.mk:servers/slapd/back-perl/Makefile.in:build/mod.mk]
[servers/slapd/back-relay/Makefile:build/top.mk:servers/slapd/back-relay/Makefile.in:build/mod.mk]
[servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/mod.mk]
[servers/slapd/back-sock/Makefile:build/top.mk:servers/slapd/back-sock/Makefile.in:build/mod.mk]
[servers/slapd/back-sql/Makefile:build/top.mk:servers/slapd/back-sql/Makefile.in:build/mod.mk]
[servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk]
[servers/slapd/slapi/Makefile:build/top.mk:servers/slapd/slapi/Makefile.in:build/lib.mk:build/lib-shared.mk]
[servers/slapd/overlays/Makefile:build/top.mk:servers/slapd/overlays/Makefile.in:build/lib.mk]
[tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk]
[tests/run]
[tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk])
AC_CONFIG_COMMANDS([default],[[
chmod +x tests/run
date > stamp-h
BACKENDSC="servers/slapd/backends.c"
echo "Making $BACKENDSC"
rm -f $BACKENDSC
cat > $BACKENDSC << ENDX
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* This file is automatically generated by configure; please do not edit. */
#include "portable.h"
#include "slap.h"
ENDX
if test "${STATIC_BACKENDS}"; then
for b in config ${STATIC_BACKENDS}; do
bb=`echo "${b}" | sed -e 's/back-//'`
cat >> $BACKENDSC << ENDX
extern BI_init ${bb}_back_initialize;
ENDX
done
cat >> $BACKENDSC << ENDX
BackendInfo slap_binfo[] = {
ENDX
for b in config ${STATIC_BACKENDS}; do
bb=`echo "${b}" | sed -e 's/back-//'`
echo " Add ${bb} ..."
cat >> $BACKENDSC << ENDX
{ "${bb}", ${bb}_back_initialize },
ENDX
done
cat >> $BACKENDSC << ENDX
{ NULL, NULL },
};
/* end of generated file */
ENDX
fi
OVERLAYSC="servers/slapd/overlays/statover.c"
echo "Making $OVERLAYSC"
rm -f $OVERLAYSC
cat > $OVERLAYSC << ENDX
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 1998-2020 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* This file is automatically generated by configure; please do not edit. */
#include "portable.h"
#include "slap.h"
ENDX
if test "${STATIC_OVERLAYS}"; then
for o in ${STATIC_OVERLAYS}; do
oo=`echo "${o}" | sed -e 's/.o$//' -e 's/_x$//'`
cat >> $OVERLAYSC << ENDX
extern OV_init ${oo}_initialize;
ENDX
done
fi
cat >> $OVERLAYSC << ENDX
OverlayInit slap_oinfo[] = {
ENDX
if test "${STATIC_OVERLAYS}"; then
for o in ${STATIC_OVERLAYS}; do
oo=`echo "${o}" | sed -e 's/.o$//' -e 's/_x$//'`
echo " Add ${oo} ..."
cat >> $OVERLAYSC << ENDX
{ "${oo}", ${oo}_initialize },
ENDX
done
fi
cat >> $OVERLAYSC << ENDX
{ NULL, NULL },
};
/* end of generated file */
ENDX
if test "${ol_cv_mkdep}" = no; then
echo '(Do not "make depend"; we do not know how to build dependencies)'
else
echo 'Please run "make depend" to build dependencies'
fi
]],[[
STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS"
STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS"
]])
AC_OUTPUT
List of OpenLDAP Configuration OIDs allocated to contrib modules
OLcfgCt{Oc|At}:1 smbk5pwd
OLcfgCt{Oc|At}:2 autogroup
OLcfgCt{Oc|At}:3 nssov
OLcfgCt{Oc|At}:4 cloak
OLcfgCt{Oc|At}:5 lastbind
OpenLDAP Contributed Software README
OpenLDAP Project provides a number of freely-distributable LDAP
software packages. While distributed as part of OpenLDAP Software,
they are not necessarily supported by the OpenLDAP Project. Some
packages may be out of date. Each package in this directory has its
own use and may have different redistribution restrictions than typical
for OpenLDAP Software.
Current contributions:
ldapc++
LDAP C++ API
Contributed by SuSE Gmbh.
ldaptcl
LDAP TCL API
Contributed by NeoSoft
slapd-modules
Native-API modules
slapd-tools
Tools to use with slapd
slapi-plugins
SLAPI plugins
OpenLDAP Contributing Guidelines are available at:
<http://www.openldap.org/devel/contributing.html>.
$OpenLDAP$
Ralf Haferkamp <rhafer@suse.de>
Copyright 1998-2020 The OpenLDAP Foundation. All rights reserved.
COPYING RESTRICTIONS APPLY.
See COPYRIGHT and LICENSE files in the top-level directory of this
distribution (i.e., ../../COPYRIGHT and ../../LICENSE, respectively).
# $OpenLDAP$
##
# Copyright 2000-2020 The OpenLDAP Foundation. All Rights Reserved.
# COPYING RESTRICTIONS APPLY, see COPYRIGHT file
##
EXTRA_DIST=COPYRIGHT doxygen.rc LICENSE version.var version.sh
SUBDIRS = src examples
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# $OpenLDAP$
# Copyright 2000-2020 The OpenLDAP Foundation. All Rights Reserved.
# COPYING RESTRICTIONS APPLY, see COPYRIGHT file
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS TODO \
config.guess config.sub depcomp install-sh ltmain.sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NMEDIT = @NMEDIT@
OBJEXT = @OBJEXT@
OPENLDAP_CPP_API_VERSION = @OPENLDAP_CPP_API_VERSION@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = COPYRIGHT doxygen.rc LICENSE version.var version.sh
SUBDIRS = src examples
all: all-recursive
.SUFFIXES:
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
cd $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d $(distdir) || mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-lzma: distdir
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-exec-am:
install-html: install-html-recursive
install-info: install-info-recursive
install-man:
install-pdf: install-pdf-recursive
install-ps: install-ps-recursive
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
install-strip
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-generic \
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \
distclean distclean-generic distclean-libtool distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
This is an unstable development release of a LDAPv3 C++ Class Library.
It was created as the diploma thesis (final project) of my computer
science studies.
It is based upon the OpenLDAP C-API and so it needs the C-library and
Headerfiles installed.
Installation:
=============
Just run the "configure" script with the apropriate options. Especially
these two options can be imported, if you didn't install the OpenLDAP-
libraries in the default place:
--with-libldap=<path to libldap> : To tell configure where the OpenLDAP
C-libraries are located.
--with-ldap-includes=<path to ldap include files> : To tell configure
where the OpenLDAP include files are located.
--enable-debug to enable compliation with debugging symbols and stderr
output
(run "configure --help" to see all possible command line options)
If configure finishes without problems. You can simply call "make" to
build the library and "make install" to install it.
Documentation:
==============
Docs are very incomplete. You can either look in the source files for
the documentation comment of generate documentation using "doxygen"
or any other javadoc compatible documentation generator.
Bugreports and other feedback:
==============================
If you find bugs please feel free to send me a detailed report. All
other kinds of feedback are welcomed as well.
Ralf Haferkamp <rhafer@suse.de>
OpenLDAP C++ LDAP API ToDo items:
=================================
This is a list of projects that need getting done for the C++ API.
They are not listed in any specific order. Contribute to projects
based upon your personal priorities.
If you would like to work on any of these projects, please coordinate
by posting to OpenLDAP-devel mailing list:
http://www.OpenLDAP.org/lists
If you have a project you'd like added to the list, talk it up on
Developer's list or just do it.
Please read:
http://www.OpenLDAP.org/devel/programming.html
http://www.OpenLDAP.org/devel/contributing.html
- Add SASL Authentication
- Add methods to the Data Classes (LDAPAttribute, LDAPEntry) for higher
usability. (e.g. LDAPAttributeList::getAttribute(name), ... )
- implement some Controls/Extented Operations
- LDIF im/export library
- Rework the logging and debugging facilities
- write some more documentation about the design and structure of the
library.
- example applications
$ID$