janger/samba-autobuild/.git
3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.14.4 release. samba-4.14.4
Karolin Seeger [Mon, 26 Apr 2021 08:26:38 +0000 (10:26 +0200)]
VERSION: Disable GIT_SNAPSHOT for the 4.14.4 release.

BUG 14571: CVE-2021-20254: Buffer overrun in sids_to_unixids().

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.14.4.
Karolin Seeger [Mon, 26 Apr 2021 08:26:10 +0000 (10:26 +0200)]
WHATSNEW: Add release notes for Samba 4.14.4.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoCVE-2021-20254 passdb: Simplify sids_to_unixids()
Volker Lendecke [Sat, 20 Feb 2021 14:50:12 +0000 (15:50 +0100)]
CVE-2021-20254 passdb: Simplify sids_to_unixids()

Best reviewed with "git show -b", there's a "continue" statement that
changes subsequent indentation.

Decouple lookup status of ids from ID_TYPE_NOT_SPECIFIED

Add comments to explain the use of the three lookup
loops.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry-picked from commit for master)

3 years agoVERSION: Bump version up to 4.14.4...
Karolin Seeger [Mon, 19 Apr 2021 07:57:25 +0000 (09:57 +0200)]
VERSION: Bump version up to 4.14.4...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
(cherry picked from commit a8b9ea7e1aa4f526bd73baee45f0a3483c95381a)

3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.14.3 release. samba-4.14.3
Karolin Seeger [Mon, 19 Apr 2021 07:56:47 +0000 (09:56 +0200)]
VERSION: Disable GIT_SNAPSHOT for the 4.14.3 release.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.14.3.
Karolin Seeger [Mon, 19 Apr 2021 07:56:20 +0000 (09:56 +0200)]
WHATSNEW: Add release notes for Samba 4.14.3.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agobuild: Notice if flex is missing at configure time
Andrew Bartlett [Fri, 26 Mar 2021 08:48:45 +0000 (21:48 +1300)]
build: Notice if flex is missing at configure time

This may also fix the coverage build by ensuring --noline
is always specified to flex.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Mar 29 02:12:23 UTC 2021 on sn-devel-184

(cherry picked from commit 942c0d2128cb8e64a9354dde6bdae82a1c1c3d88)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Tue Apr 20 07:39:05 UTC 2021 on sn-devel-184

3 years agos3-iremotewinspool: set the per-request memory context
Samuel Cabrero [Thu, 8 Apr 2021 16:45:38 +0000 (18:45 +0200)]
s3-iremotewinspool: set the per-request memory context

The iremotewinspool service is not using the pidl autogenerated code.
Set the per-request memory context following the changes made is commit
5a7e9ade9a4cdfa68900c6a64b639f53c0da47ad.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1890

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Apr  9 15:20:02 UTC 2021 on sn-devel-184

(cherry picked from commit 1efa9ffd7ae77ebf22b28c12dd642a89991b75d2)

3 years agobuild: Only add -Wl,--as-needed when supported
Martin Schwenke [Mon, 29 Mar 2021 05:30:37 +0000 (16:30 +1100)]
build: Only add -Wl,--as-needed when supported

If -Wl,--as-needed is added to EXTRA_LDFLAGS (via ADD_LDFLAGS, as per
commit 996560191ac6bd603901dcd6c0de5d239e019ef4) then on some
platforms (at least CentOS 8 and Fedora 33), any indirect/recursive
dependencies (i.e. private libraries) are added to both the
binary (reqid_test in the CTDB case) and to samba-util.so.  However,
only samba-util.so has rpath set to find private libraries.

When ld.so tries to resolve these dependencies for the binary it
fails. This may be a bug on those platforms, but it occurs reliably
and our users will also hit the bug.  For binaries that have other
private library dependencies (e.g. bundled talloc) rpath will contain
the private library directory so the duplicate private library
dependencies are then found... that is, when it works, it works by
accident!

For some reason (deep in waf or wafsamba) if -Wl,--as-needed is added to
LINKFLAGS (as is done in conf.add_as_needed()) then it works: the direct
dependencies are only added to samba-util.so and the same depenencies
(indirect dependencies for binaries) are not added incorrectly to the
binaries.

So, without changing 1/2 of waf/wafsamba the simplest fix is to revert
to adding -Wl,--as-needed to LINKFLAGS, which was the case before
commit 996560191ac6bd603901dcd6c0de5d239e019ef4.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14288
RN: Fix the build on OmniOS

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Bjoern Jacke <bj@sernet.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(backported from commit ff1c3af603b47a7e8f9faad8d1c2e4a489559155)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Wed Apr 14 07:34:20 UTC 2021 on sn-devel-184

3 years agos3: smbd: fix deferred renames
Ralph Boehme [Mon, 29 Mar 2021 10:24:39 +0000 (12:24 +0200)]
s3: smbd: fix deferred renames

This was broken by c7a9e0e4cdfb22e66533b5c8e20af3cfdb8ae78c.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14679
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1875

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@amba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Mar 31 06:13:39 UTC 2021 on sn-devel-184

(cherry picked from commit 10d753868e810604d8f60673bbd48f55aaff0797)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Thu Apr  1 11:26:31 UTC 2021 on sn-devel-184

3 years agos4: torture. Add smb2.lease.rename_wait test to reproduce regression in delay rename...
Jeremy Allison [Tue, 30 Mar 2021 22:05:47 +0000 (15:05 -0700)]
s4: torture. Add smb2.lease.rename_wait test to reproduce regression in delay rename for lease break code.

Passes against Windows 10. Add to knownfail, the
next commit will fix this.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14679
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1875

Back-ported from 8d9a0b8d57713781c72440c7e91746b5d89e6f6a.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agorpc_server3: Fix a memleak for internal pipes
Volker Lendecke [Tue, 23 Mar 2021 16:06:15 +0000 (17:06 +0100)]
rpc_server3: Fix a memleak for internal pipes

state->call should not be talloc'ed off a long-lived context

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861
RN: Memory leak in the RPC server

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Mar 31 12:14:01 UTC 2021 on sn-devel-184

(cherry picked from commit 12f516e4680753460e7fe8811e6c6ff70057580c)

3 years agospools: avoid leaking memory into the callers mem_ctx
Ralph Boehme [Mon, 22 Mar 2021 11:06:39 +0000 (12:06 +0100)]
spools: avoid leaking memory into the callers mem_ctx

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit 481176ec745c14b78fca68e01a61c83405a4b97b)

3 years agopidl: set the per-request memory context in the pidl generator
Ralph Boehme [Tue, 23 Mar 2021 10:40:21 +0000 (11:40 +0100)]
pidl: set the per-request memory context in the pidl generator

The talloc memory context referenced by the pipe_struct mem_ctx member is used
as talloc parent for RPC response data by the RPC service implementations.

In Samba versions up to 4.10 all talloc children of p->mem_ctx were freed after
a RPC response was delivered by calling talloc_free_children(p->mem_ctx). Commit
60fa8e255254d38e9443bf96f2c0f31430be6ab8 removed this call which resulted in all
memory allocations on this context not getting released, which can consume
significant memory in long running RPC connections.

Instead of putting the talloc_free_children(p->mem_ctx) back, just use the
mem_ctx argument of the ${pipename}_op_dispatch_internal() function which is a
dcesrv_call_state object created by dcesrv_process_ncacn_packet() and released
by the RPC server when the RPC request processing is finished.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit 4c3fb2a5912966a61e7ebdb05eb3231a0e1d6033)

3 years agosmbd: free open_rec state in remove_deferred_open_message_smb2_internal()
Ralph Boehme [Tue, 16 Mar 2021 17:18:46 +0000 (18:18 +0100)]
smbd: free open_rec state in remove_deferred_open_message_smb2_internal()

The lifetime of open_rec (struct deferred_open_record) ojects is the time
processing the SMB open request every time the request is scheduled, ie once we
reschedule we must wipe the slate clean. In case the request gets deferred
again, a new open_rec will be created by the schedule functions.

This ensures any timer-event tied to the open_rec gets cancelled and doesn't
fire unexpectedly.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14672
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1843
RN: smbd panic when two clients open same file

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Mar 18 18:04:09 UTC 2021 on sn-devel-184

(cherry picked from commit 591c9196962b695b01c0d86918b8f8a263e9665c)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Wed Mar 31 11:10:29 UTC 2021 on sn-devel-184

3 years agosmbd: cancel pending poll open timer in poll_open_done()
Ralph Boehme [Wed, 17 Mar 2021 15:24:28 +0000 (16:24 +0100)]
smbd: cancel pending poll open timer in poll_open_done()

The retry of the open is scheduled below, avoid rescheduling it a second time in
the open retry timeout function.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14672
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1843

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 171a58ff3e8ee07cf5d7af08eabcb4a7379e7ce5)

3 years agosmbd: reset dangling watch_req pointer in poll_open_done
Ralph Boehme [Wed, 17 Mar 2021 15:22:37 +0000 (16:22 +0100)]
smbd: reset dangling watch_req pointer in poll_open_done

We just freed subreq and a pointer to subreq is stored in open_rec->watch_req,
so we must invalidate the pointer.

Otherwise if the poll open timer fires it will do a

  TALLOC_FREE(open_rec->watch_req);

on the dangling pointer which may crash or do something worse like freeing some
other random talloc memory.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14672
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1843

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 065ed088b3d5710c288e46a5bf1e063f9a29c8cc)

3 years agos3:modules:vfs_virusfilter: Recent New_VFS changes break vfs_virusfilter_openat.
Trever L. Adams [Sat, 13 Mar 2021 19:47:21 +0000 (12:47 -0700)]
s3:modules:vfs_virusfilter: Recent New_VFS changes break vfs_virusfilter_openat.

The_New_VFS introduces several changes that broke vfs_virusfilter_openat. The assert to make sure certain checks would work broke.

This patch fixes those breaks and converts to the SMB_VFS_FSTAT_NEXT instead of SMB_VFS_STAT_NEXT.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14671
RN: vfs_virusfilter_openat support New_VFS FSTAT, avoid SMB_ASSERT(fsp_get_pathref_fd(dirfsp) == AT_FDCWD); problem.

Signed-off-by: Trever L. Adams" <trever.adams@gmail.com>
Reviewed-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 Mar 22 19:44:30 UTC 2021 on sn-devel-184

(cherry picked from commit d6a16ad00e426a6f815215af71c071dd8e85a50a)

3 years agosamba-gpupdate: Check sysvol download paths in case-insensitive way
David Mulder [Tue, 9 Mar 2021 18:13:40 +0000 (11:13 -0700)]
samba-gpupdate: Check sysvol download paths in case-insensitive way

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

Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Björn Baumbach <bb@sernet.de>
(cherry picked from commit 2d6bed495e14349e19ba680bd72c3f110f1c397b)

3 years agosamba-gpupdate: Test that sysvol paths download in case-insensitive way
David Mulder [Tue, 9 Mar 2021 19:30:14 +0000 (12:30 -0700)]
samba-gpupdate: Test that sysvol paths download in case-insensitive way

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

Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Björn Baumbach <bb@sernet.de>
(cherry picked from commit 554f2134a9f9638ebd8ac2500e5b6c94b74c27d5)

3 years agoidmap_nss: Do not return SID from unixids_to_sids on type mismatch
Christof Schmitt [Fri, 5 Mar 2021 23:07:54 +0000 (16:07 -0700)]
idmap_nss: Do not return SID from unixids_to_sids on type mismatch

The call to winbind_lookup_name already wrote the result in the id_map
array. The later check for the type detected a mismatch, but that did
not remove the SID from the result struct.

Change this by first assigning the SID to a temporary variable and only
write it to the id_map array after the type checks.

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

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Mar 11 08:38:41 UTC 2021 on sn-devel-184

(cherry picked from commit 0e789ba1802ca22e5a01abd6e93ef66cd45566a7)

3 years agoidmap_rfc2307: Do not return SID from unixids_to_sids on type mismatch
Christof Schmitt [Fri, 5 Mar 2021 23:01:13 +0000 (16:01 -0700)]
idmap_rfc2307: Do not return SID from unixids_to_sids on type mismatch

The call to winbind_lookup_name already wrote the result in the id_map
array. The later check for the type detected a mismatch, but that did
not remove the SID from the result struct.

Change this by first assigning the SID to a temporary variable and only
write it to the id_map array after the type checks.

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

Signed-off-by: Christof Schmitt <cs@samba.org>
(cherry picked from commit 79dd4b133c37451c98fe7f7c45da881e89e91ffc)

3 years agowinbind: Only use unixid2sid mapping when module reports ID_MAPPED
Christof Schmitt [Fri, 5 Mar 2021 22:48:29 +0000 (15:48 -0700)]
winbind: Only use unixid2sid mapping when module reports ID_MAPPED

Only consider a mapping to be valid when the idmap module reports
ID_MAPPED. Otherwise return the null SID.

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

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit db2afa57e4aa926b478db1be4d693edbdf4d2a23)

3 years agosmbd: Ensure errno is preserved across fsp destructor
Sachin Prabhu [Wed, 10 Mar 2021 12:22:07 +0000 (12:22 +0000)]
smbd: Ensure errno is preserved across fsp destructor

The errno can be overwritten by the calls made by the fsp destructor.
This can cause problems if the original errno was required by subsequent
calls.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Mar 10 22:55:17 UTC 2021 on sn-devel-184

(cherry picked from commit 65510204d4123b1825ea57607e84ba50f8ce3baf)

3 years agothird_party: Update socket_wrapper to version 1.3.3
Stefan Metzmacher [Wed, 17 Feb 2021 11:57:01 +0000 (12:57 +0100)]
third_party: Update socket_wrapper to version 1.3.3

This fixes a deadlock abort() when SOCKET_WRAPPER_KEEP_PCAP=1
is used.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Mar 17 23:53:04 UTC 2021 on sn-devel-184

(cherry picked from commit 10c198827d977e07b411897556578d3aedce2184)

3 years agothird_party: Update socket_wrapper to version 1.3.2
Stefan Metzmacher [Tue, 9 Feb 2021 07:56:42 +0000 (08:56 +0100)]
third_party: Update socket_wrapper to version 1.3.2

This brings support for fd-passing of INET sockets.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit ab943babc3eb454186558f6e863996dfcf7a20ea)

3 years agoVERSION: Bump version up to 4.14.2...
Stefan Metzmacher [Wed, 24 Mar 2021 10:55:22 +0000 (11:55 +0100)]
VERSION: Bump version up to 4.14.2...

GIT_SNAPSHOT is already 'yes'.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoMerge tag 'samba-4.14.2' into v4-14-test
Stefan Metzmacher [Wed, 24 Mar 2021 10:55:04 +0000 (11:55 +0100)]
Merge tag 'samba-4.14.2' into v4-14-test

samba: tag release samba-4.14.2

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.14.2. samba-4.14.2
Karolin Seeger [Wed, 24 Mar 2021 10:07:42 +0000 (11:07 +0100)]
WHATSNEW: Add release notes for Samba 4.14.2.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoVERSION: Bump version for Samba 4.14.2 release.
Stefan Metzmacher [Wed, 24 Mar 2021 09:24:47 +0000 (10:24 +0100)]
VERSION: Bump version for Samba 4.14.2 release.

o BUG #14595: CVE-2020-27840: Heap corruption via crafted DN strings.
o BUG #14655: CVE-2021-20277: Out of bounds read in AD DC LDAP server.

Note this is exactly the same as 4.14.1, except that it
has a dependency on ldb version 2.3.0, which is needed if
someone builds against a system libldb.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoldb: version 2.3.0 ldb-2.3.0
Stefan Metzmacher [Wed, 24 Mar 2021 09:23:06 +0000 (10:23 +0100)]
ldb: version 2.3.0

o BUG #14595: CVE-2020-27840: Heap corruption via crafted DN strings.
o BUG #14655: CVE-2021-20277: Out of bounds read in AD DC LDAP server.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.14.1 release. samba-4.14.1
Karolin Seeger [Tue, 23 Mar 2021 08:29:08 +0000 (09:29 +0100)]
VERSION: Disable GIT_SNAPSHOT for the 4.14.1 release.

o BUG #14595: CVE-2020-27840: Heap corruption via crafted DN strings.
o BUG #14655: CVE-2021-20277: Out of bounds read in AD DC LDAP server.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.14.1.
Karolin Seeger [Tue, 23 Mar 2021 08:28:00 +0000 (09:28 +0100)]
WHATSNEW: Add release notes for Samba 4.14.1.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoCVE-2020-27840: pytests: move Dn.validate test to ldb
Douglas Bagnall [Thu, 11 Feb 2021 03:28:43 +0000 (16:28 +1300)]
CVE-2020-27840: pytests: move Dn.validate test to ldb

We had the test in the Samba Python segfault suite because
a) the signal catching infrastructure was there, and
b) the ldb tests lack Samba's knownfail mechanism, which allowed us to
   assert the failure.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-27840 ldb_dn: avoid head corruption in ldb_dn_explode
Douglas Bagnall [Fri, 11 Dec 2020 03:32:25 +0000 (16:32 +1300)]
CVE-2020-27840 ldb_dn: avoid head corruption in ldb_dn_explode

A DN string with lots of trailing space can cause ldb_dn_explode() to
put a zero byte in the wrong place in the heap.

When a DN string has a value represented with trailing spaces,
like this

     "CN=foo   ,DC=bar"

the whitespace is supposed to be ignored. We keep track of this in the
`t` pointer, which is NULL when we are not walking through trailing
spaces, and points to the first space when we are. We are walking with
the `p` pointer, writing the value to `d`, and keeping the length in
`l`.

     "CN=foo   ,DC= "       ==>       "foo   "
            ^  ^                             ^
            t  p                             d
                                       --l---

The value is finished when we encounter a comma or the end of the
string. If `t` is not NULL at that point, we assume there are trailing
spaces and wind `d and `l` back by the correct amount. Then we switch
to expecting an attribute name (e.g. "CN"), until we get to an "=",
which puts us back into looking for a value.

Unfortunately, we forget to immediately tell `t` that we'd finished
the last value, we can end up like this:

     "CN=foo   ,DC= "       ==>        ""
            ^      ^                    ^
            t      p                    d
                                        l=0

where `p` is pointing to a new value that contains only spaces, while
`t` is still referring to the old value. `p` notices the value ends,
and we subtract `p - t` from `d`:

     "CN=foo   ,DC= "       ==>  ?     ""
            ^       ^            ^
            t       p            d
                                      l ~= SIZE_MAX - 8

At that point `d` wants to terminate its string with a '\0', but
instead it terminates someone else's byte. This does not crash if the
number of trailing spaces is small, as `d` will point into a previous
value (a copy of "foo" in this example). Corrupting that value will
ultimately not matter, as we will soon try to allocate a buffer `l`
long, which will be greater than the available memory and the whole
operation will fail properly.

However, with more spaces, `d` will point into memory before the
beginning of the allocated buffer, with the exact offset depending on
the length of the earlier attributes and the number of spaces.

What about a longer DN with more attributes? For example,
"CN=foo     ,DC= ,DC=example,DC=com" -- since `d` has moved out of
bounds, won't we continue to use it and write more DN values into
mystery memory? Fortunately not, because the aforementioned allocation
of `l` bytes must happen first, and `l` is now huge. The allocation
happens in a talloc_memdup(), which is by default restricted to
allocating 256MB.

So this allows a person who controls a string parsed by ldb_dn_explode
to corrupt heap memory by placing a single zero byte at a chosen
offset before the allocated buffer.

An LDAP bind request can send a string DN as a username. This DN is
necessarily parsed before the password is checked, so an attacker does
not need proper credentials. The attacker can easily cause a denial of
service and we cannot rule out more subtle attacks.

The immediate solution is to reset `t` to NULL when a comma is
encountered, indicating that we are no longer looking at trailing
whitespace.

Found with the help of Honggfuzz.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-27840: pytests:segfault: add ldb.Dn validate test
Douglas Bagnall [Thu, 11 Feb 2021 04:05:14 +0000 (17:05 +1300)]
CVE-2020-27840: pytests:segfault: add ldb.Dn validate test

ldb.Dn.validate wraps ldb_dn_explode.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20277 ldb/attrib_handlers casefold: stay in bounds
Douglas Bagnall [Tue, 8 Dec 2020 08:32:09 +0000 (21:32 +1300)]
CVE-2021-20277 ldb/attrib_handlers casefold: stay in bounds

For a string that had N spaces at the beginning, we would
try to move N bytes beyond the end of the string.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry-picked from commit for master)

3 years agoCVE-2021-20277 ldb: Remove tests from ldb_match_test that do not pass
Andrew Bartlett [Thu, 11 Mar 2021 22:51:56 +0000 (11:51 +1300)]
CVE-2021-20277 ldb: Remove tests from ldb_match_test that do not pass

This reverts some of the backport of 33a95a1e75b85e9795c4490b78ead2162e2a1f47

This is done here rather than squashed in the cherry-pick of the expanded testsuite
because it allows this commit to be simply reverted for the backport of bug 14044
if this lands first, or to be dropped if bug 14044 lands first.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2021-20277 ldb tests: ldb_match tests with extra spaces
Douglas Bagnall [Fri, 5 Mar 2021 07:13:01 +0000 (20:13 +1300)]
CVE-2021-20277 ldb tests: ldb_match tests with extra spaces

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry-picked from commit for master)

3 years agoldb: add tests for ldb_wildcard_compare
Douglas Bagnall [Fri, 5 Mar 2021 02:47:56 +0000 (15:47 +1300)]
ldb: add tests for ldb_wildcard_compare

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Björn Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry-picked from commit 33a95a1e75b85e9795c4490b78ead2162e2a1f47)

3 years agoVERSION: Bump version up to 4.14.1...
Karolin Seeger [Tue, 9 Mar 2021 12:31:47 +0000 (13:31 +0100)]
VERSION: Bump version up to 4.14.1...

and-re-enable GIT_SNAPSHOT.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
(cherry picked from commit 3fa3608e8f00df81ae7504f26459b42da069d322)

3 years agoVERSION: Bump version up to 4.14.1...
Karolin Seeger [Tue, 9 Mar 2021 12:31:47 +0000 (13:31 +0100)]
VERSION: Bump version up to 4.14.1...

and-re-enable GIT_SNAPSHOT.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoVERSION: Bump version up to 4.14.0... samba-4.14.0
Karolin Seeger [Tue, 9 Mar 2021 12:30:50 +0000 (13:30 +0100)]
VERSION: Bump version up to 4.14.0...

and disable GIT_SNAPSHOT for the release.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.14.0.
Karolin Seeger [Tue, 9 Mar 2021 12:27:49 +0000 (13:27 +0100)]
WHATSNEW: Add release notes for Samba 4.14.0.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoRevert "wscript: use --as-needed only if tested successfully"
Karolin Seeger [Tue, 9 Mar 2021 08:18:16 +0000 (09:18 +0100)]
Revert "wscript: use --as-needed only if tested successfully"

This reverts commit 4d1ed9c319deac5cba1682611dcefdf002cb9d48.

3 years agog_lock: Fix uninitalized variable reads
Volker Lendecke [Wed, 3 Mar 2021 18:15:31 +0000 (19:15 +0100)]
g_lock: Fix uninitalized variable reads

If dbwrap_watched_watch_recv() returns IO_TIMEOUT, "blockerdead" might
be an uninitialized non-false, and further down we'll remove the wrong
exclusive locker.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14636
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Mar  5 11:22:07 UTC 2021 on sn-devel-184

(cherry picked from commit 654c18a244f060d81280493a324b98602a69dbbf)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Mon Mar  8 10:58:06 UTC 2021 on sn-devel-184

3 years agolocking: Fix an uninitialized variable read
Volker Lendecke [Wed, 3 Mar 2021 18:19:23 +0000 (19:19 +0100)]
locking: Fix an uninitialized variable read

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14636
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 84b634c613352fc1da8e1525d72597c526d534d2)

3 years agos3:modules:vfs_virusfilter: Recent talloc changes cause infinite start-up failure
Trever L. Adams [Fri, 26 Feb 2021 22:52:03 +0000 (14:52 -0800)]
s3:modules:vfs_virusfilter: Recent talloc changes cause infinite start-up failure

Recent talloc changes cause the current check for failure to allocate to be incorrectly triggered.

This patch checks to see if the original parameter to be checked for NULL if the talloc returns NULL. This allows for rapid passing in the ca

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14634
RN: Fix failure of vfs_virusfilter starting due to talloc changes

Signed-off-by: Trever L. Adams" <trever.adams@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
(cherry picked from commit 5a92810082c9a9d2833946ae0d83ce05a6bde597)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Fri Mar  5 14:25:49 UTC 2021 on sn-devel-184

3 years agowscript: use --as-needed only if tested successfully
Björn Jacke [Tue, 2 Mar 2021 21:47:35 +0000 (22:47 +0100)]
wscript: use --as-needed only if tested successfully

Some OSes like Solaris based OmiOS don't support this.

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

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 996560191ac6bd603901dcd6c0de5d239e019ef4)

3 years agos3: VFS: nfs4_acls. Add missing TALLOC_FREE(frame) in error path.
Peter Eriksson [Tue, 23 Feb 2021 20:13:37 +0000 (12:13 -0800)]
s3: VFS: nfs4_acls. Add missing TALLOC_FREE(frame) in error path.

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

Signed-off-by: Peter Eriksson <pen@lysator.liu.se>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Autobuild-User(master): David Mulder <dmulder@samba.org>
Autobuild-Date(master): Thu Feb 25 20:46:02 UTC 2021 on sn-devel-184

(cherry picked from commit 3d91fe071a29e2e0c54a10ba081a46cb5c324585)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Wed Mar  3 10:12:36 UTC 2021 on sn-devel-184

3 years agoWHATSNEW: Remove some old stuff.
Karolin Seeger [Mon, 1 Mar 2021 11:25:31 +0000 (12:25 +0100)]
WHATSNEW: Remove some old stuff.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Mon Mar  1 20:35:12 UTC 2021 on sn-devel-184

3 years agoVERSION: Bump version up to 4.14.0rc5...
Karolin Seeger [Mon, 1 Mar 2021 09:27:24 +0000 (10:27 +0100)]
VERSION: Bump version up to 4.14.0rc5...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.14.0rc4 release. samba-4.14.0rc4
Karolin Seeger [Mon, 1 Mar 2021 09:25:56 +0000 (10:25 +0100)]
VERSION: Disable GIT_SNAPSHOT for the 4.14.0rc4 release.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.14.0rc4.
Karolin Seeger [Mon, 1 Mar 2021 09:25:19 +0000 (10:25 +0100)]
WHATSNEW: Add release notes for Samba 4.14.0rc4.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agosmbd: don't overwrite _mode if neither a msdfs symlink nor get_dosmode is requested
Ralph Boehme [Mon, 1 Feb 2021 11:37:10 +0000 (12:37 +0100)]
smbd: don't overwrite _mode if neither a msdfs symlink nor get_dosmode is requested

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit d78964c40b5ca5ee0658c46d492b3dcd6f6b4b94)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Fri Feb 26 10:00:59 UTC 2021 on sn-devel-184

3 years agoCI: verify a symlink has FILE_ATTRIBUTE_NORMAL set
Ralph Boehme [Mon, 1 Feb 2021 13:44:03 +0000 (14:44 +0100)]
CI: verify a symlink has FILE_ATTRIBUTE_NORMAL set

Not that it really makes sense to set FILE_ATTRIBUTE_NORMAL for symlinks in
POSIX client context, but that's what we had before 4.14.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 5572ae296e720a00ab438d7b50cfc458af631f69)

3 years agovfs_aixacl: fix regression from f4c2f867f035fcbe3d547d5635d058b0aec7636a
Ralph Boehme [Tue, 26 Jan 2021 09:55:42 +0000 (10:55 +0100)]
vfs_aixacl: fix regression from f4c2f867f035fcbe3d547d5635d058b0aec7636a

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Björn Jacke <bjacke@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Jan 26 20:05:39 UTC 2021 on sn-devel-184

(cherry picked from commit 7114150f43751ab869323b91da83705b1e1ab465)

3 years agovfs: restore platform specific POSIX sys_acl_set_file() functions
Ralph Boehme [Tue, 26 Jan 2021 14:50:00 +0000 (15:50 +0100)]
vfs: restore platform specific POSIX sys_acl_set_file() functions

92b149954237a445594c993b79a860c63113d54b removed SMB_VFS_SYS_ACL_SET_FILE() and
all the VFS module implementations. But sys_acl_set_file() in vfs_default calls
into sys_acl_set_file() in sysacls.c which calls back into platform specific
modules.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Björn Jacke <bjacke@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Jan 28 15:21:02 UTC 2021 on sn-devel-184

(cherry picked from commit c8c2aef0ac613849d641e39193448f3e512caccf)

3 years agosmbd: In conn_force_tdis_done() when forcing a connection closed force a full reload...
Jeremy Allison [Wed, 27 Jan 2021 05:29:58 +0000 (21:29 -0800)]
smbd: In conn_force_tdis_done() when forcing a connection closed force a full reload of services.

Prevents reload_services() caching the fact it might be
called multiple times in a row.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit e4c8cd0781aef2a29bb4db1314c9fcd4f6edcecd)

3 years agodbcheck: Check Deleted Objects and reduce noise in reports about expired tombstones
Andrew Bartlett [Thu, 10 Dec 2020 03:03:49 +0000 (16:03 +1300)]
dbcheck: Check Deleted Objects and reduce noise in reports about expired tombstones

These reports (about recently deleted objects)
create concern about a perfectly normal part of DB operation.

We must not operate on objects that are expired or we might reanimate them,
but we must fix "Deleted Objects" if it is wrong (mostly it is set as being
deleted in 9999, but in alpha19 we got this wrong).

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Feb  3 05:29:11 UTC 2021 on sn-devel-184

(cherry picked from commit da627106cdbf8d375b25fa3338a717447f3dbb6e)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Mon Feb 22 12:00:43 UTC 2021 on sn-devel-184

3 years agoselftest: Confirm that we fix any errors on the Deleted Objects container itself
Andrew Bartlett [Fri, 11 Dec 2020 02:37:04 +0000 (15:37 +1300)]
selftest: Confirm that we fix any errors on the Deleted Objects container itself

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit 1ec1c35a3ae422720df491f5555c9bc787c9944c)

3 years agoprinting: use correct error out in get_correct_cversion() when openat_pathref_fsp...
Ralph Boehme [Tue, 16 Feb 2021 13:24:05 +0000 (14:24 +0100)]
printing: use correct error out in get_correct_cversion() when openat_pathref_fsp() fails

Fixes a regression introduced by a74f0af1a91fe0bbc68e4d41d65f43ec383ae8bf: if
there's no existing file, openat_pathref_fsp() will fail with
NT_STATUS_OBJECT_NAME_NOT_FOUND which must be handled the same way it is done by
the SMB_VFS_CREATE_FILE() call below.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14635
RN: Printerdriver upload 4.14rc1 not working

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Feb 17 19:53:00 UTC 2021 on sn-devel-184

(cherry picked from commit 718f7b1a84f1c6eb35d52232a8573370f45add56)

3 years agoprinting: use correct error out in file_version_is_newer() when openat_pathref_fsp...
Ralph Boehme [Tue, 16 Feb 2021 13:23:02 +0000 (14:23 +0100)]
printing: use correct error out in file_version_is_newer() when openat_pathref_fsp() fails

Fixes a regression introduced by ef5e913bca584f0232d5bfff14df4ccba2dda35c: if
there's no existing file, openat_pathref_fsp() will fail with
NT_STATUS_OBJECT_NAME_NOT_FOUND which must be handled the same way it is done by
the SMB_VFS_CREATE_FILE() call below.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
(cherry picked from commit 70063c523bff5e471eac2b011b243c5aa0c4bee1)

3 years agoprinting: use correct error out in file_version_is_newer() when openat_pathref_fsp...
Ralph Boehme [Tue, 16 Feb 2021 13:19:51 +0000 (14:19 +0100)]
printing: use correct error out in file_version_is_newer() when openat_pathref_fsp() fails

Fixes a regression introduced by cbe25e1777d0c43c21e8acc2cea79fd03fdaf2ea: if
there's no existing file, openat_pathref_fsp() will fail with
NT_STATUS_OBJECT_NAME_NOT_FOUND which must be handled the same way it is done by
the SMB_VFS_CREATE_FILE() call below.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
(cherry picked from commit 8c1fd86db873f0326faf1cefa731a03709f8ac7f)

3 years agoVERSION: Bump version up to 4.14.0rc4...
Karolin Seeger [Thu, 18 Feb 2021 08:57:15 +0000 (09:57 +0100)]
VERSION: Bump version up to 4.14.0rc4...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoVERSION: Bump version up to 4.14.0rc3. samba-4.14.0rc3
Karolin Seeger [Thu, 18 Feb 2021 08:56:00 +0000 (09:56 +0100)]
VERSION: Bump version up to 4.14.0rc3.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.14.0rc3.
Karolin Seeger [Thu, 18 Feb 2021 08:55:28 +0000 (09:55 +0100)]
WHATSNEW: Add release notes for Samba 4.14.0rc3.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoclassicupgrade: treat old never expires value right
Björn Jacke [Fri, 5 Feb 2021 11:47:01 +0000 (12:47 +0100)]
classicupgrade: treat old never expires value right

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

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): Wed Feb 10 15:06:49 UTC 2021 on sn-devel-184

(cherry picked from commit df75d82c9de6977c466ee9f01886cb012a9c5fef)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Tue Feb 16 18:27:20 UTC 2021 on sn-devel-184

3 years agos3:pysmbd: fix fd leak in py_smbd_create_file()
Stefan Metzmacher [Tue, 9 Feb 2021 12:48:36 +0000 (13:48 +0100)]
s3:pysmbd: fix fd leak in py_smbd_create_file()

Various 'samba-tool domain backup' commands use this and will
fail if there's over ~1000 files in the sysvol folder.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit d8fa464a2dfb11df4e1db4ebffe8bd28ff118c75)

3 years agoHEIMDAL: krb5_storage_free(NULL) should work
Paul Wise [Mon, 29 Feb 2016 17:58:45 +0000 (11:58 -0600)]
HEIMDAL: krb5_storage_free(NULL) should work

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

Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Original-author: Nicolas Williams <nico@twosigma.com>
(cherry-picked from heimdal commit b3db07d5f0e03f6a1a0a392e70f9675e19a6d6af)
(cherry picked from commit f9ed4f7028a5ed29026ac8ef1b47b63755ba98f8)

3 years agolib:util: Avoid free'ing our own pointer
Andreas Schneider [Tue, 2 Feb 2021 17:10:38 +0000 (18:10 +0100)]
lib:util: Avoid free'ing our own pointer

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 0bdbe50fac680be3fe21043246b8c75005611351)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Tue Feb  9 13:31:03 UTC 2021 on sn-devel-184

3 years agolib:util: Add cache oversize test for memcache
Andreas Schneider [Wed, 3 Feb 2021 09:37:12 +0000 (10:37 +0100)]
lib:util: Add cache oversize test for memcache

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 00543ab3b29e3fbfe8314e51919629803e14ede6)

3 years agolib:util: Add basic memcache unit test
Andreas Schneider [Wed, 3 Feb 2021 09:30:08 +0000 (10:30 +0100)]
lib:util: Add basic memcache unit test

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit bebbf621d6052f797c5cf19a2a9bbc13e699d3f0)

3 years agoVERSION: Bump version up to Samba 4.14.0rc3...
Karolin Seeger [Thu, 4 Feb 2021 08:22:53 +0000 (09:22 +0100)]
VERSION: Bump version up to Samba 4.14.0rc3...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.14.0rc2 release. samba-4.14.0rc2
Karolin Seeger [Thu, 4 Feb 2021 08:22:08 +0000 (09:22 +0100)]
VERSION: Disable GIT_SNAPSHOT for the 4.14.0rc2 release.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.14.0rc2.
Karolin Seeger [Thu, 4 Feb 2021 08:21:27 +0000 (09:21 +0100)]
WHATSNEW: Add release notes for Samba 4.14.0rc2.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agos3: libsmb: cli_state_save_tcon(). Don't deepcopy tcon struct when temporarily swappi...
Jeremy Allison [Thu, 28 Jan 2021 19:08:48 +0000 (11:08 -0800)]
s3: libsmb: cli_state_save_tcon(). Don't deepcopy tcon struct when temporarily swapping out a connection on a cli_state.

This used to make a deep copy of either
cli->smb2.tcon or cli->smb1.tcon, but this leaves
the original tcon pointer in place which will then get
TALLOC_FREE()'d when the new tree connection is made on
this cli_state.

As there may be pipes open on the old tree connection with
talloc'ed state allocated using the original tcon pointer as a
talloc parent we can't deep copy and then free this pointer
as that will fire the destructors on the pipe memory and
mark them as not connected.

This call is used to temporarily swap out a tcon pointer
(whilst keeping existing pipes open) to allow a new tcon
on the same cli_state and all users correctly call
cli_state_restore_tcon() once they are finished with
the new tree connection.

Just return the existing pointer and set the old value to NULL.
We know we MUST be calling cli_state_restore_tcon() below
to restore the original tcon tree connection pointer before
closing the session.

Remove the knownfail.d entry.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Feb  2 21:05:25 UTC 2021 on sn-devel-184

(cherry picked from commit 4f80f5f9046b64a9e5e0503b1cb54f1492c4faec)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Wed Feb  3 22:32:58 UTC 2021 on sn-devel-184

3 years agos3: torture: Change the SMB1-only UID-REGRESSION-TEST to do an explicit copy of the...
Jeremy Allison [Fri, 29 Jan 2021 01:35:55 +0000 (17:35 -0800)]
s3: torture: Change the SMB1-only UID-REGRESSION-TEST to do an explicit copy of the tcon struct in use.

For this test only, explicitly copy the SMB1 tcon struct,
don't use cli_state_save_tcon()//cli_state_restore_tcon()
as these calls will soon change to just manipulate the pointer
to avoid TALLOC_FREE() on the tcon struct which calls
destructors on child pipe data.

In SMB1 this test calls cli_tdis() twice with an invalid
vuid and expects the SMB1 tcon struct to be preserved
across the calls.

SMB1 cli_tdis() frees cli->smb1.tcon so we must put back
a deep copy into cli->smb1.tcon to be able to safely call
cli_tdis() again.

This is a test-only hack. Real client code
uses cli_state_save_tcon()/cli_state_restore_tcon()
if it needs to temporarily swap out the active
tcon on a client connection.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit e93e6108837eff0cebad8dc26d055c0e1386093a)

3 years agos3: smbtorture3: Ensure run_tcon_test() always replaces any saved tcon and shuts...
Jeremy Allison [Thu, 28 Jan 2021 18:56:18 +0000 (10:56 -0800)]
s3: smbtorture3: Ensure run_tcon_test() always replaces any saved tcon and shuts down correctly even in error paths.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit f9ca91bd293e9f2710c4449c5d4f5d016a066049)

3 years agos3: smbtorture3: Ensure we *always* replace the saved saved_tcon even in an error...
Jeremy Allison [Thu, 28 Jan 2021 18:46:33 +0000 (10:46 -0800)]
s3: smbtorture3: Ensure we *always* replace the saved saved_tcon even in an error condition.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit dc701959cad7bf15aa47cad6451212606520f67f)

3 years agos3: libsmb: Ensure we disconnect the temporary SMB1 tcon pointer on failure to set...
Jeremy Allison [Thu, 28 Jan 2021 22:32:53 +0000 (14:32 -0800)]
s3: libsmb: Ensure we disconnect the temporary SMB1 tcon pointer on failure to set up encryption.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit faba89ad59eaa189f325be17377645862080a965)

3 years agos3: tests: Add regression test for bug 13992.
Jeremy Allison [Thu, 28 Jan 2021 22:07:23 +0000 (14:07 -0800)]
s3: tests: Add regression test for bug 13992.

Subtle extra test. Mark as knownfail for now.

'^ user1$' must appear MORE THAN ONCE, as it can read more than one
share. The previous test found user1, but only once as the bug only
allows reading the security descriptor for one share, and we were
unlucky that the first share security descriptor returned allows
user1 to read from it.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 068f4a977f0539f790809d580bf22d2362032e3d)

3 years agos3:smbd: Fix invalid memory access in posix_sys_acl_blob_get_fd()
Andreas Schneider [Mon, 1 Feb 2021 11:03:17 +0000 (12:03 +0100)]
s3:smbd: Fix invalid memory access in posix_sys_acl_blob_get_fd()

We are handing down an out of scope buffer.

Found by AddressSanitizer.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 0a93f5367bc55ee14f13da5bdb812333c9d9e9f3)

3 years agoscript/autobuild.py: let cleanup() ignore errors from rmdir_force() by default
Stefan Metzmacher [Fri, 20 Nov 2020 09:20:14 +0000 (09:20 +0000)]
script/autobuild.py: let cleanup() ignore errors from rmdir_force() by default

It's not useful to generate a python backtrace from within the cleanup code.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 9883ac45939f253a63f3ff312fc3912c5f02cdac)

Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Tue Feb  2 10:29:44 UTC 2021 on sn-devel-184

3 years agoscript/autobuild.py: split out a rmdir_force() helper function
Stefan Metzmacher [Fri, 20 Nov 2020 09:20:14 +0000 (09:20 +0000)]
script/autobuild.py: split out a rmdir_force() helper function

That also tries to re-add write permissions before removing.
In future we'll have jobs changing there directory to read-only.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 7a5df2deaaf62a7edd7c64251f75ab15abe94c07)

3 years agoselftest: make/use a copy of GNUPGHOME
Stefan Metzmacher [Sun, 22 Nov 2020 22:28:31 +0000 (23:28 +0100)]
selftest: make/use a copy of GNUPGHOME

That makes it possible to run tests from a read only source tree.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 86343125a55d184c15aa94cd01f4c8893a5a0917)

3 years agos4:selftest: use plansmbtorture4testsuite() for 'rpc.echo'
Stefan Metzmacher [Sun, 22 Nov 2020 21:43:36 +0000 (22:43 +0100)]
s4:selftest: use plansmbtorture4testsuite() for 'rpc.echo'

This makes sure "--basedir=$SELFTEST_TMPDIR" is passed to smbtorture.

Tests should not create files in the build nor the source directory!

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit d06f2c22d726a5ec7bd804d89154ee272ab1a679)

3 years agos3:selftest: run test_smbclient_tarmode.pl with a fixed subdirectory name
Stefan Metzmacher [Thu, 17 Dec 2020 05:38:14 +0000 (06:38 +0100)]
s3:selftest: run test_smbclient_tarmode.pl with a fixed subdirectory name

$PREFIX is the the value from --with-selftest-prefix.

The result of the test should not depend on --with-selftest-prefix,
the 'long_path' test in particular.

If the path is to long smbclient (via libarchive) will only
put the full path into a PAX HEADER as 'path' keyword,
that's fine in general, modern tools handle it just fine.
But Perl's Archive::Tar don't handle it and only seems
truncated file names.

I have a fix for Archive::Tar, see:
https://git.samba.org/?p=metze/samba/wip.git;a=shortlog;h=c75037d0a06a96cdaca3f3b20a6d237e768b075b

But finishing that is a task for another day, for now I just want to remove
the dependency to --with-selftest-prefix.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit e0d9b656452ba6277cdc7f0abb2a06d3d284ef3a)

3 years agoselftest/Samba4: allow get_cmd_env_vars() to take an overwrite dictionary
Stefan Metzmacher [Mon, 23 Nov 2020 10:35:33 +0000 (11:35 +0100)]
selftest/Samba4: allow get_cmd_env_vars() to take an overwrite dictionary

This way we can use it on even in some special cases, where we combine
variables from multiple environments.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 568c7d38debaa5ccd90d6ea33c683de512de7005)

3 years agoselftest/Samba4: correctly pass KRB5CCNAME to provision
Stefan Metzmacher [Mon, 23 Nov 2020 10:35:33 +0000 (11:35 +0100)]
selftest/Samba4: correctly pass KRB5CCNAME to provision

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit dce0bdc39ebb01ef4f5e35af0552451cfc29fd1b)

3 years agoselftest/Samba4: make more use of get_cmd_env_vars()
Stefan Metzmacher [Mon, 23 Nov 2020 10:35:33 +0000 (11:35 +0100)]
selftest/Samba4: make more use of get_cmd_env_vars()

This simplifies the code a lot and makes it much easier to
add new environment variables in future.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 15b39160406c3ef49c5f074793d3a55b3bf12e0e)

3 years agoselftest:Samba4: avoid File::Path 'make_path' in setup_dns_hub_internal()
Stefan Metzmacher [Thu, 17 Dec 2020 09:42:03 +0000 (10:42 +0100)]
selftest:Samba4: avoid File::Path 'make_path' in setup_dns_hub_internal()

While spliting the build and test stages I hit strange permission
problems, when a parent directory is missing,
which can be avoided by using plain mkdir() on each level.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 719eccd445e9cc56a1c2988c4deeb39d301bcbff)

3 years agoselftest: allow a prefix under /m/username/
Stefan Metzmacher [Thu, 19 Nov 2020 16:19:53 +0000 (16:19 +0000)]
selftest: allow a prefix under /m/username/

We only want to match/replace only a '.' pathname component
not any single character pathname compoment!

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 02301222386f2f08631d48d6e88c03cd1439325d)

3 years agoMakefile: add support for 'make testonly'
Stefan Metzmacher [Mon, 23 Nov 2020 09:38:49 +0000 (10:38 +0100)]
Makefile: add support for 'make testonly'

That skips any attempt to recompile before running the tests.
Some times that's useful for debugging and we'll
use it to split the build and test stages in autobuild and gitlab-ci
later.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 1e4714940211b10ae6574770f15b7c6ed95f5f59)

3 years agos3:idmap_hash: reliable return ID_TYPE_BOTH
Stefan Metzmacher [Fri, 23 Oct 2020 10:21:57 +0000 (12:21 +0200)]
s3:idmap_hash: reliable return ID_TYPE_BOTH

idmap_hash used to bounce back the requested type,
which was ID_TYPE_UID, ID_TYPE_GID or ID_TYPE_NOT_SPECIFIED
before as the winbindd parent always used a lookupsids.
When the lookupsids failed because of an unknown domain,
the idmap child weren't requested at all and the caller
sees ID_TYPE_NOT_SPECIFIED.

This module should have supported ID_TYPE_BOTH since
samba-4.1.0, similar to idmap_rid and idmap_autorid.

Now that the winbindd parent will pass ID_TYPE_BOTH in order to
indicate that the domain exists, it's better to always return
ID_TYPE_BOTH instead of a random mix of ID_TYPE_UID, ID_TYPE_GID
or ID_TYPE_BOTH. In order to request a type_hint it will return
ID_REQUIRE_TYPE for ID_TYPE_NOT_SPECIFIED, which means that
the parent at least assures that the domain sid exists.
And the caller still gets ID_TYPE_NOT_SPECIFIED if the
domain doesn't exist.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Jan 22 11:32:46 UTC 2021 on sn-devel-184

(cherry picked from commit d8339056eef2845805f573bd8b0f3323370ecc8f)
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(v4-14-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-14-test): Wed Jan 27 17:06:51 UTC 2021 on sn-devel-184

3 years agosmbd: use fsp->conn->session_info for the initial delete-on-close token
Ralph Boehme [Sat, 23 Jan 2021 17:36:23 +0000 (18:36 +0100)]
smbd: use fsp->conn->session_info for the initial delete-on-close token

There's a correctly set up session_info at fsp->conn->session_info, we can just
use that.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jan 26 04:04:14 UTC 2021 on sn-devel-184

(cherry picked from commit e06f86bbd93d024c70016e1adcf833db85742aca)

3 years agoselftest: add a test that verifies unlink works when "force user" is set
Ralph Boehme [Mon, 25 Jan 2021 10:48:32 +0000 (11:48 +0100)]
selftest: add a test that verifies unlink works when "force user" is set

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit aa1f09cda0a097617e34dd0a8b1b0acc7a37bca8)

3 years agoselftest: add force_user_error_inject share in maptoguest env
Ralph Boehme [Mon, 25 Jan 2021 10:47:45 +0000 (11:47 +0100)]
selftest: add force_user_error_inject share in maptoguest env

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit f3f8fdfbf10f690bc8d972a13d6f74f1fb0fb375)

3 years agovfs_error_inject: add unlinkat hook
Ralph Boehme [Mon, 25 Jan 2021 10:46:30 +0000 (11:46 +0100)]
vfs_error_inject: add unlinkat hook

Note that a failure is only injected if the owner of the parent directory is not
the same as the current user.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit c44dad3ac2eb36fc5eb5a9f80a9ef97183be26ef)

3 years agos3/auth: implement "winbind:ignore domains"
Ralph Boehme [Fri, 15 Jan 2021 11:56:25 +0000 (12:56 +0100)]
s3/auth: implement "winbind:ignore domains"

Under the following conditions a user from an ignored domain might be able to
authenticate:

- using Kerberos

- successfully previous authentication so the idmap and name caches are filled

- winbind not running (fwiw, winbindd is mandatory on a domain member)

- nscd running with a cached getpwnam for the ignored user (otherwise auth fails
  because getpwnam fails)

- lookup_name() function being modified to look into the name cache before
  contacting winbindd. Currently it talks directly to winbindd and that will
  check the cache.

Currently, authentication will only fail because creating the local token for
the user fails because an LSA lookupname RPC call fails (because winbindd is not
running).

All of this makes a successfull authentication unlikelly, but that is more by
accident then by design.

To ensures that if winbindd is not running and as such winbindd itself can not
enforce the restriction, also implement the ignored domains check in the auth
system as a last line of defense.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14602
RN: "winbind:ignore domains" doesn't prevent user login from trusted domain

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit df5fe2d835169161d3930acf1e9c750dd2bc64b6)