diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/smbldap.c | 20 | ||||
-rw-r--r-- | source3/lib/util_sid.c | 16 | ||||
-rw-r--r-- | source3/lib/util_str.c | 7 | ||||
-rw-r--r-- | source3/lib/util_uuid.c | 4 |
4 files changed, 35 insertions, 12 deletions
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c index 4360d3ab57..b6921c329c 100644 --- a/source3/lib/smbldap.c +++ b/source3/lib/smbldap.c @@ -389,6 +389,26 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = { return result; } + bool smbldap_pull_sid(LDAP *ld, LDAPMessage *msg, const char *attrib, + struct dom_sid *sid) +{ + struct berval **values; + bool ret = False; + + values = ldap_get_values_len(ld, msg, attrib); + + if (!values) { + return false; + } + + if (values[0] != NULL) { + ret = sid_parse(values[0]->bv_val, values[0]->bv_len, sid); + } + + ldap_value_free_len(values); + return ret; +} + static int ldapmsg_destructor(LDAPMessage **result) { ldap_msgfree(*result); return 0; diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 97284afae7..9e5d4d38a5 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -520,16 +520,18 @@ bool non_mappable_sid(DOM_SID *sid) Caller must free. *****************************************************************/ -char *sid_binstring(const DOM_SID *sid) +char *sid_binstring(TALLOC_CTX *mem_ctx, const DOM_SID *sid) { - char *buf, *s; + uint8_t *buf; + char *s; int len = ndr_size_dom_sid(sid, NULL, 0); - buf = (char *)SMB_MALLOC(len); - if (!buf) + buf = talloc_array(mem_ctx, uint8_t, len); + if (!buf) { return NULL; - sid_linearize(buf, len, sid); - s = binary_string_rfc2254(buf, len); - free(buf); + } + sid_linearize((char *)buf, len, sid); + s = binary_string_rfc2254(mem_ctx, buf, len); + TALLOC_FREE(buf); return s; } diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 3a941f2c21..cdd7d0a300 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1529,14 +1529,15 @@ size_t strlen_m_term_null(const char *s) Caller must free. **/ -char *binary_string_rfc2254(char *buf, int len) +char *binary_string_rfc2254(TALLOC_CTX *mem_ctx, const uint8_t *buf, int len) { char *s; int i, j; const char *hex = "0123456789ABCDEF"; - s = (char *)SMB_MALLOC(len * 3 + 1); - if (!s) + s = talloc_array(mem_ctx, char, len * 3 + 1); + if (s == NULL) { return NULL; + } for (j=i=0;i<len;i++) { s[j] = '\\'; s[j+1] = hex[((unsigned char)buf[i]) >> 4]; diff --git a/source3/lib/util_uuid.c b/source3/lib/util_uuid.c index c681b66d34..656ba2a57c 100644 --- a/source3/lib/util_uuid.c +++ b/source3/lib/util_uuid.c @@ -43,11 +43,11 @@ void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu) Caller must free. *****************************************************************/ -char *guid_binstring(const struct GUID *guid) +char *guid_binstring(TALLOC_CTX *mem_ctx, const struct GUID *guid) { UUID_FLAT guid_flat; smb_uuid_pack(*guid, &guid_flat); - return binary_string_rfc2254((char *)guid_flat.info, UUID_FLAT_SIZE); + return binary_string_rfc2254(mem_ctx, guid_flat.info, UUID_FLAT_SIZE); } |