summaryrefslogtreecommitdiffstats
path: root/src/util
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/util
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/util')
-rw-r--r--src/util/string_utils.c25
-rw-r--r--src/util/util.h7
2 files changed, 32 insertions, 0 deletions
diff --git a/src/util/string_utils.c b/src/util/string_utils.c
index a39b950e8..71b2a0920 100644
--- a/src/util/string_utils.c
+++ b/src/util/string_utils.c
@@ -83,3 +83,28 @@ char * sss_reverse_replace_space(TALLOC_CTX *mem_ctx,
return replace_char(mem_ctx, orig_name, subst, ' ');
}
+
+errno_t guid_blob_to_string_buf(const uint8_t *blob, char *str_buf,
+ size_t buf_size)
+{
+ int ret;
+
+ if (blob == NULL || str_buf == NULL || buf_size < GUID_STR_BUF_SIZE) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "Buffer too small.\n");
+ return EINVAL;
+ }
+
+ ret = snprintf(str_buf, buf_size,
+ "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ blob[3], blob[2], blob[1], blob[0],
+ blob[5], blob[4],
+ blob[7], blob[6],
+ blob[8], blob[9],
+ blob[10], blob[11],blob[12], blob[13],blob[14], blob[15]);;
+ if (ret != (GUID_STR_BUF_SIZE -1)) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "snprintf failed.\n");
+ return EIO;
+ }
+
+ return EOK;
+}
diff --git a/src/util/util.h b/src/util/util.h
index 829cf567a..704e10dc6 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -630,6 +630,13 @@ char * sss_reverse_replace_space(TALLOC_CTX *mem_ctx,
const char *orig_name,
const char replace_char);
+#define GUID_BIN_LENGTH 16
+/* 16 2-digit hex values + 4 dashes + terminating 0 */
+#define GUID_STR_BUF_SIZE (2 * GUID_BIN_LENGTH + 4 + 1)
+
+errno_t guid_blob_to_string_buf(const uint8_t *blob, char *str_buf,
+ size_t buf_size);
+
/* from become_user.c */
errno_t become_user(uid_t uid, gid_t gid);
struct sss_creds;