]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/config.c
ITS#6758
[openldap] / servers / slapd / back-sql / config.c
index 88d02229e33bd403153884919dfd4e751d7ed05b..197787ce5a39d1e5b34c41db39320b80550d44fd 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2006 The OpenLDAP Foundation.
+ * Copyright 1999-2011 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * Portions Copyright 2002 Pierangelo Masarati.
  * Portions Copyright 2004 Mark Adamson.
@@ -148,7 +148,20 @@ backsql_db_config(
                }
                ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_children_cond );
                Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
-                       "subtree_cond=%s\n", bi->sql_children_cond.bv_val, 0, 0 );
+                       "children_cond=%s\n", bi->sql_children_cond.bv_val, 0, 0 );
+
+       } else if ( !strcasecmp( argv[ 0 ], "dn_match_cond" ) ) {
+               if ( argc < 2 ) {
+                       Debug( LDAP_DEBUG_TRACE, 
+                               "<==backsql_db_config (%s line %d): "
+                               "missing SQL condition "
+                               "in \"dn_match_cond\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+               ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_dn_match_cond );
+               Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
+                       "children_cond=%s\n", bi->sql_dn_match_cond.bv_val, 0, 0 );
 
        } else if ( !strcasecmp( argv[ 0 ], "oc_query" ) ) {
                if ( argc < 2 ) {
@@ -527,8 +540,8 @@ backsql_db_config(
                        0, 0 );
 
        } else if ( !strcasecmp( argv[ 0 ], "fetch_attrs" ) ) {
-               char    *str, *s, *next;
-               char    delimstr[] = ",";
+               char            *str, *s, *next;
+               const char      *delimstr = ",";
 
                if ( argc < 2 ) {
                        Debug( LDAP_DEBUG_TRACE,
@@ -626,6 +639,37 @@ backsql_db_config(
 
                ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_aliasing_quote );
 
+       } else if ( !strcasecmp( argv[ 0 ], "autocommit" ) ) {
+               if ( argc != 2 ) {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "missing arg "
+                               "in \"autocommit {NO|yes}\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+
+               if ( !strcasecmp( argv[ 1 ], "yes" ) ||
+                       !strcasecmp( argv[ 1 ], "TRUE" ) ||
+                       !strcasecmp( argv[ 1 ], "on" ) )
+               {
+                       bi->sql_flags |= BSQLF_AUTOCOMMIT_ON;
+
+               } else if ( !strcasecmp( argv[ 1 ], "no" ) ||
+                       !strcasecmp( argv[ 1 ], "FALSE" ) ||
+                       !strcasecmp( argv[ 1 ], "off" ) )
+               {
+                       bi->sql_flags &= ~BSQLF_AUTOCOMMIT_ON;
+
+               } else {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "invalid arg "
+                               "in \"autocommit {NO|yes}\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+
        } else {
                return SLAP_CONF_UNKNOWN;
        }
@@ -646,7 +690,7 @@ read_baseObject(
 {
        backsql_info    *bi = (backsql_info *)be->be_private;
        LDIFFP          *fp;
-       int             rc = 0, lineno = 0, lmax = 0;
+       int             rc = 0, lineno = 0, lmax = 0, ldifrc;
        char            *buf = NULL;
 
        assert( fname != NULL );
@@ -672,7 +716,7 @@ read_baseObject(
        bi->sql_baseObject->e_nname = be->be_nsuffix[0];
        bi->sql_baseObject->e_attrs = NULL;
 
-       while ( ldif_read_record( fp, &lineno, &buf, &lmax ) ) {
+       while (( ldifrc = ldif_read_record( fp, &lineno, &buf, &lmax )) > 0 ) {
                Entry           *e = str2entry( buf );
                Attribute       *a;
 
@@ -691,7 +735,7 @@ read_baseObject(
                                "dn=\"%s\" (line=%d)\n",
                                e->e_name.bv_val, lineno );
                        entry_free( e );
-                       rc = EXIT_FAILURE;
+                       rc = LDAP_OTHER;
                        break;
                }
 
@@ -716,6 +760,9 @@ read_baseObject(
                }
        }
 
+       if ( ldifrc < 0 )
+               rc = LDAP_OTHER;
+
        if ( rc ) {
                entry_free( bi->sql_baseObject );
                bi->sql_baseObject = NULL;
@@ -748,10 +795,10 @@ create_baseObject(
                        "objectClass: extensibleObject\n"
                        "description: builtin baseObject for back-sql\n"
                        "description: all entries mapped "
-                       "in the \"ldap_entries\" table\n"
-                       "description: must have "
-                       "\"" BACKSQL_BASEOBJECT_IDSTR "\" "
-                       "in the \"parent\" column",
+                               "in table \"ldap_entries\" "
+                               "must have "
+                               "\"" BACKSQL_BASEOBJECT_IDSTR "\" "
+                               "in the \"parent\" column",
                        be->be_suffix[0].bv_val );
 
        bi->sql_baseObject = str2entry( buf );