s3:libsmb: don't pass 'passlen' to cli_tree_connect[_send]() and allow pass=NULL
authorStefan Metzmacher <metze@samba.org>
Thu, 8 Dec 2016 06:13:57 +0000 (07:13 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 9 Dec 2016 12:09:37 +0000 (13:09 +0100)
There're no callers which try to pass a raw lm_response directly anymore.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Dec  9 13:09:37 CET 2016 on sn-devel-144

13 files changed:
source3/client/client.c
source3/lib/util_sd.c
source3/libsmb/cliconnect.c
source3/libsmb/clidfs.c
source3/libsmb/libsmb_server.c
source3/libsmb/passchange.c
source3/libsmb/proto.h
source3/nmbd/nmbd_synclists.c
source3/torture/test_smb2.c
source3/torture/torture.c
source3/utils/net_rpc.c
source3/utils/smbcacls.c
source3/winbindd/winbindd_cm.c

index 65696f9..224ec07 100644 (file)
@@ -4638,7 +4638,7 @@ static int cmd_tcon(void)
                return 1;
        }
 
-       status = cli_tree_connect(cli, sharename, "?????", "", 0);
+       status = cli_tree_connect(cli, sharename, "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("tcon failed: %s\n", nt_errstr(status));
                return -1;
index 9a7b34f..d79fe79 100644 (file)
@@ -93,7 +93,7 @@ static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli,
        char **domains;
        char **names;
 
-       status = cli_tree_connect(cli, "IPC$", "?????", "", 0);
+       status = cli_tree_connect(cli, "IPC$", "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                goto tcon_fail;
        }
@@ -173,7 +173,7 @@ static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli,
        struct dom_sid *sids;
        enum lsa_SidType *types;
 
-       status = cli_tree_connect(cli, "IPC$", "?????", "", 0);
+       status = cli_tree_connect(cli, "IPC$", "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                goto tcon_fail;
        }
index 8f581a1..559712e 100644 (file)
@@ -2204,10 +2204,16 @@ static void cli_tree_connect_raw_done(struct tevent_req *subreq);
 
 static struct tevent_req *cli_tree_connect_send(
        TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
-       const char *share, const char *dev, const char *pass, int passlen)
+       const char *share, const char *dev, const char *pass)
 {
        struct tevent_req *req, *subreq;
        struct cli_tree_connect_state *state;
+       int passlen;
+
+       if (pass == NULL) {
+               pass = "";
+       }
+       passlen = strlen(pass) + 1;
 
        req = tevent_req_create(mem_ctx, &state,
                                struct cli_tree_connect_state);
@@ -2312,7 +2318,7 @@ static NTSTATUS cli_tree_connect_recv(struct tevent_req *req)
 }
 
 NTSTATUS cli_tree_connect(struct cli_state *cli, const char *share,
-                         const char *dev, const char *pass, int passlen)
+                         const char *dev, const char *pass)
 {
        struct tevent_context *ev;
        struct tevent_req *req;
@@ -2325,7 +2331,7 @@ NTSTATUS cli_tree_connect(struct cli_state *cli, const char *share,
        if (ev == NULL) {
                goto fail;
        }
-       req = cli_tree_connect_send(ev, ev, cli, share, dev, pass, passlen);
+       req = cli_tree_connect_send(ev, ev, cli, share, dev, pass);
        if (req == NULL) {
                goto fail;
        }
@@ -2343,18 +2349,12 @@ NTSTATUS cli_tree_connect_creds(struct cli_state *cli,
                                struct cli_credentials *creds)
 {
        const char *pw = NULL;
-       size_t pw_len = 0;
 
        if (creds != NULL) {
                pw = cli_credentials_get_password(creds);
        }
 
-       if (pw == NULL) {
-               pw = "";
-       }
-       pw_len = strlen(pw) + 1;
-
-       return cli_tree_connect(cli, share, dev, pw, pw_len);
+       return cli_tree_connect(cli, share, dev, pw);
 }
 
 /****************************************************************************
@@ -3009,7 +3009,6 @@ static void cli_full_connection_creds_tcon_start(struct tevent_req *req)
                req, struct cli_full_connection_creds_state);
        struct tevent_req *subreq = NULL;
        const char *password = NULL;
-       int pw_len = 0;
 
        if (state->service == NULL) {
                tevent_req_done(req);
@@ -3017,18 +3016,12 @@ static void cli_full_connection_creds_tcon_start(struct tevent_req *req)
        }
 
        password = cli_credentials_get_password(state->creds);
-       if (password == NULL) {
-               password = "";
-               pw_len = 0;
-       } else {
-               pw_len = strlen(password) + 1;
-       }
 
        subreq = cli_tree_connect_send(state, state->ev,
                                       state->cli,
                                       state->service,
                                       state->service_type,
-                                      password, pw_len);
+                                      password);
        if (tevent_req_nomem(subreq, req)) {
                return;
        }
index 86a74ec..b44bbef 100644 (file)
@@ -254,8 +254,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 
        /* must be a normal share */
 
-       status = cli_tree_connect(c, sharename, "?????",
-                                 password, strlen(password)+1);
+       status = cli_tree_connect(c, sharename, "?????", password);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("tree connect failed: %s\n", nt_errstr(status));
                cli_shutdown(c);
@@ -1203,7 +1202,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 
        /* check for the referral */
 
-       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, "IPC$", "IPC", NULL, 0))) {
+       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, "IPC$", "IPC", NULL))) {
                return false;
        }
 
index 591d646..438b7e6 100644 (file)
@@ -344,8 +344,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
                        status = cli_tree_connect(srv->cli,
                                                  srv->cli->share,
                                                  "?????",
-                                                 *pp_password,
-                                                 strlen(*pp_password)+1);
+                                                 *pp_password);
                        if (!NT_STATUS_IS_OK(status)) {
                                 errno = map_errno_from_nt_status(status);
                                 cli_shutdown(srv->cli);
@@ -542,8 +541,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
 
        /* must be a normal share */
 
-       status = cli_tree_connect(c, share, "?????", *pp_password,
-                                 strlen(*pp_password)+1);
+       status = cli_tree_connect(c, share, "?????", *pp_password);
        if (!NT_STATUS_IS_OK(status)) {
                errno = map_errno_from_nt_status(status);
                cli_shutdown(c);
index 71a2907..c89b7ca 100644 (file)
@@ -120,7 +120,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
                }
        }
 
-       result = cli_tree_connect(cli, "IPC$", "IPC", "", 1);
+       result = cli_tree_connect(cli, "IPC$", "IPC", NULL);
        if (!NT_STATUS_IS_OK(result)) {
                if (asprintf(err_str, "machine %s rejected the tconX on the "
                             "IPC$ share. Error was : %s.\n",
index e29ba69..e1cd185 100644 (file)
@@ -82,7 +82,7 @@ NTSTATUS cli_tree_connect_creds(struct cli_state *cli,
                                const char *share, const char *dev,
                                struct cli_credentials *creds);
 NTSTATUS cli_tree_connect(struct cli_state *cli, const char *share,
-                         const char *dev, const char *pass, int passlen);
+                         const char *dev, const char *pass);
 NTSTATUS cli_tdis(struct cli_state *cli);
 NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
                        uint16_t port, int name_type, const char *myname,
index 1c2b04d..d69d6f9 100644 (file)
@@ -101,7 +101,7 @@ static void sync_child(char *name, int nm_type,
                return;
        }
 
-       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, "IPC$", "IPC", "", 1))) {
+       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, "IPC$", "IPC", NULL))) {
                cli_shutdown(cli);
                return;
        }
index 3eee2ac..7819bc2 100644 (file)
@@ -64,7 +64,7 @@ bool run_smb2_basic(int dummy)
                return false;
        }
 
-       status = cli_tree_connect(cli, share, "?????", "", 0);
+       status = cli_tree_connect(cli, share, "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
@@ -336,7 +336,7 @@ bool run_smb2_session_reconnect(int dummy)
                return false;
        }
 
-       status = cli_tree_connect(cli1, share, "?????", "", 0);
+       status = cli_tree_connect(cli1, share, "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
@@ -527,7 +527,7 @@ bool run_smb2_session_reconnect(int dummy)
                return false;
        }
 
-       status = cli_tree_connect(cli1, share, "?????", "", 0);
+       status = cli_tree_connect(cli1, share, "?????", NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_USER_SESSION_DELETED)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
@@ -651,7 +651,7 @@ bool run_smb2_session_reconnect(int dummy)
 
        /* now do a new tcon and test file calls again */
 
-       status = cli_tree_connect(cli2, share, "?????", "", 0);
+       status = cli_tree_connect(cli2, share, "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
@@ -744,7 +744,7 @@ bool run_smb2_tcon_dependence(int dummy)
                return false;
        }
 
-       status = cli_tree_connect(cli, share, "?????", "", 0);
+       status = cli_tree_connect(cli, share, "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
@@ -896,7 +896,7 @@ bool run_smb2_multi_channel(int dummy)
                return false;
        }
 
-       status = cli_tree_connect(cli1, share, "?????", "", 0);
+       status = cli_tree_connect(cli1, share, "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
@@ -1453,7 +1453,7 @@ bool run_smb2_session_reauth(int dummy)
                return false;
        }
 
-       status = cli_tree_connect(cli, share, "?????", "", 0);
+       status = cli_tree_connect(cli, share, "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
@@ -1702,7 +1702,7 @@ bool run_smb2_session_reauth(int dummy)
                                0, /* flags */
                                0, /* capabilities */
                                0  /* maximal_access */);
-       status = cli_tree_connect(cli, share, "?????", "", 0);
+       status = cli_tree_connect(cli, share, "?????", NULL);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
@@ -1882,7 +1882,7 @@ bool run_smb2_session_reauth(int dummy)
                                0, /* flags */
                                0, /* capabilities */
                                0  /* maximal_access */);
-       status = cli_tree_connect(cli, share, "?????", "", 0);
+       status = cli_tree_connect(cli, share, "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("cli_tree_connect returned %s\n", nt_errstr(status));
                return false;
index aac558f..09e8b93 100644 (file)
@@ -1341,8 +1341,7 @@ static bool run_tcon_test(int dummy)
                return False;
        }
 
-       status = cli_tree_connect(cli, share, "?????",
-                                 password, strlen(password)+1);
+       status = cli_tree_connect(cli, share, "?????", password);
        if (!NT_STATUS_IS_OK(status)) {
                printf("%s refused 2nd tree connect (%s)\n", host,
                       nt_errstr(status));
@@ -1467,8 +1466,7 @@ static bool tcon_devtest(struct cli_state *cli,
        NTSTATUS status;
        bool ret;
 
-       status = cli_tree_connect(cli, myshare, devtype,
-                                 password, strlen(password)+1);
+       status = cli_tree_connect(cli, myshare, devtype, password);
 
        if (NT_STATUS_IS_OK(expected_error)) {
                if (NT_STATUS_IS_OK(status)) {
@@ -2792,7 +2790,7 @@ static bool run_fdsesstest(int dummy)
                return False;
 
        saved_cnum = cli_state_get_tid(cli);
-       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, share, "?????", "", 1)))
+       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, share, "?????", NULL)))
                return False;
        new_cnum = cli_state_get_tid(cli);
        cli_state_set_tid(cli, saved_cnum);
@@ -8377,8 +8375,7 @@ static bool run_large_readx(int dummy)
                status = cli_tree_connect(cli2,
                                        share,
                                        "?????",
-                                       password,
-                                       strlen(password)+1);
+                                       password);
                if (!NT_STATUS_IS_OK(status)) {
                        goto out;
                }
index 68f541b..126839e 100644 (file)
@@ -3763,7 +3763,7 @@ static bool check_share_availability(struct cli_state *cli, const char *netname)
 {
        NTSTATUS status;
 
-       status = cli_tree_connect(cli, netname, "A:", "", 0);
+       status = cli_tree_connect(cli, netname, "A:", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf(_("skipping   [%s]: not a file share.\n"), netname);
                return false;
@@ -5125,7 +5125,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
 
        cnum = cli_state_get_tid(cli);
 
-       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, netname, "A:", "", 0))) {
+       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, netname, "A:", NULL))) {
                return;
        }
 
index 8d77527..7705eb4 100644 (file)
@@ -57,7 +57,7 @@ static NTSTATUS cli_lsa_lookup_domain_sid(struct cli_state *cli,
        NTSTATUS status, result;
        TALLOC_CTX *frame = talloc_stackframe();
 
-       status = cli_tree_connect(cli, "IPC$", "?????", "", 0);
+       status = cli_tree_connect(cli, "IPC$", "?????", NULL);
        if (!NT_STATUS_IS_OK(status)) {
                goto done;
        }
index fecec97..4eff7a7 100644 (file)
@@ -1227,7 +1227,7 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
                smbXcli_session_set_disconnect_expired((*cli)->smb2.session);
        }
 
-       result = cli_tree_connect(*cli, "IPC$", "IPC", "", 0);
+       result = cli_tree_connect(*cli, "IPC$", "IPC", NULL);
 
        if (!NT_STATUS_IS_OK(result)) {
                DEBUG(1,("failed tcon_X with %s\n", nt_errstr(result)));