diff options
author | Kai Blin <kai@samba.org> | 2008-03-19 19:34:32 +0100 |
---|---|---|
committer | Kai Blin <kai@samba.org> | 2008-04-02 23:06:44 +0200 |
commit | 48b3c38f0f82691f4e0e749176f419744947ac14 (patch) | |
tree | b0548c532eda0c9d58b70d363bb1a0dc7930aae7 /source4 | |
parent | 6ce078141326a41278bbb8c6854c4cacc7cefd99 (diff) | |
download | samba-48b3c38f0f82691f4e0e749176f419744947ac14.tar.gz samba-48b3c38f0f82691f4e0e749176f419744947ac14.tar.bz2 samba-48b3c38f0f82691f4e0e749176f419744947ac14.zip |
rpc_server: Use wbclient instead of sidmap in unixinfo pipe
(This used to be commit 033db9730f1aa6d1941fbb83f55578aaa75e28bd)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/rpc_server/unixinfo/dcesrv_unixinfo.c | 160 |
1 files changed, 119 insertions, 41 deletions
diff --git a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c index 2c08d501d1..e6313b771c 100644 --- a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c +++ b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c @@ -23,53 +23,100 @@ #include "rpc_server/dcerpc_server.h" #include "rpc_server/common/common.h" #include "librpc/gen_ndr/ndr_unixinfo.h" +#include "libcli/wbclient/wbclient.h" #include "lib/events/events.h" -#include "dsdb/samdb/samdb.h" #include "system/passwd.h" #include "param/param.h" +static NTSTATUS dcerpc_unixinfo_bind(struct dcesrv_call_state *dce_call, + const struct dcesrv_interface *iface) +{ + struct wbc_context *wbc_ctx; + + wbc_ctx = wbc_init(dce_call->context, dce_call->msg_ctx, + dce_call->event_ctx); + NT_STATUS_HAVE_NO_MEMORY(wbc_ctx); + + dce_call->context->private = wbc_ctx; + + return NT_STATUS_OK; +} + +#define DCESRV_INTERFACE_UNIXINFO_BIND dcerpc_unixinfo_bind + static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct unixinfo_SidToUid *r) { NTSTATUS status; - struct sidmap_context *sidmap; - uid_t uid; + struct wbc_context *wbc_ctx = talloc_get_type_abort( + dce_call->context->private, + struct wbc_context); + struct id_mapping *ids; + struct composite_context *ctx; - sidmap = sidmap_open(mem_ctx, dce_call->conn->dce_ctx->lp_ctx); - if (sidmap == NULL) { - DEBUG(10, ("sidmap_open failed\n")); - return NT_STATUS_NO_MEMORY; - } + DEBUG(5, ("dcesrv_unixinfo_SidToUid called\n")); + + ids = talloc(mem_ctx, struct id_mapping); + NT_STATUS_HAVE_NO_MEMORY(ids); - status = sidmap_sid_to_unixuid(sidmap, &r->in.sid, &uid); + ids->sid = &r->in.sid; + ids->status = NT_STATUS_NONE_MAPPED; + ids->unixid = NULL; + ctx = wbc_sids_to_xids_send(wbc_ctx, ids, 1, ids); + NT_STATUS_HAVE_NO_MEMORY(ctx); + + status = wbc_sids_to_xids_recv(ctx, &ids); NT_STATUS_NOT_OK_RETURN(status); - *r->out.uid = uid; - return NT_STATUS_OK; + if (ids->unixid->type == ID_TYPE_BOTH || + ids->unixid->type == ID_TYPE_UID) { + *r->out.uid = ids->unixid->id; + return NT_STATUS_OK; + } else { + return NT_STATUS_INVALID_SID; + } } static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct unixinfo_UidToSid *r) { - struct sidmap_context *sidmap; - uid_t uid; - - sidmap = sidmap_open(mem_ctx, dce_call->conn->dce_ctx->lp_ctx); - if (sidmap == NULL) { - DEBUG(10, ("sidmap_open failed\n")); - return NT_STATUS_NO_MEMORY; - } + struct wbc_context *wbc_ctx = talloc_get_type_abort( + dce_call->context->private, + struct wbc_context); + struct id_mapping *ids; + struct composite_context *ctx; + uint32_t uid; + NTSTATUS status; - uid = r->in.uid; /* This cuts uid to (probably) 32 bit */ + DEBUG(5, ("dcesrv_unixinfo_UidToSid called\n")); + uid = r->in.uid; /* This cuts uid to 32 bit */ if ((uint64_t)uid != r->in.uid) { DEBUG(10, ("uid out of range\n")); return NT_STATUS_INVALID_PARAMETER; } - return sidmap_uid_to_sid(sidmap, mem_ctx, uid, &r->out.sid); + ids = talloc(mem_ctx, struct id_mapping); + NT_STATUS_HAVE_NO_MEMORY(ids); + + ids->sid = NULL; + ids->status = NT_STATUS_NONE_MAPPED; + ids->unixid = talloc(ids, struct unixid); + NT_STATUS_HAVE_NO_MEMORY(ids->unixid); + + ids->unixid->id = uid; + ids->unixid->type = ID_TYPE_UID; + + ctx = wbc_xids_to_sids_send(wbc_ctx, ids, 1, ids); + NT_STATUS_HAVE_NO_MEMORY(ctx); + + status = wbc_xids_to_sids_recv(ctx, &ids); + NT_STATUS_NOT_OK_RETURN(status); + + r->out.sid = ids->sid; + return NT_STATUS_OK; } static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call, @@ -77,43 +124,74 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call, struct unixinfo_SidToGid *r) { NTSTATUS status; - struct sidmap_context *sidmap; - gid_t gid; + struct wbc_context *wbc_ctx = talloc_get_type_abort( + dce_call->context->private, + struct wbc_context); + struct id_mapping *ids; + struct composite_context *ctx; - sidmap = sidmap_open(mem_ctx, dce_call->conn->dce_ctx->lp_ctx); - if (sidmap == NULL) { - DEBUG(10, ("sidmap_open failed\n")); - return NT_STATUS_NO_MEMORY; - } + DEBUG(5, ("dcesrv_unixinfo_SidToGid called\n")); - status = sidmap_sid_to_unixgid(sidmap, &r->in.sid, &gid); + ids = talloc(mem_ctx, struct id_mapping); + NT_STATUS_HAVE_NO_MEMORY(ids); + + ids->sid = &r->in.sid; + ids->status = NT_STATUS_NONE_MAPPED; + ids->unixid = NULL; + ctx = wbc_sids_to_xids_send(wbc_ctx, ids, 1, ids); + NT_STATUS_HAVE_NO_MEMORY(ctx); + + status = wbc_sids_to_xids_recv(ctx, &ids); NT_STATUS_NOT_OK_RETURN(status); - *r->out.gid = gid; - return NT_STATUS_OK; + if (ids->unixid->type == ID_TYPE_BOTH || + ids->unixid->type == ID_TYPE_GID) { + *r->out.gid = ids->unixid->id; + return NT_STATUS_OK; + } else { + return NT_STATUS_INVALID_SID; + } } static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct unixinfo_GidToSid *r) { - struct sidmap_context *sidmap; - gid_t gid; - - sidmap = sidmap_open(mem_ctx, dce_call->conn->dce_ctx->lp_ctx); - if (sidmap == NULL) { - DEBUG(10, ("sidmap_open failed\n")); - return NT_STATUS_NO_MEMORY; - } + struct wbc_context *wbc_ctx = talloc_get_type_abort( + dce_call->context->private, + struct wbc_context); + struct id_mapping *ids; + struct composite_context *ctx; + uint32_t gid; + NTSTATUS status; - gid = r->in.gid; /* This cuts gid to (probably) 32 bit */ + DEBUG(5, ("dcesrv_unixinfo_GidToSid called\n")); + gid = r->in.gid; /* This cuts gid to 32 bit */ if ((uint64_t)gid != r->in.gid) { DEBUG(10, ("gid out of range\n")); return NT_STATUS_INVALID_PARAMETER; } - return sidmap_gid_to_sid(sidmap, mem_ctx, gid, &r->out.sid); + ids = talloc(mem_ctx, struct id_mapping); + NT_STATUS_HAVE_NO_MEMORY(ids); + + ids->sid = NULL; + ids->status = NT_STATUS_NONE_MAPPED; + ids->unixid = talloc(ids, struct unixid); + NT_STATUS_HAVE_NO_MEMORY(ids->unixid); + + ids->unixid->id = gid; + ids->unixid->type = ID_TYPE_GID; + + ctx = wbc_xids_to_sids_send(wbc_ctx, ids, 1, ids); + NT_STATUS_HAVE_NO_MEMORY(ctx); + + status = wbc_xids_to_sids_recv(ctx, &ids); + NT_STATUS_NOT_OK_RETURN(status); + + r->out.sid = ids->sid; + return NT_STATUS_OK; } static NTSTATUS dcesrv_unixinfo_GetPWUid(struct dcesrv_call_state *dce_call, |