summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/winbindd.c6
-rw-r--r--source3/winbindd/winbindd_dual_srv.c23
-rw-r--r--source3/winbindd/winbindd_idmap.c63
-rw-r--r--source3/winbindd/winbindd_proto.h7
-rw-r--r--source3/winbindd/winbindd_set_hwm.c95
-rw-r--r--source3/winbindd/winbindd_sid.c58
6 files changed, 127 insertions, 125 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index f0dc62ef12..9d4676f9b5 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -438,10 +438,6 @@ static struct winbindd_dispatch_table {
{ WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains,
"LIST_TRUSTDOM" },
- /* Lookup related functions */
-
- { WINBINDD_SET_HWM, winbindd_set_hwm, "SET_HWMS" },
-
/* Miscellaneous */
{ WINBINDD_INFO, winbindd_info, "INFO" },
@@ -549,6 +545,8 @@ static struct winbindd_async_dispatch_table async_priv_table[] = {
winbindd_set_mapping_send, winbindd_set_mapping_recv },
{ WINBINDD_REMOVE_MAPPING, "SET_MAPPING",
winbindd_remove_mapping_send, winbindd_remove_mapping_recv },
+ { WINBINDD_SET_HWM, "SET_HWM",
+ winbindd_set_hwm_send, winbindd_set_hwm_recv },
{ 0, NULL, NULL, NULL }
};
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index 222fd835af..179a771066 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -491,3 +491,26 @@ NTSTATUS _wbint_RemoveMapping(pipes_struct *p, struct wbint_RemoveMapping *r)
return idmap_remove_mapping(&map);
}
+
+NTSTATUS _wbint_SetHWM(pipes_struct *p, struct wbint_SetHWM *r)
+{
+ struct unixid id;
+ NTSTATUS status;
+
+ id.id = r->in.id;
+
+ switch (id.type) {
+ case WBINT_ID_TYPE_UID:
+ id.type = ID_TYPE_UID;
+ status = idmap_set_uid_hwm(&id);
+ break;
+ case ID_TYPE_GID:
+ id.type = ID_TYPE_GID;
+ status = idmap_set_gid_hwm(&id);
+ break;
+ default:
+ status = NT_STATUS_INVALID_PARAMETER;
+ break;
+ }
+ return status;
+}
diff --git a/source3/winbindd/winbindd_idmap.c b/source3/winbindd/winbindd_idmap.c
index 423afe174d..1d275014ce 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_set_hwm_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_set_hwm\n"));
- cont(private_data, False);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("idmap_set_hwm returned an error\n"));
- cont(private_data, False);
- return;
- }
-
- cont(private_data, True);
-}
-
-void winbindd_set_hwm_async(TALLOC_CTX *mem_ctx, const struct unixid *xid,
- void (*cont)(void *private_data, bool success),
- void *private_data)
-{
- struct winbindd_request request;
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_DUAL_SET_HWM;
- request.data.dual_idmapset.id = xid->id;
- request.data.dual_idmapset.type = xid->type;
-
- do_async(mem_ctx, idmap_child(), &request, winbindd_set_hwm_recv,
- (void *)cont, private_data);
-}
-
-enum winbindd_result winbindd_dual_set_hwm(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- struct unixid xid;
- NTSTATUS result;
-
- DEBUG(3, ("[%5lu]: dual_set_hwm\n", (unsigned long)state->pid));
-
- xid.id = state->request->data.dual_idmapset.id;
- xid.type = state->request->data.dual_idmapset.type;
-
- switch (xid.type) {
- case ID_TYPE_UID:
- result = idmap_set_uid_hwm(&xid);
- break;
- case ID_TYPE_GID:
- result = idmap_set_gid_hwm(&xid);
- break;
- default:
- return WINBINDD_ERROR;
- }
- return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR;
-}
-
static void winbindd_sid2uid_recv(TALLOC_CTX *mem_ctx, bool success,
struct winbindd_response *response,
void *c, void *private_data)
@@ -420,10 +361,6 @@ static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
.struct_cmd = WINBINDD_DUAL_GID2SID,
.struct_fn = winbindd_dual_gid2sid,
},{
- .name = "DUAL_SET_HWMS",
- .struct_cmd = WINBINDD_DUAL_SET_HWM,
- .struct_fn = winbindd_dual_set_hwm,
- },{
.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 c5b7d9d414..f1fc0f6a2a 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -983,4 +983,11 @@ struct tevent_req *winbindd_remove_mapping_send(TALLOC_CTX *mem_ctx,
NTSTATUS winbindd_remove_mapping_recv(struct tevent_req *req,
struct winbindd_response *response);
+struct tevent_req *winbindd_set_hwm_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request);
+NTSTATUS winbindd_set_hwm_recv(struct tevent_req *req,
+ struct winbindd_response *response);
+
#endif /* _WINBINDD_PROTO_H_ */
diff --git a/source3/winbindd/winbindd_set_hwm.c b/source3/winbindd/winbindd_set_hwm.c
new file mode 100644
index 0000000000..e648ee5bcd
--- /dev/null
+++ b/source3/winbindd/winbindd_set_hwm.c
@@ -0,0 +1,95 @@
+/*
+ Unix SMB/CIFS implementation.
+ async implementation of WINBINDD_SET_HWM
+ 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_set_hwm_state {
+ uint8_t dummy;
+};
+
+static void winbindd_set_hwm_done(struct tevent_req *subreq);
+
+struct tevent_req *winbindd_set_hwm_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_set_hwm_state *state;
+ struct winbindd_child *child;
+ enum id_type type;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct winbindd_set_hwm_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ DEBUG(3, ("set_hwm %d\n", (int)request->data.dual_idmapset.id));
+
+ 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_SetHWM_send(state, ev, child->rpccli, type,
+ request->data.dual_idmapset.id);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, winbindd_set_hwm_done, req);
+ return req;
+}
+
+static void winbindd_set_hwm_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct winbindd_set_hwm_state *state = tevent_req_data(
+ req, struct winbindd_set_hwm_state);
+ NTSTATUS status, result;
+
+ status = rpccli_wbint_SetHWM_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_set_hwm_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
deleted file mode 100644
index bc058b4c42..0000000000
--- a/source3/winbindd/winbindd_sid.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Winbind daemon - sid related functions
-
- Copyright (C) Tim Potter 2000
-
- 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"
-
-#undef DBGC_CLASS
-#define DBGC_CLASS DBGC_WINBIND
-
-static void set_hwm_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 set sid mapping\n"));
- request_error(state);
- return;
- }
-
- request_ok(state);
-}
-
-void winbindd_set_hwm(struct winbindd_cli_state *state)
-{
- struct unixid xid;
-
- DEBUG(3, ("[%5lu]: set hwm\n", (unsigned long)state->pid));
-
- if ( ! state->privileged) {
- DEBUG(0, ("Only root is allowed to set mappings!\n"));
- request_error(state);
- return;
- }
-
- xid.id = state->request->data.dual_idmapset.id;
- xid.type = state->request->data.dual_idmapset.type;
-
- winbindd_set_hwm_async(state->mem_ctx, &xid, set_hwm_recv, state);
-}