From 62904cf50d232b73f4c48ce927be91043c6c8627 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 24 May 2008 11:57:18 +0000 Subject: [PATCH] allow to customize the modifiersName of internal modifications (partially addresses ITS#5505) --- doc/man/man5/slapo-refint.5 | 8 ++++- servers/slapd/overlays/refint.c | 56 ++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/doc/man/man5/slapo-refint.5 b/doc/man/man5/slapo-refint.5 index 4a4580cf34..fc8c3c94b4 100644 --- a/doc/man/man5/slapo-refint.5 +++ b/doc/man/man5/slapo-refint.5 @@ -39,7 +39,7 @@ They should appear after the .B overlay directive. .TP -.B refint_attributes +.B refint_attributes [...] Specify one or more attributes for which integrity will be maintained as described above. .TP @@ -49,6 +49,12 @@ would otherwise be deleted from an attribute. This can be useful in cases where the schema requires the existence of an attribute for which referential integrity is enforced. The attempted deletion of a required attribute will otherwise result in an Object Class Violation, causing the request to fail. +The string must be a valid DN. +.TP +.B refint_modifiersname +Specify the DN to be used as the modifiersName of the internal modifications +performed by the overlay. +It defaults to "\fIcn=Referential Integrity Overlay\fP". .B .SH FILES .TP diff --git a/servers/slapd/overlays/refint.c b/servers/slapd/overlays/refint.c index 13c520ecc6..a75d0975d0 100644 --- a/servers/slapd/overlays/refint.c +++ b/servers/slapd/overlays/refint.c @@ -81,6 +81,8 @@ typedef struct refint_data_s { BerValue dn; /* basedn in parent, */ BerValue nothing; /* the nothing value, if needed */ BerValue nnothing; /* normalized nothingness */ + BerValue refint_dn; /* modifier's name */ + BerValue refint_ndn; /* normalized modifier's name */ struct re_s *qtask; refint_q *qhead; refint_q *qtail; @@ -93,7 +95,8 @@ static MatchingRule *mr_dnSubtreeMatch; enum { REFINT_ATTRS = 1, - REFINT_NOTHING + REFINT_NOTHING, + REFINT_MODIFIERSNAME }; static ConfigDriver refint_cf_gen; @@ -110,6 +113,11 @@ static ConfigTable refintcfg[] = { "( OLcfgOvAt:11.2 NAME 'olcRefintNothing' " "DESC 'Replacement DN to supply when needed' " "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL }, + { "refint_modifiersName", "DN", 2, 2, 0, + ARG_DN|ARG_MAGIC|REFINT_MODIFIERSNAME, refint_cf_gen, + "( OLcfgOvAt:11.3 NAME 'olcRefintModifiersName' " + "DESC 'The DN to use as modifiersName' " + "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL }, { NULL, NULL, 0, 0, 0, ARG_IGNORED } }; @@ -118,7 +126,10 @@ static ConfigOCs refintocs[] = { "NAME 'olcRefintConfig' " "DESC 'Referential integrity configuration' " "SUP olcOverlayConfig " - "MAY ( olcRefintAttribute $ olcRefintNothing ) )", + "MAY ( olcRefintAttribute " + "$ olcRefintNothing " + "$ olcRefintModifiersName " + ") )", Cft_Overlay, refintcfg }, { NULL, 0, NULL } }; @@ -157,6 +168,17 @@ refint_cf_gen(ConfigArgs *c) } rc = 0; break; + case REFINT_MODIFIERSNAME: + if ( !BER_BVISEMPTY( &dd->refint_dn )) { + rc = value_add_one( &c->rvalue_vals, + &dd->refint_dn ); + if ( rc ) return rc; + rc = value_add_one( &c->rvalue_nvals, + &dd->refint_ndn ); + return rc; + } + rc = 0; + break; default: abort (); } @@ -196,6 +218,15 @@ refint_cf_gen(ConfigArgs *c) dd->nnothing.bv_len = 0; rc = 0; break; + case REFINT_MODIFIERSNAME: + if ( dd->refint_dn.bv_val ) + ber_memfree ( dd->refint_dn.bv_val ); + if ( dd->refint_ndn.bv_val ) + ber_memfree ( dd->refint_ndn.bv_val ); + dd->refint_dn.bv_len = 0; + dd->refint_ndn.bv_len = 0; + rc = 0; + break; default: abort (); } @@ -233,6 +264,15 @@ refint_cf_gen(ConfigArgs *c) dd->nnothing = c->value_ndn; rc = 0; break; + case REFINT_MODIFIERSNAME: + if ( dd->refint_dn.bv_val ) + ber_memfree ( dd->refint_dn.bv_val ); + if ( dd->refint_ndn.bv_val ) + ber_memfree ( dd->refint_ndn.bv_val ); + dd->refint_dn = c->value_dn; + dd->refint_ndn = c->value_ndn; + rc = 0; + break; default: abort (); } @@ -302,6 +342,10 @@ refint_open( return -1; ber_dupbv( &id->dn, &be->be_nsuffix[0] ); } + if ( BER_BVISNULL( &id->refint_dn ) ) { + ber_dupbv( &id->refint_dn, &refint_dn ); + ber_dupbv( &id->refint_ndn, &refint_ndn ); + } return(0); } @@ -339,6 +383,10 @@ refint_close( BER_BVZERO( &id->nothing ); ch_free( id->nnothing.bv_val ); BER_BVZERO( &id->nnothing ); + ch_free( id->refint_dn.bv_val ); + BER_BVZERO( &id->refint_dn ); + ch_free( id->refint_ndn.bv_val ); + BER_BVZERO( &id->refint_ndn ); return(0); } @@ -580,8 +628,8 @@ refint_repair( m->sml_nvalues = m->sml_values+2; BER_BVZERO( &m->sml_values[1] ); BER_BVZERO( &m->sml_nvalues[1] ); - m->sml_values[0] = refint_dn; - m->sml_nvalues[0] = refint_ndn; + m->sml_values[0] = id->refint_dn; + m->sml_nvalues[0] = id->refint_ndn; } if ( !BER_BVISEMPTY( &rq->newdn ) || ( ra->next && ra->attr == ra->next->attr ) )