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

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