]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Make sure smb_fname->st is valid in smbd_dirptr_get_entry
authorVolker Lendecke <vl@samba.org>
Thu, 22 Jun 2023 07:52:09 +0000 (09:52 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 23 Jun 2023 17:34:30 +0000 (17:34 +0000)
This simplifies the two mode_fn()s we have.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/dir.c
source3/smbd/smb1_reply.c
source3/smbd/smb2_trans2.c

index 7cfd223bb400d2e37e11936ecf42644740cd52f6..ef3230b047d5a2d710904735be330b4c73c0d03d 100644 (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",
index 18d12317a19dbec484948a1c0620c169026fd615..c80dbcb51c707b00479ed1ee1dce0539777eef84 100644 (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;
index afa89148a4ca13ecfa3393a2c5ee9cf61d68ec07..3221f9089c61e64643ffb4e6e64d3abcda6a201a 100644 (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",