]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
8 months agosmbd: Make filename_convert_dirfsp_nosymlink() public
Volker Lendecke [Fri, 16 Dec 2022 15:35:00 +0000 (16:35 +0100)] 
smbd: Make filename_convert_dirfsp_nosymlink() public

To be used directly in smb2_create.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Revert "smbd: Simplify filename_convert_dirfsp()"
Volker Lendecke [Tue, 19 Nov 2024 10:48:12 +0000 (11:48 +0100)] 
smbd: Revert "smbd: Simplify filename_convert_dirfsp()"

This reverts commit bd30c9c128c203c3ed4b123b651862a9953f6cf2.

While this does indeed slightly simplify code, it simplifies too much: Soon we
will need filename_convert_dirfsp_nosymlink raw without looking at
UCF_LCOMP_LNK_OK. So in hindsight this went too far.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Pass "create_options" to filename_create_ucf_flags()
Volker Lendecke [Fri, 2 Feb 2024 20:16:46 +0000 (21:16 +0100)] 
smbd: Pass "create_options" to filename_create_ucf_flags()

OPEN_REPARSE_POINT will trigger symlinks not being followed but
returned, even if we have "follow symlinks = yes". Prepare for setting
UCF_LCOMP_LNK_OK for this case in a central place.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agoctdb-common: Map ENOENT for a missing event script to ENOEXEC
Martin Schwenke [Wed, 20 Nov 2024 03:37:09 +0000 (14:37 +1100)] 
ctdb-common: Map ENOENT for a missing event script to ENOEXEC

This handles the case where an event script is disabled by unlinking,
while an event is being run, after the script list has been created.
Without this change the script will fail.  With this change the script
will be marked as DISABLED.  See the comment added by this commit for
more details.

Add a testcase to simulate the race, using an event script to disable
subsequent ones.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Nov 21 01:42:09 UTC 2024 on atb-devel-224

8 months agotest: Fix a typo
Volker Lendecke [Thu, 28 Dec 2023 12:39:40 +0000 (13:39 +0100)] 
test: Fix a typo

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 19 19:24:16 UTC 2024 on atb-devel-224

8 months agotests: Fix a comment
Volker Lendecke [Fri, 22 Dec 2023 12:54:34 +0000 (13:54 +0100)] 
tests: Fix a comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Simplify smb_q_posix_symlink()
Volker Lendecke [Wed, 13 Nov 2024 14:57:41 +0000 (15:57 +0100)] 
smbd: Simplify smb_q_posix_symlink()

Use the lcomp from filename_convert_dirfsp_rel()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agolibnet3: Fix Coverity ID 1034874 Resource leak
Volker Lendecke [Fri, 15 Nov 2024 10:17:42 +0000 (11:17 +0100)] 
libnet3: Fix Coverity ID 1034874 Resource leak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agontvfs: Fix Coverity ID 240792 Uninitialized scalar variable
Volker Lendecke [Thu, 14 Nov 2024 20:07:30 +0000 (21:07 +0100)] 
ntvfs: Fix Coverity ID 240792 Uninitialized scalar variable

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agontvfs: Fix Coverity ID 240791 Uninitialized scalar variable
Volker Lendecke [Thu, 14 Nov 2024 20:06:09 +0000 (21:06 +0100)] 
ntvfs: Fix Coverity ID 240791 Uninitialized scalar variable

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agontlm_auth: Fix Coverity ID 240750 Resource leak
Volker Lendecke [Thu, 14 Nov 2024 20:04:02 +0000 (21:04 +0100)] 
ntlm_auth: Fix Coverity ID 240750 Resource leak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agontlm_auth: Fix Coverity ID 240749 Resource leak
Volker Lendecke [Thu, 14 Nov 2024 20:03:02 +0000 (21:03 +0100)] 
ntlm_auth: Fix Coverity ID 240749 Resource leak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agontlm_auth: Fix Coverity ID 240748 Resource leak
Volker Lendecke [Thu, 14 Nov 2024 20:02:09 +0000 (21:02 +0100)] 
ntlm_auth: Fix Coverity ID 240748 Resource leak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agontlm_auth: Fix Coverity ID 240747 Resource leak
Volker Lendecke [Thu, 14 Nov 2024 20:00:07 +0000 (21:00 +0100)] 
ntlm_auth: Fix Coverity ID 240747 Resource leak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agontlm_auth: Fix Coverity ID 240743 Resource leak
Volker Lendecke [Thu, 14 Nov 2024 19:47:53 +0000 (20:47 +0100)] 
ntlm_auth: Fix Coverity ID 240743 Resource leak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agolibcli: Simplify debug_conditional_ace()
Volker Lendecke [Thu, 14 Nov 2024 19:52:03 +0000 (20:52 +0100)] 
libcli: Simplify debug_conditional_ace()

Move a variable declaration to its only user

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbpasswd4: Simplify smbpasswd_sethexpwd()
Volker Lendecke [Thu, 14 Nov 2024 19:48:14 +0000 (20:48 +0100)] 
smbpasswd4: Simplify smbpasswd_sethexpwd()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Early talloc_free in an error case
Volker Lendecke [Fri, 4 Oct 2024 11:39:18 +0000 (13:39 +0200)] 
smbd: Early talloc_free in an error case

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agolibsmb: Save some .data bytes with a const array
Volker Lendecke [Mon, 18 Nov 2024 11:20:19 +0000 (12:20 +0100)] 
libsmb: Save some .data bytes with a const array

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agotests: Use unix_mode_to_wire() in smb3unix tests
Volker Lendecke [Sat, 21 Sep 2024 01:38:24 +0000 (03:38 +0200)] 
tests: Use unix_mode_to_wire() in smb3unix tests

Also add the file type. Not really relevant in create, IMHO it looks
nicer in the code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Simplify smbd_do_qfilepathinfo()
Volker Lendecke [Thu, 2 Nov 2023 08:13:51 +0000 (09:13 +0100)] 
smbd: Simplify smbd_do_qfilepathinfo()

fdos_mode(fsp) unconditionally dereferences fsp, so we can get rid of
checking for fsp!=NULL.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: avoid a panic in close_directory()
Ralph Boehme [Mon, 18 Nov 2024 09:50:13 +0000 (10:50 +0100)] 
smbd: avoid a panic in close_directory()

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Nov 18 12:43:28 UTC 2024 on atb-devel-224

9 months agovfs: Remove files_struct->posix_flags
Volker Lendecke [Thu, 14 Nov 2024 19:26:57 +0000 (20:26 +0100)] 
vfs: Remove files_struct->posix_flags

I think this was missing from 2065f006560

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sat Nov 16 13:26:05 UTC 2024 on atb-devel-224

9 months agolibnet: Fix Coverity ID 1634803 Dereference after null check
Volker Lendecke [Thu, 14 Nov 2024 16:09:31 +0000 (17:09 +0100)] 
libnet: Fix Coverity ID 1634803 Dereference after null check

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Nov 14 18:29:46 UTC 2024 on atb-devel-224

9 months agoexamples:winexe: Initialize Trustee.ptstrName at the right time
Pavel Filipenský [Wed, 13 Nov 2024 08:49:47 +0000 (09:49 +0100)] 
examples:winexe: Initialize Trustee.ptstrName at the right time

This is a regression of a39cb60 examples:winexe: Fully initialize EXPLICIT_ACCESS

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Wed Nov 13 15:47:40 UTC 2024 on atb-devel-224

9 months agosmbd: Remove non_widelink_open()
Volker Lendecke [Mon, 21 Oct 2024 07:41:06 +0000 (09:41 +0200)] 
smbd: Remove non_widelink_open()

Better look at the final code, not at the patch. The idea is to call
filename_convert_dirfsp() from fd_openat() and just have one place to
follow symlinks.

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 19:21:11 UTC 2024 on atb-devel-224

9 months agosmbd: simplify openat_pathref_fullname()
Volker Lendecke [Tue, 8 Oct 2024 15:42:11 +0000 (17:42 +0200)] 
smbd: simplify openat_pathref_fullname()

We don't have to deal with stream opens anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agosmbd: simplify open_stream_pathref_fsp()
Volker Lendecke [Tue, 8 Oct 2024 15:40:41 +0000 (17:40 +0200)] 
smbd: simplify open_stream_pathref_fsp()

Looks more complex, but we don't have to go through all of
fd_openat()/non_widelink_open() for opening streams. SMB_VFS_OPENAT
knows how to deal with this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agopysmbd: Python code calls smbd code with "." and ".."
Volker Lendecke [Mon, 21 Oct 2024 13:45:47 +0000 (15:45 +0200)] 
pysmbd: Python code calls smbd code with "." and ".."

Soon we will call filename_convert_dirfsp() on these, which can't deal
with paths that are invalid by containing . and .. as path components.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agosmbd: Simplify filename_convert_dirfsp_nosymlink()
Volker Lendecke [Fri, 11 Oct 2024 10:46:53 +0000 (12:46 +0200)] 
smbd: Simplify filename_convert_dirfsp_nosymlink()

Looks more complex, but this avoids calling openat_pathref_fsp, which
eventually calls into non_widelink_open(). We need to open the pretty paranoid
SMB_ASSERT in openat_pathref_fsp_lcomp() a little bit.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agonet: filename_convert_dirfsp() needs mangling initialized
Volker Lendecke [Wed, 23 Oct 2024 15:09:04 +0000 (17:09 +0200)] 
net: filename_convert_dirfsp() needs mangling initialized

We'll call filename_convert_dirfsp() from a lot more places soon.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agosmbd: Add open_rootdir_pathref_fsp()
Volker Lendecke [Fri, 11 Oct 2024 12:56:21 +0000 (14:56 +0200)] 
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>
9 months agosmbd: Factor out filename_convert_dirfsp_rel()
Volker Lendecke [Fri, 11 Oct 2024 09:58:51 +0000 (11:58 +0200)] 
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>
9 months agosmbd: Fix following symlinks if basedir != cwd_fsp
Volker Lendecke [Wed, 23 Oct 2024 12:14:39 +0000 (14:14 +0200)] 
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>
9 months agosmbd: Slightly simplify filename_convert_dirfsp_nosymlink()
Volker Lendecke [Thu, 10 Oct 2024 08:16:14 +0000 (10:16 +0200)] 
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>
9 months agosmbd: Use OpenDir_from_pathref() in rmdir_internals()
Volker Lendecke [Wed, 9 Oct 2024 13:49:10 +0000 (15:49 +0200)] 
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>
9 months agosmbd: Use OpenDir_from_pathref() in can_delete_directory_fsp()
Volker Lendecke [Wed, 9 Oct 2024 11:36:00 +0000 (13:36 +0200)] 
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>
9 months agosmbd: Simplify OpenDir_from_pathref()
Volker Lendecke [Thu, 10 Oct 2024 15:16:02 +0000 (17:16 +0200)] 
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>
9 months agosmbd: Enable fd_openat(cwd_fsp, "/absolute/share/path")
Volker Lendecke [Sat, 19 Oct 2024 15:30:09 +0000 (17:30 +0200)] 
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>
9 months agosmbd: Tighten non_wide_link_open() for absolute root share open
Volker Lendecke [Sat, 19 Oct 2024 15:29:01 +0000 (17:29 +0200)] 
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>
9 months agosmbd: Ignore twrp in chdir_below_conn()
Volker Lendecke [Sun, 20 Oct 2024 12:41:55 +0000 (14:41 +0200)] 
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>
9 months agosmbd: Simplify filename_convert_dirfsp()
Volker Lendecke [Tue, 8 Oct 2024 13:51:06 +0000 (15:51 +0200)] 
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>
9 months agosmbd: Inline dup_file_fsp() into fcb_or_dos_open()
Volker Lendecke [Thu, 10 Oct 2024 14:34:50 +0000 (16:34 +0200)] 
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>
9 months agovfs: Don't ever call openat(-1, ...) for relative paths
Volker Lendecke [Mon, 21 Oct 2024 10:12:27 +0000 (12:12 +0200)] 
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

9 months agovfs: Only call openat for valid params in fake_acls_stat
Volker Lendecke [Mon, 11 Nov 2024 16:50:03 +0000 (17:50 +0100)] 
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>
9 months agovfs: Use the getwd-cache only if we have a valid tcon
Volker Lendecke [Mon, 11 Nov 2024 15:19:17 +0000 (16:19 +0100)] 
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>
9 months agovfs: Change the condition when to fill the getwd cache
Volker Lendecke [Mon, 11 Nov 2024 15:16:32 +0000 (16:16 +0100)] 
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>
9 months agosmbd: Don't print cwd before tcon is done
Volker Lendecke [Mon, 21 Oct 2024 10:20:55 +0000 (12:20 +0200)] 
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>
9 months agosmbd: Fix an error resource leak in OpenDir_from_pathref()
Volker Lendecke [Thu, 10 Oct 2024 15:14:10 +0000 (17:14 +0200)] 
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

9 months agolibsmb: Use SMB2_0_INFO_FILE instead of a simple "1"
Volker Lendecke [Tue, 1 Oct 2024 13:28:51 +0000 (15:28 +0200)] 
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>
9 months agosmbd: Simplify smbd_smb2_query_directory_send()
Volker Lendecke [Wed, 9 Oct 2024 05:35:26 +0000 (07:35 +0200)] 
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>
9 months agosmbd: reopen_from_fsp also works for full fsps
Volker Lendecke [Wed, 9 Oct 2024 07:30:12 +0000 (09:30 +0200)] 
smbd: reopen_from_fsp also works for full fsps

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agosmbd: Make reopen_from_fsp() public
Volker Lendecke [Wed, 9 Oct 2024 05:32:55 +0000 (07:32 +0200)] 
smbd: Make reopen_from_fsp() public

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agovfs: Fix streams_xattr_openat
Volker Lendecke [Wed, 9 Oct 2024 10:00:28 +0000 (12:00 +0200)] 
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>
9 months agovfs: Simplify streams_xattr_openat()
Volker Lendecke [Wed, 9 Oct 2024 09:59:58 +0000 (11:59 +0200)] 
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>
9 months agovfs: Convert streams_xattr_get_name() to return 0/errno
Volker Lendecke [Wed, 9 Oct 2024 09:17:20 +0000 (11:17 +0200)] 
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>
9 months agosmbd: Convert get_ea_value_fsp() to return 0/errno
Volker Lendecke [Wed, 9 Oct 2024 09:07:11 +0000 (11:07 +0200)] 
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>
9 months agosmbd: Convert refuse_symlink_fsp() to bool
Volker Lendecke [Wed, 9 Oct 2024 08:50:15 +0000 (10:50 +0200)] 
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>
9 months agosmbd: Simplify make_connection_snum()
Volker Lendecke [Fri, 11 Oct 2024 11:29:33 +0000 (13:29 +0200)] 
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>
9 months agopylibsmb: Add NFS reparse tag types
Volker Lendecke [Mon, 17 Jun 2024 15:02:09 +0000 (17:02 +0200)] 
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>
9 months agolibsmb: Fix a "cast increases required alignment" warning
Volker Lendecke [Tue, 1 Oct 2024 13:35:25 +0000 (15:35 +0200)] 
libsmb: Fix a "cast increases required alignment" warning

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agolibsmb: Fix trailing whitespace
Volker Lendecke [Wed, 25 Sep 2024 14:54:11 +0000 (16:54 +0200)] 
libsmb: Fix trailing whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agolsasrv: Simplify dcesrv_lsa_AddRemoveAccountRights()
Volker Lendecke [Fri, 20 Sep 2024 13:46:01 +0000 (15:46 +0200)] 
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>
9 months agolib: Simplify nybble_to_hex_*
Volker Lendecke [Tue, 10 Sep 2024 06:46:30 +0000 (08:46 +0200)] 
lib: Simplify nybble_to_hex_*

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agoldb: User hexchars_upper from replace.h
Volker Lendecke [Tue, 10 Sep 2024 08:02:04 +0000 (10:02 +0200)] 
ldb: User hexchars_upper from replace.h

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agolibreplace: Introduce hexchars_{upper|lower}
Volker Lendecke [Tue, 10 Sep 2024 06:45:31 +0000 (08:45 +0200)] 
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>
9 months agolibcli: Convert an int to a size_t
Volker Lendecke [Tue, 15 Oct 2024 11:46:05 +0000 (13:46 +0200)] 
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>
9 months agolib: Modernize a DEBUG
Volker Lendecke [Thu, 3 Oct 2024 09:04:15 +0000 (11:04 +0200)] 
lib: Modernize a DEBUG

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agoidl: Fix trailing whitespace
Volker Lendecke [Mon, 30 Sep 2024 10:55:25 +0000 (12:55 +0200)] 
idl: Fix trailing whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agolib: simplify smbpasswd_sethexpwd() with hex_encode_buf()
Volker Lendecke [Fri, 20 Sep 2024 13:17:33 +0000 (15:17 +0200)] 
lib: simplify smbpasswd_sethexpwd() with hex_encode_buf()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agolib: simplify smbpasswd_gethexpwd() with strhex_to_str()
Volker Lendecke [Fri, 20 Sep 2024 13:14:48 +0000 (15:14 +0200)] 
lib: simplify smbpasswd_gethexpwd() with strhex_to_str()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agolibcli: Try to fix CID 1609583 Overflowed constant
Volker Lendecke [Mon, 4 Nov 2024 17:26:43 +0000 (18:26 +0100)] 
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>
9 months agovfs_fruit: Align a few integer types
Volker Lendecke [Mon, 4 Nov 2024 17:19:48 +0000 (18:19 +0100)] 
vfs_fruit: Align a few integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
9 months agovfs_fruit: Simplify filter_empty_rsrc_stream()
Volker Lendecke [Mon, 4 Nov 2024 17:17:16 +0000 (18:17 +0100)] 
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>
9 months agolibndr: Early overflow detection
Volker Lendecke [Mon, 30 Sep 2024 13:45:16 +0000 (15:45 +0200)] 
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>
9 months agolibndr: Simplify data flow in ndr_push_relative_ptr2
Volker Lendecke [Mon, 30 Sep 2024 10:07:30 +0000 (12:07 +0200)] 
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>
9 months agolibgpo:admx:: s/the the\b/the/
Douglas Bagnall [Fri, 13 Sep 2024 02:23:12 +0000 (14:23 +1200)] 
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

9 months agolib/replace: memset_explicit() only takes three arguments
Thomas Klausner [Sun, 10 Nov 2024 07:37:17 +0000 (08:37 +0100)] 
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

9 months agoWHATSNEW: Add client netlogon ping protocol parameter
Volker Lendecke [Fri, 8 Nov 2024 15:39:42 +0000 (16:39 +0100)] 
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

9 months agotests: Run ad members with new netlogon ping protocol settings
Volker Lendecke [Wed, 6 Nov 2024 13:30:30 +0000 (14:30 +0100)] 
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>
9 months agolibcli: Make cldap_error_reply() static to cldap_server.c
Volker Lendecke [Fri, 1 Nov 2024 11:49:55 +0000 (12:49 +0100)] 
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>
9 months agolibcli: Remove two unused functions
Volker Lendecke [Fri, 1 Nov 2024 11:44:42 +0000 (12:44 +0100)] 
libcli: Remove two unused functions

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibnet: Simplify becomeDC
Volker Lendecke [Fri, 25 Oct 2024 12:53:09 +0000 (14:53 +0200)] 
libnet: Simplify becomeDC

Checking for "" does not need a call to strcmp

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agodocs: Fix a typo in a parameter file name
Volker Lendecke [Thu, 24 Oct 2024 14:44:09 +0000 (16:44 +0200)] 
docs: Fix a typo in a parameter file name

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibcli: Move "struct cldap_netlogon" definition to torture
Volker Lendecke [Fri, 1 Nov 2024 11:41:57 +0000 (12:41 +0100)] 
libcli: Move "struct cldap_netlogon" definition to torture

This structure is only used in torture/ldap/netlogon.c now for
historic reasons. Replacing it with something else would be the right
thing to do...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibcli: Remove cldap_netlogon() and friends
Volker Lendecke [Fri, 1 Nov 2024 11:39:58 +0000 (12:39 +0100)] 
libcli: Remove cldap_netlogon() and friends

Replaced with netlogon_pings()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agotorture4: Replace direct netlogon ping calls with netlogon_pings()
Volker Lendecke [Fri, 1 Nov 2024 11:36:59 +0000 (12:36 +0100)] 
torture4: Replace direct netlogon ping calls with netlogon_pings()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agotorture4: Add ldap.netlogon-ping test
Volker Lendecke [Fri, 1 Nov 2024 09:07:16 +0000 (10:07 +0100)] 
torture4: Add ldap.netlogon-ping test

This will supersede the direct cldap based netlogon tests

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agotorture4: Use netlogon_pings() in rpc.lsa tests
Volker Lendecke [Wed, 30 Oct 2024 17:22:57 +0000 (18:22 +0100)] 
torture4: Use netlogon_pings() in rpc.lsa tests

Allow LDAPS netlogon ping

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agotorture4: Use netlogon_pings_send/recv in bench-cldap
Volker Lendecke [Thu, 31 Oct 2024 17:05:00 +0000 (18:05 +0100)] 
torture4: Use netlogon_pings_send/recv in bench-cldap

This slightly changes behaviour: It uses separate client sockets per
ping instead of just one, but it allows to compare CLDAP with LDAP and
LDAPS (spoiler: LDAPS is *much* slower...)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibnet4: Use netlogon_pings() in finddcs_cldap
Volker Lendecke [Tue, 29 Oct 2024 14:35:37 +0000 (15:35 +0100)] 
libnet4: Use netlogon_pings() in finddcs_cldap

Enable LDAPS lookups

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibnet4: Use netlogon_pings() in unbecome_dc
Volker Lendecke [Tue, 29 Oct 2024 12:06:13 +0000 (13:06 +0100)] 
libnet4: Use netlogon_pings() in unbecome_dc

Enable LDAPS lookups

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibnet4: Use netlogon_pings() in become_dc
Volker Lendecke [Tue, 29 Oct 2024 11:43:53 +0000 (12:43 +0100)] 
libnet4: Use netlogon_pings() in become_dc

Allow LDAPS netlogon pings

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibnet4: Use netlogon_pings() in findsite
Volker Lendecke [Tue, 29 Oct 2024 11:12:57 +0000 (12:12 +0100)] 
libnet4: Use netlogon_pings() in findsite

Enable LDAPS lookups

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibnet: Initialize variables in libnet_FindSite()
Volker Lendecke [Mon, 28 Oct 2024 12:52:30 +0000 (13:52 +0100)] 
libnet: Initialize variables in libnet_FindSite()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibnet: Simplify error return in libnet_FindSite()
Volker Lendecke [Mon, 28 Oct 2024 07:58:54 +0000 (08:58 +0100)] 
libnet: Simplify error return in libnet_FindSite()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibnet: Save a few lines with talloc_move()
Volker Lendecke [Mon, 28 Oct 2024 07:55:33 +0000 (08:55 +0100)] 
libnet: Save a few lines with talloc_move()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibads: Move check_cldap_reply_required_flags() to netlogon_ping.c
Volker Lendecke [Mon, 28 Oct 2024 14:01:57 +0000 (15:01 +0100)] 
libads: Move check_cldap_reply_required_flags() to netlogon_ping.c

netlogon_ping.c depends on it but itself has fewer dependencies than
cldap.c, so we can use it in more places

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibads: Simplify ads_fill_cldap_reply()
Volker Lendecke [Mon, 28 Oct 2024 12:20:56 +0000 (13:20 +0100)] 
libads: Simplify ads_fill_cldap_reply()

Both callers now guarantee via the filter in netlogon_pings() that the
reply contains DCs that have the required flags set. Remove those
checks from ads_fill_cldap_reply()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 months agolibads: Pass "required_flags" through ads_cldap_netlogon_5()
Volker Lendecke [Mon, 28 Oct 2024 12:19:08 +0000 (13:19 +0100)] 
libads: Pass "required_flags" through ads_cldap_netlogon_5()

... down to netlogon_pings(). Passing 0 right now, this will change
for some callers

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>