s3/smbd: use stat from smb_fname if valid in refuse_symlink()
authorRalph Boehme <slow@samba.org>
Sat, 10 Sep 2016 12:43:07 +0000 (14:43 +0200)
committerJeremy Allison <jra@samba.org>
Sun, 11 Sep 2016 21:52:16 +0000 (23:52 +0200)
Now that refuse_symlink() gets passed in a smb_fname and not just a char
buffer, we can try to reuse its stat info and save one stat call here.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sun Sep 11 23:52:17 CEST 2016 on sn-devel-144

source3/smbd/trans2.c

index a01bb81d2ba1e0851d86b31176f1c123f5df2346..6999b2d0715a53c82c5509a7ff8a42ff7630526a 100644 (file)
@@ -55,7 +55,7 @@ static char *store_file_unix_basic_info2(connection_struct *conn,
                                const SMB_STRUCT_STAT *psbuf);
 
 /****************************************************************************
- Check if an open file handle or pathname is a symlink.
+ Check if an open file handle or smb_fname is a symlink.
 ****************************************************************************/
 
 static NTSTATUS refuse_symlink(connection_struct *conn,
@@ -68,6 +68,10 @@ static NTSTATUS refuse_symlink(connection_struct *conn,
        if (fsp) {
                pst = &fsp->fsp_name->st;
        } else {
+               pst = &smb_fname->st;
+       }
+
+       if (!VALID_STAT(*pst)) {
                int ret = vfs_stat_smb_basename(conn,
                                smb_fname,
                                &sbuf);
@@ -76,6 +80,7 @@ static NTSTATUS refuse_symlink(connection_struct *conn,
                }
                pst = &sbuf;
        }
+
        if (S_ISLNK(pst->st_ex_mode)) {
                return NT_STATUS_ACCESS_DENIED;
        }