mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-22 23:59:34 -05:00
Recode suffixAlias to implement simple check to see if part to aliased
is at a DNSEPARATOR. Moved DNSEPARATOR macro from dn.c to slap.h
This commit is contained in:
parent
029069d84a
commit
0daa8c1f06
3 changed files with 31 additions and 15 deletions
|
|
@ -11,10 +11,6 @@
|
||||||
|
|
||||||
#include "slap.h"
|
#include "slap.h"
|
||||||
|
|
||||||
#define DNSEPARATOR(c) (c == ',' || c == ';')
|
|
||||||
#define SEPARATOR(c) (c == ',' || c == ';' || c == '+')
|
|
||||||
#define SPACE(c) (c == ' ' || c == '\n')
|
|
||||||
#define NEEDSESCAPE(c) (c == '\\' || c == '"')
|
|
||||||
#define B4TYPE 0
|
#define B4TYPE 0
|
||||||
#define INTYPE 1
|
#define INTYPE 1
|
||||||
#define B4EQUAL 2
|
#define B4EQUAL 2
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,11 @@
|
||||||
|
|
||||||
#define MAXREMATCHES 10
|
#define MAXREMATCHES 10
|
||||||
|
|
||||||
|
#define DNSEPARATOR(c) ((c) == ',' || (c) == ';')
|
||||||
|
#define SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '+')
|
||||||
|
#define SPACE(c) ((c) == ' ' || (c) == '\n')
|
||||||
|
#define NEEDSESCAPE(c) ((c) == '\\' || (c) == '"')
|
||||||
|
|
||||||
LDAP_BEGIN_DECL
|
LDAP_BEGIN_DECL
|
||||||
|
|
||||||
extern int slap_debug;
|
extern int slap_debug;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
/*
|
/*
|
||||||
|
* Copyright 1999 The OpenLDAP Foundation, All Rights Reserved.
|
||||||
|
*
|
||||||
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file in the top level
|
||||||
|
* directory of this package.
|
||||||
|
*/
|
||||||
|
/* Portions
|
||||||
* Copyright (c) 1998 Will Ballantyne, ITSD, Government of BC
|
* Copyright (c) 1998 Will Ballantyne, ITSD, Government of BC
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
|
@ -18,7 +24,7 @@
|
||||||
#include "slap.h"
|
#include "slap.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* given a dn (or root part), return an aliased dn if any of the
|
* given a normalized uppercased dn (or root part), return an aliased dn if any of the
|
||||||
* alias suffixes match
|
* alias suffixes match
|
||||||
*/
|
*/
|
||||||
char *suffixAlias (char *dn, Operation *op, Backend *be)
|
char *suffixAlias (char *dn, Operation *op, Backend *be)
|
||||||
|
|
@ -32,18 +38,27 @@ char *suffixAlias (char *dn, Operation *op, Backend *be)
|
||||||
be->be_suffixAlias != NULL && be->be_suffixAlias[i] != NULL;
|
be->be_suffixAlias != NULL && be->be_suffixAlias[i] != NULL;
|
||||||
i += 2) {
|
i += 2) {
|
||||||
int aliasLength = strlen (be->be_suffixAlias[i]);
|
int aliasLength = strlen (be->be_suffixAlias[i]);
|
||||||
if (aliasLength > dnLength) {
|
int diff = dnLength - aliasLength;
|
||||||
|
|
||||||
|
if ( diff < 0 ) {
|
||||||
|
/* alias is longer than dn */
|
||||||
|
continue;
|
||||||
|
} else if ( diff > 0 ) {
|
||||||
|
if ( ! DNSEPARATOR(dn[diff-1]) ) {
|
||||||
|
/* boundary is not at a DN separator */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
/* At a DN Separator */
|
||||||
|
/* XXX or an escaped separator... oh well */
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcasecmp(be->be_suffixAlias[i],
|
if (!strcmp(be->be_suffixAlias[i], &dn[diff])) {
|
||||||
dn + (dnLength - aliasLength))) {
|
|
||||||
char *oldDN = dn;
|
char *oldDN = dn;
|
||||||
dn = ch_malloc ( (dnLength - aliasLength) +
|
dn = ch_malloc( diff + strlen(be->be_suffixAlias[i+1]) + 1 );
|
||||||
strlen (be->be_suffixAlias[ i+1 ]) + 1);
|
strncpy( dn, oldDN, diff );
|
||||||
strncpy (dn, oldDN, dnLength - aliasLength);
|
strcpy( &dn[diff], be->be_suffixAlias[i+1] );
|
||||||
strcpy (dn + (dnLength - aliasLength), be->be_suffixAlias[ i+1 ]);
|
Debug( LDAP_DEBUG_ARGS, "SuffixAlias: converted \"%s\" to \"%s\"",
|
||||||
Debug( LDAP_DEBUG_ARGS, "ALIAS: converted %s to %s", oldDN, dn, 0);
|
oldDN, dn, 0);
|
||||||
free (oldDN);
|
free (oldDN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue