1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | Async helpers for blocking functions
|
---|
5 |
|
---|
6 | Copyright (C) Volker Lendecke 2005
|
---|
7 | Copyright (C) Gerald Carter 2006
|
---|
8 | Copyright (C) Simo Sorce 2007
|
---|
9 |
|
---|
10 | The helpers always consist of three functions:
|
---|
11 |
|
---|
12 | * A request setup function that takes the necessary parameters together
|
---|
13 | with a continuation function that is to be called upon completion
|
---|
14 |
|
---|
15 | * A private continuation function that is internal only. This is to be
|
---|
16 | called by the lower-level functions in do_async(). Its only task is to
|
---|
17 | properly call the continuation function named above.
|
---|
18 |
|
---|
19 | * A worker function that is called inside the appropriate child process.
|
---|
20 |
|
---|
21 | This program is free software; you can redistribute it and/or modify
|
---|
22 | it under the terms of the GNU General Public License as published by
|
---|
23 | the Free Software Foundation; either version 3 of the License, or
|
---|
24 | (at your option) any later version.
|
---|
25 |
|
---|
26 | This program is distributed in the hope that it will be useful,
|
---|
27 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
29 | GNU General Public License for more details.
|
---|
30 |
|
---|
31 | You should have received a copy of the GNU General Public License
|
---|
32 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
33 | */
|
---|
34 |
|
---|
35 | #include "includes.h"
|
---|
36 | #include "winbindd.h"
|
---|
37 |
|
---|
38 | #undef DBGC_CLASS
|
---|
39 | #define DBGC_CLASS DBGC_WINBIND
|
---|
40 |
|
---|
41 | static const struct winbindd_child_dispatch_table idmap_dispatch_table[];
|
---|
42 |
|
---|
43 | static struct winbindd_child static_idmap_child;
|
---|
44 |
|
---|
45 | void init_idmap_child(void)
|
---|
46 | {
|
---|
47 | setup_child(&static_idmap_child,
|
---|
48 | idmap_dispatch_table,
|
---|
49 | "log.winbindd", "idmap");
|
---|
50 | }
|
---|
51 |
|
---|
52 | struct winbindd_child *idmap_child(void)
|
---|
53 | {
|
---|
54 | return &static_idmap_child;
|
---|
55 | }
|
---|
56 |
|
---|
57 | static void winbindd_set_mapping_recv(TALLOC_CTX *mem_ctx, bool success,
|
---|
58 | struct winbindd_response *response,
|
---|
59 | void *c, void *private_data)
|
---|
60 | {
|
---|
61 | void (*cont)(void *priv, bool succ) = (void (*)(void *, bool))c;
|
---|
62 |
|
---|
63 | if (!success) {
|
---|
64 | DEBUG(5, ("Could not trigger idmap_set_mapping\n"));
|
---|
65 | cont(private_data, False);
|
---|
66 | return;
|
---|
67 | }
|
---|
68 |
|
---|
69 | if (response->result != WINBINDD_OK) {
|
---|
70 | DEBUG(5, ("idmap_set_mapping returned an error\n"));
|
---|
71 | cont(private_data, False);
|
---|
72 | return;
|
---|
73 | }
|
---|
74 |
|
---|
75 | cont(private_data, True);
|
---|
76 | }
|
---|
77 |
|
---|
78 | void winbindd_set_mapping_async(TALLOC_CTX *mem_ctx, const struct id_map *map,
|
---|
79 | void (*cont)(void *private_data, bool success),
|
---|
80 | void *private_data)
|
---|
81 | {
|
---|
82 | struct winbindd_request request;
|
---|
83 | ZERO_STRUCT(request);
|
---|
84 | request.cmd = WINBINDD_DUAL_SET_MAPPING;
|
---|
85 | request.data.dual_idmapset.id = map->xid.id;
|
---|
86 | request.data.dual_idmapset.type = map->xid.type;
|
---|
87 | sid_to_fstring(request.data.dual_idmapset.sid, map->sid);
|
---|
88 |
|
---|
89 | do_async(mem_ctx, idmap_child(), &request, winbindd_set_mapping_recv,
|
---|
90 | (void *)cont, private_data);
|
---|
91 | }
|
---|
92 |
|
---|
93 | enum winbindd_result winbindd_dual_set_mapping(struct winbindd_domain *domain,
|
---|
94 | struct winbindd_cli_state *state)
|
---|
95 | {
|
---|
96 | struct id_map map;
|
---|
97 | DOM_SID sid;
|
---|
98 | NTSTATUS result;
|
---|
99 |
|
---|
100 | DEBUG(3, ("[%5lu]: dual_idmapset\n", (unsigned long)state->pid));
|
---|
101 |
|
---|
102 | if (!string_to_sid(&sid, state->request.data.dual_idmapset.sid))
|
---|
103 | return WINBINDD_ERROR;
|
---|
104 |
|
---|
105 | map.sid = &sid;
|
---|
106 | map.xid.id = state->request.data.dual_idmapset.id;
|
---|
107 | map.xid.type = state->request.data.dual_idmapset.type;
|
---|
108 | map.status = ID_MAPPED;
|
---|
109 |
|
---|
110 | result = idmap_set_mapping(&map);
|
---|
111 | return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
|
---|
112 | }
|
---|
113 |
|
---|
114 | static void winbindd_set_hwm_recv(TALLOC_CTX *mem_ctx, bool success,
|
---|
115 | struct winbindd_response *response,
|
---|
116 | void *c, void *private_data)
|
---|
117 | {
|
---|
118 | void (*cont)(void *priv, bool succ) = (void (*)(void *, bool))c;
|
---|
119 |
|
---|
120 | if (!success) {
|
---|
121 | DEBUG(5, ("Could not trigger idmap_set_hwm\n"));
|
---|
122 | cont(private_data, False);
|
---|
123 | return;
|
---|
124 | }
|
---|
125 |
|
---|
126 | if (response->result != WINBINDD_OK) {
|
---|
127 | DEBUG(5, ("idmap_set_hwm returned an error\n"));
|
---|
128 | cont(private_data, False);
|
---|
129 | return;
|
---|
130 | }
|
---|
131 |
|
---|
132 | cont(private_data, True);
|
---|
133 | }
|
---|
134 |
|
---|
135 | void winbindd_set_hwm_async(TALLOC_CTX *mem_ctx, const struct unixid *xid,
|
---|
136 | void (*cont)(void *private_data, bool success),
|
---|
137 | void *private_data)
|
---|
138 | {
|
---|
139 | struct winbindd_request request;
|
---|
140 | ZERO_STRUCT(request);
|
---|
141 | request.cmd = WINBINDD_DUAL_SET_HWM;
|
---|
142 | request.data.dual_idmapset.id = xid->id;
|
---|
143 | request.data.dual_idmapset.type = xid->type;
|
---|
144 |
|
---|
145 | do_async(mem_ctx, idmap_child(), &request, winbindd_set_hwm_recv,
|
---|
146 | (void *)cont, private_data);
|
---|
147 | }
|
---|
148 |
|
---|
149 | enum winbindd_result winbindd_dual_set_hwm(struct winbindd_domain *domain,
|
---|
150 | struct winbindd_cli_state *state)
|
---|
151 | {
|
---|
152 | struct unixid xid;
|
---|
153 | NTSTATUS result;
|
---|
154 |
|
---|
155 | DEBUG(3, ("[%5lu]: dual_set_hwm\n", (unsigned long)state->pid));
|
---|
156 |
|
---|
157 | xid.id = state->request.data.dual_idmapset.id;
|
---|
158 | xid.type = state->request.data.dual_idmapset.type;
|
---|
159 |
|
---|
160 | switch (xid.type) {
|
---|
161 | case ID_TYPE_UID:
|
---|
162 | result = idmap_set_uid_hwm(&xid);
|
---|
163 | break;
|
---|
164 | case ID_TYPE_GID:
|
---|
165 | result = idmap_set_gid_hwm(&xid);
|
---|
166 | break;
|
---|
167 | default:
|
---|
168 | return WINBINDD_ERROR;
|
---|
169 | }
|
---|
170 | return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
|
---|
171 | }
|
---|
172 |
|
---|
173 | static void winbindd_sids2xids_recv(TALLOC_CTX *mem_ctx, bool success,
|
---|
174 | struct winbindd_response *response,
|
---|
175 | void *c, void *private_data)
|
---|
176 | {
|
---|
177 | void (*cont)(void *priv, bool succ, void *, int) =
|
---|
178 | (void (*)(void *, bool, void *, int))c;
|
---|
179 |
|
---|
180 | if (!success) {
|
---|
181 | DEBUG(5, ("Could not trigger sids2xids\n"));
|
---|
182 | cont(private_data, False, NULL, 0);
|
---|
183 | return;
|
---|
184 | }
|
---|
185 |
|
---|
186 | if (response->result != WINBINDD_OK) {
|
---|
187 | DEBUG(5, ("sids2xids returned an error\n"));
|
---|
188 | cont(private_data, False, NULL, 0);
|
---|
189 | return;
|
---|
190 | }
|
---|
191 |
|
---|
192 | cont(private_data, True, response->extra_data.data, response->length - sizeof(response));
|
---|
193 | }
|
---|
194 |
|
---|
195 | void winbindd_sids2xids_async(TALLOC_CTX *mem_ctx, void *sids, int size,
|
---|
196 | void (*cont)(void *private_data, bool success, void *data, int len),
|
---|
197 | void *private_data)
|
---|
198 | {
|
---|
199 | struct winbindd_request request;
|
---|
200 | ZERO_STRUCT(request);
|
---|
201 | request.cmd = WINBINDD_DUAL_SIDS2XIDS;
|
---|
202 | request.extra_data.data = (char *)sids;
|
---|
203 | request.extra_len = size;
|
---|
204 | do_async(mem_ctx, idmap_child(), &request, winbindd_sids2xids_recv,
|
---|
205 | (void *)cont, private_data);
|
---|
206 | }
|
---|
207 |
|
---|
208 | enum winbindd_result winbindd_dual_sids2xids(struct winbindd_domain *domain,
|
---|
209 | struct winbindd_cli_state *state)
|
---|
210 | {
|
---|
211 | DOM_SID *sids;
|
---|
212 | struct unixid *xids;
|
---|
213 | struct id_map **ids;
|
---|
214 | NTSTATUS result;
|
---|
215 | int num, i;
|
---|
216 |
|
---|
217 | DEBUG(3, ("[%5lu]: sids to unix ids\n", (unsigned long)state->pid));
|
---|
218 |
|
---|
219 | if (state->request.extra_len == 0) {
|
---|
220 | DEBUG(0, ("Invalid buffer size!\n"));
|
---|
221 | return WINBINDD_ERROR;
|
---|
222 | }
|
---|
223 |
|
---|
224 | sids = (DOM_SID *)state->request.extra_data.data;
|
---|
225 | num = state->request.extra_len / sizeof(DOM_SID);
|
---|
226 |
|
---|
227 | ids = TALLOC_ZERO_ARRAY(state->mem_ctx, struct id_map *, num + 1);
|
---|
228 | if ( ! ids) {
|
---|
229 | DEBUG(0, ("Out of memory!\n"));
|
---|
230 | return WINBINDD_ERROR;
|
---|
231 | }
|
---|
232 | for (i = 0; i < num; i++) {
|
---|
233 | ids[i] = TALLOC_P(ids, struct id_map);
|
---|
234 | if ( ! ids[i]) {
|
---|
235 | DEBUG(0, ("Out of memory!\n"));
|
---|
236 | talloc_free(ids);
|
---|
237 | return WINBINDD_ERROR;
|
---|
238 | }
|
---|
239 | ids[i]->sid = &sids[i];
|
---|
240 | }
|
---|
241 |
|
---|
242 | result = idmap_sids_to_unixids(ids);
|
---|
243 |
|
---|
244 | if (NT_STATUS_IS_OK(result)) {
|
---|
245 |
|
---|
246 | xids = SMB_MALLOC_ARRAY(struct unixid, num);
|
---|
247 | if ( ! xids) {
|
---|
248 | DEBUG(0, ("Out of memory!\n"));
|
---|
249 | talloc_free(ids);
|
---|
250 | return WINBINDD_ERROR;
|
---|
251 | }
|
---|
252 |
|
---|
253 | for (i = 0; i < num; i++) {
|
---|
254 | if (ids[i]->status == ID_MAPPED) {
|
---|
255 | xids[i].type = ids[i]->xid.type;
|
---|
256 | xids[i].id = ids[i]->xid.id;
|
---|
257 | } else {
|
---|
258 | xids[i].type = -1;
|
---|
259 | }
|
---|
260 | }
|
---|
261 |
|
---|
262 | state->response.length = sizeof(state->response) + (sizeof(struct unixid) * num);
|
---|
263 | state->response.extra_data.data = xids;
|
---|
264 |
|
---|
265 | } else {
|
---|
266 | DEBUG (2, ("idmap_sids_to_unixids returned an error: 0x%08x\n", NT_STATUS_V(result)));
|
---|
267 | talloc_free(ids);
|
---|
268 | return WINBINDD_ERROR;
|
---|
269 | }
|
---|
270 |
|
---|
271 | talloc_free(ids);
|
---|
272 | return WINBINDD_OK;
|
---|
273 | }
|
---|
274 |
|
---|
275 | static void winbindd_sid2uid_recv(TALLOC_CTX *mem_ctx, bool success,
|
---|
276 | struct winbindd_response *response,
|
---|
277 | void *c, void *private_data)
|
---|
278 | {
|
---|
279 | void (*cont)(void *priv, bool succ, uid_t uid) =
|
---|
280 | (void (*)(void *, bool, uid_t))c;
|
---|
281 |
|
---|
282 | if (!success) {
|
---|
283 | DEBUG(5, ("Could not trigger sid2uid\n"));
|
---|
284 | cont(private_data, False, 0);
|
---|
285 | return;
|
---|
286 | }
|
---|
287 |
|
---|
288 | if (response->result != WINBINDD_OK) {
|
---|
289 | DEBUG(5, ("sid2uid returned an error\n"));
|
---|
290 | cont(private_data, False, 0);
|
---|
291 | return;
|
---|
292 | }
|
---|
293 |
|
---|
294 | cont(private_data, True, response->data.uid);
|
---|
295 | }
|
---|
296 |
|
---|
297 | void winbindd_sid2uid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
|
---|
298 | void (*cont)(void *private_data, bool success, uid_t uid),
|
---|
299 | void *private_data)
|
---|
300 | {
|
---|
301 | struct winbindd_request request;
|
---|
302 | ZERO_STRUCT(request);
|
---|
303 | request.cmd = WINBINDD_DUAL_SID2UID;
|
---|
304 | sid_to_fstring(request.data.dual_sid2id.sid, sid);
|
---|
305 | do_async(mem_ctx, idmap_child(), &request, winbindd_sid2uid_recv,
|
---|
306 | (void *)cont, private_data);
|
---|
307 | }
|
---|
308 |
|
---|
309 | enum winbindd_result winbindd_dual_sid2uid(struct winbindd_domain *domain,
|
---|
310 | struct winbindd_cli_state *state)
|
---|
311 | {
|
---|
312 | DOM_SID sid;
|
---|
313 | NTSTATUS result;
|
---|
314 |
|
---|
315 | DEBUG(3, ("[%5lu]: sid to uid %s\n", (unsigned long)state->pid,
|
---|
316 | state->request.data.dual_sid2id.sid));
|
---|
317 |
|
---|
318 | if (!string_to_sid(&sid, state->request.data.dual_sid2id.sid)) {
|
---|
319 | DEBUG(1, ("Could not get convert sid %s from string\n",
|
---|
320 | state->request.data.dual_sid2id.sid));
|
---|
321 | return WINBINDD_ERROR;
|
---|
322 | }
|
---|
323 |
|
---|
324 | /* Find uid for this sid and return it, possibly ask the slow remote idmap */
|
---|
325 |
|
---|
326 | result = idmap_sid_to_uid(&sid, &(state->response.data.uid));
|
---|
327 |
|
---|
328 | return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
|
---|
329 | }
|
---|
330 |
|
---|
331 | static void winbindd_sid2gid_recv(TALLOC_CTX *mem_ctx, bool success,
|
---|
332 | struct winbindd_response *response,
|
---|
333 | void *c, void *private_data)
|
---|
334 | {
|
---|
335 | void (*cont)(void *priv, bool succ, gid_t gid) =
|
---|
336 | (void (*)(void *, bool, gid_t))c;
|
---|
337 |
|
---|
338 | if (!success) {
|
---|
339 | DEBUG(5, ("Could not trigger sid2gid\n"));
|
---|
340 | cont(private_data, False, 0);
|
---|
341 | return;
|
---|
342 | }
|
---|
343 |
|
---|
344 | if (response->result != WINBINDD_OK) {
|
---|
345 | DEBUG(5, ("sid2gid returned an error\n"));
|
---|
346 | cont(private_data, False, 0);
|
---|
347 | return;
|
---|
348 | }
|
---|
349 |
|
---|
350 | cont(private_data, True, response->data.gid);
|
---|
351 | }
|
---|
352 |
|
---|
353 | void winbindd_sid2gid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
|
---|
354 | void (*cont)(void *private_data, bool success, gid_t gid),
|
---|
355 | void *private_data)
|
---|
356 | {
|
---|
357 | struct winbindd_request request;
|
---|
358 | ZERO_STRUCT(request);
|
---|
359 | request.cmd = WINBINDD_DUAL_SID2GID;
|
---|
360 | sid_to_fstring(request.data.dual_sid2id.sid, sid);
|
---|
361 |
|
---|
362 | DEBUG(7,("winbindd_sid2gid_async: Resolving %s to a gid\n",
|
---|
363 | request.data.dual_sid2id.sid));
|
---|
364 |
|
---|
365 | do_async(mem_ctx, idmap_child(), &request, winbindd_sid2gid_recv,
|
---|
366 | (void *)cont, private_data);
|
---|
367 | }
|
---|
368 |
|
---|
369 | enum winbindd_result winbindd_dual_sid2gid(struct winbindd_domain *domain,
|
---|
370 | struct winbindd_cli_state *state)
|
---|
371 | {
|
---|
372 | DOM_SID sid;
|
---|
373 | NTSTATUS result;
|
---|
374 |
|
---|
375 | DEBUG(3, ("[%5lu]: sid to gid %s\n", (unsigned long)state->pid,
|
---|
376 | state->request.data.dual_sid2id.sid));
|
---|
377 |
|
---|
378 | if (!string_to_sid(&sid, state->request.data.dual_sid2id.sid)) {
|
---|
379 | DEBUG(1, ("Could not get convert sid %s from string\n",
|
---|
380 | state->request.data.dual_sid2id.sid));
|
---|
381 | return WINBINDD_ERROR;
|
---|
382 | }
|
---|
383 |
|
---|
384 | /* Find gid for this sid and return it, possibly ask the slow remote idmap */
|
---|
385 |
|
---|
386 | result = idmap_sid_to_gid(&sid, &state->response.data.gid);
|
---|
387 |
|
---|
388 | DEBUG(10, ("winbindd_dual_sid2gid: 0x%08x - %s - %u\n",
|
---|
389 | NT_STATUS_V(result), sid_string_dbg(&sid),
|
---|
390 | state->response.data.gid));
|
---|
391 |
|
---|
392 | return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
|
---|
393 | }
|
---|
394 |
|
---|
395 | /* The following uid2sid/gid2sid functions has been contributed by
|
---|
396 | * Keith Reynolds <Keith.Reynolds@centrify.com> */
|
---|
397 |
|
---|
398 | static void winbindd_uid2sid_recv(TALLOC_CTX *mem_ctx, bool success,
|
---|
399 | struct winbindd_response *response,
|
---|
400 | void *c, void *private_data)
|
---|
401 | {
|
---|
402 | void (*cont)(void *priv, bool succ, const char *sid) =
|
---|
403 | (void (*)(void *, bool, const char *))c;
|
---|
404 |
|
---|
405 | if (!success) {
|
---|
406 | DEBUG(5, ("Could not trigger uid2sid\n"));
|
---|
407 | cont(private_data, False, NULL);
|
---|
408 | return;
|
---|
409 | }
|
---|
410 |
|
---|
411 | if (response->result != WINBINDD_OK) {
|
---|
412 | DEBUG(5, ("uid2sid returned an error\n"));
|
---|
413 | cont(private_data, False, NULL);
|
---|
414 | return;
|
---|
415 | }
|
---|
416 |
|
---|
417 | cont(private_data, True, response->data.sid.sid);
|
---|
418 | }
|
---|
419 |
|
---|
420 | void winbindd_uid2sid_async(TALLOC_CTX *mem_ctx, uid_t uid,
|
---|
421 | void (*cont)(void *private_data, bool success, const char *sid),
|
---|
422 | void *private_data)
|
---|
423 | {
|
---|
424 | struct winbindd_request request;
|
---|
425 |
|
---|
426 | ZERO_STRUCT(request);
|
---|
427 | request.cmd = WINBINDD_DUAL_UID2SID;
|
---|
428 | request.data.uid = uid;
|
---|
429 | do_async(mem_ctx, idmap_child(), &request, winbindd_uid2sid_recv,
|
---|
430 | (void *)cont, private_data);
|
---|
431 | }
|
---|
432 |
|
---|
433 | enum winbindd_result winbindd_dual_uid2sid(struct winbindd_domain *domain,
|
---|
434 | struct winbindd_cli_state *state)
|
---|
435 | {
|
---|
436 | DOM_SID sid;
|
---|
437 | NTSTATUS result;
|
---|
438 |
|
---|
439 | DEBUG(3,("[%5lu]: uid to sid %lu\n",
|
---|
440 | (unsigned long)state->pid,
|
---|
441 | (unsigned long) state->request.data.uid));
|
---|
442 |
|
---|
443 | /* Find sid for this uid and return it, possibly ask the slow remote idmap */
|
---|
444 | result = idmap_uid_to_sid(&sid, state->request.data.uid);
|
---|
445 |
|
---|
446 | if (NT_STATUS_IS_OK(result)) {
|
---|
447 | sid_to_fstring(state->response.data.sid.sid, &sid);
|
---|
448 | state->response.data.sid.type = SID_NAME_USER;
|
---|
449 | return WINBINDD_OK;
|
---|
450 | }
|
---|
451 |
|
---|
452 | return WINBINDD_ERROR;
|
---|
453 | }
|
---|
454 |
|
---|
455 | static void winbindd_gid2sid_recv(TALLOC_CTX *mem_ctx, bool success,
|
---|
456 | struct winbindd_response *response,
|
---|
457 | void *c, void *private_data)
|
---|
458 | {
|
---|
459 | void (*cont)(void *priv, bool succ, const char *sid) =
|
---|
460 | (void (*)(void *, bool, const char *))c;
|
---|
461 |
|
---|
462 | if (!success) {
|
---|
463 | DEBUG(5, ("Could not trigger gid2sid\n"));
|
---|
464 | cont(private_data, False, NULL);
|
---|
465 | return;
|
---|
466 | }
|
---|
467 |
|
---|
468 | if (response->result != WINBINDD_OK) {
|
---|
469 | DEBUG(5, ("gid2sid returned an error\n"));
|
---|
470 | cont(private_data, False, NULL);
|
---|
471 | return;
|
---|
472 | }
|
---|
473 |
|
---|
474 | cont(private_data, True, response->data.sid.sid);
|
---|
475 | }
|
---|
476 |
|
---|
477 | void winbindd_gid2sid_async(TALLOC_CTX *mem_ctx, gid_t gid,
|
---|
478 | void (*cont)(void *private_data, bool success, const char *sid),
|
---|
479 | void *private_data)
|
---|
480 | {
|
---|
481 | struct winbindd_request request;
|
---|
482 |
|
---|
483 | ZERO_STRUCT(request);
|
---|
484 | request.cmd = WINBINDD_DUAL_GID2SID;
|
---|
485 | request.data.gid = gid;
|
---|
486 | do_async(mem_ctx, idmap_child(), &request, winbindd_gid2sid_recv,
|
---|
487 | (void *)cont, private_data);
|
---|
488 | }
|
---|
489 |
|
---|
490 | enum winbindd_result winbindd_dual_gid2sid(struct winbindd_domain *domain,
|
---|
491 | struct winbindd_cli_state *state)
|
---|
492 | {
|
---|
493 | DOM_SID sid;
|
---|
494 | NTSTATUS result;
|
---|
495 |
|
---|
496 | DEBUG(3,("[%5lu]: gid %lu to sid\n",
|
---|
497 | (unsigned long)state->pid,
|
---|
498 | (unsigned long) state->request.data.gid));
|
---|
499 |
|
---|
500 | /* Find sid for this gid and return it, possibly ask the slow remote idmap */
|
---|
501 | result = idmap_gid_to_sid(&sid, state->request.data.gid);
|
---|
502 |
|
---|
503 | if (NT_STATUS_IS_OK(result)) {
|
---|
504 | sid_to_fstring(state->response.data.sid.sid, &sid);
|
---|
505 | DEBUG(10, ("[%5lu]: retrieved sid: %s\n",
|
---|
506 | (unsigned long)state->pid,
|
---|
507 | state->response.data.sid.sid));
|
---|
508 | state->response.data.sid.type = SID_NAME_DOM_GRP;
|
---|
509 | return WINBINDD_OK;
|
---|
510 | }
|
---|
511 |
|
---|
512 | return WINBINDD_ERROR;
|
---|
513 | }
|
---|
514 |
|
---|
515 | static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
|
---|
516 | {
|
---|
517 | .name = "DUAL_SID2UID",
|
---|
518 | .struct_cmd = WINBINDD_DUAL_SID2UID,
|
---|
519 | .struct_fn = winbindd_dual_sid2uid,
|
---|
520 | },{
|
---|
521 | .name = "DUAL_SID2GID",
|
---|
522 | .struct_cmd = WINBINDD_DUAL_SID2GID,
|
---|
523 | .struct_fn = winbindd_dual_sid2gid,
|
---|
524 | #if 0 /* DISABLED until we fix the interface in Samba 3.0.26 --jerry */
|
---|
525 | },{
|
---|
526 | .name = "DUAL_SIDS2XIDS",
|
---|
527 | .struct_cmd = WINBINDD_DUAL_SIDS2XIDS,
|
---|
528 | .struct_fn = winbindd_dual_sids2xids,
|
---|
529 | #endif /* end DISABLED */
|
---|
530 | },{
|
---|
531 | .name = "DUAL_UID2SID",
|
---|
532 | .struct_cmd = WINBINDD_DUAL_UID2SID,
|
---|
533 | .struct_fn = winbindd_dual_uid2sid,
|
---|
534 | },{
|
---|
535 | .name = "DUAL_GID2SID",
|
---|
536 | .struct_cmd = WINBINDD_DUAL_GID2SID,
|
---|
537 | .struct_fn = winbindd_dual_gid2sid,
|
---|
538 | },{
|
---|
539 | .name = "DUAL_SET_MAPPING",
|
---|
540 | .struct_cmd = WINBINDD_DUAL_SET_MAPPING,
|
---|
541 | .struct_fn = winbindd_dual_set_mapping,
|
---|
542 | },{
|
---|
543 | .name = "DUAL_SET_HWMS",
|
---|
544 | .struct_cmd = WINBINDD_DUAL_SET_HWM,
|
---|
545 | .struct_fn = winbindd_dual_set_hwm,
|
---|
546 | },{
|
---|
547 | .name = "ALLOCATE_UID",
|
---|
548 | .struct_cmd = WINBINDD_ALLOCATE_UID,
|
---|
549 | .struct_fn = winbindd_dual_allocate_uid,
|
---|
550 | },{
|
---|
551 | .name = "ALLOCATE_GID",
|
---|
552 | .struct_cmd = WINBINDD_ALLOCATE_GID,
|
---|
553 | .struct_fn = winbindd_dual_allocate_gid,
|
---|
554 | },{
|
---|
555 | .name = NULL,
|
---|
556 | }
|
---|
557 | };
|
---|