s3:libsmb/clidfs: make use of cli_state_encryption_on()
[samba.git] / source3 / libsmb / clidfs.c
index d677f9e0ac320cb54b733bfb1ed7ea7f9265a07a..a445649aeda5cd9cf814c40f281c3f71b742386c 100644 (file)
@@ -201,7 +201,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
           here before trying to connect to the original share.
           cli_check_msdfs_proxy() will fail if it is a normal share. */
 
-       if ((c->capabilities & CAP_DFS) &&
+       if ((cli_state_capabilities(c) & CAP_DFS) &&
                        cli_check_msdfs_proxy(ctx, c, sharename,
                                &newserver, &newshare,
                                force_encrypt,
@@ -322,7 +322,10 @@ static struct cli_state *cli_cm_find(struct cli_state *cli,
 
        /* Search to the start of the list. */
        for (p = cli; p; p = DLIST_PREV(p)) {
-               if (strequal(server, p->desthost) &&
+               const char *remote_name =
+                       cli_state_remote_name(p);
+
+               if (strequal(server, remote_name) &&
                                strequal(share,p->share)) {
                        return p;
                }
@@ -330,7 +333,10 @@ static struct cli_state *cli_cm_find(struct cli_state *cli,
 
        /* Search to the end of the list. */
        for (p = cli->next; p; p = p->next) {
-               if (strequal(server, p->desthost) &&
+               const char *remote_name =
+                       cli_state_remote_name(p);
+
+               if (strequal(server, remote_name) &&
                                strequal(share,p->share)) {
                        return p;
                }
@@ -394,13 +400,13 @@ NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
 /****************************************************************************
 ****************************************************************************/
 
-void cli_cm_display(const struct cli_state *cli)
+void cli_cm_display(struct cli_state *cli)
 {
        int i;
 
        for (i=0; cli; cli = cli->next,i++ ) {
                d_printf("%d:\tserver=%s, share=%s\n",
-                       i, cli->desthost, cli->share );
+                       i, cli_state_remote_name(cli), cli->share);
        }
 }
 
@@ -567,7 +573,7 @@ static char *cli_dfs_make_full_path(TALLOC_CTX *ctx,
        }
        return talloc_asprintf(ctx, "%c%s%c%s%c%s",
                        path_sep,
-                       cli->desthost,
+                       cli_state_remote_name(cli),
                        path_sep,
                        cli->share,
                        path_sep,
@@ -583,10 +589,10 @@ 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 (!(cli->capabilities & CAP_UNICODE)) {
+       if (!(cli_state_capabilities(cli) & CAP_UNICODE)) {
                return false;
        }
-       if (!(cli->capabilities & CAP_STATUS32)) {
+       if (!(cli_state_capabilities(cli) & CAP_STATUS32)) {
                return false;
        }
        if (NT_STATUS_EQUAL(status, expected)) {
@@ -847,12 +853,12 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 
        status = cli_cm_open(ctx,
                             rootcli,
-                            rootcli->desthost,
+                            cli_state_remote_name(rootcli),
                             "IPC$",
                             dfs_auth_info,
                             false,
-                            (rootcli->trans_enc_state != NULL),
-                            rootcli->protocol,
+                            cli_state_encryption_on(rootcli),
+                            cli_state_protocol(rootcli),
                             0,
                             0x20,
                             &cli_ipc);
@@ -902,8 +908,8 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
                             share,
                             dfs_auth_info,
                             false,
-                            (rootcli->trans_enc_state != NULL),
-                            rootcli->protocol,
+                            cli_state_encryption_on(rootcli),
+                            cli_state_protocol(rootcli),
                             0,
                             0x20,
                             targetcli);
@@ -1026,11 +1032,13 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
        uint16 cnum;
        char *newextrapath = NULL;
        NTSTATUS status;
+       const char *remote_name;
 
        if (!cli || !sharename) {
                return false;
        }
 
+       remote_name = cli_state_remote_name(cli);
        cnum = cli_state_get_tid(cli);
 
        /* special case.  never check for a referral on the IPC$ share */
@@ -1041,7 +1049,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 
        /* send a trans2_query_path_info to check for a referral */
 
-       fullpath = talloc_asprintf(ctx, "\\%s\\%s", cli->desthost, sharename );
+       fullpath = talloc_asprintf(ctx, "\\%s\\%s", remote_name, sharename);
        if (!fullpath) {
                return false;
        }
@@ -1089,7 +1097,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 
        /* check that this is not a self-referral */
 
-       if (strequal(cli->desthost, *pp_newserver) &&
+       if (strequal(remote_name, *pp_newserver) &&
                        strequal(sharename, *pp_newshare)) {
                return false;
        }