s3-client: Remove use of cli_errstr()
[mat/samba.git] / source3 / client / client.c
index 15c5e9cc94abc920a23a9b357812eb28e27a9d26..82dc8c40dd83df15cef55aa020fb26fd028c41ca 100644 (file)
@@ -311,8 +311,11 @@ static int do_dskattr(void)
        TALLOC_CTX *ctx = talloc_tos();
        NTSTATUS status;
 
-       if ( !cli_resolve_path(ctx, "", auth_info, cli, client_get_cur_dir(), &targetcli, &targetpath)) {
-               d_printf("Error in dskattr: %s\n", cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli,
+                                 client_get_cur_dir(), &targetcli,
+                                 &targetpath);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("Error in dskattr: %s\n", nt_errstr(status));
                return 1;
        }
 
@@ -365,6 +368,7 @@ static int do_cd(const char *new_dir)
        uint32 attributes;
        int ret = 1;
        TALLOC_CTX *ctx = talloc_stackframe();
+       NTSTATUS status;
 
        newdir = talloc_strdup(ctx, new_dir);
        if (!newdir) {
@@ -406,8 +410,10 @@ static int do_cd(const char *new_dir)
        new_cd = clean_name(ctx, new_cd);
        client_set_cur_dir(new_cd);
 
-       if ( !cli_resolve_path(ctx, "", auth_info, cli, new_cd, &targetcli, &targetpath)) {
-               d_printf("cd %s: %s\n", new_cd, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, new_cd,
+                                 &targetcli, &targetpath);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("cd %s: %s\n", new_cd, nt_errstr(status));
                client_set_cur_dir(saved_dir);
                goto out;
        }
@@ -421,7 +427,6 @@ static int do_cd(const char *new_dir)
           Except Win9x doesn't support the qpathinfo_basic() call..... */
 
        if (targetcli->protocol > PROTOCOL_LANMAN2 && !targetcli->win95) {
-               NTSTATUS status;
 
                status = cli_qpathinfo_basic(targetcli, targetpath, &sbuf,
                                             &attributes);
@@ -437,7 +442,6 @@ static int do_cd(const char *new_dir)
                        goto out;
                }
        } else {
-               NTSTATUS status;
 
                targetpath = talloc_asprintf(ctx,
                                "%s%s",
@@ -858,8 +862,12 @@ NTSTATUS do_list(const char *mask,
 
                        /* check for dfs */
 
-                       if ( !cli_resolve_path(ctx, "", auth_info, cli, head, &targetcli, &targetpath ) ) {
-                               d_printf("do_list: [%s] %s\n", head, cli_errstr(cli));
+                       status = cli_resolve_path(ctx, "", auth_info, cli,
+                                                 head, &targetcli,
+                                                 &targetpath);
+                       if (!NT_STATUS_IS_OK(status)) {
+                               d_printf("do_list: [%s] %s\n", head,
+                                        nt_errstr(status));
                                remove_do_list_queue_head();
                                continue;
                        }
@@ -897,8 +905,9 @@ NTSTATUS do_list(const char *mask,
                }
        } else {
                /* check for dfs */
-               if (cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetpath)) {
-
+               status = cli_resolve_path(ctx, "", auth_info, cli, mask,
+                                         &targetcli, &targetpath);
+               if (NT_STATUS_IS_OK(status)) {
                        status = cli_list(targetcli, targetpath, attribute,
                                          do_list_helper, targetcli);
                        if (!NT_STATUS_IS_OK(status)) {
@@ -908,8 +917,8 @@ NTSTATUS do_list(const char *mask,
                        }
                        TALLOC_FREE(targetpath);
                } else {
-                       d_printf("do_list: [%s] %s\n", mask, cli_errstr(cli));
-                       ret_status = cli_nt_error(cli);
+                       d_printf("do_list: [%s] %s\n", mask, nt_errstr(status));
+                       ret_status = status;
                }
        }
 
@@ -1078,8 +1087,10 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
                strlower_m(lname);
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli, &targetname ) ) {
-               d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("Failed to open %s: %s\n", rname, nt_errstr(status));
                return 1;
        }
 
@@ -1460,8 +1471,10 @@ static bool do_mkdir(const char *name)
        char *targetname = NULL;
        NTSTATUS status;
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) {
-               d_printf("mkdir %s: %s\n", name, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("mkdir %s: %s\n", name, nt_errstr(status));
                return false;
        }
 
@@ -1516,6 +1529,7 @@ static int cmd_mkdir(void)
        TALLOC_CTX *ctx = talloc_tos();
        char *mask = NULL;
        char *buf = NULL;
+        NTSTATUS status;
 
        mask = talloc_strdup(ctx, client_get_cur_dir());
        if (!mask) {
@@ -1546,7 +1560,9 @@ static int cmd_mkdir(void)
                        return 1;
                }
 
-               if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
+               status = cli_resolve_path(ctx, "", auth_info, cli, mask,
+                                         &targetcli, &targetname);
+               if (!NT_STATUS_IS_OK(status)) {
                        return 1;
                }
 
@@ -1716,6 +1732,23 @@ static int do_allinfo(const char *name)
                         (unsigned long long)streams[i].size);
        }
 
+       if (mode & FILE_ATTRIBUTE_REPARSE_POINT) {
+               char *subst, *print;
+               uint32_t flags;
+
+               status = cli_readlink(cli, name, talloc_tos(), &subst, &print,
+                                     &flags);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_fprintf(stderr, "cli_readlink returned %s\n",
+                                 nt_errstr(status));
+               } else {
+                       d_printf("symlink: subst=[%s], print=[%s], flags=%x\n",
+                                subst, print, flags);
+                       TALLOC_FREE(subst);
+                       TALLOC_FREE(print);
+               }
+       }
+
        status = cli_ntcreate(cli, name, 0,
                              CREATE_ACCESS_READ, 0,
                              FILE_SHARE_READ|FILE_SHARE_WRITE
@@ -1812,8 +1845,10 @@ static int do_put(const char *rname, const char *lname, bool reput)
        struct push_state state;
        NTSTATUS status;
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli, &targetname)) {
-               d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, rname,
+                                 &targetcli, &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("Failed to open %s: %s\n", rname, nt_errstr(status));
                return 1;
        }
 
@@ -2390,8 +2425,10 @@ static int cmd_wdel(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
-               d_printf("cmd_wdel %s: %s\n", mask, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("cmd_wdel %s: %s\n", mask, nt_errstr(status));
                return 1;
        }
 
@@ -2414,6 +2451,7 @@ static int cmd_open(void)
        char *targetname = NULL;
        struct cli_state *targetcli;
        uint16_t fnum = (uint16_t)-1;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
                d_printf("open <filename>\n");
@@ -2427,8 +2465,10 @@ static int cmd_open(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
-               d_printf("open %s: %s\n", mask, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("open %s: %s\n", mask, nt_errstr(status));
                return 1;
        }
 
@@ -2503,6 +2543,7 @@ static int cmd_posix_open(void)
        struct cli_state *targetcli;
        mode_t mode;
        uint16_t fnum;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
                d_printf("posix_open <filename> 0<mode>\n");
@@ -2522,19 +2563,28 @@ static int cmd_posix_open(void)
        }
        mode = (mode_t)strtol(buf, (char **)NULL, 8);
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
-               d_printf("posix_open %s: %s\n", mask, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("posix_open %s: %s\n", mask, nt_errstr(status));
                return 1;
        }
 
-       if (!NT_STATUS_IS_OK(cli_posix_open(targetcli, targetname, O_CREAT|O_RDWR, mode, &fnum))) {
-               if (!NT_STATUS_IS_OK(cli_posix_open(targetcli, targetname, O_CREAT|O_RDONLY, mode, &fnum))) {
-                       d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
+       status = cli_posix_open(targetcli, targetname, O_CREAT|O_RDWR, mode,
+                               &fnum);
+       if (!NT_STATUS_IS_OK(status)) {
+               status = cli_posix_open(targetcli, targetname,
+                                       O_CREAT|O_RDONLY, mode, &fnum);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("Failed to open file %s. %s\n", targetname,
+                                nt_errstr(status));
                } else {
-                       d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli));
+                       d_printf("posix_open file %s: for readonly fnum %d\n",
+                                targetname, fnum);
                }
        } else {
-               d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
+               d_printf("posix_open file %s: for read/write fnum %d\n",
+                        targetname, fnum);
        }
 
        return 0;
@@ -2548,6 +2598,7 @@ static int cmd_posix_mkdir(void)
        char *targetname = NULL;
        struct cli_state *targetcli;
        mode_t mode;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
                d_printf("posix_mkdir <filename> 0<mode>\n");
@@ -2567,8 +2618,10 @@ static int cmd_posix_mkdir(void)
        }
        mode = (mode_t)strtol(buf, (char **)NULL, 8);
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
-               d_printf("posix_mkdir %s: %s\n", mask, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("posix_mkdir %s: %s\n", mask, nt_errstr(status));
                return 1;
        }
 
@@ -2587,6 +2640,7 @@ static int cmd_posix_unlink(void)
        char *buf = NULL;
        char *targetname = NULL;
        struct cli_state *targetcli;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
                d_printf("posix_unlink <filename>\n");
@@ -2600,8 +2654,10 @@ static int cmd_posix_unlink(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
-               d_printf("posix_unlink %s: %s\n", mask, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("posix_unlink %s: %s\n", mask, nt_errstr(status));
                return 1;
        }
 
@@ -2621,6 +2677,7 @@ static int cmd_posix_rmdir(void)
        char *buf = NULL;
        char *targetname = NULL;
        struct cli_state *targetcli;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
                d_printf("posix_rmdir <filename>\n");
@@ -2634,8 +2691,10 @@ static int cmd_posix_rmdir(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
-               d_printf("posix_rmdir %s: %s\n", mask, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("posix_rmdir %s: %s\n", mask, nt_errstr(status));
                return 1;
        }
 
@@ -2868,6 +2927,7 @@ static int cmd_rmdir(void)
        char *buf = NULL;
        char *targetname = NULL;
        struct cli_state *targetcli;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
                d_printf("rmdir <dirname>\n");
@@ -2881,8 +2941,10 @@ static int cmd_rmdir(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
-               d_printf("rmdir %s: %s\n", mask, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("rmdir %s: %s\n", mask, nt_errstr(status));
                return 1;
        }
 
@@ -2907,6 +2969,7 @@ static int cmd_link(void)
        char *buf2 = NULL;
        char *targetname = NULL;
        struct cli_state *targetcli;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
            !next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
@@ -2928,8 +2991,10 @@ static int cmd_link(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli, &targetname)) {
-               d_printf("link %s: %s\n", oldname, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("link %s: %s\n", oldname, nt_errstr(status));
                return 1;
        }
 
@@ -2957,6 +3022,7 @@ static int cmd_readlink(void)
        char *targetname = NULL;
        char linkname[PATH_MAX+1];
        struct cli_state *targetcli;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
                d_printf("readlink <name>\n");
@@ -2970,8 +3036,10 @@ static int cmd_readlink(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) {
-               d_printf("readlink %s: %s\n", name, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("readlink %s: %s\n", name, nt_errstr(status));
                return 1;
        }
 
@@ -3022,9 +3090,10 @@ static int cmd_symlink(void)
                        return 1;
                }
                /* New name must be present in share namespace. */
-               if (!cli_resolve_path(ctx, "", auth_info, cli, newname,
-                                     &newcli, &newname)) {
-                       d_printf("link %s: %s\n", oldname, cli_errstr(cli));
+               status = cli_resolve_path(ctx, "", auth_info, cli, newname,
+                                         &newcli, &newname);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("link %s: %s\n", oldname, nt_errstr(status));
                        return 1;
                }
                status = cli_posix_symlink(newcli, oldname, newname);
@@ -3036,7 +3105,7 @@ static int cmd_symlink(void)
 
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("%s symlinking files (%s -> %s)\n",
-                        nt_errstr(status), newname, newname);
+                        nt_errstr(status), oldname, newname);
                return 1;
        }
 
@@ -3056,6 +3125,7 @@ static int cmd_chmod(void)
        char *targetname = NULL;
        struct cli_state *targetcli;
        mode_t mode;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
            !next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
@@ -3072,8 +3142,10 @@ static int cmd_chmod(void)
 
        mode = (mode_t)strtol(buf, NULL, 8);
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
-               d_printf("chmod %s: %s\n", src, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("chmod %s: %s\n", src, nt_errstr(status));
                return 1;
        }
 
@@ -3226,8 +3298,10 @@ static int cmd_getfacl(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
-               d_printf("stat %s: %s\n", src, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("stat %s: %s\n", src, nt_errstr(status));
                return 1;
        }
 
@@ -3395,9 +3469,10 @@ static int cmd_geteas(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
-                             &targetname)) {
-               d_printf("stat %s: %s\n", src, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("stat %s: %s\n", src, nt_errstr(status));
                return 1;
        }
 
@@ -3451,9 +3526,10 @@ static int cmd_setea(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
-                             &targetname)) {
-               d_printf("stat %s: %s\n", src, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("stat %s: %s\n", src, nt_errstr(status));
                return 1;
        }
 
@@ -3482,6 +3558,7 @@ static int cmd_stat(void)
        SMB_STRUCT_STAT sbuf;
        struct tm *lt;
        time_t tmp_time;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) {
                d_printf("stat file\n");
@@ -3495,8 +3572,10 @@ static int cmd_stat(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
-               d_printf("stat %s: %s\n", src, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("stat %s: %s\n", src, nt_errstr(status));
                return 1;
        }
 
@@ -3581,6 +3660,7 @@ static int cmd_chown(void)
        char *buf, *buf2, *buf3;
        struct cli_state *targetcli;
        char *targetname = NULL;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
            !next_token_talloc(ctx, &cmd_ptr,&buf2,NULL) ||
@@ -3599,8 +3679,10 @@ static int cmd_chown(void)
        if (!src) {
                return 1;
        }
-       if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname) ) {
-               d_printf("chown %s: %s\n", src, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("chown %s: %s\n", src, nt_errstr(status));
                return 1;
        }
 
@@ -3630,6 +3712,7 @@ static int cmd_rename(void)
        struct cli_state *targetcli;
        char *targetsrc;
        char *targetdest;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
            !next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
@@ -3653,13 +3736,17 @@ static int cmd_rename(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetsrc)) {
-               d_printf("rename %s: %s\n", src, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+                                 &targetsrc);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("rename %s: %s\n", src, nt_errstr(status));
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, dest, &targetcli, &targetdest)) {
-               d_printf("rename %s: %s\n", dest, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, dest, &targetcli,
+                                 &targetdest);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("rename %s: %s\n", dest, nt_errstr(status));
                return 1;
        }
 
@@ -3680,12 +3767,13 @@ static int cmd_rename(void)
 
 static int cmd_volume(void)
 {
-       fstring volname;
-       uint32 serial_num;
+       char *volname;
+       uint32_t serial_num;
        time_t create_date;
        NTSTATUS status;
 
-       status = cli_get_fs_volume_info(cli, volname, &serial_num,
+       status = cli_get_fs_volume_info(cli, talloc_tos(),
+                                       &volname, &serial_num,
                                        &create_date);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Error %s getting volume info\n", nt_errstr(status));
@@ -3708,6 +3796,7 @@ static int cmd_hardlink(void)
        char *buf, *buf2;
        struct cli_state *targetcli;
        char *targetname;
+        NTSTATUS status;
 
        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
            !next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
@@ -3731,8 +3820,10 @@ static int cmd_hardlink(void)
                return 1;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
-               d_printf("hardlink %s: %s\n", src, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+                                 &targetname);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("hardlink %s: %s\n", src, nt_errstr(status));
                return 1;
        }
 
@@ -4203,10 +4294,13 @@ static int cmd_show_connect( void )
        TALLOC_CTX *ctx = talloc_tos();
        struct cli_state *targetcli;
        char *targetpath;
+       NTSTATUS status;
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, client_get_cur_dir(),
-                               &targetcli, &targetpath ) ) {
-               d_printf("showconnect %s: %s\n", cur_dir, cli_errstr(cli));
+       status = cli_resolve_path(ctx, "", auth_info, cli,
+                                 client_get_cur_dir(), &targetcli,
+                                 &targetpath);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("showconnect %s: %s\n", cur_dir, nt_errstr(status));
                return 1;
        }
 
@@ -4449,12 +4543,15 @@ static int process_command_string(const char *cmd_in)
        /* establish the connection if not already */
 
        if (!cli) {
-               cli = cli_cm_open(talloc_tos(), NULL,
-                               have_ip ? dest_ss_str : desthost,
-                               service, auth_info,
-                               true, smb_encrypt,
-                               max_protocol, port, name_type);
-               if (!cli) {
+               NTSTATUS status;
+
+               status = cli_cm_open(talloc_tos(), NULL,
+                                    have_ip ? dest_ss_str : desthost,
+                                    service, auth_info,
+                                    true, smb_encrypt,
+                                    max_protocol, port, name_type,
+                                    &cli);
+               if (!NT_STATUS_IS_OK(status)) {
                        return 1;
                }
        }
@@ -4629,7 +4726,9 @@ static char **remote_completion(const char *text, int len)
                goto cleanup;
        }
 
-       if (!cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli, &targetpath)) {
+       status = cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli,
+                                 &targetpath);
+       if (!NT_STATUS_IS_OK(status)) {
                goto cleanup;
        }
        status = cli_list(targetcli, targetpath, FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
@@ -4921,12 +5020,13 @@ static int process_stdin(void)
 static int process(const char *base_directory)
 {
        int rc = 0;
+       NTSTATUS status;
 
-       cli = cli_cm_open(talloc_tos(), NULL,
-                       have_ip ? dest_ss_str : desthost,
-                       service, auth_info, true, smb_encrypt,
-                       max_protocol, port, name_type);
-       if (!cli) {
+       status = cli_cm_open(talloc_tos(), NULL,
+                            have_ip ? dest_ss_str : desthost,
+                            service, auth_info, true, smb_encrypt,
+                            max_protocol, port, name_type, &cli);
+       if (!NT_STATUS_IS_OK(status)) {
                return 1;
        }
 
@@ -4954,11 +5054,15 @@ static int process(const char *base_directory)
 
 static int do_host_query(const char *query_host)
 {
-       cli = cli_cm_open(talloc_tos(), NULL,
-                       have_ip ? dest_ss_str : query_host, "IPC$", auth_info, true, smb_encrypt,
-                       max_protocol, port, name_type);
-       if (!cli)
+       NTSTATUS status;
+
+       status = cli_cm_open(talloc_tos(), NULL,
+                            have_ip ? dest_ss_str : query_host,
+                            "IPC$", auth_info, true, smb_encrypt,
+                            max_protocol, port, name_type, &cli);
+       if (!NT_STATUS_IS_OK(status)) {
                return 1;
+       }
 
        browse_host(true);
 
@@ -4980,10 +5084,13 @@ static int do_host_query(const char *query_host)
                   else but port 139... */
 
                cli_shutdown(cli);
-               cli = cli_cm_open(talloc_tos(), NULL,
-                               have_ip ? dest_ss_str : query_host, "IPC$",
-                               auth_info, true, smb_encrypt,
-                               max_protocol, 139, name_type);
+               status = cli_cm_open(talloc_tos(), NULL,
+                                    have_ip ? dest_ss_str : query_host,
+                                    "IPC$", auth_info, true, smb_encrypt,
+                                    max_protocol, 139, name_type, &cli);
+               if (!NT_STATUS_IS_OK(status)) {
+                       cli = NULL;
+               }
        }
 
        if (cli == NULL) {
@@ -5008,12 +5115,15 @@ static int do_tar_op(const char *base_directory)
 
        /* do we already have a connection? */
        if (!cli) {
-               cli = cli_cm_open(talloc_tos(), NULL,
-                       have_ip ? dest_ss_str : desthost,
-                       service, auth_info, true, smb_encrypt,
-                       max_protocol, port, name_type);
-               if (!cli)
+               NTSTATUS status;
+
+               status = cli_cm_open(talloc_tos(), NULL,
+                                    have_ip ? dest_ss_str : desthost,
+                                    service, auth_info, true, smb_encrypt,
+                                    max_protocol, port, name_type, &cli);
+               if (!NT_STATUS_IS_OK(status)) {
                        return 1;
+               }
        }
 
        recurse=true;