1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

smbd: add create_internal_dirfsp_at()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2020-03-23 11:36:42 +01:00 committed by Jeremy Allison
parent 4d28b614af
commit 974ea2ce34
2 changed files with 58 additions and 0 deletions

View File

@ -165,6 +165,55 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
return NT_STATUS_OK;
}
/*
* Create an internal fsp for an *existing* directory.
*
* This should only be used by callers in the VFS that need to control the
* opening of the directory.
*/
NTSTATUS create_internal_dirfsp_at(connection_struct *conn,
struct files_struct *dirfsp,
const struct smb_filename *smb_dname,
struct files_struct **_fsp)
{
struct files_struct *fsp = NULL;
NTSTATUS status;
SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
status = file_new(NULL, conn, &fsp);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
status = fsp_set_smb_fname(fsp, smb_dname);
if (!NT_STATUS_IS_OK(status)) {
file_free(NULL, fsp);
return status;
}
if (!VALID_STAT(fsp->fsp_name->st)) {
status = vfs_stat_fsp(fsp);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
}
if (!S_ISDIR(fsp->fsp_name->st.st_ex_mode)) {
DBG_ERR("%s is not a directory!\n",
smb_fname_str_dbg(smb_dname));
file_free(NULL, fsp);
return NT_STATUS_NOT_A_DIRECTORY;
}
fsp->file_id = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st);
fsp->access_mask = FILE_LIST_DIRECTORY;
fsp->is_directory = true;
*_fsp = fsp;
return NT_STATUS_OK;
}
/****************************************************************************
Close all open files for a connection.
****************************************************************************/

View File

@ -419,6 +419,15 @@ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
const struct smb_filename *smb_fname_in);
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen);
NTSTATUS create_internal_dirfsp_at(connection_struct *conn,
struct files_struct *dirfsp,
const struct smb_filename *smb_dname,
struct files_struct **_fsp);
NTSTATUS open_internal_dir_fsp(connection_struct *conn,
const struct smb_filename *smb_dname,
struct files_struct **_fsp);
/* The following definitions come from smbd/ipc.c */
NTSTATUS nt_status_np_pipe(NTSTATUS status);