mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
streamline group attr specification/diagnostics
This commit is contained in:
parent
fb2e448e87
commit
53d6d3c957
@ -1110,6 +1110,7 @@ parse_acl(
|
|||||||
if ( strncasecmp( left, "group", STRLENOF( "group" ) ) == 0 ) {
|
if ( strncasecmp( left, "group", STRLENOF( "group" ) ) == 0 ) {
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
char *attr_name = SLAPD_GROUP_ATTR;
|
||||||
|
|
||||||
switch ( sty ) {
|
switch ( sty ) {
|
||||||
case ACL_STYLE_REGEX:
|
case ACL_STYLE_REGEX:
|
||||||
@ -1227,50 +1228,41 @@ parse_acl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( name && *name ) {
|
if ( name && *name ) {
|
||||||
rc = slap_str2ad( name, &b->a_group_at, &text );
|
attr_name = name;
|
||||||
|
|
||||||
if( rc != LDAP_SUCCESS ) {
|
|
||||||
char buf[ SLAP_TEXT_BUFLEN ];
|
|
||||||
|
|
||||||
snprintf( buf, sizeof( buf ),
|
|
||||||
"group \"%s\": %s.",
|
|
||||||
right, text );
|
|
||||||
Debug( LDAP_DEBUG_ANY,
|
|
||||||
"%s: line %d: %s\n",
|
|
||||||
fname, lineno, buf );
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
*--name = '/';
|
*--name = '/';
|
||||||
|
|
||||||
} else {
|
}
|
||||||
rc = slap_str2ad( SLAPD_GROUP_ATTR, &b->a_group_at, &text );
|
|
||||||
|
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
rc = slap_str2ad( attr_name, &b->a_group_at, &text );
|
||||||
char buf[ SLAP_TEXT_BUFLEN ];
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
|
char buf[ SLAP_TEXT_BUFLEN ];
|
||||||
|
|
||||||
snprintf( buf, sizeof( buf ),
|
snprintf( buf, sizeof( buf ),
|
||||||
"group \"%s\": %s.",
|
"group \"%s\": %s.",
|
||||||
SLAPD_GROUP_ATTR, text );
|
right, text );
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"%s: line %d: %s\n",
|
"%s: line %d: %s\n",
|
||||||
fname, lineno, buf );
|
fname, lineno, buf );
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !is_at_syntax( b->a_group_at->ad_type,
|
if ( !is_at_syntax( b->a_group_at->ad_type,
|
||||||
SLAPD_DN_SYNTAX ) &&
|
SLAPD_DN_SYNTAX ) /* e.g. "member" */
|
||||||
!is_at_syntax( b->a_group_at->ad_type,
|
&& !is_at_syntax( b->a_group_at->ad_type,
|
||||||
SLAPD_NAMEUID_SYNTAX ) &&
|
SLAPD_NAMEUID_SYNTAX ) /* e.g. memberUID */
|
||||||
!is_at_subtype( b->a_group_at->ad_type,
|
&& !is_at_subtype( b->a_group_at->ad_type,
|
||||||
slap_schema.si_ad_labeledURI->ad_type ) )
|
slap_schema.si_ad_labeledURI->ad_type ) /* e.g. memberURL */ )
|
||||||
{
|
{
|
||||||
char buf[ SLAP_TEXT_BUFLEN ];
|
char buf[ SLAP_TEXT_BUFLEN ];
|
||||||
|
|
||||||
snprintf( buf, sizeof( buf ),
|
snprintf( buf, sizeof( buf ),
|
||||||
"group \"%s\": inappropriate syntax: %s.",
|
"group \"%s\" attr \"%s\": inappropriate syntax: %s; "
|
||||||
|
"must be " SLAPD_DN_SYNTAX " (DN), "
|
||||||
|
SLAPD_NAMEUID_SYNTAX " (NameUID) "
|
||||||
|
"or a subtype of labeledURI.",
|
||||||
right,
|
right,
|
||||||
b->a_group_at->ad_type->sat_syntax_oid );
|
attr_name,
|
||||||
|
at_syntax( b->a_group_at->ad_type ) );
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"%s: line %d: %s\n",
|
"%s: line %d: %s\n",
|
||||||
fname, lineno, buf );
|
fname, lineno, buf );
|
||||||
|
@ -27,16 +27,32 @@
|
|||||||
#include "slap.h"
|
#include "slap.h"
|
||||||
|
|
||||||
|
|
||||||
int is_at_syntax(
|
const char *
|
||||||
AttributeType *at,
|
at_syntax(
|
||||||
const char *oid )
|
AttributeType *at )
|
||||||
{
|
{
|
||||||
for( ; at != NULL; at = at->sat_sup ) {
|
for ( ; at != NULL; at = at->sat_sup ) {
|
||||||
if( at->sat_syntax_oid ) {
|
if ( at->sat_syntax_oid ) {
|
||||||
return ( strcmp( at->sat_syntax_oid, oid ) == 0 );
|
return at->sat_syntax_oid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert( 0 );
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
is_at_syntax(
|
||||||
|
AttributeType *at,
|
||||||
|
const char *oid )
|
||||||
|
{
|
||||||
|
const char *syn_oid = at_syntax( at );
|
||||||
|
|
||||||
|
if ( syn_oid ) {
|
||||||
|
return strcmp( syn_oid, oid ) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +230,8 @@ LDAP_SLAPD_F (int) is_at_subtype LDAP_P((
|
|||||||
AttributeType *sub,
|
AttributeType *sub,
|
||||||
AttributeType *super ));
|
AttributeType *super ));
|
||||||
|
|
||||||
|
LDAP_SLAPD_F (const char *) at_syntax LDAP_P((
|
||||||
|
AttributeType *at ));
|
||||||
LDAP_SLAPD_F (int) is_at_syntax LDAP_P((
|
LDAP_SLAPD_F (int) is_at_syntax LDAP_P((
|
||||||
AttributeType *at,
|
AttributeType *at,
|
||||||
const char *oid ));
|
const char *oid ));
|
||||||
|
Loading…
Reference in New Issue
Block a user