metze/samba-autobuild/.git
9 months agoctdb-common: Replace pcap_open_live() by lower level calls
Martin Schwenke [Tue, 15 Aug 2023 00:57:59 +0000 (10:57 +1000)]
ctdb-common: Replace pcap_open_live() by lower level calls

A subsequent commit will insert an additional call before
pcap_activate().

This sequence of calls is taken from the source for pcap_open_live(),
so there should be no change in behaviour.

Given the defaults set by pcap_create_common(), it would be possible
to omit the calls to pcap_set_promisc() and pcap_set_timeout().
However, those defaults don't seem to be well documented, so continue
to explicitly set everything that was set before.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-common: Improve error handling
Martin Schwenke [Tue, 15 Aug 2023 00:43:57 +0000 (10:43 +1000)]
ctdb-common: Improve error handling

Factor out a failure label, which will get more use in subsequent
commits, and only set private_data when success is certain.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agogitlab-ci: Add running codespell
Andreas Schneider [Wed, 22 Mar 2023 09:15:54 +0000 (10:15 +0100)]
gitlab-ci: Add running codespell

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Aug 14 22:44:58 UTC 2023 on atb-devel-224

9 months agoscripts: Add codespell check
Andreas Schneider [Tue, 14 Mar 2023 07:51:03 +0000 (08:51 +0100)]
scripts: Add codespell check

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agowintest: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:50:30 +0000 (15:50 +0200)]
wintest: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agotests: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:50:07 +0000 (15:50 +0200)]
tests: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agotestprogs: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:49:45 +0000 (15:49 +0200)]
testprogs: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:wrepl_server: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:48:16 +0000 (15:48 +0200)]
s4:wrepl_server: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:wrepl_server: Remove trailing white spaces
Andreas Schneider [Thu, 3 Aug 2023 13:49:06 +0000 (15:49 +0200)]
s4:wrepl_server: Remove trailing white spaces

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:46:43 +0000 (15:46 +0200)]
s4:torture: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:smb2: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:45:39 +0000 (15:45 +0200)]
s4:torture:smb2: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:rpc: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:45:20 +0000 (15:45 +0200)]
s4:torture:rpc: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:raw: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:45:05 +0000 (15:45 +0200)]
s4:torture:raw: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:nbt: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:44:41 +0000 (15:44 +0200)]
s4:torture:nbt: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:nbench: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:44:26 +0000 (15:44 +0200)]
s4:torture:nbench: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:libnetapi: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:44:01 +0000 (15:44 +0200)]
s4:torture:libnetapi: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:ldb: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:43:39 +0000 (15:43 +0200)]
s4:torture:ldb: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:ldap: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:43:00 +0000 (15:43 +0200)]
s4:torture:ldap: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:ldap: Remove trailing white spaces
Andreas Schneider [Thu, 3 Aug 2023 13:59:51 +0000 (15:59 +0200)]
s4:torture:ldap: Remove trailing white spaces

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:krb5: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:42:18 +0000 (15:42 +0200)]
s4:torture:krb5: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:dns: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:41:49 +0000 (15:41 +0200)]
s4:torture:dns: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:basic: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:41:02 +0000 (15:41 +0200)]
s4:torture:basic: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:drs: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:40:42 +0000 (15:40 +0200)]
s4:torture:drs: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:dfs: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:40:20 +0000 (15:40 +0200)]
s4:torture:dfs: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:torture:auth: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:39:59 +0000 (15:39 +0200)]
s4:torture:auth: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:smb_server: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:35:35 +0000 (15:35 +0200)]
s4:smb_server: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:setup: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:34:24 +0000 (15:34 +0200)]
s4:setup: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos3:ldap_server: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:29:56 +0000 (15:29 +0200)]
s3:ldap_server: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:selftest: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 13:28:06 +0000 (15:28 +0200)]
s4:selftest: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:scripting: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 12:45:16 +0000 (14:45 +0200)]
s4:scripting: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:samba: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 12:42:10 +0000 (14:42 +0200)]
s4:samba: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:rpc_server: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 12:40:26 +0000 (14:40 +0200)]
s4:rpc_server: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:ntvfs: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 12:40:03 +0000 (14:40 +0200)]
s4:ntvfs: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:librpc: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 12:37:09 +0000 (14:37 +0200)]
s4:librpc: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:libnet: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 12:36:50 +0000 (14:36 +0200)]
s4:libnet: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:libcli: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 12:34:51 +0000 (14:34 +0200)]
s4:libcli: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:libcli: Remove tailing white spaces
Andreas Schneider [Fri, 4 Aug 2023 05:21:18 +0000 (07:21 +0200)]
s4:libcli: Remove tailing white spaces

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:lib: Fix code spelling
Andreas Schneider [Thu, 3 Aug 2023 12:32:27 +0000 (14:32 +0200)]
s4:lib: Fix code spelling

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agoaudit_logging: Simplify json_add_stringn() with json_stringn()
Volker Lendecke [Thu, 10 Aug 2023 13:05:22 +0000 (15:05 +0200)]
audit_logging: Simplify json_add_stringn() with json_stringn()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Aug 14 20:51:11 UTC 2023 on atb-devel-224

9 months agotevent: Fix a typo
Volker Lendecke [Wed, 9 Aug 2023 14:22:03 +0000 (16:22 +0200)]
tevent: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agolibsmb: A bit README.Coding for cli_qpathinfo2()
Volker Lendecke [Wed, 5 Jul 2023 09:58:39 +0000 (11:58 +0200)]
libsmb: A bit README.Coding for cli_qpathinfo2()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbd: Pass down "dirfsp" to smb_unix_mknod()
Volker Lendecke [Wed, 5 Jul 2023 06:27:03 +0000 (08:27 +0200)]
smbd: Pass down "dirfsp" to smb_unix_mknod()

Avoids a call to parent_pathref()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbd: Use "dirfsp" in smb_posix_unlink()
Volker Lendecke [Tue, 4 Jul 2023 15:21:32 +0000 (17:21 +0200)]
smbd: Use "dirfsp" in smb_posix_unlink()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbd: Use "dirfsp" in smb_posix_open()
Volker Lendecke [Tue, 4 Jul 2023 15:19:40 +0000 (17:19 +0200)]
smbd: Use "dirfsp" in smb_posix_open()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbstatus: Fix CID 1507865 Uninitialized pointer read
Volker Lendecke [Wed, 2 Aug 2023 16:39:20 +0000 (18:39 +0200)]
smbstatus: Fix CID 1507865 Uninitialized pointer read

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbstatus: Fix CID 1507870 Uninitialized pointer read
Volker Lendecke [Wed, 2 Aug 2023 16:38:22 +0000 (18:38 +0200)]
smbstatus: Fix CID 1507870 Uninitialized pointer read

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agodbwrap: Simplify dbwrap_change_int32_atomic_action()
Volker Lendecke [Wed, 12 Jul 2023 23:19:43 +0000 (01:19 +0200)]
dbwrap: Simplify dbwrap_change_int32_atomic_action()

Use dbwrap_do_locked()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agodbwrap: Simplify dbwrap_change_uint32_atomic_action()
Volker Lendecke [Wed, 12 Jul 2023 23:03:14 +0000 (01:03 +0200)]
dbwrap: Simplify dbwrap_change_uint32_atomic_action()

Use dbwrap_do_locked()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbd: Fix DBG macro
Volker Lendecke [Wed, 26 Jul 2023 22:47:23 +0000 (00:47 +0200)]
smbd: Fix DBG macro

This augments 5c37615efa2, the DBG macros already prepend the the function name

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agosmbd: Use struct initialization
Volker Lendecke [Wed, 26 Jul 2023 14:49:24 +0000 (16:49 +0200)]
smbd: Use struct initialization

Avoid an explicit ZERO_STRUCT

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agolib: Move few bytes of R/W data to R/O text
Volker Lendecke [Mon, 10 Jul 2023 16:17:36 +0000 (18:17 +0200)]
lib: Move few bytes of R/W data to R/O text

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agoidmap:fix whitespace
Volker Lendecke [Tue, 24 Jan 2023 17:01:43 +0000 (18:01 +0100)]
idmap:fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agoidmap_tdb: Remove a variable never used
Volker Lendecke [Tue, 24 Jan 2023 10:04:24 +0000 (11:04 +0100)]
idmap_tdb: Remove a variable never used

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agoidmap: Fix whitespace
Volker Lendecke [Tue, 24 Jan 2023 10:03:28 +0000 (11:03 +0100)]
idmap: Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agopassdb: Fix a DBG statement
Volker Lendecke [Tue, 24 Jan 2023 09:28:26 +0000 (10:28 +0100)]
passdb: Fix a DBG statement

This is not pdb_getsampwent()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agopassdb: Fix whitespace
Volker Lendecke [Tue, 24 Jan 2023 09:16:41 +0000 (10:16 +0100)]
passdb: Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agopassdb: Fix a DBG message
Volker Lendecke [Tue, 24 Jan 2023 09:00:25 +0000 (10:00 +0100)]
passdb: Fix a DBG message

This is not dsdb_add_domain_alias()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agos3: smbd: Add missing 'return;'s in exit paths in reply_exit_done().
Jeremy Allison [Fri, 11 Aug 2023 22:19:01 +0000 (15:19 -0700)]
s3: smbd: Add missing 'return;'s in exit paths in reply_exit_done().

Remove knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Aug 14 19:52:49 UTC 2023 on atb-devel-224

9 months agos3: torture: Add a test doing an SMB1 negotiate+exit.
Jeremy Allison [Fri, 11 Aug 2023 22:12:05 +0000 (15:12 -0700)]
s3: torture: Add a test doing an SMB1 negotiate+exit.

Robert Morris <rtm@lcs.mit.edu> noticed a missing
return in reply_exit_done().

Adds knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
9 months agomdssvc: Do an early talloc_free() in _mdssvc_open()
Jones Syue [Mon, 7 Aug 2023 09:08:29 +0000 (17:08 +0800)]
mdssvc: Do an early talloc_free() in _mdssvc_open()

Environment setup:
When macOS Finder connect to a samba server with 'spotlight = yes',
macOS would issue mdssvc open (mdssvc.opnum == 0) to samba and it goes
through api _mdssvc_open().

After applied 578e434a94147dc2d7dbfc006d2ab84807859c1d,
(this is reported by jaywei@qnap.com)
this line 'talloc_free(path);' is deleted if _mdssvc_open() normal exit,
so memory is lazy de-allocate: delayed to
smbd_tevent_trace_callback() @ smb2_process.c. [1]

Supposed to explicitly free 'path' in _mdssvc_open() @ srv_mdssvc_nt.c[2]
just like abnormal exit, do not wait for main loop to free 'path' which is
no longer used, this is more consistent while reading source code.

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

[1] gdb tracing 'path' address 0x56204ccc67e0 to know how it is freed.
Breakpoint 2, _tc_free_children_internal (tc=0x56204ccc6780, ptr=0x56204ccc67e0, location=0x7ff430d96410 "../../lib/talloc/talloc.c:1714") at ../../lib/talloc/talloc.c:1656
1656            while (tc->child) {
(gdb) bt
0  _tc_free_children_internal (tc=0x56204ccc6780, ptr=0x56204ccc67e0, location=0x7ff430d96410 "../../lib/talloc/talloc.c:1714") at ../../lib/talloc/talloc.c:1656
1  0x00007ff430d92b14 in _tc_free_internal (tc=0x56204ccc6780, location=0x7ff430d96410 "../../lib/talloc/talloc.c:1714") at ../../lib/talloc/talloc.c:1183
2  0x00007ff430d93b71 in _tc_free_children_internal (tc=0x56204ccc6720, ptr=0x56204ccc6780, location=0x7ff430d96410 "../../lib/talloc/talloc.c:1714") at ../../lib/talloc/talloc.c:1668
3  0x00007ff430d93d66 in talloc_free_children (ptr=0x56204ccc6780) at ../../lib/talloc/talloc.c:1714
4  0x00007ff432235aca in talloc_pop (frame=0x56204ccc6780) at ../../lib/util/talloc_stack.c:125
5  0x00007ff430d92959 in _tc_free_internal (tc=0x56204ccc6720, location=0x7ff431f358d0 "../../source3/smbd/process.c:3726") at ../../lib/talloc/talloc.c:1157
6  0x00007ff430d92cd5 in _talloc_free_internal (ptr=0x56204ccc6780, location=0x7ff431f358d0 "../../source3/smbd/process.c:3726") at ../../lib/talloc/talloc.c:1247
7  0x00007ff430d93f96 in _talloc_free (ptr=0x56204ccc6780, location=0x7ff431f358d0 "../../source3/smbd/process.c:3726") at ../../lib/talloc/talloc.c:1791
8  0x00007ff431d81292 in smbd_tevent_trace_callback (point=TEVENT_TRACE_AFTER_LOOP_ONCE, private_data=0x7ffe46591e30) at ../../source3/smbd/process.c:3726
<...cut...>

[2] gdb tracing 'path' address 0x55a6d66deed0 to know how it is freed.
Breakpoint 2, _tc_free_children_internal (tc=0x55a6d66deed0, ptr=0x55a6d66def30, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1656
1656            while (tc->child) {
(gdb) bt
0  _tc_free_children_internal (tc=0x55a6d66deed0, ptr=0x55a6d66def30, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1656
1  0x00007fc4cb892b14 in _tc_free_internal (tc=0x55a6d66deed0, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1183
2  0x00007fc4cb892cd5 in _talloc_free_internal (ptr=0x55a6d66def30, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1247
3  0x00007fc4cb893f96 in _talloc_free (ptr=0x55a6d66def30, location=0x7fc4cca84040 "../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189") at ../../lib/talloc/talloc.c:1791
4  0x00007fc4cc9396e4 in _mdssvc_open (p=0x55a6d66d5600, r=0x55a6d66edc60) at ../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:189
<...cut...>

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: Noel Power <npower@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Aug 14 18:11:37 UTC 2023 on atb-devel-224

9 months agos3: smbd: Ensure all callers to srvstr_pull_req_talloc() pass a zeroed-out dest pointer.
Jeremy Allison [Fri, 11 Aug 2023 17:52:31 +0000 (10:52 -0700)]
s3: smbd: Ensure all callers to srvstr_pull_req_talloc() pass a zeroed-out dest pointer.

Now we've fixed srvstr_pull_req_talloc() this isn't
strictly needed, but ensuring pointers are initialized
is best practice to avoid future bugs.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Aug 14 15:55:43 UTC 2023 on atb-devel-224

9 months agos3: smbd: Uncorrupt the pointer we were using to prove a crash.
Jeremy Allison [Fri, 11 Aug 2023 17:47:28 +0000 (10:47 -0700)]
s3: smbd: Uncorrupt the pointer we were using to prove a crash.

Rather than restore to uninitialized, set to NULL as per
modern coding practices.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15420
Reviewed-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agos3: smbd: Ensure srvstr_pull_req_talloc() always NULLs out *dest.
Jeremy Allison [Fri, 11 Aug 2023 17:42:41 +0000 (10:42 -0700)]
s3: smbd: Ensure srvstr_pull_req_talloc() always NULLs out *dest.

Robert Morris <rtm@lcs.mit.edu> noticed that in the case
where srvstr_pull_req_talloc() is being called with
buffer remaining == 0, we don't NULL out the destination
pointed which is *always* done in the codepaths inside
pull_string_talloc(). This prevents a crash in the caller.

Remove knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agos3: torture: Add SMB1-TRUNCATED-SESSSETUP test.
Jeremy Allison [Fri, 11 Aug 2023 17:39:36 +0000 (10:39 -0700)]
s3: torture: Add SMB1-TRUNCATED-SESSSETUP test.

Shows that we indirect through an uninitialized pointer and the client crashes
it's own smbd.

Add knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agos3: smbd: Deliberately currupt an uninitialized pointer.
Jeremy Allison [Fri, 11 Aug 2023 17:38:23 +0000 (10:38 -0700)]
s3: smbd: Deliberately currupt an uninitialized pointer.

We will need this to show smbd crashing in the test code.
This will be removed once we're passing the test.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
9 months agos4:kdc: Add get_claims_set_for_principal()
Joseph Sutton [Thu, 10 Aug 2023 22:54:52 +0000 (10:54 +1200)]
s4:kdc: Add get_claims_set_for_principal()

Add a new function, get_claims_set_for_principal(), that returns the
claims as a CLAIMS_SET structure rather than as a blob. To accommodate
this, move the call to encode_claims_set() out of get_all_claims() and
into get_claims_blob_for_principal().

Being able to get the unencoded claims will save us from having to
decode claims that we just needlessly encoded.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Aug 14 05:51:45 UTC 2023 on atb-devel-224

9 months agos4:kdc: Rename ‘claims_blob’ parameter to ‘claims_blob_out’
Joseph Sutton [Fri, 11 Aug 2023 00:21:16 +0000 (12:21 +1200)]
s4:kdc: Rename ‘claims_blob’ parameter to ‘claims_blob_out’

Just to make perfectly clear that it is an out parameter.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Rename get_claims_for_principal() to get_claims_blob_for_principal()
Joseph Sutton [Fri, 11 Aug 2023 00:20:09 +0000 (12:20 +1200)]
s4:kdc: Rename get_claims_for_principal() to get_claims_blob_for_principal()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Ensure that we don’t dereference a NULL pointer
Joseph Sutton [Fri, 11 Aug 2023 00:15:05 +0000 (12:15 +1200)]
s4:kdc: Ensure that we don’t dereference a NULL pointer

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Properly allocate claims set on a talloc context
Joseph Sutton [Fri, 11 Aug 2023 00:10:46 +0000 (12:10 +1200)]
s4:kdc: Properly allocate claims set on a talloc context

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Remove ldb_context parameter as being no longer needed
Joseph Sutton [Fri, 11 Aug 2023 00:06:00 +0000 (12:06 +1200)]
s4:kdc: Remove ldb_context parameter as being no longer needed

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Have encode_claims_set return NTSTATUS
Joseph Sutton [Fri, 11 Aug 2023 00:04:02 +0000 (12:04 +1200)]
s4:kdc: Have encode_claims_set return NTSTATUS

This change will simplify things later. Probably.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:dsdb: Check for overflow in security_token_create()
Joseph Sutton [Thu, 10 Aug 2023 22:36:04 +0000 (10:36 +1200)]
s4:dsdb: Check for overflow in security_token_create()

Overflow is unlikely ever to occur, but you never know.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:dsdb: Make ‘sids’ parameter const
Joseph Sutton [Thu, 10 Aug 2023 22:35:43 +0000 (10:35 +1200)]
s4:dsdb: Make ‘sids’ parameter const

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:dsdb: Use uint32_t for ‘num_sids’
Joseph Sutton [Thu, 10 Aug 2023 22:34:47 +0000 (10:34 +1200)]
s4:dsdb: Use uint32_t for ‘num_sids’

This matches the use of uint32_t for security_token::num_sids.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Free error message returned by krb5_get_error_message()
Joseph Sutton [Thu, 10 Aug 2023 22:25:08 +0000 (10:25 +1200)]
s4:kdc: Free error message returned by krb5_get_error_message()

Also check whether the message is NULL. Passing NULL to vasprintf() is
undefined behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Use common out path in mit_samba_kpasswd_change_password()
Joseph Sutton [Thu, 10 Aug 2023 22:23:10 +0000 (10:23 +1200)]
s4:kdc: Use common out path in mit_samba_kpasswd_change_password()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Inline samba_get_claims_blob()
Joseph Sutton [Thu, 10 Aug 2023 22:21:07 +0000 (10:21 +1200)]
s4:kdc: Inline samba_get_claims_blob()

Wrapping a function this simple doesn’t gain us very much.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Don’t enforce a server authentication policy for the krbtgt
Joseph Sutton [Thu, 10 Aug 2023 22:15:56 +0000 (10:15 +1200)]
s4:kdc: Don’t enforce a server authentication policy for the krbtgt

As the server authentication policy will be non-NULL only for entries
looked up as servers, the krbtgt shouldn’t have an authentication policy
anyway. But we might as well be explicit.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Switch to using samdb_result_dom_sid_buf()
Joseph Sutton [Thu, 10 Aug 2023 22:13:38 +0000 (10:13 +1200)]
s4:kdc: Switch to using samdb_result_dom_sid_buf()

This function doesn’t require a heap allocation.

We also check the result of the function, which we weren’t doing before.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Return krb5_error_code
Joseph Sutton [Thu, 10 Aug 2023 22:08:57 +0000 (10:08 +1200)]
s4:kdc: Return krb5_error_code

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Make some functions static
Joseph Sutton [Thu, 10 Aug 2023 22:07:55 +0000 (10:07 +1200)]
s4:kdc: Make some functions static

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Return (possibly) more appropriate error codes
Joseph Sutton [Thu, 10 Aug 2023 22:02:28 +0000 (10:02 +1200)]
s4:kdc: Return (possibly) more appropriate error codes

This change ultimately won’t make much difference to responses, as
unrecognized codes are mapped to ERR_GENERIC in any case. But it might
provide some help for debugging.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:auth: Check return value of talloc_new()
Joseph Sutton [Thu, 10 Aug 2023 21:57:11 +0000 (09:57 +1200)]
s4:auth: Check return value of talloc_new()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:auth: Fix leaks
Joseph Sutton [Thu, 10 Aug 2023 21:56:55 +0000 (09:56 +1200)]
s4:auth: Fix leaks

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:auth: Add missing space to error message
Joseph Sutton [Thu, 10 Aug 2023 21:55:17 +0000 (09:55 +1200)]
s4:auth: Add missing space to error message

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Use type bool for ‘is_tgs’
Joseph Sutton [Thu, 10 Aug 2023 21:28:31 +0000 (09:28 +1200)]
s4:kdc: Use type bool for ‘is_tgs’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Erase key data
Joseph Sutton [Thu, 10 Aug 2023 04:58:31 +0000 (16:58 +1200)]
s4:kdc: Erase key data

If we’re going to zero the keys before freeing them, we might as well do
it properly.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Ensure the value of h->len is accurate
Joseph Sutton [Thu, 10 Aug 2023 04:52:13 +0000 (16:52 +1200)]
s4:kdc: Ensure the value of h->len is accurate

If we exited this function early due to an error, h->len would contain
the number of elements that *ought* to be in h->val, but not all of
those elements must have been initialized. Subsequently trying to free
this partially-uninitialized structure with free_Keys() could have bad
results.

Avoid this by ensuring that h->len accurately reports the actual number
of initialized elements.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Consistently zero HDB structures
Joseph Sutton [Thu, 10 Aug 2023 04:35:52 +0000 (16:35 +1200)]
s4:kdc: Consistently zero HDB structures

To these conversion functions we sometimes pass malloc-allocated HDB
structures, which we free afterwards if conversion fails. If parts of
these structures are still uninitialized when we try to free them, all
sorts of fun things can result.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Fix leaks of sdb_entry’s members
Joseph Sutton [Thu, 10 Aug 2023 04:33:24 +0000 (16:33 +1200)]
s4:kdc: Fix leaks of sdb_entry’s members

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Fail PAC checksum verification if the krbtgt entry has no keys
Joseph Sutton [Thu, 10 Aug 2023 04:31:41 +0000 (16:31 +1200)]
s4:kdc: Fail PAC checksum verification if the krbtgt entry has no keys

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Correctly report length of KDC packet
Joseph Sutton [Thu, 10 Aug 2023 04:17:51 +0000 (16:17 +1200)]
s4:kdc: Correctly report length of KDC packet

If the data was received over TCP, it would have had four bytes
subtracted from its length already, in kdc_tcp_call_loop().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Use portable format specifier
Joseph Sutton [Thu, 10 Aug 2023 04:17:06 +0000 (16:17 +1200)]
s4:kdc: Use portable format specifier

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Correct error message
Joseph Sutton [Thu, 10 Aug 2023 04:16:12 +0000 (16:16 +1200)]
s4:kdc: Correct error message

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Return an error code if sdb_entry_to_hdb_entry() fails
Joseph Sutton [Thu, 10 Aug 2023 04:13:12 +0000 (16:13 +1200)]
s4:kdc: Return an error code if sdb_entry_to_hdb_entry() fails

This condition was written backwards — if samba_kdc_fetch() returned
zero, we would ignore any error code returned by
sdb_entry_to_hdb_entry().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Fix code spelling
Joseph Sutton [Thu, 10 Aug 2023 04:12:13 +0000 (16:12 +1200)]
s4:kdc: Fix code spelling

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Fix leaks
Joseph Sutton [Thu, 10 Aug 2023 04:07:17 +0000 (16:07 +1200)]
s4:kdc: Fix leaks

Use a temporary context to allocate these variables. Each variable that
needs to be transferred to the caller is stolen onto an appropriate
talloc context just prior to the function’s returning.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Move calls to talloc_steal() out of the ‘out’ paths
Joseph Sutton [Thu, 10 Aug 2023 03:25:50 +0000 (15:25 +1200)]
s4:kdc: Move calls to talloc_steal() out of the ‘out’ paths

This simplifies the ‘out’ paths.

Every code path that reaches ‘out’ via a goto ensures that ‘ret’ is set
to a nonzero value.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4:kdc: Remove unnecessary talloc context
Joseph Sutton [Thu, 10 Aug 2023 03:57:43 +0000 (15:57 +1200)]
s4:kdc: Remove unnecessary talloc context

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>