]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
9 months agotests: use libsmb.unix_mode_to_wire() in smb3unix.py
Ralph Boehme [Thu, 5 Dec 2024 09:20:00 +0000 (10:20 +0100)] 
tests: use libsmb.unix_mode_to_wire() in smb3unix.py

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agotests: use clean_file() from our superclass in smb3unix.py
Ralph Boehme [Mon, 11 Nov 2024 09:38:05 +0000 (10:38 +0100)] 
tests: use clean_file() from our superclass in smb3unix.py

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agopylibsmb: add "copy_chunk"
Ralph Boehme [Mon, 11 Nov 2024 07:06:13 +0000 (08:06 +0100)] 
pylibsmb: add "copy_chunk"

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbtorture: verify Windows SEC_FILE_APPEND_DATA behaviour
Ralph Boehme [Sat, 9 Nov 2024 15:00:39 +0000 (16:00 +0100)] 
smbtorture: verify Windows SEC_FILE_APPEND_DATA behaviour

This test proves that Windows will not enforce append behaviour when using
SEC_FILE_APPEND_DATA: writing with an offset and length into existing data is
not mapped to an append operation. According to

https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntcreatefile

Windows internal APIs seemt to support append-IO:

  If only the FILE_APPEND_DATA and SYNCHRONIZE flags are set, the caller can
  write only to the end of the file, and any offset information on writes to the
  file is ignored. However, the file is automatically extended as necessary for
  this type of write operation.

...but at least over SMB2 it doesn't work.

This also demonstrates that Windows behaves as documented in the footnote in

MS-SMB2 3.3.5.13 "Receiving an SMB2 WRITE Request":

  If the range being written to is within the existing file size and
  Open.GrantedAccess does not include FILE_WRITE_DATA, or if the range being
  written to extends the file size and Open.GrantedAccess does not include
  FILE_APPEND_DATA, the server SHOULD<358> fail the request with
  STATUS_ACCESS_DENIED.

MS-SMB2 <358> Section 3.3.5.13:

  Windows SMB2 servers allow the operation when either FILE_APPEND_DATA or
  FILE_WRITE_DATA is set in Open.GrantedAccess.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
9 months agosmbd: fix an invalid memory access
Ralph Boehme [Fri, 22 Nov 2024 09:21:14 +0000 (10:21 +0100)] 
smbd: fix an invalid memory access

This was introduced by f86208d272cfa0ce6753b02d3f5b1cce4fd91e2e:

==47833== Invalid read of size 1
==47833==    at 0x4846782: strlen (vg_replace_strmem.c:494)
==47833==    by 0x4F9D257: __vfprintf_internal (vfprintf-process-arg.c:397)
==47833==    by 0x4FBD3A5: __vasprintf_internal (vasprintf.c:57)
==47833==    by 0x4EBDFFD: __dbgtext_va (debug.c:1939)
==47833==    by 0x4EBE125: dbgtext (debug.c:1960)
==47833==    by 0x49A9E77: exit_server_common (server_exit.c:230)
==47833==    by 0x49A9EE6: smbd_exit_server_cleanly (server_exit.c:247)
==47833==    by 0x4ECA2EF: exit_server_cleanly (smbd_shim.c:113)
==47833==    by 0x495E72B: smbd_server_connection_terminate_done (smb2_server.c:1758)
==47833==    by 0x4D4ED6A: _tevent_req_notify_callback (tevent_req.c:177)
==47833==    by 0x4D4EEFB: tevent_req_finish (tevent_req.c:234)
==47833==    by 0x4D4F02A: tevent_req_trigger (tevent_req.c:291)
==47833==  Address 0xb8cf820 is 96 bytes inside a block of size 123 free'd
==47833==    at 0x484317B: free (vg_replace_malloc.c:872)
==47833==    by 0x4CF8950: _tc_free_internal (talloc.c:1222)
==47833==    by 0x4CF993E: _tc_free_children_internal (talloc.c:1669)
==47833==    by 0x4CF8830: _tc_free_internal (talloc.c:1184)
==47833==    by 0x4CF993E: _tc_free_children_internal (talloc.c:1669)
==47833==    by 0x4CF8830: _tc_free_internal (talloc.c:1184)
==47833==    by 0x4CF89F7: _talloc_free_internal (talloc.c:1248)
==47833==    by 0x4CF9D93: _talloc_free (talloc.c:1792)
==47833==    by 0x495E700: smbd_server_connection_terminate_done (smb2_server.c:1748)
==47833==    by 0x4D4ED6A: _tevent_req_notify_callback (tevent_req.c:177)
==47833==    by 0x4D4EEFB: tevent_req_finish (tevent_req.c:234)
==47833==    by 0x4D4F02A: tevent_req_trigger (tevent_req.c:291)
==47833==  Block was alloc'd at
==47833==    at 0x48407B4: malloc (vg_replace_malloc.c:381)
==47833==    by 0x4CF7CAC: __talloc_with_prefix (talloc.c:783)
==47833==    by 0x4CF7E46: __talloc (talloc.c:825)
==47833==    by 0x4CFB007: __talloc_strlendup (talloc.c:2454)
==47833==    by 0x4CFB0BD: talloc_strdup (talloc.c:2470)
==47833==    by 0x495E7B6: smbd_server_connection_terminate_ex (smb2_server.c:1775)
==47833==    by 0x4969222: smbd_smb2_connection_handler (smb2_server.c:5291)
==47833==    by 0x4D4CAE2: tevent_common_invoke_fd_handler (tevent_fd.c:174)
==47833==    by 0x4D596D5: epoll_event_loop (tevent_epoll.c:696)
==47833==    by 0x4D59E5E: epoll_event_loop_once (tevent_epoll.c:926)
==47833==    by 0x4D5529C: std_event_loop_once (tevent_standard.c:110)
==47833==    by 0x4D4B3B9: _tevent_loop_once (tevent.c:820)
==47833==

state was a child of "xconn", so when xconn was freed state went away.

As reason is used at the very end of exit_server_common() after *all* global
objects that could be used as talloc parent are freed, there's just no other way
to make "reason" a talloc string then allocating it from the NULL context right
away.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
10 months agofruit: fixup size_t overflow check
Michael Tokarev [Thu, 17 Nov 2022 20:51:03 +0000 (23:51 +0300)] 
fruit: fixup size_t overflow check

https://bugzilla.samba.org/show_bug.cgi?id=13622 .
The check ('bandsize > SIZE_MAX/nbands' is wrong, since
it caps the total size to the wrong data type size_t
instead of off_t -- samba is always built with LFS support
so off_t is always 64bits, while size_t is 32bit son a
32bit platform.  This has caused issues already, capping
size of the bands: https://bugs.debian.org/974868 .

Since there's another overflow check already, let's just
fold this one to the following one and log a more complete
error message.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Sat Jan  4 20:47:35 UTC 2025 on atb-devel-224

10 months agos3:vfs_fruit: Fix crash for nbands == 0
Pavel Filipenský [Thu, 2 Jan 2025 17:25:22 +0000 (18:25 +0100)] 
s3:vfs_fruit: Fix crash for nbands == 0

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
10 months agotorture:fruit: Test timemachine for 0 bands
Pavel Filipenský [Thu, 2 Jan 2025 17:32:40 +0000 (18:32 +0100)] 
torture:fruit: Test timemachine for 0 bands

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
10 months agoinclude <grp.h> for setgroups in a few places
Michael Tokarev [Fri, 29 Nov 2024 06:34:42 +0000 (09:34 +0300)] 
include <grp.h> for setgroups in a few places

setgroups(), unlike getgroups(), is not in <unistd.h> but in <grp.h>.
Recent compilers require function declaration before using a function
(or more and more distributions treat lack of declaration as error),
so all configure-time tests fails with source3/lib/util_sec.c:

source3/../lib/util/setid.c: In function 'samba_setgroups':
source3/../lib/util/setid.c:244:16: error: implicit declaration of function \
  'setgroups'; did you mean 'getgroups'? [-Wimplicit-function-declaration]
  244 |         return setgroups(setlen, gidset);

Add the missing include so configuration finds the existing system
functions instead of failing.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Thu Jan  2 17:58:50 UTC 2025 on atb-devel-224

10 months agoremove usage of bzero
Michael Tokarev [Mon, 18 Nov 2024 12:00:05 +0000 (15:00 +0300)] 
remove usage of bzero

bzero() function has been deprecated for a long time.
In samba it is replaced with memset().  But samba also
provides common memory-zeroing macros, like ZERO_STRUCT().
In all places where bzero() is used, it actually meant to
zero a structure or an array.

So replace these bzero() calls with ZERO_STRUCT() or
ZERO_ARRAY() as appropriate, and remove bzero() replacement
and testing entirely.

While at it, also stop checking for presence of memset() -
this function is standard for a very long time, and the
only conditional where HAVE_MEMSET were used, was to
provide replacement for bzero() - in all other places
memset() is used unconditionally.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agoreplace direct calls to memset_s() with commonly used macros
Michael Tokarev [Mon, 18 Nov 2024 11:19:54 +0000 (14:19 +0300)] 
replace direct calls to memset_s() with commonly used macros

samba provides macros for zeroing various structures in memory,
and all code uses them instead of relying on memset_s().
However, a few places use memset_s() directly.  Replace these
usages with macros for consistency and to be able to replace
memset_s() easier.

A few notes.

Commit 03a50d8f7d872b6ef701d12 "lib:util: Check memset_s() error
code in talloc_keep_secret_destructor()" (Aug-2022) added a check
for error return from memset_s().  This is the only place in whole
codebase which bothers about doing this.  But I've difficult time
figuring out the intention.  Was there a real case when this code
path is actually executed?

Commit 7658c9bf0a9c99e3f200571 "lib:crypto: Remove redundant array
zeroing" (Nov-2023) removed the OTHER line from the two lines used
to zero memory in here.  Initially the code used both memset_s()
*and* ZERO_ARRAY_LEN(), the former has been removed.  This change
removes the other - memset_s(), reintroducing ZERO_ARRAY_LEN().
Here however, it's probably better to use BURN_PTR instead of
ZERO_ARRAY - in this place and a few lines above.

Commit 8dddea2ceda40f2365bd6b1 "lib:talloc: Use memset_s() to avoid
the call gets optimized out" (Feb-2024) is a recent commit which
introduces memset_s().  However, it does not seem like it makes
any difference whatsoever for a testsuite, or that it actually
needs to clean up the memory to begin with.

We've quite an assortment of all this memory zeroing stuff.  Also
it is repeated in replace.h and memory.h (two sets in these files
are different but has big intersection).  I'd say, to fix this mess,
things from replace.h should be removed in favour of memory.h, and
necessary includes added, but this is for the next time.  We also
have lots of direct usages of memset_s() in heimdal code.

Cc: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agotestparm: do not fail if /run/samba does not exist
Michael Tokarev [Tue, 26 Apr 2022 13:14:38 +0000 (16:14 +0300)] 
testparm: do not fail if /run/samba does not exist

testparm explicitly fails if $piddir or $lockdir does not exist.
However, the daemons which actually use these directories, will
create it on demand, there is no need to fail even simple testparm
operations if the dirs are not there.

This change lets to (pre)configure samba without bothering to
pre-create the directories which are overwise needed only to fulfil
testparm criteria.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agoMinimal EDNS0 support for built-in DNS client
Michael Tokarev [Mon, 26 Feb 2024 11:15:00 +0000 (14:15 +0300)] 
Minimal EDNS0 support for built-in DNS client

Currently, samba built-in DNS client is UDP-only (it does
support TCP mode, but not all components use it).  In
particular, when winbind queries list of AD DCs (SRV
record) which can be quite large, it uses UDP-only query.
And at the same time, samba DNS client does not support
EDNS0 at all, so the reply is limited to standard DNS
packet size which is 512 bytes.

Add minimal EDNS0 OPT record to ADDITIONAL section when
sending a DNS request out, indicating we can accept
DNS packets up to 4Kb in size.

Since DNSSEC is in wide use today and DNSSEC requires
EDNS0, it is okay to assume ENDS0 is widely supported
these days, so there should be no regressions when
enabling EDNS0.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agopasschange: error message fix
Michael Tokarev [Mon, 26 Feb 2024 12:35:35 +0000 (15:35 +0300)] 
passchange: error message fix

Missing space and newline.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosilence "Can not convert group sid" warnings in the log
Michael Tokarev [Wed, 14 Feb 2024 12:26:29 +0000 (15:26 +0300)] 
silence "Can not convert group sid" warnings in the log

/var/log/samba/log.winbind is full of messages like:

[2024/02/09 06:25:04.788182,  1, pid=74620] source3/winbindd/winbindd_getgroups.c:259(winbindd_getgroups_recv)
  Could not convert sid S-0-0: NT_STATUS_NONE_MAPPED

On a busy server these are logged several 1000s times per minute,
making any other messages basically invisible.

This is a work-around, a proper solution is to handle some
special SIDs (like this one) separately.  Once this is done,
this change can be reverted.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosilence DNS lookup mismatch messages
Michael Tokarev [Mon, 23 Dec 2024 20:26:52 +0000 (23:26 +0300)] 
silence DNS lookup mismatch messages

There's just too much useless noise in the logs,
especially when the PTR record just doesn't exist.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibsamba-errors: eliminate dependency on samba-debug
Michael Tokarev [Mon, 18 Nov 2024 09:45:08 +0000 (12:45 +0300)] 
libsamba-errors: eliminate dependency on samba-debug

libsamba-errors is a collection of error codes/descriptions
like strerror(), - it is a set of simple functions converting
error code to string or the like.  However, in one single
place there's a DBG_DEBUG() "call" in errmap_unix.c, in
map_errno_from_nt_status(), which is here for a very long time
(since before samba3, initially with debug level 10).

Drop this debugging info, and eliminate extra dependency.
This makes libsamba-errors independent and self-contained,
with a well-known and stable ABI.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agospecify some deps on private libs actually used directly
Michael Tokarev [Thu, 19 May 2022 17:37:21 +0000 (20:37 +0300)] 
specify some deps on private libs actually used directly

Lots of samba libraries has incomplete dependencies listed
in wscript files.  This usually is not a problem since the
link line includes dependencies of their dependencies of
their dependencies, and somewhere down that line all immediate
dependencies which are missing are actually present.  But
sometimes this becomes a problem when a library does not
declare direct dependency on at least one private library
which it actually uses: in case no private library is
listed as direct dependency, private library directory is
not put into RUNPATH of the resulting binary, so the binary
can not find its own dependencies.

Fix a few such places, including some libraries which are
a part of public abi (libsmbldap, libndr).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agoHappy New Year 2025!
Stefan Metzmacher [Wed, 1 Jan 2025 07:36:35 +0000 (07:36 +0000)] 
Happy New Year 2025!

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jan  1 19:16:03 UTC 2025 on atb-devel-224

10 months agoldb: fix Coverity 1636883
Douglas Bagnall [Mon, 23 Dec 2024 00:07:40 +0000 (13:07 +1300)] 
ldb: fix Coverity 1636883

oops.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Mon Dec 30 04:17:46 UTC 2024 on atb-devel-224

10 months agoutil:datablob: data_blob_pad checks its alignment assumption
Douglas Bagnall [Wed, 11 Dec 2024 01:31:18 +0000 (14:31 +1300)] 
util:datablob: data_blob_pad checks its alignment assumption

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Dec 20 07:59:51 UTC 2024 on atb-devel-224

10 months agobootstrap: we don't need python-crypt-r anymore
Douglas Bagnall [Wed, 11 Dec 2024 21:35:02 +0000 (10:35 +1300)] 
bootstrap: we don't need python-crypt-r anymore

Recent commits made pyglue wrap the same crypt[_r] that dsdb modules
use, which removes an extenal dependency.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agopytest: password_hash uses internal _glue.crypt
Douglas Bagnall [Wed, 11 Dec 2024 21:46:16 +0000 (10:46 +1300)] 
pytest: password_hash uses internal _glue.crypt

This will remove an external dependency.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agosamba-tool user: hashlib.sha1 is always present
Douglas Bagnall [Wed, 11 Dec 2024 02:56:20 +0000 (15:56 +1300)] 
samba-tool user: hashlib.sha1 is always present

We maybe thought we were checking that sha1 was in hashlib, but we were
only checking that hashlib is in the Python library (`hashlib.sha1()`
would not raise ImportError).

The documentation says hashlib always contains sha1 -- if that
changes, it is better we know by failing noisily with the import error
at the top of the file.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agosamba-tool user: use _glue.crypt, not crypt.crypt
Douglas Bagnall [Wed, 11 Dec 2024 02:54:48 +0000 (15:54 +1300)] 
samba-tool user: use _glue.crypt, not crypt.crypt

Because we know we have _glue.crypt, and we know it raises exceptions
rather than returning None, we can simplify the checks.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agopytest: test that _glue.crypt works
Douglas Bagnall [Wed, 11 Dec 2024 21:44:07 +0000 (10:44 +1300)] 
pytest: test that _glue.crypt works

The test vectors were generated via Python 3.10 crypt module, which
directly wraps crypt(3), which in this case is from glibc 2.39-0ubuntu8.3.

We mainly test the sha256 and sha512 vectors, which seems to be all we
use, and which are said to be widely supported.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agopyglue: add crypt() function
Douglas Bagnall [Wed, 11 Dec 2024 01:30:15 +0000 (14:30 +1300)] 
pyglue: add crypt() function

This wraps talloc_crypt_blob() from lib/util/util_crypt.c which in
turn wraps the system crypt[_r[n]].

We want this because the Python standard library crypt module is going
away. That one also wrapped the system crypt or crypt_r, so there
should be no change.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoutil: add a crypt strerror helper
Douglas Bagnall [Wed, 11 Dec 2024 01:30:04 +0000 (14:30 +1300)] 
util: add a crypt strerror helper

This will be used by Python also.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agodsdb:password_hash: use talloc_crypt_blob()
Douglas Bagnall [Wed, 11 Dec 2024 22:16:22 +0000 (11:16 +1300)] 
dsdb:password_hash: use talloc_crypt_blob()

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agodsdb:password_hash: move hash_blob allocation up
Douglas Bagnall [Wed, 11 Dec 2024 01:29:21 +0000 (14:29 +1300)] 
dsdb:password_hash: move hash_blob allocation up

This will make the next patch simpler.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoutil: add a crypt wrapper, derived from dsdb:password_hash
Douglas Bagnall [Thu, 5 Dec 2024 03:35:51 +0000 (16:35 +1300)] 
util: add a crypt wrapper, derived from dsdb:password_hash

This is going to be used by the dsdb password_hash module, and exposed
to Python via pyglue.

We're doing this because Python 3.13 has dropped crypt from the Python
standard library.

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

Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agosamba-tool: no traceback for unauthenticated rootdse access
Douglas Bagnall [Mon, 29 Jul 2024 21:53:14 +0000 (09:53 +1200)] 
samba-tool: no traceback for unauthenticated rootdse access

Under some circumstances rootdse returns an operations error with
"Operation unavailable without authentication" instead of insufficient
access rights.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Fri Dec 20 00:00:02 UTC 2024 on atb-devel-224

10 months agoldb:dn_compare_base: avoid unlikely int overflow
Douglas Bagnall [Thu, 22 Aug 2024 22:14:04 +0000 (10:14 +1200)] 
ldb:dn_compare_base: avoid unlikely int overflow

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoldb:dn_compare: be a bit more transitive
Douglas Bagnall [Thu, 22 Aug 2024 22:17:17 +0000 (10:17 +1200)] 
ldb:dn_compare: be a bit more transitive

If neither dn can casefold, they should be considered equal. Otherwise
cmp(dn1, dn2) will be inconsistent with cmp(dn2, dn1).

These will still sort to the end of the list, relative to any valid
DNs.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoldb:kv_cache: s/ltdb/ldb_kv/ in comments and messages
Douglas Bagnall [Thu, 22 Aug 2024 04:23:09 +0000 (16:23 +1200)] 
ldb:kv_cache: s/ltdb/ldb_kv/ in comments and messages

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoldb:kv: s/ltdb/ldb_kv/ in comments and messages
Douglas Bagnall [Thu, 22 Aug 2024 04:22:28 +0000 (16:22 +1200)] 
ldb:kv: s/ltdb/ldb_kv/ in comments and messages

with some subsequent tidy-ups for style.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoldb:ldb_pack: filter avoids looping over msg when attrs contain "*"
Douglas Bagnall [Fri, 26 Jul 2024 03:47:03 +0000 (15:47 +1200)] 
ldb:ldb_pack: filter avoids looping over msg when attrs contain "*"

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoldb:dn_casefold_internal: TALLOC_FREE only what we talloced
Douglas Bagnall [Wed, 21 Aug 2024 23:03:13 +0000 (11:03 +1200)] 
ldb:dn_casefold_internal: TALLOC_FREE only what we talloced

If the failure is not on the last component, we would have
TALLOC_FREE()ed some components that we hadn't set.

I think in all pathways we initialise the unset components to zero,
but we should be careful just in case.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoldb:tests: add tests ensuring indexes don't change search results
Douglas Bagnall [Sat, 17 Aug 2024 01:34:01 +0000 (13:34 +1200)] 
ldb:tests: add tests ensuring indexes don't change search results

The index code (lib/ldb_key_value/ldb_kv_index.c) recapitulates LDB
expression logic, and it seemed less than completely obvious that it
would never make a mistake and return a different result than an
unindexed search.

Here we run the same search on an unindexed database and on some that
have been indexed with a variety of options. We assert that the
results are identical over a number of searches.

By default, when run from the command line, that number is 495161,
which takes a couple of minutes. But if the SKIP_SLOW_TESTS
environment variable is set, the number is 33569, which takes 20
seconds or so. In selftest we set the variable and run the smaller
number.

The tests will print the cumulative search time for each database for
each testsuite, like this:

$ python3 lib/ldb/tests/python/index_transparency.py
..........................................................[...]
<class '__main__.SearchTest'>
25.78186821937561 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-indexed-dn.ldb>
17.73349642753601 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-half-indexed.ldb>
15.14864206314087 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-indexed-guid.ldb>
13.107165575027466 <ldb connection mdb:///tmp/tmpf1x72x7l/mdb-indexed.ldb>

Like all benchmarks it is interesting but misleading. One caveat here
is that you have (probably) compiled tdb in developer mode without
optimisation, while lmdb is probably a system package compiled with -O2,
though perhaps not tuned to your exact architecture.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agolib:ldb-samba: use 'ldb' debug class more widely
Douglas Bagnall [Wed, 16 Oct 2024 23:12:46 +0000 (12:12 +1300)] 
lib:ldb-samba: use 'ldb' debug class more widely

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoselftest:S4: use PY_DEV_PROVISION for python dev-mode
Douglas Bagnall [Wed, 18 Sep 2024 01:52:17 +0000 (13:52 +1200)] 
selftest:S4: use PY_DEV_PROVISION for python dev-mode

Maybe we could look also at other -X options and -v.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
\18

10 months agoselftest:S4: use RR_PROVISION for rr recording
Douglas Bagnall [Wed, 18 Sep 2024 01:40:23 +0000 (13:40 +1200)] 
selftest:S4: use RR_PROVISION for rr recording

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agoselftest:S4: do not add 'env python' multiple times'
Douglas Bagnall [Wed, 18 Sep 2024 01:38:52 +0000 (13:38 +1200)] 
selftest:S4: do not add 'env python' multiple times'

While we have no sane reason to use

VALGRIND_PROVISION=1 GDB_PROVISION=1 make test...

we will soon gain PY_DEV_PROVISION, which could be useful in tandem
with valgrind, rr, or gdb, and this will allow that.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agolibcli/util: let nt_errstr() fallback to hresult_errstr()
Stefan Metzmacher [Mon, 16 Dec 2024 13:46:19 +0000 (14:46 +0100)] 
libcli/util: let nt_errstr() fallback to hresult_errstr()

Sometimes NTSTATUS fields return things like
HRES_SEC_E_WRONG_PRINCIPAL.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Dec 18 18:30:08 UTC 2024 on atb-devel-224

10 months agos4:scripting: fix gen_hresult.py
Stefan Metzmacher [Mon, 16 Dec 2024 13:43:41 +0000 (14:43 +0100)] 
s4:scripting: fix gen_hresult.py

Commit 6877e4849e81ed8f7f355fa4069f13a134e999ce reversed the
return values of hresult_errstr() and hresult_errstr_const().

hresult_errstr() should return "HRES_SEC_E_WRONG_PRINCIPAL",
while hresult_errstr_const() should return
"The target principal name is incorrect.".

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
10 months agolib: Fix error path memleaks in read_ea_list_entry()
Volker Lendecke [Thu, 12 Dec 2024 14:17:05 +0000 (15:17 +0100)] 
lib: Fix error path memleaks in read_ea_list_entry()

Don't leak the result on error

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Dec 18 09:30:33 UTC 2024 on atb-devel-224

10 months agolib: Fix a comment
Volker Lendecke [Thu, 12 Dec 2024 12:59:45 +0000 (13:59 +0100)] 
lib: Fix a comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
10 months agosmbd: Simplify smbd_do_qfsinfo()
Volker Lendecke [Tue, 10 Dec 2024 10:42:59 +0000 (11:42 +0100)] 
smbd: Simplify smbd_do_qfsinfo()

Do early returns, avoid else statements

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
10 months agoFix whitespace
Volker Lendecke [Tue, 10 Dec 2024 15:57:47 +0000 (16:57 +0100)] 
Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
10 months agovfs: Slightly speed up stream_dir()
Volker Lendecke [Mon, 9 Dec 2024 09:01:19 +0000 (10:01 +0100)] 
vfs: Slightly speed up stream_dir()

lp_parm_bool() is a relatively expensive string-based operation. Do it
only when needed.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
10 months agovfs: Simplify stream_dir()
Volker Lendecke [Mon, 9 Dec 2024 07:09:53 +0000 (08:09 +0100)] 
vfs: Simplify stream_dir()

We know in advance how large "id_hex" is.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
10 months agoModernize DEBUGs
Volker Lendecke [Mon, 9 Dec 2024 06:55:45 +0000 (07:55 +0100)] 
Modernize DEBUGs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
10 months agopam_winbind: Fix Bug 15771
Volker Lendecke [Mon, 16 Dec 2024 16:49:43 +0000 (17:49 +0100)] 
pam_winbind: Fix Bug 15771

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
10 months agos3:winbindd: Remove unused set_routing_domain()
Pavel Filipenský [Mon, 16 Dec 2024 13:39:54 +0000 (14:39 +0100)] 
s3:winbindd: Remove unused set_routing_domain()

Commit 9a613f4 winbindd: add routing_domain as parameter to add_trusted_domain
deleted all calls of set_routing_domain().

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Dec 17 13:30:25 UTC 2024 on atb-devel-224

10 months agonsswitch:winbind: Remove WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:10:48 +0000 (14:10 +0100)] 
nsswitch:winbind: Remove WINBINDD_SHOW_SEQUENCE

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agos3:winbindd: Remove implementation of WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:16:07 +0000 (14:16 +0100)] 
s3:winbindd: Remove implementation of WINBINDD_SHOW_SEQUENCE

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agos4:torture: Remove test for deprecated WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:12:22 +0000 (14:12 +0100)] 
s4:torture: Remove test for deprecated WINBINDD_SHOW_SEQUENCE

torture_winbind_struct_show_sequence() is failing if run as:

make -j8 test TESTS="samba4.rpc.lsa.trusted.*ad_dc samba4.winbind.struct.ad_dc"

The reason is that the test constructs two lists of domains and assumes
that the list contain same domains in the same order.

However:

- the list based on DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep) contains 51 domains
- the list based on DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep) contains 39 domains

and we got:

failure: show_sequence [ ../../source4/torture/winbind/struct_based.c:824: domlist[i].netbios_name was TORTURE201, expected TORTURE200: inconsistent order of domain lists
]

Both list are based on full domain list, however the smaller one filters
out domain without trust_type in winbindd_list_trusted_domains():

trust_type = get_trust_type_string(talloc_tos(), d, domain);
if (trust_type == NULL) {
continue;
}

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agonsswitch:wbinfo: Remove implementation of deprecated '--sequence'
Pavel Filipenský [Mon, 16 Dec 2024 12:57:17 +0000 (13:57 +0100)] 
nsswitch:wbinfo: Remove implementation of deprecated '--sequence'

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agodocs-xml:manpages: Remove deprecated 'wbinfo --sequence'
Pavel Filipenský [Mon, 16 Dec 2024 13:01:42 +0000 (14:01 +0100)] 
docs-xml:manpages: Remove deprecated 'wbinfo --sequence'

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agonsswitch:tests: Remove test for deprecated wbinfo --sequence
Pavel Filipenský [Mon, 16 Dec 2024 13:01:42 +0000 (14:01 +0100)] 
nsswitch:tests: Remove test for deprecated wbinfo --sequence

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
10 months agosmbd: Simplify rmdir_internals()
Volker Lendecke [Fri, 6 Dec 2024 08:23:21 +0000 (09:23 +0100)] 
smbd: Simplify rmdir_internals()

Remove another "copy" of recursive_rmdir()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Streamline recursive_rmdir()
Volker Lendecke [Fri, 6 Dec 2024 08:19:08 +0000 (09:19 +0100)] 
smbd: Streamline recursive_rmdir()

By factoring out recursive_rmdir_fsp() we can do the recursion using
openat_pathref_fsp_lcomp(). This makes strace for a recursive
directory removal look a *lot* cleaner.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Simplify rmdir_internals()
Volker Lendecke [Thu, 5 Dec 2024 16:20:41 +0000 (17:20 +0100)] 
smbd: Simplify rmdir_internals()

Remove a "copy" of can_delete_directory_hnd()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Factor out can_delete_directory_hnd()
Volker Lendecke [Thu, 5 Dec 2024 16:17:59 +0000 (17:17 +0100)] 
smbd: Factor out can_delete_directory_hnd()

To be used in close.c next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Make can_delete_directory_fsp() look cleaner in strace
Volker Lendecke [Thu, 5 Dec 2024 15:50:12 +0000 (16:50 +0100)] 
smbd: Make can_delete_directory_fsp() look cleaner in strace

I'm not sure, but it might be that we don't have a full fd coming into
can_delete_directory_fsp() without O_PATH. We open a real fd for
readdir() in all cases, which we can use for sure in openat &
friends. Use that as dirfsp for openat.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Fix can_delete_directory_fsp()
Volker Lendecke [Fri, 6 Dec 2024 10:31:56 +0000 (11:31 +0100)] 
smbd: Fix can_delete_directory_fsp()

We should only ignore veto files if they are about to deleted anyway

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: simplify can_delete_directory_fsp()
Volker Lendecke [Thu, 5 Dec 2024 12:08:32 +0000 (13:08 +0100)] 
smbd: simplify can_delete_directory_fsp()

openat_pathref_fsp_lcomp does all of what we do here manually
anyway. Use it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Remove a pointless and partially wrong comment
Volker Lendecke [Thu, 5 Dec 2024 19:07:03 +0000 (20:07 +0100)] 
smbd: Remove a pointless and partially wrong comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Fix typos
Volker Lendecke [Thu, 5 Dec 2024 10:38:51 +0000 (11:38 +0100)] 
smbd: Fix typos

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Simplify ReadDirName()
Volker Lendecke [Thu, 5 Dec 2024 10:37:15 +0000 (11:37 +0100)] 
smbd: Simplify ReadDirName()

"fp" is only used for DBG messages where I don't think we need the
full accuracy of full_path_from_dirfsp_at_basename(). Save a talloc.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolib: Simplify ad_get_internal()
Volker Lendecke [Wed, 4 Dec 2024 18:37:20 +0000 (19:37 +0100)] 
lib: Simplify ad_get_internal()

We have metadata_fsp() for this

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Pass "dirfsp" through open_streams_for_delete()
Volker Lendecke [Wed, 4 Dec 2024 18:29:03 +0000 (19:29 +0100)] 
smbd: Pass "dirfsp" through open_streams_for_delete()

One SMB_VFS_CREATE_FILE call less with "NULL" as dirfsp

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Fix a %d/%u format string hickup
Volker Lendecke [Wed, 4 Dec 2024 18:19:57 +0000 (19:19 +0100)] 
smbd: Fix a %d/%u format string hickup

num_streams is an unsigned int

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agorpcclient: Fix Coverity ID 1508978 Use of 32-bit time_t
Volker Lendecke [Wed, 4 Dec 2024 16:03:46 +0000 (17:03 +0100)] 
rpcclient: Fix Coverity ID 1508978 Use of 32-bit time_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agonet: Fix Coverity ID 1508974 Use of 32-bit time_t
Volker Lendecke [Wed, 4 Dec 2024 16:00:50 +0000 (17:00 +0100)] 
net: Fix Coverity ID 1508974 Use of 32-bit time_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agoeventlog: Fix Coverity ID 1508977 Use of 32-bit time_t
Volker Lendecke [Wed, 4 Dec 2024 15:59:01 +0000 (16:59 +0100)] 
eventlog: Fix Coverity ID 1508977 Use of 32-bit time_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agowinbind: Fix Coverity ID 1509002 Use of 32-bit time_t
Volker Lendecke [Wed, 4 Dec 2024 15:38:47 +0000 (16:38 +0100)] 
winbind: Fix Coverity ID 1509002 Use of 32-bit time_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agoprinting: Remove a few obsolete openat_pathref_fsp() calls
Volker Lendecke [Wed, 4 Dec 2024 15:30:03 +0000 (16:30 +0100)] 
printing: Remove a few obsolete openat_pathref_fsp() calls

driver_convert_unix calls filename_convert_dirfsp, which these days
fills smb_fname->fsp. So openat_pathref_fsp() will immediately return
success as it finds smb_fname->fsp != NULL.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Remove an obsolete comment
Volker Lendecke [Wed, 4 Dec 2024 15:11:44 +0000 (16:11 +0100)] 
smbd: Remove an obsolete comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Simplify smb_set_file_end_of_file_info()
Volker Lendecke [Wed, 4 Dec 2024 15:06:10 +0000 (16:06 +0100)] 
smbd: Simplify smb_set_file_end_of_file_info()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Simplify call_trans2setfileinfo()
Volker Lendecke [Wed, 4 Dec 2024 14:53:41 +0000 (15:53 +0100)] 
smbd: Simplify call_trans2setfileinfo()

Avoid an "else"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolib: Fix Coverity ID 1636566 Untrusted loop bound
Volker Lendecke [Wed, 4 Dec 2024 13:03:12 +0000 (14:03 +0100)] 
lib: Fix Coverity ID 1636566 Untrusted loop bound

Sanitize num_auths to [0,15] in sid_copy()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Modernize DEBUGs
Volker Lendecke [Wed, 4 Dec 2024 11:42:43 +0000 (12:42 +0100)] 
smbd: Modernize DEBUGs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Avoid a (double) cast
Volker Lendecke [Wed, 4 Dec 2024 11:42:00 +0000 (12:42 +0100)] 
smbd: Avoid a (double) cast

We don't need floating point here, intmax_t and %jd should be
sufficient

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Pass "dirfsp" to get_posix_fsp()
Volker Lendecke [Wed, 4 Dec 2024 11:28:34 +0000 (12:28 +0100)] 
smbd: Pass "dirfsp" to get_posix_fsp()

The two places where get_posix_fsp() is called we do have the dirfsp
around. Pass this through to SMB_VFS_CREATE_FILE(), looks much cleaner
in strace.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Simplify smb_set_posix_acl()
Volker Lendecke [Wed, 4 Dec 2024 08:01:15 +0000 (09:01 +0100)] 
smbd: Simplify smb_set_posix_acl()

Call get_posix_fsp() in the caller, this removes if-conditions in
smb_set_posix_acl() itself

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Simplify smb_q_posix_acl()
Volker Lendecke [Wed, 4 Dec 2024 07:54:19 +0000 (08:54 +0100)] 
smbd: Simplify smb_q_posix_acl()

Ensure it's called with a valid fsp. In the pathinfo case, use
get_posix_fsp() in the caller, in the fileinfo case the client has
sent us the fid. A client-visible fid is always a fsa fsp.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agosmbd: Simplify get_posix_fsp()
Volker Lendecke [Tue, 3 Dec 2024 16:24:40 +0000 (17:24 +0100)] 
smbd: Simplify get_posix_fsp()

Remove three variables only set at initialization time

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Modernize a DEBUG
Volker Lendecke [Fri, 29 Nov 2024 14:35:50 +0000 (15:35 +0100)] 
libcli: Modernize a DEBUG

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Fix a potential 32-bit problem with PRIu32
Volker Lendecke [Thu, 28 Nov 2024 17:44:02 +0000 (18:44 +0100)] 
libcli: Fix a potential 32-bit problem with PRIu32

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Make handling implicit_owner_rights bit easier to read
Volker Lendecke [Fri, 29 Nov 2024 12:06:03 +0000 (13:06 +0100)] 
libcli: Make handling implicit_owner_rights bit easier to read

The first time I came across this I missed the "FALL_THROUGH" and had
to look closely at what happens. I had expected
IMPLICIT_OWNER_READ_CONTROL_AND_WRITE_DAC_RIGHTS to grant two rights,
which to me is now more obvious. It was correct before, but to me this
is now more obvious. YMMV.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Simplify disp_sec_ace_object()
Volker Lendecke [Thu, 28 Nov 2024 17:41:50 +0000 (18:41 +0100)] 
libcli: Simplify disp_sec_ace_object()

Directly use GUID_buf_string()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Align an integer type
Volker Lendecke [Tue, 3 Dec 2024 12:33:48 +0000 (13:33 +0100)] 
libcli: Align an integer type

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Remove the "mem_ctx" argument from pull_integer()
Volker Lendecke [Thu, 28 Nov 2024 17:01:21 +0000 (18:01 +0100)] 
libcli: Remove the "mem_ctx" argument from pull_integer()

Not needed anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Simplify pull_integer()
Volker Lendecke [Thu, 28 Nov 2024 16:58:59 +0000 (17:58 +0100)] 
libcli: Simplify pull_integer()

Use ndr_pull_struct_blob_noalloc, we don't need talloc here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agovfs: Simplify connect_acl_tdb()
Volker Lendecke [Thu, 28 Nov 2024 14:48:45 +0000 (15:48 +0100)] 
vfs: Simplify connect_acl_tdb()

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>
10 months agovfs: Simplify connect_acl_xattr()
Volker Lendecke [Thu, 28 Nov 2024 14:48:45 +0000 (15:48 +0100)] 
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>
10 months agosmbd: Pass "dirfsp" through posix_mkdir()
Volker Lendecke [Sat, 23 Nov 2024 15:51:15 +0000 (16:51 +0100)] 
smbd: Pass "dirfsp" through posix_mkdir()

One less caller of SMB_VFS_CREATE_FILE with dirfsp==NULL

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Avoid an unnecessary "else"
Volker Lendecke [Mon, 25 Nov 2024 11:04:53 +0000 (12:04 +0100)] 
libcli: Avoid an unnecessary "else"

We return in the if-branch

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
10 months agolibcli: Use ndr_deepcopy_struct() in security_token_duplicate()
Volker Lendecke [Thu, 28 Nov 2024 12:56:19 +0000 (13:56 +0100)] 
libcli: Use ndr_deepcopy_struct() in security_token_duplicate()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>