Add experimental UUID/CSN support (needed for LCUP).

This commit is contained in:
Kurt Zeilenga 2001-12-05 07:25:25 +00:00
parent 268ee5ff4a
commit 86f79b85d8
6 changed files with 65 additions and 11 deletions

View File

@ -32,7 +32,7 @@
#include <stdio.h>
#include <ac/time.h>
int
size_t
lutil_csnstr(char *buf, size_t len, unsigned int replica, unsigned int mod)
{
static time_t csntime;
@ -55,7 +55,7 @@ lutil_csnstr(char *buf, size_t len, unsigned int replica, unsigned int mod)
ltm->tm_year + 1900, ltm->tm_mon, ltm->tm_mday, ltm->tm_hour,
ltm->tm_min, ltm->tm_sec, op, replica, mod );
return ( n < len ) ? 1 : 0;
return ( n < len ) ? n : 0;
}
#ifdef TEST

View File

@ -182,6 +182,7 @@ lutil_uuidstr( char *buf, size_t len )
uuid_t uu = {0};
unsigned rc;
char *s;
size_t l;
uuid_create( &uu, &rc );
if ( rc != uuid_s_ok ) {
@ -192,15 +193,17 @@ lutil_uuidstr( char *buf, size_t len )
if ( rc != uuid_s_ok ) {
return 0;
}
if ( strlen( s ) >= len ) {
l = strlen( s );
if ( l >= len ) {
free( s );
return 0;
}
strncpy( buf, s, len );
strncpy( buf, s, l );
free( s );
return 1;
return l;
#else
struct timeval tv;
@ -243,7 +246,7 @@ lutil_uuidstr( char *buf, size_t len )
(unsigned) nl[2], (unsigned) nl[3],
(unsigned) nl[4], (unsigned) nl[5] );
return (t1 < len) ? 1 : 0;
return (t1 < len) ? t1 : 0;
#endif
}

View File

@ -549,9 +549,10 @@ int slap_mods_opattrs(
Modifications **modtail,
const char **text )
{
struct berval name, timestamp;
struct berval name, timestamp, csn;
time_t now = slap_get_time();
char timebuf[22];
char csnbuf[128];
struct tm *ltm;
Modifications *mod;
@ -564,7 +565,11 @@ int slap_mods_opattrs(
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
ltm = gmtime( &now );
strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm );
csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
csn.bv_val = csnbuf;
timestamp.bv_val = timebuf;
timestamp.bv_len = strlen(timebuf);
@ -577,6 +582,22 @@ int slap_mods_opattrs(
}
if( op->o_tag == LDAP_REQ_ADD ) {
struct berval uuid;
char uuidbuf[64];
uuid.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
uuid.bv_val = uuidbuf;
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_entryUUID;
mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
mod->sml_bvalues[0] = ber_bvdup( &uuid );
mod->sml_bvalues[1] = NULL;
assert( mod->sml_bvalues[0] );
*modtail = mod;
modtail = &mod->sml_next;
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_creatorsName;
@ -598,10 +619,20 @@ int slap_mods_opattrs(
modtail = &mod->sml_next;
}
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_entryCSN;
mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
mod->sml_bvalues[0] = ber_bvdup( &csn );
mod->sml_bvalues[1] = NULL;
assert( mod->sml_bvalues[0] );
*modtail = mod;
modtail = &mod->sml_next;
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_modifiersName;
mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
mod->sml_bvalues[0] = ber_bvdup( &name );
mod->sml_bvalues[1] = NULL;
assert( mod->sml_bvalues[0] );
@ -611,7 +642,7 @@ int slap_mods_opattrs(
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
mod->sml_bvalues[0] = ber_bvdup( &timestamp );
mod->sml_bvalues[1] = NULL;
assert( mod->sml_bvalues[0] );

View File

@ -763,6 +763,22 @@ objectclass ( 1.3.6.1.4.1.4203.1.4.7
MAY authPassword
AUXILIARY )
#
# LDUP/LCUP attributes
# Experimental!
#
attributetype ( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID'
DESC 'LCUP/LDUP: universally unique identifier'
EQUALITY octetStringMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64}
SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )
attributetype ( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN'
DESC 'LCUP/LDUP: change sequence number'
EQUALITY octetStringMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64}
SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )
#
# OpenLDAP specific schema items
#

View File

@ -153,6 +153,10 @@ struct slap_schema_ad_map {
offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
/* user entry operational attributes */
{ "entryUUID", NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_entryUUID) },
{ "entryCSN", NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_entryCSN) },
{ "creatorsName", NULL, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_creatorsName) },
{ "createTimestamp", NULL, NULL, NULL,

View File

@ -473,6 +473,8 @@ struct slap_internal_schema {
/* operational attribute descriptions */
AttributeDescription *si_ad_structuralObjectClass;
AttributeDescription *si_ad_entryUUID;
AttributeDescription *si_ad_entryCSN;
AttributeDescription *si_ad_creatorsName;
AttributeDescription *si_ad_createTimestamp;
AttributeDescription *si_ad_modifiersName;
@ -544,7 +546,6 @@ typedef struct slap_mr_assertion {
struct berval *ma_value; /* required */
} MatchingRuleAssertion;
/*
* represents a search filter
*/
@ -554,7 +555,6 @@ typedef struct slap_filter {
#define SLAPD_FILTER_DN_ONE ((ber_tag_t) -2)
#define SLAPD_FILTER_DN_SUBTREE ((ber_tag_t) -3)
union f_un_u {
/* precomputed result */
ber_int_t f_un_result;