From af4736ab60d560ab9f81ae7c81b4a3bf33708b33 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <abokovoy@redhat.com>
Date: Mon, 23 Jun 2014 11:18:49 +0300
Subject: [PATCH] Define TNF-compatible logging for non-TNF environments too

---
 ldap/servers/plugins/acl/acl.c       | 9 +++++++++
 ldap/servers/plugins/acl/acl.h       | 6 ++++--
 ldap/servers/plugins/acl/acl_ext.c   | 6 ++++++
 ldap/servers/plugins/acl/aclplugin.c | 9 +++++++++
 4 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c
index f8b854c..c3b4366 100644
--- a/ldap/servers/plugins/acl/acl.c
+++ b/ldap/servers/plugins/acl/acl.c
@@ -1926,6 +1926,9 @@ acl__scan_for_acis(Acl_PBlock *aclpb, int *err)
 	int				gen_allow_handle = ACI_MAX_ELEVEL+1;
 	int				gen_deny_handle = ACI_MAX_ELEVEL+1;
 	PRUint32		cookie;
+	int					loglevel;
+
+	loglevel = slapi_is_loglevel_set(SLAPI_LOG_ACL) ? SLAPI_LOG_ACL : SLAPI_LOG_ACLSUMMARY;
 	
 	TNF_PROBE_0_DEBUG(acl__scan_for_acis_start,"ACL","");
 
@@ -2090,6 +2093,9 @@ acl__resource_match_aci( Acl_PBlock *aclpb, aci_t *aci, int skip_attrEval, int *
 	char					*matched_val = NULL;	
 	int						add_matched_val_to_ht = 0;
 	char 					res_right_str[128];
+	int					loglevel;
+
+	loglevel = slapi_is_loglevel_set(SLAPI_LOG_ACL) ? SLAPI_LOG_ACL : SLAPI_LOG_ACLSUMMARY;
 
 	TNF_PROBE_0_DEBUG(acl__resource_match_aci_start,"ACL","");
 
@@ -2906,6 +2912,9 @@ acl__TestRights(Acl_PBlock *aclpb,int access, const char **right, const char **
 	const char		*testRights[2];
 	aci_t			*aci = NULL;
 	int			numHandles = 0;
+	int					loglevel;
+
+	loglevel = slapi_is_loglevel_set(SLAPI_LOG_ACL) ? SLAPI_LOG_ACL : SLAPI_LOG_ACLSUMMARY;
 	
 	TNF_PROBE_0_DEBUG(acl__TestRights_start,"ACL","");
 
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
index 86ac12f..567ddd3 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -94,8 +94,10 @@
 #ifdef SOLARIS
 	#include <tnf/probe.h>
 #else
-	#define TNF_PROBE_0_DEBUG(a,b,c)
-	#define TNF_PROBE_1_DEBUG(a,b,c,d,e,f)
+	#define tnf_string "%s"
+	#define tnf_int "%d"
+	#define TNF_PROBE_0_DEBUG(a,b,c) slapi_log_error(loglevel, plugin_name, #a b c "\n")
+	#define TNF_PROBE_1_DEBUG(a,b,c,d,e,f) slapi_log_error(loglevel, plugin_name, #a b c d #e "\n", f)
 #endif
 
 #define ACL_PLUGIN_NAME "NSACLPlugin"
diff --git a/ldap/servers/plugins/acl/acl_ext.c b/ldap/servers/plugins/acl/acl_ext.c
index 126a234..e73648a 100644
--- a/ldap/servers/plugins/acl/acl_ext.c
+++ b/ldap/servers/plugins/acl/acl_ext.c
@@ -268,6 +268,9 @@ acl_operation_ext_constructor ( void *object, void *parent )
 {
 	Acl_PBlock *aclpb = NULL;
 
+	int					loglevel;
+
+	loglevel = slapi_is_loglevel_set(SLAPI_LOG_ACL) ? SLAPI_LOG_ACL : SLAPI_LOG_ACLSUMMARY;
 	TNF_PROBE_0_DEBUG(acl_operation_ext_constructor_start ,"ACL","");
 
 	/* This means internal operations */
@@ -297,6 +300,9 @@ acl_operation_ext_destructor ( void *ext, void *object, void *parent )
 
 	struct acl_cblock	*aclcb  = NULL;
 	struct acl_pblock	*aclpb = NULL;
+	int					loglevel;
+
+	loglevel = slapi_is_loglevel_set(SLAPI_LOG_ACL) ? SLAPI_LOG_ACL : SLAPI_LOG_ACLSUMMARY;
 
 	TNF_PROBE_0_DEBUG(acl_operation_ext_destructor_start ,"ACL","");
 
diff --git a/ldap/servers/plugins/acl/aclplugin.c b/ldap/servers/plugins/acl/aclplugin.c
index c6ad719..33a8339 100644
--- a/ldap/servers/plugins/acl/aclplugin.c
+++ b/ldap/servers/plugins/acl/aclplugin.c
@@ -140,6 +140,9 @@ aclplugin_preop_search ( Slapi_PBlock *pb )
 	int			optype;
 	int			isRoot;
 	int			rc = 0;
+	int					loglevel;
+
+	loglevel = slapi_is_loglevel_set(SLAPI_LOG_ACL) ? SLAPI_LOG_ACL : SLAPI_LOG_ACLSUMMARY;
 			
 	TNF_PROBE_0_DEBUG(aclplugin_preop_search_start ,"ACL","");
 
@@ -202,6 +205,9 @@ aclplugin_preop_common( Slapi_PBlock *pb )
 	char		*errtext = NULL;
 	int			lderr;
 	Acl_PBlock	*aclpb;
+	int					loglevel;
+
+	loglevel = slapi_is_loglevel_set(SLAPI_LOG_ACL) ? SLAPI_LOG_ACL : SLAPI_LOG_ACLSUMMARY;
 
 	TNF_PROBE_0_DEBUG(aclplugin_preop_common_start ,"ACL","");
 
@@ -368,6 +374,9 @@ acl_access_allowed_main ( Slapi_PBlock *pb, Slapi_Entry *e, char **attrs,
 {
 	int	rc =0;
 	char	*attr = NULL;
+	int					loglevel;
+
+	loglevel = slapi_is_loglevel_set(SLAPI_LOG_ACL) ? SLAPI_LOG_ACL : SLAPI_LOG_ACLSUMMARY;
 
 	TNF_PROBE_0_DEBUG(acl_access_allowed_main_start,"ACL","");
 
-- 
1.9.3

