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;
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));
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));
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;
/* 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 */
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;
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;
/* 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) {
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));