Blame SOURCES/0010-library-add-_adcli_ldap_parse_sid.patch

7ddab3
From bab08d90162c9146c1b4e8373f4b08209b84768c Mon Sep 17 00:00:00 2001
7ddab3
From: Sumit Bose <sbose@redhat.com>
7ddab3
Date: Tue, 30 Jan 2018 14:44:45 +0100
7ddab3
Subject: [PATCH 10/23] library: add _adcli_ldap_parse_sid()
7ddab3
7ddab3
Get a binary SID from a LDAP message and return it in the string
7ddab3
representation.
7ddab3
7ddab3
https://bugs.freedesktop.org/show_bug.cgi?id=100118
7ddab3
7ddab3
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
7ddab3
---
7ddab3
 library/adldap.c    | 24 ++++++++++++++++++++++++
7ddab3
 library/adprivate.h |  4 ++++
7ddab3
 2 files changed, 28 insertions(+)
7ddab3
7ddab3
diff --git a/library/adldap.c b/library/adldap.c
7ddab3
index 7c7a01b..07dc373 100644
7ddab3
--- a/library/adldap.c
7ddab3
+++ b/library/adldap.c
7ddab3
@@ -67,6 +67,30 @@ _adcli_ldap_handle_failure (LDAP *ldap,
7ddab3
 	return defres;
7ddab3
 }
7ddab3
 
7ddab3
+char *
7ddab3
+_adcli_ldap_parse_sid (LDAP *ldap,
7ddab3
+                         LDAPMessage *results,
7ddab3
+                         const char *attr_name)
7ddab3
+{
7ddab3
+	LDAPMessage *entry;
7ddab3
+	struct berval **bvs;
7ddab3
+	char *val = NULL;
7ddab3
+
7ddab3
+	entry = ldap_first_entry (ldap, results);
7ddab3
+	if (entry != NULL) {
7ddab3
+		bvs = ldap_get_values_len (ldap, entry, attr_name);
7ddab3
+		if (bvs != NULL) {
7ddab3
+			if (bvs[0]) {
7ddab3
+				val = _adcli_bin_sid_to_str ( (uint8_t *) bvs[0]->bv_val,
7ddab3
+				                              bvs[0]->bv_len);
7ddab3
+				return_val_if_fail (val != NULL, NULL);
7ddab3
+			}
7ddab3
+			ldap_value_free_len (bvs);
7ddab3
+		}
7ddab3
+	}
7ddab3
+
7ddab3
+	return val;
7ddab3
+}
7ddab3
 
7ddab3
 char *
7ddab3
 _adcli_ldap_parse_value (LDAP *ldap,
7ddab3
diff --git a/library/adprivate.h b/library/adprivate.h
7ddab3
index 7257c93..83a88f6 100644
7ddab3
--- a/library/adprivate.h
7ddab3
+++ b/library/adprivate.h
7ddab3
@@ -174,6 +174,10 @@ adcli_result  _adcli_ldap_handle_failure     (LDAP *ldap,
7ddab3
                                               const char *desc,
7ddab3
                                               ...) GNUC_PRINTF(3, 4);
7ddab3
 
7ddab3
+char *         _adcli_ldap_parse_sid         (LDAP *ldap,
7ddab3
+                                              LDAPMessage *results,
7ddab3
+                                              const char *attr_name);
7ddab3
+
7ddab3
 char *        _adcli_ldap_parse_value        (LDAP *ldap,
7ddab3
                                               LDAPMessage *results,
7ddab3
                                               const char *attr_name);
7ddab3
-- 
7ddab3
2.14.4
7ddab3