diff options
author | Sumit Bose <sbose@redhat.com> | 2016-12-22 11:15:17 +0100 |
---|---|---|
committer | Lukas Slebodnik <lslebodn@redhat.com> | 2017-01-21 20:13:56 +0100 |
commit | 0b78b4e32955ced0f35c6d4685bd277bb03d04cb (patch) | |
tree | fdcd7aa07a98b57c40b32e3d737fc7bd8acf2f34 /src/sss_client | |
parent | 51ce94d00a61f205ba727a3849835c269e568c41 (diff) | |
download | sssd-0b78b4e32955ced0f35c6d4685bd277bb03d04cb.tar.gz sssd-0b78b4e32955ced0f35c6d4685bd277bb03d04cb.tar.xz sssd-0b78b4e32955ced0f35c6d4685bd277bb03d04cb.zip |
libwbclient-sssd: wbcLookupSid() allow NULL arguments
Some caller might not be interested in some of the values wbcLookupSid()
returns and just pass NULL. Currently 'net ads user info' does this
because it is not interested in the domain. wbcLookupSid() should handle
this gracefully.
Resolves:
https://fedorahosted.org/sssd/ticket/3273
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/sss_client')
-rw-r--r-- | src/sss_client/libwbclient/wbc_sid_sssd.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/sss_client/libwbclient/wbc_sid_sssd.c b/src/sss_client/libwbclient/wbc_sid_sssd.c index cde65fa03..3736d4119 100644 --- a/src/sss_client/libwbclient/wbc_sid_sssd.c +++ b/src/sss_client/libwbclient/wbc_sid_sssd.c @@ -99,9 +99,9 @@ wbcErr wbcLookupName(const char *domain, /* Convert a SID to a domain and name */ wbcErr wbcLookupSid(const struct wbcDomainSid *sid, - char **pdomain, - char **pname, - enum wbcSidType *pname_type) + char **pdomain, + char **pname, + enum wbcSidType *pname_type) { char *str_sid; char *fq_name = NULL; @@ -121,10 +121,12 @@ wbcErr wbcLookupSid(const struct wbcDomainSid *sid, return WBC_ERR_UNKNOWN_FAILURE; } - ret = sss_id_type_to_wbcSidType(type, pname_type); - if (ret != 0) { - wbc_status = WBC_ERR_UNKNOWN_FAILURE; - goto done; + if (pname_type != NULL) { + ret = sss_id_type_to_wbcSidType(type, pname_type); + if (ret != 0) { + wbc_status = WBC_ERR_UNKNOWN_FAILURE; + goto done; + } } /* TODO: it would be nice to have a sss_nss_getnamebysid() call which @@ -136,17 +138,21 @@ wbcErr wbcLookupSid(const struct wbcDomainSid *sid, } *p = '\0'; - *pname = wbcStrDup(fq_name); - if (*pname == NULL) { - wbc_status = WBC_ERR_NO_MEMORY; - goto done; + if (pname != NULL) { + *pname = wbcStrDup(fq_name); + if (*pname == NULL) { + wbc_status = WBC_ERR_NO_MEMORY; + goto done; + } } - *pdomain = wbcStrDup(p + 1); - if (*pdomain == NULL) { - wbcFreeMemory(*pname); - wbc_status = WBC_ERR_NO_MEMORY; - goto done; + if (pdomain != NULL) { + *pdomain = wbcStrDup(p + 1); + if (*pdomain == NULL) { + wbcFreeMemory(*pname); + wbc_status = WBC_ERR_NO_MEMORY; + goto done; + } } wbc_status = WBC_ERR_SUCCESS; |