Blame 0010-library-add-_adcli_ldap_parse_sid.patch

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