From: Jeremy Allison Date: Wed, 3 Aug 2022 17:04:37 +0000 (-0700) Subject: s3: smbd: Remove filename_convert(). X-Git-Tag: samba-4.17.0rc1~76 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffc19ac98594c1b41731c7c5fe2e33f3224616c6;p=thirdparty%2Fsamba.git s3: smbd: Remove filename_convert(). (\ _ /) ( \ O / ) (// \\) X / \ /___\ _____/ \\_____ | + || | || | filename_convert || | || | || | || | || | _ ___ _ || | | \ | | \ || | | | | | | || | |_/ | |_/ || | | \ | | || | | \ | | || | | \. _|_. | . || | || * * | * ** * ** |** ** \)),.,\(/.,(//,,..,,\||(,,.,\\,.((// Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke --- diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index c39d4cc60ac..c32990bb2e4 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1914,140 +1914,6 @@ char *get_original_lcomp(TALLOC_CTX *ctx, 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 diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 6ee127f867b..8f3182a025e 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -375,12 +375,6 @@ char *get_original_lcomp(TALLOC_CTX *ctx, connection_struct *conn, const char *filename_in, uint32_t ucf_flags); -NTSTATUS filename_convert(TALLOC_CTX *mem_ctx, - connection_struct *conn, - const char *name_in, - uint32_t ucf_flags, - NTTIME twrp, - struct smb_filename **pp_smb_fname); NTSTATUS filename_convert_smb1_search_path(TALLOC_CTX *ctx, connection_struct *conn, char *name_in,