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

139680 Commits

Author SHA1 Message Date
Volker Lendecke
56e3a8e3f8 smbd: Add open_rootdir_pathref_fsp()
Get a pathref handle on the file system root. This will serve as
"basedir" for filename_convert_dirfsp_rel() to turn an absolute path
into one relative to the handle created here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
0fc8d8bfc5 smbd: Factor out filename_convert_dirfsp_rel()
Soon we'll have a caller that needs the last component as a relative
file name. Make sure it does not have to call get_lcomp or so.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
99fa20b418 smbd: Fix following symlinks if basedir != cwd_fsp
Unused so far, but soon we'll call this routine with a basedir that's
somewhere below the share root.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
82fd2230a8 smbd: Slightly simplify filename_convert_dirfsp_nosymlink()
Reference conn->cwd_fsp just once, shrinks next patches

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
88abb775dc smbd: Use OpenDir_from_pathref() in rmdir_internals()
Make strace look nicer

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
10512eebec smbd: Use OpenDir_from_pathref() in can_delete_directory_fsp()
This avoids a full path traversal if /proc/self/fd is available.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
c0bbeded93 smbd: Simplify OpenDir_from_pathref()
Use the /proc/self/fd trick to make get_real_filename_fullscan_at look
a bit nicer and faster in strace. Direct SMB_VFS_OPENAT also is
cheaper in user space, we don't need the full fd_openat and
non_widelink_open magic here.

Also avoid opening ".", which can fail where a full path open would
succeed: If the directory in question does not give "x" perms to the
user, we get a handle on the dir as such but can't cd into it.

I haven't seen real-world cases of this, but one of our tests creates
such a scenario. I have further refactoring in my local tree that make
this patch necessary.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
9550f4370e smbd: Enable fd_openat(cwd_fsp, "/absolute/share/path")
So far fd_openat needed to be called with cwd_fsp and "." if you
wanted to open the share root, this enables using the absolute share
path. The next patch will remove sending the "." with cwd_fsp as a
simplification. Enable that with this little change.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
e571da800f smbd: Tighten non_wide_link_open() for absolute root share open
Make it clear that non_widelink_open being called for absolute paths
is not done during regular operations, i.e. when we have passed our
pathnames through filename_convert_dirfsp and we work on a real
dirfsp.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
88f582d3ca smbd: Ignore twrp in chdir_below_conn()
We can't deal with snapdir paths in non_widelink_open fully with
snapdirseverywhere active: There is no way for
shadow_copy2_parent_pathname() to work when a snapshot directory is
below the directory that we want to calculate the parent for. What is
the parent directory supposed to point at? I don't know.

For me the only way out is to accept that we should ignore what
happens behind shadow_copy2's path manipulation in core
smbd. This *might* open symlink races, but the whole point of
snapshots is that they are r/o copies of the real active file system
and as such they should be immune to those races.

Found while trying to refactor code around fd_openat()

P.S: This code will go away pretty soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
bd30c9c128 smbd: Simplify filename_convert_dirfsp()
If we do the S_ISLNK check in the lower level, the if-condition is
simpler and we get the close_file_free() call for free.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
3ab6a9a9bf smbd: Inline dup_file_fsp() into fcb_or_dos_open()
Only used once, an not really complex

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 18:07:33 +00:00
Volker Lendecke
6e9c6dd6d6 vfs: Don't ever call openat(-1, ...) for relative paths
This is always a bug, we should never do this. In one iteration of my
code I was doing this, which led to an invalid fallback code, which
itself lead to an infinite recursion. Make this more obvious with an
assert.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Nov 12 15:13:03 UTC 2024 on atb-devel-224
2024-11-12 15:13:03 +00:00
Volker Lendecke
dade2981c3 vfs: Only call openat for valid params in fake_acls_stat
openat(-1, "relative path", ..) is invalid. I've tried to also tighten
this down to just relative paths (i.e. base_name[0] != '/'), but
non_widelink_open makes modifications further down that make this more
difficult.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 13:44:32 +00:00
Volker Lendecke
142a78eb24 vfs: Use the getwd-cache only if we have a valid tcon
A valid tcon will have changed fsp_get_pathref_fd() to AT_FDCWD, -100
on Linux.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 13:44:32 +00:00
Volker Lendecke
c31e7aecba vfs: Change the condition when to fill the getwd cache
The next patch will add another excluding condition, this change
keeps the if-condition that is changed here simple.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 13:44:32 +00:00
Volker Lendecke
0ab88a1fe7 smbd: Don't print cwd before tcon is done
vfs_GetWd depends upon a current tcon in fake_acls, otherwise it will
call openat with an invalid dirfd on a relative pathname.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 13:44:32 +00:00
Volker Lendecke
f8994bc289 smbd: Fix an error resource leak in OpenDir_from_pathref()
We have to undo the fsp allocation and open we've done. Not noticed,
it's probably highly unlikely OpenDir_fsp() fails.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Nov 12 13:26:10 UTC 2024 on atb-devel-224
2024-11-12 13:26:10 +00:00
Volker Lendecke
01f15d0e5e libsmb: Use SMB2_0_INFO_FILE instead of a simple "1"
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
48464c66f8 smbd: Simplify smbd_smb2_query_directory_send()
Use reopen_from_fsp(), this will use the /proc/self/fd/<fd> trick if
available, no need to go through non_widelink_open

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
774005be76 smbd: reopen_from_fsp also works for full fsps
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
3b38639330 smbd: Make reopen_from_fsp() public
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
45f50eee06 vfs: Fix streams_xattr_openat
This emulates openat, and trying to open a non-existing file should
result in ENOENT and not ENOATTR

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
ea597019aa vfs: Simplify streams_xattr_openat()
Don't go via NTSTATUS in error handling

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
bea01e845c vfs: Convert streams_xattr_get_name() to return 0/errno
This function is pretty simple, this avoids a few calls to
map_errno_from_nt_status in the callers

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
7430831f88 smbd: Convert get_ea_value_fsp() to return 0/errno
Avoid a map_errno_from_nt_status()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
eecdd0fb59 smbd: Convert refuse_symlink_fsp() to bool
I want to simplify get_ea_value_fsp next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
4b3b283b1f smbd: Simplify make_connection_snum()
Avoid nested if's, don't check for ISDIR twice

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
47c8d9b62a pylibsmb: Add NFS reparse tag types
To be used in tests later

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
3dc89edf9c libsmb: Fix a "cast increases required alignment" warning
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
6c8d817f00 libsmb: Fix trailing whitespace
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
4f727b919a lsasrv: Simplify dcesrv_lsa_AddRemoveAccountRights()
Use dom_sid_string_buf, no need to talloc.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
7c4d1f9de1 lib: Simplify nybble_to_hex_*
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
542cf01bfe ldb: User hexchars_upper from replace.h
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
fd5562bee7 libreplace: Introduce hexchars_{upper|lower}
We use that in quite a few places in our code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
72ff0312d1 libcli: Convert an int to a size_t
More appropriate for an array length

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
83582d417c lib: Modernize a DEBUG
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
83bb0c4ae6 idl: Fix trailing whitespace
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:35 +00:00
Volker Lendecke
804568a1d7 lib: simplify smbpasswd_sethexpwd() with hex_encode_buf()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:34 +00:00
Volker Lendecke
282a5778fb lib: simplify smbpasswd_gethexpwd() with strhex_to_str()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:34 +00:00
Volker Lendecke
3a5068f294 libcli: Try to fix CID 1609583 Overflowed constant
Coverity does not like the --i

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:34 +00:00
Volker Lendecke
8a64775334 vfs_fruit: Align a few integer types
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:34 +00:00
Volker Lendecke
63f0b59cbe vfs_fruit: Simplify filter_empty_rsrc_stream()
Inspired by Coverity finding CID 1609584 Overflowed constant -- not
sure it fixes it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:34 +00:00
Volker Lendecke
ccb6e6634a libndr: Early overflow detection
This is an addition without an overflow check. Do it right there.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:34 +00:00
Volker Lendecke
5d19591e75 libndr: Simplify data flow in ndr_push_relative_ptr2
Consolidate saving/replacing ndr->offset right around the push_uint32

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-12 12:09:34 +00:00
Douglas Bagnall
b80afa1ca0 libgpo:admx:: s/the the\b/the/
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Nov 12 09:21:53 UTC 2024 on atb-devel-224
2024-11-12 09:21:53 +00:00
Thomas Klausner
04e0fb9b2d lib/replace: memset_explicit() only takes three arguments
Signed-off-by: Thomas Klausner <wiz@gatalith.at>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Nov 11 16:47:46 UTC 2024 on atb-devel-224
2024-11-11 16:47:46 +00:00
Volker Lendecke
1c859ec1db WHATSNEW: Add client netlogon ping protocol parameter
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Nov 11 15:15:29 UTC 2024 on atb-devel-224
2024-11-11 15:15:29 +00:00
Volker Lendecke
47d7e86a62 tests: Run ad members with new netlogon ping protocol settings
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-11-11 14:03:04 +00:00
Volker Lendecke
f151f462d5 libcli: Make cldap_error_reply() static to cldap_server.c
Only used there

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-11-11 14:03:04 +00:00