]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#7420 move entry_naming_check earlier in Add
authorHoward Chu <hyc@openldap.org>
Tue, 19 Dec 2023 13:08:14 +0000 (13:08 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 10 Jan 2024 17:05:13 +0000 (17:05 +0000)
Make sure RDN is present in e_attrs before passing entry to overlays

servers/slapd/add.c
servers/slapd/proto-slap.h
servers/slapd/schema_check.c
servers/slapd/slapcommon.c

index 7934d3e4b440510daf517484b3369d0f209059b7..747537df086a6fff96e0e6ea9e2430357d6b1756 100644 (file)
@@ -184,6 +184,15 @@ do_add( Operation *op, SlapReply *rs )
                goto done;
        }
 
+       /* make sure RDN is present in attrs */
+       if ( !is_entry_glue ( op->ora_e )) {
+               rs->sr_err = entry_naming_check( op->ora_e, get_relax( op ), 1, &rs->sr_text, textbuf, textlen );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       send_ldap_result( op, rs );
+                       goto done;
+               }
+       }
+
        freevals = 0;
        oex = op->o_tmpalloc( sizeof(OpExtraDB), op->o_tmpmemctx );
        oex->oe.oe_key = (void *)do_add;
index d9dfb85bc897b4fef4a9d7f8039c136b06d2a607..69ab97337802444cd98f75a6ae0d4c1584cb015e 100644 (file)
@@ -1799,6 +1799,13 @@ LDAP_SLAPD_F( int ) entry_schema_check(
        const char** text,
        char *textbuf, size_t textlen );
 
+LDAP_SLAPD_F( int ) entry_naming_check(
+       Entry *e,
+       int manage,
+       int add_naming,
+       const char** text,
+       char *textbuf, size_t textlen );
+
 LDAP_SLAPD_F( int ) mods_structural_class(
        Modifications *mods,
        struct berval *oc,
index 7fa768ffb7af5e856f9ff510f35e747f725583d0..0ea6280e697dd29480d4dd7383b401d715f14151 100644 (file)
@@ -29,12 +29,6 @@ static char * oc_check_required(
        ObjectClass *oc,
        struct berval *ocname );
 
-static int entry_naming_check(
-       Entry *e,
-       int manage,
-       int add_naming,
-       const char** text,
-       char *textbuf, size_t textlen );
 /*
  * entry_schema_check - check that entry e conforms to the schema required
  * by its object class(es).
@@ -237,8 +231,8 @@ got_soc:
        }
 
        /* naming check */
-       if ( !is_entry_glue ( e ) ) {
-               rc = entry_naming_check( e, manage, add, text, textbuf, textlen );
+       if ( !is_entry_glue ( e ) && !add ) { /* add already did this */
+               rc = entry_naming_check( e, manage, 0, text, textbuf, textlen );
                if( rc != LDAP_SUCCESS ) {
                        goto done;
                }
@@ -772,7 +766,7 @@ int mods_structural_class(
 }
 
 
-static int
+int
 entry_naming_check(
        Entry *e,
        int manage,
index b4766c0c02540701ec6461f9e50cdb078dc8a21f..d156add364c0e8879944fc91caa74d5146ea4fd7 100644 (file)
@@ -1180,6 +1180,9 @@ slap_tool_entry_check(
                int rc = entry_schema_check( op, e, manage, 1, NULL,
                        text, textbuf, textlen );
 
+               if( rc == LDAP_SUCCESS )
+                       rc = entry_naming_check( e, manage, 1, text, textbuf, textlen );
+
                if( rc != LDAP_SUCCESS ) {
                        fprintf( stderr, "%s: dn=\"%s\" (line=%d): (%d) %s\n",
                                progname, e->e_dn, lineno, rc, *text );