mirror of
https://github.com/samba-team/samba.git
synced 2025-01-24 02:04:21 +03:00
smbd: Introduce get_real_filename_full_scan_at()
Make get_real_filename_full_scan() a wrapper. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
973212e8c1
commit
dcdc258509
@ -1541,26 +1541,20 @@ static bool sname_equal(const char *name1, const char *name2,
|
|||||||
If the name looks like a mangled name then try via the mangling functions
|
If the name looks like a mangled name then try via the mangling functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
NTSTATUS get_real_filename_full_scan(connection_struct *conn,
|
NTSTATUS get_real_filename_full_scan_at(struct files_struct *dirfsp,
|
||||||
const char *path,
|
const char *name,
|
||||||
const char *name,
|
bool mangled,
|
||||||
bool mangled,
|
TALLOC_CTX *mem_ctx,
|
||||||
TALLOC_CTX *mem_ctx,
|
char **found_name)
|
||||||
char **found_name)
|
|
||||||
{
|
{
|
||||||
|
struct connection_struct *conn = dirfsp->conn;
|
||||||
struct smb_Dir *cur_dir = NULL;
|
struct smb_Dir *cur_dir = NULL;
|
||||||
const char *dname = NULL;
|
const char *dname = NULL;
|
||||||
char *talloced = NULL;
|
char *talloced = NULL;
|
||||||
char *unmangled_name = NULL;
|
char *unmangled_name = NULL;
|
||||||
long curpos;
|
long curpos;
|
||||||
struct smb_filename *smb_fname = NULL;
|
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
/* handle null paths */
|
|
||||||
if ((path == NULL) || (*path == 0)) {
|
|
||||||
path = ".";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we have a case-sensitive filesystem, it doesn't do us any
|
/* If we have a case-sensitive filesystem, it doesn't do us any
|
||||||
* good to search for a name. If a case variation of the name was
|
* good to search for a name. If a case variation of the name was
|
||||||
* there, then the original stat(2) would have found it.
|
* there, then the original stat(2) would have found it.
|
||||||
@ -1594,31 +1588,16 @@ NTSTATUS get_real_filename_full_scan(connection_struct *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
smb_fname = synthetic_smb_fname(talloc_tos(),
|
|
||||||
path,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
if (smb_fname == NULL) {
|
|
||||||
TALLOC_FREE(unmangled_name);
|
|
||||||
return NT_STATUS_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open the directory */
|
/* open the directory */
|
||||||
status = OpenDir(
|
status = OpenDir_from_pathref(talloc_tos(), dirfsp, NULL, 0, &cur_dir);
|
||||||
talloc_tos(), conn, smb_fname, NULL, 0, &cur_dir);
|
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DBG_NOTICE("scan dir didn't open dir [%s]: %s\n",
|
DBG_NOTICE("scan dir didn't open dir [%s]: %s\n",
|
||||||
path,
|
fsp_str_dbg(dirfsp),
|
||||||
nt_errstr(status));
|
nt_errstr(status));
|
||||||
TALLOC_FREE(unmangled_name);
|
TALLOC_FREE(unmangled_name);
|
||||||
TALLOC_FREE(smb_fname);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
TALLOC_FREE(smb_fname);
|
|
||||||
|
|
||||||
/* now scan for matching names */
|
/* now scan for matching names */
|
||||||
curpos = 0;
|
curpos = 0;
|
||||||
while ((dname = ReadDirName(cur_dir, &curpos, NULL, &talloced))) {
|
while ((dname = ReadDirName(cur_dir, &curpos, NULL, &talloced))) {
|
||||||
@ -1661,6 +1640,41 @@ NTSTATUS get_real_filename_full_scan(connection_struct *conn,
|
|||||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS get_real_filename_full_scan(connection_struct *conn,
|
||||||
|
const char *path,
|
||||||
|
const char *name,
|
||||||
|
bool mangled,
|
||||||
|
TALLOC_CTX *mem_ctx,
|
||||||
|
char **found_name)
|
||||||
|
{
|
||||||
|
struct smb_filename *smb_dname = NULL;
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
/* handle null paths */
|
||||||
|
if ((path == NULL) || (*path == 0)) {
|
||||||
|
path = ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
status = synthetic_pathref(
|
||||||
|
talloc_tos(),
|
||||||
|
conn->cwd_fsp,
|
||||||
|
path,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
&smb_dname);
|
||||||
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = get_real_filename_full_scan_at(
|
||||||
|
smb_dname->fsp, name, mangled, mem_ctx, found_name);
|
||||||
|
|
||||||
|
TALLOC_FREE(smb_dname);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Wrapper around the vfs get_real_filename and the full directory scan
|
Wrapper around the vfs get_real_filename and the full directory scan
|
||||||
fallback.
|
fallback.
|
||||||
|
@ -365,6 +365,11 @@ NTSTATUS get_real_filename_full_scan(connection_struct *conn,
|
|||||||
bool mangled,
|
bool mangled,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
char **found_name);
|
char **found_name);
|
||||||
|
NTSTATUS get_real_filename_full_scan_at(struct files_struct *dirfsp,
|
||||||
|
const char *name,
|
||||||
|
bool mangled,
|
||||||
|
TALLOC_CTX *mem_ctx,
|
||||||
|
char **found_name);
|
||||||
char *get_original_lcomp(TALLOC_CTX *ctx,
|
char *get_original_lcomp(TALLOC_CTX *ctx,
|
||||||
connection_struct *conn,
|
connection_struct *conn,
|
||||||
const char *filename_in,
|
const char *filename_in,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user