s3: smbd: Add dirfsp parameter to can_write_to_file().
authorJeremy Allison <jra@samba.org>
Thu, 30 Apr 2020 22:44:37 +0000 (15:44 -0700)
committerRalph Boehme <slow@samba.org>
Mon, 4 May 2020 13:55:33 +0000 (13:55 +0000)
Not yet used. Currently always conn->cwd_fsp.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/dir.c
source3/smbd/dosmode.c
source3/smbd/file_access.c
source3/smbd/nttrans.c
source3/smbd/posix_acls.c
source3/smbd/proto.h

index 1758bbd98c9bbdd007d77ef1dd9989303eb2af22..d430ff769573a6076b4555f1a59322dda8378704 100644 (file)
@@ -1176,7 +1176,7 @@ static bool user_can_write_file(connection_struct *conn,
                return True;
        }
 
-       return can_write_to_file(conn, smb_fname);
+       return can_write_to_file(conn, dirfsp, smb_fname);
 }
 
 /*******************************************************************
index b061e9ac794122396e3fe6a3667fc5c07d6654f6..2c4efa0fcff8f1947943d937a10f8a739eda9571 100644 (file)
@@ -220,6 +220,7 @@ static uint32_t dos_mode_from_sbuf(connection_struct *conn,
        } else if (ro_opts == MAP_READONLY_PERMISSIONS) {
                /* Check actual permissions for read-only. */
                if (!can_write_to_file(conn,
+                               conn->cwd_fsp,
                                smb_fname))
                {
                        result |= FILE_ATTRIBUTE_READONLY;
@@ -542,6 +543,7 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn,
 
                if (!set_dosmode_ok && lp_dos_filemode(SNUM(conn))) {
                        set_dosmode_ok = can_write_to_file(conn,
+                                               conn->cwd_fsp,
                                                smb_fname);
                }
 
@@ -1073,6 +1075,7 @@ int file_set_dosmode(connection_struct *conn,
        */
 
        if (!can_write_to_file(conn,
+                       conn->cwd_fsp,
                        smb_fname))
        {
                errno = EACCES;
@@ -1248,6 +1251,7 @@ int file_ntimes(connection_struct *conn, const struct smb_filename *smb_fname,
 
        /* Check if we have write access. */
        if (can_write_to_file(conn,
+                       conn->cwd_fsp,
                        smb_fname))
        {
                /* We are allowed to become root and change the filetime. */
index 1b9785d670abd356f28d4dfd97487331a7d32850..eb9ff905781e26b9bc26e30674c60757b7fa4efe 100644 (file)
@@ -131,8 +131,10 @@ bool can_delete_file_in_directory(connection_struct *conn,
 ****************************************************************************/
 
 bool can_write_to_file(connection_struct *conn,
+                       struct files_struct *dirfsp,
                        const struct smb_filename *smb_fname)
 {
+       SMB_ASSERT(dirfsp == conn->cwd_fsp);
        return NT_STATUS_IS_OK(smbd_check_access_rights(conn,
                                smb_fname,
                                false,
index c44501108abd97742568595be93187476ed66179..e83ccc25ac46040a6f61aa63331e94920b751f0d 100644 (file)
@@ -727,6 +727,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
                if (fsp->fsp_flags.is_directory ||
                    fsp->fsp_flags.can_write ||
                    can_write_to_file(conn,
+                               conn->cwd_fsp,
                                smb_fname))
                {
                        perms = FILE_GENERIC_ALL;
@@ -1391,6 +1392,7 @@ static void call_nt_transact_create(connection_struct *conn,
                if (fsp->fsp_flags.is_directory ||
                    fsp->fsp_flags.can_write ||
                    can_write_to_file(conn,
+                               conn->cwd_fsp,
                                smb_fname))
                {
                        perms = FILE_GENERIC_ALL;
index 2e78b9c3bbb4821842ef2dc243bdfd491175bc80..bdae3bc636e79a2762d93de4894f94d0865430e0 100644 (file)
@@ -2847,6 +2847,7 @@ static bool acl_group_override(connection_struct *conn,
        /* user has writeable permission */
        if (lp_dos_filemode(SNUM(conn)) &&
            can_write_to_file(conn,
+                               conn->cwd_fsp,
                                smb_fname))
        {
                return true;
index 5303c477cf7b16ad5aaf35a4213ce019b41e7f17..931d2fd2cdd5e28d7d400d5ab7dd4e9813e1c307 100644 (file)
@@ -334,6 +334,7 @@ bool can_delete_file_in_directory(connection_struct *conn,
                        struct files_struct *dirfsp,
                        const struct smb_filename *smb_fname);
 bool can_write_to_file(connection_struct *conn,
+                       struct files_struct *dirfsp,
                        const struct smb_filename *smb_fname);
 bool directory_has_default_acl(connection_struct *conn,
                        struct files_struct *dirfsp,