1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00
Commit Graph

481 Commits

Author SHA1 Message Date
Volker Lendecke
0e4cc565e6 smbd: get_acl_group_bits() needs a fsp, not a name
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-03-11 18:22:28 +00:00
Volker Lendecke
fd1dca2d17 smbd: Inherit acl from an fsp instead of a fname
Moving slowly towards passing directory handles instead of names,
representing the idea that we hold a O_PATH file descriptor on
directories.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-03-04 17:43:42 +00:00
Martin Schwenke
98594d3328 util: Drop unused variable mask_perms
clang complains:

../../source3/smbd/posix_acls.c:2783:9: error: variable 'mask_perms' set but not used [-Werror,-Wunused-but-set-variable]
        mode_t mask_perms = 0;
               ^

That is, the variable is initialised and updated but the value is
never used.

This potentially points to a bug in commit
f735551b9e from 2002.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-02-17 18:12:51 +00:00
Volker Lendecke
ede2328c96 smbd: Fix CID 1497981: Null pointer dereferences (REVERSE_INULL)
brown paper bag quality, sorry...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-07 19:00:34 +00:00
Volker Lendecke
1d6762d86b smbd: copy_access_posix_acl() just needs fsps these days
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-01 19:09:34 +00:00
Volker Lendecke
a1d5ae30ed smbd: chmod_acl_internals() does not need connection_struct anymore
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-01 19:09:34 +00:00
Volker Lendecke
ea8a653754 smbd: Make directory_has_default_posix_acl() just take "dirfsp"
conn is not referenced anymore, and we only need the files_struct

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-01 19:09:34 +00:00
Jeremy Allison
0657db2644 s3: smbd: Explicitly code the semantics of "dos filemode" into the chown code.
We actually don't need this to get the right semantics, as the open or the
set_sd() code catches the correct cases and returns ACCESS_DENIED, but it
makes me much happier to see the prerequisites needed expressed in code here
right at the point of use.

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

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Jul 13 08:11:36 UTC 2021 on sn-devel-184
2021-07-13 08:11:36 +00:00
Jeremy Allison
757b7d5c6a s3: smbd: fload_inherited_info(). Always use SMB_VFS_FGETXATTR().
If the underlying fd is -1, we want this to fail with EBADF.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-25 15:53:31 +00:00
Jeremy Allison
a602256269 s3: smbd: Cleanup - Remove #ifdef'ed out load_inherited_info().
I commented this out but forgot to remove in the
previous mega-patch.

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

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jun 10 21:36:11 UTC 2021 on sn-devel-184
2021-06-10 21:36:11 +00:00
Jeremy Allison
bb038f2b89 s3: VFS: RIP SMB_VFS_SYS_ACL_GET_FILE()
(\  _  /)
                    ( \ O / )
                     (// \\)
                        X
                       / \
                      /___\
               _____/      \\_____
              |         +         ||
              |                   ||
              |   SMB_VFS_SYS_    ||
              |  ACL_GET_FILE()   ||
              |                   ||
              |                   ||
              |                   ||
              |  _     ___   _    ||
              | | \     |   | \   ||
              | |  |    |   |  |  ||
              | |_/     |   |_/   ||
              | | \     |   |     ||
              | |  \    |   |     ||
              | |   \. _|_. | .   ||
              |                   ||
      *     * | *   **    * **    |**     **
       \)),.,\(/.,(//,,..,,\||(,,.,\\,.((//

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
ccef64dab7 s3: smbd: Remove posix_get_nt_acl().No longer used.
Comment out load_inherited_info() as that was 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
92eff16d5a s3: smbd: Change acl_group_override() -> acl_group_override_fsp().
We always have a valid fsp here. Inside acl_group_override_fsp()
change can_write_to_file() -> can_write_to_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
5f3599fab0 s3: smbd: copy_access_posix_acl(), SMB_VFS_SYS_ACL_GET_FILE() -> SMB_VFS_SYS_ACL_GET_FD().
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
23217ced3e s3: smbd: directory_has_default_posix_acl(), SMB_VFS_SYS_ACL_GET_FILE() -> SMB_VFS_SYS_ACL_GET_FD().
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
9042bdd0dd s3: smbd: In get_acl_group_bits(), SMB_VFS_SYS_ACL_GET_FILE() -> SMB_VFS_SYS_ACL_GET_FD().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Noel Power
91cd0e87f9 s3/smbd: make posix_sys_acl_blob_get_fd actually use handle api with the changes to underlying sys_acl_get_fd_fn we now can pass the acl type down
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Noel Power
e59244461f VFS: SMB_VFS_SYS_ACL_GET_FD: Modify api to take additional type param
Modify all implementations (and the definitions) related to
SMB_VFS_SYS_ACL_GET_FD to accept additional SMB_ACL_TYPE_T type param.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:30 +00:00
Jeremy Allison
b7f62e1393 s3: smbd: Ensure POSIX default ACL is mapped into returned Windows ACL for directory handles.
Remove knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Wed May 19 09:22:56 UTC 2021 on sn-devel-184
2021-05-19 09:22:56 +00:00
Jeremy Allison
fd16f9da7c s3: smbd: Change SMB_VFS_SYS_ACL_DELETE_DEF_FILE() -> SMB_VFS_SYS_ACL_DELETE_DEF_FD().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2021-05-18 17:29:34 +00:00
Noel Power
0f0b945c1a s3/smbd: posix_acls SMB_VFS_SETXATTR -> SMB_VFS_FSETXATTR
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-11 17:50:30 +00:00
Andreas Schneider
0a93f5367b s3:smbd: Fix invalid memory access in posix_sys_acl_blob_get_fd()
We are handing down an out of scope buffer.

Found by AddressSanitizer.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Feb  1 22:55:10 UTC 2021 on sn-devel-184
2021-02-01 22:55:09 +00:00
Ralph Boehme
6efe41c49c posix_acls: use pathref fsp in copy_access_posix_acl()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 18:56:29 +00:00
Ralph Boehme
33cbe40c41 posix_acls: use SMB_VFS_SYS_ACL_SET_FD() in set_unix_posix_default_acl()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 18:56:29 +00:00
Ralph Boehme
8d323aebe3 posix_acls: use SMB_VFS_SYS_ACL_SET_FD() in set_canon_ace_list()
SMB_VFS_SYS_ACL_SET_FD() can now safely be used to set default ACLs on
directories.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 18:56:29 +00:00
Ralph Boehme
8d0ea8bafa vfs: add acl type arg to SMB_VFS_SYS_ACL_SET_FD()
No change in behaviour, the new arg is not yet used in any module.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 18:56:28 +00:00
Ralph Boehme
879d8a3be9 smbd/posix_acls: support pathref fd's in posix_sys_acl_blob_get_fd()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
5648662b2f smbd: use fsp_get_pathref_fd() for "internal" xattr functions
We're using xattr data storage for internal reasons in these places, so in all
places it's safe to use a possibly root opened fd.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
9db3ff2573 smbd: use fsp_get_io_fd() when accessing a file or it's associated metadata
In all places where we access or modify a file or it's associated metadata, we
use fsp_get_io_fd() to fetch the low-level fd from the fsp. This ensures we
don't accidentally use a pathref fsp where the fd would be opened as root on
systems lacking O_PATH.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
c14a95dc1a smbd: simplify uid_entry_in_group()
conn->session_info is always valid since
1fa05e5c76 and preceeding commits.

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): Sat May 30 02:40:22 UTC 2020 on sn-devel-184
2020-05-30 02:40:22 +00:00
Gary Lockyer
13a2f70a4d Fix clang 9 missing-field-initializer warnings
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-05-08 09:31:31 +00:00
Jeremy Allison
7c1f1e5243 s3: smbd: Add dirfsp parameter to can_write_to_file().
Not yet used. Currently always conn->cwd_fsp.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-04 13:55:33 +00:00
Jeremy Allison
21d16fe212 s3: smbd: Reformat users of can_write_to_file().
Make new parameter addition clearer.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-04 13:55:33 +00:00
Jeremy Allison
d7f4bb57f2 s3: smbd: Cleanup - move the function get_nt_acl_no_snum() to it's user module.
Make static. It was only called from one place.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-30 07:33:41 +00:00
Jeremy Allison
7288e9a445 s3: smbd: In posix_fget_nt_acl() remove the fall-back to path based operations.
Previously we'd do this for directory opens, but directory opens
now always have an open fd. stat opens don't have permissions
to read a security descriptor anyway.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-30 07:33:40 +00:00
Ralph Boehme
bf504ac3c6 smbd: convert inherit_access_posix_acl() arg parent_dir to struct smb_filename
This also fixes a bug introduced by cea8e57eac
where inherit_access_posix_acl() used the smb_fname->base_name instead of
inherit_from_dir in synthetic_smb_fname() to get an struct smb_filename of the
parent directory.

Nobody complained so far, fix it silently.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-29 16:39:41 +00:00
Ralph Boehme
cb996cd5a3 smbd: move files_struct.is_directory to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:44 +00:00
Ralph Boehme
5a5bbcd9d9 smbd: reformat calling ensure_canon_entry_valid_on_set() in unpack_canon_ace()
No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:43 +00:00
Volker Lendecke
29b591d972 smbd: Use ARRAY_DEL_ELEMENT() in merge_default_aces()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-03-26 14:43:31 +00:00
Ralph Boehme
459233b962 smbd: pass session_info to create_conn_struct_tos()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-12-20 11:41:41 +00:00
Ralph Boehme
d68d8c6538 s3:rpc_server: pass session_info to get_nt_acl_no_snum()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-12-20 11:41:41 +00:00
Jeremy Allison
2dbc68e2c0 s3: smbd: set_nt_acl(). Now we know we always have a valid file handle, always use VFS_FCHOWN.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
2019-10-15 18:46:36 +00:00
Jeremy Allison
78bdbfbf54 s3: smbd: Posix ACLs. Now we know we have a handle, always use VFS_FCHMOD instead of VFS_CHMOD.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-06-24 18:49:10 +00:00
Jeremy Allison
147ce70eea s3: smbd: Make set_unix_posix_default_acl() take an fsp argument, not smb_fname.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-06-24 18:49:10 +00:00
Jeremy Allison
503e1243d2 s3: smbd: Only pass fsp to remove_posix_acl(). No longer uses smb_fname.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-06-24 18:49:10 +00:00
Jeremy Allison
caa4024a91 s3: smbd: Only pass fsp to set_unix_posix_acl(). No longer uses smb_fname.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-06-24 18:49:10 +00:00
Jeremy Allison
681f0f2337 s3: smbd: Change set_unix_posix_default_acl() to return NTSTATUS.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-06-24 18:49:09 +00:00
Jeremy Allison
763b52d237 s3: smbd: Cleanup - make set_unix_posix_default_acl() use modern coding standards.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-06-24 18:49:09 +00:00
Jeremy Allison
0b496fd905 s3: smbd: Make set_unix_posix_acl() return NTSTATUS.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-06-24 18:49:09 +00:00
Jeremy Allison
e626cb70fd s3: smbd: Cleanup - make remove_posix_acl() return NTSTATUS.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-06-24 18:49:09 +00:00