1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00
Commit Graph

1229 Commits

Author SHA1 Message Date
Jeremy Allison
6ef5ed2309 s3: smbd: open_directory(). Pass down the real parent_dir->fsp to smbd_check_access_rights_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
63fb55cd6c s3: smbd: open_file(). Pass down the real parent_dir->fsp to smbd_check_access_rights_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
699356a245 s3: smbd: smbd_check_access_rights_fsp(). Add dirfsp parameter.
Pass down to smbd_check_access_rights_sd().

Always pass conn->cwd_fsp for now.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
88881510c7 s3: smbd: smbd_check_access_rights_sd(). Add dirfsp parameter.
Pass down to parent_override_delete().

Always pass fsp->conn->cwd_fsp for now.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
3b1d2ddc79 s3: smbd: parent_override_delete(). Add dirfsp parameter.
Pass down to can_delete_file_in_directory().

Always pass conn->cwd_fsp for now.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
7d4f4c8326 s3: smbd: open_directory(). Start passing a real parent dirfsp to smbd_calculate_access_mask_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
eea3a3c156 s3: smbd: open_file_ntcreate(). Start passing a real parent dirfsp to smbd_calculate_access_mask_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
492d105b44 s3: smbd: smbd_calculate_access_mask_fsp(). Add dirfsp parameter.
Pass this down into smbd_calculate_maximum_allowed_access_fsp().

Currently pass fsp->conn->cwd_fsp everywhere.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
6503bb48ca s3: smbd: smbd_calculate_maximum_allowed_access_fsp(), add parent dirfsp parameter and pass to can_delete_file_in_directory().
Pass the same fsp->conn->cwd_fsp parameter to can_delete_file_in_directory()
dirfsp for now.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
eaff826aed s3: smbd: Remove smbd_check_access_rights(). No longer used.
There are now no more callers of SMB_VFS_GET_NT_ACL_AT().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
1e90d91b03 s3: smbd: Remove smbd_calculate_maximum_allowed_access(). No longer used.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
f700460c07 s3: smbd: Remove smbd_calculate_access_mask(). No longer used.
Comment out smbd_calculate_maximum_allowed_access() as it is
a static function and we just removed the only caller.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
18d9282c1e s3: smbd: open_directory(), smbd_calculate_access_mask() -> smbd_calculate_access_mask_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
5abb0409ff s3: smbd: open_file_ntcreate(), smbd_calculate_access_mask() -> smbd_calculate_access_mask_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
07a81f6982 s3: smbd: Change check_base_file_access() to take an fsp as the first argument.
Internally, change check_base_file_access(), smbd_calculate_access_mask() -> smbd_calculate_access_mask_fsp().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
03352e981b s3: smbd: Add smbd_calculate_access_mask_fsp().
Not yet used but this now uses smbd_calculate_maximum_allowed_access_fsp(),
so uncomment it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
2c32cb18fc s3: smbd: Add new smbd_calculate_access_mask_fsp() function.
Commented out as not yet used.

Signed-off-by: Noel Power <noel.power@suse.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
845aaadccd s3: smbd: open_directory(). Cleanup debug message to refer to correct function.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
bed09bc2d6 s3: smbd: open_file(). Cleanup debug message to refer to correct function.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
b8d43466e1 s3: smbd: open_file(). Cleanup debug message to refer to correct function.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
3f61369d15 s3: smbd: open_file(), smbd_check_access_rights() -> smbd_check_access_rights_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
af291abefa s3: smbd: open_directory(), smbd_check_access_rights() -> smbd_check_access_rights_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
11910757c6 s3: smbd: check_base_file_access(), smbd_check_access_rights() -> smbd_check_access_rights_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
26dc10bdb2 s3: smbd: open_file(), smbd_check_access_rights() -> smbd_check_access_rights_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
3bd2cfc292 s3: smbd: Inside inherit_new_acl(), change from SMB_VFS_GET_NT_ACL_AT() -> SMB_VFS_FGET_NT_ACL().
One more pathname-based call gone.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
110de2f476 s3: smbd: Pass parent_dir_fname parameter to inherit_new_acl().
Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
428bceb127 s3: smbd: Change directory_has_default_acl() -> directory_has_default_acl_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
580226610f s3: smbd: Remove check_parent_access().
No more callers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
0e88fc3735 s3: smbd: Change open_file() to use check_parent_access_fsp() instead of check_parent_access().
No more uses of check_parent_access().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
1509ba3c44 s3: smbd: In open_file_ntcreate(), remove the local parent_dir_fname and rename the passed in parameter to be the same.
open_file() can now use parent_dir_fname->fsp for handle-based
access calls.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
066729f8ce s3: smbd: In open_file_ntcreate() initialize the local parent_dir_fname from the passed in parent_dir_fname_in.
We can now remove the call to parent_smb_fname().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
64bd0ae358 s3: smbd: Pass parent_dir_fname_in, smb_fname_atname_in from create_file_unixpath() to open_file_ntcreate().
Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
748f693a9c s3: smbd: In mkdir_internal(), remove the local parent_dir_fname. We pass it in from the caller now.
This will allow us to change directory_has_default_acl() to
directory_has_default_acl_fsp() later.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
8d4a73db8b s3: smbd: In mkdir_internal(), use the passed in 'smb_fname_atname' instead of a local 'base_name' variable.
atname is a better name, as base_name refers to the name without streams
and this is nothing to do with streams.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
da5762de71 s3: smbd: In mkdir_internal() assign the passed in parent_dir_fname_in, smb_fname_atname_in to the local variables.
We don't need the parent_pathref() and more, and as we don't
own parent_dir_fname anymore, don't free it on exit.

Next step will be to remove the local variables.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
7a06544d18 s3: smbd: Pass parent_dir_fname_in, smb_fname_atname_in to mkdir_internal().
Not yet used. Next step will be to use them to replace the
internal parent_dir_fname,base_name variables inside mkdir_internal().

Annotate them so we know what these extra params are.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
00baf898e8 s3: smbd: Pass in the newly created parent_dir_fname and smb_fname_atname to open_directory().
Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
7aa5acb895 s3: smbd: Get a parent pathref in create_file_unixpath().
Not yet used.

We will be passing this down to open_directory() and
open_file_ntcreate() and using it within create_file_unixpath()
as all of these functions need a parent pathref to check parent
ACLs etc.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
8d5e5095c0 s3: smbd: Make mkdir_internal() use check_parent_access_fsp().
We already have a parent pathref fsp here.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
133196790a s3: smbd: Add check_parent_access_fsp().
Next migrate check_parent_access() users over to it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
153da186a1 s3: smbd: smbd_check_access_rights_fsp(), for a symlink handle just check the handle bits.
For the pathname verison of this function smbd_check_access_rights()
we return the st_mode bits turned into an NT ACL for a symlink.

For a symlink the mode bits are always 'lrwxrwxrwx' which means
smbd_check_access_rights() version always returned NT_STATUS_OK
for any access rights requested on a symlink.

For smbd_check_access_rights_fsp() to a symlink use the handle
access bits as this is a better representation of the access
allowed.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
c11f25b7ea s3: smbd: Fix smbd_check_access_rights_fsp() to cope with fake/printer fsp's.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
ae5cb84fae s3: smbd: Subtle change to semantics needed for smbd_check_access_rights_fsp().
smbd_check_access_rights() is checking permissions on a file *before*
open, so getting ACCESS_DENIED and mapping to NT_STATUS_OK when
reading the security descriptor is fine, as if we really don't have
access the open will fail.

smbd_check_access_rights_fsp() takes place *after* the open (pathref
or otherwise), so being unable to get the security decriptor should
be reported back to the caller and not mapped to NT_STATUS_OK.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
ae8313a445 s3: smbd: In open_directory() move the call to smbd_check_access_rights() until after the fsp is set up.
This doesn't matter now, but later we will move to a handle-based call to
check access rights, so we will need the full handle setup.

Add a fd_close(fsp) in the error path now this is done after the fd open.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:29 +00:00
Jeremy Allison
d2d52ebb6c s3: smbd: In open_file(), remove post-open check for opening a directory.
Now we do an early check for opening a directory, this code
could never have been triggered.

The only case we need to consider now is when the filesystem
object exists as a file when we enter open_file() and another
smbd removes and then re-creates the object as a directory before we
call reopen_from_fsp(). In that case, we will open the object,
and come back out to open_file_ntcreate(), where the race
condition detection code that calls check_same_dev_ino()
will catch the case and error out the client request.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:29 +00:00
Jeremy Allison
f1ca59b81b s3: smbd: Make open_file() fail early for an existing directory we are trying to open.
Makes sure we keep the pathref fd open for the NT_FILE_IS_A_DIRECTORY case.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:29 +00:00
Jeremy Allison
68124e2a46 s3: smbd: Cleanup. open_file(). If SMB_VFS_FSTAT() fails report the error.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:29 +00:00
Jeremy Allison
aaba2918f8 s3: smbd: Cleanup. open_file(). This returns NTSTATUS, don't set errno explicitly internally.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:29 +00:00
Jeremy Allison
99c02ff6c1 s3: smbd: Cleanup. open_file_ntcreate(). This returns NTSTATUS, don't set errno explicitly internally.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:29 +00:00
Jeremy Allison
8a427783e5 smbd: fix pathref unlinking in create_file_unixpath()
This is really subtle. If someone passes in an smb_fname where smb_fname
actually is taken from fsp->fsp_name, then the lifetime of these objects is
meant to be the same.

This is commonly the case from an SMB1 path-based call
(eg call_trans2qfilepathinfo()) where we use the pathref fsp
(smb_fname->fsp) as the handle. In this case we must not unlink smb_fname->fsp
from it's owner.

The asserts below:

  SMB_ASSERT(fsp->fsp_name->fsp != NULL);
  SMB_ASSERT(fsp->fsp_name->fsp == fsp);

ensure the required invarients are met.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14732

Pair-Programmed-With: Ralph Boehme <slow@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Jun  8 20:44:41 UTC 2021 on sn-devel-184
2021-06-08 20:44:41 +00:00