summaryrefslogtreecommitdiffstats
path: root/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
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/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
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/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c')
-rw-r--r--daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c b/daemons/ipa-slapi-plugins/ipa-uuid/ipa_uuid.c
index 8455eed37..919abc821 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);