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

Jakub Hrozek jhrozek at redhat.com
Thu Nov 18 14:16:49 UTC 2010


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
> 
> [PATCH 2/6] Stricter compilation flags
> Use a little stricter compilation flags, in particular -Wall and treat
> implicit function declarations as errors.
> 
> [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
> 
> [PATCH 4/6] Don't use deprecated ldap_bind_s
> ldap_bind_s is marked as deprecated in new libldap releases.
> 
> [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.
> 
> [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.
> 
> Patches 3 - 6 fix https://fedorahosted.org/freeipa/ticket/454

Attached are patches rebased on top of current master, esp. the UUID
patch.
-------------- next part --------------
>From a89642497c219c93da7f94913364c73a7ab70a7f 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, 335 insertions(+), 447 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 0000000..8a7d518
--- /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 8a4ba09..fc3c55c 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 8a9906a..bc5551e 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 5770624..3b0ff62 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 72e16e9..1e094f1 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 6358ece..3577e48 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 ed9637a..8df766e 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 5b15622..523934c 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 514274e..92c388a 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 527e178..4513501 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 6636d61..44b280b 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 167a196..1e5d979 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 919abc8..58ef6e6 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
@@ -45,41 +45,20 @@
 #include "prclist.h"
 #include "uuid/uuid.h"
 
-#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
+#include "util.h"
 
 #define IPAUUID_STR_SIZE 36
 
-#ifndef discard_const
-#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#ifndef TEMP_TEMP_GET_A_DEFINE_FROM_389DS_TEAM
+int slapi_uniqueIDGenerateString(char **uId);
 #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 IPAUUID_PLUGIN_NAME "ipa-uuid-plugin"
+#define IPAUUID_PLUGIN_VERSION 0x00010000
 
-#define LOG_TRACE(fmt, ...) \
-    slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)
+#define IPAUUID_DN "cn=IPA UUID,cn=plugins,cn=config" /* temporary */
 
-#define LOG_OOM() LOG_FATAL("Out of Memory!\n")
+#define IPA_PLUGIN_NAME IPAUUID_PLUGIN_NAME
 
 /**
  * IPA UUID config types
@@ -235,7 +214,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 +260,7 @@ ipauuid_init(Slapi_PBlock *pb)
         )
         ) {
         LOG_FATAL("failed to register plugin\n");
-        status = IPAUUID_FAILURE;
+        status = EFAIL;
     }
 
     LOG_TRACE("<--out--\n");
@@ -291,7 +270,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 +280,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 +289,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 +304,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 +334,7 @@ ipauuid_start(Slapi_PBlock * pb)
     if (!g_ipauuid_cache_lock) {
         LOG_FATAL("lock creation failed\n");
 
-        return IPAUUID_FAILURE;
+        return EFAIL;
     }
 
     /**
@@ -381,9 +360,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 +370,7 @@ ipauuid_start(Slapi_PBlock * pb)
     LOG_TRACE("<--out--\n");
 
 done:
-    return IPAUUID_SUCCESS;
+    return EOK;
 }
 
 /*
@@ -410,7 +389,7 @@ ipauuid_close(Slapi_PBlock * pb)
 
     LOG_TRACE("<--out--\n");
 
-    return IPAUUID_SUCCESS;
+    return EOK;
 }
 
 /*
@@ -426,7 +405,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 +426,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 +461,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 +473,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 +500,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 +523,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 +540,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 +601,7 @@ bail:
         }
         ipauuid_free_config_entry(&entry);
     } else {
-        ret = IPAUUID_SUCCESS;
+        ret = EOK;
     }
 
     LOG_TRACE("<--out--\n");
@@ -886,7 +865,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 +1180,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 331ce7f..f90543e 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 a938001..e8c633b 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 94bc2dc..79c37be 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 45efa6d..5e762bc 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 9ee8805..4e2d534 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 58a9a6c..338e67c 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 bb01c43fa062e2ab5785aae741dafe92765996d9 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 9960789..7b2b997 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 53806f5..da86557 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 ce241ca..40e8c58 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 fc3c55c..d041815 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 3b0ff62..b798687 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 3577e48..6f6092d 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 1e5d979..7c3709b 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 f90543e..d26a7d2 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 79c37be..82a934a 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 2fc45be..655a686 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 bfa77ce..95becd3 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 60c03071911b474cb49dc4a7bbb88a0085c6a5df 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                |    1 +
 ipa-client/Makefile.am                             |    5 ++
 ipa-client/ipa-getkeytab.c                         |    4 +-
 util/ipa_krb5.c                                    |   46 ++++++++++++++++++++
 util/ipa_krb5.h                                    |   12 +++++
 7 files changed, 71 insertions(+), 2 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 6f6092d..41d9f23 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 523934c..bc52107 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 4513501..37002d3 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
diff --git a/ipa-client/Makefile.am b/ipa-client/Makefile.am
index 655a686..ebb9a83 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 a54c57c..8bdc6b6 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
diff --git a/util/ipa_krb5.c b/util/ipa_krb5.c
new file mode 100644
index 0000000..4311705
--- /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
+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
+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 == 0) {
+        ret->length = 0;
+        ret->data = 0;
+        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 0000000..7f00889
--- /dev/null
+++ b/util/ipa_krb5.h
@@ -0,0 +1,12 @@
+#ifndef __IPA_KRB5_H_
+#define __IPA_KRB5_H_
+
+#include <krb5.h>
+
+void
+krb5_free_ktypes(krb5_context context, krb5_enctype *val);
+
+krb5_error_code
+krb5_principal2salt_norealm(krb5_context context, krb5_const_principal pr, krb5_data *ret);
+
+#endif /* __IPA_KRB5_H_ */
-- 
1.7.3.2

-------------- next part --------------
>From 1254aba9d610c040202342f2191c00cc5e0d29e8 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 8bdc6b6..daf6f20 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 252743820f6e3f9179a88d4ecdadf1beed7625cd 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 +-
 daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h   |    1 +
 .../ipa-pwd-extop/ipapwd_common.c                  |   18 ++++++-------
 .../ipa-pwd-extop/ipapwd_prepost.c                 |    3 +-
 daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c      |   21 ++++++---------
 .../ipa-winsync/ipa-winsync-config.c               |   11 +++-----
 .../ipa-slapi-plugins/ipa-winsync/ipa-winsync.c    |   18 +++++++------
 .../ipa-slapi-plugins/ipa-winsync/ipa-winsync.h    |    5 +++-
 9 files changed, 50 insertions(+), 56 deletions(-)

diff --git a/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c b/daemons/ipa-slapi-plugins/ipa-modrdn/ipa_modrdn.c
index 1e094f1..5a0cef5 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 8df766e..f347eef 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.h b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
index bc52107..b9ad01f 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd.h
@@ -131,6 +131,7 @@ Slapi_Value **ipapwd_setPasswordHistory(Slapi_Mods *smods,
 int ipapwd_apply_mods(const char *dn, Slapi_Mods *mods);
 void ipapwd_free_slapi_value_array(Slapi_Value ***svals);
 void free_ipapwd_krbcfg(struct ipapwd_krbcfg **cfg);
+void hexbuf(char *out, const uint8_t *in);
 
 /* from ipapwd_encoding.c */
 struct ipapwd_krbkeydata {
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 92c388a..0e7f2aa 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_common.c
@@ -564,7 +564,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 +574,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 +932,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 +982,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 +990,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 +1111,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 +1257,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_prepost.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/ipapwd_prepost.c
index 44b280b..281522f 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 58ef6e6..b202806 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
@@ -123,9 +123,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);
 
 /**
@@ -150,7 +150,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 *);
 
 /**
@@ -158,17 +158,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);
 }
@@ -178,7 +178,7 @@ void ipauuid_unlock()
  * Get the plug-in version
  *
  */
-int ipauuid_version()
+int ipauuid_version(void)
 {
     return IPAUUID_PLUGIN_VERSION;
 }
@@ -191,7 +191,7 @@ void setPluginID(void *pluginID)
     _PluginID = pluginID;
 }
 
-void *getPluginID()
+void *getPluginID(void)
 {
     return _PluginID;
 }
@@ -201,7 +201,7 @@ void setPluginDN(char *pluginDN)
     _PluginDN = pluginDN;
 }
 
-char *getPluginDN()
+char *getPluginDN(void)
 {
     return _PluginDN;
 }
@@ -408,7 +408,6 @@ ipauuid_load_plugin_config()
     int status = EOK;
     int result;
     int i;
-    time_t now;
     Slapi_PBlock *search_pb;
     Slapi_Entry **entries = NULL;
 
@@ -472,7 +471,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");
@@ -575,7 +573,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 5e762bc..b5b1a4d 100644
--- a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c
+++ b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c
@@ -59,8 +59,6 @@
 #endif
 #include "ipa-winsync.h"
 
-#include <string.h>
-
 #define IPA_WINSYNC_CONFIG_FILTER "(objectclass=*)"
 
 /*
@@ -162,13 +160,13 @@ parse_acct_disable(const char *theval)
     if (!theval || !*theval) {
         return retval;
     }
-    if (!PL_strcasecmp(theval, IPA_WINSYNC_ACCT_DISABLE_NONE)) {
+    if (!strcasecmp(theval, IPA_WINSYNC_ACCT_DISABLE_NONE)) {
         retval = ACCT_DISABLE_NONE;
-    } else if (!PL_strcasecmp(theval, IPA_WINSYNC_ACCT_DISABLE_TO_AD)) {
+    } else if (!strcasecmp(theval, IPA_WINSYNC_ACCT_DISABLE_TO_AD)) {
         retval = ACCT_DISABLE_TO_AD;
-    } else if (!PL_strcasecmp(theval, IPA_WINSYNC_ACCT_DISABLE_TO_DS)) {
+    } else if (!strcasecmp(theval, IPA_WINSYNC_ACCT_DISABLE_TO_DS)) {
         retval = ACCT_DISABLE_TO_DS;
-    } else if (!PL_strcasecmp(theval, IPA_WINSYNC_ACCT_DISABLE_BOTH)) {
+    } else if (!strcasecmp(theval, IPA_WINSYNC_ACCT_DISABLE_BOTH)) {
         retval = ACCT_DISABLE_BOTH;
     }
 
@@ -542,7 +540,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 4e2d534..b16fb1e 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 <strings.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;
 }
@@ -644,7 +646,7 @@ ipa_check_account_lock(Slapi_Entry *ds_entry, int *isvirt)
     if (strval) { /* value is real */
         *isvirt = 0; /* value is real */
         rc = 1; /* default to enabled */
-        if (PL_strncasecmp(strval, "true", 4) == 0) {
+        if (strncasecmp(strval, "true", 4) == 0) {
             rc = 0; /* account is disabled */
         }
         slapi_ch_free_string(&strval);
@@ -668,7 +670,7 @@ ipa_check_account_lock(Slapi_Entry *ds_entry, int *isvirt)
         *isvirt = 1; /* value is virtual */
         if ((slapi_valueset_first_value(values, &v) != -1) &&
             (bvp = slapi_value_get_berval(v)) != NULL) {
-            if ( (bvp != NULL) && (PL_strncasecmp(bvp->bv_val, "true", 4) == 0) ) {
+            if ( (bvp != NULL) && (strncasecmp(bvp->bv_val, "true", 4) == 0) ) {
                 slapi_vattr_values_free(&values, &actual_type_name, attr_free_flags);
                 rc = 0; /* account is disabled */
             }
@@ -816,7 +818,7 @@ sync_acct_disable(
             struct berval *mod_bval = NULL;
             for (mod = slapi_mods_get_first_mod(smods); mod;
                  mod = slapi_mods_get_next_mod(smods)) {
-                if (!PL_strcasecmp(mod->mod_type, "userAccountControl") &&
+                if (!strcasecmp(mod->mod_type, "userAccountControl") &&
                     mod->mod_bvalues && mod->mod_bvalues[0]) {
                     mod_bval = mod->mod_bvalues[0];
                     /* mod_bval points directly to value inside mod list */
@@ -1033,7 +1035,7 @@ find_and_add_mod(Slapi_Entry *ent, Slapi_Mods *smods, const char *type,
              !found && mod;
              mod = slapi_mods_get_next_mod(smods)) {
             int ii;
-            if (PL_strcasecmp(mod->mod_type, type)) {
+            if (strcasecmp(mod->mod_type, type)) {
                 continue; /* skip - not a mod of this type */
             }
             if (!(mod->mod_op & (LDAP_MOD_ADD|LDAP_MOD_REPLACE))) {
@@ -1044,8 +1046,8 @@ find_and_add_mod(Slapi_Entry *ent, Slapi_Mods *smods, const char *type,
                  !found && mod->mod_bvalues && mod->mod_bvalues[ii];
                  ++ii) {
                 if (mod->mod_bvalues[ii]->bv_val) {
-                    found = !PL_strncasecmp(mod->mod_bvalues[ii]->bv_val,
-                                            val, vallen);
+                    found = !strncasecmp(mod->mod_bvalues[ii]->bv_val,
+                                         val, vallen);
                 }
             }
         }
diff --git a/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h b/daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h
index 338e67c..735f656 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 4431b3255d8abcc8d1eefffeb0ff4a12372c6677 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 ebb9a83..7d152fb 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 69bd9cb..31060e3 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 0000000..d7b6230
--- /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 0000000..dbf474d
--- /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 daf6f20..b396ab8 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 e67f29b..01afa1a 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 c46bb8b..1ccf673 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