Commit ac9395d8 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

updates from HEAD

parent 20a05ed4
......@@ -186,9 +186,14 @@ main( int argc, char **argv )
int referrals, timelimit, sizelimit, debug;
int authmethod, version, want_bindpw;
LDAP *ld = NULL;
int valuesReturnFilter;
BerElement *ber;
struct berval *bvalp;
char *vrFilter = NULL, *control = NULL, *s;
infile = NULL;
debug = verbose = not = vals2tmp = referrals =
debug = verbose = not = vals2tmp = referrals = valuesReturnFilter =
attrsonly = manageDSAit = ldif = want_bindpw = 0;
lutil_log_initialize(argc, argv);
......@@ -222,7 +227,7 @@ main( int argc, char **argv )
prog = (prog = strrchr(argv[0], *LDAP_DIRSEP)) == NULL ? argv[0] : prog + 1;
while (( i = getopt( argc, argv, "Aa:b:F:f:Ll:S:s:T:tuz:"
while (( i = getopt( argc, argv, "Aa:b:E:F:f:Ll:S:s:T:tuz:"
"Cd:D:h:H:IkKMnO:p:P:QR:U:vw:WxX:Y:Z")) != EOF )
{
switch( i ) {
......@@ -254,6 +259,47 @@ main( int argc, char **argv )
}
infile = strdup( optarg );
break;
case 'E': /* controls */
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -C incompatible with LDAPv%d\n",
prog, version );
return EXIT_FAILURE;
}
/* should be extended to support comma separated list of
* key/value pairs: -E foo=123,bar=567
*/
control = strdup( optarg );
if ( (s = strchr( control, '=' )) == NULL ) {
return EXIT_FAILURE;
}
*s++ = '\0';
if ( strcasecmp( control, "mv" ) == 0 ) {
/* ValuesReturnFilter control */
if (valuesReturnFilter!=0) {
fprintf( stderr, "ValuesReturnFilter previously specified");
return EXIT_FAILURE;
}
if ( *s == '!' ){
s++;
valuesReturnFilter=2;
} else {
valuesReturnFilter=1;
}
vrFilter = s;
version = LDAP_VERSION3;
break;
} else {
fprintf( stderr, "Invalid control name: %s\n", control );
usage(prog);
return EXIT_FAILURE;
}
case 'F': /* uri prefix */
if( urlpre ) free( urlpre );
urlpre = strdup( optarg );
......@@ -829,24 +875,56 @@ main( int argc, char **argv )
}
}
if ( manageDSAit ) {
if ( manageDSAit || valuesReturnFilter ) {
int err;
LDAPControl c;
LDAPControl *ctrls[2];
ctrls[0] = &c;
ctrls[1] = NULL;
int i=0;
LDAPControl c1,c2;
LDAPControl *ctrls[3];
if ( manageDSAit ) {
ctrls[i++]=&c1;
ctrls[i] = NULL;
c1.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
c1.ldctl_value.bv_val = NULL;
c1.ldctl_value.bv_len = 0;
c1.ldctl_iscritical = manageDSAit > 1;
}
c.ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
c.ldctl_value.bv_val = NULL;
c.ldctl_value.bv_len = 0;
c.ldctl_iscritical = manageDSAit > 1;
if ( valuesReturnFilter ) {
struct berval *bvalp;
ctrls[i++]=&c2;
ctrls[i] = NULL;
c2.ldctl_oid = LDAP_CONTROL_VALUESRETURNFILTER;
c2.ldctl_iscritical = valuesReturnFilter > 1;
if (( ber = ber_alloc_t(LBER_USE_DER)) == NULL )
exit( EXIT_FAILURE );
if ( err = put_vrFilter(ber, vrFilter)==-1 ) {
ber_free( ber, 1 );
fprintf( stderr, "Bad ValuesReturnFilter: %s\n", vrFilter );
exit( EXIT_FAILURE );
}
if ( ber_flatten( ber, &bvalp ) == LBER_ERROR )
return LDAP_NO_MEMORY;
c2.ldctl_value=(*bvalp);
}
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
ber_bvfree(bvalp);
ber_free( ber, 1 );
if( err != LDAP_OPT_SUCCESS ) {
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
c.ldctl_iscritical ? "critical " : "" );
if( c.ldctl_iscritical ) {
fprintf( stderr, "Could not set %scontrols\n",
(c1.ldctl_iscritical || c2.ldctl_iscritical)
? "critical " : "" );
if( c1.ldctl_iscritical && c2.ldctl_iscritical ) {
exit( EXIT_FAILURE );
}
}
......
Tools ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
ldapdelete *CDE *HI*K M*OPQR U*WXYZ cdef*h**k *n*p* vwx*
ldapmodify *CDEF*HI*K M*OPQR U*WXYZabcdef*h**k *n*p*r t vwx*
ldapmodrdn *CDE *HI*K M*OPQR U*WXYZ cdef*h**k *n*p*rs vwx*
ldappasswd A*CDE *HI* *O QRS U*WXYZa de *h** * * * s vwx*
ldapsearch A*CDE *HI*KLM*OPQRSTU*WXYZab*def*h**kl*n*p* stuvwx*z
Other Clients ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
fax500 * f h m
finger * c f i l p t x
go500 I * bcd f l p t x
go500gw I P * a cd f h l p t x
mail500 C * d f h lm v
rcpt500 U* abc f h l p st z
rp500 * ab d f x z
ud D * cd f l p s uv
* reserved
GJNgijmoqy
* General flags:
-C Chase Referrals
-D Bind DN
-E CommandSpecific Extensions (e.g., -E <[!]oid[=options]>*)
-e General Extensions (e.g., -e <[!]oid[=options]>*)
-H URI
-P protocol version
-V version information
-W prompt for bind password
-d debug
-h host
-n no-op
-p port
-v verbose
-w Bind password
* LDAPv3 Only
-x simple bind (not recommended excepting for
anonymous access, w/ -ZZ, or with ldaps://.
-M ManageDSAIT
-Z StartTLS
-Y SASL Mechanism (defaults to "best")
-R SASL Realm (defaults to empty)
-O SASL Security Options (defaults to "noanonymous,noplain")
-U SASL Authentication Identity (defaults to USER)
-X SASL Authorization Identity (defaults to empty)
-I SASL interactive mode (default: automatic)
-Q SASL quiet mode (default: automatic)
* LDAPv2+ Only (DEPRECATED)
-K LDAPv2 Kerberos Bind (Step 1 only)
-k LDAPv2 Kerberos Bind
---
$OpenLDAP$
.TH LDAPDELETE 1 "13 November 1995" "U-M LDAP LDVERSION"
.TH LDAPDELETE 1 "20 August 2001" "OpenLDAP LDVERSION"
.\" $OpenLDAP$
.\" Copyright 1998-2002 The OpenLDAP Foundation All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
ldapdelete \- ldap delete entry tool
ldapdelete \- LDAP delete entry tool
.SH SYNOPSIS
.B ldapdelete
.B [\-n]
.B [\-v]
.B [\-k]
.B [\-K]
.B [\-c]
.B [\-d debuglevel]
.B [\-f file]
.B [\-D binddn]
.B [\-w passwd]
.B [\-h ldaphost]
.B [\-p ldapport]
.B [dn]...
[\c
.BR \-n ]
[\c
.BR \-v ]
[\c
.BR \-k ]
[\c
.BR \-K ]
[\c
.BR \-c ]
[\c
.BR \-C ]
[\c
.BR \-M[M] ]
[\c
.BI \-d \ debuglevel\fR]
[\c
.BI \-f \ file\fR]
[\c
.BI \-D \ binddn\fR]
[\c
.BR \-W ]
[\c
.BI \-w \ passwd\fR]
[\c
.BI \-H \ ldapuri\fR]
[\c
.BI \-h \ ldaphost\fR]
[\c
.BI \-P \ 2\fR\||\|\fI3\fR]
[\c
.BI \-p \ ldapport\fR]
[\c
.BR \-O \ security-properties ]
[\c
.BI \-U \ authcid\fR]
[\c
.BR \-x ]
[\c
.BR \-I ]
[\c
.BR \-Q ]
[\c
.BI \-X \ authzid\fR]
[\c
.BI \-Y \ mech\fR]
[\c
.BR \-Z[Z] ]
[\c
.IR dn ]...
.SH DESCRIPTION
.I ldapdelete
is a shell-accessible interface to the
......@@ -23,9 +64,10 @@ library call.
.LP
.B ldapdelete
opens a connection to an LDAP server, binds, and deletes one or more
entries. If one or more \fIdn\fP arguments are provided, entries with
those Distinguished Names are deleted. Each \fIdn\fP should be a
string-represented DN as defined in RFC 1779. If no \fIdn\fP arguments
entries. If one or more \fIDN\fP arguments are provided, entries with
those Distinguished Names are deleted. Each \fIDN\fP should be provided
using the LDAPv3 string representation as defined in RFC 2253.
If no \fIdn\fP arguments
are provided, a list of DNs is read from standard input (or from
\fIfile\fP if the -f flag is used).
.SH OPTIONS
......@@ -38,16 +80,19 @@ debugging in conjunction with -v.
Use verbose mode, with many diagnostics written to standard output.
.TP
.B \-k
Use Kerberos authentication instead of simple authentication. It is
Use Kerberos IV authentication instead of simple authentication. It is
assumed that you already have a valid ticket granting ticket. This option
only has effect if
. B ldapdelete
is compiled with KERBEROS defined.
is compiled with Kerberos support.
.TP
.B \-K
Same as \-k, but only does step 1 of the kerberos bind. This is useful
Same as \-k, but only does step 1 of the Kerberos IV bind. This is useful
when connecting to a slapd and there is no x500dsa.hostname principal
registered with your kerberos servers.
registered with your Kerberos Domain Controller(s).
.TP
.B \-C
Automatically chase referrals.
.TP
.B \-c
Continuous operation mode. Errors are reported, but
......@@ -55,55 +100,110 @@ Continuous operation mode. Errors are reported, but
will continue with deletions. The default is to exit after
reporting an error.
.TP
.B \-d debuglevel
.B \-M[M]
Enable manage DSA IT control.
.B \-MM
makes control critical.
.TP
.BI \-d \ debuglevel
Set the LDAP debugging level to \fIdebuglevel\fP.
.B ldapdelete
must be compiled with LDAP_DEBUG defined for this option to have any effect.
.TP
.B \-f file
Read a series of lines from \fIfile\fP, performing one LDAP search for
each line. In this case, the \fIfilter\fP given on the command line
is treated as a pattern where the first occurrence of \fB%s\fP is
replaced with a line from \fIfile\fP.
.BI \-f \ file
Read a series of DNs from \fIfile\fP, one per line, performing an
LDAP delete for each.
.TP
.B \-x
Use simple authentication instead of SASL.
.TP
.BI \-D \ binddn
Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
.TP
.B \-D binddn
Use \fIbinddn\fP to bind to the X.500 directory. \fIbinddn\fP should be
a string-represented DN as defined in RFC 1779.
.B \-W
Prompt for simple authentication.
This is used instead of specifying the password on the command line.
.TP
.B \-w passwd
.BI \-w \ passwd
Use \fIpasswd\fP as the password for simple authentication.
.TP
.B \-h ldaphost
.BI \-H \ ldapuri
Specify URI(s) referring to the ldap server(s).
.TP
.BI \-h \ ldaphost
Specify an alternate host on which the ldap server is running.
Deprecated in favor of -H.
.TP
.B \-p ldapport
.BI \-p \ ldapport
Specify an alternate TCP port where the ldap server is listening.
Deprecated in favor of -H.
.TP
.BI \-P \ 2\fR\||\|\fI3
Specify the LDAP protocol version to use.
.TP
.B \-r
Do a recursive delete. If the DN specified isn't a leaf, its
children, and all their children are deleted down the tree. No
verification is done, so if you add this switch, ldapdelete will
happily delete large portions of your tree. Use with care.
.TP
.BI \-O \ security-properties
Specify SASL security properties.
.TP
.B \-I
Enable SASL Interactive mode. Always prompt. Default is to prompt
only as needed.
.TP
.B \-Q
Enable SASL Quiet mode. Never prompt.
.TP
.BI \-U \ authcid
Specify the authentication ID for SASL bind. The form of the identity depends on the
actual SASL mechanism used.
.TP
.BI \-X \ authzid
Specify the requested authorization ID for SASL bind.
.I authzid
must be one of the following formats:
.B dn:\c
.I <distinguished name>
or
.B u:\c
.I <username>
.TP
.BI \-Y \ mech
Specify the SASL mechanism to be used for authentication. If it's not
specified, the program will choose the best mechanism the server knows.
.TP
.B \-Z[Z]
Issue StartTLS (Transport Layer Security) extended operation. If you use
.B \-ZZ\c
, the command will require the operation to be successful.
.SH EXAMPLE
The following command:
.LP
.nf
ldapdelete "cn=Delete Me, o=University of Michigan, c=US"
ldapdelete "cn=Delete Me,dc=example,dc=com"
.fi
.LP
will attempt to delete the entry named with commonName "Delete Me"
directly below the University of Michigan organizational entry. Of
course it would probably be necessary to supply a \fIbinddn\fP and
\fIpasswd\fP for deletion to be allowed (see the -D and -w options).
will attempt to delete the entry named "cn=Delete Me,dc=example,dc=com".
Of course it would probably be necessary to supply authentication
credentials.
.SH DIAGNOSTICS
Exit status is 0 if no errors occur. Errors result in a non-zero exit
status and a diagnostic message being written to standard error.
.SH "SEE ALSO"
.BR ldap.conf (5),
.BR ldapadd (1),
.BR ldapmodify (1),
.BR ldapmodrdn (1),
.BR ldapsearch (1),
.BR ldap (3),
.BR ldap_delete (3)
.LP
Kille, S.,
.IR "A String Representation of Distinguished Names",
.SM RFC
1779,
ISODE Consortium, March 1995.
.SH BUGS
There is no interactive mode, but there probably should be.
.SH AUTHOR
The OpenLDAP Project <http://www.openldap.org/>
.SH ACKNOWLEDGEMENTS
.B OpenLDAP
is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
.B OpenLDAP
is derived from University of Michigan LDAP 3.3 Release.
......@@ -193,8 +193,7 @@ An invalid filter was supplied to ldap_search() (e.g., unbalanced
parentheses).
.TP
.SM LDAP_PARAM_ERROR
An ldap routine was called with a bad parameter (e.g., a NULL ld
pointer, etc.).
An ldap routine was called with a bad parameter.
.TP
.SM LDAP_NO_MEMORY
An memory allocation (e.g., malloc(3) or other dynamic memory
......
......@@ -15,10 +15,8 @@ make it easy to tie an existing database to the
front-end.
.SH WARNING
.B "This backend's calling conventions have changed since OpenLDAP 2.0."
The operations receive a new "opid:" (operation ID) line, to be used
instead of "msgid:".
The "msgid:" line will be removed in a future version.
Also, abandon now gets a new "abandonid:" line.
The abandon operation now gets a new "pid:" line.
The "msgid:" lines will be removed in a future version.
.SH CONFIGURATION
These
.B slapd.conf
......@@ -36,17 +34,15 @@ Each option is followed by the input lines that the program receives:
.B abandon <pathname> <argument>...
.nf
ABANDON
opid: <operation ID>
msgid: <message ID of operation to abandon>
<repeat { "suffix:" <database suffix DN> }>
abandonid: <operation ID of operation to abandon>
pid: <process ID of operation to abandon>
.fi
.TP
.B add <pathname> <argument>...
.nf
ADD
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
<entry in LDIF format>
.fi
......@@ -54,8 +50,7 @@ msgid: <message ID>
.B bind <pathname> <argument>...
.nf
BIND
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
method: <method number>
......@@ -66,8 +61,7 @@ cred: <credentials>
.B compare <pathname> <argument>...
.nf
COMPARE
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<attribute>: <value>
......@@ -76,8 +70,7 @@ dn: <DN>
.B delete <pathname> <argument>...
.nf
DELETE
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
.fi
......@@ -85,8 +78,7 @@ dn: <DN>
.B modify <pathname> <argument>...
.nf
MODIFY
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<repeat {
......@@ -99,8 +91,7 @@ dn: <DN>
.B modrdn <pathname> <argument>...
.nf
MODRDN
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
newrdn: <new RDN>
......@@ -111,8 +102,7 @@ deleteoldrdn: <0 or 1>
.B search <pathname> <argument>...
.nf
SEARCH
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
base: <base DN>
scope: <0-2, see ldap.h>
......@@ -127,16 +117,11 @@ attrs: <"all" or space-separated attribute list>
.B unbind <pathname> <argument>...
.nf
UNBIND
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <bound DN>
.fi
.LP
An
.I operation ID
is a "connection ID/message ID" string identifying an operation.
.LP
Note that you need only supply configuration lines for those commands you
want the backend to handle.
Operations for which a command is not supplied will be refused with an
......
......@@ -204,6 +204,22 @@ disables Start TLS from forcing session to anonymous status (see also
disables StartTLS if authenticated (see also
.BR tls_2_anon ).
.TP
.B gentlehup { on | off }
A SIGHUP signal will only cause a 'gentle' shutdown-attempt:
.B Slapd
will stop listening for new connections, but will not close the
connections to the current clients. It terminates when all clients
have closed their connections (if they ever do), or \- as before \-
if it receives a SIGTERM signal. This can be useful if you wish to
terminate the server and start a new
.B slapd
server
.B with another database,
without disrupting the currently active clients.
The default is off. You may wish to use
.B idletimeout
along with this option.
.TP
.B idletimeout <integer>
Specify the number of seconds to wait before forcibly closing
an idle client connection. A idletimeout of 0 disables this
......
......@@ -413,9 +413,8 @@ ldap_create_control(
LDAPControl *ctrl;
struct berval *bvalp;
if ( requestOID == NULL || ctrlp == NULL ) {
return LDAP_PARAM_ERROR;
}
assert( requestOID != NULL );
assert( ctrlp != NULL );
ctrl = (LDAPControl *) LDAP_MALLOC( sizeof(LDAPControl) );
if ( ctrl == NULL ) {
......
/* $OpenLDAP$ */
/*
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/*
* locate LDAP servers using DNS SRV records.
* Location code based on MIT Kerberos KDC location code.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/param.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include "ldap-int.h"
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif
/* Sometimes this is not defined. */
#ifndef T_SRV
#define T_SRV 33