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

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