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

104 Commits

Author SHA1 Message Date
Volker Lendecke
d088738342 vfs: Simplify connect_acl_xattr()
We don't need talloc for printing a mask with %o

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Anoop C S
697d41420b Revert "vfs_acl_xattr.c: prefer capabilities over become_root"
This reverts commit 0e3836e396.

With capabilities preferred over become_root() we failed to achieve
the basic goal of storing NT ACLs in xattrs using vfs_acl_xattr. This
is due to the fact that apart from CAP_DAC_OVERRIDE it is manadatory
to have CAP_SYS_ADMIN for write access to xattrs from security
namespace[1]. Despite the option to configure the xattr name within
the module we should not anticipate and miss to consider xattrs from
security namespace which is far more protected even with our default
name "security.NTACL".

Theorotically we could make it work by adding another capability on
top of existing ones. But given the functions designed around this
area we may not be able to come up with a cleaner change which can
handle the fallback mechanism to become_root(). Any failure to set
the very first capability would put us in become_root() path where
further capabilities are mostly not required. Thus reverting to old
behaviour to always become_root() until we have a cleaner approach
to handle the fallback while modifying multiple capabilities at once.

[1] https://www.man7.org/linux/man-pages/man7/xattr.7.html

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-01-26 10:26:30 +00:00
Björn Jacke
0e3836e396 vfs_acl_xattr.c: prefer capabilities over become_root
Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2023-11-16 21:38:38 +00:00
Ralph Boehme
f2b6258b68 vfs_acl_xattr: add acl_xattr:security_acl_name option
Pair-Programmed-With: Jeremy Allison <jra@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
2022-06-27 15:50:29 +00:00
Jeremy Allison
f694b36335 s3: modules: acl_xattr: getxattr_do(). Remove the smb_fname parameter.
It was always NULL. Always use the passed in fsp.

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
45341cee01 s3: VFS: acl_xattr: Remove unused get_acl_blob_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
fd8a2cfd4e s3: VFS: acl_xattr: Remove acl_xattr_get_nt_acl_at().
Comment out get_acl_blob_at() as 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
Noel Power
a773d5e321 s3/modules: VFS: acl_xattr: Remove call to chmod_acl_module_common()
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-04-11 22:27:34 +00:00
Noel Power
17054bfa9f s3/modules: vfs_acl_xattr 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
Ralph Boehme
25ec288172 vfs_acl_xattr: avoid removing the ACL xattr
...when called as part of setting a new NT ACL.

This depends on the previous code changes, so
won't be back ported. But for reference the
bug id is below.

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

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
d860785f68 vfs_acl_xattr: reformatting
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
92b1499542 vfs: RIP SMB_VFS_SYS_ACL_SET_FILE()
.--. .-,       .-..-.__
        .'(`.-` \_.-'-./`  |\_( "\__
     __.>\ ';  _;---,._|   / __/`'--)
    /.--.  : |/' _.--.<|  /  | |
_..-'    `\     /' /`  /_/ _/_/
 >_.-``-. `Y  /' _;---.`|/))))
'` .-''. \|:  .'   __, .-'"`
 .'--._ `-:  \/:  /'  '.\             _|_
     /.'`\ :;   /'      `-           `-|-`
    -`    |     |                      |
          :.; : |                  .-'~^~`-.
          |:    |                .' _     _ `.
          |:.   |                | |_) | |_) |
          :. :  |                | | \ | |   |
          : ;   |                |           |
          : ;   |                |  SMB_VFS  |
          : ;   |                |  SYS_ACL  |
          : ;   |                | SET_FILE  |
        .jgs. : ;                |           |
-."-/\\\/:::.    `\."-._'."-"_\\-|           |///."-
" -."-.\\"-."//.-".`-."_\\-.".-\\`=.........=`//-".

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
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
Jeremy Allison
617759ce06 s3: VFS: acl_xattr. Remove get_nt_acl_fn().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:37 +00:00
Jeremy Allison
2840bf3700 s3: VFS: acl_xattr: Add acl_xattr_get_nt_acl_at().
Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:35 +00:00
Jeremy Allison
d825d31f7a s3: VFS: vfs_common and callers. Change get_nt_acl_common() -> get_nt_acl_common_at().
Add in the dirfsp parameter. Fix all callers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:34 +00:00
Jeremy Allison
42651479e5 s3: VFS: ACLs. Remove smb_fname argument to get_nt_acl_common().
As a bonus stat_fsp_or_smb_fname() is no longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:34 +00:00
Jeremy Allison
b7847aa25a s3: VFS: acl_xattr: Change acl_xattr_fget_nt_acl() to use fget_nt_acl_common().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:34 +00:00
Jeremy Allison
d902ea5215 s3: VFS: ACLs. Switch fset_nt_acl_common() over to using fget_acl_blob_fn().
Removes passing in smb_fname to fsp functions.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:34 +00:00
Jeremy Allison
936b9aee5e s3: VFS: acl_xattr.c: Add fget_acl_blob().
Separate from get_acl_blob() which took both an fsp and a pathname.
Commented out so we still compile.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07 19:27:34 +00:00
Jeremy Allison
26eb0e70bc s3: VFS: vfs_acl_xattr: Remove rmdir_fn(). No longer used.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-10-10 06:09:40 +00:00
Jeremy Allison
7f54bc8794 s3: VFS: Change rmdir_acl_common() to take a files_struct *dirfsp pointer.
Pass in the passed dirfsp if available, else handle->conn->cwd_fsp.

No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-10-10 06:09:39 +00:00
Jeremy Allison
9290510fe4 s3: VFS: vfs_acl_xattr. Wrap rmdir_acl_common() by acl_xattr_rmdir() so we don't call it directly.
This will allow adding the extra dirfsp parameter to
rmdir_acl_common().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-10-10 06:09:39 +00:00
Jeremy Allison
7222d63d42 s3: VFS: vfs_acl_xattr: Remove unlink_fn. No longer used.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-09-26 17:20:52 +00:00
Jeremy Allison
63d814047f s3: VFS: vfs_acl_common: Add dirfsp, flags parameters to unlink_acl_common().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-09-26 17:20:48 +00:00
Jeremy Allison
6ef40bdb94 s3: VFS: vfs_acl_xattr: Don't call unlink_acl_common() directly.
Use a wrapper function so we can change the parameters.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-09-26 17:20:47 +00:00
Jeremy Allison
2a7e472e5c s3: VFS: vfs_acl_xattr. Implement unlinkat().
Note this isn't identical to unlink() as
this must cope with (flags & AT_REMOVEDIR),
which is identical to rmdir(). It calls
either unlink or rmdir depending on the
flags parameter.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-09-26 17:20:44 +00:00
Andreas Schneider
0a001515bf s3:modules: Remove superfloues sha256.h include in vfs_acl_xattr
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2018-12-12 09:13:23 +01:00
Jeremy Allison
5bbb831041 s3: VFS: Remove SMB_VFS_FCHMOD_ACL().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2018-05-25 18:39:25 +02:00
Jeremy Allison
7b8fa17f06 s3: VFS: Remove SMB_VFS_CHMOD_ACL().
No longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2018-05-25 18:39:24 +02:00
Volker Lendecke
48815f8c3e acl_common: Avoid "#include vfs_acl_common.c"
This makes vfs_acl_common.c a subsystem of its own that acl_xattr and acl_tdb
now link against, not #include it.

This patch is a bit on the large and clumsy side, but splitting it up would
(I believe) involve a separate intermediate copy of acl_common.c.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-08-24 01:46:07 +02:00
Jeremy Allison
854ea4eba8 s3: VFS: Change SMB_VFS_GETXATTR to use const struct smb_filename * instead of const char *.
We need to migrate all pathname based VFS calls to use a struct
to finish modernising the VFS with extra timestamp and flags parameters.

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  1 02:58:53 CEST 2017 on sn-devel-144
2017-06-01 02:58:53 +02:00
Jeremy Allison
48956fa4d3 s3: VFS: Change SMB_VFS_SETXATTR to use const struct smb_filename * instead of const char *.
We need to migrate all pathname based VFS calls to use a struct
to finish modernising the VFS with extra timestamp and flags parameters.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-05-31 22:50:22 +02:00
Jeremy Allison
12b801d9d7 s3: VFS: Change SMB_VFS_REMOVEXATTR to use const struct smb_filename * instead of const char *.
We need to migrate all pathname based VFS calls to use a struct
to finish modernising the VFS with extra timestamp and flags parameters.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-05-31 22:50:22 +02:00
Jeremy Allison
aada94885d s3: VFS: Change SMB_VFS_SYS_ACL_SET_FILE to use const struct smb_filename * instead of const char *.
We need to migrate all pathname based VFS calls to use a struct
to finish modernising the VFS with extra timestamp and flags parameters.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-05-31 22:50:22 +02:00
Jeremy Allison
306783d6f5 lib: modules: Change XXX_init interface from XXX_init(void) to XXX_init(TALLOC_CTX *)
Not currently used - no logic changes inside.

This will make it possible to pass down a long-lived talloc
context from the loading function for modules to use instead
of having them internally all use talloc_autofree_context()
which is a hidden global.

Updated all known module interface numbers, and added a
WHATSNEW.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Ralph Böhme <slow@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Apr 22 01:17:00 CEST 2017 on sn-devel-144
2017-04-22 01:17:00 +02:00
Ralph Boehme
375d772d04 vfs_acl_xattr|tdb: ensure create mask is at least 0666 if ignore_system_acls is set
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12562

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Apr 20 20:50:10 CEST 2017 on sn-devel-144
2017-04-20 20:50:10 +02:00
Uri Simchoni
05d83ccf7a vfs_acl_xattr: avoid needlessly supplying a large buffer to getxattr()
When obtaining the security descriptor via getxattr(), first try
optimistically to supply a buffer of 4K, and if that turns out
to be too small, determine the correct buffer size.

The previous behavior of falling back to a 64K buffer encountered
problem with Linux prior to version 3.6, due to pyisical memory
fragmentation. With those kernels, as long as the buffer is 8K or
smaller, getting the xattr is much less prone to failure due to
memory fragmentation.

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

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Apr 18 04:41:16 CEST 2017 on sn-devel-144
2017-04-18 04:41:16 +02:00
Uri Simchoni
7b775abd92 vfs_acl_xattr: factor out fetching of an extended attribute
Pure refactoring - add a function that fetches an extended attribute
based on either the file descriptor or the file name.

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

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-04-18 00:43:20 +02:00
Ralph Boehme
b72287514c vfs_acl_xattr|tdb: enforced settings when ignore system acls=yes
When "ignore system acls" is set to "yes, we need to ensure filesystem
permission always grant access so that when doing our own access checks
we don't run into situations where we grant access but the filesystem
doesn't.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12181

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

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Aug 31 18:41:20 CEST 2016 on sn-devel-144
2016-08-31 18:41:20 +02:00
Ralph Boehme
61c3d2124f vfs_acl_tdb|xattr: use a config handle
Better for performance and a subsequent commit will add one more option
where this will pay off.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12177

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-08-30 21:12:25 +02:00
Jeremy Allison
6b877102db s3:vfs: Change get_acl_blob() to take a const smb_filename * parameter from const char *.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
2016-03-15 08:29:31 +01:00
Volker Lendecke
af26da1e47 vfs_acl_*: Only sha256 needed
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-11-09 07:53:18 +01:00
Stefan Metzmacher
37b2677648 s3:modules/vfs_*: make function prototypes available via static_decl_vfs;
This allows the static build of the modules.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-08-20 16:06:21 +02:00
Richard Sharpe
bfe4a2baee Fix the overwriting of errno before use in a DEBUG statement and use the return value from store_acl_blob_fsp rather than ignoring it.
Autobuild-User: Richard Sharpe <sharpe@samba.org>
Autobuild-Date: Wed May 16 03:43:41 CEST 2012 on sn-devel-104
2012-05-16 03:43:40 +02:00
Richard Sharpe
422494a8e6 vfs: Make function pointer names consistent. They all end in _fn
Autobuild-User: Richard Sharpe <sharpe@samba.org>
Autobuild-Date: Mon Dec 12 04:58:40 CET 2011 on sn-devel-104
2011-12-12 04:58:40 +01:00
Jeremy Allison
7ef4d08a98 Remove the setting of the inherited ACL on new files/directories. This is
now done correctly in the main codepath. The vfs_acl_XXXX modules are
now thin shims that simply store/retrieve ACLs as they should be.
2011-11-22 12:33:54 -08:00
Jeremy Allison
cde73e2ece Remove opendir() VFS code from ACL modules.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Wed Nov  2 02:13:51 CET 2011 on sn-devel-104
2011-11-02 02:13:51 +01:00
Jeremy Allison
30a599684a Remove the mkdir and open functions from the ACL modules - main code paths now handle this. 2011-10-28 12:16:42 -07:00