summaryrefslogtreecommitdiff
path: root/source4/winbind/wb_sid2gid.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-03-19 10:18:35 +1100
committerAndrew Bartlett <abartlet@samba.org>2008-03-19 10:18:35 +1100
commitb1b37e3776c6e6e20f42140a907e296b65cc0c62 (patch)
tree601f049791bcbd9df9daef64b0b1003dbf1a413b /source4/winbind/wb_sid2gid.c
parent9e6b0c28712ee77ce878809c8576826a3ba08d95 (diff)
parent52669d84722c175555e17a222077f845d9aa958f (diff)
downloadsamba-b1b37e3776c6e6e20f42140a907e296b65cc0c62.tar.gz
samba-b1b37e3776c6e6e20f42140a907e296b65cc0c62.tar.bz2
samba-b1b37e3776c6e6e20f42140a907e296b65cc0c62.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-local
(This used to be commit 400c16e7004bc3a881bb6efb99a273cdac87f70c)
Diffstat (limited to 'source4/winbind/wb_sid2gid.c')
-rw-r--r--source4/winbind/wb_sid2gid.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/source4/winbind/wb_sid2gid.c b/source4/winbind/wb_sid2gid.c
index 12129226be..d68956ce85 100644
--- a/source4/winbind/wb_sid2gid.c
+++ b/source4/winbind/wb_sid2gid.c
@@ -3,7 +3,7 @@
Map a SID to a gid
- Copyright (C) Kai Blin 2007
+ Copyright (C) 2007-2008 Kai Blin
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -33,11 +33,14 @@ struct sid2gid_state {
gid_t gid;
};
+static void sid2gid_recv_gid(struct composite_context *ctx);
+
struct composite_context *wb_sid2gid_send(TALLOC_CTX *mem_ctx,
struct wbsrv_service *service, const struct dom_sid *sid)
{
- struct composite_context *result;
+ struct composite_context *result, *ctx;
struct sid2gid_state *state;
+ struct id_mapping *ids;
DEBUG(5, ("wb_sid2gid_send called\n"));
@@ -51,18 +54,43 @@ struct composite_context *wb_sid2gid_send(TALLOC_CTX *mem_ctx,
result->private_data = state;
state->service = service;
- state->ctx->status = idmap_sid_to_gid(service->idmap_ctx, state, sid,
- &state->gid);
- if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) {
- state->ctx->status = idmap_sid_to_gid(service->idmap_ctx, state,
- sid, &state->gid);
- }
- if (!composite_is_ok(state->ctx)) return result;
+ ids = talloc(result, struct id_mapping);
+ if (composite_nomem(ids, result)) return result;
+
+ ids->sid = dom_sid_dup(result, sid);
+ if (composite_nomem(ids->sid, result)) return result;
+
+ ctx = wb_sids2xids_send(result, service, 1, ids);
+ if (composite_nomem(ctx, result)) return result;
- composite_done(state->ctx);
+ composite_continue(result, ctx, sid2gid_recv_gid, state);
return result;
}
+static void sid2gid_recv_gid(struct composite_context *ctx)
+{
+ struct sid2gid_state *state = talloc_get_type(ctx->async.private_data,
+ struct sid2gid_state);
+
+ struct id_mapping *ids = NULL;
+
+ state->ctx->status = wb_sids2xids_recv(ctx, &ids);
+ if (!composite_is_ok(state->ctx)) return;
+
+ if (!NT_STATUS_IS_OK(ids->status)) {
+ composite_error(state->ctx, ids->status);
+ return;
+ }
+
+ if (ids->unixid->type == ID_TYPE_BOTH ||
+ ids->unixid->type == ID_TYPE_GID) {
+ state->gid = ids->unixid->id;
+ composite_done(state->ctx);
+ } else {
+ composite_error(state->ctx, NT_STATUS_INVALID_SID);
+ }
+}
+
NTSTATUS wb_sid2gid_recv(struct composite_context *ctx, gid_t *gid)
{
NTSTATUS status = composite_wait(ctx);