1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | Main winbindd irpc handlers
|
---|
4 |
|
---|
5 | Copyright (C) Stefan Metzmacher 2006
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or modify
|
---|
8 | it under the terms of the GNU General Public License as published by
|
---|
9 | the Free Software Foundation; either version 3 of the License, or
|
---|
10 | (at your option) any later version.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful,
|
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | GNU General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #include "includes.h"
|
---|
22 | #include "winbind/wb_server.h"
|
---|
23 | #include "lib/messaging/irpc.h"
|
---|
24 | #include "libcli/composite/composite.h"
|
---|
25 | #include "libcli/security/proto.h"
|
---|
26 | #include "librpc/gen_ndr/ndr_winbind.h"
|
---|
27 | #include "smbd/service_task.h"
|
---|
28 |
|
---|
29 | struct wb_irpc_SamLogon_state {
|
---|
30 | struct irpc_message *msg;
|
---|
31 | struct winbind_SamLogon *req;
|
---|
32 | };
|
---|
33 |
|
---|
34 | static void wb_irpc_SamLogon_callback(struct composite_context *ctx);
|
---|
35 |
|
---|
36 | static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg,
|
---|
37 | struct winbind_SamLogon *req)
|
---|
38 | {
|
---|
39 | struct wbsrv_service *service = talloc_get_type(msg->private_data,
|
---|
40 | struct wbsrv_service);
|
---|
41 | struct wb_irpc_SamLogon_state *s;
|
---|
42 | struct composite_context *ctx;
|
---|
43 |
|
---|
44 | DEBUG(5, ("wb_irpc_SamLogon called\n"));
|
---|
45 |
|
---|
46 | s = talloc(msg, struct wb_irpc_SamLogon_state);
|
---|
47 | NT_STATUS_HAVE_NO_MEMORY(s);
|
---|
48 |
|
---|
49 | s->msg = msg;
|
---|
50 | s->req = req;
|
---|
51 |
|
---|
52 | ctx = wb_sam_logon_send(msg, service, req);
|
---|
53 | NT_STATUS_HAVE_NO_MEMORY(ctx);
|
---|
54 |
|
---|
55 | ctx->async.fn = wb_irpc_SamLogon_callback;
|
---|
56 | ctx->async.private_data = s;
|
---|
57 |
|
---|
58 | msg->defer_reply = true;
|
---|
59 | return NT_STATUS_OK;
|
---|
60 | }
|
---|
61 |
|
---|
62 | static void wb_irpc_SamLogon_callback(struct composite_context *ctx)
|
---|
63 | {
|
---|
64 | struct wb_irpc_SamLogon_state *s = talloc_get_type(ctx->async.private_data,
|
---|
65 | struct wb_irpc_SamLogon_state);
|
---|
66 | NTSTATUS status;
|
---|
67 |
|
---|
68 | DEBUG(5, ("wb_irpc_SamLogon_callback called\n"));
|
---|
69 |
|
---|
70 | status = wb_sam_logon_recv(ctx, s, s->req);
|
---|
71 |
|
---|
72 | irpc_send_reply(s->msg, status);
|
---|
73 | }
|
---|
74 |
|
---|
75 | struct wb_irpc_get_idmap_state {
|
---|
76 | struct irpc_message *msg;
|
---|
77 | struct winbind_get_idmap *req;
|
---|
78 | int level;
|
---|
79 | };
|
---|
80 |
|
---|
81 | static void wb_irpc_get_idmap_callback(struct composite_context *ctx);
|
---|
82 |
|
---|
83 | static NTSTATUS wb_irpc_get_idmap(struct irpc_message *msg,
|
---|
84 | struct winbind_get_idmap *req)
|
---|
85 | {
|
---|
86 | struct wbsrv_service *service = talloc_get_type(msg->private_data,
|
---|
87 | struct wbsrv_service);
|
---|
88 | struct wb_irpc_get_idmap_state *s;
|
---|
89 | struct composite_context *ctx;
|
---|
90 |
|
---|
91 | DEBUG(5, ("wb_irpc_get_idmap called\n"));
|
---|
92 |
|
---|
93 | s = talloc(msg, struct wb_irpc_get_idmap_state);
|
---|
94 | NT_STATUS_HAVE_NO_MEMORY(s);
|
---|
95 |
|
---|
96 | s->msg = msg;
|
---|
97 | s->req = req;
|
---|
98 | s->level = req->in.level;
|
---|
99 |
|
---|
100 | switch(s->level) {
|
---|
101 | case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
|
---|
102 | ctx = wb_sids2xids_send(msg, service, req->in.count,
|
---|
103 | req->in.ids);
|
---|
104 | break;
|
---|
105 | case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
|
---|
106 | ctx = wb_xids2sids_send(msg, service, req->in.count,
|
---|
107 | req->in.ids);
|
---|
108 | break;
|
---|
109 | }
|
---|
110 | NT_STATUS_HAVE_NO_MEMORY(ctx);
|
---|
111 |
|
---|
112 | composite_continue(ctx, ctx, wb_irpc_get_idmap_callback, s);
|
---|
113 | msg->defer_reply = true;
|
---|
114 |
|
---|
115 | return NT_STATUS_OK;
|
---|
116 | }
|
---|
117 |
|
---|
118 | static void wb_irpc_get_idmap_callback(struct composite_context *ctx)
|
---|
119 | {
|
---|
120 | struct wb_irpc_get_idmap_state *s;
|
---|
121 | NTSTATUS status;
|
---|
122 |
|
---|
123 | DEBUG(5, ("wb_irpc_get_idmap_callback called\n"));
|
---|
124 |
|
---|
125 | s = talloc_get_type(ctx->async.private_data,
|
---|
126 | struct wb_irpc_get_idmap_state);
|
---|
127 |
|
---|
128 | switch(s->level) {
|
---|
129 | case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
|
---|
130 | status = wb_sids2xids_recv(ctx, &s->req->out.ids);
|
---|
131 | break;
|
---|
132 | case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
|
---|
133 | status = wb_xids2sids_recv(ctx, &s->req->out.ids);
|
---|
134 | break;
|
---|
135 | default:
|
---|
136 | status = NT_STATUS_INTERNAL_ERROR;
|
---|
137 | break;
|
---|
138 | }
|
---|
139 |
|
---|
140 | irpc_send_reply(s->msg, status);
|
---|
141 | }
|
---|
142 |
|
---|
143 | NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
|
---|
144 | {
|
---|
145 | NTSTATUS status;
|
---|
146 |
|
---|
147 | irpc_add_name(service->task->msg_ctx, "winbind_server");
|
---|
148 |
|
---|
149 | status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_SAMLOGON,
|
---|
150 | wb_irpc_SamLogon, service);
|
---|
151 | NT_STATUS_NOT_OK_RETURN(status);
|
---|
152 |
|
---|
153 | status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_GET_IDMAP,
|
---|
154 | wb_irpc_get_idmap, service);
|
---|
155 | NT_STATUS_NOT_OK_RETURN(status);
|
---|
156 |
|
---|
157 | return NT_STATUS_OK;
|
---|
158 | }
|
---|