]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10374 pcache: fix config emit of noattr attrset
authorHoward Chu <hyc@openldap.org>
Thu, 31 Jul 2025 15:43:31 +0000 (16:43 +0100)
committerHoward Chu <hyc@openldap.org>
Thu, 31 Jul 2025 15:43:31 +0000 (16:43 +0100)
Support for configuring an empty attrset was added in add25c2f45a126eb321e25a068140e32068666c6
for ITS#5074 but code to emit the config wasn't updated accordingly.

servers/slapd/overlays/pcache.c

index 9fd72e6d7261ff543474f9c58b2dbdde1671db1c..1810f29d88d560e501b33151b448f3a978619b68 100644 (file)
@@ -3880,32 +3880,41 @@ pc_cf_gen( ConfigArgs *c )
                        break;
                case PC_ATTR:
                        for (i=0; i<cm->numattrsets; i++) {
-                               if ( !qm->attr_sets[i].count ) continue;
+                               if ( !(qm->attr_sets[i].flags & PC_CONFIGURED) ) continue;
 
                                bv.bv_len = snprintf( c->cr_msg, sizeof( c->cr_msg ), "%d", i );
+                               if ( !qm->attr_sets[i].count ) {
+                                       bv.bv_len += sizeof( LDAP_NO_ATTRS );
+                                       bv.bv_val = ch_malloc( bv.bv_len+1 );
+                                       ptr = lutil_strcopy( bv.bv_val, c->cr_msg );
+                                       *ptr++ = ' ';
+                                       lutil_strcopy( ptr, LDAP_NO_ATTRS );
+                               } else {
 
-                               /* count the attr length */
-                               for ( attr_name = qm->attr_sets[i].attrs;
-                                       attr_name->an_name.bv_val; attr_name++ )
-                               {
-                                       bv.bv_len += attr_name->an_name.bv_len + 1;
-                                       if ( attr_name->an_desc &&
-                                                       ( attr_name->an_desc->ad_flags & SLAP_DESC_TEMPORARY ) ) {
-                                               bv.bv_len += STRLENOF("undef:");
+                                       /* count the attr length */
+                                       for ( attr_name = qm->attr_sets[i].attrs;
+                                               attr_name->an_name.bv_val; attr_name++ )
+                                       {
+                                               bv.bv_len += attr_name->an_name.bv_len + 1;
+                                               if ( attr_name->an_desc &&
+                                                               ( attr_name->an_desc->ad_flags & SLAP_DESC_TEMPORARY ) ) {
+                                                       bv.bv_len += STRLENOF("undef:");
+                                               }
                                        }
-                               }
 
-                               bv.bv_val = ch_malloc( bv.bv_len+1 );
-                               ptr = lutil_strcopy( bv.bv_val, c->cr_msg );
-                               for ( attr_name = qm->attr_sets[i].attrs;
-                                       attr_name->an_name.bv_val; attr_name++ ) {
-                                       *ptr++ = ' ';
-                                       if ( attr_name->an_desc &&
-                                                       ( attr_name->an_desc->ad_flags & SLAP_DESC_TEMPORARY ) ) {
-                                               ptr = lutil_strcopy( ptr, "undef:" );
+                                       bv.bv_val = ch_malloc( bv.bv_len+1 );
+                                       ptr = lutil_strcopy( bv.bv_val, c->cr_msg );
+                                       for ( attr_name = qm->attr_sets[i].attrs;
+                                               attr_name->an_name.bv_val; attr_name++ ) {
+                                               *ptr++ = ' ';
+                                               if ( attr_name->an_desc &&
+                                                               ( attr_name->an_desc->ad_flags & SLAP_DESC_TEMPORARY ) ) {
+                                                       ptr = lutil_strcopy( ptr, "undef:" );
+                                               }
+                                               ptr = lutil_strcopy( ptr, attr_name->an_name.bv_val );
                                        }
-                                       ptr = lutil_strcopy( ptr, attr_name->an_name.bv_val );
                                }
+
                                ber_bvarray_add( &c->rvalue_vals, &bv );
                        }
                        if ( !c->rvalue_vals )