1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

s3-winbindd: use fill_domain_username_talloc() in winbind.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Günther Deschner 2018-05-08 11:18:56 +02:00 committed by Andreas Schneider
parent e1dad1d8dd
commit 3c6481d75c
5 changed files with 46 additions and 17 deletions

View File

@ -69,7 +69,8 @@ static void wb_getpwsid_queryuser_done(struct tevent_req *subreq)
req, struct wb_getpwsid_state);
struct winbindd_pw *pw = state->pw;
struct wbint_userinfo *info;
fstring acct_name, output_username;
fstring acct_name;
const char *output_username;
char *mapped_name = NULL;
char *tmp;
NTSTATUS status;
@ -101,16 +102,24 @@ static void wb_getpwsid_queryuser_done(struct tevent_req *subreq)
acct_name,
&mapped_name);
if (NT_STATUS_IS_OK(status)) {
fill_domain_username(output_username,
output_username = fill_domain_username_talloc(state,
info->domain_name,
mapped_name, true);
if (output_username == NULL) {
tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
fstrcpy(acct_name, mapped_name);
} else if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_RENAMED)) {
fstrcpy(acct_name, mapped_name);
} else {
fill_domain_username(output_username,
output_username = fill_domain_username_talloc(state,
info->domain_name,
acct_name, true);
if (output_username == NULL) {
tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
}
strlcpy(pw->pw_name, output_username, sizeof(pw->pw_name));

View File

@ -104,11 +104,14 @@ static void wb_query_user_list_done(struct tevent_req *subreq)
for (i=0; i<state->names.num_principals; i++) {
struct wbint_Principal *p = &state->names.principals[i];
fstring name;
const char *name;
int ret;
fill_domain_username(name, state->domain_name, p->name, true);
name = fill_domain_username_talloc(state, state->domain_name, p->name, true);
if (name == NULL) {
tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
ret = strv_add(state, &state->users, name);
if (ret != 0) {
tevent_req_nterror(req, map_nt_error_from_unix(ret));

View File

@ -34,7 +34,7 @@
bool fill_grent(TALLOC_CTX *mem_ctx, struct winbindd_gr *gr,
const char *dom_name, const char *gr_name, gid_t unix_gid)
{
fstring full_group_name;
const char *full_group_name;
char *mapped_name = NULL;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
@ -43,19 +43,23 @@ bool fill_grent(TALLOC_CTX *mem_ctx, struct winbindd_gr *gr,
/* Basic whitespace replacement */
if (NT_STATUS_IS_OK(nt_status)) {
fill_domain_username(full_group_name, dom_name,
full_group_name = fill_domain_username_talloc(mem_ctx, dom_name,
mapped_name, true);
}
/* Mapped to an aliase */
else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) {
fstrcpy(full_group_name, mapped_name);
full_group_name = mapped_name;
}
/* no change */
else {
fill_domain_username( full_group_name, dom_name,
full_group_name = fill_domain_username_talloc(mem_ctx, dom_name,
gr_name, True );
}
if (full_group_name == NULL) {
return false;
}
gr->gr_gid = unix_gid;
/* Group name and password */

View File

@ -171,10 +171,13 @@ NTSTATUS winbindd_list_groups_recv(struct tevent_req *req,
struct winbindd_list_groups_domstate *d = &state->domains[i];
for (j=0; j<d->groups.num_principals; j++) {
fstring name;
fill_domain_username(name, d->domain->name,
const char *name;
name = fill_domain_username_talloc(response, d->domain->name,
d->groups.principals[j].name,
True);
if (name == NULL) {
return NT_STATUS_NO_MEMORY;
}
len += strlen(name)+1;
}
response->data.num_entries += d->groups.num_principals;
@ -190,11 +193,14 @@ NTSTATUS winbindd_list_groups_recv(struct tevent_req *req,
struct winbindd_list_groups_domstate *d = &state->domains[i];
for (j=0; j<d->groups.num_principals; j++) {
fstring name;
const char *name;
size_t this_len;
fill_domain_username(name, d->domain->name,
name = fill_domain_username_talloc(response, d->domain->name,
d->groups.principals[j].name,
True);
if (name == NULL) {
return NT_STATUS_NO_MEMORY;
}
this_len = strlen(name);
memcpy(result+len, name, this_len);
len += this_len;

View File

@ -194,7 +194,7 @@ static NTSTATUS append_unix_username(TALLOC_CTX *mem_ctx,
/* We've been asked to return the unix username, per
'winbind use default domain' settings and the like */
const char *nt_username, *nt_domain;
const char *nt_username, *nt_domain, *unix_username;
nt_domain = talloc_strdup(mem_ctx, info3->base.logon_domain.string);
if (!nt_domain) {
@ -210,8 +210,15 @@ static NTSTATUS append_unix_username(TALLOC_CTX *mem_ctx,
nt_username = name_user;
}
fill_domain_username(resp->data.auth.unix_username,
nt_domain, nt_username, true);
unix_username = fill_domain_username_talloc(mem_ctx,
nt_domain,
nt_username,
true);
if (unix_username == NULL) {
return NT_STATUS_NO_MEMORY;
}
fstrcpy(resp->data.auth.unix_username, unix_username);
DEBUG(5, ("Setting unix username to [%s]\n",
resp->data.auth.unix_username));