[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Fri Mar 27 02:42:02 UTC 2020
The branch, master has been updated
via fe78216b1cf smbd: use a helper variable in filename_convert_internal()
via 41fbfc279b9 smbd: use filename_convert() in smb_file_rename_information()
via cd8c229d24f smbd: modernize DEBUG in unix_convert()
via 855a354686e smbd: turn (*orig_path != '/') assert into a normal if check
via c77530a04f0 smbd: consolidate comments in unix_convert()
via 63cbc330ea5 smbd: modernize unix_convert() replacing True with true
via 81857450844 smbd: modernize unix_convert() replacing False with false
via c4897903bed smbd: initialize end to NULL in unix_convert()
via 9565c8f99a9 smbd: leave start at NULL, it's not used before being set to smbfname->basename
from f71364bc2d6 tdbtorture: Use ARRAY_DEL_ELEMENT()
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit fe78216b1cf433b6d42ace758948ab20a7dfcb8a
Author: Ralph Boehme <slow at samba.org>
Date: Thu Mar 26 15:08:53 2020 +0100
smbd: use a helper variable in filename_convert_internal()
Avoids the complicated pointer-to-pointer dereferencing.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Fri Mar 27 02:41:39 UTC 2020 on sn-devel-184
commit 41fbfc279b9d0f784115e01ddaa231943df46329
Author: Ralph Boehme <slow at samba.org>
Date: Thu Mar 26 14:49:33 2020 +0100
smbd: use filename_convert() in smb_file_rename_information()
Replaces direct calls to resolve_dfspath_wcard() and filename_convert(). On the
way to consolidate all callers of pathname processing onto filename_convert().
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit cd8c229d24faa61ccfc246cc6ac7349ce3f539db
Author: Ralph Boehme <slow at samba.org>
Date: Wed Mar 25 19:00:32 2020 +0100
smbd: modernize DEBUG in unix_convert()
I'm also consolidating on level 10 instead of 5 for "debug" level messages, as
that what's tend to be the canonical debug level these days.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 855a354686e2c27015fd8f49d8733c7835bea729
Author: Ralph Boehme <slow at samba.org>
Date: Wed Mar 25 07:56:37 2020 +0100
smbd: turn (*orig_path != '/') assert into a normal if check
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit c77530a04f060844c672f54af847d165e4314b0e
Author: Ralph Boehme <slow at samba.org>
Date: Wed Mar 25 07:53:29 2020 +0100
smbd: consolidate comments in unix_convert()
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 63cbc330ea5ff3f1d14c7aa1c20bf6180f437e36
Author: Ralph Boehme <slow at samba.org>
Date: Wed Mar 25 07:48:16 2020 +0100
smbd: modernize unix_convert() replacing True with true
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 818574508449eb115ffd105e67bfd5b36331fe25
Author: Ralph Boehme <slow at samba.org>
Date: Wed Mar 25 07:47:22 2020 +0100
smbd: modernize unix_convert() replacing False with false
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit c4897903bedc9c9bdbc7e89ce67a3422a5ae50aa
Author: Ralph Boehme <slow at samba.org>
Date: Wed Mar 25 07:46:22 2020 +0100
smbd: initialize end to NULL in unix_convert()
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 9565c8f99a9db5c033ca7b15f27607dbad12fb21
Author: Ralph Boehme <slow at samba.org>
Date: Wed Mar 25 07:45:43 2020 +0100
smbd: leave start at NULL, it's not used before being set to smbfname->basename
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/smbd/filename.c | 138 ++++++++++++++++++++++++------------------------
source3/smbd/trans2.c | 21 +++-----
2 files changed, 76 insertions(+), 83 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 32e5835e676..d1dc1aef4f2 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -407,6 +407,11 @@ streams etc.
We assume that we have already done a chdir() to the right "root" directory
for this service.
+Conversion to basic unix format is already done in check_path_syntax().
+
+Names must be relative to the root of the service - any leading /. and
+trailing /'s should have been trimmed by check_path_syntax().
+
The function will return an NTSTATUS error if some part of the name except for
the last part cannot be resolved, else NT_STATUS_OK.
@@ -437,19 +442,12 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
uint32_t ucf_flags)
{
struct smb_filename *smb_fname = NULL;
-
- /*
- * This looks strange. But we need "start" initialized to "" here but
- * it can't be a const char *, so 'char *start = "";' does not work.
- */
- char cnull = '\0';
- char *start = &cnull;
-
- char *end;
+ char *start = NULL;
+ char *end = NULL;
char *dirpath = NULL;
char *stream = NULL;
- bool component_was_mangled = False;
- bool name_has_wildcard = False;
+ bool component_was_mangled = false;
+ bool name_has_wildcard = false;
bool posix_pathnames = (ucf_flags & UCF_POSIX_PATHNAMES);
bool allow_wcard_last_component =
(ucf_flags & UCF_ALWAYS_ALLOW_WCARD_LCOMP);
@@ -478,21 +476,12 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
smb_fname->flags = posix_pathnames ? SMB_FILENAME_POSIX_PATH : 0;
- DEBUG(5, ("unix_convert called on file \"%s\"\n", orig_path));
+ DBG_DEBUG("Called on file [%s]\n", orig_path);
- /*
- * Conversion to basic unix format is already done in
- * check_path_syntax().
- */
-
- /*
- * Names must be relative to the root of the service - any leading /.
- * and trailing /'s should have been trimmed by check_path_syntax().
- */
-
-#ifdef DEVELOPER
- SMB_ASSERT(*orig_path != '/');
-#endif
+ if (orig_path[0] == '/') {
+ DBG_ERR("Path [%s] starts with '/'\n", orig_path);
+ return NT_STATUS_OBJECT_NAME_INVALID;
+ }
/*
* If we trimmed down to a single '\0' character
@@ -511,8 +500,8 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
status = map_nt_error_from_unix(errno);
goto err;
}
- DEBUG(5, ("conversion finished \"\" -> %s\n",
- smb_fname->base_name));
+ DBG_DEBUG("conversion finished [] -> [%s]\n",
+ smb_fname->base_name);
goto done;
}
@@ -531,7 +520,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
/* Start with the full orig_path as given by the caller. */
if (!(smb_fname->base_name = talloc_strdup(smb_fname, orig_path))) {
- DEBUG(0, ("talloc_strdup failed\n"));
+ DBG_ERR("talloc_strdup failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -556,7 +545,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
if (conn->case_sensitive && !conn->case_preserve &&
!conn->short_case_preserve) {
if (!strnorm(smb_fname->base_name, lp_default_case(SNUM(conn)))) {
- DEBUG(0, ("strnorm %s failed\n", smb_fname->base_name));
+ DBG_ERR("strnorm [%s] failed\n", smb_fname->base_name);
status = NT_STATUS_INVALID_PARAMETER;
goto err;
}
@@ -624,9 +613,9 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
status = NT_STATUS_NO_MEMORY;
goto err;
}
- DEBUG(5, ("conversion finished %s -> %s\n",
- orig_path,
- smb_fname->base_name));
+ DBG_INFO("conversion finished [%s] -> [%s]\n",
+ orig_path,
+ smb_fname->base_name);
goto done;
}
}
@@ -657,7 +646,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
*/
if ((dirpath == NULL) && (!(dirpath = talloc_strdup(ctx,".")))) {
- DEBUG(0, ("talloc_strdup failed\n"));
+ DBG_ERR("talloc_strdup failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -678,8 +667,8 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
}
}
- DEBUG(5,("unix_convert begin: name = %s, dirpath = %s, start = %s\n",
- smb_fname->base_name, dirpath, start));
+ DBG_DEBUG("Begin: name [%s] dirpath [%s] start [%s]\n",
+ smb_fname->base_name, dirpath, start);
if (!name_has_wildcard) {
/*
@@ -701,8 +690,9 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
/* Add the path (not including the stream) to the cache. */
stat_cache_add(orig_path, smb_fname->base_name,
conn->case_sensitive);
- DEBUG(5,("conversion of base_name finished %s -> %s\n",
- orig_path, smb_fname->base_name));
+ DBG_DEBUG("Conversion of base_name finished "
+ "[%s] -> [%s]\n",
+ orig_path, smb_fname->base_name);
goto done;
}
@@ -815,7 +805,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
*/
if (mangle_is_mangled(start, conn->params)) {
- component_was_mangled = True;
+ component_was_mangled = true;
}
/*
@@ -847,7 +837,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
smb_fname->original_lcomp = talloc_strdup(smb_fname,
end ? end + 1 : start);
if (!smb_fname->original_lcomp) {
- DEBUG(0, ("talloc failed\n"));
+ DBG_ERR("talloc failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -882,7 +872,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
/* Skip the stat call if it's a wildcard end. */
if (name_has_wildcard) {
- DEBUG(5,("Wildcard %s\n",start));
+ DBG_DEBUG("Wildcard [%s]\n", start);
goto done;
}
@@ -906,7 +896,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
* An intermediate part of the name isn't
* a directory.
*/
- DEBUG(5,("Not a dir %s\n",start));
+ DBG_DEBUG("Not a dir [%s]\n", start);
*end = '/';
/*
* We need to return the fact that the
@@ -990,8 +980,8 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
* An intermediate part of the name
* can't be found.
*/
- DEBUG(5,("Intermediate not found %s\n",
- start));
+ DBG_DEBUG("Intermediate [%s] missing\n",
+ start);
*end = '/';
/*
@@ -1073,13 +1063,13 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
* Thomas Neumann <t.neumann at iku-ag.de>.
*/
if (!conn->case_preserve ||
- (mangle_is_8_3(start, False,
+ (mangle_is_8_3(start, false,
conn->params) &&
!conn->short_case_preserve)) {
if (!strnorm(start,
lp_default_case(SNUM(conn)))) {
- DEBUG(0, ("strnorm %s failed\n",
- start));
+ DBG_DEBUG("strnorm %s failed\n",
+ start);
status = NT_STATUS_INVALID_PARAMETER;
goto err;
}
@@ -1109,7 +1099,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
tmp = unmangled;
}
if (tmp == NULL) {
- DEBUG(0, ("talloc failed\n"));
+ DBG_ERR("talloc failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -1120,7 +1110,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
end = start + strlen(start);
}
- DEBUG(5,("New file %s\n",start));
+ DBG_DEBUG("New file [%s]\n", start);
goto done;
}
@@ -1145,7 +1135,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
end+1);
}
if (tmp == NULL) {
- DEBUG(0, ("talloc_asprintf failed\n"));
+ DBG_ERR("talloc_asprintf failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -1168,7 +1158,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
found_name);
}
if (tmp == NULL) {
- DEBUG(0, ("talloc failed\n"));
+ DBG_ERR("talloc failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -1204,7 +1194,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
char *tmp = talloc_asprintf(ctx,
"%s/%s", dirpath, start);
if (!tmp) {
- DEBUG(0, ("talloc_asprintf failed\n"));
+ DBG_ERR("talloc_asprintf failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -1214,7 +1204,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
else {
TALLOC_FREE(dirpath);
if (!(dirpath = talloc_strdup(ctx,start))) {
- DEBUG(0, ("talloc_strdup failed\n"));
+ DBG_ERR("talloc_strdup failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -1251,8 +1241,8 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
* The name has been resolved.
*/
- DEBUG(5,("conversion finished %s -> %s\n", orig_path,
- smb_fname->base_name));
+ DBG_DEBUG("Conversion finished [%s] -> [%s]\n",
+ orig_path, smb_fname->base_name);
done:
/* Add back the stream if one was stripped off originally. */
@@ -1269,7 +1259,8 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
*smb_fname_out = smb_fname;
return NT_STATUS_OK;
fail:
- DEBUG(10, ("dirpath = [%s] start = [%s]\n", dirpath, start));
+ DBG_DEBUG("Conversion failed: dirpath [%s] start [%s]\n",
+ dirpath, start);
if (dirpath && !ISDOT(dirpath)) {
smb_fname->base_name = talloc_asprintf(smb_fname, "%s/%s",
dirpath, start);
@@ -1277,7 +1268,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
smb_fname->base_name = talloc_strdup(smb_fname, start);
}
if (!smb_fname->base_name) {
- DEBUG(0, ("talloc_asprintf failed\n"));
+ DBG_ERR("talloc_asprintf failed\n");
status = NT_STATUS_NO_MEMORY;
goto err;
}
@@ -1704,13 +1695,14 @@ static NTSTATUS filename_convert_internal(TALLOC_CTX *ctx,
uint32_t ucf_flags,
time_t *twrp,
bool *ppath_contains_wcard,
- struct smb_filename **pp_smb_fname)
+ struct smb_filename **_smb_fname)
{
+ struct smb_filename *smb_fname = NULL;
const char *name = NULL;
char *twrp_name = NULL;
NTSTATUS status;
- *pp_smb_fname = NULL;
+ *_smb_fname = NULL;
if (ucf_flags & UCF_DFS_PATHNAME) {
bool path_contains_wcard = false;
@@ -1736,13 +1728,14 @@ static NTSTATUS filename_convert_internal(TALLOC_CTX *ctx,
}
if (is_fake_file_path(name_in)) {
- *pp_smb_fname = synthetic_smb_fname_split(ctx,
+ smb_fname = synthetic_smb_fname_split(ctx,
name_in,
(ucf_flags & UCF_POSIX_PATHNAMES));
- if (*pp_smb_fname == NULL) {
+ if (smb_fname == NULL) {
return NT_STATUS_NO_MEMORY;
}
- (*pp_smb_fname)->st = (SMB_STRUCT_STAT) { .st_ex_nlink = 1 };
+ smb_fname->st = (SMB_STRUCT_STAT) { .st_ex_nlink = 1 };
+ *_smb_fname = smb_fname;
return NT_STATUS_OK;
}
@@ -1776,7 +1769,7 @@ static NTSTATUS filename_convert_internal(TALLOC_CTX *ctx,
name = twrp_name;
}
- status = unix_convert(ctx, conn, name, pp_smb_fname, ucf_flags);
+ status = unix_convert(ctx, conn, name, &smb_fname, ucf_flags);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("filename_convert_internal: unix_convert failed "
"for name %s with %s\n",
@@ -1788,26 +1781,33 @@ static NTSTATUS filename_convert_internal(TALLOC_CTX *ctx,
TALLOC_FREE(twrp_name);
if ((ucf_flags & UCF_UNIX_NAME_LOOKUP) &&
- VALID_STAT((*pp_smb_fname)->st) &&
- S_ISLNK((*pp_smb_fname)->st.st_ex_mode)) {
- return check_veto_path(conn, (*pp_smb_fname));
+ VALID_STAT(smb_fname->st) &&
+ S_ISLNK(smb_fname->st.st_ex_mode)) {
+ status = check_veto_path(conn, smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(smb_fname);
+ return status;
+ }
+ *_smb_fname = smb_fname;
+ return NT_STATUS_OK;
}
if (!smbreq) {
- status = check_name(conn, (*pp_smb_fname));
+ status = check_name(conn, smb_fname);
} else {
status = check_name_with_privilege(conn, smbreq,
- (*pp_smb_fname));
+ smb_fname);
}
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3,("filename_convert_internal: check_name failed "
"for name %s with %s\n",
- smb_fname_str_dbg(*pp_smb_fname),
+ smb_fname_str_dbg(smb_fname),
nt_errstr(status) ));
- TALLOC_FREE(*pp_smb_fname);
+ TALLOC_FREE(smb_fname);
return status;
}
+ *_smb_fname = smb_fname;
return status;
}
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 5b7333773bb..73510d8ae46 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -7326,18 +7326,6 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
DEBUG(10,("smb_file_rename_information: got name |%s|\n",
newname));
- if (req->flags2 & FLAGS2_DFS_PATHNAMES) {
- status = resolve_dfspath_wcard(ctx, conn,
- newname,
- UCF_COND_ALLOW_WCARD_LCOMP,
- !conn->sconn->using_smb2,
- &newname,
- &dest_has_wcard);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
- }
-
/* Check the new name has no '/' characters. */
if (strchr_m(newname, '/')) {
return NT_STATUS_NOT_SUPPORTED;
@@ -7415,8 +7403,13 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
return NT_STATUS_NO_MEMORY;
}
- status = unix_convert(ctx, conn, base_name, &smb_fname_dst,
- ucf_flags);
+ status = filename_convert(ctx,
+ conn,
+ base_name,
+ ucf_flags,
+ NULL,
+ NULL,
+ &smb_fname_dst);
/* If an error we expect this to be
* NT_STATUS_OBJECT_PATH_NOT_FOUND */
--
Samba Shared Repository
More information about the samba-cvs
mailing list