2004-02-27 03:03:41 +08:00
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2007-01-03 04:00:42 +08:00
|
|
|
* Copyright 1998-2007 The OpenLDAP Foundation.
|
2004-02-27 03:03:41 +08:00
|
|
|
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
|
|
|
|
* Portions Copyright 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 file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was initially developed by Kurt Zeilenga for inclusion
|
|
|
|
* in OpenLDAP Software. Additional signficant contributors include
|
|
|
|
* Jong Hyuk Choi
|
|
|
|
* Pierangelo Masarati
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/stdlib.h>
|
|
|
|
|
|
|
|
#include <ac/ctype.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
#include <ac/unistd.h>
|
|
|
|
|
|
|
|
#include <lber.h>
|
|
|
|
#include <ldif.h>
|
|
|
|
#include <lutil.h>
|
|
|
|
|
|
|
|
#include "slapcommon.h"
|
|
|
|
|
|
|
|
static char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
|
2007-08-26 23:39:45 +08:00
|
|
|
static char maxcsnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE * ( SLAP_SYNC_SID_MAX + 1 ) ];
|
2004-02-27 03:03:41 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
slapadd( int argc, char **argv )
|
|
|
|
{
|
2005-10-13 01:34:06 +08:00
|
|
|
char *buf = NULL;
|
2004-02-27 03:03:41 +08:00
|
|
|
const char *text;
|
|
|
|
char textbuf[SLAP_TEXT_BUFLEN] = { '\0' };
|
|
|
|
size_t textlen = sizeof textbuf;
|
2005-02-17 23:18:30 +08:00
|
|
|
const char *progname = "slapadd";
|
2004-02-27 03:03:41 +08:00
|
|
|
|
|
|
|
struct berval csn;
|
2007-08-26 23:39:45 +08:00
|
|
|
struct berval maxcsn[ SLAP_SYNC_SID_MAX + 1 ];
|
|
|
|
unsigned long sid;
|
2005-10-13 01:34:06 +08:00
|
|
|
struct berval bvtext;
|
2004-02-27 03:03:41 +08:00
|
|
|
Attribute *attr;
|
|
|
|
Entry *ctxcsn_e;
|
2005-01-14 12:26:59 +08:00
|
|
|
ID ctxcsn_id, id;
|
2005-10-13 07:17:28 +08:00
|
|
|
OperationBuffer opbuf;
|
2005-10-13 01:34:06 +08:00
|
|
|
Operation *op;
|
|
|
|
|
|
|
|
int match;
|
2005-07-15 03:52:08 +08:00
|
|
|
int checkvals;
|
2006-05-29 10:41:06 +08:00
|
|
|
int lineno, nextline;
|
2005-10-13 01:34:06 +08:00
|
|
|
int lmax;
|
|
|
|
int rc = EXIT_SUCCESS;
|
|
|
|
int manage = 0;
|
2005-08-01 23:26:13 +08:00
|
|
|
|
2007-08-29 03:35:57 +08:00
|
|
|
/* default "000" */
|
|
|
|
csnsid = 0;
|
|
|
|
|
2004-02-27 03:03:41 +08:00
|
|
|
slap_tool_init( progname, SLAPADD, argc, argv );
|
|
|
|
|
2005-10-13 07:17:28 +08:00
|
|
|
memset( &opbuf, 0, sizeof(opbuf) );
|
2007-05-19 07:54:26 +08:00
|
|
|
op = &opbuf.ob_op;
|
|
|
|
op->o_hdr = &opbuf.ob_hdr;
|
2005-08-01 23:26:13 +08:00
|
|
|
|
2004-02-27 03:03:41 +08:00
|
|
|
if( !be->be_entry_open ||
|
|
|
|
!be->be_entry_close ||
|
2005-09-01 07:23:13 +08:00
|
|
|
!be->be_entry_put ||
|
|
|
|
(update_ctxcsn &&
|
|
|
|
(!be->be_dn2id_get ||
|
2007-08-11 12:19:53 +08:00
|
|
|
!be->be_entry_get ||
|
2005-09-01 07:23:13 +08:00
|
|
|
!be->be_entry_modify)) )
|
2004-02-27 03:03:41 +08:00
|
|
|
{
|
|
|
|
fprintf( stderr, "%s: database doesn't support necessary operations.\n",
|
|
|
|
progname );
|
2004-07-17 23:35:06 +08:00
|
|
|
if ( dryrun ) {
|
|
|
|
fprintf( stderr, "\t(dry) continuing...\n" );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
exit( EXIT_FAILURE );
|
|
|
|
}
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
|
|
|
|
2005-01-24 11:41:51 +08:00
|
|
|
checkvals = (slapMode & SLAP_TOOL_QUICK) ? 0 : 1;
|
|
|
|
|
2004-02-27 03:03:41 +08:00
|
|
|
lmax = 0;
|
2006-05-29 10:41:06 +08:00
|
|
|
nextline = 0;
|
2004-02-27 03:03:41 +08:00
|
|
|
|
2007-08-29 02:36:42 +08:00
|
|
|
/* enforce schema checking unless not disabled */
|
|
|
|
if ( (slapMode & SLAP_TOOL_NO_SCHEMA_CHECK) == 0) {
|
|
|
|
SLAP_DBFLAGS(be) &= ~(SLAP_DBFLAG_NO_SCHEMA_CHECK);
|
|
|
|
}
|
|
|
|
|
2004-07-17 22:45:07 +08:00
|
|
|
if( !dryrun && be->be_entry_open( be, 1 ) != 0 ) {
|
2004-02-27 03:03:41 +08:00
|
|
|
fprintf( stderr, "%s: could not open database.\n",
|
|
|
|
progname );
|
|
|
|
exit( EXIT_FAILURE );
|
|
|
|
}
|
|
|
|
|
2005-01-14 12:26:59 +08:00
|
|
|
if ( update_ctxcsn ) {
|
2007-08-26 23:39:45 +08:00
|
|
|
maxcsn[ 0 ].bv_val = maxcsnbuf;
|
|
|
|
for ( sid = 1; sid <= SLAP_SYNC_SID_MAX; sid++ ) {
|
|
|
|
maxcsn[ sid ].bv_val = maxcsn[ sid - 1 ].bv_val + LDAP_LUTIL_CSNSTR_BUFSIZE;
|
|
|
|
maxcsn[ sid ].bv_len = 0;
|
|
|
|
}
|
2005-01-14 12:26:59 +08:00
|
|
|
}
|
|
|
|
|
2006-05-29 10:41:06 +08:00
|
|
|
/* nextline is the line number of the end of the current entry */
|
|
|
|
for( lineno=1; ldif_read_record( ldiffp, &nextline, &buf, &lmax );
|
|
|
|
lineno=nextline+1 ) {
|
2006-05-31 09:52:32 +08:00
|
|
|
Entry *e;
|
2006-05-29 10:41:06 +08:00
|
|
|
|
|
|
|
if ( lineno < jumpline )
|
|
|
|
continue;
|
|
|
|
|
2006-05-31 09:52:32 +08:00
|
|
|
e = str2entry2( buf, checkvals );
|
2004-02-27 03:03:41 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize text buffer
|
|
|
|
*/
|
|
|
|
bvtext.bv_len = textlen;
|
|
|
|
bvtext.bv_val = textbuf;
|
|
|
|
bvtext.bv_val[0] = '\0';
|
|
|
|
|
|
|
|
if( e == NULL ) {
|
|
|
|
fprintf( stderr, "%s: could not parse entry (line=%d)\n",
|
|
|
|
progname, lineno );
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
if( continuemode ) continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure the DN is not empty */
|
2005-04-09 19:27:35 +08:00
|
|
|
if( BER_BVISEMPTY( &e->e_nname ) &&
|
|
|
|
!BER_BVISEMPTY( be->be_nsuffix )) {
|
2004-02-27 03:03:41 +08:00
|
|
|
fprintf( stderr, "%s: empty dn=\"%s\" (line=%d)\n",
|
|
|
|
progname, e->e_dn, lineno );
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
entry_free( e );
|
|
|
|
if( continuemode ) continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check backend */
|
2007-07-13 11:18:20 +08:00
|
|
|
if( select_backend( &e->e_nname, nosubordinates )
|
2004-02-27 03:03:41 +08:00
|
|
|
!= be )
|
|
|
|
{
|
|
|
|
fprintf( stderr, "%s: line %d: "
|
|
|
|
"database (%s) not configured to hold \"%s\"\n",
|
|
|
|
progname, lineno,
|
|
|
|
be ? be->be_suffix[0].bv_val : "<none>",
|
|
|
|
e->e_dn );
|
|
|
|
fprintf( stderr, "%s: line %d: "
|
|
|
|
"database (%s) not configured to hold \"%s\"\n",
|
|
|
|
progname, lineno,
|
|
|
|
be ? be->be_nsuffix[0].bv_val : "<none>",
|
|
|
|
e->e_ndn );
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
entry_free( e );
|
|
|
|
if( continuemode ) continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-12 06:24:18 +08:00
|
|
|
{
|
2004-02-27 03:03:41 +08:00
|
|
|
Attribute *oc = attr_find( e->e_attrs,
|
|
|
|
slap_schema.si_ad_objectClass );
|
|
|
|
|
|
|
|
if( oc == NULL ) {
|
|
|
|
fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n",
|
|
|
|
progname, e->e_dn, lineno,
|
|
|
|
"no objectClass attribute");
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
entry_free( e );
|
|
|
|
if( continuemode ) continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check schema */
|
2005-08-01 23:26:13 +08:00
|
|
|
op->o_bd = be;
|
|
|
|
|
2006-01-09 04:18:14 +08:00
|
|
|
if ( (slapMode & SLAP_TOOL_NO_SCHEMA_CHECK) == 0) {
|
2006-11-28 03:59:59 +08:00
|
|
|
rc = entry_schema_check( op, e, NULL, manage, 1,
|
2006-01-09 04:18:14 +08:00
|
|
|
&text, textbuf, textlen );
|
2004-02-27 03:03:41 +08:00
|
|
|
|
2006-01-09 04:18:14 +08:00
|
|
|
if( rc != LDAP_SUCCESS ) {
|
|
|
|
fprintf( stderr, "%s: dn=\"%s\" (line=%d): (%d) %s\n",
|
|
|
|
progname, e->e_dn, lineno, rc, text );
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
entry_free( e );
|
|
|
|
if( continuemode ) continue;
|
|
|
|
break;
|
|
|
|
}
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( SLAP_LASTMOD(be) ) {
|
|
|
|
time_t now = slap_get_time();
|
|
|
|
char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
|
|
|
|
struct berval vals[ 2 ];
|
|
|
|
|
|
|
|
struct berval name, timestamp;
|
|
|
|
|
|
|
|
struct berval nvals[ 2 ];
|
|
|
|
struct berval nname;
|
|
|
|
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
|
|
|
|
|
|
|
|
vals[1].bv_len = 0;
|
|
|
|
vals[1].bv_val = NULL;
|
|
|
|
|
|
|
|
nvals[1].bv_len = 0;
|
|
|
|
nvals[1].bv_val = NULL;
|
|
|
|
|
2007-08-29 03:35:57 +08:00
|
|
|
csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), csnsid, 0 );
|
2004-02-27 03:03:41 +08:00
|
|
|
csn.bv_val = csnbuf;
|
|
|
|
|
|
|
|
timestamp.bv_val = timebuf;
|
2005-06-07 12:12:14 +08:00
|
|
|
timestamp.bv_len = sizeof(timebuf);
|
|
|
|
|
|
|
|
slap_timestamp( &now, ×tamp );
|
2004-02-27 03:03:41 +08:00
|
|
|
|
2004-07-20 05:43:03 +08:00
|
|
|
if ( BER_BVISEMPTY( &be->be_rootndn ) ) {
|
|
|
|
BER_BVSTR( &name, SLAPD_ANONYMOUS );
|
|
|
|
nname = name;
|
2004-02-27 03:03:41 +08:00
|
|
|
} else {
|
|
|
|
name = be->be_rootdn;
|
|
|
|
nname = be->be_rootndn;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( attr_find( e->e_attrs, slap_schema.si_ad_entryUUID )
|
|
|
|
== NULL )
|
|
|
|
{
|
|
|
|
vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
|
|
|
|
vals[0].bv_val = uuidbuf;
|
2005-04-22 07:36:37 +08:00
|
|
|
attr_merge_normalize_one( e, slap_schema.si_ad_entryUUID, vals, NULL );
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if( attr_find( e->e_attrs, slap_schema.si_ad_creatorsName )
|
|
|
|
== NULL )
|
|
|
|
{
|
|
|
|
vals[0] = name;
|
|
|
|
nvals[0] = nname;
|
|
|
|
attr_merge( e, slap_schema.si_ad_creatorsName, vals, nvals );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( attr_find( e->e_attrs, slap_schema.si_ad_modifiersName )
|
|
|
|
== NULL )
|
|
|
|
{
|
|
|
|
vals[0] = name;
|
|
|
|
nvals[0] = nname;
|
|
|
|
attr_merge( e, slap_schema.si_ad_modifiersName, vals, nvals );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( attr_find( e->e_attrs, slap_schema.si_ad_createTimestamp )
|
|
|
|
== NULL )
|
|
|
|
{
|
|
|
|
vals[0] = timestamp;
|
|
|
|
attr_merge( e, slap_schema.si_ad_createTimestamp, vals, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp )
|
|
|
|
== NULL )
|
|
|
|
{
|
|
|
|
vals[0] = timestamp;
|
|
|
|
attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( attr_find( e->e_attrs, slap_schema.si_ad_entryCSN )
|
|
|
|
== NULL )
|
|
|
|
{
|
|
|
|
vals[0] = csn;
|
|
|
|
attr_merge( e, slap_schema.si_ad_entryCSN, vals, NULL );
|
|
|
|
}
|
|
|
|
|
2005-01-14 12:26:59 +08:00
|
|
|
if ( update_ctxcsn ) {
|
2007-08-27 01:03:22 +08:00
|
|
|
int rc_sid;
|
2007-08-26 23:39:45 +08:00
|
|
|
|
2004-02-27 03:03:41 +08:00
|
|
|
attr = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN );
|
2007-08-26 23:39:45 +08:00
|
|
|
assert( attr != NULL );
|
2007-08-27 01:03:22 +08:00
|
|
|
|
|
|
|
rc_sid = slap_parse_csn_sid( &attr->a_nvals[ 0 ] );
|
|
|
|
if ( rc_sid < 0 ) {
|
2007-08-26 23:39:45 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "%s: could not "
|
|
|
|
"extract SID from entryCSN=%s\n",
|
|
|
|
progname, attr->a_nvals[ 0 ].bv_val, 0 );
|
|
|
|
|
2004-02-27 03:03:41 +08:00
|
|
|
} else {
|
2007-08-27 01:03:22 +08:00
|
|
|
assert( rc_sid <= SLAP_SYNC_SID_MAX );
|
2007-08-26 23:39:45 +08:00
|
|
|
|
2007-08-27 01:03:22 +08:00
|
|
|
sid = (unsigned)rc_sid;
|
2007-08-26 23:39:45 +08:00
|
|
|
if ( maxcsn[ sid ].bv_len != 0 ) {
|
|
|
|
match = 0;
|
|
|
|
value_match( &match, slap_schema.si_ad_entryCSN,
|
|
|
|
slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
|
|
|
|
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
|
|
|
|
&maxcsn[ sid ], &attr->a_nvals[0], &text );
|
|
|
|
} else {
|
|
|
|
match = -1;
|
|
|
|
}
|
|
|
|
if ( match < 0 ) {
|
|
|
|
strcpy( maxcsn[ sid ].bv_val, attr->a_nvals[0].bv_val );
|
|
|
|
maxcsn[ sid ].bv_len = attr->a_nvals[0].bv_len;
|
|
|
|
}
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-14 12:26:59 +08:00
|
|
|
if ( !dryrun ) {
|
|
|
|
id = be->be_entry_put( be, e, &bvtext );
|
|
|
|
if( id == NOID ) {
|
|
|
|
fprintf( stderr, "%s: could not add entry dn=\"%s\" "
|
|
|
|
"(line=%d): %s\n", progname, e->e_dn,
|
|
|
|
lineno, bvtext.bv_val );
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
entry_free( e );
|
|
|
|
if( continuemode ) continue;
|
|
|
|
break;
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
2005-07-27 16:48:43 +08:00
|
|
|
if ( verbose )
|
2005-01-14 12:26:59 +08:00
|
|
|
fprintf( stderr, "added: \"%s\" (%08lx)\n",
|
|
|
|
e->e_dn, (long) id );
|
2005-07-27 16:48:43 +08:00
|
|
|
} else {
|
|
|
|
if ( verbose )
|
|
|
|
fprintf( stderr, "added: \"%s\"\n",
|
|
|
|
e->e_dn );
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
entry_free( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
bvtext.bv_len = textlen;
|
|
|
|
bvtext.bv_val = textbuf;
|
|
|
|
bvtext.bv_val[0] = '\0';
|
|
|
|
|
2007-08-26 23:39:45 +08:00
|
|
|
if ( rc == EXIT_SUCCESS && update_ctxcsn && !dryrun && sid != SLAP_SYNC_SID_MAX + 1 ) {
|
2005-01-14 12:26:59 +08:00
|
|
|
ctxcsn_id = be->be_dn2id_get( be, be->be_nsuffix );
|
|
|
|
if ( ctxcsn_id == NOID ) {
|
|
|
|
fprintf( stderr, "%s: context entry is missing\n", progname );
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
} else {
|
2007-08-11 12:19:53 +08:00
|
|
|
ctxcsn_e = be->be_entry_get( be, ctxcsn_id );
|
|
|
|
if ( ctxcsn_e != NULL ) {
|
2007-08-27 15:13:25 +08:00
|
|
|
Entry *e = entry_dup( ctxcsn_e );
|
2007-11-12 11:50:31 +08:00
|
|
|
int change;
|
2007-08-27 15:13:25 +08:00
|
|
|
attr = attr_find( e->e_attrs, slap_schema.si_ad_contextCSN );
|
2005-04-09 18:00:15 +08:00
|
|
|
if ( attr ) {
|
2007-08-26 23:39:45 +08:00
|
|
|
int i;
|
|
|
|
|
2007-11-12 11:50:31 +08:00
|
|
|
change = 0;
|
|
|
|
|
2007-08-27 18:12:39 +08:00
|
|
|
for ( i = 0; !BER_BVISNULL( &attr->a_nvals[ i ] ); i++ ) {
|
2007-08-27 01:03:22 +08:00
|
|
|
int rc_sid;
|
2007-08-26 23:39:45 +08:00
|
|
|
|
2007-08-27 01:03:22 +08:00
|
|
|
rc_sid = slap_parse_csn_sid( &attr->a_nvals[ i ] );
|
|
|
|
if ( rc_sid < 0 ) {
|
2007-08-26 23:39:45 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY,
|
|
|
|
"%s: unable to extract SID "
|
|
|
|
"from #%d contextCSN=%s\n",
|
|
|
|
progname, i,
|
|
|
|
attr->a_nvals[ i ].bv_val );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-08-27 01:03:22 +08:00
|
|
|
assert( rc_sid <= SLAP_SYNC_SID_MAX );
|
|
|
|
|
|
|
|
sid = (unsigned)rc_sid;
|
|
|
|
|
2007-08-26 23:39:45 +08:00
|
|
|
if ( maxcsn[ sid ].bv_len == 0 ) {
|
|
|
|
match = -1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
value_match( &match, slap_schema.si_ad_entryCSN,
|
|
|
|
slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
|
|
|
|
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
|
|
|
|
&maxcsn[ sid ], &attr->a_nvals[i], &text );
|
|
|
|
}
|
|
|
|
|
2007-11-12 11:50:31 +08:00
|
|
|
if ( match > 0 ) {
|
|
|
|
change = 1;
|
|
|
|
} else {
|
2007-08-26 23:39:45 +08:00
|
|
|
AC_MEMCPY( maxcsn[ sid ].bv_val,
|
|
|
|
attr->a_nvals[ i ].bv_val,
|
|
|
|
attr->a_nvals[ i ].bv_len );
|
|
|
|
maxcsn[ sid ].bv_val[ attr->a_nvals[ i ].bv_len ] = '\0';
|
|
|
|
maxcsn[ sid ].bv_len = attr->a_nvals[ i ].bv_len;
|
|
|
|
}
|
2005-04-09 18:00:15 +08:00
|
|
|
}
|
2007-08-26 23:39:45 +08:00
|
|
|
|
2007-11-12 11:50:31 +08:00
|
|
|
if ( change ) {
|
|
|
|
if ( attr->a_nvals != attr->a_vals ) {
|
|
|
|
ber_bvarray_free( attr->a_nvals );
|
|
|
|
}
|
|
|
|
attr->a_nvals = NULL;
|
|
|
|
ber_bvarray_free( attr->a_vals );
|
|
|
|
attr->a_vals = NULL;
|
|
|
|
attr->a_numvals = 0;
|
2007-08-26 23:39:45 +08:00
|
|
|
}
|
2007-11-12 11:50:31 +08:00
|
|
|
} else {
|
|
|
|
change = 1;
|
2005-04-09 18:00:15 +08:00
|
|
|
}
|
2007-08-26 23:39:45 +08:00
|
|
|
|
2007-11-12 11:50:31 +08:00
|
|
|
if ( change ) {
|
|
|
|
for ( sid = 0; sid <= SLAP_SYNC_SID_MAX; sid++ ) {
|
|
|
|
if ( maxcsn[ sid ].bv_len ) {
|
|
|
|
attr_merge_one( e, slap_schema.si_ad_contextCSN,
|
|
|
|
&maxcsn[ sid], NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ctxcsn_id = be->be_entry_modify( be, e, &bvtext );
|
|
|
|
if( ctxcsn_id == NOID ) {
|
|
|
|
fprintf( stderr, "%s: could not modify ctxcsn\n",
|
|
|
|
progname);
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
} else if ( verbose ) {
|
|
|
|
fprintf( stderr, "modified: \"%s\" (%08lx)\n",
|
|
|
|
e->e_dn, (long) ctxcsn_id );
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
2007-08-26 23:39:45 +08:00
|
|
|
}
|
2007-08-27 15:13:25 +08:00
|
|
|
entry_free( e );
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
2005-01-14 12:26:59 +08:00
|
|
|
}
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ch_free( buf );
|
|
|
|
|
2004-07-17 23:35:06 +08:00
|
|
|
if ( !dryrun ) {
|
|
|
|
if( be->be_entry_close( be ) ) {
|
|
|
|
rc = EXIT_FAILURE;
|
|
|
|
}
|
2004-02-27 03:03:41 +08:00
|
|
|
|
2004-07-17 23:35:06 +08:00
|
|
|
if( be->be_sync ) {
|
|
|
|
be->be_sync( be );
|
|
|
|
}
|
2004-02-27 03:03:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
slap_tool_destroy();
|
2004-07-17 23:35:06 +08:00
|
|
|
|
2004-02-27 03:03:41 +08:00
|
|
|
return rc;
|
|
|
|
}
|
2004-07-17 23:35:06 +08:00
|
|
|
|