This also eliminates the need for resolve_dfspath().
connection_struct *conn,
bool dfs_path,
const char *name_in,
+ uint32_t ucf_flags,
+ bool *ppath_contains_wcard,
struct smb_filename **pp_smb_fname);
/* The following definitions come from smbd/filename_utils.c */
conn,
false,
r->in.file,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(nt_status)) {
werr = ntstatus_to_werror(nt_status);
conn,
false,
r->in.file,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(nt_status)) {
werr = ntstatus_to_werror(nt_status);
return status;
}
-/****************************************************************************
- Go through all the steps to validate a filename.
-****************************************************************************/
-
+/**
+ * Go through all the steps to validate a filename.
+ *
+ * @param ctx talloc_ctx to allocate memory with.
+ * @param conn connection struct for vfs calls.
+ * @param dfs_path Whether this path requires dfs resolution.
+ * @param name_in The unconverted name.
+ * @param ucf_flags flags to pass through to unix_convert().
+ * UCF_ALLOW_WCARD_LCOMP will be stripped out if
+ * p_cont_wcard == NULL or is false.
+ * @param p_cont_wcard If not NULL, will be set to true if the dfs path
+ * resolution detects a wildcard.
+ * @param pp_smb_fname The final converted name will be allocated if the
+ * return is NT_STATUS_OK.
+ *
+ * @return NT_STATUS_OK if all operations completed succesfully, appropriate
+ * error otherwise.
+ */
NTSTATUS filename_convert(TALLOC_CTX *ctx,
connection_struct *conn,
bool dfs_path,
const char *name_in,
+ uint32_t ucf_flags,
+ bool *ppath_contains_wcard,
struct smb_filename **pp_smb_fname)
{
NTSTATUS status;
*pp_smb_fname = NULL;
- status = resolve_dfspath(ctx, conn,
+ status = resolve_dfspath_wcard(ctx, conn,
dfs_path,
name_in,
- &fname);
+ &fname,
+ ppath_contains_wcard);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("filename_convert: resolve_dfspath failed "
"for name %s with %s\n",
nt_errstr(status) ));
return status;
}
- status = unix_convert(ctx, conn, fname, pp_smb_fname, 0);
+
+ /*
+ * Strip out the UCF_ALLOW_WCARD_LCOMP if the path doesn't contain a
+ * wildcard.
+ */
+ if (ppath_contains_wcard != NULL && !*ppath_contains_wcard &&
+ ucf_flags & UCF_ALLOW_WCARD_LCOMP) {
+ ucf_flags &= ~UCF_ALLOW_WCARD_LCOMP;
+ }
+
+ status = unix_convert(ctx, conn, fname, pp_smb_fname, ucf_flags);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("filename_convert: unix_convert failed "
"for name %s with %s\n",
}
/******************************************************************************
- Core function to resolve a dfs pathname.
-******************************************************************************/
-
-NTSTATUS resolve_dfspath(TALLOC_CTX *ctx,
- connection_struct *conn,
- bool dfs_pathnames,
- const char *name_in,
- char **pp_name_out)
-{
- NTSTATUS status = NT_STATUS_OK;
- bool dummy;
- if (dfs_pathnames) {
- status = dfs_redirect(ctx,
- conn,
- name_in,
- False,
- pp_name_out,
- &dummy);
- } else {
- /*
- * Cheat and just return a copy of the in ptr.
- * Once srvstr_get_path() uses talloc it'll
- * be a talloced ptr anyway.
- */
- *pp_name_out = CONST_DISCARD(char *,name_in);
- }
- return status;
-}
-
-/******************************************************************************
- Core function to resolve a dfs pathname possibly containing a wildcard.
- This function is identical to the above except for the bool param to
- dfs_redirect but I need this to be separate so it's really clear when
- we're allowing wildcards and when we're not. JRA.
+ Core function to resolve a dfs pathname possibly containing a wildcard. If
+ ppath_contains_wcard != NULL, it will be set to true if a wildcard is
+ detected during dfs resolution.
******************************************************************************/
NTSTATUS resolve_dfspath_wcard(TALLOC_CTX *ctx,
char **pp_name_out,
bool *ppath_contains_wcard)
{
+ bool path_contains_wcard;
NTSTATUS status = NT_STATUS_OK;
+
if (dfs_pathnames) {
status = dfs_redirect(ctx,
conn,
name_in,
True,
pp_name_out,
- ppath_contains_wcard);
+ &path_contains_wcard);
+
+ if (NT_STATUS_IS_OK(status) && ppath_contains_wcard != NULL) {
+ *ppath_contains_wcard = path_contains_wcard;
+ }
} else {
/*
* Cheat and just return a copy of the in ptr.
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
status = filename_convert(ctx, conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
oldname,
+ 0,
+ NULL,
&smb_fname_old);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,
status = filename_convert(ctx, conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
newname,
+ 0,
+ NULL,
&smb_fname_new);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
name,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
status = filename_convert(ctx, conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
status = filename_convert(ctx, conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
directory,
+ 0,
+ NULL,
&smb_dname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
status = filename_convert(ctx, conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
directory,
+ 0,
+ NULL,
&smb_dname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
smbreq->conn,
smbreq->flags2 & FLAGS2_DFS_PATHNAMES,
in_name,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
oldname,
+ 0,
+ NULL,
&smb_fname_old);
if (!NT_STATUS_IS_OK(status)) {
return status;
status = filename_convert(req, conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
fname,
+ 0,
+ NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
directory,
+ 0,
+ NULL,
&smb_dname);
if (!NT_STATUS_IS_OK(status)) {