s3/libsmb: Use smbXcli_conn_use_unicode instead of smb1 specific test
[mat/samba.git] / source3 / libsmb / clidfs.c
index 1eaec45eabdaef4bd7ee881fe4cf073afaf55f5d..e311adab27351478046d38e5592f50b0b507c957 100644 (file)
@@ -48,7 +48,23 @@ NTSTATUS cli_cm_force_encryption(struct cli_state *c,
                        const char *domain,
                        const char *sharename)
 {
-       NTSTATUS status = cli_force_encryption(c,
+       NTSTATUS status;
+
+       if (smbXcli_conn_protocol(c->conn) >= PROTOCOL_SMB2_02) {
+               status = smb2cli_session_encryption_on(c->smb2.session);
+               if (NT_STATUS_EQUAL(status,NT_STATUS_NOT_SUPPORTED)) {
+                       d_printf("Encryption required and "
+                               "server doesn't support "
+                               "SMB3 encryption - failing connect\n");
+               } else if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("Encryption required and "
+                               "setup failed with error %s.\n",
+                               nt_errstr(status));
+               }
+               return status;
+       }
+
+       status = cli_force_encryption(c,
                                        username,
                                        password,
                                        domain);
@@ -129,6 +145,9 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
        if (get_cmdline_auth_info_use_ccache(auth_info)) {
                flags |= CLI_FULL_CONNECTION_USE_CCACHE;
        }
+       if (get_cmdline_auth_info_use_pw_nt_hash(auth_info)) {
+               flags |= CLI_FULL_CONNECTION_USE_NT_HASH;
+       }
 
        status = cli_connect_nb(
                server, NULL, port, name_type, NULL,
@@ -147,7 +166,9 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
        }
        DEBUG(4,(" session request ok\n"));
 
-       status = cli_negprot(c, max_protocol);
+       status = smbXcli_negprot(c->conn, c->timeout,
+                                lp_cli_minprotocol(),
+                                max_protocol);
 
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("protocol negotiation failed: %s\n",
@@ -156,6 +177,11 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
                return status;
        }
 
+       if (smbXcli_conn_protocol(c->conn) >= PROTOCOL_SMB2_02) {
+               /* Ensure we ask for some initial credits. */
+               smb2cli_conn_set_max_credits(c->conn, DEFAULT_SMB2_MAX_CREDITS);
+       }
+
        username = get_cmdline_auth_info_username(auth_info);
        password = get_cmdline_auth_info_password(auth_info);
 
@@ -596,7 +622,7 @@ static bool cli_dfs_check_error(struct cli_state *cli, NTSTATUS expected,
 {
        /* only deal with DS when we negotiated NT_STATUS codes and UNICODE */
 
-       if (!(smb1cli_conn_capabilities(cli->conn) & CAP_UNICODE)) {
+       if (!(smbXcli_conn_use_unicode(cli->conn))) {
                return false;
        }
        if (!(smb1cli_conn_capabilities(cli->conn) & CAP_STATUS32)) {
@@ -647,7 +673,7 @@ NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
        }
        SSVAL(param, 0, 0x03);  /* max referral level */
 
-       param = trans2_bytes_push_str(param, cli_ucs2(cli),
+       param = trans2_bytes_push_str(param, smbXcli_conn_use_unicode(cli->conn),
                                      path, strlen(path)+1,
                                      NULL);
        if (!param) {
@@ -864,7 +890,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
                             "IPC$",
                             dfs_auth_info,
                             false,
-                            cli_state_encryption_on(rootcli),
+                            smb1cli_conn_encryption_on(rootcli->conn),
                             smbXcli_conn_protocol(rootcli->conn),
                             0,
                             0x20,
@@ -915,7 +941,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
                             share,
                             dfs_auth_info,
                             false,
-                            cli_state_encryption_on(rootcli),
+                            smb1cli_conn_encryption_on(rootcli->conn),
                             smbXcli_conn_protocol(rootcli->conn),
                             0,
                             0x20,