summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_group.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/nsswitch/winbindd_group.c')
-rw-r--r--source3/nsswitch/winbindd_group.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/source3/nsswitch/winbindd_group.c b/source3/nsswitch/winbindd_group.c
index aac8a9aac3..18a7be29de 100644
--- a/source3/nsswitch/winbindd_group.c
+++ b/source3/nsswitch/winbindd_group.c
@@ -124,9 +124,7 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
if (sys_getpeereid(state->sock, &ret_uid)==0) {
/* We know who's asking - look up their SID if
it's one we've mapped before. */
- status = idmap_uid_to_sid(&querying_user_sid,
- ret_uid,
- IDMAP_FLAG_QUERY_ONLY|IDMAP_FLAG_CACHE_ONLY);
+ status = idmap_uid_to_sid(&querying_user_sid, ret_uid);
if (NT_STATUS_IS_OK(status)) {
pquerying_user_sid = &querying_user_sid;
DEBUG(10,("fill_grent_mem: querying uid %u -> %s\n",
@@ -399,7 +397,7 @@ void winbindd_getgrnam(struct winbindd_cli_state *state)
/* Try to get the GID */
- status = idmap_sid_to_gid(&group_sid, &gid, 0);
+ status = idmap_sid_to_gid(&group_sid, &gid);
if (NT_STATUS_IS_OK(status)) {
goto got_gid;
@@ -444,18 +442,20 @@ static void getgrgid_got_sid(struct winbindd_cli_state *state, DOM_SID group_sid
{
struct winbindd_domain *domain;
enum lsa_SidType name_type;
- fstring dom_name;
- fstring group_name;
+ char *dom_name = NULL;
+ char *group_name = NULL;
size_t gr_mem_len;
size_t num_gr_mem;
char *gr_mem;
/* Get name from sid */
- if (!winbindd_lookup_name_by_sid(state->mem_ctx, &group_sid, dom_name,
- group_name, &name_type)) {
+ if (!winbindd_lookup_name_by_sid(state->mem_ctx, &group_sid, &dom_name,
+ &group_name, &name_type)) {
DEBUG(1, ("could not lookup sid\n"));
request_error(state);
+ TALLOC_FREE(group_name);
+ TALLOC_FREE(dom_name);
return;
}
@@ -466,6 +466,8 @@ static void getgrgid_got_sid(struct winbindd_cli_state *state, DOM_SID group_sid
if (!domain) {
DEBUG(1,("Can't find domain from sid\n"));
request_error(state);
+ TALLOC_FREE(group_name);
+ TALLOC_FREE(dom_name);
return;
}
@@ -476,6 +478,8 @@ static void getgrgid_got_sid(struct winbindd_cli_state *state, DOM_SID group_sid
DEBUG(1, ("name '%s' is not a local or domain group: %d\n",
group_name, name_type));
request_error(state);
+ TALLOC_FREE(group_name);
+ TALLOC_FREE(dom_name);
return;
}
@@ -485,6 +489,8 @@ static void getgrgid_got_sid(struct winbindd_cli_state *state, DOM_SID group_sid
&num_gr_mem,
&gr_mem, &gr_mem_len)) {
request_error(state);
+ TALLOC_FREE(group_name);
+ TALLOC_FREE(dom_name);
return;
}
@@ -497,6 +503,9 @@ static void getgrgid_got_sid(struct winbindd_cli_state *state, DOM_SID group_sid
state->response.length += gr_mem_len;
state->response.extra_data.data = gr_mem;
+ TALLOC_FREE(group_name);
+ TALLOC_FREE(dom_name);
+
request_ok(state);
}
@@ -534,32 +543,10 @@ static void getgrgid_recv(void *private_data, BOOL success, const char *sid)
/* Return a group structure from a gid number */
void winbindd_getgrgid(struct winbindd_cli_state *state)
{
- DOM_SID group_sid;
- NTSTATUS status;
-
DEBUG(3, ("[%5lu]: getgrgid %lu\n", (unsigned long)state->pid,
(unsigned long)state->request.data.gid));
- /* Bug out if the gid isn't in the winbind range */
-
- if ((state->request.data.gid < server_state.gid_low) ||
- (state->request.data.gid > server_state.gid_high)) {
- request_error(state);
- return;
- }
-
- /* Get sid from gid */
-
- status = idmap_gid_to_sid(&group_sid, state->request.data.gid, IDMAP_FLAG_NONE);
- if (NT_STATUS_IS_OK(status)) {
- /* This is a remote one */
- getgrgid_got_sid(state, group_sid);
- return;
- }
-
- DEBUG(10,("winbindd_getgrgid: gid %lu not found in cache, try with the async interface\n",
- (unsigned long)state->request.data.gid));
-
+ /* always use the async interface */
winbindd_gid2sid_async(state->mem_ctx, state->request.data.gid, getgrgid_recv, state);
}
@@ -855,8 +842,7 @@ void winbindd_getgrent(struct winbindd_cli_state *state)
sid_copy(&group_sid, &domain->sid);
sid_append_rid(&group_sid, name_list[ent->sam_entry_index].rid);
- if (!NT_STATUS_IS_OK(idmap_sid_to_gid(&group_sid,
- &group_gid, 0))) {
+ if (!NT_STATUS_IS_OK(idmap_sid_to_gid(&group_sid, &group_gid))) {
union unid_t id;
enum lsa_SidType type;