[Pkg-freeipa-devel] slapi-nis: Changes to 'upstream-unstable'

Timo Aaltonen tjaalton-guest at alioth.debian.org
Tue Dec 11 08:48:34 UTC 2012


 README                            |    2 
 configure.ac                      |  118 +++++++++++++++++++++++++
 doc/betxn-notes.txt               |   18 +++
 doc/nis-known-maps.txt            |    2 
 slapi-nis.spec                    |   18 +++
 src/back-nis.c                    |   24 +++++
 src/back-sch.c                    |  130 +++++++++++++++++++++++++---
 src/back-shr.c                    |  173 ++++++++++++++++++++++++++++++++------
 src/back-shr.h                    |    5 -
 src/backend.h                     |    4 
 src/defs-nis.c                    |   71 ++++++++++++++-
 src/plug-nis.c                    |   50 ++++++++++
 src/plug-sch.c                    |   73 +++++++++++++++-
 src/plugin.h                      |    3 
 tests/config/dse.ldif.initial.in  |   12 ++
 tests/config/dse.ldif.memberof.in |    1 
 tests/config/dse.ldif.mep.in      |    1 
 tests/config/dse.ldif.refint.in   |    1 
 tests/config/dse.ldif.usn.in      |    1 
 tests/run-tests.sh                |   27 ++++-
 20 files changed, 678 insertions(+), 56 deletions(-)

New commits:
commit c133905b65d576f3cd68ebfee8732758eddf3db9
Author: Nalin Dahyabhai <nalin at dahyabhai.net>
Date:   Wed Nov 14 10:53:16 2012 -0500

    tag 0.44

diff --git a/configure.ac b/configure.ac
index 6211ab3..0705ac7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(slapi-nis,0.43)
+AC_INIT(slapi-nis,0.44)
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE(foreign)
 LT_INIT([disable-static])
diff --git a/slapi-nis.spec b/slapi-nis.spec
index b045347..97204d5 100644
--- a/slapi-nis.spec
+++ b/slapi-nis.spec
@@ -5,7 +5,7 @@
 %endif
 
 Name:		slapi-nis
-Version:	0.43
+Version:	0.44
 Release:	1%{?dist}
 Summary:	NIS Server and Schema Compatibility plugins for Directory Server
 Group:		System Environment/Daemons
@@ -70,6 +70,13 @@ rm -rf $RPM_BUILD_ROOT
 %{_sbindir}/nisserver-plugin-defs
 
 %changelog
+* Wed Nov 14 2012 Nalin Dahyabhai <nalin at redhat.com> - 0.44-1
+- add missing newline to a couple of debug log messages
+- note whether or not betxn support is compiled in as part of the
+  nsslapd-pluginVersion value we report to the server
+- register callbacks in the same order in both plugins, so that
+  their log messages are logged in the same order
+
 * Tue Nov 13 2012 Nalin Dahyabhai <nalin at redhat.com> - 0.43-1
 - reintroduce support for directory server transactions (nhosoi, IPA#3046)
 - control transaction support at run-time, deciding when to do things based

commit ea2a620f165f6dcf564640cbdc9d2cacb67b61c1
Author: Nalin Dahyabhai <nalin at dahyabhai.net>
Date:   Wed Nov 14 10:30:24 2012 -0500

    just go human-readable on version details

diff --git a/configure.ac b/configure.ac
index 9d639cf..6211ab3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -226,12 +226,12 @@ AH_VERBATIM([PACKAGE_VERSION_HAVE_TXNS],
 [
 #ifdef SLAPI_NIS_SUPPORT_BE_TXNS
 #ifdef DEFAULT_PLUGIN_USE_BETXNS
-#define PACKAGE_VERSION_TXNS " (betxns:supported_and_used_by_default)"
+#define PACKAGE_VERSION_TXNS " (betxn support available and enabled by default)"
 #else
-#define PACKAGE_VERSION_TXNS " (betxns:supported_but_not_used_by_default)"
+#define PACKAGE_VERSION_TXNS " (betxn support available but not enabled by default)"
 #endif
 #else
-#define PACKAGE_VERSION_TXNS " (betxns:not_supported)"
+#define PACKAGE_VERSION_TXNS " (betxn support not available)"
 #endif
 ])
 

commit b64c92fa17dc5a1c30276f213340ef80d9f41457
Author: Nalin Dahyabhai <nalin at dahyabhai.net>
Date:   Wed Nov 14 10:30:09 2012 -0500

    include header to avoid implicit declaration

diff --git a/src/plug-sch.c b/src/plug-sch.c
index 23af048..5440e00 100644
--- a/src/plug-sch.c
+++ b/src/plug-sch.c
@@ -51,6 +51,7 @@
 #endif
 
 #include "backend.h"
+#include "back-shr.h"
 #include "map.h"
 #include "plugin.h"
 #include "portmap.h"

commit f82045c0b7f8090376dcb3cc77dbee487b6eb182
Author: Nalin Dahyabhai <nalin at dahyabhai.net>
Date:   Wed Nov 14 10:27:23 2012 -0500

    log message fixups
    
    - put a newline at the end of these two messages
    - register callbacks in a consistent order

diff --git a/src/plug-nis.c b/src/plug-nis.c
index 85aa3e2..212063a 100644
--- a/src/plug-nis.c
+++ b/src/plug-nis.c
@@ -517,7 +517,7 @@ nis_plugin_init(Slapi_PBlock *pb)
 							 "nsslapd-pluginbetxn",
 							 DEFAULT_PLUGIN_USE_BETXNS);
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"starting with betxn support %s",
+				"starting with betxn support %s\n",
 				is_betxn ? "enabled" : "disabled");
 		state->use_be_txns = is_betxn;
 	}
diff --git a/src/plug-sch.c b/src/plug-sch.c
index 913ab5e..23af048 100644
--- a/src/plug-sch.c
+++ b/src/plug-sch.c
@@ -219,7 +219,7 @@ schema_compat_plugin_init(Slapi_PBlock *pb)
 							 "nsslapd-pluginbetxn",
 							 DEFAULT_PLUGIN_USE_BETXNS);
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"starting with betxn support %s",
+				"starting with betxn support %s\n",
 				is_betxn ? "enabled" : "disabled");
 		state->use_be_txns = is_betxn;
 	}
@@ -252,15 +252,6 @@ schema_compat_plugin_init(Slapi_PBlock *pb)
 				"error registering betxn preoperation plugin\n");
 		return -1;
 	}
-	if (slapi_register_plugin("betxnpostoperation", TRUE,
-				  "schema_compat_plugin_init_betxn_postop",
-				  schema_compat_plugin_init_betxn_postop,
-				  PLUGIN_BETXN_POSTOP_ID, NULL,
-				  state->plugin_identity) != 0) {
-		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"error registering betxn postoperation plugin\n");
-		return -1;
-	}
 #endif
 	if (slapi_register_plugin("postoperation", TRUE,
 				  "schema_compat_plugin_init_postop",
@@ -280,6 +271,17 @@ schema_compat_plugin_init(Slapi_PBlock *pb)
 				"error registering internal postoperation plugin\n");
 		return -1;
 	}
+#ifdef SLAPI_NIS_SUPPORT_BE_TXNS
+	if (slapi_register_plugin("betxnpostoperation", TRUE,
+				  "schema_compat_plugin_init_betxn_postop",
+				  schema_compat_plugin_init_betxn_postop,
+				  PLUGIN_BETXN_POSTOP_ID, NULL,
+				  state->plugin_identity) != 0) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"error registering betxn postoperation plugin\n");
+		return -1;
+	}
+#endif
 	slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
 			"registered plugin hooks\n");
 	global_plugin_state = NULL;

commit d80ce0def40c2b4d1f8627791707ee074040920a
Author: Nalin Dahyabhai <nalin at dahyabhai.net>
Date:   Wed Nov 14 10:27:00 2012 -0500

    explicitly check for "no" values

diff --git a/src/back-shr.c b/src/back-shr.c
index a6a7230..97fa2e2 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -550,11 +550,19 @@ backend_shr_get_vattr_boolean(struct plugin_state *state,
 	if (tmp != NULL) {
 		/* FIXME: should we use nl_langinfo(YESEXPR) here? */
 		if ((strcasecmp(tmp, "yes") == 0) ||
+		    (strcasecmp(tmp, "true") == 0) ||
 		    (strcasecmp(tmp, "on") == 0) ||
 		    (strcasecmp(tmp, "1") == 0)) {
 			ret = TRUE;
 		} else {
-			ret = FALSE;
+			if ((strcasecmp(tmp, "no") == 0) ||
+			    (strcasecmp(tmp, "false") == 0) ||
+			    (strcasecmp(tmp, "off") == 0) ||
+			    (strcasecmp(tmp, "0") == 0)) {
+				ret = FALSE;
+			} else {
+				ret = default_value;
+			}
 		}
 		free(tmp);
 	}

commit d1d78630e01dfc64319ce4db406477379b1a2b37
Author: Nalin Dahyabhai <nalin at redhat.com>
Date:   Tue Nov 13 18:21:33 2012 -0500

    warning cleanup: remove unused variables

diff --git a/src/back-sch.c b/src/back-sch.c
index 85de48c..fede75d 100644
--- a/src/back-sch.c
+++ b/src/back-sch.c
@@ -259,7 +259,7 @@ backend_entry_get_usn(Slapi_PBlock *pb, Slapi_Entry *e,
 	Slapi_DN *sdn;
 	char *attr, *attrs[2], *actual_attr, *val;
 	const char *cval;
-	int count, disposition, buffer_flags, i;
+	int count, disposition, buffer_flags;
 
 	root = NULL;
 	if (e != NULL) {
@@ -838,8 +838,7 @@ backend_update_params(Slapi_PBlock *pb, struct plugin_state *state)
 {
 	Slapi_DN *our_dn;
 	Slapi_Entry *our_entry;
-	char *tmp, **tmpv;
-	int i, use_be_txns;
+	int use_be_txns;
 
 	our_dn = slapi_sdn_new_dn_byval(state->plugin_base);
 	if (our_dn == NULL) {

commit eaa9c342928e20324f3248e65a37bb344fb0671c
Author: Nalin Dahyabhai <nalin at redhat.com>
Date:   Tue Nov 13 18:08:38 2012 -0500

    show betxn settings in the plugin version

diff --git a/configure.ac b/configure.ac
index d285b3b..9d639cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -222,6 +222,19 @@ fi
 AC_DEFINE_UNQUOTED(DEFAULT_PLUGIN_USE_BETXNS,$deftransactions,
 		   [Define non-zero if support for backend transactions should be enabled by default.])
 
+AH_VERBATIM([PACKAGE_VERSION_HAVE_TXNS],
+[
+#ifdef SLAPI_NIS_SUPPORT_BE_TXNS
+#ifdef DEFAULT_PLUGIN_USE_BETXNS
+#define PACKAGE_VERSION_TXNS " (betxns:supported_and_used_by_default)"
+#else
+#define PACKAGE_VERSION_TXNS " (betxns:supported_but_not_used_by_default)"
+#endif
+#else
+#define PACKAGE_VERSION_TXNS " (betxns:not_supported)"
+#endif
+])
+
 if test $thread_api = NSPR ; then
 	AC_DEFINE(USE_NSPR_THREADS,1,[Define to use NSPR threading functions.])
 elif test $thread_api = POSIX ; then
diff --git a/src/plug-nis.c b/src/plug-nis.c
index 4815749..85aa3e2 100644
--- a/src/plug-nis.c
+++ b/src/plug-nis.c
@@ -68,7 +68,7 @@ static Slapi_PluginDesc
 plugin_description = {
 	.spd_id = "nis-plugin",
 	.spd_vendor = "redhat.com",
-	.spd_version = PACKAGE_VERSION,
+	.spd_version = PACKAGE_VERSION PACKAGE_VERSION_TXNS,
 	.spd_description = "NIS Server Plugin",
 };
 static struct plugin_state *global_plugin_state;
diff --git a/src/plug-sch.c b/src/plug-sch.c
index a1c6344..913ab5e 100644
--- a/src/plug-sch.c
+++ b/src/plug-sch.c
@@ -68,7 +68,7 @@ static Slapi_PluginDesc
 plugin_description = {
 	.spd_id = PLUGIN_ID,
 	.spd_vendor = "redhat.com",
-	.spd_version = PACKAGE_VERSION,
+	.spd_version = PACKAGE_VERSION PACKAGE_VERSION_TXNS,
 	.spd_description = "Schema Compatibility Plugin",
 };
 static struct plugin_state *global_plugin_state;

commit 9a926114539a95cfc09e2b6601322072437d9a19
Author: Nalin Dahyabhai <nalin at redhat.com>
Date:   Tue Nov 13 17:59:31 2012 -0500

    re-sync with fedora package changelog

diff --git a/slapi-nis.spec b/slapi-nis.spec
index 3b7357d..b045347 100644
--- a/slapi-nis.spec
+++ b/slapi-nis.spec
@@ -76,6 +76,9 @@ rm -rf $RPM_BUILD_ROOT
   on the value of the nsslapd-pluginbetxn attribute in the plugin's entry
 - NIS: add default settings for shadow.byname and passwd.adjunct.byname maps
 
+* Sat Jul 21 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.42-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
+
 * Wed Jun 13 2012 Nalin Dahyabhai <nalin at redhat.com> - 0.42-1
 - drop support for directory server transactions (richm, #766320)
 

commit faa6a360094e660b1f0865998aecbc0697c5a5b6
Author: Nalin Dahyabhai <nalin at redhat.com>
Date:   Tue Nov 13 17:50:19 2012 -0500

    tag 0.43

diff --git a/configure.ac b/configure.ac
index 47181f5..d285b3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(slapi-nis,0.42)
+AC_INIT(slapi-nis,0.43)
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE(foreign)
 LT_INIT([disable-static])
diff --git a/slapi-nis.spec b/slapi-nis.spec
index 27bc051..3b7357d 100644
--- a/slapi-nis.spec
+++ b/slapi-nis.spec
@@ -5,7 +5,7 @@
 %endif
 
 Name:		slapi-nis
-Version:	0.42
+Version:	0.43
 Release:	1%{?dist}
 Summary:	NIS Server and Schema Compatibility plugins for Directory Server
 Group:		System Environment/Daemons
@@ -70,7 +70,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_sbindir}/nisserver-plugin-defs
 
 %changelog
-* Tue Nov 13 2012 Nalin Dahyabhai <nalin at redhat.com>
+* Tue Nov 13 2012 Nalin Dahyabhai <nalin at redhat.com> - 0.43-1
 - reintroduce support for directory server transactions (nhosoi, IPA#3046)
 - control transaction support at run-time, deciding when to do things based
   on the value of the nsslapd-pluginbetxn attribute in the plugin's entry

commit 91597a1a0ebc874d41f7ab80c27017d8bfe6b5c7
Author: Nalin Dahyabhai <nalin at redhat.com>
Date:   Tue Nov 13 17:49:11 2012 -0500

    - reintroduce support for directory server transactions (nhosoi, IPA#3046)
    - control transaction support at run-time, deciding when to do things based
      on the value of the nsslapd-pluginbetxn attribute in the plugin's entry
    - NIS: add default settings for shadow.byname and passwd.adjunct.byname maps

diff --git a/slapi-nis.spec b/slapi-nis.spec
index 46b1117..27bc051 100644
--- a/slapi-nis.spec
+++ b/slapi-nis.spec
@@ -70,6 +70,12 @@ rm -rf $RPM_BUILD_ROOT
 %{_sbindir}/nisserver-plugin-defs
 
 %changelog
+* Tue Nov 13 2012 Nalin Dahyabhai <nalin at redhat.com>
+- reintroduce support for directory server transactions (nhosoi, IPA#3046)
+- control transaction support at run-time, deciding when to do things based
+  on the value of the nsslapd-pluginbetxn attribute in the plugin's entry
+- NIS: add default settings for shadow.byname and passwd.adjunct.byname maps
+
 * Wed Jun 13 2012 Nalin Dahyabhai <nalin at redhat.com> - 0.42-1
 - drop support for directory server transactions (richm, #766320)
 

commit f3f8ea446c04b3ca50a723d007314eba9d21d133
Author: Nalin Dahyabhai <nalin at redhat.com>
Date:   Mon Nov 12 13:47:47 2012 -0500

    add test use of betxns

diff --git a/configure.ac b/configure.ac
index 90dba52..47181f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -481,6 +481,7 @@ TESTS_USE_REFINT=true
 TESTS_USE_MEMBEROF=true
 TESTS_USE_MANAGED_ENTRIES=true
 TESTS_USE_USN=true
+TESTS_USE_BETXN=true
 AC_ARG_ENABLE(tests-with-refint,
 	      AS_HELP_STRING([--disable-tests-with-refint],
 			     [skip tests which use the the refint plugin]),
@@ -521,10 +522,27 @@ AC_ARG_ENABLE(tests-with-usn,
 		  TESTS_USE_USN=false
 	      fi,
 	      AC_MSG_RESULT([running tests with usn enabled]))
+AC_ARG_ENABLE(tests-with-betxn,
+	      AS_HELP_STRING([--disable-tests-with-betxn],
+			     [skip tests which are impacted by betxns]),
+	      if test x$enableval = xyes ; then
+		  AC_MSG_RESULT([running tests with betxn enabled])
+	      else
+	          AC_MSG_RESULT([running tests with betxn disabled])
+		  TESTS_USE_BETXN=false
+	      fi,
+	      AC_MSG_RESULT([running tests with betxn enabled]))
 AC_SUBST(TESTS_USE_REFINT)
 AC_SUBST(TESTS_USE_MEMBEROF)
 AC_SUBST(TESTS_USE_MANAGED_ENTRIES)
 AC_SUBST(TESTS_USE_USN)
+AC_SUBST(TESTS_USE_BETXN)
+if $TESTS_USE_BETXN ; then
+	TEST_PLUGIN_BETXN_ENABLE_OR_NOT="nsslapd-pluginbetxn: on"
+else
+	TEST_PLUGIN_BETXN_ENABLE_OR_NOT="nsslapd-pluginbetxn: off"
+fi
+AC_SUBST(TEST_PLUGIN_BETXN_ENABLE_OR_NOT)
 
 AC_CONFIG_HEADER(src/config.h)
 AC_OUTPUT(Makefile yp/Makefile src/Makefile
diff --git a/tests/config/dse.ldif.initial.in b/tests/config/dse.ldif.initial.in
index e022671..5db1a7f 100644
--- a/tests/config/dse.ldif.initial.in
+++ b/tests/config/dse.ldif.initial.in
@@ -173,6 +173,7 @@ nsslapd-pluginId: NS7bitAttr
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: Enforce  7-bit clean attribute values
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=ACL Plugin,cn=plugins,cn=config
 objectClass: top
@@ -203,6 +204,7 @@ nsslapd-pluginId: acl
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: acl access check plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=attribute uniqueness,cn=plugins,cn=config
 objectClass: top
@@ -220,6 +222,7 @@ nsslapd-pluginId: NSUniqueAttr
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: Enforce unique attribute values
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=Binary Syntax,cn=plugins,cn=config
 objectClass: top
@@ -318,6 +321,7 @@ nsslapd-pluginId: chaining database
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: LDAP chaining backend database plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=Class of Service,cn=plugins,cn=config
 objectClass: top
@@ -335,6 +339,7 @@ nsslapd-pluginId: cos
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: class of service plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=Country String Syntax,cn=plugins,cn=config
 objectClass: top
@@ -392,6 +397,7 @@ nsslapd-pluginId: Distributed Numeric Assignment
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: Distributed Numeric Assignment plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=Enhanced Guide Syntax,cn=plugins,cn=config
 objectClass: top
@@ -463,6 +469,7 @@ nsslapd-pluginId: http-client
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: HTTP Client plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=Integer Syntax,cn=plugins,cn=config
 objectClass: top
@@ -522,6 +529,7 @@ nsslapd-pluginId: ldbm-backend
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: high-performance LDAP backend database plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=NIS Server,cn=plugins,cn=config
 objectClass: top
@@ -647,6 +655,7 @@ nsslapd-pluginId: retrocl
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: Retrocl Plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=Roles Plugin,cn=plugins,cn=config
 objectClass: top
@@ -664,6 +673,7 @@ nsslapd-pluginId: roles
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: roles plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=Schema Compatibility, cn=plugins, cn=config
 objectClass: top
@@ -721,6 +731,7 @@ nsslapd-pluginId: statechange
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: state change notification service plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=Telex Syntax,cn=plugins,cn=config
 objectClass: top
@@ -793,6 +804,7 @@ nsslapd-pluginId: views
 nsslapd-pluginVersion: 1.1.1
 nsslapd-pluginVendor: Fedora Project
 nsslapd-pluginDescription: virtual directory information tree views plugin
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=mapping,cn=sasl,cn=config
 objectClass: top
diff --git a/tests/config/dse.ldif.memberof.in b/tests/config/dse.ldif.memberof.in
index 4d731b2..1d867c8 100644
--- a/tests/config/dse.ldif.memberof.in
+++ b/tests/config/dse.ldif.memberof.in
@@ -10,4 +10,5 @@ nsslapd-pluginenabled: on
 nsslapd-plugin-depends-on-type: database
 memberOfGroupAttr: member
 memberOfAttr: memberOf
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
diff --git a/tests/config/dse.ldif.mep.in b/tests/config/dse.ldif.mep.in
index e9d6ff3..513f284 100644
--- a/tests/config/dse.ldif.mep.in
+++ b/tests/config/dse.ldif.mep.in
@@ -9,6 +9,7 @@ nsslapd-plugininitfunc: mep_init
 nsslapd-plugintype: preoperation
 nsslapd-pluginenabled: on
 nsslapd-plugin-depends-on-type: database
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
 dn: cn=UPG Definition,cn=Managed Entries,cn=plugins,cn=config
 objectclass: extensibleObject
diff --git a/tests/config/dse.ldif.refint.in b/tests/config/dse.ldif.refint.in
index 8b217d3..8700d54 100644
--- a/tests/config/dse.ldif.refint.in
+++ b/tests/config/dse.ldif.refint.in
@@ -16,4 +16,5 @@ nsslapd-pluginArg4: uniquemember
 nsslapd-pluginArg5: owner
 nsslapd-pluginArg6: seeAlso
 nsslapd-plugin-depends-on-type: database
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
diff --git a/tests/config/dse.ldif.usn.in b/tests/config/dse.ldif.usn.in
index 1173eda..339ba49 100644
--- a/tests/config/dse.ldif.usn.in
+++ b/tests/config/dse.ldif.usn.in
@@ -8,4 +8,5 @@ nsslapd-plugininitfunc: usn_init
 nsslapd-plugintype: object
 nsslapd-pluginenabled: on
 nsslapd-plugin-depends-on-type: database
+ at TEST_PLUGIN_BETXN_ENABLE_OR_NOT@
 
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index 3ab4fe1..91afdc9 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -40,6 +40,12 @@ for subdir in "$@" ; do
 			continue
 		fi
 	fi
+	if ! $TESTS_USE_BETXN ; then
+		if test -s $TESTDIR/$TEST/plugin-need-betxn.txt ; then
+			echo Skipping "$TEST", needs backend transaction support.
+			continue
+		fi
+	fi
 	if test -x edit-dse-config.sh ; then
 		precmd="$TESTDIR/$subdir/edit-dse-config.sh $BTESTDIR/config/dse.ldif"
 	fi

commit f3107c65d71d2167e9b95ff79a0d75ed5385bb56
Author: Nalin Dahyabhai <nalin at redhat.com>
Date:   Thu Nov 1 19:25:23 2012 -0400

    Overhaul betxn support
    
    * Check for BETXN support at build-time, provide options for disabling
      or requiring that it be available for build to succeed.
    * Track whether or not BETXN support is enabled in the plugin-local
      state.
    * Skip processing in post/internalpost callbacks if BETXN support is enabled.
    * Skip work in betxnpost callbacks if BETXN support is disabled.

diff --git a/configure.ac b/configure.ac
index 66c978e..90dba52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,6 +105,14 @@ dirsrv)
 			SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN,
 			SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN,
 			SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN,
+			SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN,
+			SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN,
+			SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN,
+			SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN,
+			SLAPI_PLUGIN_BE_TXN_POST_ADD_FN,
+			SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN,
+			SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN,
+			SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN,
 			NULL]
 		       ,,,
 		       [AC_INCLUDES_DEFAULT
@@ -137,6 +145,83 @@ dirsrv)
 	;;
 esac
 
+AC_ARG_ENABLE(be-txns,
+	AS_HELP_STRING([--disable-be-txns],
+		       [build without support for backend transactions]),
+	if test x$enableval = xno ; then
+		transactions=false
+	elif test x$enableval = xyes; then
+		transactions=true
+	fi,
+	transactions=auto)
+if test x$transactions = xauto ; then
+	AC_MSG_CHECKING([for transaction support])
+	transactions=false
+	if test x$ac_cv_have_decl_SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN = xyes; then
+	if test x$ac_cv_have_decl_SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN = xyes; then
+	if test x$ac_cv_have_decl_SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN = xyes; then
+	if test x$ac_cv_have_decl_SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN = xyes; then
+	if test x$ac_cv_have_decl_SLAPI_PLUGIN_BE_TXN_POST_ADD_FN = xyes; then
+	if test x$ac_cv_have_decl_SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN = xyes; then
+	if test x$ac_cv_have_decl_SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN = xyes; then
+	if test x$ac_cv_have_decl_SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN = xyes; then
+		transactions=true
+	fi
+	fi
+	fi
+	fi
+	fi
+	fi
+	fi
+	fi
+	if $transactions ; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+	fi
+else
+	if $transactions ; then
+		AC_MSG_RESULT([enabling backend transaction support])
+	else
+		AC_MSG_RESULT([disabling backend transaction support])
+	fi
+fi
+if $transactions ; then
+	AC_DEFINE(SLAPI_NIS_SUPPORT_BE_TXNS,1,
+		  [Define if support for backend transactions should be built.])
+fi
+
+AC_ARG_ENABLE(be-txns-by-default,
+	AS_HELP_STRING([--disable-be-txns-by-default],
+		       [disable use of backend transactions by default]),
+	if test x$enableval = xno ; then
+		deftransactions=0
+	elif test x$enableval = xyes ; then
+		if ! $transactions ; then
+			AC_MSG_ERROR([unable to enable transactions by default without support for them])
+		fi
+		deftransactions=1
+	else
+		deftransactions=auto
+	fi,
+	deftransactions=auto)
+if test $deftransactions = auto ; then
+	AC_MSG_CHECKING([whether or not to enable transaction support by default])
+	if $transactions ; then
+		AC_MSG_RESULT([yes])
+		deftransactions=1
+	else
+		AC_MSG_RESULT([no transaction support, so no])
+		deftransactions=0
+	fi
+elif test x$deftransactions = x0 ; then
+	AC_MSG_RESULT([disabling backend transactions by default])
+elif test x$deftransactions = x1 ; then
+	AC_MSG_RESULT([enabling backend transactions by default])
+fi
+AC_DEFINE_UNQUOTED(DEFAULT_PLUGIN_USE_BETXNS,$deftransactions,
+		   [Define non-zero if support for backend transactions should be enabled by default.])
+
 if test $thread_api = NSPR ; then
 	AC_DEFINE(USE_NSPR_THREADS,1,[Define to use NSPR threading functions.])
 elif test $thread_api = POSIX ; then
diff --git a/src/back-nis.c b/src/back-nis.c
index fa810ab..40df624 100644
--- a/src/back-nis.c
+++ b/src/back-nis.c
@@ -748,7 +748,7 @@ backend_update_params(Slapi_PBlock *pb, struct plugin_state *state)
 	Slapi_DN *our_dn;
 	Slapi_Entry *our_entry;
 	char *tmp, **tmpv;
-	int i;
+	int i, use_be_txns;
 
 	our_dn = slapi_sdn_new_dn_byval(state->plugin_base);
 	if (our_dn == NULL) {
@@ -810,6 +810,18 @@ backend_update_params(Slapi_PBlock *pb, struct plugin_state *state)
 			    DEFAULT_TCPWRAP_NAME);
 	}
 #endif
+	use_be_txns = backend_shr_get_vattr_boolean(state, our_entry,
+						    "nsslapd-pluginbetxn",
+						    DEFAULT_PLUGIN_USE_BETXNS);
+	if (state->use_be_txns && !use_be_txns) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"turning off betxn support");
+	}
+	if (!state->use_be_txns && use_be_txns) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"turning on betxn support");
+	}
+	state->use_be_txns = use_be_txns;
 	slapi_entry_free(our_entry);
 }
 
@@ -970,6 +982,16 @@ backend_startup(Slapi_PBlock *pb, struct plugin_state *state)
 }
 
 /* Set up our post-op callbacks. */
+#ifdef SLAPI_NIS_SUPPORT_BE_TXNS
+int
+backend_init_betxn_postop(Slapi_PBlock *pb, struct plugin_state *state)
+{
+	slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+			"hooking up betxn postoperation callbacks\n");
+	return backend_shr_betxn_postop_init(pb, state);
+}
+#endif
+
 int
 backend_init_postop(Slapi_PBlock *pb, struct plugin_state *state)
 {
diff --git a/src/back-sch.c b/src/back-sch.c
index e889458..85de48c 100644
--- a/src/back-sch.c
+++ b/src/back-sch.c
@@ -836,6 +836,48 @@ backend_entry_get_set_config_entry_filter(void)
 void
 backend_update_params(Slapi_PBlock *pb, struct plugin_state *state)
 {
+	Slapi_DN *our_dn;
+	Slapi_Entry *our_entry;
+	char *tmp, **tmpv;
+	int i, use_be_txns;
+
+	our_dn = slapi_sdn_new_dn_byval(state->plugin_base);
+	if (our_dn == NULL) {
+		slapi_log_error(SLAPI_LOG_PLUGIN,
+				state->plugin_desc->spd_id,
+				"backend_update_params: "
+				"error parsing %s%s%s\n",
+				state->plugin_base ? "\"" : "",
+				state->plugin_base ?
+				state->plugin_base : "NULL",
+				state->plugin_base ? "\"" : "");
+		return;
+	}
+	wrap_search_internal_get_entry(pb, our_dn, NULL, NULL, &our_entry,
+				       state->plugin_identity);
+	slapi_sdn_free(&our_dn);
+	our_dn = NULL;
+	if (our_entry == NULL) {
+		slapi_log_error(SLAPI_LOG_PLUGIN,
+				state->plugin_desc->spd_id,
+				"backend_update_params: failure reading entry "
+				"\"%s\"\n", state->plugin_base);
+		return;
+	}
+	/* Pull out the attribute values.  Just the one here. */
+	use_be_txns = backend_shr_get_vattr_boolean(state, our_entry,
+						    "nsslapd-pluginbetxn",
+						    DEFAULT_PLUGIN_USE_BETXNS);
+	if (state->use_be_txns && !use_be_txns) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"turning off betxn support");
+	}
+	if (!state->use_be_txns && use_be_txns) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"turning on betxn support");
+	}
+	state->use_be_txns = use_be_txns;
+	slapi_entry_free(our_entry);
 }
 
 /* Intercept a search request, and if it belongs to one of our compatibility
@@ -1345,6 +1387,22 @@ backend_write_cb(Slapi_PBlock *pb)
 }
 
 static int
+backend_pre_write_cb(Slapi_PBlock *pb)
+{
+	struct plugin_state *state;
+	slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state);
+	return state->use_be_txns ? 0: backend_write_cb(pb);
+}
+
+static int
+backend_betxn_pre_write_cb(Slapi_PBlock *pb)
+{
+	struct plugin_state *state;
+	slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state);
+	return state->use_be_txns ? backend_write_cb(pb) : 0;
+}
+
+static int
 backend_bind_cb(Slapi_PBlock *pb)
 {
 	struct backend_entry_data *data;
@@ -1441,106 +1499,90 @@ backend_startup(Slapi_PBlock *pb, struct plugin_state *state)
 int
 backend_init_preop(Slapi_PBlock *pb, struct plugin_state *state)
 {
-	int bindfn = SLAPI_PLUGIN_PRE_BIND_FN;
-	int cmpfn = SLAPI_PLUGIN_PRE_COMPARE_FN;
-	int srchfn = SLAPI_PLUGIN_PRE_SEARCH_FN;
-	int addfn = SLAPI_PLUGIN_PRE_ADD_FN;
-	int modfn = SLAPI_PLUGIN_PRE_MODIFY_FN;
-	int mdnfn = SLAPI_PLUGIN_PRE_MODRDN_FN;
-	int delfn = SLAPI_PLUGIN_PRE_DELETE_FN;
-	Slapi_Entry *plugin_entry = NULL;
-	char *plugin_type = NULL;
-	int is_betxn = 0;
-
-	if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
-	     plugin_entry &&
-	    (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
-	    plugin_type && strstr(plugin_type, "betxn")) {
-		is_betxn = 1;
-	}
-	slapi_ch_free_string(&plugin_type);
-
 	slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
 			"hooking up preoperation callbacks\n");
 	/* Intercept bind requests and return a referral or failure for entries
 	 * that we're managing. */
-	if (slapi_pblock_set(pb, bindfn, backend_bind_cb) != 0) {
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_BIND_FN,
+			     backend_bind_cb) != 0) {
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"error hooking up bind callback\n");
+				"error hooking up pre bind callback\n");
 		return -1;
 	}
 	/* Intercept compare requests and return the right data. */
-	if (slapi_pblock_set(pb, cmpfn, backend_compare_cb) != 0) {
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_COMPARE_FN,
+			     backend_compare_cb) != 0) {
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"error hooking up compare callback\n");
+				"error hooking up pre compare callback\n");
 		return -1;
 	}
 	/* Intercept search requests and return the right data. */
-	if (slapi_pblock_set(pb, srchfn, backend_search_cb) != 0) {
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_SEARCH_FN,
+			     backend_search_cb) != 0) {
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"error hooking up search callback\n");
+				"error hooking up pre search callback\n");
 		return -1;
 	}
-	if (!is_betxn) {
-		/* if is_betxn, these callbacks are registered for betxnpreop */
-		/* Intercept write requests and return an insufficient-access error for
-		 * attempts to write to anything we're managing. */
-		if (slapi_pblock_set(pb, addfn, backend_write_cb) != 0) {
-			slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-					"error hooking up add callback\n");
-			return -1;
-		}
-		if (slapi_pblock_set(pb, modfn, backend_write_cb) != 0) {
-			slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-					"error hooking up modify callback\n");
-			return -1;
-		}
-		if (slapi_pblock_set(pb, mdnfn, backend_write_cb) != 0) {
-			slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-					"error hooking up modrdn callback\n");
-			return -1;
-		}
-		if (slapi_pblock_set(pb, delfn, backend_write_cb) != 0) {
-			slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-					"error hooking up delete callback\n");
-			return -1;
-		}
+	/* Intercept write requests to our areas. */
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN,
+			     backend_pre_write_cb) != 0) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"error hooking up pre add callback\n");
+		return -1;
+	}
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN,
+			     backend_pre_write_cb) != 0) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"error hooking up pre modify callback\n");
+		return -1;
+	}
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODRDN_FN,
+			     backend_pre_write_cb) != 0) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"error hooking up pre modrdn callback\n");
+		return -1;
+	}
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_DELETE_FN,
+			     backend_pre_write_cb) != 0) {
+		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+				"error hooking up pre delete callback\n");
+		return -1;
 	}
 	/* We don't hook abandonment requests. */
 	/* We don't hook unbind requests. */
 	return 0;
 }
 
+#ifdef SLAPI_NIS_SUPPORT_BE_TXNS
 int
-backend_init_betxnpreop(Slapi_PBlock *pb, struct plugin_state *state)
+backend_init_betxn_preop(Slapi_PBlock *pb, struct plugin_state *state)
 {
-	int addfn = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
-	int modfn = SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN;
-	int mdnfn = SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN;
-	int delfn = SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN;
-
 	slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
 	                "hooking up betxn preoperation callbacks\n");
 	/* Intercept write requests and return an insufficient-access error for
 	 * attempts to write to anything we're managing. */
-	if (slapi_pblock_set(pb, addfn, backend_write_cb) != 0) {
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN,
+			     backend_betxn_pre_write_cb) != 0) {
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"error hooking up add callback\n");
+				"error hooking up betxn pre add callback\n");
 		return -1;
 	}
-	if (slapi_pblock_set(pb, modfn, backend_write_cb) != 0) {
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN,
+			     backend_betxn_pre_write_cb) != 0) {
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"error hooking up modify callback\n");
+				"error hooking up betxn pre modify callback\n");
 		return -1;
 	}
-	if (slapi_pblock_set(pb, mdnfn, backend_write_cb) != 0) {
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN,
+			     backend_betxn_pre_write_cb) != 0) {
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"error hooking up modrdn callback\n");
+				"error hooking up betxn pre modrdn callback\n");
 		return -1;
 	}
-	if (slapi_pblock_set(pb, delfn, backend_write_cb) != 0) {
+	if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN,
+			     backend_betxn_pre_write_cb) != 0) {
 		slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
-				"error hooking up delete callback\n");
+				"error hooking up betxn pre delete callback\n");
 		return -1;
 	}
 	/* We don't hook abandonment requests. */
@@ -1549,6 +1591,15 @@ backend_init_betxnpreop(Slapi_PBlock *pb, struct plugin_state *state)
 }
 
 int
+backend_init_betxn_postop(Slapi_PBlock *pb, struct plugin_state *state)
+{
+	slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+			"hooking up betxn postoperation callbacks\n");
+	return backend_shr_betxn_postop_init(pb, state);
+}



More information about the Pkg-freeipa-devel mailing list