summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd_allocate_gid.c
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/winbindd_allocate_gid.c
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/winbindd_allocate_gid.c')
-rw-r--r--source3/winbindd/winbindd_allocate_gid.c92
1 files changed, 92 insertions, 0 deletions
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;
+}