Selaa lähdekoodia

Resolves: #202843
Summary: referential integrity plugin does not stack with Class of Service appliance (Comment #11)
Changes:
1) registered cos_post_op and roles_post_op as SLAPI_PLUGIN_INTERNAL_POST_op_FN
functions.
2) changed the plugin type of CoS and Roles from "postoperation" to "object".

Noriko Hosoi 19 vuotta sitten
vanhempi
sitoutus
d0a8ec6091

+ 2 - 2
ldap/admin/src/create_instance.c

@@ -2949,7 +2949,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
     fprintf(f, "cn: Roles Plugin\n");
     fprintf(f, "nsslapd-pluginpath: %s/libroles-plugin%s\n", cf->plugin_dir, shared_lib);
     fprintf(f, "nsslapd-plugininitfunc: roles_init\n");
-     fprintf(f, "nsslapd-plugintype: postoperation\n");
+     fprintf(f, "nsslapd-plugintype: object\n");
     fprintf(f, "nsslapd-pluginenabled: on\n");
     fprintf(f, "nsslapd-plugin-depends-on-type: database\n");
     fprintf(f, "nsslapd-plugin-depends-on-named: State Change Plugin\n");
@@ -3027,7 +3027,7 @@ char *ds_gen_confs(char *sroot, server_config_s *cf, char *cs_path)
     fprintf(f, "cn: Class of Service\n");
     fprintf(f, "nsslapd-pluginpath: %s/libcos-plugin%s\n", cf->plugin_dir, shared_lib);
     fprintf(f, "nsslapd-plugininitfunc: cos_init\n");
-    fprintf(f, "nsslapd-plugintype: postoperation\n");
+    fprintf(f, "nsslapd-plugintype: object\n");
     fprintf(f, "nsslapd-pluginenabled: on\n");
     fprintf(f, "nsslapd-plugin-depends-on-type: database\n");
     fprintf(f, "nsslapd-plugin-depends-on-named: State Change Plugin\n");

+ 76 - 24
ldap/servers/plugins/cos/cos.c

@@ -168,6 +168,52 @@ int cos_version()
 	return COS_VERSION;
 }
 
+int
+cos_postop_init ( Slapi_PBlock *pb )
+{
+	int rc = 0;
+
+	if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, 
+							SLAPI_PLUGIN_VERSION_01 ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
+							(void *)cos_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
+							(void *)cos_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
+							(void *) cos_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
+							(void *) cos_post_op ) != 0 )
+	{
+		slapi_log_error( SLAPI_LOG_FATAL, COS_PLUGIN_SUBSYSTEM,
+						 "cos_postop_init: failed to register plugin\n" );
+		rc = -1;
+	}
+	return rc;
+}
+
+int
+cos_internalpostop_init ( Slapi_PBlock *pb )
+{
+	int rc = 0;
+
+	if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, 
+							SLAPI_PLUGIN_VERSION_01 ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN,
+							(void *)cos_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN,
+							(void *)cos_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN,
+							(void *) cos_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN,
+							(void *) cos_post_op ) != 0 )
+	{
+		slapi_log_error( SLAPI_LOG_FATAL, COS_PLUGIN_SUBSYSTEM,
+					"cos_internalpostop_init: failed to register plugin\n" );
+		rc = -1;
+	}
+	return rc;
+}
+
 /* 
 	cos_init
 	--------
@@ -185,37 +231,43 @@ int cos_init( Slapi_PBlock *pb )
 	** Used for internal operations
 	*/
 	
-    	slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
-    	PR_ASSERT (plugin_identity);
+	slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
+	PR_ASSERT (plugin_identity);
 	cos_set_plugin_identity(plugin_identity);
 	
-	if (	slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
-	    			SLAPI_PLUGIN_VERSION_01 ) != 0 ||
-	        slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN,
-        	         (void *) cos_start ) != 0 ||
-	        slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
-        	         (void *) cos_post_op ) != 0 ||
-	        slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
-        	         (void *) cos_post_op ) != 0 ||
-	        slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
-        	         (void *) cos_post_op ) != 0 ||
-	        slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
-        	         (void *) cos_post_op ) != 0 ||
-	        slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN,
-        	         (void *) cos_close ) != 0 ||
-			slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
-                     (void *)&pdesc ) != 0 )
-    {
-        slapi_log_error( SLAPI_LOG_FATAL, COS_PLUGIN_SUBSYSTEM,
-                         "cos_init: failed to register plugin\n" );
+	if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
+							SLAPI_PLUGIN_VERSION_01 ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN,
+							(void *) cos_start ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN,
+							(void *) cos_close ) != 0 ||
+		 slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
+							(void *)&pdesc ) != 0 )
+	{
+		slapi_log_error( SLAPI_LOG_FATAL, COS_PLUGIN_SUBSYSTEM,
+						 "cos_init: failed to register plugin\n" );
 		ret = -1;
-    }
+		goto bailout;
+	}
+
+	ret = slapi_register_plugin("postoperation", 1 /* Enabled */,
+					"cos_postop_init", cos_postop_init,
+					"Class of Service postoperation plugin", NULL,
+					plugin_identity);
+	if ( ret < 0 ) {
+		goto bailout;
+	}
+
+	ret = slapi_register_plugin("internalpostoperation", 1 /* Enabled */,
+					"cos_internalpostop_init", cos_internalpostop_init,
+					"Class of Service internalpostoperation plugin", NULL,
+					plugin_identity);
 
+bailout:
 	LDAPDebug( LDAP_DEBUG_TRACE, "<-- cos_init\n",0,0,0);
-    return ret;
+	return ret;
 }
 
-
 /*
 	cos_start
 	---------

+ 71 - 19
ldap/servers/plugins/roles/roles_plugin.c

@@ -83,6 +83,52 @@ static int roles_post_op( Slapi_PBlock *pb );
 static int roles_close( Slapi_PBlock *pb );
 static void roles_set_plugin_identity(void * identity);
 
+int
+roles_postop_init ( Slapi_PBlock *pb )
+{
+	int rc = 0;
+
+	if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, 
+							SLAPI_PLUGIN_VERSION_01 ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
+							(void *)roles_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
+							(void *)roles_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
+							(void *) roles_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
+							(void *) roles_post_op ) != 0 )
+	{
+		slapi_log_error( SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
+						 "roles_postop_init: failed to register plugin\n" );
+		rc = -1;
+	}
+	return rc;
+}
+
+int
+roles_internalpostop_init ( Slapi_PBlock *pb )
+{
+	int rc = 0;
+
+	if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, 
+							SLAPI_PLUGIN_VERSION_01 ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN,
+							(void *)roles_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN,
+							(void *)roles_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN,
+							(void *) roles_post_op ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN,
+							(void *) roles_post_op ) != 0 )
+	{
+		slapi_log_error( SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
+					"roles_internalpostop_init: failed to register plugin\n" );
+		rc = -1;
+	}
+	return rc;
+}
+
 /* roles_init
    ----------
    Initialization of the plugin
@@ -93,36 +139,42 @@ int roles_init( Slapi_PBlock *pb )
 	void *plugin_identity = NULL; 
 
 	slapi_log_error( SLAPI_LOG_PLUGIN, ROLES_PLUGIN_SUBSYSTEM,
-			"=> roles_init\n" );
+						"=> roles_init\n" );
 
 	slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &plugin_identity);
 	PR_ASSERT (plugin_identity);
 	roles_set_plugin_identity(plugin_identity);
 
-    if (    slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
-					(void *)SLAPI_PLUGIN_VERSION_01 ) != 0 ||
-			slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
-					(void *)&pdesc ) != 0 || 
-			slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN,
-					(void *)roles_start ) != 0 ||
-            slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
-                     (void *) roles_post_op ) != 0 ||
-            slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
-                     (void *) roles_post_op ) != 0 ||
-            slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
-                     (void *) roles_post_op ) != 0 ||
-            slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
-                     (void *) roles_post_op ) != 0 ||
-            slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN,
-                     (void *) roles_close ) != 0 )
+	if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
+							(void *)SLAPI_PLUGIN_VERSION_01 ) != 0 ||
+		 slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
+							(void *)&pdesc ) != 0 || 
+		 slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN,
+							(void *)roles_start ) != 0 ||
+		 slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN,
+							(void *) roles_close ) != 0 )
 	{
 		slapi_log_error( SLAPI_LOG_FATAL, ROLES_PLUGIN_SUBSYSTEM,
 					"roles_init failed\n" );
 		rc = -1;
-    }
+		goto bailout;
+	}
+
+	rc = slapi_register_plugin("postoperation", 1 /* Enabled */,
+					"roles_postop_init", roles_postop_init,
+					"Roles postoperation plugin", NULL,
+					plugin_identity);
+	if ( rc < 0 ) {
+		goto bailout;
+	}
 
+	rc = slapi_register_plugin("internalpostoperation", 1 /* Enabled */,
+					"roles_internalpostop_init", roles_internalpostop_init,
+					"Roles internalpostoperation plugin", NULL,
+					plugin_identity);
+bailout:
 	slapi_log_error( SLAPI_LOG_PLUGIN, ROLES_PLUGIN_SUBSYSTEM,
-			"<= roles_init %d\n", rc );
+							"<= roles_init %d\n", rc );
 	return rc;
 }