The branch, master has been updated
       via  17c6e0a s3:libsmb: don't set cli->protocol in cli_state_create()
       via  3f00cce s3:libsmb: pass max_protocol to cli_negprot()
       via  4f7be46 s3:libsmb: add basic max_protocol support in cli_negprot()
      from  7f40b60 s3:libsmb: use local variables in cli_state_create()

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 17c6e0abae3e4011b526b50691c8f37ccde582d9
Author: Stefan Metzmacher <[email protected]>
Date:   Tue Sep 13 14:37:29 2011 +0200

    s3:libsmb: don't set cli->protocol in cli_state_create()
    
    This is done in cli_negprot_done(), when we know the protocol.
    
    metze
    
    Autobuild-User: Stefan Metzmacher <[email protected]>
    Autobuild-Date: Thu Sep 15 11:57:18 CEST 2011 on sn-devel-104

commit 3f00cce9b3502c8ec9b3f7fcf5b2024c10550f82
Author: Stefan Metzmacher <[email protected]>
Date:   Tue Sep 13 14:33:31 2011 +0200

    s3:libsmb: pass max_protocol to cli_negprot()
    
    metze

commit 4f7be46d99b68040c3b42f3a4662fccd777012a3
Author: Stefan Metzmacher <[email protected]>
Date:   Tue Sep 13 14:21:28 2011 +0200

    s3:libsmb: add basic max_protocol support in cli_negprot()
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 source3/auth/auth_server.c     |    2 +-
 source3/libsmb/cliconnect.c    |   31 ++++++++++++++++++++-----------
 source3/libsmb/clidfs.c        |    4 +---
 source3/libsmb/clientgen.c     |    1 -
 source3/libsmb/libsmb_server.c |    2 +-
 source3/libsmb/passchange.c    |    4 +---
 source3/libsmb/proto.h         |    5 +++--
 source3/nmbd/nmbd_synclists.c  |    2 +-
 source3/torture/locktest.c     |    2 +-
 source3/torture/masktest.c     |    4 +---
 source3/torture/torture.c      |    6 +++---
 source3/utils/net_rpc.c        |    2 +-
 source3/utils/net_time.c       |    2 +-
 source3/winbindd/winbindd_cm.c |    2 +-
 14 files changed, 36 insertions(+), 33 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index 04b4673..1df0853 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -106,7 +106,7 @@ static struct cli_state *server_cryptkey(TALLOC_CTX 
*mem_ctx)
 
        DEBUG(3,("got session\n"));
 
-       status = cli_negprot(cli);
+       status = cli_negprot(cli, PROTOCOL_NT1);
 
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(mutex);
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index b896f28..23518ea 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -2538,29 +2538,33 @@ fail:
 
 struct cli_negprot_state {
        struct cli_state *cli;
+       enum protocol_types max_protocol;
 };
 
 static void cli_negprot_done(struct tevent_req *subreq);
 
 struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
                                    struct event_context *ev,
-                                   struct cli_state *cli)
+                                   struct cli_state *cli,
+                                   enum protocol_types max_protocol)
 {
        struct tevent_req *req, *subreq;
        struct cli_negprot_state *state;
        uint8_t *bytes = NULL;
        int numprots;
+       enum protocol_types tmp_protocol;
 
        req = tevent_req_create(mem_ctx, &state, struct cli_negprot_state);
        if (req == NULL) {
                return NULL;
        }
        state->cli = cli;
+       state->max_protocol = max_protocol;
 
        /* setup the protocol strings */
        for (numprots=0; numprots < ARRAY_SIZE(prots); numprots++) {
                uint8_t c = 2;
-               if (prots[numprots].prot > cli_state_protocol(cli)) {
+               if (prots[numprots].prot > state->max_protocol) {
                        break;
                }
                bytes = (uint8_t *)talloc_append_blob(
@@ -2577,9 +2581,11 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
                }
        }
 
+       tmp_protocol = cli->protocol;
+       cli->protocol = state->max_protocol;
        subreq = cli_smb_send(state, ev, cli, SMBnegprot, 0, 0, NULL,
                              talloc_get_size(bytes), bytes);
-
+       cli->protocol = tmp_protocol;
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -2603,6 +2609,7 @@ static void cli_negprot_done(struct tevent_req *subreq)
        uint8_t *inbuf;
        uint32_t both_capabilities;
        uint32_t server_capabilities = 0;
+       enum protocol_types protocol;
 
        status = cli_smb_recv(subreq, state, &inbuf, 1, &wct, &vwv,
                              &num_bytes, &bytes);
@@ -2615,21 +2622,21 @@ static void cli_negprot_done(struct tevent_req *subreq)
        protnum = SVAL(vwv, 0);
 
        if ((protnum >= ARRAY_SIZE(prots))
-           || (prots[protnum].prot > cli_state_protocol(cli))) {
+           || (prots[protnum].prot > state->max_protocol)) {
                tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
                return;
        }
 
-       cli->protocol = prots[protnum].prot;
+       protocol = prots[protnum].prot;
 
-       if ((cli_state_protocol(cli) < PROTOCOL_NT1) &&
+       if ((protocol < PROTOCOL_NT1) &&
            client_is_signing_mandatory(cli)) {
                DEBUG(0,("cli_negprot: SMB signing is mandatory and the 
selected protocol level doesn't support it.\n"));
                tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
                return;
        }
 
-       if (cli_state_protocol(cli) >= PROTOCOL_NT1) {
+       if (protocol >= PROTOCOL_NT1) {
                struct timespec ts;
                const char *client_signing = NULL;
                bool server_mandatory;
@@ -2699,7 +2706,7 @@ static void cli_negprot_done(struct tevent_req *subreq)
                        return;
                }
 
-       } else if (cli_state_protocol(cli) >= PROTOCOL_LANMAN1) {
+       } else if (protocol >= PROTOCOL_LANMAN1) {
                if (wct != 0x0D) {
                        tevent_req_nterror(req, 
NT_STATUS_INVALID_NETWORK_RESPONSE);
                        return;
@@ -2749,6 +2756,8 @@ static void cli_negprot_done(struct tevent_req *subreq)
        cli->capabilities |= both_capabilities & SMB_CAP_BOTH_MASK;
        cli->capabilities |= server_capabilities & SMB_CAP_SERVER_MASK;
 
+       cli->protocol = protocol;
+
        tevent_req_done(req);
 }
 
@@ -2757,7 +2766,7 @@ NTSTATUS cli_negprot_recv(struct tevent_req *req)
        return tevent_req_simple_recv_ntstatus(req);
 }
 
-NTSTATUS cli_negprot(struct cli_state *cli)
+NTSTATUS cli_negprot(struct cli_state *cli, enum protocol_types max_protocol)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct event_context *ev;
@@ -2778,7 +2787,7 @@ NTSTATUS cli_negprot(struct cli_state *cli)
                goto fail;
        }
 
-       req = cli_negprot_send(frame, ev, cli);
+       req = cli_negprot_send(frame, ev, cli, max_protocol);
        if (req == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto fail;
@@ -2934,7 +2943,7 @@ NTSTATUS cli_start_connection(struct cli_state 
**output_cli,
                return nt_status;
        }
 
-       nt_status = cli_negprot(cli);
+       nt_status = cli_negprot(cli, PROTOCOL_NT1);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(1, ("failed negprot: %s\n", nt_errstr(nt_status)));
                cli_shutdown(cli);
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index 68a6724..b066b8b 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -144,11 +144,9 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
        if (max_protocol == 0) {
                max_protocol = PROTOCOL_NT1;
        }
-       c->protocol = max_protocol;
-
        DEBUG(4,(" session request ok\n"));
 
-       status = cli_negprot(c);
+       status = cli_negprot(c, max_protocol);
 
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("protocol negotiation failed: %s\n",
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 05f9548..6d85239 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -194,7 +194,6 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
                goto error;
        }
        cli->raw_status = NT_STATUS_INTERNAL_ERROR;
-       cli->protocol = PROTOCOL_NT1;
        cli->timeout = 20000; /* Timeout is in milliseconds. */
        cli->max_xmit = CLI_BUFFER_SIZE+4;
        cli->case_sensitive = false;
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 005f2cd..0af9798 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -439,7 +439,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
 
        cli_set_timeout(c, smbc_getTimeout(context));
 
-       status = cli_negprot(c);
+       status = cli_negprot(c, PROTOCOL_NT1);
 
        if (!NT_STATUS_IS_OK(status)) {
                cli_shutdown(c);
diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c
index e5c336f..58997e4 100644
--- a/source3/libsmb/passchange.c
+++ b/source3/libsmb/passchange.c
@@ -66,9 +66,7 @@ NTSTATUS remote_password_change(const char *remote_machine, 
const char *user_nam
                return result;
        }
 
-       cli->protocol = PROTOCOL_NT1;
-
-       result = cli_negprot(cli);
+       result = cli_negprot(cli, PROTOCOL_NT1);
 
        if (!NT_STATUS_IS_OK(result)) {
                if (asprintf(err_str, "machine %s rejected the negotiate "
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 4992d95..88035ff 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -67,10 +67,11 @@ struct tevent_req *cli_tdis_send(TALLOC_CTX *mem_ctx,
                                  struct cli_state *cli);
 NTSTATUS cli_tdis_recv(struct tevent_req *req);
 NTSTATUS cli_tdis(struct cli_state *cli);
-NTSTATUS cli_negprot(struct cli_state *cli);
+NTSTATUS cli_negprot(struct cli_state *cli, enum protocol_types max_protocol);
 struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
                                    struct event_context *ev,
-                                   struct cli_state *cli);
+                                   struct cli_state *cli,
+                                   enum protocol_types max_protocol);
 NTSTATUS cli_negprot_recv(struct tevent_req *req);
 NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage 
*dest_ss,
                        uint16_t port, int name_type, const char *myname,
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index a5fd356..7a256a3 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -88,7 +88,7 @@ static void sync_child(char *name, int nm_type,
                return;
        }
 
-       status = cli_negprot(cli);
+       status = cli_negprot(cli, PROTOCOL_NT1);
        if (!NT_STATUS_IS_OK(status)) {
                cli_shutdown(cli);
                return;
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index da3b9a7..e7d3df2 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -198,7 +198,7 @@ static struct cli_state *connect_one(char *share, int snum)
                return NULL;
        }
 
-       status = cli_negprot(c);
+       status = cli_negprot(c, PROTOCOL_NT1);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("protocol negotiation failed: %s\n",
                          nt_errstr(status)));
diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
index 6a4bb6e..eaac0d8 100644
--- a/source3/torture/masktest.c
+++ b/source3/torture/masktest.c
@@ -187,9 +187,7 @@ static struct cli_state *connect_one(char *share)
                return NULL;
        }
 
-       c->protocol = max_protocol;
-
-       status = cli_negprot(c);
+       status = cli_negprot(c, max_protocol);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("protocol negotiation failed: %s\n",
                          nt_errstr(status)));
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 1de7e79..3eb6fec 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -3037,7 +3037,7 @@ static bool run_negprot_nowait(int dummy)
        for (i=0;i<50000;i++) {
                struct tevent_req *req;
 
-               req = cli_negprot_send(ev, ev, cli);
+               req = cli_negprot_send(ev, ev, cli, PROTOCOL_NT1);
                if (req == NULL) {
                        TALLOC_FREE(ev);
                        return false;
@@ -6289,7 +6289,7 @@ static bool run_error_map_extract(int dummy) {
        }
        disable_spnego = false;
 
-       status = cli_negprot(c_nt);
+       status = cli_negprot(c_nt, PROTOCOL_NT1);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("%s rejected the NT-error negprot (%s)\n", host,
@@ -6316,7 +6316,7 @@ static bool run_error_map_extract(int dummy) {
        disable_spnego = false;
        force_dos_errors = false;
 
-       status = cli_negprot(c_dos);
+       status = cli_negprot(c_dos, PROTOCOL_NT1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("%s rejected the DOS-error negprot (%s)\n", host,
                       nt_errstr(status));
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 9ed4ead..fe41e77 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -7096,7 +7096,7 @@ bool net_rpc_check(struct net_context *c, unsigned flags)
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
-       status = cli_negprot(cli);
+       status = cli_negprot(cli, PROTOCOL_NT1);
        if (!NT_STATUS_IS_OK(status))
                goto done;
        if (cli_state_protocol(cli) < PROTOCOL_NT1)
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index c8d0808..88520c4 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -40,7 +40,7 @@ static time_t cli_servertime(const char *host,
                goto done;
        }
 
-       status = cli_negprot(cli);
+       status = cli_negprot(cli, PROTOCOL_NT1);
        if (!NT_STATUS_IS_OK(status)) {
                fprintf(stderr, _("Protocol negotiation failed: %s\n"),
                        nt_errstr(status));
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index b631ab6..33c4dee 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -821,7 +821,7 @@ static NTSTATUS cm_prepare_connection(const struct 
winbindd_domain *domain,
 
        cli_set_timeout(*cli, 10000); /* 10 seconds */
 
-       result = cli_negprot(*cli);
+       result = cli_negprot(*cli, PROTOCOL_NT1);
 
        if (!NT_STATUS_IS_OK(result)) {
                DEBUG(1, ("cli_negprot failed: %s\n", nt_errstr(result)));


-- 
Samba Shared Repository

Reply via email to