mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-18 11:05:48 +08:00
Trim replog-related cruft
This commit is contained in:
parent
d30661d361
commit
b2cf21e625
@ -70,15 +70,14 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
static int ldapadd, force = 0;
|
static int ldapadd;
|
||||||
static char *rejfile = NULL;
|
static char *rejfile = NULL;
|
||||||
static LDAP *ld = NULL;
|
static LDAP *ld = NULL;
|
||||||
|
|
||||||
#define M_SEP 0x7f
|
#define M_SEP 0x7f
|
||||||
|
|
||||||
/* strings found in replog/LDIF entries (mostly lifted from slurpd/slurp.h) */
|
/* strings found in LDIF entries */
|
||||||
static struct berval BV_VERSION = BER_BVC("version");
|
static struct berval BV_VERSION = BER_BVC("version");
|
||||||
static struct berval BV_REPLICA = BER_BVC("replica");
|
|
||||||
static struct berval BV_DN = BER_BVC("dn");
|
static struct berval BV_DN = BER_BVC("dn");
|
||||||
static struct berval BV_CONTROL = BER_BVC("control");
|
static struct berval BV_CONTROL = BER_BVC("control");
|
||||||
static struct berval BV_CHANGETYPE = BER_BVC("changetype");
|
static struct berval BV_CHANGETYPE = BER_BVC("changetype");
|
||||||
@ -144,7 +143,6 @@ usage( void )
|
|||||||
fprintf( stderr,
|
fprintf( stderr,
|
||||||
_(" [!]txn=<commit|abort> (transaction)\n"));
|
_(" [!]txn=<commit|abort> (transaction)\n"));
|
||||||
#endif
|
#endif
|
||||||
fprintf( stderr, _(" -F force all changes records to be used\n"));
|
|
||||||
fprintf( stderr, _(" -S file write skipped modifications to `file'\n"));
|
fprintf( stderr, _(" -S file write skipped modifications to `file'\n"));
|
||||||
|
|
||||||
tool_common_usage();
|
tool_common_usage();
|
||||||
@ -152,7 +150,7 @@ usage( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char options[] = "aE:FrS:"
|
const char options[] = "aE:rS:"
|
||||||
"cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
|
"cd:D:e:f:h:H:IMnO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -217,10 +215,6 @@ handle_private_option( int i )
|
|||||||
ldapadd = 1;
|
ldapadd = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'F': /* force all changes records to be used */
|
|
||||||
force = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r': /* replace (obsolete) */
|
case 'r': /* replace (obsolete) */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -411,7 +405,7 @@ process_ldif_rec( char *rbuf, int linenum )
|
|||||||
int rc, modop, replicaport;
|
int rc, modop, replicaport;
|
||||||
int expect_modop, expect_sep;
|
int expect_modop, expect_sep;
|
||||||
int deleteoldrdn;
|
int deleteoldrdn;
|
||||||
int saw_replica, use_record, new_entry, delete_entry, got_all;
|
int new_entry, delete_entry, got_all;
|
||||||
LDAPMod **pmods, *lm = NULL;
|
LDAPMod **pmods, *lm = NULL;
|
||||||
int version;
|
int version;
|
||||||
LDAPControl **pctrls;
|
LDAPControl **pctrls;
|
||||||
@ -422,11 +416,10 @@ process_ldif_rec( char *rbuf, int linenum )
|
|||||||
|
|
||||||
new_entry = ldapadd;
|
new_entry = ldapadd;
|
||||||
|
|
||||||
rc = got_all = saw_replica = delete_entry = modop = expect_modop = 0;
|
rc = got_all = delete_entry = modop = expect_modop = 0;
|
||||||
expect_sep = 0;
|
expect_sep = 0;
|
||||||
version = 0;
|
version = 0;
|
||||||
deleteoldrdn = 1;
|
deleteoldrdn = 1;
|
||||||
use_record = force;
|
|
||||||
pmods = NULL;
|
pmods = NULL;
|
||||||
pctrls = NULL;
|
pctrls = NULL;
|
||||||
dn = newrdn = newsup = NULL;
|
dn = newrdn = newsup = NULL;
|
||||||
@ -464,27 +457,7 @@ process_ldif_rec( char *rbuf, int linenum )
|
|||||||
freeval[i] = freev;
|
freeval[i] = freev;
|
||||||
|
|
||||||
if ( dn == NULL ) {
|
if ( dn == NULL ) {
|
||||||
if ( !use_record && !BVICMP( btype+i, &BV_REPLICA )) {
|
if ( linenum+i == 1 && !BVICMP( btype+i, &BV_VERSION )) {
|
||||||
char *p;
|
|
||||||
++saw_replica;
|
|
||||||
if (( p = strchr( vals[i].bv_val, ':' )) == NULL ) {
|
|
||||||
replicaport = 0;
|
|
||||||
} else {
|
|
||||||
*p++ = '\0';
|
|
||||||
if ( lutil_atoi( &replicaport, p ) != 0 ) {
|
|
||||||
fprintf( stderr, _("%s: unable to parse replica port \"%s\" (line %d) entry: \"%s\"\n"),
|
|
||||||
prog, p, linenum+i, dn == NULL ? "" : dn );
|
|
||||||
rc = LDAP_PARAM_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( ldaphost != NULL &&
|
|
||||||
strcasecmp( vals[i].bv_val, ldaphost ) == 0 &&
|
|
||||||
replicaport == ldapport )
|
|
||||||
{
|
|
||||||
use_record = 1;
|
|
||||||
}
|
|
||||||
} else if ( linenum+i == 1 && !BVICMP( btype+i, &BV_VERSION )) {
|
|
||||||
int v;
|
int v;
|
||||||
if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) {
|
if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) {
|
||||||
fprintf( stderr,
|
fprintf( stderr,
|
||||||
@ -496,13 +469,6 @@ process_ldif_rec( char *rbuf, int linenum )
|
|||||||
} else if ( !BVICMP( btype+i, &BV_DN )) {
|
} else if ( !BVICMP( btype+i, &BV_DN )) {
|
||||||
dn = vals[i].bv_val;
|
dn = vals[i].bv_val;
|
||||||
idn = i;
|
idn = i;
|
||||||
if ( !use_record && saw_replica ) {
|
|
||||||
printf(_("%s: skipping change record for entry: %s at line %d\n"),
|
|
||||||
prog, dn, linenum+i);
|
|
||||||
printf(_("\t(LDAP host/port does not match replica: lines)\n"));
|
|
||||||
rc = 0;
|
|
||||||
goto leave;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* skip all lines until we see "dn:" */
|
/* skip all lines until we see "dn:" */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user