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

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