]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
8 months agosmbd: move calling fsctl_get_reparse_tag() into smb3_file_posix_information_init()
Ralph Boehme [Wed, 27 Nov 2024 14:27:14 +0000 (15:27 +0100)] 
smbd: move calling fsctl_get_reparse_tag() into smb3_file_posix_information_init()

This already fixes SMB2-GETINFO with POSIX infolevel to return the reparse tag
of reparse points.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agosmbd: simplify smb3_file_posix_information_init()
Ralph Boehme [Tue, 26 Nov 2024 06:49:15 +0000 (07:49 +0100)] 
smbd: simplify smb3_file_posix_information_init()

The dos attributes are already setup by fdos_mode(). Still assert
FILE_ATTRIBUTE_REPARSE_POINT is correctly set just in case.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agosmbd: fix DOS attributes for reparse points in fdos_mode()
Ralph Boehme [Tue, 26 Nov 2024 17:21:32 +0000 (18:21 +0100)] 
smbd: fix DOS attributes for reparse points in fdos_mode()

Reparse have only FILE_ATTRIBUTE_REPARSE_POINT set, but never
FILE_ATTRIBUTE_NORMAL or FILE_ATTRIBUTE_DIRECTORY at the same time.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agotests: test POSIX file type on reparse point
Ralph Boehme [Wed, 27 Nov 2024 14:14:32 +0000 (15:14 +0100)] 
tests: test POSIX file type on reparse point

Create a symlink reparse point over SMB2. Then query file info over SMB2 and
check the POSIX file type is correctly assigned in the POSIX info levels.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agotests: check reparse tag and POSIX file type from query-file with POSIX infolevel
Ralph Boehme [Tue, 26 Nov 2024 13:54:29 +0000 (14:54 +0100)] 
tests: check reparse tag and POSIX file type from query-file with POSIX infolevel

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agotests: fix test teardown/cleanup of test_create_reparse_directory()
Ralph Boehme [Tue, 26 Nov 2024 16:06:06 +0000 (17:06 +0100)] 
tests: fix test teardown/cleanup of test_create_reparse_directory()

This kept failing in a local make test not being able to cleanup the test
directory in the *subsequent* test test_create_reparse_nonempty_directory().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agotests: prepare reparsepoints.py for using POSIX on the SMB2 connection
Ralph Boehme [Tue, 26 Nov 2024 13:53:45 +0000 (14:53 +0100)] 
tests: prepare reparsepoints.py for using POSIX on the SMB2 connection

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agotests: move wire_mode_to_unix() to libsmb.py
Ralph Boehme [Tue, 26 Nov 2024 13:52:52 +0000 (14:52 +0100)] 
tests: move wire_mode_to_unix() to libsmb.py

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agopylibsmb: implement getinfo level FSCC_FILE_POSIX_INFORMATION
Ralph Boehme [Fri, 22 Nov 2024 18:39:22 +0000 (19:39 +0100)] 
pylibsmb: implement getinfo level FSCC_FILE_POSIX_INFORMATION

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agosmbd: rename SMB2_FS_POSIX_INFORMATION to FSCC_FS_POSIX_INFORMATION
Ralph Boehme [Tue, 26 Nov 2024 19:00:01 +0000 (20:00 +0100)] 
smbd: rename SMB2_FS_POSIX_INFORMATION to FSCC_FS_POSIX_INFORMATION

Streamline the info-level defines. Also get rid of
SMB2_FS_POSIX_INFORMATION_INTERNAL which is not needed for an info-level that
is exclusive to SMB2.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agosmbd: rename SMB2_FILE_POSIX_INFORMATION to FSCC_FILE_POSIX_INFORMATION
Ralph Boehme [Tue, 26 Nov 2024 18:44:13 +0000 (19:44 +0100)] 
smbd: rename SMB2_FILE_POSIX_INFORMATION to FSCC_FILE_POSIX_INFORMATION

Streamline the info-level defines. Also get rid of
SMB2_FILE_POSIX_INFORMATION_INTERNAL which is not needed for an info-level that
is exclusive to SMB2.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agosmbd: use NT_PASSTHROUGH_OFFSET in a few places
Ralph Boehme [Tue, 26 Nov 2024 18:32:00 +0000 (19:32 +0100)] 
smbd: use NT_PASSTHROUGH_OFFSET in a few places

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 months agogitlab-ci: Fix building debian 32bit images
Andreas Schneider [Tue, 26 Nov 2024 18:38:40 +0000 (19:38 +0100)] 
gitlab-ci: Fix building debian 32bit images

Trying to pull registry-1.docker.io/i386/debian:12...
Error: creating build container: choosing an image from manifest list
docker://registry-1.docker.io/i386/debian:12: no image found in image index for
architecture "amd64", variant "", OS "linux"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Nov 27 16:32:07 UTC 2024 on atb-devel-224

8 months agogitlab-ci: Move to Fedora 41
Andreas Schneider [Wed, 20 Nov 2024 14:43:13 +0000 (15:43 +0100)] 
gitlab-ci: Move to Fedora 41

Python 3.13 removed the `crypt` module. I can work around it on Fedora 41, but
we need to address this better sooner than later.

See also https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agoselftest: Allow to use SHA1 with OpenSSL for selftest
Andreas Schneider [Wed, 27 Nov 2024 10:17:27 +0000 (11:17 +0100)] 
selftest: Allow to use SHA1 with OpenSSL for selftest

This is needed for samba.tests.krb5.pkinit_tests with sha1.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agopython: Fix length of Common Name x509 attribute
Andreas Schneider [Wed, 27 Nov 2024 09:15:45 +0000 (10:15 +0100)] 
python: Fix length of Common Name x509 attribute

File "bin/python/samba/tests/krb5/pkinit_tests.py", line 1496, in
create_certificate
  x509.NameAttribute(NameOID.COMMON_NAME,
  ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
                     f'{cert_name}/emailAddress={cert_name}'),
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.13/site-packages/cryptography/x509/name.py",
line 152, in __init__
  raise ValueError(msg)
ValueError: Attribute's length must be >= 1 and <= 64, but it was 84

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agoautobuild: Run the samba-minimal-smbd build jobs with -j 2
Volker Lendecke [Mon, 25 Nov 2024 15:34:06 +0000 (16:34 +0100)] 
autobuild: Run the samba-minimal-smbd build jobs with -j 2

samba-minimal-smbd is now always the slowest job by many
minutes. There's no timeouts to be expected, so run them with nice -n
19.

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): Tue Nov 26 12:38:17 UTC 2024 on atb-devel-224

8 months agolibndr: Add overflow check to ndr_push_subcontext_end()
Volker Lendecke [Mon, 25 Nov 2024 14:08:26 +0000 (15:08 +0100)] 
libndr: Add overflow check to ndr_push_subcontext_end()

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 25 15:36:07 UTC 2024 on atb-devel-224

8 months agotests: Check symlinks are readable as reparse points
Volker Lendecke [Wed, 17 May 2023 08:54:49 +0000 (10:54 +0200)] 
tests: Check symlinks are readable as reparse points

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): Fri Nov 22 11:05:33 UTC 2024 on atb-devel-224

8 months agosmbd: Return NT_STATUS_STOPPED_ON_SYMLINK
Volker Lendecke [Wed, 20 Nov 2024 11:56:33 +0000 (12:56 +0100)] 
smbd: Return NT_STATUS_STOPPED_ON_SYMLINK

Do this for "follow symlinks = now" and smb2 unix extensions

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Always init symlink_err in filename_convert_dirfsp_nosymlink()
Volker Lendecke [Wed, 20 Nov 2024 11:54:05 +0000 (12:54 +0100)] 
smbd: Always init symlink_err in filename_convert_dirfsp_nosymlink()

Make sure that we don't leave symlink_err in the caller
uninitialized.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Create the proper error blob for STOPPED_ON_SYMLINK
Volker Lendecke [Wed, 20 Nov 2024 10:13:12 +0000 (11:13 +0100)] 
smbd: Create the proper error blob for STOPPED_ON_SYMLINK

Unused so far, our lowerlevel routines so far never return
NT_STATUS_STOPPED_ON_SYMLINK. Also see the NULL passed as
"symlink_reparse", this will change soon. Separate patch for easier
review.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Prepare smbd_smb2_create_recv() to return a symlink error
Volker Lendecke [Wed, 20 Nov 2024 12:18:25 +0000 (13:18 +0100)] 
smbd: Prepare smbd_smb2_create_recv() to return a symlink error

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agotests: Fix test_symlinkerror_absolute_inshare
Volker Lendecke [Tue, 16 May 2023 15:32:28 +0000 (17:32 +0200)] 
tests: Fix test_symlinkerror_absolute_inshare

This tests converting an absolute into a relative target. Reflect that
in the flags expected from the STOPPED_ON_SYMLINK error response.

As of this patch it's still knownfail, so irrelevant. But soon this test will
succeed.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agotests: Reparse point dirs are shown as REPARSE_POINT|DIRECTORY
Volker Lendecke [Mon, 9 Jan 2023 17:30:05 +0000 (18:30 +0100)] 
tests: Reparse point dirs are shown as REPARSE_POINT|DIRECTORY

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agotests: Reparse point files are shown as FILE_ATTRIBUTE_REPARSE_POINT
Volker Lendecke [Mon, 9 Jan 2023 17:24:23 +0000 (18:24 +0100)] 
tests: Reparse point files are shown as FILE_ATTRIBUTE_REPARSE_POINT

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Allow a symlink as lcomp when asking for REPARSE_POINT
Volker Lendecke [Wed, 20 Nov 2024 11:02:54 +0000 (12:02 +0100)] 
smbd: Allow a symlink as lcomp when asking for REPARSE_POINT

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Fix the turning an absolute symlink into a relative one
Volker Lendecke [Sun, 4 Feb 2024 10:45:22 +0000 (11:45 +0100)] 
smbd: Fix the turning an absolute symlink into a relative one

If dirfsp is the share root, we end up with a "/." at the end of
subdir_path. subdir_of() does not cover that case. fsp_fullbasepath()
takes care of that case and also avoids a talloc.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Set fsp->fsp_flags.posix_open in openat_pathref_fsp_lcomp()
Volker Lendecke [Wed, 31 Jan 2024 18:48:48 +0000 (19:48 +0100)] 
smbd: Set fsp->fsp_flags.posix_open in openat_pathref_fsp_lcomp()

Not sure why this wasn't caught as a bug yet...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Allow symlinks to be read via GET_REPARSE_POINT
Volker Lendecke [Wed, 21 Dec 2022 15:42:12 +0000 (16:42 +0100)] 
smbd: Allow symlinks to be read via GET_REPARSE_POINT

... to be used soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agosmbd: Prepare fdos_mode() for handling symlinks in smb2
Volker Lendecke [Tue, 19 Nov 2024 14:35:58 +0000 (15:35 +0100)] 
smbd: Prepare fdos_mode() for handling symlinks in smb2

We should show all special files as NORMAL|REPARSE_POINT, except
symlinks for SMB1 Posix Extensions. IFREG and IFDIR are handled via
our xattr mechanisms.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agolibsmb: Retry the open with OPEN_REPARSE_POINT on IO_REPARSE_TAG_NOT_HANDLED
Volker Lendecke [Wed, 3 May 2023 14:44:34 +0000 (16:44 +0200)] 
libsmb: Retry the open with OPEN_REPARSE_POINT on IO_REPARSE_TAG_NOT_HANDLED

If we get that error message, we want to look at the reparse point as
such. This does not affect normal files, but soon we will need it in
our tests.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
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

8 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

8 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

8 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

8 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

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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

8 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>
8 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>
8 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>
8 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>
8 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

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>