mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
w3:winbind: Convert WINBINDD_ALLOCATE_GID to the new API
This commit is contained in:
parent
9e7c6f12fd
commit
0cae043b0c
@ -1191,6 +1191,7 @@ WINBINDD_OBJ1 = \
|
||||
winbindd/winbindd_uid_to_sid.o \
|
||||
winbindd/winbindd_gid_to_sid.o \
|
||||
winbindd/winbindd_allocate_uid.o \
|
||||
winbindd/winbindd_allocate_gid.o \
|
||||
winbindd/winbindd_getpwsid.o \
|
||||
winbindd/winbindd_getpwnam.o \
|
||||
winbindd/winbindd_getpwuid.o \
|
||||
|
@ -1319,6 +1319,163 @@ NTSTATUS rpccli_wbint_AllocateUid(struct rpc_pipe_client *cli,
|
||||
return r.out.result;
|
||||
}
|
||||
|
||||
struct rpccli_wbint_AllocateGid_state {
|
||||
struct wbint_AllocateGid orig;
|
||||
struct wbint_AllocateGid tmp;
|
||||
TALLOC_CTX *out_mem_ctx;
|
||||
NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
|
||||
};
|
||||
|
||||
static void rpccli_wbint_AllocateGid_done(struct tevent_req *subreq);
|
||||
|
||||
struct tevent_req *rpccli_wbint_AllocateGid_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct rpc_pipe_client *cli,
|
||||
uint64_t *_gid /* [out] [ref] */)
|
||||
{
|
||||
struct tevent_req *req;
|
||||
struct rpccli_wbint_AllocateGid_state *state;
|
||||
struct tevent_req *subreq;
|
||||
|
||||
req = tevent_req_create(mem_ctx, &state,
|
||||
struct rpccli_wbint_AllocateGid_state);
|
||||
if (req == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
state->out_mem_ctx = NULL;
|
||||
state->dispatch_recv = cli->dispatch_recv;
|
||||
|
||||
/* In parameters */
|
||||
|
||||
/* Out parameters */
|
||||
state->orig.out.gid = _gid;
|
||||
|
||||
/* Result */
|
||||
ZERO_STRUCT(state->orig.out.result);
|
||||
|
||||
if (DEBUGLEVEL >= 10) {
|
||||
NDR_PRINT_IN_DEBUG(wbint_AllocateGid, &state->orig);
|
||||
}
|
||||
|
||||
state->out_mem_ctx = talloc_named_const(state, 0,
|
||||
"rpccli_wbint_AllocateGid_out_memory");
|
||||
if (tevent_req_nomem(state->out_mem_ctx, req)) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
|
||||
/* make a temporary copy, that we pass to the dispatch function */
|
||||
state->tmp = state->orig;
|
||||
|
||||
subreq = cli->dispatch_send(state, ev, cli,
|
||||
&ndr_table_wbint,
|
||||
NDR_WBINT_ALLOCATEGID,
|
||||
&state->tmp);
|
||||
if (tevent_req_nomem(subreq, req)) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
tevent_req_set_callback(subreq, rpccli_wbint_AllocateGid_done, req);
|
||||
return req;
|
||||
}
|
||||
|
||||
static void rpccli_wbint_AllocateGid_done(struct tevent_req *subreq)
|
||||
{
|
||||
struct tevent_req *req = tevent_req_callback_data(
|
||||
subreq, struct tevent_req);
|
||||
struct rpccli_wbint_AllocateGid_state *state = tevent_req_data(
|
||||
req, struct rpccli_wbint_AllocateGid_state);
|
||||
NTSTATUS status;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
|
||||
if (state->out_mem_ctx) {
|
||||
mem_ctx = state->out_mem_ctx;
|
||||
} else {
|
||||
mem_ctx = state;
|
||||
}
|
||||
|
||||
status = state->dispatch_recv(subreq, mem_ctx);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
tevent_req_nterror(req, status);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Copy out parameters */
|
||||
*state->orig.out.gid = *state->tmp.out.gid;
|
||||
|
||||
/* Copy result */
|
||||
state->orig.out.result = state->tmp.out.result;
|
||||
|
||||
/* Reset temporary structure */
|
||||
ZERO_STRUCT(state->tmp);
|
||||
|
||||
if (DEBUGLEVEL >= 10) {
|
||||
NDR_PRINT_OUT_DEBUG(wbint_AllocateGid, &state->orig);
|
||||
}
|
||||
|
||||
tevent_req_done(req);
|
||||
}
|
||||
|
||||
NTSTATUS rpccli_wbint_AllocateGid_recv(struct tevent_req *req,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
NTSTATUS *result)
|
||||
{
|
||||
struct rpccli_wbint_AllocateGid_state *state = tevent_req_data(
|
||||
req, struct rpccli_wbint_AllocateGid_state);
|
||||
NTSTATUS status;
|
||||
|
||||
if (tevent_req_is_nterror(req, &status)) {
|
||||
tevent_req_received(req);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Steal possbile out parameters to the callers context */
|
||||
talloc_steal(mem_ctx, state->out_mem_ctx);
|
||||
|
||||
/* Return result */
|
||||
*result = state->orig.out.result;
|
||||
|
||||
tevent_req_received(req);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS rpccli_wbint_AllocateGid(struct rpc_pipe_client *cli,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
uint64_t *gid /* [out] [ref] */)
|
||||
{
|
||||
struct wbint_AllocateGid r;
|
||||
NTSTATUS status;
|
||||
|
||||
/* In parameters */
|
||||
|
||||
if (DEBUGLEVEL >= 10) {
|
||||
NDR_PRINT_IN_DEBUG(wbint_AllocateGid, &r);
|
||||
}
|
||||
|
||||
status = cli->dispatch(cli,
|
||||
mem_ctx,
|
||||
&ndr_table_wbint,
|
||||
NDR_WBINT_ALLOCATEGID,
|
||||
&r);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (DEBUGLEVEL >= 10) {
|
||||
NDR_PRINT_OUT_DEBUG(wbint_AllocateGid, &r);
|
||||
}
|
||||
|
||||
if (NT_STATUS_IS_ERR(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Return variables */
|
||||
*gid = *r.out.gid;
|
||||
|
||||
/* Return result */
|
||||
return r.out.result;
|
||||
}
|
||||
|
||||
struct rpccli_wbint_QueryUser_state {
|
||||
struct wbint_QueryUser orig;
|
||||
struct wbint_QueryUser tmp;
|
||||
|
@ -112,6 +112,16 @@ NTSTATUS rpccli_wbint_AllocateUid_recv(struct tevent_req *req,
|
||||
NTSTATUS rpccli_wbint_AllocateUid(struct rpc_pipe_client *cli,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
uint64_t *uid /* [out] [ref] */);
|
||||
struct tevent_req *rpccli_wbint_AllocateGid_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct rpc_pipe_client *cli,
|
||||
uint64_t *_gid /* [out] [ref] */);
|
||||
NTSTATUS rpccli_wbint_AllocateGid_recv(struct tevent_req *req,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
NTSTATUS *result);
|
||||
NTSTATUS rpccli_wbint_AllocateGid(struct rpc_pipe_client *cli,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
uint64_t *gid /* [out] [ref] */);
|
||||
struct tevent_req *rpccli_wbint_QueryUser_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct rpc_pipe_client *cli,
|
||||
|
@ -1319,6 +1319,67 @@ _PUBLIC_ void ndr_print_wbint_AllocateUid(struct ndr_print *ndr, const char *nam
|
||||
ndr->depth--;
|
||||
}
|
||||
|
||||
static enum ndr_err_code ndr_push_wbint_AllocateGid(struct ndr_push *ndr, int flags, const struct wbint_AllocateGid *r)
|
||||
{
|
||||
if (flags & NDR_IN) {
|
||||
}
|
||||
if (flags & NDR_OUT) {
|
||||
if (r->out.gid == NULL) {
|
||||
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
|
||||
}
|
||||
NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, *r->out.gid));
|
||||
NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
|
||||
}
|
||||
return NDR_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
static enum ndr_err_code ndr_pull_wbint_AllocateGid(struct ndr_pull *ndr, int flags, struct wbint_AllocateGid *r)
|
||||
{
|
||||
TALLOC_CTX *_mem_save_gid_0;
|
||||
if (flags & NDR_IN) {
|
||||
ZERO_STRUCT(r->out);
|
||||
|
||||
NDR_PULL_ALLOC(ndr, r->out.gid);
|
||||
ZERO_STRUCTP(r->out.gid);
|
||||
}
|
||||
if (flags & NDR_OUT) {
|
||||
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
|
||||
NDR_PULL_ALLOC(ndr, r->out.gid);
|
||||
}
|
||||
_mem_save_gid_0 = NDR_PULL_GET_MEM_CTX(ndr);
|
||||
NDR_PULL_SET_MEM_CTX(ndr, r->out.gid, LIBNDR_FLAG_REF_ALLOC);
|
||||
NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, r->out.gid));
|
||||
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_gid_0, LIBNDR_FLAG_REF_ALLOC);
|
||||
NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
|
||||
}
|
||||
return NDR_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
_PUBLIC_ void ndr_print_wbint_AllocateGid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_AllocateGid *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name, "wbint_AllocateGid");
|
||||
ndr->depth++;
|
||||
if (flags & NDR_SET_VALUES) {
|
||||
ndr->flags |= LIBNDR_PRINT_SET_VALUES;
|
||||
}
|
||||
if (flags & NDR_IN) {
|
||||
ndr_print_struct(ndr, "in", "wbint_AllocateGid");
|
||||
ndr->depth++;
|
||||
ndr->depth--;
|
||||
}
|
||||
if (flags & NDR_OUT) {
|
||||
ndr_print_struct(ndr, "out", "wbint_AllocateGid");
|
||||
ndr->depth++;
|
||||
ndr_print_ptr(ndr, "gid", r->out.gid);
|
||||
ndr->depth++;
|
||||
ndr_print_hyper(ndr, "gid", *r->out.gid);
|
||||
ndr->depth--;
|
||||
ndr_print_NTSTATUS(ndr, "result", r->out.result);
|
||||
ndr->depth--;
|
||||
}
|
||||
ndr->depth--;
|
||||
}
|
||||
|
||||
static enum ndr_err_code ndr_push_wbint_QueryUser(struct ndr_push *ndr, int flags, const struct wbint_QueryUser *r)
|
||||
{
|
||||
if (flags & NDR_IN) {
|
||||
@ -2115,6 +2176,14 @@ static const struct ndr_interface_call wbint_calls[] = {
|
||||
(ndr_print_function_t) ndr_print_wbint_AllocateUid,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"wbint_AllocateGid",
|
||||
sizeof(struct wbint_AllocateGid),
|
||||
(ndr_push_flags_fn_t) ndr_push_wbint_AllocateGid,
|
||||
(ndr_pull_flags_fn_t) ndr_pull_wbint_AllocateGid,
|
||||
(ndr_print_function_t) ndr_print_wbint_AllocateGid,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"wbint_QueryUser",
|
||||
sizeof(struct wbint_QueryUser),
|
||||
@ -2216,7 +2285,7 @@ const struct ndr_interface_table ndr_table_wbint = {
|
||||
NDR_WBINT_VERSION
|
||||
},
|
||||
.helpstring = NDR_WBINT_HELPSTRING,
|
||||
.num_calls = 17,
|
||||
.num_calls = 18,
|
||||
.calls = wbint_calls,
|
||||
.endpoints = &wbint_endpoints,
|
||||
.authservices = &wbint_authservices
|
||||
|
@ -27,25 +27,27 @@ extern const struct ndr_interface_table ndr_table_wbint;
|
||||
|
||||
#define NDR_WBINT_ALLOCATEUID (0x07)
|
||||
|
||||
#define NDR_WBINT_QUERYUSER (0x08)
|
||||
#define NDR_WBINT_ALLOCATEGID (0x08)
|
||||
|
||||
#define NDR_WBINT_LOOKUPUSERALIASES (0x09)
|
||||
#define NDR_WBINT_QUERYUSER (0x09)
|
||||
|
||||
#define NDR_WBINT_LOOKUPUSERGROUPS (0x0a)
|
||||
#define NDR_WBINT_LOOKUPUSERALIASES (0x0a)
|
||||
|
||||
#define NDR_WBINT_QUERYSEQUENCENUMBER (0x0b)
|
||||
#define NDR_WBINT_LOOKUPUSERGROUPS (0x0b)
|
||||
|
||||
#define NDR_WBINT_LOOKUPGROUPMEMBERS (0x0c)
|
||||
#define NDR_WBINT_QUERYSEQUENCENUMBER (0x0c)
|
||||
|
||||
#define NDR_WBINT_QUERYUSERLIST (0x0d)
|
||||
#define NDR_WBINT_LOOKUPGROUPMEMBERS (0x0d)
|
||||
|
||||
#define NDR_WBINT_QUERYGROUPLIST (0x0e)
|
||||
#define NDR_WBINT_QUERYUSERLIST (0x0e)
|
||||
|
||||
#define NDR_WBINT_DSGETDCNAME (0x0f)
|
||||
#define NDR_WBINT_QUERYGROUPLIST (0x0f)
|
||||
|
||||
#define NDR_WBINT_LOOKUPRIDS (0x10)
|
||||
#define NDR_WBINT_DSGETDCNAME (0x10)
|
||||
|
||||
#define NDR_WBINT_CALL_COUNT (17)
|
||||
#define NDR_WBINT_LOOKUPRIDS (0x11)
|
||||
|
||||
#define NDR_WBINT_CALL_COUNT (18)
|
||||
enum ndr_err_code ndr_push_wbint_userinfo(struct ndr_push *ndr, int ndr_flags, const struct wbint_userinfo *r);
|
||||
enum ndr_err_code ndr_pull_wbint_userinfo(struct ndr_pull *ndr, int ndr_flags, struct wbint_userinfo *r);
|
||||
void ndr_print_wbint_userinfo(struct ndr_print *ndr, const char *name, const struct wbint_userinfo *r);
|
||||
@ -72,6 +74,7 @@ void ndr_print_wbint_Sid2Gid(struct ndr_print *ndr, const char *name, int flags,
|
||||
void ndr_print_wbint_Uid2Sid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_Uid2Sid *r);
|
||||
void ndr_print_wbint_Gid2Sid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_Gid2Sid *r);
|
||||
void ndr_print_wbint_AllocateUid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_AllocateUid *r);
|
||||
void ndr_print_wbint_AllocateGid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_AllocateGid *r);
|
||||
void ndr_print_wbint_QueryUser(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QueryUser *r);
|
||||
void ndr_print_wbint_LookupUserAliases(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupUserAliases *r);
|
||||
void ndr_print_wbint_LookupUserGroups(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupUserGroups *r);
|
||||
|
@ -664,6 +664,86 @@ static bool api_wbint_AllocateUid(pipes_struct *p)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool api_wbint_AllocateGid(pipes_struct *p)
|
||||
{
|
||||
const struct ndr_interface_call *call;
|
||||
struct ndr_pull *pull;
|
||||
struct ndr_push *push;
|
||||
enum ndr_err_code ndr_err;
|
||||
DATA_BLOB blob;
|
||||
struct wbint_AllocateGid *r;
|
||||
|
||||
call = &ndr_table_wbint.calls[NDR_WBINT_ALLOCATEGID];
|
||||
|
||||
r = talloc(talloc_tos(), struct wbint_AllocateGid);
|
||||
if (r == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!prs_data_blob(&p->in_data.data, &blob, r)) {
|
||||
talloc_free(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
pull = ndr_pull_init_blob(&blob, r, NULL);
|
||||
if (pull == NULL) {
|
||||
talloc_free(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
pull->flags |= LIBNDR_FLAG_REF_ALLOC;
|
||||
ndr_err = call->ndr_pull(pull, NDR_IN, r);
|
||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||
talloc_free(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DEBUGLEVEL >= 10) {
|
||||
NDR_PRINT_IN_DEBUG(wbint_AllocateGid, r);
|
||||
}
|
||||
|
||||
ZERO_STRUCT(r->out);
|
||||
r->out.gid = talloc_zero(r, uint64_t);
|
||||
if (r->out.gid == NULL) {
|
||||
talloc_free(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
r->out.result = _wbint_AllocateGid(p, r);
|
||||
|
||||
if (p->rng_fault_state) {
|
||||
talloc_free(r);
|
||||
/* Return true here, srv_pipe_hnd.c will take care */
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DEBUGLEVEL >= 10) {
|
||||
NDR_PRINT_OUT_DEBUG(wbint_AllocateGid, r);
|
||||
}
|
||||
|
||||
push = ndr_push_init_ctx(r, NULL);
|
||||
if (push == NULL) {
|
||||
talloc_free(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
ndr_err = call->ndr_push(push, NDR_OUT, r);
|
||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||
talloc_free(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
blob = ndr_push_blob(push);
|
||||
if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
|
||||
talloc_free(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
talloc_free(r);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool api_wbint_QueryUser(pipes_struct *p)
|
||||
{
|
||||
const struct ndr_interface_call *call;
|
||||
@ -1396,6 +1476,7 @@ static struct api_struct api_wbint_cmds[] =
|
||||
{"WBINT_UID2SID", NDR_WBINT_UID2SID, api_wbint_Uid2Sid},
|
||||
{"WBINT_GID2SID", NDR_WBINT_GID2SID, api_wbint_Gid2Sid},
|
||||
{"WBINT_ALLOCATEUID", NDR_WBINT_ALLOCATEUID, api_wbint_AllocateUid},
|
||||
{"WBINT_ALLOCATEGID", NDR_WBINT_ALLOCATEGID, api_wbint_AllocateGid},
|
||||
{"WBINT_QUERYUSER", NDR_WBINT_QUERYUSER, api_wbint_QueryUser},
|
||||
{"WBINT_LOOKUPUSERALIASES", NDR_WBINT_LOOKUPUSERALIASES, api_wbint_LookupUserAliases},
|
||||
{"WBINT_LOOKUPUSERGROUPS", NDR_WBINT_LOOKUPUSERGROUPS, api_wbint_LookupUserGroups},
|
||||
@ -1532,6 +1613,18 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
case NDR_WBINT_ALLOCATEGID: {
|
||||
struct wbint_AllocateGid *r = (struct wbint_AllocateGid *)_r;
|
||||
ZERO_STRUCT(r->out);
|
||||
r->out.gid = talloc_zero(mem_ctx, uint64_t);
|
||||
if (r->out.gid == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
r->out.result = _wbint_AllocateGid(cli->pipes_struct, r);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
case NDR_WBINT_QUERYUSER: {
|
||||
struct wbint_QueryUser *r = (struct wbint_QueryUser *)_r;
|
||||
ZERO_STRUCT(r->out);
|
||||
|
@ -9,6 +9,7 @@ NTSTATUS _wbint_Sid2Gid(pipes_struct *p, struct wbint_Sid2Gid *r);
|
||||
NTSTATUS _wbint_Uid2Sid(pipes_struct *p, struct wbint_Uid2Sid *r);
|
||||
NTSTATUS _wbint_Gid2Sid(pipes_struct *p, struct wbint_Gid2Sid *r);
|
||||
NTSTATUS _wbint_AllocateUid(pipes_struct *p, struct wbint_AllocateUid *r);
|
||||
NTSTATUS _wbint_AllocateGid(pipes_struct *p, struct wbint_AllocateGid *r);
|
||||
NTSTATUS _wbint_QueryUser(pipes_struct *p, struct wbint_QueryUser *r);
|
||||
NTSTATUS _wbint_LookupUserAliases(pipes_struct *p, struct wbint_LookupUserAliases *r);
|
||||
NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, struct wbint_LookupUserGroups *r);
|
||||
@ -28,6 +29,7 @@ NTSTATUS _wbint_Sid2Gid(pipes_struct *p, struct wbint_Sid2Gid *r);
|
||||
NTSTATUS _wbint_Uid2Sid(pipes_struct *p, struct wbint_Uid2Sid *r);
|
||||
NTSTATUS _wbint_Gid2Sid(pipes_struct *p, struct wbint_Gid2Sid *r);
|
||||
NTSTATUS _wbint_AllocateUid(pipes_struct *p, struct wbint_AllocateUid *r);
|
||||
NTSTATUS _wbint_AllocateGid(pipes_struct *p, struct wbint_AllocateGid *r);
|
||||
NTSTATUS _wbint_QueryUser(pipes_struct *p, struct wbint_QueryUser *r);
|
||||
NTSTATUS _wbint_LookupUserAliases(pipes_struct *p, struct wbint_LookupUserAliases *r);
|
||||
NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, struct wbint_LookupUserGroups *r);
|
||||
|
@ -153,6 +153,15 @@ struct wbint_AllocateUid {
|
||||
};
|
||||
|
||||
|
||||
struct wbint_AllocateGid {
|
||||
struct {
|
||||
uint64_t *gid;/* [ref] */
|
||||
NTSTATUS result;
|
||||
} out;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct wbint_QueryUser {
|
||||
struct {
|
||||
struct dom_sid *sid;/* [ref] */
|
||||
|
@ -58,6 +58,10 @@ interface wbint
|
||||
[out] hyper *uid
|
||||
);
|
||||
|
||||
NTSTATUS wbint_AllocateGid(
|
||||
[out] hyper *gid
|
||||
);
|
||||
|
||||
typedef [public] struct {
|
||||
[string,charset(UTF8)] char *acct_name;
|
||||
[string,charset(UTF8)] char *full_name;
|
||||
|
@ -440,7 +440,6 @@ static struct winbindd_dispatch_table {
|
||||
|
||||
/* Lookup related functions */
|
||||
|
||||
{ WINBINDD_ALLOCATE_GID, winbindd_allocate_gid, "ALLOCATE_GID" },
|
||||
{ WINBINDD_SET_MAPPING, winbindd_set_mapping, "SET_MAPPING" },
|
||||
{ WINBINDD_REMOVE_MAPPING, winbindd_remove_mapping, "REMOVE_MAPPING" },
|
||||
{ WINBINDD_SET_HWM, winbindd_set_hwm, "SET_HWMS" },
|
||||
@ -545,6 +544,8 @@ static struct winbindd_async_dispatch_table async_nonpriv_table[] = {
|
||||
static struct winbindd_async_dispatch_table async_priv_table[] = {
|
||||
{ WINBINDD_ALLOCATE_UID, "ALLOCATE_UID",
|
||||
winbindd_allocate_uid_send, winbindd_allocate_uid_recv },
|
||||
{ WINBINDD_ALLOCATE_GID, "ALLOCATE_GID",
|
||||
winbindd_allocate_gid_send, winbindd_allocate_gid_recv },
|
||||
|
||||
{ 0, NULL, NULL, NULL }
|
||||
};
|
||||
|
92
source3/winbindd/winbindd_allocate_gid.c
Normal file
92
source3/winbindd/winbindd_allocate_gid.c
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
async implementation of WINBINDD_ALLOCATE_GID
|
||||
Copyright (C) Volker Lendecke 2009
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "winbindd.h"
|
||||
#include "librpc/gen_ndr/cli_wbint.h"
|
||||
|
||||
struct winbindd_allocate_gid_state {
|
||||
uint64_t gid;
|
||||
};
|
||||
|
||||
static void winbindd_allocate_gid_done(struct tevent_req *subreq);
|
||||
|
||||
struct tevent_req *winbindd_allocate_gid_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct winbindd_cli_state *cli,
|
||||
struct winbindd_request *request)
|
||||
{
|
||||
struct tevent_req *req, *subreq;
|
||||
struct winbindd_allocate_gid_state *state;
|
||||
struct winbindd_child *child;
|
||||
|
||||
req = tevent_req_create(mem_ctx, &state,
|
||||
struct winbindd_allocate_gid_state);
|
||||
if (req == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG(3, ("allocate_gid\n"));
|
||||
|
||||
child = idmap_child();
|
||||
|
||||
subreq = rpccli_wbint_AllocateGid_send(state, ev, child->rpccli,
|
||||
&state->gid);
|
||||
if (tevent_req_nomem(subreq, req)) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
tevent_req_set_callback(subreq, winbindd_allocate_gid_done, req);
|
||||
return req;
|
||||
}
|
||||
|
||||
static void winbindd_allocate_gid_done(struct tevent_req *subreq)
|
||||
{
|
||||
struct tevent_req *req = tevent_req_callback_data(
|
||||
subreq, struct tevent_req);
|
||||
struct winbindd_allocate_gid_state *state = tevent_req_data(
|
||||
req, struct winbindd_allocate_gid_state);
|
||||
NTSTATUS status, result;
|
||||
|
||||
status = rpccli_wbint_AllocateGid_recv(subreq, state, &result);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
tevent_req_nterror(req, status);
|
||||
return;
|
||||
}
|
||||
if (!NT_STATUS_IS_OK(result)) {
|
||||
tevent_req_nterror(req, result);
|
||||
return;
|
||||
}
|
||||
tevent_req_done(req);
|
||||
}
|
||||
|
||||
NTSTATUS winbindd_allocate_gid_recv(struct tevent_req *req,
|
||||
struct winbindd_response *response)
|
||||
{
|
||||
struct winbindd_allocate_gid_state *state = tevent_req_data(
|
||||
req, struct winbindd_allocate_gid_state);
|
||||
NTSTATUS status;
|
||||
|
||||
if (tevent_req_is_nterror(req, &status)) {
|
||||
DEBUG(5, ("Could not allocate gid: %s\n", nt_errstr(status)));
|
||||
return status;
|
||||
}
|
||||
response->data.gid = state->gid;
|
||||
return NT_STATUS_OK;
|
||||
}
|
@ -4357,6 +4357,7 @@ static bool wcache_opnum_cacheable(uint32_t opnum)
|
||||
case NDR_WBINT_PING:
|
||||
case NDR_WBINT_QUERYSEQUENCENUMBER:
|
||||
case NDR_WBINT_ALLOCATEUID:
|
||||
case NDR_WBINT_ALLOCATEGID:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -119,6 +119,19 @@ NTSTATUS _wbint_AllocateUid(pipes_struct *p, struct wbint_AllocateUid *r)
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS _wbint_AllocateGid(pipes_struct *p, struct wbint_AllocateGid *r)
|
||||
{
|
||||
struct unixid xid;
|
||||
NTSTATUS status;
|
||||
|
||||
status = idmap_allocate_gid(&xid);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
*r->out.gid = xid.id;
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS _wbint_QueryUser(pipes_struct *p, struct wbint_QueryUser *r)
|
||||
{
|
||||
struct winbindd_domain *domain = wb_child_domain();
|
||||
|
@ -556,10 +556,6 @@ static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
|
||||
.name = "DUAL_SET_HWMS",
|
||||
.struct_cmd = WINBINDD_DUAL_SET_HWM,
|
||||
.struct_fn = winbindd_dual_set_hwm,
|
||||
},{
|
||||
.name = "ALLOCATE_GID",
|
||||
.struct_cmd = WINBINDD_ALLOCATE_GID,
|
||||
.struct_fn = winbindd_dual_allocate_gid,
|
||||
},{
|
||||
.name = "NDRCMD",
|
||||
.struct_cmd = WINBINDD_DUAL_NDRCMD,
|
||||
|
@ -728,6 +728,13 @@ struct tevent_req *winbindd_allocate_uid_send(TALLOC_CTX *mem_ctx,
|
||||
NTSTATUS winbindd_allocate_uid_recv(struct tevent_req *req,
|
||||
struct winbindd_response *response);
|
||||
|
||||
struct tevent_req *winbindd_allocate_gid_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct winbindd_cli_state *cli,
|
||||
struct winbindd_request *request);
|
||||
NTSTATUS winbindd_allocate_gid_recv(struct tevent_req *req,
|
||||
struct winbindd_response *response);
|
||||
|
||||
struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
const struct dom_sid *user_sid);
|
||||
|
@ -140,27 +140,3 @@ void winbindd_set_hwm(struct winbindd_cli_state *state)
|
||||
|
||||
winbindd_set_hwm_async(state->mem_ctx, &xid, set_hwm_recv, state);
|
||||
}
|
||||
|
||||
void winbindd_allocate_gid(struct winbindd_cli_state *state)
|
||||
{
|
||||
if ( !state->privileged ) {
|
||||
DEBUG(2, ("winbindd_allocate_gid: non-privileged access "
|
||||
"denied!\n"));
|
||||
request_error(state);
|
||||
return;
|
||||
}
|
||||
|
||||
sendto_child(state, idmap_child());
|
||||
}
|
||||
|
||||
enum winbindd_result winbindd_dual_allocate_gid(struct winbindd_domain *domain,
|
||||
struct winbindd_cli_state *state)
|
||||
{
|
||||
struct unixid xid;
|
||||
|
||||
if (!NT_STATUS_IS_OK(idmap_allocate_gid(&xid))) {
|
||||
return WINBINDD_ERROR;
|
||||
}
|
||||
state->response->data.gid = xid.id;
|
||||
return WINBINDD_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user