s3:winbind: Convert WINBINDD_SET_HWM to the new API
authorVolker Lendecke <vl@samba.org>
Sun, 6 Sep 2009 13:18:58 +0000 (15:18 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 7 Sep 2009 16:30:14 +0000 (09:30 -0700)
15 files changed:
source3/Makefile.in
source3/librpc/gen_ndr/cli_wbint.c
source3/librpc/gen_ndr/cli_wbint.h
source3/librpc/gen_ndr/ndr_wbint.c
source3/librpc/gen_ndr/ndr_wbint.h
source3/librpc/gen_ndr/srv_wbint.c
source3/librpc/gen_ndr/srv_wbint.h
source3/librpc/gen_ndr/wbint.h
source3/librpc/idl/wbint.idl
source3/winbindd/winbindd.c
source3/winbindd/winbindd_dual_srv.c
source3/winbindd/winbindd_idmap.c
source3/winbindd/winbindd_proto.h
source3/winbindd/winbindd_set_hwm.c [new file with mode: 0644]
source3/winbindd/winbindd_sid.c [deleted file]

index b2e33936b78702a57da42120be27edb5a603f94c..3528d6ce391e1ed17efdc7c24a7ef00db2a8e9f9 100644 (file)
@@ -1141,7 +1141,6 @@ WINBINDD_OBJ1 = \
                winbindd/winbindd_util.o  \
                winbindd/winbindd_cache.o \
                winbindd/winbindd_pam.o   \
-               winbindd/winbindd_sid.o   \
                winbindd/winbindd_misc.o  \
                winbindd/winbindd_cm.o    \
                winbindd/winbindd_wins.o  \
@@ -1216,6 +1215,7 @@ WINBINDD_OBJ1 = \
                winbindd/winbindd_check_machine_acct.o \
                winbindd/winbindd_set_mapping.o \
                winbindd/winbindd_remove_mapping.o \
+               winbindd/winbindd_set_hwm.o \
                auth/token_util.o \
                ../nsswitch/libwbclient/wb_reqtrans.o \
                smbd/connection.o
index 4a303ee6d7118146426519114bcc8127e8e40d58..3e5fc441d59973cd9cfc5f219fc1a7d1ae4a42bc 100644 (file)
@@ -3391,3 +3391,157 @@ NTSTATUS rpccli_wbint_RemoveMapping(struct rpc_pipe_client *cli,
        return r.out.result;
 }
 
+struct rpccli_wbint_SetHWM_state {
+       struct wbint_SetHWM orig;
+       struct wbint_SetHWM tmp;
+       TALLOC_CTX *out_mem_ctx;
+       NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+};
+
+static void rpccli_wbint_SetHWM_done(struct tevent_req *subreq);
+
+struct tevent_req *rpccli_wbint_SetHWM_send(TALLOC_CTX *mem_ctx,
+                                           struct tevent_context *ev,
+                                           struct rpc_pipe_client *cli,
+                                           enum wbint_IdType _type /* [in]  */,
+                                           uint64_t _id /* [in]  */)
+{
+       struct tevent_req *req;
+       struct rpccli_wbint_SetHWM_state *state;
+       struct tevent_req *subreq;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct rpccli_wbint_SetHWM_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       state->out_mem_ctx = NULL;
+       state->dispatch_recv = cli->dispatch_recv;
+
+       /* In parameters */
+       state->orig.in.type = _type;
+       state->orig.in.id = _id;
+
+       /* Out parameters */
+
+       /* Result */
+       ZERO_STRUCT(state->orig.out.result);
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(wbint_SetHWM, &state->orig);
+       }
+
+       /* 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_SETHWM,
+                                   &state->tmp);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, rpccli_wbint_SetHWM_done, req);
+       return req;
+}
+
+static void rpccli_wbint_SetHWM_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct rpccli_wbint_SetHWM_state *state = tevent_req_data(
+               req, struct rpccli_wbint_SetHWM_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 */
+
+       /* 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_SetHWM, &state->orig);
+       }
+
+       tevent_req_done(req);
+}
+
+NTSTATUS rpccli_wbint_SetHWM_recv(struct tevent_req *req,
+                                 TALLOC_CTX *mem_ctx,
+                                 NTSTATUS *result)
+{
+       struct rpccli_wbint_SetHWM_state *state = tevent_req_data(
+               req, struct rpccli_wbint_SetHWM_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_SetHWM(struct rpc_pipe_client *cli,
+                            TALLOC_CTX *mem_ctx,
+                            enum wbint_IdType type /* [in]  */,
+                            uint64_t id /* [in]  */)
+{
+       struct wbint_SetHWM r;
+       NTSTATUS status;
+
+       /* In parameters */
+       r.in.type = type;
+       r.in.id = id;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(wbint_SetHWM, &r);
+       }
+
+       status = cli->dispatch(cli,
+                               mem_ctx,
+                               &ndr_table_wbint,
+                               NDR_WBINT_SETHWM,
+                               &r);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(wbint_SetHWM, &r);
+       }
+
+       if (NT_STATUS_IS_ERR(status)) {
+               return status;
+       }
+
+       /* Return variables */
+
+       /* Return result */
+       return r.out.result;
+}
+
index e75f9b517c32f5bd409789749e2c7b65cfeec539..7d7c2bcdaca0938b5c29fe7798aefce59b8a5f69 100644 (file)
@@ -268,4 +268,16 @@ NTSTATUS rpccli_wbint_RemoveMapping(struct rpc_pipe_client *cli,
                                    struct dom_sid *sid /* [in] [ref] */,
                                    enum wbint_IdType type /* [in]  */,
                                    uint64_t id /* [in]  */);
+struct tevent_req *rpccli_wbint_SetHWM_send(TALLOC_CTX *mem_ctx,
+                                           struct tevent_context *ev,
+                                           struct rpc_pipe_client *cli,
+                                           enum wbint_IdType _type /* [in]  */,
+                                           uint64_t _id /* [in]  */);
+NTSTATUS rpccli_wbint_SetHWM_recv(struct tevent_req *req,
+                                 TALLOC_CTX *mem_ctx,
+                                 NTSTATUS *result);
+NTSTATUS rpccli_wbint_SetHWM(struct rpc_pipe_client *cli,
+                            TALLOC_CTX *mem_ctx,
+                            enum wbint_IdType type /* [in]  */,
+                            uint64_t id /* [in]  */);
 #endif /* __CLI_WBINT__ */
index 40e06b1c0a9d37bde70697f3b8554cc667d2a3c0..d5f46a43b322c3842444af9e549efd6eb0fae29a 100644 (file)
@@ -2304,6 +2304,53 @@ _PUBLIC_ void ndr_print_wbint_RemoveMapping(struct ndr_print *ndr, const char *n
        ndr->depth--;
 }
 
+static enum ndr_err_code ndr_push_wbint_SetHWM(struct ndr_push *ndr, int flags, const struct wbint_SetHWM *r)
+{
+       if (flags & NDR_IN) {
+               NDR_CHECK(ndr_push_wbint_IdType(ndr, NDR_SCALARS, r->in.type));
+               NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->in.id));
+       }
+       if (flags & NDR_OUT) {
+               NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_wbint_SetHWM(struct ndr_pull *ndr, int flags, struct wbint_SetHWM *r)
+{
+       if (flags & NDR_IN) {
+               NDR_CHECK(ndr_pull_wbint_IdType(ndr, NDR_SCALARS, &r->in.type));
+               NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->in.id));
+       }
+       if (flags & NDR_OUT) {
+               NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_wbint_SetHWM(struct ndr_print *ndr, const char *name, int flags, const struct wbint_SetHWM *r)
+{
+       ndr_print_struct(ndr, name, "wbint_SetHWM");
+       ndr->depth++;
+       if (flags & NDR_SET_VALUES) {
+               ndr->flags |= LIBNDR_PRINT_SET_VALUES;
+       }
+       if (flags & NDR_IN) {
+               ndr_print_struct(ndr, "in", "wbint_SetHWM");
+               ndr->depth++;
+               ndr_print_wbint_IdType(ndr, "type", r->in.type);
+               ndr_print_hyper(ndr, "id", r->in.id);
+               ndr->depth--;
+       }
+       if (flags & NDR_OUT) {
+               ndr_print_struct(ndr, "out", "wbint_SetHWM");
+               ndr->depth++;
+               ndr_print_NTSTATUS(ndr, "result", r->out.result);
+               ndr->depth--;
+       }
+       ndr->depth--;
+}
+
 static const struct ndr_interface_call wbint_calls[] = {
        {
                "wbint_Ping",
@@ -2473,6 +2520,14 @@ static const struct ndr_interface_call wbint_calls[] = {
                (ndr_print_function_t) ndr_print_wbint_RemoveMapping,
                false,
        },
+       {
+               "wbint_SetHWM",
+               sizeof(struct wbint_SetHWM),
+               (ndr_push_flags_fn_t) ndr_push_wbint_SetHWM,
+               (ndr_pull_flags_fn_t) ndr_pull_wbint_SetHWM,
+               (ndr_print_function_t) ndr_print_wbint_SetHWM,
+               false,
+       },
        { NULL, 0, NULL, NULL, NULL, false }
 };
 
@@ -2502,7 +2557,7 @@ const struct ndr_interface_table ndr_table_wbint = {
                NDR_WBINT_VERSION
        },
        .helpstring     = NDR_WBINT_HELPSTRING,
-       .num_calls      = 21,
+       .num_calls      = 22,
        .calls          = wbint_calls,
        .endpoints      = &wbint_endpoints,
        .authservices   = &wbint_authservices
index 17fd6ecbce79cf6fc67c894f10eea67cd3e88b35..5cefc94162c1b4a6cfd51baa68a8e2edd9f060e8 100644 (file)
@@ -53,7 +53,9 @@ extern const struct ndr_interface_table ndr_table_wbint;
 
 #define NDR_WBINT_REMOVEMAPPING (0x14)
 
-#define NDR_WBINT_CALL_COUNT (21)
+#define NDR_WBINT_SETHWM (0x15)
+
+#define NDR_WBINT_CALL_COUNT (22)
 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);
@@ -96,4 +98,5 @@ void ndr_print_wbint_LookupRids(struct ndr_print *ndr, const char *name, int fla
 void ndr_print_wbint_CheckMachineAccount(struct ndr_print *ndr, const char *name, int flags, const struct wbint_CheckMachineAccount *r);
 void ndr_print_wbint_SetMapping(struct ndr_print *ndr, const char *name, int flags, const struct wbint_SetMapping *r);
 void ndr_print_wbint_RemoveMapping(struct ndr_print *ndr, const char *name, int flags, const struct wbint_RemoveMapping *r);
+void ndr_print_wbint_SetHWM(struct ndr_print *ndr, const char *name, int flags, const struct wbint_SetHWM *r);
 #endif /* _HEADER_NDR_wbint */
index 1aaf0a5bf8b6544cee6a55548f0443852f727ee5..b3b535bc9cbe52c185cb1f2d6bff2a25965c9e89 100644 (file)
@@ -1683,6 +1683,79 @@ static bool api_wbint_RemoveMapping(pipes_struct *p)
        return true;
 }
 
+static bool api_wbint_SetHWM(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_SetHWM *r;
+
+       call = &ndr_table_wbint.calls[NDR_WBINT_SETHWM];
+
+       r = talloc(talloc_tos(), struct wbint_SetHWM);
+       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_SetHWM, r);
+       }
+
+       r->out.result = _wbint_SetHWM(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_SetHWM, 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;
+}
+
 
 /* Tables */
 static struct api_struct api_wbint_cmds[] = 
@@ -1708,6 +1781,7 @@ static struct api_struct api_wbint_cmds[] =
        {"WBINT_CHECKMACHINEACCOUNT", NDR_WBINT_CHECKMACHINEACCOUNT, api_wbint_CheckMachineAccount},
        {"WBINT_SETMAPPING", NDR_WBINT_SETMAPPING, api_wbint_SetMapping},
        {"WBINT_REMOVEMAPPING", NDR_WBINT_REMOVEMAPPING, api_wbint_RemoveMapping},
+       {"WBINT_SETHWM", NDR_WBINT_SETHWM, api_wbint_SetHWM},
 };
 
 void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns)
@@ -1973,6 +2047,12 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co
                        return NT_STATUS_OK;
                }
 
+               case NDR_WBINT_SETHWM: {
+                       struct wbint_SetHWM *r = (struct wbint_SetHWM *)_r;
+                       r->out.result = _wbint_SetHWM(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
                default:
                        return NT_STATUS_NOT_IMPLEMENTED;
        }
index f26c44ba0d1b0979fc396644256ffa0b82845a43..70738fcacf964ab24472a556ac13016bb6798109 100644 (file)
@@ -22,6 +22,7 @@ NTSTATUS _wbint_LookupRids(pipes_struct *p, struct wbint_LookupRids *r);
 NTSTATUS _wbint_CheckMachineAccount(pipes_struct *p, struct wbint_CheckMachineAccount *r);
 NTSTATUS _wbint_SetMapping(pipes_struct *p, struct wbint_SetMapping *r);
 NTSTATUS _wbint_RemoveMapping(pipes_struct *p, struct wbint_RemoveMapping *r);
+NTSTATUS _wbint_SetHWM(pipes_struct *p, struct wbint_SetHWM *r);
 void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns);
 NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r);
 void _wbint_Ping(pipes_struct *p, struct wbint_Ping *r);
@@ -45,5 +46,6 @@ NTSTATUS _wbint_LookupRids(pipes_struct *p, struct wbint_LookupRids *r);
 NTSTATUS _wbint_CheckMachineAccount(pipes_struct *p, struct wbint_CheckMachineAccount *r);
 NTSTATUS _wbint_SetMapping(pipes_struct *p, struct wbint_SetMapping *r);
 NTSTATUS _wbint_RemoveMapping(pipes_struct *p, struct wbint_RemoveMapping *r);
+NTSTATUS _wbint_SetHWM(pipes_struct *p, struct wbint_SetHWM *r);
 NTSTATUS rpc_wbint_init(void);
 #endif /* __SRV_WBINT__ */
index dc4fc0c117ac853456ba3de1dae1a84a6e3f78f0..894e851ed129da5297c0dd180928282f97bd824d 100644 (file)
@@ -321,4 +321,17 @@ struct wbint_RemoveMapping {
 
 };
 
+
+struct wbint_SetHWM {
+       struct {
+               enum wbint_IdType type;
+               uint64_t id;
+       } in;
+
+       struct {
+               NTSTATUS result;
+       } out;
+
+};
+
 #endif /* _HEADER_wbint */
index 764d122c6045145d32e3a9c3ab420bfb72ae53aa..af59cb6b75077888eda8547646f88a74ca67da6c 100644 (file)
@@ -164,4 +164,9 @@ interface wbint
        [in] wbint_IdType type,
        [in] hyper id
        );
+
+    NTSTATUS wbint_SetHWM(
+       [in] wbint_IdType type,
+       [in] hyper id
+       );
 }
\ No newline at end of file
index f0dc62ef12b8614ca16053c70bb875cdbff4ba7c..9d4676f9b5976a9b22ca9656adb63eab6689127e 100644 (file)
@@ -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 }
 };
index 222fd835af03e510b77e4754ba363c2c716cb2fc..179a77106660c894fa929d33f344eaa636e2f6b7 100644 (file)
@@ -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;
+}
index 423afe174de1e3d5cd8734c0c69961f8cabd4754..1d275014ce0874618a339d4d6de15a24a83375b7 100644 (file)
@@ -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)
@@ -419,10 +360,6 @@ static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
                .name           = "DUAL_GID2SID",
                .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,
index 8c4d51a47c1bd6bf4b226b883a97e28858749546..538548ba85468e22d292114106d560ac0d8b883a 100644 (file)
@@ -992,4 +992,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 (file)
index 0000000..e648ee5
--- /dev/null
@@ -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 (file)
index bc058b4..0000000
+++ /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);
-}