summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-08-30 09:46:34 +0200
committerVolker Lendecke <vl@samba.org>2009-08-30 09:48:28 +0200
commit0cae043b0c1d2fa55f6709230658155caaecb4fc (patch)
tree835f5b2809527a5952abdca6f1dd86119973be69 /source3/winbindd
parent9e7c6f12fdb6a8ce198359572bb9e69c7d46530a (diff)
downloadsamba-0cae043b0c1d2fa55f6709230658155caaecb4fc.tar.gz
samba-0cae043b0c1d2fa55f6709230658155caaecb4fc.tar.bz2
samba-0cae043b0c1d2fa55f6709230658155caaecb4fc.zip
w3:winbind: Convert WINBINDD_ALLOCATE_GID to the new API
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/winbindd.c3
-rw-r--r--source3/winbindd/winbindd_allocate_gid.c92
-rw-r--r--source3/winbindd/winbindd_cache.c1
-rw-r--r--source3/winbindd/winbindd_dual_srv.c13
-rw-r--r--source3/winbindd/winbindd_idmap.c4
-rw-r--r--source3/winbindd/winbindd_proto.h7
-rw-r--r--source3/winbindd/winbindd_sid.c24
7 files changed, 115 insertions, 29 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index d664a51671..e5468e38a9 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -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 }
};
diff --git a/source3/winbindd/winbindd_allocate_gid.c b/source3/winbindd/winbindd_allocate_gid.c
new file mode 100644
index 0000000000..868a5cc405
--- /dev/null
+++ b/source3/winbindd/winbindd_allocate_gid.c
@@ -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;
+}
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index 5bb76c5b06..8d44d27141 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -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;
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index 8bea6ac03a..3b6107a398 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -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();
diff --git a/source3/winbindd/winbindd_idmap.c b/source3/winbindd/winbindd_idmap.c
index 65cc0d1f53..c6b70f4edb 100644
--- a/source3/winbindd/winbindd_idmap.c
+++ b/source3/winbindd/winbindd_idmap.c
@@ -557,10 +557,6 @@ static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
.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,
.struct_fn = winbindd_dual_ndrcmd,
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index cbb57634ba..fba6bd2d46 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -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);
diff --git a/source3/winbindd/winbindd_sid.c b/source3/winbindd/winbindd_sid.c
index 717a0272d6..80d4677d75 100644
--- a/source3/winbindd/winbindd_sid.c
+++ b/source3/winbindd/winbindd_sid.c
@@ -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;
-}