diff options
author | Günther Deschner <gd@samba.org> | 2018-05-08 11:18:56 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-05-17 17:30:08 +0200 |
commit | 3c6481d75cea175d0a69988577163efb40e2316b (patch) | |
tree | d512e2a89c1d57bbe78634a64ea99e38d8966321 /source3/winbindd | |
parent | e1dad1d8ddeb9281b267186163dc4109cae3d599 (diff) | |
download | samba-3c6481d75cea175d0a69988577163efb40e2316b.tar.gz |
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>
Diffstat (limited to 'source3/winbindd')
-rw-r--r-- | source3/winbindd/wb_getpwsid.c | 15 | ||||
-rw-r--r-- | source3/winbindd/wb_query_user_list.c | 9 | ||||
-rw-r--r-- | source3/winbindd/winbindd_group.c | 12 | ||||
-rw-r--r-- | source3/winbindd/winbindd_list_groups.c | 14 | ||||
-rw-r--r-- | source3/winbindd/winbindd_pam.c | 13 |
5 files changed, 46 insertions, 17 deletions
diff --git a/source3/winbindd/wb_getpwsid.c b/source3/winbindd/wb_getpwsid.c index 01c2f9cebfb..a8f32f2fc94 100644 --- a/source3/winbindd/wb_getpwsid.c +++ b/source3/winbindd/wb_getpwsid.c @@ -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)); diff --git a/source3/winbindd/wb_query_user_list.c b/source3/winbindd/wb_query_user_list.c index 3c18080e847..6d699875e9b 100644 --- a/source3/winbindd/wb_query_user_list.c +++ b/source3/winbindd/wb_query_user_list.c @@ -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)); diff --git a/source3/winbindd/winbindd_group.c b/source3/winbindd/winbindd_group.c index 417565ecbf0..76ba14afb3b 100644 --- a/source3/winbindd/winbindd_group.c +++ b/source3/winbindd/winbindd_group.c @@ -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 */ diff --git a/source3/winbindd/winbindd_list_groups.c b/source3/winbindd/winbindd_list_groups.c index f593ba26f2a..36800ae54ec 100644 --- a/source3/winbindd/winbindd_list_groups.c +++ b/source3/winbindd/winbindd_list_groups.c @@ -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; diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c index 25564277f0a..bed5a940282 100644 --- a/source3/winbindd/winbindd_pam.c +++ b/source3/winbindd/winbindd_pam.c @@ -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)); |