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
This commit is contained in:
Simo Sorce 2010-11-10 17:04:53 -05:00
parent edf0f9b901
commit 23f03251e0
4 changed files with 30 additions and 10 deletions

View File

@ -201,6 +201,14 @@ AC_CHECK_HEADER(openssl/des.h, [], [AC_MSG_ERROR([openssl/des.h not found])])
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 ---------------------------------------------------------------------------

View File

@ -26,6 +26,7 @@ libipa_uuid_la_LDFLAGS = -avoid-version
libipa_uuid_la_LIBADD = \
$(MOZLDAP_LIBS) \
$(UUID_LIBS) \
$(NULL)
appdir = $(IPA_DATA_DIR)

View File

@ -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);

View File

@ -47,6 +47,7 @@ BuildRequires: xmlrpc-c-devel
BuildRequires: libcurl-devel
BuildRequires: gettext
BuildRequires: authconfig
BuildRequires: libuuid-devel
%endif
%description