X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Foverlays%2Frwmconf.c;h=804f7566203ba9d41cded6d0641cee7277edf38a;hb=8bdfd2edbb7a09f5bfe96b2bca043680f731237a;hp=7a87ccff0020665c92539e076407e02955e53029;hpb=03db9632dd9a33fec81647f09895196ace6a591f;p=openldap diff --git a/servers/slapd/overlays/rwmconf.c b/servers/slapd/overlays/rwmconf.c index 7a87ccff00..804f756620 100644 --- a/servers/slapd/overlays/rwmconf.c +++ b/servers/slapd/overlays/rwmconf.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1999-2005 The OpenLDAP Foundation. + * Copyright 1999-2009 The OpenLDAP Foundation. * Portions Copyright 1999-2003 Howard Chu. * Portions Copyright 2000-2003 Pierangelo Masarati. * All rights reserved. @@ -47,6 +47,7 @@ rwm_map_config( struct ldapmapping *mapping; char *src, *dst; int is_oc = 0; + int rc = 0; if ( argc < 3 || argc > 4 ) { fprintf( stderr, @@ -70,10 +71,17 @@ rwm_map_config( return 1; } + if ( !is_oc && map->map == NULL ) { + /* only init if required */ + if ( rwm_map_init( map, &mapping ) != LDAP_SUCCESS ) { + return 1; + } + } + if ( strcmp( argv[2], "*" ) == 0 ) { if ( argc < 4 || strcmp( argv[3], "*" ) == 0 ) { map->drop_missing = ( argc < 4 ); - return 0; + goto success_return; } src = dst = argv[3]; @@ -146,15 +154,8 @@ rwm_map_config( if ( mapping[0].m_dst_oc == NULL ) { fprintf( stderr, "%s: line %d: unable to mimic destination objectClass '%s'\n", fname, lineno, dst ); - return 1; + goto error_return; } - -#if 0 - mapping[0].m_dst_oc = ch_malloc( sizeof( ObjectClass ) ); - memset( mapping[0].m_dst_oc, 0, sizeof( ObjectClass ) ); - mapping[0].m_dst_oc->soc_cname = mapping[0].m_dst; - mapping[0].m_flags |= RWMMAP_F_FREE_DST; -#endif } mapping[1].m_src_oc = mapping[0].m_dst_oc; @@ -186,7 +187,7 @@ rwm_map_config( fprintf( stderr, "%s: line %d: source attributeType '%s': %d (%s)\n", fname, lineno, src, rc, text ? text : "null" ); - return 1; + goto error_return; } } @@ -207,7 +208,7 @@ rwm_map_config( fprintf( stderr, "%s: line %d: destination attributeType '%s': %d (%s)\n", fname, lineno, dst, rc, text ? text : "null" ); - return 1; + goto error_return; } } mapping[1].m_src_ad = mapping[0].m_dst_ad; @@ -217,7 +218,7 @@ rwm_map_config( || avl_find( map->remap, (caddr_t)&mapping[1], rwm_mapping_cmp ) != NULL) { fprintf( stderr, - "%s: line %d: duplicate mapping found" SLAPD_CONF_UNKNOWN_IGNORED ".\n", + "%s: line %d: duplicate mapping found.\n", fname, lineno ); /* FIXME: free stuff */ goto error_return; @@ -230,7 +231,8 @@ rwm_map_config( avl_insert( &map->remap, (caddr_t)&mapping[1], rwm_mapping_cmp, rwm_mapping_dup ); - return 0; +success_return:; + return rc; error_return:; if ( mapping ) { @@ -240,7 +242,6 @@ error_return:; return 1; } -#ifdef ENABLE_REWRITE static char * rwm_suffix_massage_regexize( const char *s ) { @@ -406,6 +407,5 @@ rwm_suffix_massage_config( return 0; } -#endif /* ENABLE_REWRITE */ #endif /* SLAPD_OVER_RWM */