summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-07-03 20:53:55 +0200
committerVolker Lendecke <vlendec@samba.org>2011-07-06 08:35:27 +0200
commit26782fbbf3a7885746aa17be259607dd2d418347 (patch)
treec2bccfc28bf124b7b983f167fa156a590a448eb0 /source3
parentc019302e65051f214c5ea2ef908aa0ef79c8b12e (diff)
downloadsamba-26782fbbf3a7885746aa17be259607dd2d418347.tar.gz
samba-26782fbbf3a7885746aa17be259607dd2d418347.tar.bz2
samba-26782fbbf3a7885746aa17be259607dd2d418347.zip
s3: make cli_resolve_path return NTSTATUS
This looks larger than it is. No parameters needed changing.
Diffstat (limited to 'source3')
-rw-r--r--source3/client/client.c142
-rw-r--r--source3/libsmb/clidfs.c78
-rw-r--r--source3/libsmb/libsmb_dir.c51
-rw-r--r--source3/libsmb/libsmb_file.c54
-rw-r--r--source3/libsmb/libsmb_stat.c8
-rw-r--r--source3/libsmb/libsmb_xattr.c13
-rw-r--r--source3/libsmb/proto.h14
-rw-r--r--source3/utils/net_rpc.c6
8 files changed, 230 insertions, 136 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index bc653d5ec7..cbeabdf34c 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -311,7 +311,10 @@ 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)) {
+ 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", cli_errstr(cli));
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,7 +410,9 @@ 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)) {
+ 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, cli_errstr(cli));
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,7 +862,10 @@ NTSTATUS do_list(const char *mask,
/* check for dfs */
- if ( !cli_resolve_path(ctx, "", auth_info, cli, head, &targetcli, &targetpath ) ) {
+ 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, cli_errstr(cli));
remove_do_list_queue_head();
continue;
@@ -897,8 +904,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)) {
@@ -1078,7 +1086,9 @@ 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 ) ) {
+ 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, cli_errstr(cli));
return 1;
}
@@ -1460,7 +1470,9 @@ static bool do_mkdir(const char *name)
char *targetname = NULL;
NTSTATUS status;
- if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("mkdir %s: %s\n", name, cli_errstr(cli));
return false;
}
@@ -1516,6 +1528,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 +1559,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;
}
@@ -1829,7 +1844,9 @@ 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)) {
+ 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, cli_errstr(cli));
return 1;
}
@@ -2407,7 +2424,9 @@ static int cmd_wdel(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)) {
d_printf("cmd_wdel %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@@ -2431,6 +2450,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");
@@ -2444,7 +2464,9 @@ static int cmd_open(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)) {
d_printf("open %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@@ -2520,6 +2542,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");
@@ -2539,7 +2562,9 @@ 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)) {
+ 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, cli_errstr(cli));
return 1;
}
@@ -2565,6 +2590,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");
@@ -2584,7 +2610,9 @@ 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)) {
+ 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, cli_errstr(cli));
return 1;
}
@@ -2604,6 +2632,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");
@@ -2617,7 +2646,9 @@ static int cmd_posix_unlink(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)) {
d_printf("posix_unlink %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@@ -2638,6 +2669,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");
@@ -2651,7 +2683,9 @@ static int cmd_posix_rmdir(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)) {
d_printf("posix_rmdir %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@@ -2885,6 +2919,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");
@@ -2898,7 +2933,9 @@ static int cmd_rmdir(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)) {
d_printf("rmdir %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@@ -2924,6 +2961,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)) {
@@ -2945,7 +2983,9 @@ static int cmd_link(void)
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli, &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("link %s: %s\n", oldname, cli_errstr(cli));
return 1;
}
@@ -2974,6 +3014,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");
@@ -2987,7 +3028,9 @@ static int cmd_readlink(void)
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("readlink %s: %s\n", name, cli_errstr(cli));
return 1;
}
@@ -3039,8 +3082,9 @@ 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)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, newname,
+ &newcli, &newname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("link %s: %s\n", oldname, cli_errstr(cli));
return 1;
}
@@ -3073,6 +3117,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)) {
@@ -3089,7 +3134,9 @@ static int cmd_chmod(void)
mode = (mode_t)strtol(buf, NULL, 8);
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("chmod %s: %s\n", src, cli_errstr(cli));
return 1;
}
@@ -3243,7 +3290,9 @@ static int cmd_getfacl(void)
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("stat %s: %s\n", src, cli_errstr(cli));
return 1;
}
@@ -3412,8 +3461,9 @@ static int cmd_geteas(void)
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
- &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("stat %s: %s\n", src, cli_errstr(cli));
return 1;
}
@@ -3468,8 +3518,9 @@ static int cmd_setea(void)
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
- &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("stat %s: %s\n", src, cli_errstr(cli));
return 1;
}
@@ -3499,6 +3550,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");
@@ -3512,7 +3564,9 @@ static int cmd_stat(void)
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("stat %s: %s\n", src, cli_errstr(cli));
return 1;
}
@@ -3598,6 +3652,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) ||
@@ -3616,7 +3671,9 @@ static int cmd_chown(void)
if (!src) {
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname) ) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("chown %s: %s\n", src, cli_errstr(cli));
return 1;
}
@@ -3647,6 +3704,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)) {
@@ -3670,12 +3728,16 @@ static int cmd_rename(void)
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetsrc)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetsrc);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("rename %s: %s\n", src, cli_errstr(cli));
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, dest, &targetcli, &targetdest)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, dest, &targetcli,
+ &targetdest);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("rename %s: %s\n", dest, cli_errstr(cli));
return 1;
}
@@ -3725,6 +3787,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)) {
@@ -3748,7 +3811,9 @@ static int cmd_hardlink(void)
return 1;
}
- if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
+ status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli,
+ &targetname);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("hardlink %s: %s\n", src, cli_errstr(cli));
return 1;
}
@@ -4220,9 +4285,12 @@ 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 ) ) {
+ 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, cli_errstr(cli));
return 1;
}
@@ -4649,7 +4717,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,
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index bb08b22c8d..9c0f1f433f 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -745,13 +745,13 @@ NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
/********************************************************************
********************************************************************/
-bool cli_resolve_path(TALLOC_CTX *ctx,
- const char *mountpt,
- const struct user_auth_info *dfs_auth_info,
- struct cli_state *rootcli,
- const char *path,
- struct cli_state **targetcli,
- char **pp_targetpath)
+NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
+ const char *mountpt,
+ const struct user_auth_info *dfs_auth_info,
+ struct cli_state *rootcli,
+ const char *path,
+ struct cli_state **targetcli,
+ char **pp_targetpath)
{
struct client_dfs_referral *refs = NULL;
size_t num_refs = 0;
@@ -772,7 +772,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
NTSTATUS status;
if ( !rootcli || !path || !targetcli ) {
- return false;
+ return NT_STATUS_INVALID_PARAMETER;
}
/* Don't do anything if this is not a DFS root. */
@@ -781,9 +781,9 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
*targetcli = rootcli;
*pp_targetpath = talloc_strdup(ctx, path);
if (!*pp_targetpath) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
- return true;
+ return NT_STATUS_OK;
}
*targetcli = NULL;
@@ -792,12 +792,12 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
cleanpath = clean_path(ctx, path);
if (!cleanpath) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
dfs_path = cli_dfs_make_full_path(ctx, rootcli, cleanpath);
if (!dfs_path) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
status = cli_qpathinfo_basic( rootcli, dfs_path, &sbuf, &attributes);
@@ -806,7 +806,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
*targetcli = rootcli;
*pp_targetpath = talloc_strdup(ctx, path);
if (!*pp_targetpath) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
goto done;
}
@@ -818,7 +818,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
*targetcli = rootcli;
*pp_targetpath = talloc_strdup(ctx, path);
if (!*pp_targetpath) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
goto done;
}
@@ -827,7 +827,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
if (!cli_dfs_check_error(rootcli, NT_STATUS_PATH_NOT_COVERED,
status)) {
- return false;
+ return status;
}
/* Check for the referral. */
@@ -844,36 +844,36 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
0x20,
&cli_ipc);
if (!NT_STATUS_IS_OK(status)) {
- return false;
+ return status;
}
status = cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs,
&num_refs, &consumed);
if (!NT_STATUS_IS_OK(status) || !num_refs) {
- return false;
+ return status;
}
/* Just store the first referral for now. */
if (!refs[0].dfspath) {
- return false;
+ return NT_STATUS_NOT_FOUND;
}
if (!split_dfs_path(ctx, refs[0].dfspath, &server, &share,
&extrapath)) {
- return false;
+ return NT_STATUS_NOT_FOUND;
}
/* Make sure to recreate the original string including any wildcards. */
dfs_path = cli_dfs_make_full_path(ctx, rootcli, path);
if (!dfs_path) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
pathlen = strlen(dfs_path);
consumed = MIN(pathlen, consumed);
*pp_targetpath = talloc_strdup(ctx, &dfs_path[consumed]);
if (!*pp_targetpath) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
dfs_path[consumed] = '\0';
@@ -897,7 +897,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
if (!NT_STATUS_IS_OK(status)) {
d_printf("Unable to follow dfs referral [\\%s\\%s]\n",
server, share );
- return false;
+ return status;
}
if (extrapath && strlen(extrapath) > 0) {
@@ -915,7 +915,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
*pp_targetpath);
}
if (!*pp_targetpath) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
}
@@ -928,26 +928,26 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
d_printf("cli_resolve_path: "
"dfs_path (%s) not in correct format.\n",
dfs_path );
- return false;
+ return NT_STATUS_NOT_FOUND;
}
ppath++; /* Now pointing at start of server name. */
if ((ppath = strchr_m( dfs_path, '\\' )) == NULL) {
- return false;
+ return NT_STATUS_NOT_FOUND;
}
ppath++; /* Now pointing at start of share name. */
if ((ppath = strchr_m( ppath+1, '\\' )) == NULL) {
- return false;
+ return NT_STATUS_NOT_FOUND;
}
ppath++; /* Now pointing at path component. */
newmount = talloc_asprintf(ctx, "%s\\%s", mountpt, ppath );
if (!newmount) {
- return false;
+ return NT_STATUS_NOT_FOUND;
}
cli_set_mntpoint(*targetcli, newmount);
@@ -956,13 +956,14 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
checking for loops here. */
if (!strequal(*pp_targetpath, "\\") && !strequal(*pp_targetpath, "/")) {
- if (cli_resolve_path(ctx,
- newmount,
- dfs_auth_info,
- *targetcli,
- *pp_targetpath,
- &newcli,
- &newpath)) {
+ status = cli_resolve_path(ctx,
+ newmount,
+ dfs_auth_info,
+ *targetcli,
+ *pp_targetpath,
+ &newcli,
+ &newpath);
+ if (NT_STATUS_IS_OK(status)) {
/*
* When cli_resolve_path returns true here it's always
* returning the complete path in newpath, so we're done
@@ -970,7 +971,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
*/
*targetcli = newcli;
*pp_targetpath = newpath;
- return true;
+ return status;
}
}
@@ -980,12 +981,15 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
if ((*targetcli)->dfsroot) {
dfs_path = talloc_strdup(ctx, *pp_targetpath);
if (!dfs_path) {
- return false;
+ return NT_STATUS_NO_MEMORY;
}
*pp_targetpath = cli_dfs_make_full_path(ctx, *targetcli, dfs_path);
+ if (*pp_targetpath == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
}
- return true;
+ return NT_STATUS_OK;
}
/********************************************************************
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index ea75dbf264..b394c3541a 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -807,9 +807,10 @@ SMBC_opendir_ctx(SMBCCTX *context,
return NULL;
}
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(
+ frame, "", context->internal->auth_info,
+ srv->cli, path, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
if (dir) {
SAFE_FREE(dir->fname);
@@ -1161,6 +1162,7 @@ SMBC_mkdir_ctx(SMBCCTX *context,
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@@ -1211,9 +1213,9 @@ SMBC_mkdir_ctx(SMBCCTX *context,
}
/*d_printf(">>>mkdir: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ srv->cli, path, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -1269,6 +1271,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@@ -1319,9 +1322,9 @@ SMBC_rmdir_ctx(SMBCCTX *context,
}
/*d_printf(">>>rmdir: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ srv->cli, path, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -1338,7 +1341,6 @@ SMBC_rmdir_ctx(SMBCCTX *context,
/* Local storage to avoid buffer overflows */
char *lpath;
bool smbc_rmdir_dirempty = true;
- NTSTATUS status;
lpath = talloc_asprintf(frame, "%s\\*",
targetpath);
@@ -1555,6 +1557,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
char *path = NULL;
uint16 mode;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
@@ -1604,9 +1607,9 @@ SMBC_chmod_ctx(SMBCCTX *context,
}
/*d_printf(">>>unlink: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ srv->cli, path, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -1747,6 +1750,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
struct cli_state *targetcli = NULL;
SMBCSRV *srv = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
@@ -1797,9 +1801,9 @@ SMBC_unlink_ctx(SMBCCTX *context,
}
/*d_printf(">>>unlink: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ srv->cli, path, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -1882,6 +1886,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
struct cli_state *targetcli2 = NULL;
SMBCSRV *srv = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!ocontext || !ncontext ||
!ocontext->internal->initialized ||
@@ -1971,10 +1976,9 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
password1);
/*d_printf(">>>rename: resolving %s\n", path1);*/
- if (!cli_resolve_path(frame, "", ocontext->internal->auth_info,
- srv->cli,
- path1,
- &targetcli1, &targetpath1)) {
+ status = cli_resolve_path(frame, "", ocontext->internal->auth_info,
+ srv->cli, path1, &targetcli1, &targetpath1);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path1);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -1989,10 +1993,9 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
/*d_printf(">>>rename: resolved path as %s\n", targetpath1);*/
/*d_printf(">>>rename: resolving %s\n", path2);*/
- if (!cli_resolve_path(frame, "", ncontext->internal->auth_info,
- srv->cli,
- path2,
- &targetcli2, &targetpath2)) {
+ status = cli_resolve_path(frame, "", ncontext->internal->auth_info,
+ srv->cli, path2, &targetcli2, &targetpath2);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path2);
errno = ENOENT;
TALLOC_FREE(frame);
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index c822eab798..4517a36f57 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -111,9 +111,10 @@ SMBC_open_ctx(SMBCCTX *context,
ZERO_STRUCTP(file);
/*d_printf(">>>open: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(
+ frame, "", context->internal->auth_info,
+ srv->cli, path, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
SAFE_FREE(file);
@@ -230,6 +231,7 @@ SMBC_read_ctx(SMBCCTX *context,
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
/*
* offset:
@@ -283,9 +285,10 @@ SMBC_read_ctx(SMBCCTX *context,
}
/*d_printf(">>>read: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- file->srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ file->srv->cli, path,
+ &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -368,9 +371,10 @@ SMBC_write_ctx(SMBCCTX *context,
}
/*d_printf(">>>write: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- file->srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ file->srv->cli, path,
+ &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -406,6 +410,7 @@ SMBC_close_ctx(SMBCCTX *context,
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@@ -442,9 +447,10 @@ SMBC_close_ctx(SMBCCTX *context,
}
/*d_printf(">>>close: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- file->srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ file->srv->cli, path,
+ &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -495,6 +501,7 @@ SMBC_getatr(SMBCCTX * context,
struct cli_state *targetcli = NULL;
time_t write_time;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@@ -522,9 +529,10 @@ SMBC_getatr(SMBCCTX * context,
}
DEBUG(4,("SMBC_getatr: sending qpathinfo\n"));
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- srv->cli, fixedpath,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ srv->cli, fixedpath,
+ &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Couldn't resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -677,6 +685,7 @@ SMBC_lseek_ctx(SMBCCTX *context,
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@@ -721,9 +730,10 @@ SMBC_lseek_ctx(SMBCCTX *context,
}
/*d_printf(">>>lseek: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- file->srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(
+ frame, "", context->internal->auth_info,
+ file->srv->cli, path, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
@@ -774,6 +784,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@@ -810,9 +821,10 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
}
/*d_printf(">>>fstat: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- file->srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ file->srv->cli, path,
+ &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c
index b579a5f5c1..c40db4a8d9 100644
--- a/source3/libsmb/libsmb_stat.c
+++ b/source3/libsmb/libsmb_stat.c
@@ -215,6 +215,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
struct cli_state *targetcli = NULL;
SMB_INO_T ino = 0;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@@ -250,9 +251,10 @@ SMBC_fstat_ctx(SMBCCTX *context,
}
/*d_printf(">>>fstat: resolving %s\n", path);*/
- if (!cli_resolve_path(frame, "", context->internal->auth_info,
- file->srv->cli, path,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(frame, "", context->internal->auth_info,
+ file->srv->cli, path,
+ &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Could not resolve %s\n", path);
errno = ENOENT;
TALLOC_FREE(frame);
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index 7695dfb99e..00f94122bc 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -889,9 +889,10 @@ cacl_get(SMBCCTX *context,
/* Point to the portion after "system.nt_sec_desc." */
name += 19; /* if (all) this will be invalid but unused */
- if (!cli_resolve_path(ctx, "", context->internal->auth_info,
- cli, filename,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(
+ ctx, "", context->internal->auth_info,
+ cli, filename, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("cacl_get Could not resolve %s\n",
filename));
errno = ENOENT;
@@ -1548,9 +1549,9 @@ cacl_set(SMBCCTX *context,
return -1;
}
- if (!cli_resolve_path(ctx, "", context->internal->auth_info,
- cli, filename,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(ctx, "", context->internal->auth_info,
+ cli, filename, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(5,("cacl_set: Could not resolve %s\n", filename));
errno = ENOENT;
return -1;
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 1caf0f904a..89f5857091 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -132,13 +132,13 @@ NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
struct client_dfs_referral **refs,
size_t *num_refs,
size_t *consumed);
-bool cli_resolve_path(TALLOC_CTX *ctx,
- const char *mountpt,
- const struct user_auth_info *dfs_auth_info,
- struct cli_state *rootcli,
- const char *path,
- struct cli_state **targetcli,
- char **pp_targetpath);
+NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
+ const char *mountpt,
+ const struct user_auth_info *dfs_auth_info,
+ struct cli_state *rootcli,
+ const char *path,
+ struct cli_state **targetcli,
+ char **pp_targetpath);
bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
struct cli_state *cli,
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 2ecf1aaa5a..5c21b63741 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -3827,8 +3827,10 @@ static NTSTATUS sync_files(struct copy_clistate *cp_clistate, const char *mask)
DEBUG(3,("calling cli_list with mask: %s\n", mask));
- if ( !cli_resolve_path(talloc_tos(), "", NULL, cp_clistate->cli_share_src,
- mask, &targetcli, &targetpath ) ) {
+ status = cli_resolve_path(talloc_tos(), "", NULL,
+ cp_clistate->cli_share_src,
+ mask, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, _("cli_resolve_path %s failed with error: "
"%s\n"),
mask, cli_errstr(cp_clistate->cli_share_src));