libwbclient: wbc_create_error_info is always called with mem_ctx==NULL
[ira/wip.git] / nsswitch / libwbclient / wbc_sid.c
index 46c59a9513f88b7231857058861300fdbb52f2ae..7aab04b86f744e2174969446fc89d6939ac94065 100644 (file)
@@ -22,8 +22,9 @@
 
 /* Required Headers */
 
+#include "replace.h"
 #include "libwbclient.h"
-
+#include "../winbind_client.h"
 
 /* Convert a binary SID to a character string */
 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
@@ -247,9 +248,13 @@ wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
        if (WBC_ERROR_IS_OK(wbc_status)) {
                if (pdomain != NULL) {
                        *pdomain = domain;
+               } else {
+                       TALLOC_FREE(domain);
                }
                if (pname != NULL) {
                        *pname = name;
+               } else {
+                       TALLOC_FREE(name);
                }
                if (pname_type != NULL) {
                        *pname_type = name_type;
@@ -391,9 +396,7 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
        wbc_status = WBC_ERR_SUCCESS;
 
  done:
-       if (response.extra_data.data) {
-               free(response.extra_data.data);
-       }
+       winbindd_free_response(&response);
 
        if (WBC_ERROR_IS_OK(wbc_status)) {
                *pp_domain_name = domain_name;
@@ -481,9 +484,7 @@ wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
        wbc_status = WBC_ERR_SUCCESS;
 
  done:
-       if (response.extra_data.data) {
-               free(response.extra_data.data);
-       }
+       winbindd_free_response(&response);
        if (sids) {
                talloc_free(sids);
        }
@@ -619,9 +620,7 @@ wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid,
        if (extra_data) {
                talloc_free(extra_data);
        }
-       if (response.extra_data.data) {
-               free(response.extra_data.data);
-       }
+       winbindd_free_response(&response);
        if (rids) {
                talloc_free(rids);
        }
@@ -689,9 +688,7 @@ wbcErr wbcListUsers(const char *domain_name,
        wbc_status = WBC_ERR_SUCCESS;
 
  done:
-       if (response.extra_data.data) {
-               free(response.extra_data.data);
-       }
+       winbindd_free_response(&response);
        if (users) {
                talloc_free(users);
        }
@@ -757,9 +754,7 @@ wbcErr wbcListGroups(const char *domain_name,
        wbc_status = WBC_ERR_SUCCESS;
 
  done:
-       if (response.extra_data.data) {
-               free(response.extra_data.data);
-       }
+       winbindd_free_response(&response);
        if (groups) {
                talloc_free(groups);
        }
@@ -809,3 +804,20 @@ wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
 
        return wbc_status;
 }
+
+const char* wbcSidTypeString(enum wbcSidType type)
+{
+       switch (type) {
+       case WBC_SID_NAME_USE_NONE: return "SID_NONE";
+       case WBC_SID_NAME_USER:     return "SID_USER";
+       case WBC_SID_NAME_DOM_GRP:  return "SID_DOM_GROUP";
+       case WBC_SID_NAME_DOMAIN:   return "SID_DOMAIN";
+       case WBC_SID_NAME_ALIAS:    return "SID_ALIAS";
+       case WBC_SID_NAME_WKN_GRP:  return "SID_WKN_GROUP";
+       case WBC_SID_NAME_DELETED:  return "SID_DELETED";
+       case WBC_SID_NAME_INVALID:  return "SID_INVALID";
+       case WBC_SID_NAME_UNKNOWN:  return "SID_UNKNOWN";
+       case WBC_SID_NAME_COMPUTER: return "SID_COMPUTER";
+       default:                    return "Unknown type";
+       }
+}