]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/dyngroup.c
Fix modify deadlock
[openldap] / servers / slapd / overlays / dyngroup.c
index c351065c6538e68b98363f4553ced01d6d815ea8..d16f4df0e1b5912d9050b648758bc508a163b7f5 100644 (file)
@@ -1,32 +1,28 @@
 /* dyngroup.c - Demonstration of overlay code */
 /* $OpenLDAP$ */
-/*
- * Copyright 2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Copyright 2003 by Howard Chu.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
-/*
- * Copyright 2003, Howard Chu, All rights reserved. <hyc@symas.com>
- * 
- * Permission is granted to anyone to use this software for any purpose
- * on any computer system, and to alter it and redistribute it, subject
- * to the following restrictions:
- * 
- * 1. The author is not responsible for the consequences of use of this
- *    software, no matter how awful, even if they arise from flaws in it.
- * 
- * 2. The origin of this software must not be misrepresented, either by
- *    explicit claim or by omission.  Since few users ever read sources,
- *    credits should appear in the documentation.
- * 
- * 3. Altered versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.  Since few users
- *    ever read sources, credits should appear in the documentation.
- * 
- * 4. This notice may not be removed or altered.
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Howard Chu for inclusion in
+ * OpenLDAP Software.
  */
 
 #include "portable.h"
 
+#ifdef SLAPD_OVER_DYNGROUP
+
 #include <stdio.h>
 
 #include <ac/string.h>
@@ -94,21 +90,22 @@ static int dyngroup_config(
        if ( strcasecmp( argv[0], "attrpair" ) == 0 ) {
                const char *text;
                if ( argc != 3 ) {
-                       Debug( LDAP_DEBUG_ANY,
-               "%s: line %d: attribute description missing in \"attrpair <member-attribute> <URL-attribute>\" line.\n",
-                       fname, lineno, 0 );
-                       return( 1 );
+                       Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                               "attribute description missing in "
+                               "\"attrpair <member-attribute> <URL-attribute>\" line.\n",
+                               fname, lineno, 0 );
+               return( 1 );
                }
                if ( slap_str2ad( argv[1], &ap.ap_mem, &text ) ) {
-                       Debug( LDAP_DEBUG_ANY,
-               "%s: line %d: attribute description unknown \"attrpair\" line: %s.\n",
-                       fname, lineno, text );
+                       Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                               "attribute description unknown \"attrpair\" line: %s.\n",
+                               fname, lineno, text );
                        return( 1 );
                }
                if ( slap_str2ad( argv[2], &ap.ap_uri, &text ) ) {
-                       Debug( LDAP_DEBUG_ANY,
-               "%s: line %d: attribute description unknown \"attrpair\" line: %s.\n",
-                       fname, lineno, text );
+                       Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                               "attribute description unknown \"attrpair\" line: %s.\n",
+                               fname, lineno, text );
                        return( 1 );
                }
                /* The on->on_bi.bi_private pointer can be used for
@@ -120,6 +117,8 @@ static int dyngroup_config(
                a2->ap_mem = ap.ap_mem;
                a2->ap_uri = ap.ap_uri;
                on->on_bi.bi_private = a2;
+       } else {
+               return SLAP_CONF_UNKNOWN;
        }
        return 0;
 }
@@ -146,7 +145,7 @@ static slap_overinst dyngroup;
  * initialized and registered by some other function inside slapd.
  */
 
-int init_module(int argc, char *argv[]) {
+int dyngroup_init() {
        dyngroup.on_bi.bi_type = "dyngroup";
        dyngroup.on_bi.bi_db_config = dyngroup_config;
        dyngroup.on_bi.bi_db_close = dyngroup_close;
@@ -154,3 +153,11 @@ int init_module(int argc, char *argv[]) {
 
        return overlay_register( &dyngroup );
 }
+
+#if SLAPD_OVER_DYNGROUP == SLAPD_MOD_DYNAMIC
+int init_module(int argc, char *argv[]) {
+       return dyngroup_init();
+}
+#endif
+
+#endif /* defined(SLAPD_OVER_DYNGROUP) */