return orig_lcomp;
}
-/**
- * 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 smbreq SMB request if we're using privileges.
- * @param name_in The unconverted name.
- * @param ucf_flags flags to pass through to unix_convert().
- * @param twrp Optional VSS time
- * @param p_cont_wcard If not NULL, will be set to true if the dfs path
- * resolution detects a wildcard.
- * @param _smb_fname The final converted name will be allocated if the
- * return is NT_STATUS_OK.
- *
- * @return NT_STATUS_OK if all operations completed successfully, appropriate
- * error otherwise.
- */
-NTSTATUS filename_convert(TALLOC_CTX *ctx,
- connection_struct *conn,
- const char *name_in,
- uint32_t ucf_flags,
- NTTIME twrp,
- struct smb_filename **_smb_fname)
-{
- struct smb_filename *smb_fname = NULL;
- NTSTATUS status;
-
- *_smb_fname = NULL;
-
- if (ucf_flags & UCF_DFS_PATHNAME) {
- char *fname = NULL;
- NTTIME dfs_twrp = 0;
- status = dfs_redirect(ctx, conn,
- name_in,
- ucf_flags,
- !conn->sconn->using_smb2,
- &dfs_twrp,
- &fname);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_DEBUG("dfs_redirect "
- "failed for name %s with %s\n",
- name_in,
- nt_errstr(status));
- return status;
- }
- name_in = fname;
- ucf_flags &= ~UCF_DFS_PATHNAME;
- if (twrp == 0 && dfs_twrp != 0) {
- twrp = dfs_twrp;
- }
- }
-
- if (is_fake_file_path(name_in)) {
- smb_fname = synthetic_smb_fname_split(ctx,
- name_in,
- (ucf_flags & UCF_POSIX_PATHNAMES));
- if (smb_fname == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- smb_fname->st = (SMB_STRUCT_STAT) { .st_ex_nlink = 1 };
- smb_fname->st.st_ex_btime = (struct timespec){0, SAMBA_UTIME_OMIT};
- smb_fname->st.st_ex_atime = (struct timespec){0, SAMBA_UTIME_OMIT};
- smb_fname->st.st_ex_mtime = (struct timespec){0, SAMBA_UTIME_OMIT};
- smb_fname->st.st_ex_ctime = (struct timespec){0, SAMBA_UTIME_OMIT};
-
- *_smb_fname = smb_fname;
- return NT_STATUS_OK;
- }
-
- status = unix_convert(ctx, conn, name_in, twrp, &smb_fname, ucf_flags);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_DEBUG("unix_convert failed "
- "for name %s with %s\n",
- name_in,
- nt_errstr(status));
- return status;
- }
-
- if ((ucf_flags & UCF_POSIX_PATHNAMES) &&
- 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;
- }
- } else {
- status = check_name(conn, smb_fname);
- }
- if (!NT_STATUS_IS_OK(status)) {
- DBG_NOTICE("check_name failed "
- "for name %s with %s\n",
- smb_fname_str_dbg(smb_fname),
- nt_errstr(status));
- TALLOC_FREE(smb_fname);
- return status;
- }
-
- if (!VALID_STAT(smb_fname->st)) {
- DBG_DEBUG("[%s] does not exist, skipping pathref fsp\n",
- smb_fname_str_dbg(smb_fname));
- *_smb_fname = smb_fname;
- return NT_STATUS_OK;
- }
-
- status = openat_pathref_fsp(conn->cwd_fsp, smb_fname);
- if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
- /*
- * We deal with symlinks here as we do in
- * SMB_VFS_CREATE_FILE(): return success for POSIX clients with
- * the notable difference that there will be no fsp in
- * smb_fname->fsp.
- *
- * For Windows (non POSIX) clients fail with
- * NT_STATUS_OBJECT_NAME_NOT_FOUND.
- */
- if (smb_fname->flags & SMB_FILENAME_POSIX_PATH &&
- S_ISLNK(smb_fname->st.st_ex_mode))
- {
- status = NT_STATUS_OK;
- }
- }
- if (!NT_STATUS_IS_OK(status)) {
- DBG_DEBUG("openat_pathref_fsp [%s] failed: %s\n",
- smb_fname_str_dbg(smb_fname),
- nt_errstr(status));
- return status;
- }
-
- *_smb_fname = smb_fname;
- return status;
-}
-
/*
* Deal with the SMB1 semantics of sending a pathname with a
* wildcard as the terminal component for a SMB1search or