]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#7901 slapschema: preserve errors in -c mode
authorArvid Requate <requate@univention.de>
Tue, 21 Oct 2025 15:56:02 +0000 (16:56 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 22 Oct 2025 19:25:34 +0000 (19:25 +0000)
servers/slapd/slapschema.c

index b5a33a9ed3a8ed39f75ec66a1d41059aeb6c7876..d67c998816e091db7601c430984d419b576f80d4 100644 (file)
@@ -45,6 +45,7 @@ slapschema( int argc, char **argv )
 {
        ID id;
        int rc = EXIT_SUCCESS;
+       int result = EXIT_SUCCESS;
        const char *progname = "slapschema";
        Connection conn = { 0 };
        OperationBuffer opbuf;
@@ -117,7 +118,7 @@ slapschema( int argc, char **argv )
                e = be->be_entry_get( be, id );
                if ( e == NULL ) {
                        printf("# no data for entry id=%08lx\n\n", (long) id );
-                       rc = EXIT_FAILURE;
+                       result = EXIT_FAILURE;
                        if( continuemode ) continue;
                        break;
                }
@@ -133,6 +134,7 @@ slapschema( int argc, char **argv )
                        if ( filter != NULL ) {
                                int rc = test_filter( NULL, e, filter );
                                if ( rc != LDAP_COMPARE_TRUE ) {
+                                       result = rc;
                                        be_entry_release_r( op, e );
                                        continue;
                                }
@@ -151,15 +153,19 @@ slapschema( int argc, char **argv )
                                text ? ": " : "",
                                text ? text : "" );
                        fprintf( ldiffp->fp, "dn: %s\n\n", e->e_name.bv_val );
+                       result = rc;
                }
 
                be_entry_release_r( op, e );
+               if ( result != LDAP_SUCCESS && !continuemode ) {
+                       break;
+               }
        }
 
        be->be_entry_close( be );
 
        if ( slap_tool_destroy() )
-               rc = EXIT_FAILURE;
+               result = EXIT_FAILURE;
 
-       return rc;
+       return result;
 }