]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9629 back-sql: Add support for ppolicy opattrs
authorAapo Romu <aapo.romu@eficode.com>
Mon, 29 Mar 2021 16:31:13 +0000 (16:31 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 12 Aug 2021 13:40:40 +0000 (14:40 +0100)
So that ppolicy rules are applied

servers/slapd/back-sql/add.c

index b47e96c1cd7e895d1196a22cfd142137f95bf33f..9375827d82230d3c0d17abb88595df2460566c88 100644 (file)
 #include <lutil.h>
 #endif /* BACKSQL_SYNCPROV */
 
+const char * processable_op_attrs[] = {
+               "pwdAccountLockedTime",
+               "pwdChangedTime",
+               "pwdFailureTime",
+               "pwdGraceUseTime",
+               "pwdHistory",
+               "pwdPolicySubentry",
+               "pwdReset",
+               "entryUUID"
+};
+
+#define processable_op_attrs_length (sizeof (processable_op_attrs) / sizeof (const char *))
+
+static int indexOf(const char *array[], int array_size, const char * value) {
+       for (int i = 0; i < array_size; ++i) {
+               if(strcmp(array[i], value) == 0) {
+                       return i;
+               }
+       }
+       return -1;
+}
+
+static int is_processable_opattr(const char * attr) {
+       return indexOf(processable_op_attrs, processable_op_attrs_length, attr) >= 0;
+}
+
+#define backsql_opattr_skip(ad) \
+       (is_at_operational( (ad)->ad_type ) && (ad) != slap_schema.si_ad_ref )
+
 /*
  * Skip:
  * - null values (e.g. delete modification)
  * - single occurrence of objectClass, because it is already used
  *   to determine how to build the SQL entry
- * - operational attributes
+ * - operational attributes (except those in processable_op_attrs)
  * - empty attributes
  */
-#define backsql_opattr_skip(ad) \
-       (is_at_operational( (ad)->ad_type ) && (ad) != slap_schema.si_ad_ref )
 #define        backsql_attr_skip(ad, vals) \
        ( \
-               ( (ad) == slap_schema.si_ad_objectClass \
+               ( ( (ad) == slap_schema.si_ad_objectClass \
                                && (vals) && BER_BVISNULL( &((vals)[ 1 ]) ) ) \
                || backsql_opattr_skip( (ad) ) \
                || ( (vals) && BER_BVISNULL( &((vals)[ 0 ]) ) ) \
-       )
+       ) && !is_processable_opattr( ad->ad_cname.bv_val ) )
 
 int
 backsql_modify_delete_all_values(
@@ -302,6 +329,10 @@ backsql_modify_internal(
                        ad->ad_cname.bv_val, sm_ops[ sm_op ], BACKSQL_OC_NAME( oc ) );
 
                if ( backsql_attr_skip( ad, sm_values ) ) {
+                       Debug( LDAP_DEBUG_TRACE, "   backsql_modify_internal(): "
+                               "skipping attribute \"%s\"\n",
+                               ad->ad_cname.bv_val, 0, 0 );
+
                        continue;
                }