From 5a0aaafb1b4d196cfc873753e7ae7833c067202b Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 13 Aug 2007 16:45:51 +0000 Subject: r24376: Missed this file from the checkin, sorry. (This used to be commit c81b0980cac901e70e52dfd0eb013ad4d6f15540) --- source4/winbind/wb_gid2sid.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 source4/winbind/wb_gid2sid.c (limited to 'source4/winbind/wb_gid2sid.c') diff --git a/source4/winbind/wb_gid2sid.c b/source4/winbind/wb_gid2sid.c new file mode 100644 index 0000000000..40fd9b6c35 --- /dev/null +++ b/source4/winbind/wb_gid2sid.c @@ -0,0 +1,78 @@ +/* + Unix SMB/CIFS implementation. + + Command backend for wbinfo -G + + Copyright (C) Kai Blin 2007 + + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "includes.h" +#include "libcli/composite/composite.h" +#include "winbind/wb_server.h" +#include "smbd/service_task.h" +#include "winbind/wb_helper.h" +#include "libcli/security/proto.h" + +struct gid2sid_state { + struct composite_context *ctx; + struct wbsrv_service *service; + struct dom_sid *sid; +}; + +struct composite_context *wb_gid2sid_send(TALLOC_CTX *mem_ctx, + struct wbsrv_service *service, uid_t uid) +{ + struct composite_context *result; + struct gid2sid_state *state; + + DEBUG(5, ("wb_gid2sid_send called\n")); + + result = composite_create(mem_ctx, service->task->event_ctx); + if (!result) return NULL; + + state = talloc(mem_ctx, struct gid2sid_state); + if (composite_nomem(state, result)) return result; + + state->ctx = result; + result->private_data = state; + state->service = service; + + /* FIXME: This is a stub so far. + * We cheat by just using the uid as RID with the domain SID.*/ + state->sid = dom_sid_add_rid(result, service->primary_sid, uid); + if (composite_nomem(state->sid, state->ctx)) return result; + + composite_done(state->ctx); + return result; +} + +NTSTATUS wb_gid2sid_recv(struct composite_context *ctx, TALLOC_CTX *mem_ctx, + struct dom_sid **sid) +{ + NTSTATUS status = composite_wait(ctx); + + DEBUG(5, ("wb_gid2sid_recv called.\n")); + + if (NT_STATUS_IS_OK(status)) { + struct gid2sid_state *state = + talloc_get_type(ctx->private_data, + struct gid2sid_state); + *sid = talloc_steal(mem_ctx, state->sid); + } + talloc_free(ctx); + return status; +} + -- cgit From 0b96f54f04237df6045a63c9cd1b9563cd30682a Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Tue, 14 Aug 2007 07:18:41 +0000 Subject: r24396: Fix a typo. Thanks to metze (metze@samba.org) for catching this one. (This used to be commit abf631822da6221af187498cde9fe068cd91ee43) --- source4/winbind/wb_gid2sid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/winbind/wb_gid2sid.c') diff --git a/source4/winbind/wb_gid2sid.c b/source4/winbind/wb_gid2sid.c index 40fd9b6c35..5c0b87118d 100644 --- a/source4/winbind/wb_gid2sid.c +++ b/source4/winbind/wb_gid2sid.c @@ -33,7 +33,7 @@ struct gid2sid_state { }; struct composite_context *wb_gid2sid_send(TALLOC_CTX *mem_ctx, - struct wbsrv_service *service, uid_t uid) + struct wbsrv_service *service, gid_t gid) { struct composite_context *result; struct gid2sid_state *state; @@ -51,8 +51,8 @@ struct composite_context *wb_gid2sid_send(TALLOC_CTX *mem_ctx, state->service = service; /* FIXME: This is a stub so far. - * We cheat by just using the uid as RID with the domain SID.*/ - state->sid = dom_sid_add_rid(result, service->primary_sid, uid); + * We cheat by just using the gid as RID with the domain SID.*/ + state->sid = dom_sid_add_rid(result, service->primary_sid, gid); if (composite_nomem(state->sid, state->ctx)) return result; composite_done(state->ctx); -- cgit From 9c7f714962bdfe280baed42ed6a1e35a422a0267 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 18 Feb 2008 14:30:17 +0100 Subject: idmap: Handle gid->SID mapping (This used to be commit 6f2d95030cd7b4b22d1b75d15b76881449eda697) --- source4/winbind/wb_gid2sid.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source4/winbind/wb_gid2sid.c') diff --git a/source4/winbind/wb_gid2sid.c b/source4/winbind/wb_gid2sid.c index 5c0b87118d..f2577029aa 100644 --- a/source4/winbind/wb_gid2sid.c +++ b/source4/winbind/wb_gid2sid.c @@ -25,6 +25,7 @@ #include "smbd/service_task.h" #include "winbind/wb_helper.h" #include "libcli/security/proto.h" +#include "winbind/idmap.h" struct gid2sid_state { struct composite_context *ctx; @@ -50,10 +51,14 @@ struct composite_context *wb_gid2sid_send(TALLOC_CTX *mem_ctx, result->private_data = state; state->service = service; - /* FIXME: This is a stub so far. - * We cheat by just using the gid as RID with the domain SID.*/ - state->sid = dom_sid_add_rid(result, service->primary_sid, gid); - if (composite_nomem(state->sid, state->ctx)) return result; + state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, mem_ctx, gid, + &state->sid); + if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { + state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, + mem_ctx, gid, + &state->sid); + } + if (!composite_is_ok(state->ctx)) return result; composite_done(state->ctx); return result; -- cgit From a1875b039bb77bad9c3cef4e1ebe037a7e645938 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Thu, 6 Mar 2008 00:52:37 +0100 Subject: idmap: Map SIDs to unixids instead of uids/gids (This used to be commit 73ac7c4a1ce937bddd3c52d048665cd0078c6aaa) --- source4/winbind/wb_gid2sid.c | 47 +++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'source4/winbind/wb_gid2sid.c') diff --git a/source4/winbind/wb_gid2sid.c b/source4/winbind/wb_gid2sid.c index f2577029aa..834d869845 100644 --- a/source4/winbind/wb_gid2sid.c +++ b/source4/winbind/wb_gid2sid.c @@ -3,7 +3,7 @@ Command backend for wbinfo -G - 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,35 +33,60 @@ struct gid2sid_state { struct dom_sid *sid; }; +static void gid2sid_recv_sid(struct composite_context *ctx); + struct composite_context *wb_gid2sid_send(TALLOC_CTX *mem_ctx, struct wbsrv_service *service, gid_t gid) { - struct composite_context *result; + struct composite_context *result, *ctx; struct gid2sid_state *state; + struct unixid *unixid; + struct id_mapping *ids; DEBUG(5, ("wb_gid2sid_send called\n")); result = composite_create(mem_ctx, service->task->event_ctx); if (!result) return NULL; - state = talloc(mem_ctx, struct gid2sid_state); + state = talloc(result, struct gid2sid_state); if (composite_nomem(state, result)) return result; state->ctx = result; result->private_data = state; state->service = service; - state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, mem_ctx, gid, - &state->sid); - if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) { - state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, - mem_ctx, gid, - &state->sid); + unixid = talloc(result, struct unixid); + if (composite_nomem(unixid, result)) return result; + unixid->id = gid; + unixid->type = ID_TYPE_GID; + + ids = talloc(result, struct id_mapping); + if (composite_nomem(ids, result)) return result; + ids->unixid = unixid; + ids->sid = NULL; + + ctx = wb_xids2sids_send(result, service, 1, ids); + if (composite_nomem(ctx, result)) return result; + + composite_continue(result, ctx, gid2sid_recv_sid, state); + return result; +} + +static void gid2sid_recv_sid(struct composite_context *ctx) +{ + struct gid2sid_state *state = talloc_get_type(ctx->async.private_data, + struct gid2sid_state); + struct id_mapping *ids = NULL; + state->ctx->status = wb_xids2sids_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 (!composite_is_ok(state->ctx)) return result; + state->sid = ids->sid; composite_done(state->ctx); - return result; } NTSTATUS wb_gid2sid_recv(struct composite_context *ctx, TALLOC_CTX *mem_ctx, -- cgit