summaryrefslogtreecommitdiff
path: root/source3/nsswitch/libwbclient
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-05 23:09:38 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-01-05 23:09:38 +0100
commitaaa27706664da2855c09da0691c3717b571edaba (patch)
tree17cc8a7475f7062eb664d0201d660c77bf415a7e /source3/nsswitch/libwbclient
parent3ba8fbef29aabfcd78e1170fcbfcf7bc943af6f9 (diff)
parent4a413e4bd177402a1697cffac43d35e94cc55102 (diff)
downloadsamba-aaa27706664da2855c09da0691c3717b571edaba.tar.gz
samba-aaa27706664da2855c09da0691c3717b571edaba.tar.bz2
samba-aaa27706664da2855c09da0691c3717b571edaba.zip
Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
(This used to be commit 5a30f6377d37d8a5cadce4fb9a2fc19b78fc1709)
Diffstat (limited to 'source3/nsswitch/libwbclient')
-rw-r--r--source3/nsswitch/libwbclient/wbc_pam.c4
-rw-r--r--source3/nsswitch/libwbclient/wbc_pwd.c8
-rw-r--r--source3/nsswitch/libwbclient/wbc_sid.c35
-rw-r--r--source3/nsswitch/libwbclient/wbc_util.c16
-rw-r--r--source3/nsswitch/libwbclient/wbclient.h2
5 files changed, 32 insertions, 33 deletions
diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c
index 1548c3344a..7f7c7b8140 100644
--- a/source3/nsswitch/libwbclient/wbc_pam.c
+++ b/source3/nsswitch/libwbclient/wbc_pam.c
@@ -31,7 +31,7 @@
* @return #wbcErr
**/
-wbcErr wbcAuthenticateUser(const char *username,
+wbcErr wbcAuthenticateUser(const char *username,
const char *password)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
@@ -61,5 +61,5 @@ wbcErr wbcAuthenticateUser(const char *username,
BAIL_ON_WBC_ERROR(wbc_status);
done:
- return wbc_status;
+ return wbc_status;
}
diff --git a/source3/nsswitch/libwbclient/wbc_pwd.c b/source3/nsswitch/libwbclient/wbc_pwd.c
index 4e3b0d3967..b24e198bc5 100644
--- a/source3/nsswitch/libwbclient/wbc_pwd.c
+++ b/source3/nsswitch/libwbclient/wbc_pwd.c
@@ -228,13 +228,14 @@ wbcErr wbcGetgrnam(const char *name, struct group **grp)
&response);
BAIL_ON_WBC_ERROR(wbc_status);
- *grp = copy_group_entry(&response.data.gr, response.extra_data.data);
+ *grp = copy_group_entry(&response.data.gr,
+ (char*)response.extra_data.data);
BAIL_ON_PTR_ERROR(*grp, wbc_status);
done:
if (response.extra_data.data)
free(response.extra_data.data);
-
+
return wbc_status;
}
@@ -270,7 +271,8 @@ wbcErr wbcGetgrgid(gid_t gid, struct group **grp)
&response);
BAIL_ON_WBC_ERROR(wbc_status);
- *grp = copy_group_entry(&response.data.gr, response.extra_data.data);
+ *grp = copy_group_entry(&response.data.gr,
+ (char*)response.extra_data.data);
BAIL_ON_PTR_ERROR(*grp, wbc_status);
done:
diff --git a/source3/nsswitch/libwbclient/wbc_sid.c b/source3/nsswitch/libwbclient/wbc_sid.c
index c877e1d9d4..abe1457cc1 100644
--- a/source3/nsswitch/libwbclient/wbc_sid.c
+++ b/source3/nsswitch/libwbclient/wbc_sid.c
@@ -265,12 +265,12 @@ wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
/* Copy out result */
if (domain != NULL) {
- *domain = strdup(response.data.name.dom_name);
+ *domain = talloc_strdup(NULL, response.data.name.dom_name);
BAIL_ON_PTR_ERROR((*domain), wbc_status);
}
if (name != NULL) {
- *name = strdup(response.data.name.name);
+ *name = talloc_strdup(NULL, response.data.name.name);
BAIL_ON_PTR_ERROR((*name), wbc_status);
}
@@ -283,9 +283,9 @@ wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
done:
if (!WBC_ERROR_IS_OK(wbc_status)) {
if (*domain)
- free(*domain);
+ talloc_free(*domain);
if (*name)
- free(*name);
+ talloc_free(*name);
}
return wbc_status;
@@ -334,11 +334,9 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
ridbuf_size = (sizeof(char)*11) * num_rids + 1;
- ridlist = malloc(ridbuf_size);
+ ridlist = talloc_zero_array(NULL, char, ridbuf_size);
BAIL_ON_PTR_ERROR(ridlist, wbc_status);
- memset(ridlist, 0x0, ridbuf_size);
-
len = 0;
for (i=0; i<num_rids && (len-1)>0; i++) {
char ridstr[12];
@@ -356,15 +354,15 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
wbc_status = wbcRequestResponse(WINBINDD_LOOKUPRIDS,
&request,
&response);
- free(ridlist);
+ talloc_free(ridlist);
- domain_name = strdup(response.data.domain_name);
+ domain_name = talloc_strdup(NULL, response.data.domain_name);
BAIL_ON_PTR_ERROR(domain_name, wbc_status);
- *names = (const char**)malloc(sizeof(char*) * num_rids);
+ *names = talloc_array(NULL, const char*, num_rids);
BAIL_ON_PTR_ERROR((*names), wbc_status);
- *types = (enum wbcSidType*)malloc(sizeof(enum wbcSidType) * num_rids);
+ *types = talloc_array(NULL, enum wbcSidType, num_rids);
BAIL_ON_PTR_ERROR((*types), wbc_status);
p = (char *)response.extra_data.data;
@@ -393,7 +391,8 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
*q = '\0';
- (*names)[i] = strdup(p);
+ (*names)[i] = talloc_strdup((*names), p);
+ BAIL_ON_PTR_ERROR(((*names)[i]), wbc_status);
p = q+1;
}
@@ -403,18 +402,20 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
BAIL_ON_WBC_ERROR(wbc_status);
}
- free(response.extra_data.data);
-
wbc_status = WBC_ERR_SUCCESS;
done:
+ if (response.extra_data.data) {
+ free(response.extra_data.data);
+ }
+
if (!WBC_ERROR_IS_OK(wbc_status)) {
if (domain_name)
- free(domain_name);
+ talloc_free(domain_name);
if (*names)
- free(*names);
+ talloc_free(*names);
if (*types)
- free(*types);
+ talloc_free(*types);
} else {
*pp_domain_name = domain_name;
}
diff --git a/source3/nsswitch/libwbclient/wbc_util.c b/source3/nsswitch/libwbclient/wbc_util.c
index c6acb27e55..ff3cec8689 100644
--- a/source3/nsswitch/libwbclient/wbc_util.c
+++ b/source3/nsswitch/libwbclient/wbc_util.c
@@ -51,10 +51,6 @@ wbcErr wbcPing(void)
*
* @return #wbcErr
*
- * The char* members of the struct wbcDomainInfo* are malloc()'d
- * and it the the responsibility of the caller to free the members
- * before discarding the struct.
- *
**/
@@ -64,7 +60,7 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
struct winbindd_response response;
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcDomainInfo *info = NULL;
-
+
if (!domain || !dinfo) {
wbc_status = WBC_ERR_INVALID_PARAM;
BAIL_ON_WBC_ERROR(wbc_status);
@@ -75,7 +71,7 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- strncpy(request.domain_name, domain,
+ strncpy(request.domain_name, domain,
sizeof(request.domain_name)-1);
wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_INFO,
@@ -86,15 +82,15 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
info = talloc(NULL, struct wbcDomainInfo);
BAIL_ON_PTR_ERROR(info, wbc_status);
- info->short_name = talloc_strdup(info,
+ info->short_name = talloc_strdup(info,
response.data.domain_info.name);
BAIL_ON_PTR_ERROR(info->short_name, wbc_status);
- info->dns_name = talloc_strdup(info,
+ info->dns_name = talloc_strdup(info,
response.data.domain_info.alt_name);
BAIL_ON_PTR_ERROR(info->dns_name, wbc_status);
- wbc_status = wbcStringToSid(response.data.domain_info.sid,
+ wbc_status = wbcStringToSid(response.data.domain_info.sid,
&info->sid);
BAIL_ON_WBC_ERROR(wbc_status);
@@ -106,7 +102,7 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
info->flags |= WBC_DOMINFO_PRIMARY;
*dinfo = info;
-
+
wbc_status = WBC_ERR_SUCCESS;
done:
diff --git a/source3/nsswitch/libwbclient/wbclient.h b/source3/nsswitch/libwbclient/wbclient.h
index 2867aad69e..6b85d7e8b3 100644
--- a/source3/nsswitch/libwbclient/wbclient.h
+++ b/source3/nsswitch/libwbclient/wbclient.h
@@ -177,7 +177,7 @@ wbcErr wbcDomainSequenceNumbers(void);
* Athenticate functions
*/
-wbcErr wbcAuthenticateUser(const char *username,
+wbcErr wbcAuthenticateUser(const char *username,
const char *password);