diff options
author | Volker Lendecke <vl@samba.org> | 2011-07-03 20:53:55 +0200 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2011-07-06 08:35:27 +0200 |
commit | 26782fbbf3a7885746aa17be259607dd2d418347 (patch) | |
tree | c2bccfc28bf124b7b983f167fa156a590a448eb0 /source3/libsmb | |
parent | c019302e65051f214c5ea2ef908aa0ef79c8b12e (diff) | |
download | samba-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/libsmb')
-rw-r--r-- | source3/libsmb/clidfs.c | 78 | ||||
-rw-r--r-- | source3/libsmb/libsmb_dir.c | 51 | ||||
-rw-r--r-- | source3/libsmb/libsmb_file.c | 54 | ||||
-rw-r--r-- | source3/libsmb/libsmb_stat.c | 8 | ||||
-rw-r--r-- | source3/libsmb/libsmb_xattr.c | 13 | ||||
-rw-r--r-- | source3/libsmb/proto.h | 14 |
6 files changed, 120 insertions, 98 deletions
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, |