diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-04-08 03:45:06 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-04-08 03:45:06 +0200 |
commit | b5d84a74d146cfe0d2e0c336a88bd269ad61cded (patch) | |
tree | 8acad6b634cfe312144f92f8a0fb6ab44b47cd19 /source4/rpc_server/unixinfo | |
parent | 237f1cca028881a57f961884f427673907c1535a (diff) | |
parent | 1f474f4a545752f7ac0ad402d01d1e768b973dbe (diff) | |
download | samba-b5d84a74d146cfe0d2e0c336a88bd269ad61cded.tar.gz samba-b5d84a74d146cfe0d2e0c336a88bd269ad61cded.tar.bz2 samba-b5d84a74d146cfe0d2e0c336a88bd269ad61cded.zip |
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-gmake3
Conflicts:
source/auth/credentials/config.mk
source/auth/gensec/config.mk
source/build/smb_build/makefile.pm
source/heimdal_build/config.mk
source/lib/events/config.mk
source/lib/nss_wrapper/config.mk
source/lib/policy/config.mk
source/lib/registry/config.mk
source/lib/socket_wrapper/config.mk
source/lib/tdb/config.mk
source/lib/tls/config.mk
source/lib/util/config.mk
source/libcli/config.mk
source/libcli/ldap/config.mk
source/libnet/config.mk
source/librpc/config.mk
source/param/config.mk
source/rpc_server/config.mk
source/scripting/ejs/config.mk
source/smbd/process_model.mk
(This used to be commit 760378e0294dd0cd4523a83448328478632d7e3d)
Diffstat (limited to 'source4/rpc_server/unixinfo')
-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, |