From d68319431e62e43c0ecb23328e3162128d823958 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 16 Oct 2005 12:43:09 +0000 Subject: r11095: Implement wb_getuserdomgroups. Tridge, if you have the time, you might want to look at a problem I'm having with unix domain stream sockets. From a comment in this commit: /* Using composite_trigger_error here causes problems with the client * socket. Linux 2.6.8 gives me a ECONNRESET on the next read after * writing the reply when I don't wait the 100 milliseconds. */ This is in winbind/wb_cmd_userdomgroups.c:93. The problem I have is that I can not *immediately* send an error reply to the client because the next receive fails. Waiting 100 milliseconds helps. It might also be a problem with epoll(), I don't really know. I'd appreciate if you took a brief look at this, maybe I'm doing something wrong. Thanks, Volker (This used to be commit 3e535cce743710a68a4264e4f66e9c0c4d6770c6) --- source4/winbind/wb_samba3_cmd.c | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'source4/winbind/wb_samba3_cmd.c') diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c index fb43eacb5c..a53b06ae4e 100644 --- a/source4/winbind/wb_samba3_cmd.c +++ b/source4/winbind/wb_samba3_cmd.c @@ -174,6 +174,84 @@ static void getdcname_recv_dc(struct composite_context *ctx) } } +static void userdomgroups_recv_groups(struct composite_context *ctx); + +NTSTATUS wbsrv_samba3_userdomgroups(struct wbsrv_samba3_call *s3call) +{ + struct composite_context *ctx; + struct dom_sid *sid; + + DEBUG(5, ("wbsrv_samba3_userdomgroups called\n")); + + sid = dom_sid_parse_talloc(s3call, s3call->request.data.sid); + if (sid == NULL) { + DEBUG(5, ("Could not parse sid %s\n", + s3call->request.data.sid)); + return NT_STATUS_NO_MEMORY; + } + + ctx = wb_cmd_userdomgroups_send(s3call->call, sid); + NT_STATUS_HAVE_NO_MEMORY(ctx); + + ctx->async.fn = userdomgroups_recv_groups; + ctx->async.private_data = s3call; + s3call->call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC; + return NT_STATUS_OK; +} + +static void userdomgroups_recv_groups(struct composite_context *ctx) +{ + struct wbsrv_samba3_call *s3call = + talloc_get_type(ctx->async.private_data, + struct wbsrv_samba3_call); + int i, num_sids; + struct dom_sid **sids; + char *sids_string; + NTSTATUS status; + + status = wb_cmd_userdomgroups_recv(ctx, s3call, &num_sids, &sids); + if (!NT_STATUS_IS_OK(status)) goto done; + + sids_string = talloc_strdup(s3call, ""); + if (sids_string == NULL) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + for (i=0; iresponse.result = WINBINDD_OK; + s3call->response.extra_data = sids_string; + s3call->response.length += strlen(sids_string)+1; + s3call->response.data.num_entries = num_sids; + + done: + if (!NT_STATUS_IS_OK(status)) { + struct winbindd_response *resp = &s3call->response; + resp->result = WINBINDD_ERROR; + WBSRV_SAMBA3_SET_STRING(resp->data.auth.nt_status_string, + nt_errstr(status)); + WBSRV_SAMBA3_SET_STRING(resp->data.auth.error_string, + nt_errstr(status)); + resp->data.auth.pam_error = nt_status_to_pam(status); + } + + status = wbsrv_send_reply(s3call->call); + if (!NT_STATUS_IS_OK(status)) { + wbsrv_terminate_connection(s3call->call->wbconn, + "wbsrv_queue_reply() failed"); + return; + } +} + static void lookupname_recv_sid(struct composite_context *ctx); NTSTATUS wbsrv_samba3_lookupname(struct wbsrv_samba3_call *s3call) -- cgit