summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2015-02-17 04:41:21 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-03-20 12:26:47 +0100
commit1d93029624d708119bbf803e6647a2cbb271f001 (patch)
treeec32405f56893f2e49adf8831e16106e7e51df89 /src/db
parent2bb92b969abc805be95f58ab5aafe9cde09e2238 (diff)
downloadsssd-1d93029624d708119bbf803e6647a2cbb271f001.tar.gz
sssd-1d93029624d708119bbf803e6647a2cbb271f001.tar.xz
sssd-1d93029624d708119bbf803e6647a2cbb271f001.zip
sdap: properly handle binary objectGuid attribute
Although in the initial processing SSSD treats the binary value right at some point it mainly assumes that it is a string. Depending on the value this might end up with the correct binary value stored in the cache but in most cases there will be only a broken entry in the cache. This patch converts the binary value into a string representation which is described in [MS-DTYP] and stores the result in the cache. Resolves https://fedorahosted.org/sssd/ticket/2588 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h6
-rw-r--r--src/db/sysdb_ops.c52
2 files changed, 58 insertions, 0 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 84c84a49f..2a3a2df98 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -1113,4 +1113,10 @@ errno_t sysdb_get_sids_of_members(TALLOC_CTX *mem_ctx,
const char ***_sids,
const char ***_dns,
size_t *_n);
+
+errno_t sysdb_handle_original_uuid(const char *orig_name,
+ struct sysdb_attrs *src_attrs,
+ const char *src_name,
+ struct sysdb_attrs *dest_attrs,
+ const char *dest_name);
#endif /* __SYS_DB_H__ */
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 183406ebe..8895b62c4 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -3691,3 +3691,55 @@ done:
talloc_free(tmp_ctx);
return ret;
}
+
+errno_t sysdb_handle_original_uuid(const char *orig_name,
+ struct sysdb_attrs *src_attrs,
+ const char *src_name,
+ struct sysdb_attrs *dest_attrs,
+ const char *dest_name)
+{
+ int ret;
+ struct ldb_message_element *el;
+ char guid_str_buf[GUID_STR_BUF_SIZE];
+
+ if (orig_name == NULL || src_attrs == NULL || src_name == NULL
+ || dest_attrs == NULL || dest_name == NULL) {
+ return EINVAL;
+ }
+
+ ret = sysdb_attrs_get_el_ext(src_attrs, src_name, false, &el);
+ if (ret != EOK) {
+ if (ret != ENOENT) {
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_el failed.\n");
+ }
+ return ret;
+ }
+
+ if (el->num_values != 1) {
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "Found more than one UUID value, using the first.\n");
+ }
+
+ /* Check if we got a binary AD objectGUID */
+ if (el->values[0].length == GUID_BIN_LENGTH
+ && strcasecmp(orig_name, "objectGUID") == 0) {
+ ret = guid_blob_to_string_buf(el->values[0].data, guid_str_buf,
+ GUID_STR_BUF_SIZE);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, "guid_blob_to_string_buf failed.\n");
+ return ret;
+ }
+
+ ret = sysdb_attrs_add_string(dest_attrs, dest_name, guid_str_buf);
+ } else {
+ ret = sysdb_attrs_add_string(dest_attrs, dest_name,
+ (const char *)el->values[0].data);
+ }
+
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_add_string failed.\n");
+ return ret;;
+ }
+
+ return EOK;
+}