summaryrefslogtreecommitdiffstats
path: root/daemons
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-11-10 17:04:53 -0500
committerSimo Sorce <ssorce@redhat.com>2010-11-15 11:47:27 -0500
commit23f03251e06ea6795376f5a7bac0db3e6796a46b (patch)
tree35a2ff884ceeeb37e322fd06a61c694d13e443af /daemons
parentedf0f9b90188b0f55ce4a26351b7c356a7ae7086 (diff)
downloadfreeipa-23f03251e06ea6795376f5a7bac0db3e6796a46b.tar.gz
freeipa-23f03251e06ea6795376f5a7bac0db3e6796a46b.tar.xz
freeipa-23f03251e06ea6795376f5a7bac0db3e6796a46b.zip
uuid plugin: convert the plugin to use the libuuid library
The DS guys decided not to expose the DS inetrnal functions used to generate UUIDs for DS. This means the interface is not guaranteed to be available. Switch the ipa_uuid plugin to use the system libuuid plugin instead. NOTE: This causes once again a change in the tring format used for UUIDs. fixes: https://fedorahosted.org/freeipa/ticket/465
Diffstat (limited to 'daemons')
-rw-r--r--daemons/configure.ac8
-rw-r--r--daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am1
-rw-r--r--daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c30
3 files changed, 29 insertions, 10 deletions
diff --git a/daemons/configure.ac b/daemons/configure.ac
index b7ad33fe..53806f52 100644
--- a/daemons/configure.ac
+++ b/daemons/configure.ac
@@ -202,6 +202,14 @@ AC_CHECK_LIB(crypto, DES_set_key_unchecked, [SSL_LIBS="-lcrypto"])
AC_SUBST(SSL_LIBS)
dnl ---------------------------------------------------------------------------
+dnl - Check for UUID library
+dnl ---------------------------------------------------------------------------
+AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([uuid/uuid.h not found])])
+
+AC_CHECK_LIB(uuid, uuid_generate_time, [UUID_LIBS="-luuid"])
+AC_SUBST(UUID_LIBS)
+
+dnl ---------------------------------------------------------------------------
dnl - Check for Python
dnl ---------------------------------------------------------------------------
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am b/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
index 37bd9290..167a1963 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/Makefile.am
@@ -26,6 +26,7 @@ libipa_uuid_la_LDFLAGS = -avoid-version
libipa_uuid_la_LIBADD = \
$(MOZLDAP_LIBS) \
+ $(UUID_LIBS) \
$(NULL)
appdir = $(IPA_DATA_DIR)
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
index 8455eed3..919abc82 100644
--- a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
+++ b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
@@ -43,10 +43,7 @@
#include "slapi-plugin.h"
#include "nspr.h"
#include "prclist.h"
-
-#ifndef TEMP_TEMP_GET_A_DEFINE_FROM_389DS_TEAM
-int slapi_uniqueIDGenerateString(char **uId);
-#endif
+#include "uuid/uuid.h"
#define IPAUUID_PLUGIN_NAME "ipa-uuid-plugin"
#define IPAUUID_PLUGIN_VERSION 0x00010000
@@ -56,6 +53,8 @@ int slapi_uniqueIDGenerateString(char **uId);
#define IPAUUID_SUCCESS 0
#define IPAUUID_FAILURE -1
+#define IPAUUID_STR_SIZE 36
+
#ifndef discard_const
#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
#endif
@@ -760,6 +759,16 @@ ipauuid_list_contains_attr(char **list, char *attr)
return ret;
}
+/* this function must be passed a preallocated buffer of 37 characters in the
+ * out parameter */
+static void ipauuid_generate_uuid(char *out)
+{
+ uuid_t uu;
+
+ uuid_generate_time(uu);
+ uuid_unparse_lower(uu, out);
+}
+
/* for mods and adds:
where dn's are supplied, the closest in scope
is used as long as the type filter matches
@@ -1063,13 +1072,13 @@ static int ipauuid_pre_op(Slapi_PBlock *pb, int modtype)
char *new_value;
/* create the value to add */
- ret = slapi_uniqueIDGenerateString(&value);
- if (ret != 0) {
- errstr = slapi_ch_smprintf("Allocation of a new value for"
- " attr %s failed! Unable to "
- "proceed.", cfgentry->attr);
- break;
+ value = slapi_ch_calloc(1, IPAUUID_STR_SIZE + 1);
+ if (!value) {
+ LOG_OOM();
+ ret = LDAP_OPERATIONS_ERROR;
+ goto done;
}
+ ipauuid_generate_uuid(value);
if (cfgentry->prefix) {
new_value = slapi_ch_smprintf("%s%s",
@@ -1178,6 +1187,7 @@ done:
}
slapi_ch_array_free(generated_attrs);
+ slapi_ch_free_string(&value);
if (free_entry && e) {
slapi_entry_free(e);