Initial implementation of DN-String and DN-Binary syntax.
authorNadezhda Ivanova <nivanova@symas.com>
Tue, 5 Aug 2014 12:38:18 +0000 (15:38 +0300)
committerNadezhda Ivanova <nivanova@symas.com>
Tue, 5 Aug 2014 12:44:02 +0000 (15:44 +0300)
Validation cannot be tested in this point, will be added
later. The new syntaces are compatible with octetStringMatch.

contrib/slapd-modules/samba4/Makefile
contrib/slapd-modules/samba4/dnsyntax.c [new file with mode: 0644]

index c4b9d9717ec35f885079bcabeac66ac826152d02..7ec90d3e8d7ac1bab967f874ef0c835fc802a6aa 100644 (file)
@@ -28,13 +28,14 @@ DEFS = -DSLAPD_OVER_RDNVAL=SLAPD_MOD_DYNAMIC \
        -DSLAPD_OVER_SYNTAXCHECKS=SLAPD_MOD_DYNAMIC \
        -DSLAPD_OVER_SHOWDELETED=SLAPD_MOD_DYNAMIC \
         -DSLAPD_OVER_LAZYCOMMIT=SLAPD_MOD_DYNAMIC \
-       -DSLAPD_OVER_SAMBA4SCHEMA=SLAPD_MOD_DYNAMIC
+       -DSLAPD_OVER_SAMBA4SCHEMA=SLAPD_MOD_DYNAMIC \
+       -DSLAPD_OVER_DNSYNTAX=SLAPD_MOD_DYNAMIC
 
 INCS = $(LDAP_INC)
 LIBS = $(LDAP_LIB)
 
 PROGRAMS = pguid.la rdnval.la vernum.la syntax_checks.la instancetype.la \
-           show_deleted.la samba4_schema.la lazycommit.la
+           show_deleted.la samba4_schema.la lazycommit.la dnsyntax.la
 LTVER = 0:0:0
 
 prefix=/usr/local
@@ -84,6 +85,10 @@ lazycommit.la: lazycommit.lo
        $(LIBTOOL) --mode=link $(CC) $(OPT) -version-info $(LTVER) \
        -rpath $(moduledir) -module -o $@ $? $(LIBS)
 
+dnsyntax.la: dnsyntax.lo
+       $(LIBTOOL) --mode=link $(CC) $(OPT) -version-info $(LTVER) \
+       -rpath $(moduledir) -module -o $@ $? $(LIBS)
+
 clean:
        rm -rf *.o *.lo *.la .libs
 
diff --git a/contrib/slapd-modules/samba4/dnsyntax.c b/contrib/slapd-modules/samba4/dnsyntax.c
new file mode 100644 (file)
index 0000000..e1fcbf6
--- /dev/null
@@ -0,0 +1,105 @@
+
+#include "portable.h"
+
+#ifdef SLAPD_OVER_DNSYNTAX
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+
+#include "slap.h"
+#include "config.h"
+#include "lutil.h"
+
+static slap_overinst dnsyntax;
+
+static int
+dnStringSyntaxValidate(
+       Syntax          *syntax,
+       struct berval   *val )
+{
+       /* TODO, in samba this is most likely validated in a module, check */
+       return LDAP_SUCCESS;
+}
+
+static int
+dnBinarySyntaxValidate(
+       Syntax          *syntax,
+       struct berval   *val )
+{
+       return LDAP_SUCCESS;
+}
+
+static char    *dnsyntaxMRs[] = {
+       "octetStringMatch",
+       NULL
+};
+
+static struct {
+       char                    *oid;
+       slap_syntax_defs_rec    syn;
+       char                    **mrs;
+} dnsyntaxes[] = {
+       { "1.2.840.113556.1.4.903" ,
+               { "( 1.2.840.113556.1.4.903 DESC 'DN-String, String + DN' )",
+                       0,
+                       NULL,
+                       dnStringSyntaxValidate,
+                       NULL },
+               dnsyntaxMRs },
+       { "1.2.840.113556.1.4.904" ,
+               { "( 1.2.840.113556.1.4.904 DESC 'DN-Binary, Binary blob + DN' )",
+                       0,
+                       NULL,
+                       dnBinarySyntaxValidate,
+                       NULL },
+               dnsyntaxMRs },
+       { NULL }
+};
+
+int dnsyntax_initialize()
+{
+       int i;
+
+       dnsyntax.on_bi.bi_type = "dnsyntax";
+
+       for ( i=0; dnsyntaxes[i].oid; i++ ) {
+               int code;
+
+               code = register_syntax( &dnsyntaxes[ i ].syn );
+               if ( code != 0 ) {
+                       Debug( LDAP_DEBUG_ANY,
+                               "dnsyntax_init: register_syntax failed\n",
+                               0, 0, 0 );
+                       return code;
+               }
+
+               if ( dnsyntaxes[i].mrs != NULL ) {
+                       code = mr_make_syntax_compat_with_mrs(
+                               dnsyntaxes[i].oid, dnsyntaxes[i].mrs );
+                       if ( code < 0 ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                       "dnsyntax_init: "
+                                       "mr_make_syntax_compat_with_mrs "
+                                       "failed\n",
+                                       0, 0, 0 );
+                               return code;
+                       }
+               }
+       }
+
+
+
+       return overlay_register(&dnsyntax);
+}
+
+#if SLAPD_OVER_DNSYNTAX == SLAPD_MOD_DYNAMIC
+int
+init_module( int argc, char *argv[] )
+{
+       return dnsyntax_initialize();
+}
+#endif
+
+#endif /* SLAPD_OVER_DNSYNTAX */