[Freeipa-devel] [PATCH] Fix a couple of problems in C code

Jakub Hrozek jhrozek at redhat.com
Mon Nov 22 18:00:52 UTC 2010


On Mon, Nov 22, 2010 at 11:55:21AM -0500, Simo Sorce wrote:
> On Thu, 18 Nov 2010 15:16:49 +0100
> Jakub Hrozek <jhrozek at redhat.com> wrote:
> 
> > On Mon, Nov 08, 2010 at 10:14:18PM +0100, Jakub Hrozek wrote:
> > > [PATCH 1/6] Common include file for SLAPI plugin logging
> > > Consolidate the common logging macros into common/util.h and use
> > > them in SLAPI plugins instead of calling slapi_log_error() directly.
> > > 
> > > https://fedorahosted.org/freeipa/ticket/408
> 
> NACK, reintroduces a define of a function that was private to 389ds
> that we stoppped using.
> Everything else look fine
> 

Fixed.

> > > [PATCH 2/6] Stricter compilation flags
> > > Use a little stricter compilation flags, in particular -Wall and
> > > treat implicit function declarations as errors.
> 
> ACK
> 
> > > [PATCH 3/6] Use internal implementation of internal Kerberos
> > > functions Don't use KRB5_PRIVATE.
> > > 
> > > The patch implements and uses the following krb5 functions that are
> > > otherwise private in recent MIT Kerberos releases:
> > >  * krb5_principal2salt_norealm
> > >  * krb5_free_ktypes
> 
> NACK, i we re-implement functions we should use our own namespace or we
> risk conflicts with the real functions in the library.
> 

Thanks, fixed. Also changed pointer initialization from ptr=0 (which
libkrb5 uses) to ptr=NULL as discussed on IRC.

> > > [PATCH 4/6] Don't use deprecated ldap_bind_s
> > > ldap_bind_s is marked as deprecated in new libldap releases.
> 
> ACK
>  
> > > [PATCH 5/6] Silence compilation warnings in SLAPI plugins
> > > The most important part of the patch is exporting hexbuf() in
> > > ipapwd.h Also uses strcasecmp() instead of PL_strcasecmp() since we
> > > were not including nspr headers and linking against it - I hope
> > > this is OK, we can revert if we need to be portable to platforms
> > > with no strcasecmp(). The rest are cosmetic fixes.
> 
> It seems to me that hexbuf() is used only in ipapwd_encoding.c, what
> about moving it there and making it static instead ?

It was already in ipapwd_util.c and seemed like it could be potentially useful
elsewhere in ipapwd. But moving it is OK, too.

> 
> Adding the header would make less changes than replacing PL_strcasecmp
> everywhere. Any reason why replacing is easier than just adding the
> proper header ?
> 

Initially, I was thinking that by not using any nspr functions we could lose
a dependency, but given the tight coupling between 389-ds, nss and nspr,
this is not realistic. So I reverted the PL_str* calls and added a
#include directive instead.

> > > [PATCH 6/6] ipa-client code cleanup
> > > Fixes errors about implicit function declaration and moves
> > > duplicated gettext code into a common module. Also silences some
> > > warnings.
> 
> ACK
> 
> > > Patches 3 - 6 fix https://fedorahosted.org/freeipa/ticket/454
> > 
> > Attached are patches rebased on top of current master, esp. the UUID
> > patch.
> 
> Only needs minor changes, mostly a very good set, thanks!
> 
> Simo.
> 

Thanks for the review! New patches are attached.

If you're going to use interdiff or something similar, please note that
these patches were generated with different flags passed to git
format-patch, as suggested on IRC.
-------------- next part --------------
>From 4c34f472d847dcd5382a41a363bb92fa98682268 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 3 Nov 2010 14:44:44 +0100
Subject: [PATCH 1/6] Common include file for SLAPI plugin logging

Consolidate the common logging macros into common/util.h and use them
in SLAPI plugins instead of calling slapi_log_error() directly.

https://fedorahosted.org/freeipa/ticket/408
---
 daemons/ipa-slapi-plugins/common/util.h            |   40 +++
 .../ipa-slapi-plugins/ipa-enrollment/Makefile.am   |    3 +
 .../ipa-enrollment/ipa_enrollment.c                |   78 ++---
 daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am   |    3 +
 daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c  |   41 +--
 .../ipa-slapi-plugins/ipa-pwd-extop/Makefile.am    |    3 +
 .../ipa-pwd-extop/ipa_pwd_extop.c                  |    1 +
 daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h   |   21 +--
 .../ipa-pwd-extop/ipapwd_common.c                  |    1 +
 .../ipa-pwd-extop/ipapwd_encoding.c                |    1 +
 .../ipa-pwd-extop/ipapwd_prepost.c                 |    1 +
 daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am     |    3 +
 daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c      |   85 ++---
 daemons/ipa-slapi-plugins/ipa-version/Makefile.am  |    3 +
 .../ipa-version/ipa_repl_version.c                 |   51 ++--
 daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am  |    3 +
 .../ipa-winsync/ipa-winsync-config.c               |   90 +++---
 .../ipa-slapi-plugins/ipa-winsync/ipa-winsync.c    |  350 ++++++++------------
 .../ipa-slapi-plugins/ipa-winsync/ipa-winsync.h    |    4 +-
 19 files changed, 333 insertions(+), 449 deletions(-)
 create mode 100644 daemons/ipa-slapi-plugins/common/util.h

diff --git a/daemons/ipa-slapi-plugins/common/util.h b/daemons/ipa-slapi-plugins/common/util.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a7d51870b1483b183da9654c4cc2c35118002fb
--- /dev/null
+++ b/daemons/ipa-slapi-plugins/common/util.h
@@ -0,0 +1,40 @@
+#ifndef _SLAPI_PLUGINS_UTIL_H
+#define _SLAPI_PLUGINS_UTIL_H
+
+#define EOK 0
+#define EFAIL -1
+
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#endif
+
+#define log_func discard_const(__func__)
+
+#define LOG_PLUGIN_NAME(NAME, fmt, ...) \
+    slapi_log_error(SLAPI_LOG_PLUGIN, \
+                    NAME, \
+                    fmt, ##__VA_ARGS__)
+
+#define LOG(fmt, ...) \
+    LOG_PLUGIN_NAME(IPA_PLUGIN_NAME, fmt, ##__VA_ARGS__)
+
+#define LOG_CONFIG_NAME(NAME, fmt, ...) \
+    slapi_log_error(SLAPI_LOG_CONFIG, \
+                    NAME, \
+                    fmt, ##__VA_ARGS__)
+
+#define LOG_CONFIG(fmt, ...) \
+    LOG_CONFIG_NAME(IPA_PLUGIN_NAME, fmt, ##__VA_ARGS__)
+
+#define LOG_FATAL(fmt, ...) \
+    slapi_log_error(SLAPI_LOG_FATAL, log_func, \
+                    "[file %s, line %d]: " fmt, \
+                    __FILE__, __LINE__, ##__VA_ARGS__)
+
+#define LOG_TRACE(fmt, ...) \
+    slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)
+
+#define LOG_OOM() LOG_FATAL("Out of Memory!\n")
+
+#endif /* _SLAPI_PLUGINS_UTIL_H */
+
diff --git a/daemons/ipa-slapi-plugins/ipa-enrollment/Makefile.am b/daemons/ipa-slapi-plugins/ipa-enrollment/Makefile.am
index 8a4ba09c7e8658b2132d6722fe929a71a6f0fdf1..fc3c55cca95c3aba0abf20a6f4c4e63ba80a5c4e 100644
--- a/daemons/ipa-slapi-plugins/ipa-enrollment/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-enrollment/Makefile.am
@@ -1,8 +1,11 @@
 NULL =
 
+PLUGIN_COMMON_DIR=../common
+
 INCLUDES =							\
 	-I.							\
 	-I$(srcdir)						\
+	-I$(PLUGIN_COMMON_DIR)					\
 	-DPREFIX=\""$(prefix)"\" 				\
 	-DBINDIR=\""$(bindir)"\"				\
 	-DLIBDIR=\""$(libdir)"\" 				\
diff --git a/daemons/ipa-slapi-plugins/ipa-enrollment/ipa_enrollment.c b/daemons/ipa-slapi-plugins/ipa-enrollment/ipa_enrollment.c
index 8a9906aab5fabd5643fc6a03e9b48b2c5a26216f..bc5551eda29d11c2f4e75a1e1ef8cf4130b8f955 100644
--- a/daemons/ipa-slapi-plugins/ipa-enrollment/ipa_enrollment.c
+++ b/daemons/ipa-slapi-plugins/ipa-enrollment/ipa_enrollment.c
@@ -49,11 +49,15 @@
 #include <dirsrv/slapi-plugin.h>
 #include <krb5.h>
 
+#include "util.h"
+
+#define IPA_PLUGIN_NAME "ipa-enrollment"
+
 /* OID of the extended operation handled by this plug-in */
 #define JOIN_OID    "2.16.840.1.113730.3.8.3.53"
 
 Slapi_PluginDesc pdesc = {
-    "ipa-enrollment",
+    IPA_PLUGIN_NAME,
     "IPA Project",
     "IPA/2.0",
     "IPA Enrollment Extended Operation plugin"
@@ -80,21 +84,19 @@ ipaenrollement_secure(Slapi_PBlock *pb, char **errMesg)
     int sasl_ssf, is_ssl;
     int rc = LDAP_SUCCESS;
 
-    slapi_log_error(SLAPI_LOG_TRACE, "ipa_enrollment", "=> ipaenrollment_secure\n");
+    LOG_TRACE("=> ipaenrollment_secure\n");
 
     /* Allow enrollment only for SSL/TLS established connections and
      * connections using SASL privacy layers */
     if (slapi_pblock_get(pb, SLAPI_CONN_SASL_SSF, &sasl_ssf) != 0) {
-        slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
-                        "Could not get SASL SSF from connection\n");
+        LOG_TRACE("Could not get SASL SSF from connection\n");
         *errMesg = "Operation requires a secure connection.\n";
         rc = LDAP_OPERATIONS_ERROR;
         goto done;
     }
 
     if (slapi_pblock_get(pb, SLAPI_CONN_IS_SSL_SESSION, &is_ssl) != 0) {
-        slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
-                        "Could not get IS SSL from connection\n");
+        LOG_TRACE("Could not get IS SSL from connection\n");
         *errMesg = "Operation requires a secure connection.\n";
         rc = LDAP_OPERATIONS_ERROR;
         goto done;
@@ -107,7 +109,7 @@ ipaenrollement_secure(Slapi_PBlock *pb, char **errMesg)
     }
 
 done:
-    slapi_log_error(SLAPI_LOG_TRACE, "ipa_enrollment", "<= ipaenrollment_secure\n");
+    LOG_TRACE("<= ipaenrollment_secure\n");
     return rc;
 
 }
@@ -175,9 +177,7 @@ ipa_join(Slapi_PBlock *pb)
     ret = slapi_search_internal_pb(pbte);
     slapi_pblock_get(pbte, SLAPI_PLUGIN_INTOP_RESULT, &res);
     if (ret == -1 || res != LDAP_SUCCESS) {
-        slapi_log_error(SLAPI_LOG_TRACE, "ipaenrollment_extop",
-                "Search for host failed, err (%d)\n",
-                res?res:ret);
+        LOG_TRACE("Search for host failed, err (%d)\n", res?res:ret);
         errMesg = "Host not found.\n";
         rc = LDAP_NO_SUCH_OBJECT;
         goto free_and_return;
@@ -186,7 +186,7 @@ ipa_join(Slapi_PBlock *pb)
     /* get entries */
     slapi_pblock_get(pbte, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &es);
     if (!es) {
-        slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "No entries ?!");
+        LOG_TRACE("No entries ?!");
         errMesg = "Host not found.\n";
         rc = LDAP_NO_SUCH_OBJECT;
         goto free_and_return;
@@ -197,8 +197,7 @@ ipa_join(Slapi_PBlock *pb)
 
     /* if there is none or more than one, freak out */
     if (i != 1) {
-        slapi_log_error(SLAPI_LOG_TRACE, "ipaenrollment_extop",
-                "Too many entries, or entry no found (%d)", i);
+        LOG_TRACE("Too many entries, or entry no found (%d)", i);
         errMesg = "Host not found.\n";
         rc = LDAP_NO_SUCH_OBJECT;
         goto free_and_return;
@@ -208,8 +207,7 @@ ipa_join(Slapi_PBlock *pb)
     /* Is this host already enrolled? */
     krbLastPwdChange = slapi_entry_attr_get_charptr(targetEntry, "krbLastPwdChange");
     if (NULL != krbLastPwdChange) {
-        slapi_log_error(SLAPI_LOG_TRACE, "ipaenrollment_extop",
-                "Host already enrolled");
+        LOG_TRACE("Host already enrolled");
         errMesg = "Host already enrolled.\n";
         rc = LDAP_OPERATIONS_ERROR;
         goto free_and_return;
@@ -266,19 +264,16 @@ ipa_join(Slapi_PBlock *pb)
 
     rc = slapi_modify_internal_pb (pbtm);
     if (rc) {
-        slapi_log_error(SLAPI_LOG_TRACE, "ipaenrollment_extop",
-            "WARNING: modify error %d on entry '%s'\n",
-            rc, slapi_entry_get_dn_const(targetEntry));
+        LOG_TRACE("WARNING: modify error %d on entry '%s'\n",
+                  rc, slapi_entry_get_dn_const(targetEntry));
     } else {
         slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
 
         if (rc != LDAP_SUCCESS){
-            slapi_log_error(SLAPI_LOG_TRACE, "ipaenrollment_extop",
-                "WARNING: modify error %d on entry '%s'\n",
-                rc, slapi_entry_get_dn_const(targetEntry));
+            LOG_TRACE("WARNING: modify error %d on entry '%s'\n",
+                      rc, slapi_entry_get_dn_const(targetEntry));
         } else {
-            slapi_log_error(SLAPI_LOG_TRACE, "ipaenrollment_extop",
-                "<= apply mods: Successful\n");
+            LOG_TRACE("<= apply mods: Successful\n");
         }
     }
 
@@ -291,8 +286,7 @@ done:
     if (!ret) ret = slapi_pblock_set(pb, SLAPI_EXT_OP_RET_VALUE, &retbval);
     if (ret) {
         errMesg = "Could not set return values";
-        slapi_log_error(SLAPI_LOG_PLUGIN, "ipaenrollmenti_extop", "%s\n",
-                    errMesg);
+        LOG("%s\n", errMesg);
         rc = SLAPI_PLUGIN_EXTENDED_SENT_RESULT;
     }
 
@@ -309,7 +303,7 @@ free_and_return:
 
     if (krbLastPwdChange) slapi_ch_free_string(&krbLastPwdChange);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, "ipaenrollment_extop", errMesg ? errMesg : "success\n");
+    LOG(errMesg ? errMesg : "success\n");
     slapi_send_ldap_result(pb, rc, NULL, errMesg, 0, NULL);
 
     free(principal);
@@ -325,7 +319,7 @@ ipaenrollment_extop(Slapi_PBlock *pb)
     char *errMesg = NULL;
     int rc, ret;
 
-    slapi_log_error(SLAPI_LOG_TRACE, "ipa_enrollment", "=> ipaenrollment_extop\n");
+    LOG_TRACE("=> ipaenrollment_extop\n");
 
     rc = ipaenrollement_secure(pb, &errMesg);
     if (rc) {
@@ -336,7 +330,7 @@ ipaenrollment_extop(Slapi_PBlock *pb)
     if (slapi_pblock_get(pb, SLAPI_EXT_OP_REQ_OID, &oid ) != 0) {
         errMesg = "Could not get OID and value from request.\n";
         rc = LDAP_OPERATIONS_ERROR;
-        slapi_log_error(SLAPI_LOG_PLUGIN, "ipa_pwd_extop", errMesg);
+        LOG(errMesg);
         goto free_and_return;
     }
 
@@ -349,7 +343,7 @@ ipaenrollment_extop(Slapi_PBlock *pb)
     rc = LDAP_OPERATIONS_ERROR;
 
 free_and_return:
-    slapi_log_error(SLAPI_LOG_PLUGIN, "ipa_enrollment", errMesg);
+    LOG(errMesg);
     slapi_send_ldap_result(pb, rc, NULL, errMesg, 0, NULL);
 
     return SLAPI_PLUGIN_EXTENDED_SENT_RESULT;
@@ -369,35 +363,32 @@ ipaenrollment_start(Slapi_PBlock *pb)
 
     krberr = krb5_init_context(&krbctx);
     if (krberr) {
-        slapi_log_error(SLAPI_LOG_FATAL, "ipaenrollment_init",
-                        "krb5_init_context failed\n");
+        LOG_FATAL("krb5_init_context failed\n");
         return LDAP_OPERATIONS_ERROR;
     }
 
     ret = krb5_get_default_realm(krbctx, &realm);
     if (ret) {
-        slapi_log_error(SLAPI_LOG_FATAL, "ipaenrollment_init",
-                        "Failed to get default realm?!\n");
+        LOG_FATAL("Failed to get default realm?!\n");
         ret = LDAP_OPERATIONS_ERROR;
     }
 
     if (slapi_pblock_get(pb, SLAPI_TARGET_DN, &config_dn) != 0) {
-        slapi_log_error( SLAPI_LOG_FATAL, "ipaenrollment_start", "No config DN?\n");
+        LOG_FATAL("No config DN?\n");
         ret = LDAP_OPERATIONS_ERROR;
         goto done;
     }
     sdn = slapi_sdn_new_dn_byref(config_dn);
     if ((rc = slapi_search_internal_get_entry(sdn, NULL, &config_entry,
                                 ipaenrollment_plugin_id)) != LDAP_SUCCESS ){
-        slapi_log_error(SLAPI_LOG_TRACE, "ipaenrollment_extop",
-                        "ipaenrollment_start: No such entry-(%s), err (%d)\n",
-                        config_dn, rc);
+        LOG_TRACE("ipaenrollment_start: No such entry-(%s), err (%d)\n",
+                  config_dn, rc);
     }
     slapi_sdn_free(&sdn);
 
     partition_dn = slapi_entry_attr_get_charptr(config_entry, "nsslapd-realmtree");
     if (!partition_dn) {
-        slapi_log_error( SLAPI_LOG_FATAL, "ipapwd_start", "Missing partition configuration entry (nsslapd-realmTree)!\n");
+        LOG_FATAL("Missing partition configuration entry (nsslapd-realmTree)!\n");
         ret = LDAP_OPERATIONS_ERROR;
         goto done;
     }
@@ -405,7 +396,7 @@ ipaenrollment_start(Slapi_PBlock *pb)
     ipa_realm_dn = slapi_ch_smprintf("cn=computers,cn=accounts,%s", partition_dn);
     slapi_ch_free_string(&partition_dn);
     if (!ipa_realm_dn) {
-        slapi_log_error( SLAPI_LOG_FATAL, "ipapwd_start", "Out of memory ?\n");
+        LOG_FATAL("Out of memory ?\n");
         ret = LDAP_OPERATIONS_ERROR;
         goto done;
     }
@@ -430,13 +421,11 @@ ipaenrollment_init(Slapi_PBlock *pb)
 
     ret = slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &ipaenrollment_plugin_id);
     if ((ret != 0) || (NULL == ipaenrollment_plugin_id)) {
-        slapi_log_error(SLAPI_LOG_PLUGIN,
-            "ipaenrollment_init", "Could not get identity or identity was NULL\n");
+        LOG("Could not get identity or identity was NULL\n");
         return -1;
     }
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, "ipaenrollment_init",
-        "Registering plug-in for extended op.\n");
+    LOG("Registering plug-in for extended op.\n");
 
     /* Register the plug-in function as an extended operation
        plug-in function. */
@@ -448,8 +437,7 @@ ipaenrollment_init(Slapi_PBlock *pb)
     if (!ret) slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)ipaenrollment_extop);
 
     if (ret) {
-        slapi_log_error(SLAPI_LOG_PLUGIN, "ipaenrollment_init",
-            "Failed to set plug-in version, function, and OID.\n");
+        LOG("Failed to set plug-in version, function, and OID.\n");
         return -1;
     }
 
diff --git a/daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am b/daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am
index 57706246416c5bb309cf0403fe499f32536f5058..3b0ff629730e49244433dd85f9ca6fdb6211d838 100644
--- a/daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am
@@ -1,8 +1,11 @@
 NULL =
 
+PLUGIN_COMMON_DIR=../common
+
 INCLUDES =							\
 	-I.							\
 	-I$(srcdir)						\
+	-I$(PLUGIN_COMMON_DIR)					\
 	-I/usr/include/dirsrv					\
 	-DPREFIX=\""$(prefix)"\" 				\
 	-DBINDIR=\""$(bindir)"\"				\
diff --git a/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c b/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
index 72e16e90c2f41f3601ece714bbcf781538a163f4..1e094f1d0eebb258bd9cd72450eefb09294f8598 100644
--- a/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
+++ b/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
@@ -44,40 +44,13 @@
 #include "nspr.h"
 #include "prclist.h"
 
-#define IPAMODRDN_PLUGIN_NAME "ipa-modrdn-plugin"
+#include "util.h"
+
+#define IPA_PLUGIN_NAME "ipa-modrdn-plugin"
 #define IPAMODRDN_PLUGIN_VERSION 0x00010000
 
 #define IPAMODRDN_DN "cn=IPA MODRDN,cn=plugins,cn=config" /* temporary */
 
-#define EOK 0
-#define EFAIL -1
-
-#ifndef discard_const
-#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
-#endif
-
-#define log_func discard_const(__func__)
-
-#define LOG(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_PLUGIN, \
-                    IPAMODRDN_PLUGIN_NAME, \
-                    fmt, ##__VA_ARGS__)
-
-#define LOG_CONFIG(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_CONFIG, \
-                    IPAMODRDN_PLUGIN_NAME, \
-                    fmt, ##__VA_ARGS__)
-
-#define LOG_FATAL(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_FATAL, log_func, \
-                    "[file %s, line %d]: " fmt, \
-                    __FILE__, __LINE__, ##__VA_ARGS__)
-
-#define LOG_TRACE(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)
-
-#define LOG_OOM() LOG_FATAL("Out of Memory!\n")
-
 /**
  * IPA MODRDN config types
  */
@@ -701,7 +674,7 @@ ipamodrdn_change_attr(struct configEntry *cfgentry,
     mods[0] = &mod;
     mods[1] = 0;
 
-    LOG("Setting %s to %s in entry (%s)\n", cfgentry->tattr, targetdn);
+    LOG("Setting %s to %s in entry (%s)\n", cfgentry->tattr, value, targetdn);
 
     /* Perform the modify operation. */
     slapi_modify_internal_set_pb(mod_pb, targetdn, mods,
@@ -785,12 +758,12 @@ static int ipamodrdn_post_op(Slapi_PBlock *pb)
             }
 
             if (slapi_entry_attr_find(e, cfgentry->sattr, &sattr) != 0) {
-                LOG_TRACE("Source attr %s not found for %d\n",
+                LOG_TRACE("Source attr %s not found for %s\n",
                           cfgentry->sattr, dn);
                 continue;
             }
             if (slapi_entry_attr_find(e, cfgentry->tattr, &tattr) != 0) {
-                LOG_TRACE("Target attr %s not found for %d\n",
+                LOG_TRACE("Target attr %s not found for %s\n",
                           cfgentry->tattr, dn);
             } else {
                 Slapi_Value *val;
@@ -805,7 +778,7 @@ static int ipamodrdn_post_op(Slapi_PBlock *pb)
 
                 ret = ipamodrdn_change_attr(cfgentry, dn, strval);
                 if (ret != EOK) {
-                    LOG_FATAL("Failed to set target attr %s for %d\n",
+                    LOG_FATAL("Failed to set target attr %s for %s\n",
                               cfgentry->tattr, dn);
                 }
             }
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
index 6358eceb2db8d576a6efbfa7ffc7dd32b3060bc7..3577e48cc050a5d96987886b466f3b1ead71a646 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
@@ -1,8 +1,11 @@
 NULL =
 
+PLUGIN_COMMON_DIR=../common
+
 INCLUDES =							\
 	-I.							\
 	-I$(srcdir)						\
+	-I$(PLUGIN_COMMON_DIR)					\
 	-DPREFIX=\""$(prefix)"\" 				\
 	-DBINDIR=\""$(bindir)"\"				\
 	-DLIBDIR=\""$(libdir)"\" 				\
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
index ed9637a00d2ced89b619076b3ce29d48d9d0398c..8df766e03b0613805f6bba1cb5b4ca24dc94b471 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
@@ -38,6 +38,7 @@
  * END COPYRIGHT BLOCK **/
 
 #include "ipapwd.h"
+#include "util.h"
 
 /*
  * Password Modify - LDAP Extended Operation.
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
index 5b15622fa999dfa48c79442794dc488fdaa273d9..523934ccdc46217b92b64b0f9ee57ef044b21a7c 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
@@ -64,26 +64,7 @@
 #define IPAPWD_FEATURE_DESC  "IPA Password Manager"
 #define IPAPWD_PLUGIN_DESC   "IPA Password Extended Operation plugin"
 
-#ifndef discard_const
-#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
-#endif
-
-#define log_func discard_const(__func__)
-
-#define LOG(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_PLUGIN, \
-                    IPAPWD_PLUGIN_NAME, \
-                    fmt, ##__VA_ARGS__)
-
-#define LOG_FATAL(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_FATAL, log_func, \
-                    "[file %s, line %d]: " fmt, \
-                    __FILE__, __LINE__, ##__VA_ARGS__)
-
-#define LOG_TRACE(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)
-
-#define LOG_OOM() LOG_FATAL("Out of Memory!\n")
+#define IPA_PLUGIN_NAME IPAPWD_PLUGIN_NAME
 
 #define IPAPWD_CHECK_CONN_SECURE    0x00000001
 #define IPAPWD_CHECK_DN             0x00000002
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c
index 514274e77308d4f8a850b5b1b71502517695e090..92c388a259c1caaa80779bbf005063b0fe1b48e0 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c
@@ -38,6 +38,7 @@
  * END COPYRIGHT BLOCK **/
 
 #include "ipapwd.h"
+#include "util.h"
 
 /* Type of connection for this operation;*/
 #define LDAP_EXTOP_PASSMOD_CONN_SECURE
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
index 527e178fe01b9f775fb0522f81eeedfcbde0ee50..451350163fe820d5a9ed6ff2494461ece3e7e1d8 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
@@ -53,6 +53,7 @@
 #include <time.h>
 
 #include "ipapwd.h"
+#include "util.h"
 
 /* krbTicketFlags */
 #define KTF_DISALLOW_POSTDATED        0x00000001
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c
index 6636d611a2facca5ead4d5d474f1494ea9675e41..44b280bfd61f685ccf0a2e720648bc5b0e7d7372 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c
@@ -53,6 +53,7 @@
 #include <time.h>
 
 #include "ipapwd.h"
+#include "util.h"
 
 #define IPAPWD_OP_NULL 0
 #define IPAPWD_OP_ADD 1
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am b/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
index 167a196314bd4e7fa0b23827730c5dfed570c67f..1e5d9793779a43c0d23f34ae1dc69824af1a1c9e 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
@@ -1,8 +1,11 @@
 NULL =
 
+PLUGIN_COMMON_DIR=../common
+
 INCLUDES =							\
 	-I.							\
 	-I$(srcdir)						\
+	-I$(PLUGIN_COMMON_DIR)					\
 	-I/usr/include/dirsrv					\
 	-DPREFIX=\""$(prefix)"\" 				\
 	-DBINDIR=\""$(bindir)"\"				\
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
index 919abc821e290b74623deb7121f71d46118f71a5..1f6e5d30a53b35a21506b6fc1fc8aacf42827484 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
@@ -45,41 +45,16 @@
 #include "prclist.h"
 #include "uuid/uuid.h"
 
+#include "util.h"
+
+#define IPAUUID_STR_SIZE 36
+
 #define IPAUUID_PLUGIN_NAME "ipa-uuid-plugin"
 #define IPAUUID_PLUGIN_VERSION 0x00010000
 
 #define IPAUUID_DN "cn=IPA UUID,cn=plugins,cn=config" /* temporary */
 
-#define IPAUUID_SUCCESS 0
-#define IPAUUID_FAILURE -1
-
-#define IPAUUID_STR_SIZE 36
-
-#ifndef discard_const
-#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
-#endif
-
-#define log_func discard_const(__func__)
-
-#define LOG(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_PLUGIN, \
-                    IPAUUID_PLUGIN_NAME, \
-                    fmt, ##__VA_ARGS__)
-
-#define LOG_CONFIG(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_CONFIG, \
-                    IPAUUID_PLUGIN_NAME, \
-                    fmt, ##__VA_ARGS__)
-
-#define LOG_FATAL(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_FATAL, log_func, \
-                    "[file %s, line %d]: " fmt, \
-                    __FILE__, __LINE__, ##__VA_ARGS__)
-
-#define LOG_TRACE(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)
-
-#define LOG_OOM() LOG_FATAL("Out of Memory!\n")
+#define IPA_PLUGIN_NAME IPAUUID_PLUGIN_NAME
 
 /**
  * IPA UUID config types
@@ -235,7 +210,7 @@ char *getPluginDN()
 int
 ipauuid_init(Slapi_PBlock *pb)
 {
-    int status = IPAUUID_SUCCESS;
+    int status = EOK;
     char *plugin_identity = NULL;
 
     LOG_TRACE("--in-->\n");
@@ -281,7 +256,7 @@ ipauuid_init(Slapi_PBlock *pb)
         )
         ) {
         LOG_FATAL("failed to register plugin\n");
-        status = IPAUUID_FAILURE;
+        status = EFAIL;
     }
 
     LOG_TRACE("<--out--\n");
@@ -291,7 +266,7 @@ ipauuid_init(Slapi_PBlock *pb)
 static int
 ipauuid_internal_preop_init(Slapi_PBlock *pb)
 {
-    int status = IPAUUID_SUCCESS;
+    int status = EOK;
 
     if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
                          SLAPI_PLUGIN_VERSION_01) != 0 ||
@@ -301,7 +276,7 @@ ipauuid_internal_preop_init(Slapi_PBlock *pb)
                          (void *) ipauuid_mod_pre_op) != 0 ||
         slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN,
                          (void *) ipauuid_add_pre_op) != 0) {
-        status = IPAUUID_FAILURE;
+        status = EFAIL;
     }
  
     return status;
@@ -310,7 +285,7 @@ ipauuid_internal_preop_init(Slapi_PBlock *pb)
 static int
 ipauuid_postop_init(Slapi_PBlock *pb)
 {
-    int status = IPAUUID_SUCCESS;
+    int status = EOK;
 
     if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION,
                          SLAPI_PLUGIN_VERSION_01) != 0 ||
@@ -325,7 +300,7 @@ ipauuid_postop_init(Slapi_PBlock *pb)
         slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
                          (void *) ipauuid_config_check_post_op) != 0) {
         LOG_FATAL("failed to register plugin\n");
-        status = IPAUUID_FAILURE;
+        status = EFAIL;
     }
 
     return status;
@@ -355,7 +330,7 @@ ipauuid_start(Slapi_PBlock * pb)
     if (!g_ipauuid_cache_lock) {
         LOG_FATAL("lock creation failed\n");
 
-        return IPAUUID_FAILURE;
+        return EFAIL;
     }
 
     /**
@@ -381,9 +356,9 @@ ipauuid_start(Slapi_PBlock * pb)
         slapi_ch_calloc(1, sizeof(struct configEntry));
     PR_INIT_CLIST(ipauuid_global_config);
 
-    if (ipauuid_load_plugin_config() != IPAUUID_SUCCESS) {
+    if (ipauuid_load_plugin_config() != EOK) {
         LOG_FATAL("unable to load plug-in configuration\n");
-        return IPAUUID_FAILURE;
+        return EFAIL;
     }
 
     g_plugin_started = 1;
@@ -391,7 +366,7 @@ ipauuid_start(Slapi_PBlock * pb)
     LOG_TRACE("<--out--\n");
 
 done:
-    return IPAUUID_SUCCESS;
+    return EOK;
 }
 
 /*
@@ -410,7 +385,7 @@ ipauuid_close(Slapi_PBlock * pb)
 
     LOG_TRACE("<--out--\n");
 
-    return IPAUUID_SUCCESS;
+    return EOK;
 }
 
 /*
@@ -426,7 +401,7 @@ ipauuid_close(Slapi_PBlock * pb)
 static int
 ipauuid_load_plugin_config()
 {
-    int status = IPAUUID_SUCCESS;
+    int status = EOK;
     int result;
     int i;
     time_t now;
@@ -447,14 +422,14 @@ ipauuid_load_plugin_config()
     slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
 
     if (LDAP_SUCCESS != result) {
-        status = IPAUUID_FAILURE;
+        status = EFAIL;
         goto cleanup;
     }
 
     slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
                      &entries);
     if (NULL == entries || NULL == entries[0]) {
-        status = IPAUUID_SUCCESS;
+        status = EOK;
         goto cleanup;
     }
 
@@ -482,7 +457,7 @@ ipauuid_load_plugin_config()
  * validate config without making any changes by setting apply
  * to 0.
  *
- * Returns IPAUUID_SUCCESS if the entry is valid and IPAUUID_FAILURE
+ * Returns EOK if the entry is valid and EFAIL
  * if it is invalid.
  */
 static int
@@ -494,20 +469,20 @@ ipauuid_parse_config_entry(Slapi_Entry * e, bool apply)
     PRCList *list;
     int entry_added = 0;
     int i = 0;
-    int ret = IPAUUID_SUCCESS;
+    int ret = EOK;
 
     LOG_TRACE("--in-->\n");
 
     /* If this is the main UUID plug-in config entry, just bail. */
     if (strcasecmp(getPluginDN(), slapi_entry_get_ndn(e)) == 0) {
-        ret = IPAUUID_FAILURE;
+        ret = EFAIL;
         goto bail;
     }
 
     entry = (struct configEntry *)
     slapi_ch_calloc(1, sizeof(struct configEntry));
     if (NULL == entry) {
-        ret = IPAUUID_FAILURE;
+        ret = EFAIL;
         goto bail;
     }
 
@@ -521,7 +496,7 @@ ipauuid_parse_config_entry(Slapi_Entry * e, bool apply)
     if (!entry->attr) {
         LOG_FATAL("The %s config setting is required for %s.\n",
                   IPAUUID_ATTR, entry->dn);
-        ret = IPAUUID_FAILURE;
+        ret = EFAIL;
         goto bail;
     }
     LOG_CONFIG("----------> %s [%s]\n", IPAUUID_ATTR, entry->attr);
@@ -544,13 +519,13 @@ ipauuid_parse_config_entry(Slapi_Entry * e, bool apply)
         if (NULL == (entry->slapi_filter = slapi_str2filter(value))) {
             LOG_FATAL("Error: Invalid search filter in entry [%s]: [%s]\n",
                       entry->dn, value);
-            ret = IPAUUID_FAILURE;
+            ret = EFAIL;
             goto bail;
         }
     } else {
         LOG_FATAL("The %s config setting is required for %s.\n",
                   IPAUUID_FILTER, entry->dn);
-        ret = IPAUUID_FAILURE;
+        ret = EFAIL;
         goto bail;
     }
     LOG_CONFIG("----------> %s [%s]\n", IPAUUID_FILTER, value);
@@ -561,7 +536,7 @@ ipauuid_parse_config_entry(Slapi_Entry * e, bool apply)
     } else {
         LOG_FATAL("The %s config config setting is required for %s.\n",
                   IPAUUID_SCOPE, entry->dn);
-        ret = IPAUUID_FAILURE;
+        ret = EFAIL;
         goto bail;
     }
     LOG_CONFIG("----------> %s [%s]\n", IPAUUID_SCOPE, entry->scope);
@@ -622,7 +597,7 @@ bail:
         }
         ipauuid_free_config_entry(&entry);
     } else {
-        ret = IPAUUID_SUCCESS;
+        ret = EOK;
     }
 
     LOG_TRACE("<--out--\n");
@@ -886,7 +861,7 @@ static int ipauuid_pre_op(Slapi_PBlock *pb, int modtype)
             test_e = resulting_e;
         }
 
-        if (ipauuid_parse_config_entry(test_e, false) != IPAUUID_SUCCESS) {
+        if (ipauuid_parse_config_entry(test_e, false) != EOK) {
             /* Refuse the operation if config parsing failed. */
             ret = LDAP_UNWILLING_TO_PERFORM;
             if (LDAP_CHANGETYPE_ADD == modtype) {
@@ -1201,7 +1176,7 @@ done:
         LOG("operation failure [%d]\n", ret);
         slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
         slapi_ch_free((void **)&errstr);
-        ret = IPAUUID_FAILURE;
+        ret = EFAIL;
     }
 
     LOG_TRACE("<--out--\n");
diff --git a/daemons/ipa-slapi-plugins/ipa-version/Makefile.am b/daemons/ipa-slapi-plugins/ipa-version/Makefile.am
index 331ce7f1bcf7e24e499a38760683c81415a29b27..f90543ee426438820356541041c2480a5808ea95 100644
--- a/daemons/ipa-slapi-plugins/ipa-version/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-version/Makefile.am
@@ -1,9 +1,12 @@
 NULL =
 
+PLUGIN_COMMON_DIR=../common
+
 INCLUDES =							\
 	-I.							\
 	-I../../						\
 	-I$(srcdir)						\
+	-I$(PLUGIN_COMMON_DIR)					\
 	-I/usr/include/dirsrv					\
 	-DPREFIX=\""$(prefix)"\" 				\
 	-DBINDIR=\""$(bindir)"\"				\
diff --git a/daemons/ipa-slapi-plugins/ipa-version/ipa_repl_version.c b/daemons/ipa-slapi-plugins/ipa-version/ipa_repl_version.c
index a93800134b42c310c0d5f064e5892768c1c4823d..e8c633be6dd13a35d0a05d233b542b846a4f8560 100644
--- a/daemons/ipa-slapi-plugins/ipa-version/ipa_repl_version.c
+++ b/daemons/ipa-slapi-plugins/ipa-version/ipa_repl_version.c
@@ -38,12 +38,13 @@
 #include "slapi-plugin.h"
 #include "repl-session-plugin.h"
 #include "ipa-version.h"
+#include "util.h"
 #include <string.h>
 
 /* Identify the type of data we're sending, an unsigned int in this case */
 #define REPL_VERSION_DATA_GUID "2D562D8B-2F30-4447-AF76-2B721D1D5F6A"
 
-static char *repl_version_plugin_name = "ipa_replication_version";
+#define IPA_PLUGIN_NAME "ipa_replication_version"
 static char *data_version = NULL;
 
 /*
@@ -74,8 +75,7 @@ static int
 repl_version_plugin_pre_acquire_cb(void *cookie, const Slapi_DN *repl_subtree,
                                         int is_total, char **data_guid, struct berval **data)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-        "repl_version_plugin_pre_acquire_cb() called for suffix \"%s\", "
+    LOG("repl_version_plugin_pre_acquire_cb() called for suffix \"%s\", "
         "is_total: \"%s\".\n", slapi_sdn_get_ndn(repl_subtree),
         is_total ? "TRUE" : "FALSE");
 
@@ -85,9 +85,8 @@ repl_version_plugin_pre_acquire_cb(void *cookie, const Slapi_DN *repl_subtree,
     (*data)->bv_val = slapi_ch_smprintf("%s", data_version);
     (*data)->bv_len = strlen((*data)->bv_val) + 1;
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-        "repl_version_plugin_pre_acquire_cb() sending data: guid: \"%s\" data: \"%s\".\n",
-    *data_guid, (*data)->bv_val);
+    LOG("repl_version_plugin_pre_acquire_cb() sending data: guid: \"%s\" data: \"%s\".\n",
+        *data_guid, (*data)->bv_val);
 
     return 0;
 }
@@ -108,18 +107,17 @@ static int
 repl_version_plugin_recv_acquire_cb(const char *repl_subtree, int is_total,
                                          const char *data_guid, const struct berval *data)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-        "test_repl_session_plugin_recv_acquire_cb() called for suffix \"%s\", is_total: \"%s\".\n",
+    LOG("test_repl_session_plugin_recv_acquire_cb() called for suffix \"%s\", is_total: \"%s\".\n",
         repl_subtree, is_total ? "TRUE" : "FALSE");
 
     /* compare our data version to the master data version */
     if (data_guid && data && (strcmp(data_guid, REPL_VERSION_DATA_GUID) == 0)) {
-        slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-            "repl_version_plugin_recv_acquire_cb() received data: guid: \"%s\" data: \"%s\".\n",
+        LOG("repl_version_plugin_recv_acquire_cb() received data: guid: \"%s\" data: \"%s\".\n",
             data_guid, data->bv_val);
         if (!(strcmp(data_version, data->bv_val) == 0)) {
-            slapi_log_error(SLAPI_LOG_FATAL, repl_version_plugin_name,
-                "Incompatible IPA versions, pausing replication. This server: \"%s\" remote server: \"%s\".\n", data_version, data->bv_val);
+            LOG_FATAL("Incompatible IPA versions, pausing replication. "
+                      "This server: \"%s\" remote server: \"%s\".\n",
+                      data_version, data->bv_val);
             return 1;
         }
     }
@@ -146,35 +144,30 @@ static void *repl_version_api[] = {
 static int
 repl_version_plugin_start(Slapi_PBlock *pb)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-                    "--> repl_version_plugin_start -- begin\n");
+    LOG("--> repl_version_plugin_start -- begin\n");
 
-    data_version = slapi_ch_smprintf("%llu", DATA_VERSION);
+    data_version = slapi_ch_smprintf("%llu", (unsigned long long) DATA_VERSION);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-                    "<-- repl_version_plugin_start -- end\n");
+    LOG("<-- repl_version_plugin_start -- end\n");
     return 0;
 }
 
 static int
 repl_version_plugin_close(Slapi_PBlock *pb)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-                    "--> repl_version_plugin_close -- begin\n");
+    LOG("--> repl_version_plugin_close -- begin\n");
 
     slapi_apib_unregister(REPL_SESSION_v1_0_GUID);
 
     slapi_ch_free_string(&data_version);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-                    "<-- repl_version_plugin_close -- end\n");
+    LOG("<-- repl_version_plugin_close -- end\n");
     return 0;
 }
 
 int repl_version_plugin_init(Slapi_PBlock *pb)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-                    "--> repl_version_plugin_init -- begin\n");
+    LOG("--> repl_version_plugin_init -- begin\n");
 
     if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
                            SLAPI_PLUGIN_VERSION_01 ) != 0 ||
@@ -185,14 +178,12 @@ int repl_version_plugin_init(Slapi_PBlock *pb)
          slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
                            (void *)&repl_version_pdesc ) != 0 )
     {
-        slapi_log_error( SLAPI_LOG_FATAL, repl_version_plugin_name,
-                         "<-- repl_version_plugin_init -- failed to register plugin -- end\n");
+        LOG_FATAL("<-- repl_version_plugin_init -- failed to register plugin -- end\n");
         return -1;
     }
 
     if( slapi_apib_register(REPL_SESSION_v1_0_GUID, repl_version_api) ) {
-        slapi_log_error( SLAPI_LOG_FATAL, repl_version_plugin_name,
-                         "<-- repl_version_plugin_start -- failed to register repl_version api -- end\n");
+        LOG_FATAL("<-- repl_version_plugin_start -- failed to register repl_version api -- end\n");
         return -1;
     }
 
@@ -200,12 +191,10 @@ int repl_version_plugin_init(Slapi_PBlock *pb)
     /* Retrieve and save the plugin identity to later pass to
        internal operations */
     if (slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &repl_version_plugin_id) != 0) {
-        slapi_log_error(SLAPI_LOG_FATAL, repl_version_plugin_name,
-                         "<-- repl_version_plugin_init -- failed to retrieve plugin identity -- end\n");
+        LOG_FATAL("<-- repl_version_plugin_init -- failed to retrieve plugin identity -- end\n");
         return -1;
     }
 
-    slapi_log_error( SLAPI_LOG_PLUGIN, repl_version_plugin_name,
-                     "<-- repl_version_plugin_init -- end\n");
+    LOG("<-- repl_version_plugin_init -- end\n");
     return 0;
 }
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am b/daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am
index 94bc2dc68af33c59d91116b5c54739e4ec94e90b..79c37becb4bf8e62e91ce87c5333623de5421d31 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am
@@ -1,8 +1,11 @@
 NULL =
 
+PLUGIN_COMMON_DIR=../common
+
 INCLUDES =							\
 	-I.							\
 	-I$(srcdir)						\
+	-I$(PLUGIN_COMMON_DIR)					\
 	-DPREFIX=\""$(prefix)"\" 				\
 	-DBINDIR=\""$(bindir)"\"				\
 	-DLIBDIR=\""$(libdir)"\" 				\
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c
index 45efa6df09fdce93ae1c60dcbbdf71122d1d0fc3..5e762bc426b46993606661a6fdd267fca38013cc 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c
@@ -109,10 +109,9 @@ ipa_winsync_config(Slapi_Entry *config_e)
     char returntext[SLAPI_DSE_RETURNTEXT_SIZE];
 
     if ( inited ) {
-        slapi_log_error( SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                         "Error: IPA WinSync plug-in already configured.  "
-                         "Please remove the plugin config entry [%s]\n",
-                         slapi_entry_get_dn_const(config_e));
+        LOG_FATAL("Error: IPA WinSync plug-in already configured.  "
+                  "Please remove the plugin config entry [%s]\n",
+                  slapi_entry_get_dn_const(config_e));
         return( LDAP_PARAM_ERROR );
     }
 
@@ -150,8 +149,7 @@ ipa_winsync_config(Slapi_Entry *config_e)
     inited = 1;
 
     if (returncode != LDAP_SUCCESS) {
-        slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                        "Error %d: %s\n", returncode, returntext);
+        LOG_FATAL("Error %d: %s\n", returncode, returntext);
     }
 
     return returncode;
@@ -264,9 +262,8 @@ ipa_winsync_validate_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_E
     /* get new_user_oc_attr */
     if (!(attrsvals = slapi_entry_attr_get_charray(
               e, IPA_WINSYNC_NEW_USER_ATTRS_VALS))) {
-        slapi_log_error(SLAPI_LOG_PLUGIN, IPA_WINSYNC_PLUGIN_NAME,
-                        "Info: no default attributes and values given in [%s]\n",
-                        IPA_WINSYNC_NEW_USER_ATTRS_VALS);
+        LOG("Info: no default attributes and values given in [%s]\n",
+            IPA_WINSYNC_NEW_USER_ATTRS_VALS);
     }
 
     /* format of *attrsvals is "attrname value" */
@@ -461,9 +458,8 @@ ipa_winsync_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore,
     /* get new_user_oc_attr */
     if (!(attrsvals = slapi_entry_attr_get_charray(
               e, IPA_WINSYNC_NEW_USER_ATTRS_VALS))) {
-        slapi_log_error(SLAPI_LOG_PLUGIN, IPA_WINSYNC_PLUGIN_NAME,
-                        "Info: no default attributes and values given in [%s]\n",
-                        IPA_WINSYNC_NEW_USER_ATTRS_VALS);
+        LOG("Info: no default attributes and values given in [%s]\n",
+            IPA_WINSYNC_NEW_USER_ATTRS_VALS);
     }
 
     /* get acct disable sync value */
@@ -688,20 +684,18 @@ internal_find_entry_get_attr_val(const Slapi_DN *basedn, int scope,
     */
     slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
     if (ret != LDAP_SUCCESS) {
-        slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                        "Error [%d:%s] searching for base [%s] filter [%s]"
-                        " attr [%s]\n", ret, ldap_err2string(ret),
-                        search_basedn, filter, attrs[0]);
+        LOG_FATAL("Error [%d:%s] searching for base [%s] filter [%s]"
+                  " attr [%s]\n", ret, ldap_err2string(ret),
+                  search_basedn, filter, attrs[0]);
         goto out1;
     }
 
     slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
     if (entries && entries[0] && entries[1]) {
         /* error - should never be more than one matching entry */
-        slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                        "Error: more than one entry matches search for "
-                        "base [%s] filter [%s] attr [%s]\n",
-                        search_basedn, filter, attrs[0]);
+        LOG_FATAL("Error: more than one entry matches search for "
+                  "base [%s] filter [%s] attr [%s]\n",
+                  search_basedn, filter, attrs[0]);
         ret = LDAP_UNWILLING_TO_PERFORM;
         goto out1;
     }
@@ -724,10 +718,9 @@ internal_find_entry_get_attr_val(const Slapi_DN *basedn, int scope,
         }
     } else {
         ret = LDAP_NO_SUCH_OBJECT;
-        slapi_log_error(SLAPI_LOG_PLUGIN, IPA_WINSYNC_PLUGIN_NAME,
-                        "Did not find an entry for search "
-                        "base [%s] filter [%s] attr [%s]\n",
-                        search_basedn, filter, attrs[0]);
+        LOG("Did not find an entry for search "
+            "base [%s] filter [%s] attr [%s]\n",
+            search_basedn, filter, attrs[0]);
     }
 
 out1:
@@ -814,10 +807,9 @@ ipa_winsync_config_refresh_domain(
 
     if (!iwdc->realm_name) {
         /* error - could not find the IPA config entry with the realm name */
-        slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                        "Error: could not find the entry containing the realm name for "
-                        "ds subtree [%s] filter [%s] attr [%s]\n",
-                        slapi_sdn_get_dn(ds_subtree), realm_filter, realm_attr);
+        LOG_FATAL("Error: could not find the entry containing the realm name for "
+                  "ds subtree [%s] filter [%s] attr [%s]\n",
+                  slapi_sdn_get_dn(ds_subtree), realm_filter, realm_attr);
         goto out;
     }
 
@@ -828,10 +820,9 @@ ipa_winsync_config_refresh_domain(
                                            &new_user_objclasses, NULL);
     if (!new_user_objclasses) {
         /* error - could not find the entry containing list of objectclasses */
-        slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                        "Error: could not find the entry containing the new user objectclass list for "
-                        "ds subtree [%s] filter [%s] attr [%s]\n",
-                        slapi_sdn_get_dn(ds_subtree), new_entry_filter, new_user_oc_attr);
+        LOG_FATAL("Error: could not find the entry containing the new user objectclass list for "
+                  "ds subtree [%s] filter [%s] attr [%s]\n",
+                  slapi_sdn_get_dn(ds_subtree), new_entry_filter, new_user_oc_attr);
         goto out;
     }
 
@@ -844,10 +835,9 @@ ipa_winsync_config_refresh_domain(
                                            NULL, &iwdc->homedir_prefix);
     if (!iwdc->homedir_prefix) {
         /* error - could not find the home dir prefix */
-        slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                        "Error: could not find the entry containing the home directory prefix for "
-                        "ds subtree [%s] filter [%s] attr [%s]\n",
-                        slapi_sdn_get_dn(ds_subtree), new_entry_filter, homedir_prefix_attr);
+        LOG_FATAL("Error: could not find the entry containing the home directory prefix for "
+                  "ds subtree [%s] filter [%s] attr [%s]\n",
+                  slapi_sdn_get_dn(ds_subtree), new_entry_filter, homedir_prefix_attr);
         goto out;
     }
 
@@ -860,10 +850,9 @@ ipa_winsync_config_refresh_domain(
                                            NULL, &default_group_name);
     if (!default_group_name) {
         /* error - could not find the default group name */
-        slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                        "Error: could not find the entry containing the default group name for "
-                        "ds subtree [%s] filter [%s] attr [%s]\n",
-                        slapi_sdn_get_dn(ds_subtree), new_entry_filter, default_group_attr);
+        LOG_FATAL("Error: could not find the entry containing the default group name for "
+                  "ds subtree [%s] filter [%s] attr [%s]\n",
+                  slapi_sdn_get_dn(ds_subtree), new_entry_filter, default_group_attr);
         goto out;
     }
 
@@ -877,10 +866,9 @@ ipa_winsync_config_refresh_domain(
                                            NULL, &default_gid);
     if (!default_gid) {
         /* error - could not find the default gidNumber */
-        slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                        "Error: could not find the entry containing the default gidNumber "
-                        "ds subtree [%s] filter [%s] attr [%s]\n",
-                        slapi_sdn_get_dn(ds_subtree), new_entry_filter, "gidNumber");
+        LOG_FATAL("Error: could not find the entry containing the default gidNumber "
+                  "ds subtree [%s] filter [%s] attr [%s]\n",
+                  slapi_sdn_get_dn(ds_subtree), new_entry_filter, "gidNumber");
         goto out;
     }
 
@@ -897,10 +885,9 @@ ipa_winsync_config_refresh_domain(
                                                NULL, &inactivated_group_dn);
         if (!inactivated_group_dn) {
             /* error - could not find the inactivated group dn */
-            slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                            "Error: could not find the DN of the inactivated users group "
-                            "ds subtree [%s] filter [%s]\n",
-                            slapi_sdn_get_dn(ds_subtree), inactivated_filter);
+            LOG_FATAL("Error: could not find the DN of the inactivated users group "
+                      "ds subtree [%s] filter [%s]\n",
+                      slapi_sdn_get_dn(ds_subtree), inactivated_filter);
             goto out;
         }
         ret = internal_find_entry_get_attr_val(config_dn, search_scope,
@@ -908,10 +895,9 @@ ipa_winsync_config_refresh_domain(
                                                NULL, &activated_group_dn);
         if (!activated_group_dn) {
             /* error - could not find the activated group dn */
-            slapi_log_error(SLAPI_LOG_FATAL, IPA_WINSYNC_PLUGIN_NAME,
-                            "Error: could not find the DN of the activated users group "
-                            "ds subtree [%s] filter [%s]\n",
-                            slapi_sdn_get_dn(ds_subtree), activated_filter);
+            LOG_FATAL("Error: could not find the DN of the activated users group "
+                      "ds subtree [%s] filter [%s]\n",
+                      slapi_sdn_get_dn(ds_subtree), activated_filter);
             goto out;
         }
     }
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c
index 9ee8805bb1bf9683a194d82f16e6e6ea7d5f5141..4e2d534fc174657e02be1c0692de01f8745d4ba8 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c
@@ -59,8 +59,6 @@
 #endif
 #include "ipa-winsync.h"
 
-static char *ipa_winsync_plugin_name = IPA_WINSYNC_PLUGIN_NAME;
-
 static void
 sync_acct_disable(
     void *cbdata, /* the usual domain config data */
@@ -87,16 +85,14 @@ static void *
 ipa_winsync_agmt_init(const Slapi_DN *ds_subtree, const Slapi_DN *ad_subtree)
 {
     void *cbdata = NULL;
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_agmt_init [%s] [%s] -- begin\n",
-                    slapi_sdn_get_dn(ds_subtree),
-                    slapi_sdn_get_dn(ad_subtree));
+    LOG("--> ipa_winsync_agmt_init [%s] [%s] -- begin\n",
+        slapi_sdn_get_dn(ds_subtree),
+        slapi_sdn_get_dn(ad_subtree));
 
     /* do the domain specific configuration based on the ds subtree */
     cbdata = ipa_winsync_config_new_domain(ds_subtree, ad_subtree);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_agmt_init -- end\n");
+    LOG("<-- ipa_winsync_agmt_init -- end\n");
 
     return cbdata;
 }
@@ -106,11 +102,9 @@ ipa_winsync_dirsync_search_params_cb(void *cbdata, const char *agmt_dn,
                                      char **base, int *scope, char **filter,
                                      char ***attrs, LDAPControl ***serverctrls)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_dirsync_search_params_cb -- begin\n");
+    LOG("--> ipa_winsync_dirsync_search_params_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_dirsync_search_params_cb -- end\n");
+    LOG("<-- ipa_winsync_dirsync_search_params_cb -- end\n");
 
     return;
 }
@@ -121,11 +115,9 @@ ipa_winsync_pre_ad_search_cb(void *cbdata, const char *agmt_dn,
                              char **base, int *scope, char **filter,
                              char ***attrs, LDAPControl ***serverctrls)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ad_search_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ad_search_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ad_search_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ad_search_cb -- end\n");
 
     return;
 }
@@ -136,16 +128,13 @@ ipa_winsync_pre_ds_search_entry_cb(void *cbdata, const char *agmt_dn,
                                    char **base, int *scope, char **filter,
                                    char ***attrs, LDAPControl ***serverctrls)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ds_search_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ds_search_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "-- ipa_winsync_pre_ds_search_cb - base [%s] "
-                    "scope [%d] filter [%s]\n",
-                    *base, *scope, *filter);
+    LOG("-- ipa_winsync_pre_ds_search_cb - base [%s] "
+        "scope [%d] filter [%s]\n",
+        *base, *scope, *filter);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ds_search_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ds_search_cb -- end\n");
 
     return;
 }
@@ -156,9 +145,8 @@ ipa_winsync_pre_ds_search_all_cb(void *cbdata, const char *agmt_dn,
                                  char **base, int *scope, char **filter,
                                  char ***attrs, LDAPControl ***serverctrls)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ds_search_all_cb -- orig filter [%s] -- begin\n",
-                    ((filter && *filter) ? *filter : "NULL"));
+    LOG("--> ipa_winsync_pre_ds_search_all_cb -- orig filter [%s] -- begin\n",
+        ((filter && *filter) ? *filter : "NULL"));
 
     /* We only want to grab users from the ds side - no groups */
     slapi_ch_free_string(filter);
@@ -167,8 +155,7 @@ ipa_winsync_pre_ds_search_all_cb(void *cbdata, const char *agmt_dn,
        indexed for equality only - need to add presence? */
     *filter = slapi_ch_strdup("(&(objectclass=ntuser)(ntUserDomainId=*))");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ds_search_all_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ds_search_all_cb -- end\n");
 
     return;
 }
@@ -178,14 +165,12 @@ ipa_winsync_pre_ad_mod_user_cb(void *cbdata, const Slapi_Entry *rawentry,
                                Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
                                Slapi_Mods *smods, int *do_modify)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ad_mod_user_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ad_mod_user_cb -- begin\n");
 
     sync_acct_disable(cbdata, rawentry, ds_entry, ACCT_DISABLE_TO_AD,
                       NULL, smods, do_modify);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ad_mod_user_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ad_mod_user_cb -- end\n");
 
     return;
 }
@@ -195,11 +180,9 @@ ipa_winsync_pre_ad_mod_group_cb(void *cbdata, const Slapi_Entry *rawentry,
                                 Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
                                 Slapi_Mods *smods, int *do_modify)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ad_mod_group_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ad_mod_group_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ad_mod_group_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ad_mod_group_cb -- end\n");
 
     return;
 }
@@ -209,16 +192,14 @@ ipa_winsync_pre_ds_mod_user_cb(void *cbdata, const Slapi_Entry *rawentry,
                                Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
                                Slapi_Mods *smods, int *do_modify)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ds_mod_user_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ds_mod_user_cb -- begin\n");
 
     sync_acct_disable(cbdata, rawentry, ds_entry, ACCT_DISABLE_TO_DS,
                       NULL, smods, do_modify);
 
     do_force_sync(rawentry, ds_entry, smods, do_modify);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ds_mod_user_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ds_mod_user_cb -- end\n");
 
     return;
 }
@@ -228,11 +209,9 @@ ipa_winsync_pre_ds_mod_group_cb(void *cbdata, const Slapi_Entry *rawentry,
                                 Slapi_Entry *ad_entry, Slapi_Entry *ds_entry,
                                 Slapi_Mods *smods, int *do_modify)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ds_mod_group_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ds_mod_group_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ds_mod_group_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ds_mod_group_cb -- end\n");
 
     return;
 }
@@ -247,16 +226,14 @@ ipa_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry,
     char *type = NULL;
     IPA_WinSync_Config *global_ipaconfig = ipa_winsync_get_config();
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ds_add_user_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ds_add_user_cb -- begin\n");
 
     if (!ipaconfig || !ipaconfig->domain_e || !ipaconfig->realm_name ||
         !ipaconfig->homedir_prefix) {
-        slapi_log_error(SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-                        "Error: configuration failure: cannot map Windows "
-                        "entry dn [%s], DS entry dn [%s]\n",
-                        slapi_entry_get_dn_const(ad_entry),
-                        slapi_entry_get_dn_const(ds_entry));
+        LOG_FATAL("Error: configuration failure: cannot map Windows "
+                  "entry dn [%s], DS entry dn [%s]\n",
+                  slapi_entry_get_dn_const(ad_entry),
+                  slapi_entry_get_dn_const(ds_entry));
         return;
     }
 
@@ -278,10 +255,9 @@ ipa_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry,
             {
                 if (!slapi_entry_attr_has_syntax_value(ds_entry, type, sv)) {
                     /* attr-value sv not found in ds_entry; add it */
-                    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                                    "--> ipa_winsync_pre_ds_add_user_cb -- "
-                                    "adding val for [%s] to new entry [%s]\n",
-                                    type, slapi_entry_get_dn_const(ds_entry));
+                    LOG("--> ipa_winsync_pre_ds_add_user_cb -- "
+                        "adding val for [%s] to new entry [%s]\n",
+                        type, slapi_entry_get_dn_const(ds_entry));
 
                     slapi_entry_add_value(ds_entry, type, sv);
                 }
@@ -310,13 +286,12 @@ ipa_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry,
             upn = slapi_ch_smprintf("%s@%s", samAccountName, ipaconfig->realm_name);
             slapi_ch_free_string(&samAccountName);
         } else { /* fatal error - nothing to use for krbPrincipalName */
-            slapi_log_error(SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-                            "Error creating %s for realm [%s] for Windows "
-                            "entry dn [%s], DS entry dn [%s] - Windows entry "
-                            "has no samAccountName, and DS entry has no uid.\n",
-                            type, ipaconfig->realm_name,
-                            slapi_entry_get_dn_const(ad_entry),
-                            slapi_entry_get_dn_const(ds_entry));
+            LOG_FATAL("Error creating %s for realm [%s] for Windows "
+                      "entry dn [%s], DS entry dn [%s] - Windows entry "
+                      "has no samAccountName, and DS entry has no uid.\n",
+                      type, ipaconfig->realm_name,
+                      slapi_entry_get_dn_const(ad_entry),
+                      slapi_entry_get_dn_const(ds_entry));
         }
 
         if (upn) {
@@ -341,13 +316,12 @@ ipa_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry,
                                         samAccountName);
             slapi_ch_free_string(&samAccountName);
         } else { /* fatal error - nothing to use for homeDirectory */
-            slapi_log_error(SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-                            "Error creating %s for realm [%s] for Windows "
-                            "entry dn [%s], DS entry dn [%s] - Windows entry "
-                            "has no samAccountName, and DS entry has no uid.\n",
-                            type, ipaconfig->realm_name,
-                            slapi_entry_get_dn_const(ad_entry),
-                            slapi_entry_get_dn_const(ds_entry));
+            LOG_FATAL("Error creating %s for realm [%s] for Windows "
+                      "entry dn [%s], DS entry dn [%s] - Windows entry "
+                      "has no samAccountName, and DS entry has no uid.\n",
+                      type, ipaconfig->realm_name,
+                      slapi_entry_get_dn_const(ad_entry),
+                      slapi_entry_get_dn_const(ds_entry));
         }
 
         if (homeDir) {
@@ -375,8 +349,7 @@ ipa_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry,
 
     sync_acct_disable(cbdata, rawentry, ds_entry, ACCT_DISABLE_TO_DS,
                       ds_entry, NULL, NULL);
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ds_add_user_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ds_add_user_cb -- end\n");
 
     return;
 }
@@ -385,11 +358,9 @@ static void
 ipa_winsync_pre_ds_add_group_cb(void *cbdata, const Slapi_Entry *rawentry,
                                 Slapi_Entry *ad_entry, Slapi_Entry *ds_entry)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ds_add_group_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ds_add_group_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ds_add_group_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ds_add_group_cb -- end\n");
 
     return;
 }
@@ -403,8 +374,7 @@ ipa_winsync_get_new_ds_user_dn_cb(void *cbdata, const Slapi_Entry *rawentry,
     PRBool flatten = PR_TRUE;
     IPA_WinSync_Config *ipaconfig = ipa_winsync_get_config();
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_get_new_ds_user_dn_cb -- old dn [%s] -- begin\n",
+    LOG("--> ipa_winsync_get_new_ds_user_dn_cb -- old dn [%s] -- begin\n",
                     *new_dn_string);
 
     slapi_lock_mutex(ipaconfig->lock);
@@ -425,8 +395,7 @@ ipa_winsync_get_new_ds_user_dn_cb(void *cbdata, const Slapi_Entry *rawentry,
     *new_dn_string = slapi_ch_smprintf("%s,%s", rdns[0], slapi_sdn_get_dn(ds_suffix));
     ldap_value_free(rdns);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_get_new_ds_user_dn_cb -- new dn [%s] -- end\n",
+    LOG("<-- ipa_winsync_get_new_ds_user_dn_cb -- new dn [%s] -- end\n",
                     *new_dn_string);
 
     return;
@@ -437,11 +406,9 @@ ipa_winsync_get_new_ds_group_dn_cb(void *cbdata, const Slapi_Entry *rawentry,
                                    Slapi_Entry *ad_entry, char **new_dn_string,
                                    const Slapi_DN *ds_suffix, const Slapi_DN *ad_suffix)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_get_new_ds_group_dn_cb -- begin\n");
+    LOG("--> ipa_winsync_get_new_ds_group_dn_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_get_new_ds_group_dn_cb -- end\n");
+    LOG("<-- ipa_winsync_get_new_ds_group_dn_cb -- end\n");
 
     return;
 }
@@ -455,8 +422,7 @@ ipa_winsync_pre_ad_mod_user_mods_cb(void *cbdata, const Slapi_Entry *rawentry,
 {
     Slapi_Mods *smods;
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ad_mod_user_mods_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ad_mod_user_mods_cb -- begin\n");
 
     /* wrap the modstosend in a Slapi_Mods for convenience */
     smods = slapi_mods_new();
@@ -467,8 +433,7 @@ ipa_winsync_pre_ad_mod_user_mods_cb(void *cbdata, const Slapi_Entry *rawentry,
     /* convert back to LDAPMod ** and clean up */
     *modstosend = slapi_mods_get_ldapmods_passout(smods);
     slapi_mods_free(&smods);
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ad_mod_user_mods_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ad_mod_user_mods_cb -- end\n");
 
     return;
 }
@@ -480,11 +445,9 @@ ipa_winsync_pre_ad_mod_group_mods_cb(void *cbdata, const Slapi_Entry *rawentry,
                                      LDAPMod * const *origmods,
                                      Slapi_DN *remote_dn, LDAPMod ***modstosend)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_pre_ad_mod_group_mods_cb -- begin\n");
+    LOG("--> ipa_winsync_pre_ad_mod_group_mods_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_pre_ad_mod_group_mods_cb -- end\n");
+    LOG("<-- ipa_winsync_pre_ad_mod_group_mods_cb -- end\n");
 
     return;
 }
@@ -493,11 +456,9 @@ static int
 ipa_winsync_can_add_entry_to_ad_cb(void *cbdata, const Slapi_Entry *local_entry,
                                    const Slapi_DN *remote_dn)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_can_add_entry_to_ad_cb -- begin\n");
+    LOG("--> ipa_winsync_can_add_entry_to_ad_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_can_add_entry_to_ad_cb -- end\n");
+    LOG("<-- ipa_winsync_can_add_entry_to_ad_cb -- end\n");
 
     return 0; /* false - do not allow entries to be added to ad */
 }
@@ -506,13 +467,11 @@ static void
 ipa_winsync_begin_update_cb(void *cbdata, const Slapi_DN *ds_subtree,
                             const Slapi_DN *ad_subtree, int is_total)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_begin_update_cb -- begin\n");
+    LOG("--> ipa_winsync_begin_update_cb -- begin\n");
 
     ipa_winsync_config_refresh_domain(cbdata, ds_subtree, ad_subtree);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_begin_update_cb -- end\n");
+    LOG("<-- ipa_winsync_begin_update_cb -- end\n");
 
     return;
 }
@@ -521,11 +480,9 @@ static void
 ipa_winsync_end_update_cb(void *cbdata, const Slapi_DN *ds_subtree,
                           const Slapi_DN *ad_subtree, int is_total)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_end_update_cb -- begin\n");
+    LOG("--> ipa_winsync_end_update_cb -- begin\n");
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_end_update_cb -- end\n");
+    LOG("<-- ipa_winsync_end_update_cb -- end\n");
 
     return;
 }
@@ -534,13 +491,11 @@ static void
 ipa_winsync_destroy_agmt_cb(void *cbdata, const Slapi_DN *ds_subtree,
                             const Slapi_DN *ad_subtree)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_destroy_agmt_cb -- begin\n");
+    LOG("--> ipa_winsync_destroy_agmt_cb -- begin\n");
 
     ipa_winsync_config_destroy_domain(cbdata, ds_subtree, ad_subtree);
     
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_destroy_agmt_cb -- end\n");
+    LOG("<-- ipa_winsync_destroy_agmt_cb -- end\n");
 
     return;
 }
@@ -600,42 +555,35 @@ ipa_winsync_plugin_start(Slapi_PBlock *pb)
 	int rc;
 	Slapi_Entry *config_e = NULL; /* entry containing plugin config */
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_plugin_start -- begin\n");
+    LOG("--> ipa_winsync_plugin_start -- begin\n");
 
 	if( slapi_apib_register(WINSYNC_v1_0_GUID, ipa_winsync_api) ) {
-        slapi_log_error( SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-                         "<-- ipa_winsync_plugin_start -- failed to register winsync api -- end\n");
-        return -1;
+            LOG_FATAL("<-- ipa_winsync_plugin_start -- failed to register winsync api -- end\n");
+            return -1;
 	}
 	
     if ( slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &config_e ) != 0 ) {
-		slapi_log_error( SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-						 "missing config entry\n" );
-		return( -1 );
+        LOG_FATAL("missing config entry\n" );
+        return( -1 );
     }
 
     if (( rc = ipa_winsync_config( config_e )) != LDAP_SUCCESS ) {
-		slapi_log_error( SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-						 "configuration failed (%s)\n", ldap_err2string( rc ));
-		return( -1 );
+        LOG_FATAL("configuration failed (%s)\n", ldap_err2string( rc ));
+        return( -1 );
     }
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_plugin_start -- end\n");
-	return 0;
+    LOG("<-- ipa_winsync_plugin_start -- end\n");
+    return 0;
 }
 
 static int
 ipa_winsync_plugin_close(Slapi_PBlock *pb)
 {
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_plugin_close -- begin\n");
+    LOG("--> ipa_winsync_plugin_close -- begin\n");
 
 	slapi_apib_unregister(WINSYNC_v1_0_GUID);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- ipa_winsync_plugin_close -- end\n");
+    LOG("<-- ipa_winsync_plugin_close -- end\n");
 	return 0;
 }
 
@@ -646,8 +594,7 @@ int ipa_winsync_plugin_init(Slapi_PBlock *pb)
 {
     void *plugin_id = NULL;
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "--> ipa_winsync_plugin_init -- begin\n");
+    LOG("--> ipa_winsync_plugin_init -- begin\n");
 
     if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
                            SLAPI_PLUGIN_VERSION_01 ) != 0 ||
@@ -658,23 +605,20 @@ int ipa_winsync_plugin_init(Slapi_PBlock *pb)
          slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
                            (void *)&ipa_winsync_pdesc ) != 0 )
     {
-        slapi_log_error( SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-                         "<-- ipa_winsync_plugin_init -- failed to register plugin -- end\n");
+        LOG_FATAL("<-- ipa_winsync_plugin_init -- failed to register plugin -- end\n");
         return -1;
     }
 
     /* Retrieve and save the plugin identity to later pass to
        internal operations */
     if (slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &plugin_id) != 0) {
-        slapi_log_error(SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-                         "<-- ipa_winsync_plugin_init -- failed to retrieve plugin identity -- end\n");
+        LOG_FATAL("<-- ipa_winsync_plugin_init -- failed to retrieve plugin identity -- end\n");
         return -1;
     }
 
     ipa_winsync_set_plugin_identity(plugin_id);
 
-    slapi_log_error( SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                     "<-- ipa_winsync_plugin_init -- end\n");
+    LOG("<-- ipa_winsync_plugin_init -- end\n");
     return 0;
 }
 
@@ -704,11 +648,10 @@ ipa_check_account_lock(Slapi_Entry *ds_entry, int *isvirt)
             rc = 0; /* account is disabled */
         }
         slapi_ch_free_string(&strval);
-        slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                        "<-- ipa_check_account_lock - entry [%s] has real "
-                        "attribute nsAccountLock and entry %s locked\n",
-                        slapi_entry_get_dn_const(ds_entry),
-                        rc ? "is not" : "is");
+        LOG("<-- ipa_check_account_lock - entry [%s] has real "
+            "attribute nsAccountLock and entry %s locked\n",
+            slapi_entry_get_dn_const(ds_entry),
+            rc ? "is not" : "is");
         return rc;
     }
 
@@ -734,18 +677,16 @@ ipa_check_account_lock(Slapi_Entry *ds_entry, int *isvirt)
         if (values != NULL) {
             slapi_vattr_values_free(&values, &actual_type_name, attr_free_flags);
         }
-        slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                        "<-- ipa_check_account_lock - entry [%s] has virtual "
-                        "attribute nsAccountLock and entry %s locked\n",
-                        slapi_entry_get_dn_const(ds_entry),
-                        rc ? "is not" : "is");
+        LOG("<-- ipa_check_account_lock - entry [%s] has virtual "
+            "attribute nsAccountLock and entry %s locked\n",
+            slapi_entry_get_dn_const(ds_entry),
+            rc ? "is not" : "is");
     } else {
         rc = 1; /* no attr == entry is enabled */
-        slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                        "<-- ipa_check_account_lock - entry [%s] does not "
-                        "have attribute nsAccountLock - entry %s locked\n",
-                        slapi_entry_get_dn_const(ds_entry),
-                        rc ? "is not" : "is");
+        LOG("<-- ipa_check_account_lock - entry [%s] does not "
+            "have attribute nsAccountLock - entry %s locked\n",
+            slapi_entry_get_dn_const(ds_entry),
+            rc ? "is not" : "is");
     }
 
     return rc;
@@ -784,12 +725,11 @@ do_group_modify(const char *dn, const char *modtype, int modop, const char *modv
 
     slapi_pblock_destroy(mod_pb);
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "<-- do_group_modify - %s value [%s] in attribute [%s] "
-                    "in entry [%s] - result (%d: %s)\n",
-                    (modop & LDAP_MOD_ADD) ? "added" : "deleted",
-                    modval, modtype, dn,
-                    rc, ldap_err2string(rc));
+    LOG("<-- do_group_modify - %s value [%s] in attribute [%s] "
+        "in entry [%s] - result (%d: %s)\n",
+        (modop & LDAP_MOD_ADD) ? "added" : "deleted",
+        modval, modtype, dn,
+        rc, ldap_err2string(rc));
 
     return rc;
 }
@@ -863,12 +803,11 @@ sync_acct_disable(
                 adval |= mask; /* set the 0x2 disable bit */
             }
             slapi_entry_attr_set_ulong(update_entry, "userAccountControl", adval);
-            slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                            "<-- sync_acct_disable - %s AD account [%s] - "
-                            "new value is [%ld]\n",
-                            (ds_is_enabled) ? "enabled" : "disabled",
-                            slapi_entry_get_dn_const(update_entry),
-                            adval);
+            LOG("<-- sync_acct_disable - %s AD account [%s] - "
+                "new value is [%ld]\n",
+                (ds_is_enabled) ? "enabled" : "disabled",
+                slapi_entry_get_dn_const(update_entry),
+                adval);
         } else {
             /* iterate through the mods - if there is already a mod
                for userAccountControl, change it - otherwise, add it */
@@ -924,12 +863,11 @@ sync_acct_disable(
                 mod_bval->bv_val = slapi_ch_strdup(acctvalstr);
                 mod_bval->bv_len = strlen(acctvalstr);
             }
-            slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                            "<-- sync_acct_disable - %s AD account [%s] - "
-                            "new value is [%ld]\n",
-                            (ds_is_enabled) ? "enabled" : "disabled",
-                            slapi_entry_get_dn_const(ad_entry),
-                            adval);
+            LOG("<-- sync_acct_disable - %s AD account [%s] - "
+                "new value is [%ld]\n",
+                (ds_is_enabled) ? "enabled" : "disabled",
+                slapi_entry_get_dn_const(ad_entry),
+                adval);
         }
     }
 
@@ -946,10 +884,9 @@ sync_acct_disable(
 
             if (update_entry) {
                 slapi_entry_attr_set_charptr(update_entry, attrtype, attrval);
-                slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                                "<-- sync_acct_disable - %s DS account [%s]\n",
-                                (ad_is_enabled) ? "enabled" : "disabled",
-                                slapi_entry_get_dn_const(ds_entry));
+                LOG("<-- sync_acct_disable - %s DS account [%s]\n",
+                    (ad_is_enabled) ? "enabled" : "disabled",
+                    slapi_entry_get_dn_const(ds_entry));
             } else { /* do mod */
                 struct berval tmpbval = {0, NULL};
                 Slapi_Mod *smod = slapi_mod_new();
@@ -964,10 +901,9 @@ sync_acct_disable(
                 slapi_mods_add_ldapmod(smods,
                                        slapi_mod_get_ldapmod_passout(smod));
                 slapi_mod_free(&smod);
-                slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                                "<-- sync_acct_disable - %s DS account [%s]\n",
-                                (ad_is_enabled) ? "enabled" : "disabled",
-                                slapi_entry_get_dn_const(ds_entry));
+                LOG("<-- sync_acct_disable - %s DS account [%s]\n",
+                    (ad_is_enabled) ? "enabled" : "disabled",
+                    slapi_entry_get_dn_const(ds_entry));
                 if (do_modify) {
                     *do_modify = 1; /* added mods */
                 }
@@ -993,27 +929,24 @@ sync_acct_disable(
             }
 
             dsdn = slapi_entry_get_dn_const(ds_entry);
-            slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                            "<-- sync_acct_disable - %s DS account [%s] - "
-                            "deldn [%s] adddn [%s]\n",
-                            (ad_is_enabled) ? "enabling" : "disabling",
-                            slapi_entry_get_dn_const(ds_entry),
-                            deldn, adddn);
+            LOG("<-- sync_acct_disable - %s DS account [%s] - "
+                "deldn [%s] adddn [%s]\n",
+                (ad_is_enabled) ? "enabling" : "disabling",
+                slapi_entry_get_dn_const(ds_entry),
+                deldn, adddn);
             /* first, delete the user from the deldn group - ignore (but log)
                value not found errors - means the user wasn't there yet */
             rc = do_group_modify(deldn, "member", LDAP_MOD_DELETE, dsdn);
             if (rc == LDAP_NO_SUCH_ATTRIBUTE) {
                 /* either the value of the attribute doesn't exist */
-                slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                                "Could not delete user [%s] from the [%s] group: "
-                                "either the user was not in the group already, "
-                                "or the group had no members\n",
-                                dsdn, deldn);
+                LOG("Could not delete user [%s] from the [%s] group: "
+                    "either the user was not in the group already, "
+                    "or the group had no members\n",
+                    dsdn, deldn);
             } else if (rc != LDAP_SUCCESS) {
-                slapi_log_error(SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-                                "Error deleting user [%s] from the [%s] group: "
-                                "(%d - %s)\n", dsdn, deldn, rc,
-                                ldap_err2string(rc));
+                LOG_FATAL("Error deleting user [%s] from the [%s] group: "
+                          "(%d - %s)\n", dsdn, deldn, rc,
+                          ldap_err2string(rc));
             }
             /* next, add the user to the adddn group - ignore (but log)
                if the user is already in that group */
@@ -1024,15 +957,13 @@ sync_acct_disable(
             }
             if (rc == LDAP_TYPE_OR_VALUE_EXISTS) {
                 /* user already in that group */
-                slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                                "Could not add user [%s] to the [%s] group: "
-                                "user is already in that group\n",
-                                dsdn, adddn);
+                LOG("Could not add user [%s] to the [%s] group: "
+                    "user is already in that group\n",
+                    dsdn, adddn);
             } else if (rc != LDAP_SUCCESS) {
-                slapi_log_error(SLAPI_LOG_FATAL, ipa_winsync_plugin_name,
-                                "Error adding user [%s] to the [%s] group: "
-                                "(%d - %s)\n", dsdn, adddn, rc,
-                                ldap_err2string(rc));
+                LOG_FATAL("Error adding user [%s] to the [%s] group: "
+                          "(%d - %s)\n", dsdn, adddn, rc,
+                          ldap_err2string(rc));
             }
 #ifndef MEMBEROF_WORKS_FOR_INTERNAL_OPS
             /* memberOf doesn't currently listen for internal operations
@@ -1074,10 +1005,9 @@ sync_acct_disable(
                 slapi_value_free(&sv);
             }
 #endif /* MEMBEROF_WORKS_FOR_INTERNAL_OPS */
-            slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                            "<-- sync_acct_disable - %s DS account [%s]\n",
-                            (ad_is_enabled) ? "enabled" : "disabled",
-                            slapi_entry_get_dn_const(ds_entry));
+            LOG("<-- sync_acct_disable - %s DS account [%s]\n",
+                (ad_is_enabled) ? "enabled" : "disabled",
+                slapi_entry_get_dn_const(ds_entry));
         }
     }
 
@@ -1125,10 +1055,9 @@ find_and_add_mod(Slapi_Entry *ent, Slapi_Mods *smods, const char *type,
         if (do_modify) {
             *do_modify = 1; /* added a mod */
         }
-        slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                        "<-- find_and_add_mod - added value [%s] "
-                        "to attribute [%s] in entry [%s]\n",
-                        val, type, slapi_entry_get_dn_const(ent));
+        LOG("<-- find_and_add_mod - added value [%s] "
+            "to attribute [%s] in entry [%s]\n",
+            val, type, slapi_entry_get_dn_const(ent));
     }
     slapi_value_free(&sv);
 
@@ -1165,11 +1094,10 @@ do_force_sync(
         return; /* not supported */
     }
 
-    slapi_log_error(SLAPI_LOG_PLUGIN, ipa_winsync_plugin_name,
-                    "do_force_sync - forcing sync of AD entry [%s] "
-                    "with DS entry [%s]\n",
-                    slapi_entry_get_dn_const(ad_entry),
-                    slapi_entry_get_dn_const(ds_entry));
+    LOG("do_force_sync - forcing sync of AD entry [%s] "
+        "with DS entry [%s]\n",
+        slapi_entry_get_dn_const(ad_entry),
+        slapi_entry_get_dn_const(ds_entry));
 
     find_and_add_mod(ds_entry, smods, "objectClass", "ntUser", (size_t)6, do_modify);
 
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h
index 58a9a6c40e67d6be3cd92219432340d13f3ec59e..338e67cfb310e791f629c213c152553b666c1455 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h
@@ -52,7 +52,9 @@
 #include <dirsrv/winsync-plugin.h>
 #endif /* WINSYNC_TEST_IPA */
 
-#define IPA_WINSYNC_PLUGIN_NAME "ipa-winsync"
+#include "util.h"
+
+#define IPA_PLUGIN_NAME "ipa-winsync"
 
 typedef struct ipa_winsync_config_struct {
     Slapi_Mutex *lock; /* for config access */
-- 
1.7.3.2

-------------- next part --------------
>From e0fc8221ed25ab9269f2263bedba5a0bd42f8a55 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Thu, 4 Nov 2010 17:08:26 +0100
Subject: [PATCH 2/6] Stricter compilation flags

Use a little stricter compilation flags, in particular -Wall and treat
implicit function declarations as errors.
---
 daemons/Makefile.am                                |    8 ++++++++
 daemons/configure.ac                               |    2 ++
 daemons/ipa-kpasswd/Makefile.am                    |    1 +
 .../ipa-slapi-plugins/ipa-enrollment/Makefile.am   |    1 +
 daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am   |    1 +
 .../ipa-slapi-plugins/ipa-pwd-extop/Makefile.am    |    1 +
 daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am     |    1 +
 daemons/ipa-slapi-plugins/ipa-version/Makefile.am  |    1 +
 daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am  |    1 +
 ipa-client/Makefile.am                             |    9 +++++++++
 ipa-client/configure.ac                            |    2 ++
 11 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/daemons/Makefile.am b/daemons/Makefile.am
index 9960789a4cef414371f9b90cc78ce8e2aa59723b..7b2b9974647246cfbe02c85fd7def6776394614e 100644
--- a/daemons/Makefile.am
+++ b/daemons/Makefile.am
@@ -4,6 +4,14 @@ AUTOMAKE_OPTIONS = 1.7
 
 NULL =
 
+AM_CFLAGS = $(NULL)
+if HAVE_GCC
+    AM_CFLAGS += -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith \
+		-Wcast-align -Werror-implicit-function-declaration \
+		$(NULL)
+endif
+export AM_CFLAGS
+
 SUBDIRS =			\
 	ipa-kpasswd		\
 	ipa-slapi-plugins	\
diff --git a/daemons/configure.ac b/daemons/configure.ac
index 53806f52d499bcb9f692d42994eebcc30a5f0955..da86557d28b2c6e1035ab85a21408f9bb0a6724f 100644
--- a/daemons/configure.ac
+++ b/daemons/configure.ac
@@ -16,6 +16,8 @@ AC_PROG_LIBTOOL
 
 AC_HEADER_STDC
 
+AM_CONDITIONAL([HAVE_GCC], [test "$ac_cv_prog_gcc" = yes])
+
 AC_SUBST(VERSION)
 
 dnl ---------------------------------------------------------------------------
diff --git a/daemons/ipa-kpasswd/Makefile.am b/daemons/ipa-kpasswd/Makefile.am
index ce241ca06a67f36500309c46a3ef75b8fb39e6b2..40e8c58f06fdb3a1e86284e5e13a2deef9359a29 100644
--- a/daemons/ipa-kpasswd/Makefile.am
+++ b/daemons/ipa-kpasswd/Makefile.am
@@ -8,6 +8,7 @@ INCLUDES =							\
 	-DLIBDIR=\""$(libdir)"\" 				\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
+	$(AM_CFLAGS)						\
 	$(OPENLDAP_CFLAGS)						\
 	$(KRB5_CFLAGS)						\
 	$(WARN_CFLAGS)						\
diff --git a/daemons/ipa-slapi-plugins/ipa-enrollment/Makefile.am b/daemons/ipa-slapi-plugins/ipa-enrollment/Makefile.am
index fc3c55cca95c3aba0abf20a6f4c4e63ba80a5c4e..d041815a2693a990431e2f42d22d0ae6ad5024fa 100644
--- a/daemons/ipa-slapi-plugins/ipa-enrollment/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-enrollment/Makefile.am
@@ -11,6 +11,7 @@ INCLUDES =							\
 	-DLIBDIR=\""$(libdir)"\" 				\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
+	$(AM_CFLAGS)						\
 	$(MOZLDAP_CFLAGS)					\
 	$(KRB5_CFLAGS)						\
 	$(WARN_CFLAGS)						\
diff --git a/daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am b/daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am
index 3b0ff629730e49244433dd85f9ca6fdb6211d838..b7986874822690422f015b1d39454c2ed9995340 100644
--- a/daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-modrdn/Makefile.am
@@ -12,6 +12,7 @@ INCLUDES =							\
 	-DLIBDIR=\""$(libdir)"\" 				\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
+	$(AM_CFLAGS)						\
 	$(MOZLDAP_CFLAGS)					\
 	$(WARN_CFLAGS)						\
 	$(NULL)
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
index 3577e48cc050a5d96987886b466f3b1ead71a646..6f6092d2080e97e7b2985b524145a360576f1d5c 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
@@ -11,6 +11,7 @@ INCLUDES =							\
 	-DLIBDIR=\""$(libdir)"\" 				\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
+	$(AM_CFLAGS)						\
 	$(MOZLDAP_CFLAGS)					\
 	$(KRB5_CFLAGS)						\
 	$(SSL_CFLAGS)						\
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am b/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
index 1e5d9793779a43c0d23f34ae1dc69824af1a1c9e..7c3709b5a4d88f48e46aa67cfc054aa01e1a5599 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
@@ -12,6 +12,7 @@ INCLUDES =							\
 	-DLIBDIR=\""$(libdir)"\" 				\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
+	$(AM_CFLAGS)						\
 	$(MOZLDAP_CFLAGS)					\
 	$(WARN_CFLAGS)						\
 	$(NULL)
diff --git a/daemons/ipa-slapi-plugins/ipa-version/Makefile.am b/daemons/ipa-slapi-plugins/ipa-version/Makefile.am
index f90543ee426438820356541041c2480a5808ea95..d26a7d24eca5f4ca6de6e7906e462d165b657d14 100644
--- a/daemons/ipa-slapi-plugins/ipa-version/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-version/Makefile.am
@@ -13,6 +13,7 @@ INCLUDES =							\
 	-DLIBDIR=\""$(libdir)"\" 				\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
+	$(AM_CFLAGS)						\
 	$(MOZLDAP_CFLAGS)					\
 	$(KRB5_CFLAGS)						\
 	$(WARN_CFLAGS)						\
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am b/daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am
index 79c37becb4bf8e62e91ce87c5333623de5421d31..82a934a220598399569e6cb9ad80c5b9e751b365 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/Makefile.am
@@ -11,6 +11,7 @@ INCLUDES =							\
 	-DLIBDIR=\""$(libdir)"\" 				\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
+	$(AM_CFLAGS)						\
 	$(MOZLDAP_CFLAGS)					\
 	$(WARN_CFLAGS)						\
 	$(NULL)
diff --git a/ipa-client/Makefile.am b/ipa-client/Makefile.am
index 2fc45be259bc9e9793dd71c7cbe43fabb7868ad4..655a686649ae169af4bd174f21569be564d9c4ad 100644
--- a/ipa-client/Makefile.am
+++ b/ipa-client/Makefile.am
@@ -4,6 +4,14 @@ AUTOMAKE_OPTIONS = 1.7
 
 NULL =
 
+AM_CFLAGS = $(NULL)
+if HAVE_GCC
+    AM_CFLAGS += -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith \
+		-Wcast-align -Werror-implicit-function-declaration \
+		$(NULL)
+endif
+export AM_CFLAGS
+
 INCLUDES =							\
 	-I.							\
 	-I$(srcdir)						\
@@ -13,6 +21,7 @@ INCLUDES =							\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
 	-DLOCALEDIR=\""$(localedir)"\"				\
+	$(AM_CFLAGS)						\
 	$(KRB5_CFLAGS)						\
 	$(OPENLDAP_CFLAGS)					\
 	$(MOZLDAP_CFLAGS)					\
diff --git a/ipa-client/configure.ac b/ipa-client/configure.ac
index bfa77cefafac78b66c33f159a302cf03dbe1f577..95becd352f54c4b33dd0d3e007cccadb363be52d 100644
--- a/ipa-client/configure.ac
+++ b/ipa-client/configure.ac
@@ -19,6 +19,8 @@ AC_DISABLE_STATIC
 
 AC_HEADER_STDC
 
+AM_CONDITIONAL([HAVE_GCC], [test "$ac_cv_prog_gcc" = yes])
+
 AC_SUBST(VERSION)
 
 dnl ---------------------------------------------------------------------------
-- 
1.7.3.2

-------------- next part --------------
>From 6bb0c68aae485275b6acdf1dbbb8054fc1004c1d Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Thu, 4 Nov 2010 19:29:01 +0100
Subject: [PATCH 3/6] Use internal implementation of internal Kerberos functions

Don't use KRB5_PRIVATE.

The patch implements and uses the following krb5 functions that are
otherwise private in recent MIT Kerberos releases:
 * krb5_principal2salt_norealm
 * krb5_free_ktypes
---
 .../ipa-slapi-plugins/ipa-pwd-extop/Makefile.am    |    4 ++
 daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h   |    1 -
 .../ipa-pwd-extop/ipapwd_encoding.c                |    3 +-
 ipa-client/Makefile.am                             |    5 ++
 ipa-client/ipa-getkeytab.c                         |   10 +++--
 util/ipa_krb5.c                                    |   46 ++++++++++++++++++++
 util/ipa_krb5.h                                    |   12 +++++
 7 files changed, 75 insertions(+), 6 deletions(-)
 create mode 100644 util/ipa_krb5.c
 create mode 100644 util/ipa_krb5.h

diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
index 6f6092d2080e97e7b2985b524145a360576f1d5c..41d9f237850a485371a60722d8ad54e4dab133ef 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
@@ -1,11 +1,14 @@
 NULL =
 
 PLUGIN_COMMON_DIR=../common
+KRB5_UTIL_DIR= ../../../util
+KRB5_UTIL_SRCS=$(KRB5_UTIL_DIR)/ipa_krb5.c
 
 INCLUDES =							\
 	-I.							\
 	-I$(srcdir)						\
 	-I$(PLUGIN_COMMON_DIR)					\
+	-I$(KRB5_UTIL_DIR)					\
 	-DPREFIX=\""$(prefix)"\" 				\
 	-DBINDIR=\""$(bindir)"\"				\
 	-DLIBDIR=\""$(libdir)"\" 				\
@@ -28,6 +31,7 @@ libipa_pwd_extop_la_SOURCES = 		\
 	ipapwd_encoding.c		\
 	ipapwd_prepost.c		\
 	ipa_pwd_extop.c			\
+	$(KRB5_UTIL_SRCS)		\
 	$(NULL)
 
 libipa_pwd_extop_la_LDFLAGS = -avoid-version
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
index 523934ccdc46217b92b64b0f9ee57ef044b21a7c..bc521071e908cbc4f4288fcb3542372ca79e26ba 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
@@ -52,7 +52,6 @@
 #include <prio.h>
 #include <ssl.h>
 #include <dirsrv/slapi-plugin.h>
-#define KRB5_PRIVATE 1
 #include <krb5.h>
 #include <lber.h>
 #include <time.h>
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
index 451350163fe820d5a9ed6ff2494461ece3e7e1d8..bba6367730821900fd6dbca43b48dfa013627eac 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
@@ -54,6 +54,7 @@
 
 #include "ipapwd.h"
 #include "util.h"
+#include "ipa_krb5.h"
 
 /* krbTicketFlags */
 #define KTF_DISALLOW_POSTDATED        0x00000001
@@ -341,7 +342,7 @@ static Slapi_Value **encrypt_encode_key(struct ipapwd_krbcfg *krbcfg,
 
         case KRB5_KDB_SALTTYPE_NOREALM:
 
-            krberr = krb5_principal2salt_norealm(krbctx, princ, &salt);
+            krberr = ipa_krb5_principal2salt_norealm(krbctx, princ, &salt);
             if (krberr) {
                 LOG_FATAL("krb5_principal2salt failed [%s]\n",
                           krb5_get_error_message(krbctx, krberr));
diff --git a/ipa-client/Makefile.am b/ipa-client/Makefile.am
index 655a686649ae169af4bd174f21569be564d9c4ad..ebb9a8392585985cbf4b232e388bca575a3e1c66 100644
--- a/ipa-client/Makefile.am
+++ b/ipa-client/Makefile.am
@@ -12,9 +12,13 @@ if HAVE_GCC
 endif
 export AM_CFLAGS
 
+KRB5_UTIL_DIR=../util
+KRB5_UTIL_SRCS=$(KRB5_UTIL_DIR)/ipa_krb5.c
+
 INCLUDES =							\
 	-I.							\
 	-I$(srcdir)						\
+	-I$(KRB5_UTIL_DIR)					\
 	-DPREFIX=\""$(prefix)"\" 				\
 	-DBINDIR=\""$(bindir)"\"				\
 	-DLIBDIR=\""$(libdir)"\" 				\
@@ -38,6 +42,7 @@ sbin_PROGRAMS =			\
 
 ipa_getkeytab_SOURCES =		\
 	ipa-getkeytab.c		\
+	$(KRB5_UTIL_SRCS)	\
 	$(NULL)
 
 ipa_getkeytab_LDADD = 		\
diff --git a/ipa-client/ipa-getkeytab.c b/ipa-client/ipa-getkeytab.c
index a54c57c7e662cb558c02d9527e7214f17783423f..8588652691d54cef34259d7377c9d79750373e52 100644
--- a/ipa-client/ipa-getkeytab.c
+++ b/ipa-client/ipa-getkeytab.c
@@ -27,10 +27,10 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <string.h>
 #include <errno.h>
 #include <time.h>
-#define KRB5_PRIVATE 1
 #include <krb5.h>
 #ifdef WITH_MOZLDAP
 #include <mozldap/ldap.h>
@@ -44,6 +44,8 @@
 #include <libintl.h>
 #define _(STRING) gettext(STRING)
 
+#include "ipa_krb5.h"
+
 /* Salt types */
 #define NO_SALT                        -1
 #define KRB5_KDB_SALTTYPE_NORMAL        0
@@ -152,7 +154,7 @@ static int prep_ksdata(krb5_context krbctx, const char *str,
             ksdata[i].salttype = KRB5_KDB_SALTTYPE_NORMAL;
         }
 
-        krb5_free_ktypes(krbctx, ktypes);
+        ipa_krb5_free_ktypes(krbctx, ktypes);
 
         nkeys = i;
 
@@ -322,7 +324,7 @@ static int create_keys(krb5_context krbctx,
             break;
 
         case KRB5_KDB_SALTTYPE_NOREALM:
-            krberr = krb5_principal2salt_norealm(krbctx, princ, &ksdata[i].salt);
+            krberr = ipa_krb5_principal2salt_norealm(krbctx, princ, &ksdata[i].salt);
             if (krberr) {
                 fprintf(stderr, _("Failed to create key!\n"));
                 return 0;
@@ -848,7 +850,7 @@ int main(int argc, char *argv[])
 			}
 			fprintf(stdout, "%s\n", enc);
 		}
-		krb5_free_ktypes(krbctx, ktypes);
+		ipa_krb5_free_ktypes(krbctx, ktypes);
 		exit (0);
 	}
 
diff --git a/util/ipa_krb5.c b/util/ipa_krb5.c
new file mode 100644
index 0000000000000000000000000000000000000000..e2cf201b54f74297ed312bd166418b7049c8a8db
--- /dev/null
+++ b/util/ipa_krb5.c
@@ -0,0 +1,46 @@
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "ipa_krb5.h"
+
+void
+ipa_krb5_free_ktypes(krb5_context context, krb5_enctype *val)
+{
+    free(val);
+}
+
+/*
+ * Convert a krb5_principal into the default salt for that principal.
+ */
+krb5_error_code
+ipa_krb5_principal2salt_norealm(krb5_context context, krb5_const_principal pr, krb5_data *ret)
+{
+    unsigned int size = 0, offset=0;
+    krb5_int32 nelem;
+    register int i;
+
+    if (pr == NULL) {
+        ret->length = 0;
+        ret->data = NULL;
+        return 0;
+    }
+
+    nelem = krb5_princ_size(context, pr);
+
+    for (i = 0; i < (int) nelem; i++)
+        size += krb5_princ_component(context, pr, i)->length;
+
+    ret->length = size;
+    if (!(ret->data = malloc (size)))
+        return ENOMEM;
+
+    for (i = 0; i < (int) nelem; i++) {
+        memcpy(&ret->data[offset], krb5_princ_component(context, pr, i)->data,
+               krb5_princ_component(context, pr, i)->length);
+        offset += krb5_princ_component(context, pr, i)->length;
+    }
+    return 0;
+}
+
+
diff --git a/util/ipa_krb5.h b/util/ipa_krb5.h
new file mode 100644
index 0000000000000000000000000000000000000000..09f492ea13ec76f44e3aad5b012e3847bc9a9420
--- /dev/null
+++ b/util/ipa_krb5.h
@@ -0,0 +1,12 @@
+#ifndef __IPA_KRB5_H_
+#define __IPA_KRB5_H_
+
+#include <krb5.h>
+
+void
+ipa_krb5_free_ktypes(krb5_context context, krb5_enctype *val);
+
+krb5_error_code
+ipa_krb5_principal2salt_norealm(krb5_context context, krb5_const_principal pr, krb5_data *ret);
+
+#endif /* __IPA_KRB5_H_ */
-- 
1.7.3.2

-------------- next part --------------
>From 91eed393b0e0313f6d03c82e6ebb9c19fd1afd86 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Thu, 4 Nov 2010 19:41:12 +0100
Subject: [PATCH 4/6] Don't use deprecated ldap_bind_s

ldap_bind_s is marked as deprecated in new libldap releases.
---
 ipa-client/ipa-getkeytab.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/ipa-client/ipa-getkeytab.c b/ipa-client/ipa-getkeytab.c
index 8588652691d54cef34259d7377c9d79750373e52..19f8b21d663de5c28bec19e282985f70fcc6197a 100644
--- a/ipa-client/ipa-getkeytab.c
+++ b/ipa-client/ipa-getkeytab.c
@@ -58,6 +58,10 @@
 #define KEYTAB_SET_OID "2.16.840.1.113730.3.8.3.1"
 #define KEYTAB_RET_OID "2.16.840.1.113730.3.8.3.2"
 
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#endif
+
 struct krb_key_salt {
     krb5_enctype enctype;
     krb5_int32 salttype;
@@ -576,7 +580,13 @@ static int ldap_set_keytab(krb5_context krbctx,
 	}
 
 	if (binddn) {
-		ret = ldap_bind_s(ld, binddn, bindpw, LDAP_AUTH_SIMPLE);
+                struct berval bv;
+
+                bv.bv_val = discard_const(bindpw);
+                bv.bv_len = strlen(bindpw);
+
+                ret = ldap_sasl_bind_s(ld, binddn, LDAP_SASL_SIMPLE, &bv,
+                                       NULL, NULL, NULL);
 		if (ret != LDAP_SUCCESS) {
 			fprintf(stderr, _("Simple bind failed\n"));
 			goto error_out;
-- 
1.7.3.2

-------------- next part --------------
>From 57ae09159e803cc7ae3e53755a17abbc9139d46e Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 3 Nov 2010 16:54:44 +0100
Subject: [PATCH 5/6] Silence compilation warnings in SLAPI plugins

---
 daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c  |   27 +++++++----------
 .../ipa-pwd-extop/ipa_pwd_extop.c                  |    2 +-
 .../ipa-pwd-extop/ipapwd_common.c                  |   32 +++++---------------
 .../ipa-pwd-extop/ipapwd_encoding.c                |   14 ++++++++
 .../ipa-pwd-extop/ipapwd_prepost.c                 |    3 +-
 daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c      |   21 +++++-------
 .../ipa-winsync/ipa-winsync-config.c               |    3 +-
 .../ipa-slapi-plugins/ipa-winsync/ipa-winsync.c    |    6 ++-
 .../ipa-slapi-plugins/ipa-winsync/ipa-winsync.h    |    5 ++-
 9 files changed, 54 insertions(+), 59 deletions(-)

diff --git a/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c b/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
index 1e094f1d0eebb258bd9cd72450eefb09294f8598..5a0cef57311cb0b5da53315a8554d0876a2ca5f8 100644
--- a/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
+++ b/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
@@ -111,9 +111,9 @@ static int ipamodrdn_close(Slapi_PBlock * pb);
  * Local operation functions
  *
  */
-static int ipamodrdn_load_plugin_config();
+static int ipamodrdn_load_plugin_config(void);
 static int ipamodrdn_parse_config_entry(Slapi_Entry * e, bool apply);
-static void ipamodrdn_delete_config();
+static void ipamodrdn_delete_config(void);
 static void ipamodrdn_free_config_entry(struct configEntry ** entry);
 
 /**
@@ -135,7 +135,7 @@ static int ipamodrdn_post_op(Slapi_PBlock * pb);
 /**
  * debug functions - global, for the debugger
  */
-void ipamodrdn_dump_config();
+void ipamodrdn_dump_config(void);
 void ipamodrdn_dump_config_entry(struct configEntry *);
 
 /**
@@ -143,17 +143,17 @@ void ipamodrdn_dump_config_entry(struct configEntry *);
  * Deal with cache locking
  *
  */
-void ipamodrdn_read_lock()
+void ipamodrdn_read_lock(void)
 {
     PR_RWLock_Rlock(g_ipamodrdn_cache_lock);
 }
 
-void ipamodrdn_write_lock()
+void ipamodrdn_write_lock(void)
 {
     PR_RWLock_Wlock(g_ipamodrdn_cache_lock);
 }
 
-void ipamodrdn_unlock()
+void ipamodrdn_unlock(void)
 {
     PR_RWLock_Unlock(g_ipamodrdn_cache_lock);
 }
@@ -163,7 +163,7 @@ void ipamodrdn_unlock()
  * Get the plug-in version
  *
  */
-int ipamodrdn_version()
+int ipamodrdn_version(void)
 {
     return IPAMODRDN_PLUGIN_VERSION;
 }
@@ -176,7 +176,7 @@ void setPluginID(void *pluginID)
     _PluginID = pluginID;
 }
 
-void *getPluginID()
+void *getPluginID(void)
 {
     return _PluginID;
 }
@@ -186,7 +186,7 @@ void setPluginDN(char *pluginDN)
     _PluginDN = pluginDN;
 }
 
-char *getPluginDN()
+char *getPluginDN(void)
 {
     return _PluginDN;
 }
@@ -330,12 +330,11 @@ ipamodrdn_close(Slapi_PBlock * pb)
  * ------ cn=etc etc
  */
 static int
-ipamodrdn_load_plugin_config()
+ipamodrdn_load_plugin_config(void)
 {
     int status = EOK;
     int result;
     int i;
-    time_t now;
     Slapi_PBlock *search_pb;
     Slapi_Entry **entries = NULL;
 
@@ -399,7 +398,6 @@ ipamodrdn_parse_config_entry(Slapi_Entry * e, bool apply)
     struct configEntry *config_entry;
     PRCList *list;
     int entry_added = 0;
-    int i = 0;
     int ret = EOK;
 
     LOG_TRACE("--in-->\n");
@@ -512,7 +510,6 @@ ipamodrdn_parse_config_entry(Slapi_Entry * e, bool apply)
                 break;
             }
 
-          next:
             list = PR_NEXT_LINK(list);
 
             if (ipamodrdn_global_config == list) {
@@ -594,7 +591,7 @@ ipamodrdn_delete_configEntry(PRCList *entry)
 }
 
 static void
-ipamodrdn_delete_config()
+ipamodrdn_delete_config(void)
 {
     PRCList *list;
 
@@ -710,8 +707,6 @@ static int ipamodrdn_post_op(Slapi_PBlock *pb)
     struct slapi_entry *e = NULL;
     Slapi_Attr *sattr = NULL;
     Slapi_Attr *tattr = NULL;
-    char *value = NULL;
-    char *errstr = NULL;
     int ret = LDAP_SUCCESS;
 
     LOG_TRACE("--in-->\n");
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
index 8df766e03b0613805f6bba1cb5b4ca24dc94b471..f347eef2d11898b38274d3c76961c5d5720a4e0d 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
@@ -916,7 +916,7 @@ static int ipapwd_setkeytab(Slapi_PBlock *pb, struct ipapwd_krbcfg *krbcfg)
 
 	if (ret != -1) {
 		struct berval *bvp;
-		LDAPControl new_ctrl = {0};
+		LDAPControl new_ctrl;
 
 		ret = ber_flatten(ber, &bvp);
 		if (ret == -1) {
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c
index 92c388a259c1caaa80779bbf005063b0fe1b48e0..99ade1211e49601bc1c977bf8d4ee4b18213d3db 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c
@@ -535,20 +535,6 @@ static Slapi_Value *ipapwd_strip_pw_date(Slapi_Value *pw)
     return slapi_value_new_string(&pwstr[GENERALIZED_TIME_LENGTH]);
 }
 
-/* ascii hex output of bytes in "in"
- * out len is 32 (preallocated)
- * in len is 16 */
-static const char hexchars[] = "0123456789ABCDEF";
-void hexbuf(char *out, const uint8_t *in)
-{
-    int i;
-
-    for (i = 0; i < 16; i++) {
-        out[i*2] = hexchars[in[i] >> 4];
-        out[i*2+1] = hexchars[in[i] & 0x0f];
-    }
-}
-
 /* searches the directory and finds the policy closest to the DN */
 /* return 0 on success, -1 on error or if no policy is found */
 static int ipapwd_sv_pw_cmp(const void *pv1, const void *pv2)
@@ -564,7 +550,7 @@ static int ipapwd_sv_pw_cmp(const void *pv1, const void *pv2)
 
 int ipapwd_entry_checks(Slapi_PBlock *pb, struct slapi_entry *e,
                         int *is_root, int *is_krb, int *is_smb,
-                        char *attr, int access)
+                        char *attr, int acc)
 {
     Slapi_Value *sval;
     int rc;
@@ -574,7 +560,7 @@ int ipapwd_entry_checks(Slapi_PBlock *pb, struct slapi_entry *e,
 
     if (!*is_root) {
         /* verify this user is allowed to write a user password */
-        rc = slapi_access_allowed(pb, e, attr, NULL, access);
+        rc = slapi_access_allowed(pb, e, attr, NULL, acc);
         if (rc != LDAP_SUCCESS) {
             /* we have no business here, the operation will be denied anyway */
             rc = LDAP_SUCCESS;
@@ -932,14 +918,14 @@ int ipapwd_CheckPolicy(struct ipapwd_data *data)
     ret = slapi_entry_attr_find(data->target,
                                 "passwordHistory", &passwordHistory);
     if (ret == 0) {
-        int ret, hint, count, i, j;
+        int err, hint, count, i, j;
         const char *pwstr;
         Slapi_Value **pH;
         Slapi_Value *pw;
 
         hint = 0;
         count = 0;
-        ret = slapi_attr_get_numvalues(passwordHistory, &count);
+        err = slapi_attr_get_numvalues(passwordHistory, &count);
         /* check history only if we have one */
         if (count > 0 && data->pwHistoryLen > 0) {
             pH = calloc(count + 2, sizeof(Slapi_Value *));
@@ -982,7 +968,7 @@ int ipapwd_CheckPolicy(struct ipapwd_data *data)
                 return LDAP_OPERATIONS_ERROR;
             }
 
-            ret = slapi_pw_find_sv(pH, pw);
+            err = slapi_pw_find_sv(pH, pw);
 
             for (j = 0; pH[j]; j++) {
                 slapi_value_free(&pH[j]);
@@ -990,7 +976,7 @@ int ipapwd_CheckPolicy(struct ipapwd_data *data)
             slapi_value_free(&pw);
             free(pH);
 
-            if (ret == 0) {
+            if (err == 0) {
                 LOG_TRACE("Password in history\n");
                 slapi_entry_free(policy);
                 return IPAPWD_POLICY_ERROR | LDAP_PWPOLICY_PWDINHISTORY;
@@ -1111,8 +1097,6 @@ int ipapwd_SetPassword(struct ipapwd_krbcfg *krbcfg,
     Slapi_Value **pwvals = NULL;
     struct tm utctime;
     char timestr[GENERALIZED_TIME_LENGTH+1];
-    krb5_context krbctx;
-    krb5_error_code krberr;
     char *lm = NULL;
     char *nt = NULL;
     int is_smb = 0;
@@ -1259,13 +1243,13 @@ Slapi_Value **ipapwd_setPasswordHistory(Slapi_Mods *smods,
     ret = slapi_entry_attr_find(data->target,
                                 "passwordHistory", &passwordHistory);
     if (ret == 0) {
-        int ret, hint, count, i, j;
+        int err, hint, count, i, j;
         const char *pwstr;
         Slapi_Value *pw;
 
         hint = 0;
         count = 0;
-        ret = slapi_attr_get_numvalues(passwordHistory, &count);
+        err = slapi_attr_get_numvalues(passwordHistory, &count);
         /* if we have one */
         if (count > 0 && data->pwHistoryLen > 0) {
             pH = calloc(count + 2, sizeof(Slapi_Value *));
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
index bba6367730821900fd6dbca43b48dfa013627eac..6746d63b628a4d8d1169eb9202e77dc38b8be2b5 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_encoding.c
@@ -112,6 +112,20 @@ void krb5int_c_free_keyblock_contents(krb5_context context,
 
  */
 
+/* ascii hex output of bytes in "in"
+ * out len is 32 (preallocated)
+ * in len is 16 */
+static const char hexchars[] = "0123456789ABCDEF";
+static void hexbuf(char *out, const uint8_t *in)
+{
+    int i;
+
+    for (i = 0; i < 16; i++) {
+        out[i*2] = hexchars[in[i] >> 4];
+        out[i*2+1] = hexchars[in[i] & 0x0f];
+    }
+}
+
 struct berval *encode_keys(struct ipapwd_keyset *kset)
 {
     BerElement *be = NULL;
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c
index 44b280bfd61f685ccf0a2e720648bc5b0e7d7372..281522f6a34415260278fc2377a5fd51a14d898f 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c
@@ -41,8 +41,10 @@
 #  include <config.h>
 #endif
 
+#define _XOPEN_SOURCE /* strptime needs this */
 #include <stdio.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -880,7 +882,6 @@ static int ipapwd_pre_bind(Slapi_PBlock *pb)
     Slapi_Value *value = NULL;
     Slapi_Attr *attr = NULL;
     struct tm expire_tm;
-    time_t expire_time;
     char *errMesg = "Internal operations error\n"; /* error message */
     char *expire = NULL; /* passwordExpirationTime attribute value */
     char *dn = NULL; /* bind DN */
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
index 1f6e5d30a53b35a21506b6fc1fc8aacf42827484..27e5e8e0786b99f0a9fbefca96f78ba77a041365 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
@@ -119,9 +119,9 @@ static int ipauuid_postop_init(Slapi_PBlock * pb);
  * Local operation functions
  *
  */
-static int ipauuid_load_plugin_config();
+static int ipauuid_load_plugin_config(void);
 static int ipauuid_parse_config_entry(Slapi_Entry * e, bool apply);
-static void ipauuid_delete_config();
+static void ipauuid_delete_config(void);
 static void ipauuid_free_config_entry(struct configEntry ** entry);
 
 /**
@@ -146,7 +146,7 @@ static int ipauuid_add_pre_op(Slapi_PBlock * pb);
 /**
  * debug functions - global, for the debugger
  */
-void ipauuid_dump_config();
+void ipauuid_dump_config(void);
 void ipauuid_dump_config_entry(struct configEntry *);
 
 /**
@@ -154,17 +154,17 @@ void ipauuid_dump_config_entry(struct configEntry *);
  * Deal with cache locking
  *
  */
-void ipauuid_read_lock()
+void ipauuid_read_lock(void)
 {
     PR_RWLock_Rlock(g_ipauuid_cache_lock);
 }
 
-void ipauuid_write_lock()
+void ipauuid_write_lock(void)
 {
     PR_RWLock_Wlock(g_ipauuid_cache_lock);
 }
 
-void ipauuid_unlock()
+void ipauuid_unlock(void)
 {
     PR_RWLock_Unlock(g_ipauuid_cache_lock);
 }
@@ -174,7 +174,7 @@ void ipauuid_unlock()
  * Get the plug-in version
  *
  */
-int ipauuid_version()
+int ipauuid_version(void)
 {
     return IPAUUID_PLUGIN_VERSION;
 }
@@ -187,7 +187,7 @@ void setPluginID(void *pluginID)
     _PluginID = pluginID;
 }
 
-void *getPluginID()
+void *getPluginID(void)
 {
     return _PluginID;
 }
@@ -197,7 +197,7 @@ void setPluginDN(char *pluginDN)
     _PluginDN = pluginDN;
 }
 
-char *getPluginDN()
+char *getPluginDN(void)
 {
     return _PluginDN;
 }
@@ -404,7 +404,6 @@ ipauuid_load_plugin_config()
     int status = EOK;
     int result;
     int i;
-    time_t now;
     Slapi_PBlock *search_pb;
     Slapi_Entry **entries = NULL;
 
@@ -468,7 +467,6 @@ ipauuid_parse_config_entry(Slapi_Entry * e, bool apply)
     struct configEntry *config_entry;
     PRCList *list;
     int entry_added = 0;
-    int i = 0;
     int ret = EOK;
 
     LOG_TRACE("--in-->\n");
@@ -571,7 +569,6 @@ ipauuid_parse_config_entry(Slapi_Entry * e, bool apply)
                 break;
             }
 
-          next:
             list = PR_NEXT_LINK(list);
 
             if (ipauuid_global_config == list) {
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c
index 5e762bc426b46993606661a6fdd267fca38013cc..88f6df359834bf5b0e54bf029dbf4f82a584448e 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c
@@ -59,7 +59,7 @@
 #endif
 #include "ipa-winsync.h"
 
-#include <string.h>
+#include "plstr.h"
 
 #define IPA_WINSYNC_CONFIG_FILTER "(objectclass=*)"
 
@@ -542,7 +542,6 @@ ipa_winsync_apply_config (Slapi_PBlock *pb, Slapi_Entry* entryBefore,
             PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
                         "Error: could not add value [%s] for attribute name "
                         "[%s] - ldap error [%d: %s]", val, attrsvals[ii],
-                        attrsvals[ii], IPA_WINSYNC_NEW_USER_ATTRS_VALS,
                         rc, ldap_err2string(rc));
             slapi_entry_free(theConfig.config_e);
             theConfig.config_e = NULL;
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c
index 4e2d534fc174657e02be1c0692de01f8745d4ba8..ecdda238f2fc1cd22be74845244e7eaecc19c43a 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c
@@ -59,6 +59,9 @@
 #endif
 #include "ipa-winsync.h"
 
+#include <string.h>
+#include "plstr.h"
+
 static void
 sync_acct_disable(
     void *cbdata, /* the usual domain config data */
@@ -224,7 +227,6 @@ ipa_winsync_pre_ds_add_user_cb(void *cbdata, const Slapi_Entry *rawentry,
     Slapi_Attr *attr = NULL;
     Slapi_Attr *e_attr = NULL;
     char *type = NULL;
-    IPA_WinSync_Config *global_ipaconfig = ipa_winsync_get_config();
 
     LOG("--> ipa_winsync_pre_ds_add_user_cb -- begin\n");
 
@@ -544,7 +546,7 @@ void ipa_winsync_set_plugin_identity(void * identity)
 	ipa_winsync_plugin_id=identity;
 }
 
-void * ipa_winsync_get_plugin_identity()
+void * ipa_winsync_get_plugin_identity(void)
 {
 	return ipa_winsync_plugin_id;
 }
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h
index 338e67cfb310e791f629c213c152553b666c1455..735f65684d2f545d743cc02dc10e7eccb58f1b58 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h
@@ -52,6 +52,9 @@
 #include <dirsrv/winsync-plugin.h>
 #endif /* WINSYNC_TEST_IPA */
 
+#include <string.h>
+#include <strings.h>
+
 #include "util.h"
 
 #define IPA_PLUGIN_NAME "ipa-winsync"
@@ -86,7 +89,7 @@ typedef struct ipa_winsync_domain_config {
 } IPA_WinSync_Domain_Config;
 
 void ipa_winsync_set_plugin_identity(void * identity);
-void * ipa_winsync_get_plugin_identity();
+void * ipa_winsync_get_plugin_identity(void);
 
 int ipa_winsync_config( Slapi_Entry *config_e );
 IPA_WinSync_Config *ipa_winsync_get_config( void );
-- 
1.7.3.2

-------------- next part --------------
>From 277ee471abeb953d160098219e89894d54491ed7 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Fri, 5 Nov 2010 09:36:00 +0100
Subject: [PATCH 6/6] ipa-client code cleanup

Fixes errors about implicit function declaration and moves duplicated
gettext code into a common module. Also silences some warnings.
---
 ipa-client/Makefile.am         |    3 ++
 ipa-client/config.c            |   30 ++----------------------
 ipa-client/ipa-client-common.c |   48 ++++++++++++++++++++++++++++++++++++++++
 ipa-client/ipa-client-common.h |    9 +++++++
 ipa-client/ipa-getkeytab.c     |   36 ++++-------------------------
 ipa-client/ipa-join.c          |   13 +---------
 ipa-client/ipa-rmkeytab.c      |   32 ++------------------------
 7 files changed, 73 insertions(+), 98 deletions(-)
 create mode 100644 ipa-client/ipa-client-common.c
 create mode 100644 ipa-client/ipa-client-common.h

diff --git a/ipa-client/Makefile.am b/ipa-client/Makefile.am
index ebb9a8392585985cbf4b232e388bca575a3e1c66..7d152fbfd38391a6ab6feb2f549086f19acf8d2a 100644
--- a/ipa-client/Makefile.am
+++ b/ipa-client/Makefile.am
@@ -42,6 +42,7 @@ sbin_PROGRAMS =			\
 
 ipa_getkeytab_SOURCES =		\
 	ipa-getkeytab.c		\
+	ipa-client-common.c	\
 	$(KRB5_UTIL_SRCS)	\
 	$(NULL)
 
@@ -55,6 +56,7 @@ ipa_getkeytab_LDADD = 		\
 
 ipa_rmkeytab_SOURCES =		\
 	ipa-rmkeytab.c		\
+	ipa-client-common.c	\
 	$(NULL)
 
 ipa_rmkeytab_LDADD = 		\
@@ -64,6 +66,7 @@ ipa_rmkeytab_LDADD = 		\
 
 ipa_join_SOURCES =		\
 	config.c		\
+	ipa-client-common.c	\
 	ipa-join.c		\
 	$(NULL)
 
diff --git a/ipa-client/config.c b/ipa-client/config.c
index 69bd9cb3398bea013928bfabc1810d21abd93524..31060e39f031b4d2586c521a9bdb167fac71fcce 100644
--- a/ipa-client/config.c
+++ b/ipa-client/config.c
@@ -39,8 +39,8 @@
 
 #include <errno.h>
 #include "config.h"
-#include <libintl.h>
-#define _(STRING) gettext(STRING)
+
+#include "ipa-client-common.h"
 
 char *
 read_config_file(const char *filename)
@@ -88,7 +88,7 @@ read_config_file(const char *filename)
 char *
 get_config_entry(char * in_data, const char *section, const char *key)
 {
-    char *ptr, *p, *tmp;
+    char *ptr = NULL, *p, *tmp;
     char *line;
     int in_section = 0;
     char * data;
@@ -164,27 +164,3 @@ get_config_entry(char * in_data, const char *section, const char *key)
     free(data);
     return NULL;
 }
-
-int init_gettext(void)
-{
-    char *c;
-
-    c = setlocale(LC_ALL, "");
-    if (!c) {
-        return EIO;
-    }
-
-    errno = 0;
-    c = bindtextdomain(PACKAGE, LOCALEDIR);
-    if (c == NULL) {
-        return errno;
-    }
-
-    errno = 0;
-    c = textdomain(PACKAGE);
-    if (c == NULL) {
-        return errno;
-    }
-
-    return 0;
-}
diff --git a/ipa-client/ipa-client-common.c b/ipa-client/ipa-client-common.c
new file mode 100644
index 0000000000000000000000000000000000000000..d7b62307840eed3d7cb30421be316bd0de7af53f
--- /dev/null
+++ b/ipa-client/ipa-client-common.c
@@ -0,0 +1,48 @@
+/* Authors: Jakub Hrozek <jhrozek at redhat.com>
+ *
+ * Copyright (C) 2010  Red Hat
+ * see file 'COPYING' for use and warranty information
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 only
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <locale.h>
+#include <libintl.h>
+#include <errno.h>
+
+#include "config.h"
+
+int init_gettext(void)
+{
+    char *c;
+
+    c = setlocale(LC_ALL, "");
+    if (!c) {
+        return EIO;
+    }
+
+    errno = 0;
+    c = bindtextdomain(PACKAGE, LOCALEDIR);
+    if (c == NULL) {
+        return errno;
+    }
+
+    errno = 0;
+    c = textdomain(PACKAGE);
+    if (c == NULL) {
+        return errno;
+    }
+
+    return 0;
+}
diff --git a/ipa-client/ipa-client-common.h b/ipa-client/ipa-client-common.h
new file mode 100644
index 0000000000000000000000000000000000000000..dbf474d526c161c9be0ae48d43a52659dc7e9f11
--- /dev/null
+++ b/ipa-client/ipa-client-common.h
@@ -0,0 +1,9 @@
+#ifndef __IPA_CLIENT_COMMON_H
+#define __IPA_CLIENT_COMMON_H
+
+#include <libintl.h>
+#define _(STRING) gettext(STRING)
+
+int init_gettext(void);
+
+#endif /* __IPA_CLIENT_COMMON_H */
diff --git a/ipa-client/ipa-getkeytab.c b/ipa-client/ipa-getkeytab.c
index 19f8b21d663de5c28bec19e282985f70fcc6197a..2f9d09bf8167aa4157f3873fd15627d5b836798b 100644
--- a/ipa-client/ipa-getkeytab.c
+++ b/ipa-client/ipa-getkeytab.c
@@ -41,10 +41,9 @@
 #include <popt.h>
 
 #include "config.h"
-#include <libintl.h>
-#define _(STRING) gettext(STRING)
 
 #include "ipa_krb5.h"
+#include "ipa-client-common.h"
 
 /* Salt types */
 #define NO_SALT                        -1
@@ -229,7 +228,7 @@ static int prep_ksdata(krb5_context krbctx, const char *str,
      * MIT code do anyway */
 
     for (i = 0, n = 0; i < nkeys; i++ ) {
-        int similar = 0;
+        krb5_boolean similar = 0;
 
         for (j = 0; j < i; j++) {
             krberr = krb5_c_enctype_compare(krbctx,
@@ -275,7 +274,7 @@ static int create_keys(krb5_context krbctx,
     krb5_error_code krberr;
     krb5_data key_password;
     krb5_data *realm;
-    int i, j, nkeys;
+    int i, nkeys;
     int ret;
 
     ret = prep_ksdata(krbctx, enctypes_string, keys);
@@ -751,31 +750,7 @@ static char *ask_password(krb5_context krbctx)
     return password;
 }
 
-int init_gettext(void)
-{
-    char *c;
-
-    c = setlocale(LC_ALL, "");
-    if (!c) {
-        return EIO;
-    }
-
-    errno = 0;
-    c = bindtextdomain(PACKAGE, LOCALEDIR);
-    if (c == NULL) {
-        return errno;
-    }
-
-    errno = 0;
-    c = textdomain(PACKAGE);
-    if (c == NULL) {
-        return errno;
-    }
-
-    return 0;
-}
-
-int main(int argc, char *argv[])
+int main(int argc, const char *argv[])
 {
 	static const char *server = NULL;
 	static const char *principal = NULL;
@@ -805,7 +780,7 @@ int main(int argc, char *argv[])
               _("Show the list of permitted encryption types and exit"),
               _("Permitted Encryption Types") },
 	    { "password", 'P', POPT_ARG_NONE, &askpass, 0,
-              _("Asks for a non-random password to use for the principal") },
+              _("Asks for a non-random password to use for the principal"), NULL },
 	    { "binddn", 'D', POPT_ARG_STRING, &binddn, 0,
               _("LDAP DN"), _("DN to bind as if not using kerberos") },
 	    { "bindpw", 'w', POPT_ARG_STRING, &bindpw, 0,
@@ -821,7 +796,6 @@ int main(int argc, char *argv[])
 	krb5_principal uprinc;
 	krb5_principal sprinc;
 	krb5_error_code krberr;
-	ber_int_t *enctypes;
 	struct keys_container keys;
 	krb5_keytab kt;
 	int kvno;
diff --git a/ipa-client/ipa-join.c b/ipa-client/ipa-join.c
index e67f29b810a09116519b9ef740f58ee4621cafed..01afa1ad03ab437f06bf5c0d6d9d19b32d2cca3f 100644
--- a/ipa-client/ipa-join.c
+++ b/ipa-client/ipa-join.c
@@ -38,8 +38,7 @@
 #include "xmlrpc-c/base.h"
 #include "xmlrpc-c/client.h"
 
-#include <libintl.h>
-#define _(STRING) gettext(STRING)
+#include "ipa-client-common.h"
 
 #define NAME "ipa-join"
 #define VERSION "1.0"
@@ -82,14 +81,6 @@ getIPAserver(char * data) {
     return get_config_entry(data, "global", "server");
 }
 
-/* Get the IPA realm from the configuration file.
- * The caller is responsible for freeing this value
- */
-static char *
-getIPArealm(char * data) {
-    return get_config_entry(data, "global", "realm");
-}
-
 /* Make sure that the keytab is writable before doing anything */
 static int check_perms(const char *keytab)
 {
@@ -951,7 +942,7 @@ cleanup:
  * unique (host already added).
  */
 int
-main(int argc, char **argv) {
+main(int argc, const char **argv) {
     static const char *hostname = NULL;
     static const char *server = NULL;
     static const char *keytab = NULL;
diff --git a/ipa-client/ipa-rmkeytab.c b/ipa-client/ipa-rmkeytab.c
index c46bb8b6ceb9b4618122666701fff93258f1d55f..1ccf673272e254f22dd95401225db3efdb559a9f 100644
--- a/ipa-client/ipa-rmkeytab.c
+++ b/ipa-client/ipa-rmkeytab.c
@@ -25,10 +25,8 @@
 #include <popt.h>
 #include <errno.h>
 
+#include "ipa-client-common.h"
 #include "config.h"
-#include <libintl.h>
-#define _(STRING) gettext(STRING)
-
 
 int
 remove_principal(krb5_context context, krb5_keytab ktid, const char *principal, int debug)
@@ -143,32 +141,8 @@ done:
     return rval;
 }
 
-int init_gettext(void)
-{
-    char *c;
-
-    c = setlocale(LC_ALL, "");
-    if (!c) {
-        return EIO;
-    }
-
-    errno = 0;
-    c = bindtextdomain(PACKAGE, LOCALEDIR);
-    if (c == NULL) {
-        return errno;
-    }
-
-    errno = 0;
-    c = textdomain(PACKAGE);
-    if (c == NULL) {
-        return errno;
-    }
-
-    return 0;
-}
-
 int
-main(int argc, char **argv)
+main(int argc, const char **argv)
 {
     krb5_context context;
     krb5_error_code krberr;
@@ -180,7 +154,7 @@ main(int argc, char **argv)
     static const char *principal = NULL;
     static const char *realm = NULL;
     int debug = 0;
-    int ret, rval;
+    int ret, rval = 0;
     struct poptOption options[] = {
         { "debug", 'd', POPT_ARG_NONE, &debug, 0,
           _("Print debugging information"), _("Debugging output") },
-- 
1.7.3.2



More information about the Freeipa-devel mailing list