Make Samba3 use the new common libcli/auth code
[ira/wip.git] / source3 / rpc_client / cli_pipe.c
index 6b83c170f5791d06097c2d0671dbbc8651fa30ee..567794db88d8f0e0f44eab958260250210d4444c 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include "includes.h"
+#include "../libcli/auth/libcli_auth.h"
 #include "librpc/gen_ndr/cli_epmapper.h"
 
 #undef DBGC_CLASS
@@ -2291,19 +2292,24 @@ NTSTATUS rpc_api_pipe_req(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli,
        TALLOC_CTX *frame = talloc_stackframe();
        struct event_context *ev;
        struct tevent_req *req;
-       NTSTATUS status = NT_STATUS_NO_MEMORY;
+       NTSTATUS status = NT_STATUS_OK;
 
        ev = event_context_init(frame);
        if (ev == NULL) {
+               status = NT_STATUS_NO_MEMORY;
                goto fail;
        }
 
        req = rpc_api_pipe_req_send(frame, ev, cli, op_num, in_data);
        if (req == NULL) {
+               status = NT_STATUS_NO_MEMORY;
                goto fail;
        }
 
-       tevent_req_poll(req, ev);
+       if (!tevent_req_poll(req, ev)) {
+               status = map_nt_error_from_unix(errno);
+               goto fail;
+       }
 
        status = rpc_api_pipe_req_recv(req, mem_ctx, out_data);
  fail:
@@ -2905,19 +2911,24 @@ NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
        TALLOC_CTX *frame = talloc_stackframe();
        struct event_context *ev;
        struct tevent_req *req;
-       NTSTATUS status = NT_STATUS_NO_MEMORY;
+       NTSTATUS status = NT_STATUS_OK;
 
        ev = event_context_init(frame);
        if (ev == NULL) {
+               status = NT_STATUS_NO_MEMORY;
                goto fail;
        }
 
        req = rpc_pipe_bind_send(frame, ev, cli, auth);
        if (req == NULL) {
+               status = NT_STATUS_NO_MEMORY;
                goto fail;
        }
 
-       tevent_req_poll(req, ev);
+       if (!tevent_req_poll(req, ev)) {
+               status = map_nt_error_from_unix(errno);
+               goto fail;
+       }
 
        status = rpc_pipe_bind_recv(req);
  fail:
@@ -3840,7 +3851,7 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
                                             const struct ndr_syntax_id *interface,
                                             enum pipe_auth_level auth_level,
                                             const char *domain,
-                                            const struct dcinfo *pdc,
+                                            struct netlogon_creds_CredentialState *pdc,
                                             struct rpc_pipe_client **presult)
 {
        struct rpc_pipe_client *result;
@@ -3853,7 +3864,7 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
        }
 
        status = rpccli_schannel_bind_data(result, domain, auth_level,
-                                          pdc->sess_key, &auth);
+                                          pdc->session_key, &auth);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("rpccli_schannel_bind_data returned %s\n",
                          nt_errstr(status)));
@@ -3872,11 +3883,11 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
 
        /*
         * The credentials on a new netlogon pipe are the ones we are passed
-        * in - copy them over.
+        * in - reference them in
         */
-       result->dc = (struct dcinfo *)talloc_memdup(result, pdc, sizeof(*pdc));
+       result->dc = talloc_reference(result, pdc);
        if (result->dc == NULL) {
-               DEBUG(0, ("talloc failed\n"));
+               DEBUG(0, ("talloc reference failed\n"));
                TALLOC_FREE(result);
                return NT_STATUS_NO_MEMORY;
        }