summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-09-06 14:59:41 +0200
committerVolker Lendecke <vl@samba.org>2009-09-07 01:28:32 +0200
commit4ad330d5226901aed18656c49c70a3fc7a62826c (patch)
tree25acbaf40be3cbde44ed2ff27d99683f53888f0c /source3/winbindd
parent7159060450e4d5cd3d71e6a5c7837dcd648a6220 (diff)
downloadsamba-4ad330d5226901aed18656c49c70a3fc7a62826c.tar.gz
samba-4ad330d5226901aed18656c49c70a3fc7a62826c.tar.bz2
samba-4ad330d5226901aed18656c49c70a3fc7a62826c.zip
s3:winbind: Convert WINBINDD_REMOVE_MAPPING to the new API
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/winbindd.c3
-rw-r--r--source3/winbindd/winbindd_dual_srv.c22
-rw-r--r--source3/winbindd/winbindd_idmap.c63
-rw-r--r--source3/winbindd/winbindd_proto.h7
-rw-r--r--source3/winbindd/winbindd_remove_mapping.c106
-rw-r--r--source3/winbindd/winbindd_sid.c42
6 files changed, 137 insertions, 106 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index b29c646631..f0dc62ef12 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -440,7 +440,6 @@ static struct winbindd_dispatch_table {
/* Lookup related functions */
- { WINBINDD_REMOVE_MAPPING, winbindd_remove_mapping, "REMOVE_MAPPING" },
{ WINBINDD_SET_HWM, winbindd_set_hwm, "SET_HWMS" },
/* Miscellaneous */
@@ -548,6 +547,8 @@ static struct winbindd_async_dispatch_table async_priv_table[] = {
winbindd_allocate_gid_send, winbindd_allocate_gid_recv },
{ WINBINDD_SET_MAPPING, "SET_MAPPING",
winbindd_set_mapping_send, winbindd_set_mapping_recv },
+ { WINBINDD_REMOVE_MAPPING, "SET_MAPPING",
+ winbindd_remove_mapping_send, winbindd_remove_mapping_recv },
{ 0, NULL, NULL, NULL }
};
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index 2a6f7ce99d..222fd835af 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -469,3 +469,25 @@ NTSTATUS _wbint_SetMapping(pipes_struct *p, struct wbint_SetMapping *r)
return idmap_set_mapping(&map);
}
+
+NTSTATUS _wbint_RemoveMapping(pipes_struct *p, struct wbint_RemoveMapping *r)
+{
+ struct id_map map;
+
+ map.sid = r->in.sid;
+ map.xid.id = r->in.id;
+ map.status = ID_MAPPED;
+
+ switch (r->in.type) {
+ case WBINT_ID_TYPE_UID:
+ map.xid.type = ID_TYPE_UID;
+ break;
+ case WBINT_ID_TYPE_GID:
+ map.xid.type = ID_TYPE_GID;
+ break;
+ default:
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ return idmap_remove_mapping(&map);
+}
diff --git a/source3/winbindd/winbindd_idmap.c b/source3/winbindd/winbindd_idmap.c
index a59907243f..423afe174d 100644
--- a/source3/winbindd/winbindd_idmap.c
+++ b/source3/winbindd/winbindd_idmap.c
@@ -45,65 +45,6 @@ struct winbindd_child *idmap_child(void)
return &static_idmap_child;
}
-static void winbindd_remove_mapping_recv(TALLOC_CTX *mem_ctx, bool success,
- struct winbindd_response *response,
- void *c, void *private_data)
-{
- void (*cont)(void *priv, bool succ) = (void (*)(void *, bool))c;
-
- if (!success) {
- DEBUG(5, ("Could not trigger idmap_remove_mapping\n"));
- cont(private_data, False);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("idmap_remove_mapping returned an error\n"));
- cont(private_data, False);
- return;
- }
-
- cont(private_data, True);
-}
-
-void winbindd_remove_mapping_async(TALLOC_CTX *mem_ctx,
- const struct id_map *map,
- void (*cont)(void *private_data, bool success),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_REMOVE_MAPPING;
- request.data.dual_idmapset.id = map->xid.id;
- request.data.dual_idmapset.type = map->xid.type;
- sid_to_fstring(request.data.dual_idmapset.sid, map->sid);
-
- do_async(mem_ctx, idmap_child(), &request, winbindd_remove_mapping_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_remove_mapping(
- struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- struct id_map map;
- DOM_SID sid;
- NTSTATUS result;
-
- DEBUG(3, ("[%5lu]: dual_idmapremove\n", (unsigned long)state->pid));
-
- if (!string_to_sid(&sid, state->request->data.dual_idmapset.sid))
- return WINBINDD_ERROR;
-
- map.sid = &sid;
- map.xid.id = state->request->data.dual_idmapset.id;
- map.xid.type = state->request->data.dual_idmapset.type;
- map.status = ID_MAPPED;
-
- result = idmap_remove_mapping(&map);
- return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
-}
-
static void winbindd_set_hwm_recv(TALLOC_CTX *mem_ctx, bool success,
struct winbindd_response *response,
void *c, void *private_data)
@@ -479,10 +420,6 @@ static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
.struct_cmd = WINBINDD_DUAL_GID2SID,
.struct_fn = winbindd_dual_gid2sid,
},{
- .name = "DUAL_REMOVE_MAPPING",
- .struct_cmd = WINBINDD_DUAL_REMOVE_MAPPING,
- .struct_fn = winbindd_dual_remove_mapping,
- },{
.name = "DUAL_SET_HWMS",
.struct_cmd = WINBINDD_DUAL_SET_HWM,
.struct_fn = winbindd_dual_set_hwm,
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 1b99935be1..c5b7d9d414 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -976,4 +976,11 @@ struct tevent_req *winbindd_set_mapping_send(TALLOC_CTX *mem_ctx,
NTSTATUS winbindd_set_mapping_recv(struct tevent_req *req,
struct winbindd_response *response);
+struct tevent_req *winbindd_remove_mapping_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request);
+NTSTATUS winbindd_remove_mapping_recv(struct tevent_req *req,
+ struct winbindd_response *response);
+
#endif /* _WINBINDD_PROTO_H_ */
diff --git a/source3/winbindd/winbindd_remove_mapping.c b/source3/winbindd/winbindd_remove_mapping.c
new file mode 100644
index 0000000000..e94f6c28a1
--- /dev/null
+++ b/source3/winbindd/winbindd_remove_mapping.c
@@ -0,0 +1,106 @@
+/*
+ Unix SMB/CIFS implementation.
+ async implementation of WINBINDD_REMOVE_MAPPING
+ 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_remove_mapping_state {
+ struct dom_sid sid;
+};
+
+static void winbindd_remove_mapping_done(struct tevent_req *subreq);
+
+struct tevent_req *winbindd_remove_mapping_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_remove_mapping_state *state;
+ struct winbindd_child *child;
+ enum id_type type;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct winbindd_remove_mapping_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ /* Ensure null termination */
+ request->data.dual_idmapset.sid[
+ sizeof(request->data.dual_idmapset.sid)-1]='\0';
+
+ DEBUG(3, ("set_mapping %s\n", request->data.dual_idmapset.sid));
+
+ if (!string_to_sid(&state->sid, request->data.dual_idmapset.sid)) {
+ DEBUG(5, ("%s not a SID\n", request->data.dual_idmapset.sid));
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
+
+ switch (request->data.dual_idmapset.type) {
+ case ID_TYPE_UID:
+ type = WBINT_ID_TYPE_UID;
+ break;
+ case ID_TYPE_GID:
+ type = WBINT_ID_TYPE_GID;
+ break;
+ default:
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
+
+ child = idmap_child();
+
+ subreq = rpccli_wbint_RemoveMapping_send(
+ state, ev, child->rpccli, &state->sid, type,
+ request->data.dual_idmapset.id);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, winbindd_remove_mapping_done, req);
+ return req;
+}
+
+static void winbindd_remove_mapping_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct winbindd_remove_mapping_state *state = tevent_req_data(
+ req, struct winbindd_remove_mapping_state);
+ NTSTATUS status, result;
+
+ status = rpccli_wbint_RemoveMapping_recv(subreq, state, &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
+ tevent_req_nterror(req, result);
+ return;
+ }
+ return tevent_req_done(req);
+}
+
+NTSTATUS winbindd_remove_mapping_recv(struct tevent_req *req,
+ struct winbindd_response *response)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
diff --git a/source3/winbindd/winbindd_sid.c b/source3/winbindd/winbindd_sid.c
index 5c9bb4dba9..bc058b4c42 100644
--- a/source3/winbindd/winbindd_sid.c
+++ b/source3/winbindd/winbindd_sid.c
@@ -25,48 +25,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
-static void remove_mapping_recv(void *private_data, bool success)
-{
- struct winbindd_cli_state *state =
- talloc_get_type_abort(private_data, struct winbindd_cli_state);
-
- if (!success) {
- DEBUG(5, ("Could not remove sid mapping\n"));
- request_error(state);
- return;
- }
-
- request_ok(state);
-}
-
-void winbindd_remove_mapping(struct winbindd_cli_state *state)
-{
- struct id_map map;
- DOM_SID sid;
-
- DEBUG(3, ("[%5lu]: remove id map\n", (unsigned long)state->pid));
-
- if ( ! state->privileged) {
- DEBUG(0, ("Only root is allowed to remove mappings!\n"));
- request_error(state);
- return;
- }
-
- if (!string_to_sid(&sid, state->request->data.dual_idmapset.sid)) {
- DEBUG(1, ("Could not get convert sid %s from string\n",
- state->request->data.sid));
- request_error(state);
- return;
- }
-
- map.sid = &sid;
- map.xid.id = state->request->data.dual_idmapset.id;
- map.xid.type = state->request->data.dual_idmapset.type;
-
- winbindd_remove_mapping_async(state->mem_ctx, &map,
- remove_mapping_recv, state);
-}
-
static void set_hwm_recv(void *private_data, bool success)
{
struct winbindd_cli_state *state =