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

smbd: Make sure smb_fname->st is valid in smbd_dirptr_get_entry

This simplifies the two mode_fn()s we have.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2023-06-22 09:52:09 +02:00 committed by Jeremy Allison
parent c837ecf442
commit 3f97b6a4f7
3 changed files with 9 additions and 20 deletions

View File

@ -709,6 +709,13 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
get_dosmode = false;
}
/*
* openat_pathref_fsp() filled atname->st, but from
* now on we're working with smb_fname. Keep the stat
* info for mode_fn's use.
*/
smb_fname->st = atname->st;
status = move_smb_fname_fsp_link(smb_fname, atname);
if (!NT_STATUS_IS_OK(status)) {
DBG_WARNING("Failed to move pathref for [%s]: %s\n",

View File

@ -1207,20 +1207,6 @@ static bool smbd_dirptr_8_3_mode_fn(TALLOC_CTX *ctx,
bool get_dosmode,
uint32_t *_mode)
{
connection_struct *conn = (connection_struct *)private_data;
if (!VALID_STAT(smb_fname->st)) {
if ((SMB_VFS_STAT(conn, smb_fname)) != 0) {
DEBUG(5,
("smbd_dirptr_8_3_mode_fn: "
"Couldn't stat [%s]. Error "
"= %s\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
return false;
}
}
if (get_dosmode) {
*_mode = fdos_mode(smb_fname->fsp);
smb_fname->st = smb_fname->fsp->fsp_name->st;

View File

@ -1050,7 +1050,6 @@ static bool smbd_dirptr_lanman2_mode_fn(TALLOC_CTX *ctx,
{
struct smbd_dirptr_lanman2_state *state =
(struct smbd_dirptr_lanman2_state *)private_data;
bool ms_dfs_link = false;
if (smb_fname->flags & SMB_FILENAME_POSIX_PATH) {
if (SMB_VFS_LSTAT(state->conn, smb_fname) != 0) {
@ -1063,14 +1062,11 @@ static bool smbd_dirptr_lanman2_mode_fn(TALLOC_CTX *ctx,
return true;
}
if (!VALID_STAT(smb_fname->st) &&
SMB_VFS_STAT(state->conn, smb_fname) != 0) {
if (S_ISLNK(smb_fname->st.st_ex_mode)) {
/* Needed to show the msdfs symlinks as
* directories */
ms_dfs_link = check_msdfs_link(dirfsp,
atname,
smb_fname);
bool ms_dfs_link = check_msdfs_link(dirfsp, atname, smb_fname);
if (!ms_dfs_link) {
DEBUG(5,("smbd_dirptr_lanman2_mode_fn: "
"Couldn't stat [%s] (%s)\n",