From: Volker Lendecke Date: Thu, 22 Jun 2023 07:52:09 +0000 (+0200) Subject: smbd: Make sure smb_fname->st is valid in smbd_dirptr_get_entry X-Git-Tag: talloc-2.4.1~267 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f97b6a4f7ed3240068fbfc1441f5fd7c93a02f3;p=thirdparty%2Fsamba.git 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 7cfd223bb40..ef3230b047d 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -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", diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index 18d12317a19..c80dbcb51c7 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -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; diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index afa89148a4c..3221f9089c6 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -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",