]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
45 hours agovfs_gpfs: convert smb2gpfs_acl() to use talloc master
Shwetha Acharya [Thu, 16 Apr 2026 13:45:19 +0000 (19:15 +0530)] 
vfs_gpfs: convert smb2gpfs_acl() to use talloc

This avoids mixing malloc and talloc allocation patterns and
aligns the code with Samba's memory management conventions.

Signed-off-by: Shwetha Acharya <Shwetha.K.Acharya@ibm.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Sat Apr 18 20:58:22 UTC 2026 on atb-devel-224

3 days agoctdb-scripts: Support interface altnames gitlab/master
Martin Schwenke [Thu, 9 Apr 2026 07:52:20 +0000 (17:52 +1000)] 
ctdb-scripts: Support interface altnames

This avoids generating a warning like:

  WARNING: Public IP <ip> hosted on interface <iface> but VNN says <altname>

every time a public IP is removed from an interface that is configured
via an altname.

The new check will nearly always be successful because the IP will be
on the expected interface during releaseip/updateip.

The original check is now used as a backup when the IP is not on the
expected interface.  To allow the mask bits check to cover both cases,
the original check and the associated interface check needs to be
inside the else clause.

Update the unit test to reflect the change.

Best reviewed with "git show -w" or similar.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Apr 17 00:11:50 UTC 2026 on atb-devel-224

3 days agoctdb-tests: Add addip/releaseip altname unit test
Martin Schwenke [Mon, 13 Apr 2026 04:48:07 +0000 (14:48 +1000)] 
ctdb-tests: Add addip/releaseip altname unit test

This shows that a warning is generated whenever an IP address is
removed using an altname.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-tests: Implement altname property for ip link/addr
Martin Schwenke [Mon, 13 Apr 2026 04:18:28 +0000 (14:18 +1000)] 
ctdb-tests: Implement altname property for ip link/addr

Only implemented for these commands.  I don't even want to think about
doing this for ip route right now.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Rename/reimplement get_iface_ip_maskbits()
Martin Schwenke [Thu, 9 Apr 2026 05:29:10 +0000 (15:29 +1000)] 
ctdb-scripts: Rename/reimplement get_iface_ip_maskbits()

Reimplement to set prefix instead of maskbits.  Rename to
get_ip_prefix_iface().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Add function ip_prefix_iface()
Martin Schwenke [Wed, 8 Apr 2026 23:40:55 +0000 (09:40 +1000)] 
ctdb-scripts: Add function ip_prefix_iface()

Reimplement ip_maskbits_iface() using the ip -brief option.  Do less
parsing, no longer extract maskbits but return whole prefix.

Retain ip_maskbits_iface() for backward compatibility in case custom
event scripts are using it.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-tests: Implement -brief option for ip addr show stub
Martin Schwenke [Wed, 8 Apr 2026 03:02:52 +0000 (13:02 +1000)] 
ctdb-tests: Implement -brief option for ip addr show stub

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-tests: Fix a typo in "ip link show" stub output
Martin Schwenke [Wed, 8 Apr 2026 02:10:43 +0000 (12:10 +1000)] 
ctdb-tests: Fix a typo in "ip link show" stub output

Status is different to state and should not be repeated.  For example:

eth0             UP             aa:bb:cc:dd:ee:ff <BROADCAST,MULTICAST,UP,LOWER_UP>

Clearly nothing looks at this field but it should be correct.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Drop full address prefix lengths
Martin Schwenke [Thu, 2 Apr 2026 07:23:52 +0000 (18:23 +1100)] 
ctdb-scripts: Drop full address prefix lengths

ip addr assumes these defaults anyway.  They are just noise.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Add an extra variable to help reviewers
Martin Schwenke [Fri, 10 Apr 2026 01:22:19 +0000 (11:22 +1000)] 
ctdb-scripts: Add an extra variable to help reviewers

Using $_bcast to determine if the address is an IPv6 one is lazy.  It
causes anyone reading the code (including the original author) to have
to go back and confirm that the condition makes sense.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Add function ip_addr_add()
Martin Schwenke [Wed, 8 Apr 2026 01:28:41 +0000 (11:28 +1000)] 
ctdb-scripts: Add function ip_addr_add()

For consistency with new ip_addr_del().

Update all callers of add_ip_to_iface() to use this function
instead.

Retain add_ip_to_iface() for backward compatibility in case custom
event scripts are using it.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Add function ip_addr_del()
Martin Schwenke [Thu, 2 Apr 2026 01:45:05 +0000 (12:45 +1100)] 
ctdb-scripts: Add function ip_addr_del()

Using a prefix is more natural because it matches "ip addr ..." usage.
It should also allow for less parsing.

Update all callers of delete_ip_from_iface() to use this function
instead.

Retain delete_ip_from_iface() for backward compatibility in case
custom event scripts are using it.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Only warn when removing an unassigned public IP
Martin Schwenke [Thu, 9 Apr 2026 02:15:33 +0000 (12:15 +1000)] 
ctdb-scripts: Only warn when removing an unassigned public IP

get_iface_ip_maskbits() now sets iface="" when the IP is unassigned,
allowing dependent code to be conditional.

Currently, ctdb_takeover.c:ctdb_control_release_ip() ensures no
releaseip event is triggered if the public address is not on the node.
So, no change of behaviour for releaseip.

The previous attempt at making updateip behave more like takeip when
the IP isn't currently assigned caused commands with missing mask bits
to be run.  Avoid this.

Best reviewed with "git show -w" or similar.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Simplify by taking advantage of early return/exit
Martin Schwenke [Thu, 9 Apr 2026 12:02:24 +0000 (22:02 +1000)] 
ctdb-scripts: Simplify by taking advantage of early return/exit

Negate the condition in the if-statement so the current else part goes
first.  It always returns or exits, so the remainder (current if part)
can just follow.

This makes a subsequent change easier to understand.

Probably best reviewed with "git show -w" or similar.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Fix the NAT gateway IP drop in crash cleanup
Martin Schwenke [Thu, 9 Apr 2026 08:10:51 +0000 (18:10 +1000)] 
ctdb-scripts: Fix the NAT gateway IP drop in crash cleanup

This has been bizarrely wrong since commit
095fac9491bfe6a29127d9c3f76c15bc947cf591.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: No longer attempt to delete IP from new interface
Martin Schwenke [Thu, 9 Apr 2026 02:12:29 +0000 (12:12 +1000)] 
ctdb-scripts: No longer attempt to delete IP from new interface

Since commit 6471541d6d2bc9f2af0ff92b280abbd1d933cf88 this is
completely unnecessary because interface $oiface is determined by
looking at the system.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Add address with specified mask bits in updateip
Martin Schwenke [Thu, 9 Apr 2026 02:08:40 +0000 (12:08 +1000)] 
ctdb-scripts: Add address with specified mask bits in updateip

That is, add using $_maskbits, not $maskbits.

In the rare case where the mask bits were inconsistent on the old
interface, $maskbits will be needed for removal from the old
interface.

However, the specified mask bits ($_maskbits) must always be used when
adding to the new interface.  Circumstances where this matters are
likely to be very rare.

It matters more if the address is unexpectedly not assigned at all.
In this case $maskbits will not be set, so the address can't be added
to the new interface using that variable.

This got confused in commit 6471541d6d2bc9f2af0ff92b280abbd1d933cf88.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Change style to use if-statements
Martin Schwenke [Fri, 10 Apr 2026 00:51:53 +0000 (10:51 +1000)] 
ctdb-scripts: Change style to use if-statements

Well known, explicit structured programming constructs are arguably
easier to understand than implicit shell magic.

Only change instances that will be updated by subsequent commits.
Doing this separately, instead of in each subsequent commit, will make
those commits easier to understand.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Reformat with "shfmt -w -i 0 -fn"
Martin Schwenke [Wed, 8 Apr 2026 01:31:44 +0000 (11:31 +1000)] 
ctdb-scripts: Reformat with "shfmt -w -i 0 -fn"

Best reviewed with "git show -w" or similar.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 days agoctdb-scripts: Avoid a shellcheck complaint
Martin Schwenke [Thu, 2 Apr 2026 01:41:14 +0000 (12:41 +1100)] 
ctdb-scripts: Avoid a shellcheck complaint

In ctdb/config/events/legacy/11.natgw.script line 174:
read _old_natgwleader <"$natgw_leader_old"
                ^--^ SC2162 (info): read without -r will mangle backslashes.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
4 days agosmbd: handle synthetic_smb_fname failure properly in delete_all_streams
Shachar Sharon [Thu, 16 Apr 2026 09:04:25 +0000 (12:04 +0300)] 
smbd: handle synthetic_smb_fname failure properly in delete_all_streams

When 'synthetic_smb_fname' fails due to memory error, it returns NULL.
Fix this error-case logic in 'delete_all_streams'.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Thu Apr 16 13:48:23 UTC 2026 on atb-devel-224

4 days agondr:dns_utils.h: add header guards
Douglas Bagnall [Wed, 1 Apr 2026 20:35:01 +0000 (09:35 +1300)] 
ndr:dns_utils.h: add header guards

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): Thu Apr 16 01:57:42 UTC 2026 on atb-devel-224

4 days agondr/util push_dns_string: avoid unnecessary tallocs
Douglas Bagnall [Sat, 25 Apr 2020 02:56:05 +0000 (14:56 +1200)] 
ndr/util push_dns_string: avoid unnecessary tallocs

We know the components are all less than 64 bytes long.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 days agondr:dns: introduce and use MAX_COMP_LEN
Douglas Bagnall [Wed, 19 Feb 2025 02:44:34 +0000 (15:44 +1300)] 
ndr:dns: introduce and use MAX_COMP_LEN

it means 63 or 0x3f, and is the maximum length of a DNS/NBT component.

We also simplify an error message that was fond of long hex
representations of small numbers.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 days agondr: pull_dns_string: don't allow dots or '\0' in labels
Douglas Bagnall [Tue, 19 May 2020 22:05:16 +0000 (10:05 +1200)] 
ndr: pull_dns_string: don't allow dots or '\0' in labels

We use a copy function that returns false if the copied string
contains the bad characters, and true otherwise.

As a special case, we allow a '.' as the last character, because an
NBT name with a trailing dot is sometimes used as a username, and we
need to match these exactly, even though the dotless form is
semantically the same (per RFC).

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 days agolibrpc/tests: Initialize name _test_ndr_pull_dns_string_list
Andreas Schneider [Thu, 9 Apr 2026 05:27:11 +0000 (07:27 +0200)] 
librpc/tests: Initialize name _test_ndr_pull_dns_string_list

When ndr_pull_struct_blob fails (which it will for labels containing
dots, now rejected by the new dns_component_copy check), name remains
uninitialized and the subsequent push call dereference it.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 days agondr: pull_dns_string: check length, use buffers/memcpy
Douglas Bagnall [Sat, 6 Jun 2020 11:22:16 +0000 (23:22 +1200)] 
ndr: pull_dns_string: check length, use buffers/memcpy

RFC 1035 says the maximum length for a DNS name is 255 characters, and
one of the factors that allowed CVE-2020-10745 is that Samba did not
enforce that directly, enabling names around 8k long.

We fix that by keeping track of the name length. It is easier and more
efficient to use a 64 byte buffer for the components, and this will
help us to introduce further hardening in the next commit.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 days agondr: pull_dns_string: drop nbt/dns mem_ctx difference
Douglas Bagnall [Wed, 20 May 2020 07:18:14 +0000 (19:18 +1200)] 
ndr: pull_dns_string: drop nbt/dns mem_ctx difference

Until now NBT and DNS have used talloc contexts of different lifetimes
to allocate component strings. The actual talloc context doesn't
really matter -- these strings are immediately copied and can be freed
straight after. So that is what we do.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 days agondr/nbt: use ndr_dns_utils/ndr_pull_dns_string_list
Douglas Bagnall [Tue, 19 May 2020 01:55:53 +0000 (13:55 +1200)] 
ndr/nbt: use ndr_dns_utils/ndr_pull_dns_string_list

To retain exactly the same behaviour with regard to memory contexts
and error messages, we add an is_nbt flag.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 days agondr/dns: shift pull_dns_string to ndr_dns_util.c
Douglas Bagnall [Wed, 29 Apr 2020 04:16:26 +0000 (16:16 +1200)] 
ndr/dns: shift pull_dns_string to ndr_dns_util.c

This will allow NBT to use the same function (after modifications in
the next commit).

This is post CVE-2020-10745 hardening and optimisation.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 days agopytests: dns_packet tests check rcodes match Windows
Douglas Bagnall [Wed, 3 Jun 2020 02:42:41 +0000 (14:42 +1200)] 
pytests: dns_packet tests check rcodes match Windows

the dns_packet tests originally checked only for a particular DoS
situation (CVE-2020-10745) but now we widen them to ensure Samba's
replies to invalid packets resembles those of Windows (in particular,
Windows 2012r2). We want Samba to reply only when Windows replies, and
with the same rcode.

At present we fail a lot of these tests.

The original CVE-2020-10745 test is retained and widened indirectly --
any test that leaves the server unable to respond within 0.5 seconds
will count as a failure.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 days agos3/modules: fix snapper_gmt_fstatat
Noel Power [Fri, 10 Apr 2026 15:50:55 +0000 (16:50 +0100)] 
s3/modules: fix snapper_gmt_fstatat

snapper_gmt_fstatat is failing when called on items in a
'previous version' snapshot because the wrong timestamp value is
passed (the raw timewarp value is used) and snapper_gmt_convert cannot
find the valid snapshot instance to use.

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

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Wed Apr 15 15:29:38 UTC 2026 on atb-devel-224

5 days agos3/modules: Fix vfs snapper not finding files in subdirs
Noel Power [Fri, 10 Apr 2026 10:08:08 +0000 (11:08 +0100)] 
s3/modules: Fix vfs snapper not finding files in subdirs

when trying to browse on windows a snapper share (exposed via windows previous versions) files in subdirs are not visible. In other words only files that are in the root dir of the versioned share can be seen

/ashare/file1
/ashare/file2
/ashare/subdir
/ashare/subdir/subfile1

For example with the file hierarchy above only file1, file2 and subdir are visible. Navigating into subdir shows an empty dir

snapper_gmt_openat is failing because when calling snapper_gmt_convert
it doesn't take into account the path to the subdirectory.
snapper_gmt_convert is just passed the leaf name where it constructs the
snapper path based on the base dir of the share.

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

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
5 days agos3:loadparm: fix NULL pointer dereference in volume_label()
Jeremy Allison [Fri, 10 Apr 2026 21:24:34 +0000 (14:24 -0700)] 
s3:loadparm: fix NULL pointer dereference in volume_label()

volume_label() calls lp_servicename() as a fallback when lp_volume()
returns an empty string. lp_servicename() is a FN_LOCAL_SUBSTITUTED_STRING
that falls back to sDefault.szService when the service is invalid. Since
sDefault.szService is initialized to NULL and is never set by
init_globals(), the substitution returns NULL, and the subsequent
strlen() call crashes with a segmentation fault.

Add a NULL guard so volume_label() returns an empty string instead
of crashing.

Remove knownfail.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Apr 15 00:07:12 UTC 2026 on atb-devel-224

5 days agos3:smbd: guard lp_killservice() in delete_and_reload_printers() with connections_snum...
Jeremy Allison [Fri, 10 Apr 2026 21:21:55 +0000 (14:21 -0700)] 
s3:smbd: guard lp_killservice() in delete_and_reload_printers() with connections_snum_used check

delete_and_reload_printers() unconditionally calls lp_killservice()
to destroy autoloaded printer services that are no longer in the
printer list. If any active connection is still using the printer
service number, the destroyed service can cause a NULL pointer
dereference on subsequent requests.

Guard the call with connections_snum_used() so the service is only
freed when no connections are using it.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
5 days agos3:srvsvc: guard lp_killservice() in _srvsvc_NetShareDel() with connections_snum_used...
Jeremy Allison [Fri, 10 Apr 2026 21:20:45 +0000 (14:20 -0700)] 
s3:srvsvc: guard lp_killservice() in _srvsvc_NetShareDel() with connections_snum_used check

_srvsvc_NetShareDel() unconditionally calls lp_killservice() to
destroy the service after deleting a share via RPC. If any active
connection is still using this service number, the destroyed service
can cause a NULL pointer dereference on subsequent requests.

Guard the call with connections_snum_used() so the service is only
freed when no connections are using it. The periodic
load_usershare_shares() sweep will clean up the stale service once
all connections have disconnected.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
5 days agos3:loadparm: guard free_service_byindex() in lp_servicenumber() with snum_in_use...
Jeremy Allison [Fri, 10 Apr 2026 21:19:01 +0000 (14:19 -0700)] 
s3:loadparm: guard free_service_byindex() in lp_servicenumber() with snum_in_use check

lp_servicenumber() calls free_service_byindex() to destroy usershare
services when usershare_exists() returns false or when the usershare
file has been modified. This is unsafe because active connections may
still hold the service number — the destroyed service leaves a NULL
ServicePtrs[] entry that causes a NULL pointer dereference when the
connection subsequently calls lp_servicename() or similar functions.

The crash path is:
  get_referred_path() -> lp_servicenumber() -> usershare_exists()
  fails (e.g. EACCES) -> free_service_byindex() destroys service ->
  later request on same connection -> volume_label() ->
  lp_servicename() -> FN_LOCAL_SUBSTITUTED_STRING falls back to
  sDefault.szService (NULL) -> strlen(NULL) -> SIGSEGV

Guard both free_service_byindex() call sites with the snum_in_use
callback registered in the previous commit. When the service is in
use by an active connection, skip the destruction and let the
periodic load_usershare_shares() mark-and-sweep handle cleanup
safely via its conn_snum_used() check.

When snum_in_use is NULL (non-smbd programs), the original behaviour
is preserved — services are freed immediately since no connections
can exist.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
5 days agos3:loadparm: add lp_register_snum_in_use_fn() callback registration
Jeremy Allison [Fri, 10 Apr 2026 21:15:48 +0000 (14:15 -0700)] 
s3:loadparm: add lp_register_snum_in_use_fn() callback registration

Add a mechanism for smbd to register a callback that checks whether
a service number is currently in use by any active connection.

This will be used by subsequent commits to guard free_service_byindex()
calls in lp_servicenumber() and other sites that currently destroy
services without checking if they are in use, which can leave active
connections holding stale service numbers that lead to NULL pointer
dereferences.

The callback is registered by smbd during smbd_process() startup via
connections_snum_used. Non-smbd programs (testparm, net, etc.) leave the
callback as NULL, meaning no connections exist and it is always safe
to free services.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
5 days agos3:tests: add regression test for usershare EACCES crash
Jeremy Allison [Fri, 10 Apr 2026 23:45:39 +0000 (16:45 -0700)] 
s3:tests: add regression test for usershare EACCES crash

Add a test that verifies smbd does not crash when a usershare
definition file becomes inaccessible while a client is connected.

The test creates a usershare, connects to it, makes the usershare
definition file inaccessible (chmod 000), then issues a volume
query which triggers the volume_label() -> lp_servicename() code
path. It verifies smbd is still alive afterward by connecting to
a different share.

Add knownfail.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
6 days agos3/rpc_server: Add worker status smbcontrol message support
Noel Power [Wed, 11 Feb 2026 08:45:33 +0000 (08:45 +0000)] 
s3/rpc_server: Add worker status smbcontrol message support

Add information about the number of connections a rpc_worker
process is handling and when each connection was initiated.

command
  smbcontrol 55063 rpc-dump-worker-status

will output data like below:

  rpcd_spoolss pid 55063:
      num connections = 2
      num_association_groups = 2
      last client connection 2026/03/18 06:51:04.482192
      last client disconnection 2026/03/18 06:51:00.304951
   active connections:
      [1] endpoint=ncacn_np:[\pipe\spoolss] client addr=192.168.32.175 server=priu0002 connected at 2026/03/18 06:51:04.482192
      [2] endpoint=ncacn_np:[\pipe\spoolss] client addr=192.168.33.232 server=priu0002 connected at 2026/03/18 06:47:08.466157

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Tue Apr 14 12:12:07 UTC 2026 on atb-devel-224

6 days agorpc_server: Only allocate fsp when counting file locks
Shwetha Acharya [Thu, 5 Mar 2026 12:01:52 +0000 (17:31 +0530)] 
rpc_server: Only allocate fsp when counting file locks

Avoids creating fsp, which is not needed unless we
are going to count the brlocks.

Also uses early continue and removes num_locks variable
by assigning the result directly.

Signed-off-by: Shwetha Acharya <Shwetha.K.Acharya@ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Tue Apr 14 10:02:29 UTC 2026 on atb-devel-224

6 days agorpc_server: Optionally skip "process_exists" when enumerating files
Volker Lendecke [Wed, 2 May 2018 14:20:14 +0000 (16:20 +0200)] 
rpc_server: Optionally skip "process_exists" when enumerating files

If you want to skip the potentially expensive process_exists calls when
enumerating millions of files, set

srvsvc : file enum check stale = false

in your [global] section of your smb.conf

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
6 days agorpc_server: Optionally skip counting byte range locks when enumerating files
Ralph Wuerthner [Tue, 8 May 2018 08:52:08 +0000 (10:52 +0200)] 
rpc_server: Optionally skip counting byte range locks when enumerating files

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 days agosamba_cross.py: autobuild fails with trailing space at line endings
Björn Jacke [Fri, 10 Apr 2026 10:20:56 +0000 (12:20 +0200)] 
samba_cross.py: autobuild fails with trailing space at line endings

autobuild fails with trailing space at line endings, so we need to strip() only
at "\n" here strictly.

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

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Apr 10 21:20:52 UTC 2026 on atb-devel-224

12 days agovfs_glusterfs: fix directory fd leak via FSP extension destructor
Thales Antunes de Oliveira Barretto [Fri, 27 Feb 2026 07:38:06 +0000 (04:38 -0300)] 
vfs_glusterfs: fix directory fd leak via FSP extension destructor

When Samba closes a directory backed by vfs_glusterfs, the glfs_fd_t
opened by vfs_gluster_openat() is never closed.  This leaks one
libgfapi file descriptor and one server-side fd_t in glusterfsd per
directory open/close cycle.  With persistent SMB2 connections the
leak is unbounded and drives monotonic RSS growth on the GlusterFS
brick process.

The leak happens because vfs_glusterfs creates two independent
glfs_fd_t handles per directory: one via glfs_open() in
vfs_gluster_openat(), stored in the FSP extension, and another via
glfs_opendir() in vfs_gluster_fdopendir(), tracked by struct smb_Dir.
On close, smb_Dir_destructor() closes the opendir handle and sets the
pathref fd to -1.  fd_close() then returns early without calling
SMB_VFS_CLOSE, so vfs_gluster_close() never runs and the glfs_open()
handle is orphaned.  The original code passed NULL as the destroy
callback to VFS_ADD_FSP_EXTENSION, so there was no safety net.

The default VFS does not have this problem because fdopendir(3) wraps
the existing kernel fd rather than opening a new handle.  libgfapi
has no equivalent -- glfs_opendir() always creates an independent
handle by path.  The actual glfs_fd_t is stored in the FSP extension,
not in fsp->fh->fd (which holds a sentinel value), so Samba's generic
close path cannot reach it.

Register vfs_gluster_fsp_ext_destroy() as the FSP extension destroy
callback.  It calls glfs_close() on the stored pointer and is invoked
by vfs_remove_all_fsp_extensions() during file_free(), which runs
unconditionally for every fsp.  In the explicit close path,
vfs_gluster_close() NULLs the extension pointer before calling
VFS_REMOVE_FSP_EXTENSION to prevent double-close.  This follows the
same pattern used by vfs_ceph_new.c (vfs_ceph_fsp_ext_destroy_cb).

Observed on a production file server with persistent SMB2 connections
and continuous directory operations.  GlusterFS brick statedumps
showed fd_t pool growth from 1,993 to 80,350 active instances over
6 days, roughly 13,000 leaked fds per day per brick.

RN: Fix a directory file descriptor leak in vfs_glusterfs that caused
unbounded memory growth on the GlusterFS brick with persistent SMB2
connections.

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

Signed-off-by: Thales Antunes de Oliveira Barretto <thales.barretto.git@gmail.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Apr  8 16:46:12 UTC 2026 on atb-devel-224

12 days agoprinting: Set default value in case of non-exisiting record
Vinit Agnihotri [Mon, 23 Mar 2026 15:31:37 +0000 (21:01 +0530)] 
printing: Set default value in case of non-exisiting record

This fixes regression caused by commit#e9a7dce599
Newly added function treats non-existing record as error, instead of
setting just -1 i.e. default value for non-exisiting record for
printing subsystem. This results into print_cache_expired returning
incorrect status.

Fix sets default value in case of non-exisiting record
which would ensure print_cache_expired to return correct status.

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

Signed-off-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: Rabinarayan Panigrahi <rapanigr@redhat.com>
Reviewed-by: Avan Thakkar <athakkar@redhat.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
12 days agodsdb: use wellknow object IDs for new user and computer objects
Björn Jacke [Fri, 6 Mar 2026 16:16:46 +0000 (17:16 +0100)] 
dsdb: use wellknow object IDs for new user and computer objects

this allows redirusr and redircmp to work as expected

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

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Apr  8 15:41:21 UTC 2026 on atb-devel-224

12 days agobootstrap: Move to openSUSE Leap 16
Jennifer Sutton [Wed, 1 Apr 2026 21:51:03 +0000 (10:51 +1300)] 
bootstrap: Move to openSUSE Leap 16

openSUSE Leap 15.5 is out of support.

Signed-off-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 days agobootstrap: Drop Ubuntu 20.04 in CI
Jennifer Sutton [Wed, 1 Apr 2026 21:09:49 +0000 (10:09 +1300)] 
bootstrap: Drop Ubuntu 20.04 in CI

Ubuntu 20.04 is out of support. We want to run Ubuntu 26.04 in CI instead.

Signed-off-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 days agos3:smb2_server: failing lease/oplock breaks should call smbd_server_connection_termin...
Stefan Metzmacher [Thu, 12 Feb 2026 12:21:06 +0000 (13:21 +0100)] 
s3:smb2_server: failing lease/oplock breaks should call smbd_server_connection_terminate()

If there's a problem sending a lease break we need to
call smbd_server_connection_terminate(xconn).

Currently we only called smbXsrv_connection_disconnect_transport(),
which only closes the low level socket, but it doesn't
cleanup smbXsrv_connection and in case of the last connection
for the smbXsrv_client, so we leave the stale structures and
the stale process behind.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
12 days agobuildtools: fix clang warning: argument unused
Gary Lockyer [Tue, 31 Mar 2026 01:54:44 +0000 (14:54 +1300)] 
buildtools: fix clang warning: argument unused

Fix:
clang-xx: warning: argument unused during compilation:
          '-undefined dynamic_lookup' [-Wunused-command-line-argument]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Wed Apr  8 08:38:21 UTC 2026 on atb-devel-224

13 days agos3:printing: make printer_list.tdb none readable for others
Shwetha Acharya [Mon, 6 Apr 2026 11:25:42 +0000 (16:55 +0530)] 
s3:printing: make printer_list.tdb none readable for others

Signed-off-by: Shwetha Acharya <Shwetha.K.Acharya@ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Tue Apr  7 16:12:32 UTC 2026 on atb-devel-224

13 days agos3:rpc_server: make epmdb.tdb non readable for others
Shwetha Acharya [Wed, 1 Apr 2026 08:27:51 +0000 (13:57 +0530)] 
s3:rpc_server: make epmdb.tdb non readable for others

Signed-off-by: Shwetha Acharya <Shwetha.K.Acharya@ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:idmap_tdb2: make idmap2.tdb non readable for others
Shwetha Acharya [Wed, 1 Apr 2026 08:16:29 +0000 (13:46 +0530)] 
s3:idmap_tdb2: make idmap2.tdb non readable for others

Signed-off-by: Shwetha Acharya <Shwetha.K.Acharya@ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:idmap: make idmap.tdb non readable for others
Shwetha Acharya [Wed, 1 Apr 2026 07:36:01 +0000 (13:06 +0530)] 
s3:idmap: make idmap.tdb non readable for others

Signed-off-by: Shwetha Acharya <Shwetha.K.Acharya@ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:gencache: make gencache.tdb none readable for others
Ralph Wuerthner [Wed, 26 Feb 2020 10:29:50 +0000 (11:29 +0100)] 
s3:gencache: make gencache.tdb none readable for others

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:locking: make leases.tdb none readable for others
Ralph Wuerthner [Tue, 21 Jan 2020 08:14:23 +0000 (09:14 +0100)] 
s3:locking: make leases.tdb none readable for others

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:locking: make locking.tdb none readable for others
Ralph Wuerthner [Tue, 21 Jan 2020 08:14:36 +0000 (09:14 +0100)] 
s3:locking: make locking.tdb none readable for others

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:idmap_autorid: make autorid.tdb none readable for others
Ralph Wuerthner [Tue, 21 Jan 2020 08:15:40 +0000 (09:15 +0100)] 
s3:idmap_autorid: make autorid.tdb none readable for others

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:cleanupdb: make smbd_cleanupd.tdb none readable for others
Ralph Wuerthner [Wed, 26 Feb 2020 10:31:26 +0000 (11:31 +0100)] 
s3:cleanupdb: make smbd_cleanupd.tdb none readable for others

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:smbprofile: make smbprofile.tdb none readable for others
Ralph Wuerthner [Wed, 26 Feb 2020 13:01:50 +0000 (14:01 +0100)] 
s3:smbprofile: make smbprofile.tdb none readable for others

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 days agos3:libads: Set dns_lookup_kdc=false during net ads join
Pavel Filipenský [Mon, 23 Mar 2026 18:05:31 +0000 (19:05 +0100)] 
s3:libads: Set dns_lookup_kdc=false during net ads join

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

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): Tue Apr  7 14:09:40 UTC 2026 on atb-devel-224

13 days agos3:libads: Allow to specify 'dns_lookup_kdc' in krb5.conf
Pavel Filipenský [Mon, 23 Mar 2026 18:03:34 +0000 (19:03 +0100)] 
s3:libads: Allow to specify 'dns_lookup_kdc' in krb5.conf

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 days agos3:libnet: Fix DC numeric ip handling
Pavel Filipenský [Wed, 18 Mar 2026 19:24:37 +0000 (20:24 +0100)] 
s3:libnet: Fix DC numeric ip handling

This is fixing regression introduced via 82f53c8

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 days agosubunit: Do not return successful exit code if tests fail or error
Jennifer Sutton [Thu, 2 Apr 2026 03:11:56 +0000 (16:11 +1300)] 
subunit: Do not return successful exit code if tests fail or error

TestProtocolClient.writeOutcome() removed items from self.errors and
self.failures via TestProtocolClient._filterErrors(). This made wasSuccessful()
inappropriately return True even if there were errors or failures.
subunit.run.runTests() uses wasSuccessful() to determine the exit code.

To fix this, do not remove items from self.errors or self.failures, but instead
use indices to keep track of how many items we have already processed in each of
self.errors and self.failures.

This fixes a regression introduced by commit
421dc7fc4d83629d3a5f9e558d378f44c7b9dad3.

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

Signed-off-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Tue Apr  7 04:17:08 UTC 2026 on atb-devel-224

13 days agoselftest: Add keywords arguments to addDuration() method
Jennifer Sutton [Thu, 2 Apr 2026 03:09:58 +0000 (16:09 +1300)] 
selftest: Add keywords arguments to addDuration() method

Without these, the type checker complains:

Method "addDuration" overrides class "TestResult" in an incompatible manner.

Signed-off-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2 weeks agovfs_ceph_new: fix errno handling in vfs_ceph_readdir
Shweta Sodani [Wed, 25 Mar 2026 09:23:42 +0000 (14:53 +0530)] 
vfs_ceph_new: fix errno handling in vfs_ceph_readdir

Signed-off-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Thu Apr  2 05:49:13 UTC 2026 on atb-devel-224

2 weeks agovfs_ceph_new: add missing sentinel to enum_vfs_cephfs_fscrypt_vals
Shweta Sodani [Wed, 25 Mar 2026 08:55:08 +0000 (14:25 +0530)] 
vfs_ceph_new: add missing sentinel to enum_vfs_cephfs_fscrypt_vals

Signed-off-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
2 weeks agos4/dns_server: truncate large dns packets over udp and set truncated flag
Andréas Leroux [Fri, 13 Feb 2026 08:25:55 +0000 (09:25 +0100)] 
s4/dns_server: truncate large dns packets over udp and set truncated flag

Large DNS response must be truncated over UDP, letting client retry over TCP. Current threshold is set to 1232 as it is regarded as a safe size.
Truncated packets have no answers nor record, only the packet header and initial question(s).

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

Signed-off-by: Andréas Leroux <aleroux@tranquil.it>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Jennifer Sutton <jsutton@samba.org>
Autobuild-Date(master): Wed Apr  1 05:08:14 UTC 2026 on atb-devel-224

2 weeks agos4/dns_server: add large dns udp truncated packets tests
Andréas Leroux [Fri, 13 Feb 2026 08:22:32 +0000 (09:22 +0100)] 
s4/dns_server: add large dns udp truncated packets tests

Large DNS response must be truncated over UDP, though this is not yet done in samba. Test is added as knownfail until implementation

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

Signed-off-by: Andréas Leroux <aleroux@tranquil.it>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2 weeks agoauth: Check return of talloc_strdup() for NULL
Pavel Filipenský [Sun, 8 Mar 2026 18:06:26 +0000 (19:06 +0100)] 
auth: Check return of talloc_strdup() for NULL

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): Tue Mar 31 09:18:43 UTC 2026 on atb-devel-224

2 weeks agolibcli/smb: Call data_blob_clear() to zero MAC signing key
Pavel Filipenský [Sun, 8 Mar 2026 19:26:53 +0000 (20:26 +0100)] 
libcli/smb: Call data_blob_clear() to zero MAC signing key

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 weeks agoauth: Use secure variant data_blob_talloc_s() to zero sensitive data blobs
Pavel Filipenský [Mon, 9 Mar 2026 07:45:20 +0000 (08:45 +0100)] 
auth: Use secure variant data_blob_talloc_s() to zero sensitive data blobs

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 weeks agoauth: Call talloc_keep_secret() for sensitive memory
Pavel Filipenský [Sat, 7 Mar 2026 20:03:11 +0000 (21:03 +0100)] 
auth: Call talloc_keep_secret() for sensitive memory

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 weeks agoauth: Call ZERO_ARRAY()/ZERO_STRUCT() for sensitive variables on stack
Pavel Filipenský [Sun, 8 Mar 2026 07:43:39 +0000 (08:43 +0100)] 
auth: Call ZERO_ARRAY()/ZERO_STRUCT() for sensitive variables on stack

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 weeks agothird_party:heimdal: Import lorikeet-heimdal-202603261022
Gary Lockyer [Thu, 26 Mar 2026 22:26:06 +0000 (11:26 +1300)] 
third_party:heimdal: Import lorikeet-heimdal-202603261022

Fix compiler errors when compiling with clang 22

Fixes for bug 15746

commits: 5367944b74888bd1f8af3567e18c1b763f8f58c6
         1b18c37544405a74b20c6dff4454c0b7dc79d5df

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Tue Mar 31 00:41:46 UTC 2026 on atb-devel-224

2 weeks agotests:krb5 expired password handling
Gary Lockyer [Thu, 26 Mar 2026 00:39:45 +0000 (13:39 +1300)] 
tests:krb5 expired password handling

The windows ADDC checks password validity before password expiry. So an
incorrect expired password will return KDC_ERR_PREAUTH_REQUIRED not
KDC_ERR_KEY_EXPIRED.

The KDC behaviour fixes will be made to lorikeet-heimdal and then imported to
samba.

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
3 weeks agopython:tests/krb5: Make PADATA_PK_AS_REP optional in non-strict mode
Andreas Schneider [Wed, 25 Mar 2026 11:44:02 +0000 (12:44 +0100)] 
python:tests/krb5: Make PADATA_PK_AS_REP optional in non-strict mode

Commit c1433f821f7 added PADATA_PK_AS_REP (PA-PK-AS-REP, type 17) to
the expected padata list when check_rep_padata sees KDC_ERR_KEY_EXPIRED.
This reflects Samba's Heimdal KDC behaviour, which includes PKINIT hints
in expired-password error responses.

Samba with MIT KDC does not include PADATA_PK_AS_REP in KDC_ERR_KEY_EXPIRED
responses; it returns a METHOD-DATA with just the NTSTATUS payload (type 3) and
the FX-COOKIE (type 133).  This causes test_pw_expired to fail intermittently
when the expired-password code path is exercised against MIT KDC.

Add PADATA_PK_AS_REP to the require_strict set alongside PADATA_PK_AS_REP_19,
so it is treated as optional in non-strict checking mode (STRICT_CHECKING=0)
while still being enforced in strict mode.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Mar 30 10:41:07 UTC 2026 on atb-devel-224

3 weeks agoselftest: Fix missing --configfile in schema_pair_dc drs replicate cmd
Andreas Schneider [Wed, 25 Mar 2026 11:19:32 +0000 (12:19 +0100)] 
selftest: Fix missing --configfile in schema_pair_dc drs replicate cmd

Without the configuration argument, samba-tool falls back to
load_default() which fails in the test environment when there is no
system-wide smb.conf.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
3 weeks agoselftest: Add test_device_and_server_silo_restrictions to knownfail_mit_kdc
Andreas Schneider [Wed, 25 Mar 2026 10:38:50 +0000 (11:38 +0100)] 
selftest: Add test_device_and_server_silo_restrictions to knownfail_mit_kdc

MIT KRB5 1.22 fixed a spurious FAST armor processing error. In
KRB5 1.21 this spurious error caused verify_access() with device FAST
armor to fail, which accidentally made the device silo restriction check
in test_device_and_server_silo_restrictions appear to work.

With KRB5 1.22 the spurious error is gone. Device authentication is
still not implemented in MIT Kerberos, so the second assertRaises block
(user has silo assigned, device does not) no longer raises NTSTATUSError
and the test fails.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
3 weeks agopython:tests: Fix assertEqual placement in test_device_group_restrictions
Andreas Schneider [Wed, 25 Mar 2026 10:37:09 +0000 (11:37 +0100)] 
python:tests: Fix assertEqual placement in test_device_group_restrictions

The assertEqual calls checking the exception attributes were incorrectly
indented inside the 'with self.assertRaises()' block. When the expected
NTSTATUSError is raised by verify_access(), execution exits the block
immediately, so those lines were never reached.
When the exception is not raised (e.g. with MIT KRB5 1.22 where a spurious FAST
error was fixed), execution falls through to the assertEqual inside the block,
causing AttributeError because error.exception is only available after the
'with' block exits.

The exception returned is NT_STATUS_UNSUCCESSFUL with Heimdal.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
3 weeks agos3/librpc/crypto: Don't keep growing in memory keytab
Noel Power [Thu, 26 Mar 2026 12:03:55 +0000 (12:03 +0000)] 
s3/librpc/crypto: Don't keep growing in memory keytab

When we have long living concurrent connections every rpc bind
ends up calling and subsequently adding keytab entries to the
memory keytab returned by 'gse_krb5_get_server_keytab(...)'. This is
happening because as long as there is a handle open for the
keytab named "MEMORY:cifs_srv_keytab" then we keep adding entries to
it.

Note: There is no leak of gensec_security nor the krb5_keytab
      it contains. When rpc clients connected to the rpc worker process
      exit the gensec_security and the krb5_keytab structures are
      destructed as expected. However because we use a fixed name
      "MEMORY:cifs_srv_keytab" clients end up with a handle to a
      reference counted shared keytab. Destruction of the keytab results
      in the associated reference count being decremented. When the
      reference count reaches 0 the keytab is destroyed.

To avoid the keytab being extended the easiest solution is to ensure a
unique memory keytab is created for each client.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=16042
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Mar 30 09:36:45 UTC 2026 on atb-devel-224

3 weeks agoquic:libquic:handshake fix clang-22 warning
Gary Lockyer [Tue, 24 Mar 2026 02:02:19 +0000 (15:02 +1300)] 
quic:libquic:handshake fix clang-22 warning

Fix:
   ../../third_party/quic/libquic/handshake.c:567:56:
      error: format specifies type 'unsigned int' but the argument has type
             'size_t' (aka 'unsigned long') [-Werror,-Wformat]
        567   quic_log_debug("  Read func: %u %u %u", level, htype, datalen);
                                                 ~~                 ^~~~~~~

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Mon Mar 30 01:49:56 UTC 2026 on atb-devel-224

3 weeks agowafsamba: Add -D_FORTIFY_SOURCE=3 when stack protector is enabled
Andreas Schneider [Tue, 24 Mar 2026 14:00:21 +0000 (15:00 +0100)] 
wafsamba: Add -D_FORTIFY_SOURCE=3 when stack protector is enabled

The capability check in SAMBA_CONFIG_H() already tests that the compiler
accepts both -Wp,-D_FORTIFY_SOURCE and the stack protector flag
together, but only the stack protector flag was added to EXTRA_CFLAGS on
success.

The glibc normally silently downgrades to the supported level if the on
specified is not supported.

Note that -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 only sets it if not
already defined.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Mar 27 08:33:09 UTC 2026 on atb-devel-224

3 weeks agodocs-xml: Sync pam_winbind with pam_winbind.conf manpage
Andreas Schneider [Mon, 9 Feb 2026 10:05:10 +0000 (11:05 +0100)] 
docs-xml: Sync pam_winbind with pam_winbind.conf manpage

Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Mar 26 10:59:47 UTC 2026 on atb-devel-224

3 weeks agodocs-xml: Remove trailing spaces from pam_winbind.8.xml
Andreas Schneider [Mon, 9 Feb 2026 10:06:21 +0000 (11:06 +0100)] 
docs-xml: Remove trailing spaces from pam_winbind.8.xml

Reviewed-by: Alexander Bokovoy <ab@samba.org>
3 weeks agos3:winbind: Add support for krb5_ccache_type = DEFAULT
Andreas Schneider [Mon, 9 Feb 2026 10:02:11 +0000 (11:02 +0100)] 
s3:winbind: Add support for krb5_ccache_type = DEFAULT

This will use the ccache_type defined in the krb5.conf.

Pair-Programmed-With: Pavel Filipenský <pfilipen@samba.org>
Signed-off-by: Pavel Filipenský <pfilipen@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
3 weeks agolib:krb5_wrap: Add function to read the default_ccache_name config value
Andreas Schneider [Tue, 10 Feb 2026 13:00:43 +0000 (14:00 +0100)] 
lib:krb5_wrap: Add function to read the default_ccache_name config value

krb5_cc_default_name() expands the config value %{uid} is expanded to the
current id. However when we call this as winbind, it is expanded to root and not
the user we are authenticating. This functions reads directly from the config.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
3 weeks agos3:winbind: Also support %{uid} substitution for krb5_ccache_type
Andreas Schneider [Mon, 9 Feb 2026 10:00:45 +0000 (11:00 +0100)] 
s3:winbind: Also support %{uid} substitution for krb5_ccache_type

Pair-Programmed-With: Pavel Filipenský <pfilipen@redhat.com>
Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
3 weeks agodocs-xml: Update krb5_ccache_type documentation in pam_winbind.5 manpage
Andreas Schneider [Fri, 5 Dec 2025 10:19:32 +0000 (11:19 +0100)] 
docs-xml: Update krb5_ccache_type documentation in pam_winbind.5 manpage

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
3 weeks agos3:winbind: Improve generate_krb5_ccache()
Andreas Schneider [Fri, 5 Dec 2025 10:03:23 +0000 (11:03 +0100)] 
s3:winbind: Improve generate_krb5_ccache()

Signed-off-by: Andreas Schneider <asn@samba.org>
Pair-Programmed-With: Alexander Bokovoy <ab@samba.org>

Reviewed-by: Alexander Bokovoy <ab@samba.org>
3 weeks agovfs_ceph_new: do not set negative value in vfs_aio_state.error
Shachar Sharon [Sun, 22 Mar 2026 17:52:44 +0000 (19:52 +0200)] 
vfs_ceph_new: do not set negative value in vfs_aio_state.error

Ceph uses negative error valuers but Samba's VFS expects error value as
non-negative values (errno style).

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Avan Thakkar <athakkar@redhat.com>
Reviewed-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Thu Mar 26 09:23:11 UTC 2026 on atb-devel-224

3 weeks agovfs_ceph_new: avoid iref leak due to failure in ceph_ll_link
Shachar Sharon [Sun, 22 Mar 2026 17:50:16 +0000 (19:50 +0200)] 
vfs_ceph_new: avoid iref leak due to failure in ceph_ll_link

Even in cases where vfs_ceph_ll_link fails, we need to do iput in order
to decrement inode's ref-count.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Avan Thakkar <athakkar@redhat.com>
Reviewed-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 weeks agovfs_ceph_new: protect from malloc failure in ceph_getcwd
Shachar Sharon [Sun, 22 Mar 2026 17:46:13 +0000 (19:46 +0200)] 
vfs_ceph_new: protect from malloc failure in ceph_getcwd

When ceph_getcwd returns NULL (due to out-of-memory) bail out to avoid
segfault in strlen.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Avan Thakkar <athakkar@redhat.com>
Reviewed-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
3 weeks agoauth: Remove talloc_set_name_const() if talloc_keep_secret() changes the talloc name
Pavel Filipenský [Wed, 11 Mar 2026 19:07:05 +0000 (20:07 +0100)] 
auth: Remove talloc_set_name_const() if talloc_keep_secret() changes the talloc name

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Autobuild-User(timing): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(timing): Wed Mar 25 21:16:35 UTC 2026 on atb-devel-224

3 weeks agoauth/credentials: Add talloc_keep_secret() to zero out old_password
Pavel Filipenský [Wed, 11 Mar 2026 19:11:29 +0000 (20:11 +0100)] 
auth/credentials: Add talloc_keep_secret() to zero out old_password

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
3 weeks agoauth/credentials: Check talloc_strdup() for NULL
Pavel Filipenský [Thu, 12 Mar 2026 08:21:38 +0000 (09:21 +0100)] 
auth/credentials: Check talloc_strdup() for NULL

Return false if talloc_strdup() fails.

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
3 weeks agoutil/tests: Test that talloc_keep_secret() does not overwrite the name
Pavel Filipenský [Wed, 11 Mar 2026 18:37:11 +0000 (19:37 +0100)] 
util/tests: Test that talloc_keep_secret() does not overwrite the name

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
3 weeks agolib/util: Overwrite talloc name in talloc_keep_secret() only if it would reveal memor...
Pavel Filipenský [Wed, 11 Mar 2026 16:39:48 +0000 (17:39 +0100)] 
lib/util: Overwrite talloc name in talloc_keep_secret() only if it would reveal memory content

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
3 weeks agoutil/tests: Extend the 'test_talloc_keep_secret' test
Pavel Filipenský [Wed, 11 Mar 2026 18:36:22 +0000 (19:36 +0100)] 
util/tests: Extend the 'test_talloc_keep_secret' test

Test that talloc_strdup() puts the secret as talloc name.

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>