samba.git
13 months agoVERSION: Disable GIT_SNAPSHOT for the 4.18.2 release. samba-4.18.2
Jule Anger [Wed, 19 Apr 2023 10:16:08 +0000 (12:16 +0200)]
VERSION: Disable GIT_SNAPSHOT for the 4.18.2 release.

Signed-off-by: Jule Anger <janger@samba.org>
13 months agoWHATSNEW: Add release notes for Samba 4.18.2.
Jule Anger [Wed, 19 Apr 2023 10:15:36 +0000 (12:15 +0200)]
WHATSNEW: Add release notes for Samba 4.18.2.

Signed-off-by: Jule Anger <janger@samba.org>
13 months agoshadow_copy2: Fix stream open for streams_depot paths
Volker Lendecke [Fri, 14 Apr 2023 15:22:18 +0000 (17:22 +0200)]
shadow_copy2: Fix stream open for streams_depot paths

streams_depot hands us absolute paths with : filename components
instead of having set smb_fname_in->stream_name.

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

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

(cherry picked from commit 526f381f413d1cb5cde93b9542034f5ebfcfcc10)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Tue Apr 18 19:06:55 UTC 2023 on atb-devel-224

13 months agotests: Show that streams_depot and shadow_copy2 don't play together
Volker Lendecke [Fri, 14 Apr 2023 15:34:17 +0000 (15:34 +0000)]
tests: Show that streams_depot and shadow_copy2 don't play together

See the next patch, we assert in shadow_copy2_openat() over paths
passed in from shadow_copy2

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

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

13 months agostreams_depot: Create files when requested
Volker Lendecke [Fri, 14 Apr 2023 14:32:42 +0000 (16:32 +0200)]
streams_depot: Create files when requested

If you set "create mask = 0600" no streams will be created....

Tested manually. Not creating an automated test for this, there are so
many places where this can go wrong that testing this individual
glitch does not gain us much confidence.

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

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

13 months agorpcd_mdssvc: initialize POSIX locking
Ralph Boehme [Thu, 6 Apr 2023 08:16:46 +0000 (10:16 +0200)]
rpcd_mdssvc: initialize POSIX locking

Otherwise the posix_pending_close_db is NULL and we crash when trying to close a
file descriptor:

   #4 /usr/lib64/samba/libdbwrap-samba4.so(dbwrap_parse_record+0xe) [0x7fbc5d05c8ae]
   #5 /usr/lib64/samba/libdbwrap-samba4.so(dbwrap_fetch_int32+0x38) [0x7fbc5d05d438]
   #6 /usr/lib64/samba/libsmbd-base-samba4.so(fd_close_posix+0x7b) [0x7fbc5e276f8b]
   #7 /usr/lib64/samba/libsmbd-base-samba4.so(+0x57900) [0x7fbc5e28a900]
   #8 /usr/lib64/samba/libsmbd-base-samba4.so(fd_close+0x68) [0x7fbc5e2b7ea8]
   #9 /usr/lib64/samba/libsmbd-base-samba4.so(+0x62608) [0x7fbc5e295608]
   #10 /usr/lib64/samba/libtalloc-samba4.so(_talloc_free+0x51b) [0x7fbc5d9f439b]
   #11 /usr/lib64/samba/vfs/fruit.so(+0xcac2) [0x7fbc45fcdac2]
   #12 /usr/lib64/samba/vfs/fruit.so(+0xcbdd) [0x7fbc45fcdbdd]
   #13 /usr/lib64/samba/vfs/fruit.so(+0xf603) [0x7fbc45fd0603]
   #14 /usr/lib64/samba/libsmbd-base-samba4.so(+0x56375) [0x7fbc5e289375]
   #15 /usr/lib64/samba/vfs/nothingtoseeherereally.so(+0x196c) [0x7fbc467f996c]
   #16 /usr/lib64/samba/vfs/streams_xattr.so(+0x51fc) [0x7fbc461e71fc]
   #17 /usr/lib64/samba/libsmbd-base-samba4.so(+0xade3a) [0x7fbc5e2e0e3a]
   #18 /usr/lib64/samba/libsmbd-base-samba4.so(create_conn_struct_cwd+0x44) [0x7fbc5e2e1cf4]
   #19 /usr/libexec/samba/rpcd_mdssvc(mds_init_ctx+0x2c3) [0x563fdac08f03]
   #20 /usr/libexec/samba/rpcd_mdssvc(_mdssvc_open+0x141) [0x563fdac0b4d1]

The corresponding open is done as part of initializing a connection_struct
object, where we chdir() and stat() the root path of the share. The stat() in
vfs_fruit causes an expensive metadata request on the path which triggers an
internal open of a pathref handle. Note that this only affects servers that have
fruit:metadata = netatalk set, which is the default unfortunately.

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

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): Fri Apr  7 21:12:21 UTC 2023 on atb-devel-224

(cherry picked from commit 3633027e49aec064e7d890a1f7ec4d81711a5de7)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Sun Apr 16 16:39:24 UTC 2023 on atb-devel-224

13 months agonet_ads: fill ads->auth.realm from c->creds
Stefan Metzmacher [Thu, 2 Mar 2023 13:46:25 +0000 (14:46 +0100)]
net_ads: fill ads->auth.realm from c->creds

We get the realm we use for authentication needs to
the realm belonging to the username we use.

We derive the username from c->creds, so we need to
do the same for the realm.

Otherwise we try to authenticate as the wrong user.

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

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

13 months agotestprogs/blackbox: add test_net_ads_search_server.sh
Stefan Metzmacher [Wed, 5 Apr 2023 14:45:21 +0000 (16:45 +0200)]
testprogs/blackbox: add test_net_ads_search_server.sh

This reproduces a regression with
'net ads search -P --server server.of.trusted.domain'

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

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

13 months agosmbXsrv_tcon: avoid storing temporary (invalid!) records.
Stefan Metzmacher [Wed, 5 Apr 2023 14:59:44 +0000 (16:59 +0200)]
smbXsrv_tcon: avoid storing temporary (invalid!) records.

We used to store smbXsrv_tcon_global.tdb records in two steps,
first we created a record in order to allocate the tcon id.
The temporary record had a NULL share_name, which translated
into 0 bytes for the string during ndr_push_smbXsrv_tcon_global0.

The problem is that ndr_pull_smbXsrv_tcon_global0 fails on
this with something like:

Invalid record in smbXsrv_tcon_global.tdb:key '2CA0ED4A' ndr_pull_struct_blob(length=85) - Buffer Size Error

The blob looks like this:

[0000] 00 00 00 00 01 00 00 00   00 00 00 00 00 00 02 00   ........  ........
[0010] 00 00 00 00 4A ED A0 2C   4A ED A0 2C 00 00 00 00   ....J.., J..,....
[0020] F8 4B 00 00 00 00 00 00   00 00 00 00 FF FF FF FF   .K......  ........
[0030] 4D 59 9B 9F 83 F4 35 20   36 D2 B0 82 62 68 D9 01   MY....5 6...bh..
[0040] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........  ........
[0050] 00 00 00 00 00                                      .....

The reason for having a temporary entry was just based on
the fact, that it was easier to keep the logic in
make_connection_snum() untouched.

But we have all information available in order to store
the final record directly. We only need to do the
"max connections" check first.

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

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

13 months agosmbd: Fix case normalization in for directories
Volker Lendecke [Fri, 17 Feb 2023 09:02:37 +0000 (10:02 +0100)]
smbd: Fix case normalization in for directories

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15313
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Feb 24 08:46:14 UTC 2023 on atb-devel-224

(cherry picked from commit bf9130d375b6c401bb79fc1a0911975814759e3b)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Tue Apr 11 16:30:25 UTC 2023 on atb-devel-224

13 months agotests: Show that the case sensitive large dir optimization is broken
Volker Lendecke [Fri, 17 Feb 2023 14:41:12 +0000 (15:41 +0100)]
tests: Show that the case sensitive large dir optimization is broken

We don't normalize the directories

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15313
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 342d8f6a0a8bc2229332783a840c882f85a1dd4e)

13 months agotests: Move libsmb-basic to fileserver_smb1 environment
Volker Lendecke [Fri, 17 Feb 2023 14:40:30 +0000 (15:40 +0100)]
tests: Move libsmb-basic to fileserver_smb1 environment

This has the lower-case share, used in the next commit

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15313
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit a9301d8f2956409a6d36e7776d0237d03bfbdbf6)

13 months agos3: smbd: Fix log spam. Change a normal error message from DBG_ERR (level 0) to DBG_I...
Jeremy Allison [Wed, 8 Feb 2023 01:51:10 +0000 (17:51 -0800)]
s3: smbd: Fix log spam. Change a normal error message from DBG_ERR (level 0) to DBG_INFO (level 5).

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sat Feb 11 08:48:05 UTC 2023 on atb-devel-224

(cherry picked from commit e8abe52df2d3ae533b3f874a885856f26ba5ec7e)

13 months agosmbd: Prevent creation of vetoed files
Ralph Boehme [Wed, 5 Apr 2023 09:03:52 +0000 (11:03 +0200)]
smbd: Prevent creation of vetoed files

The problem is when checking for vetoed names on the last path component in
openat_pathref_fsp_case_insensitive() we return
NT_STATUS_OBJECT_NAME_NOT_FOUND. The in the caller
filename_convert_dirfsp_nosymlink() this is treated as the "file creation case"
causing filename_convert_dirfsp_nosymlink() to return NT_STATUS_OK.

In order to correctly distinguish between the cases

1) file doesn't exist, we may be creating it, return
2) a vetoed a file

we need 2) to return a more specific error to
filename_convert_dirfsp_nosymlink(). I've chosen NT_STATUS_OBJECT_NAME_INVALID
which gets mapped to the appropriate errror NT_STATUS_OBJECT_PATH_NOT_FOUND or
NT_STATUS_OBJECT_NAME_NOT_FOUND depending on which path component was vetoed.

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

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 Apr  6 23:03:50 UTC 2023 on atb-devel-224

(cherry picked from commit 8b23a4a7eca9b8f80cc4113bb8cf9bb7bd5b4807)

13 months agoCI: add a test creating a vetoed file
Ralph Boehme [Wed, 5 Apr 2023 09:32:09 +0000 (11:32 +0200)]
CI: add a test creating a vetoed file

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

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

13 months agodsdb/tests: Double number of expressions in large_ldap.py ldap_timeout test
Andrew Bartlett [Wed, 5 Apr 2023 20:59:17 +0000 (08:59 +1200)]
dsdb/tests: Double number of expressions in large_ldap.py ldap_timeout test

By slowing the filter down more this makes the test reliable on the
autobuild host.

This is not a long-term solution, but is a quick tweak that can be done
today to address current issues with getting commits past the host-based
(compared with cloud-based) autobuild.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
(cherry picked from commit 479634e4cd6543d489eb4700aebde1a479b94fe5)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Tue Apr 11 08:36:03 UTC 2023 on atb-devel-224

13 months agodsdb/tests: Move SD modification on class-created objects to classSetUp
Andrew Bartlett [Wed, 5 Apr 2023 20:54:02 +0000 (08:54 +1200)]
dsdb/tests: Move SD modification on class-created objects to classSetUp

These modifications persist, so should be done at the class level,
not in the test.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
(cherry picked from commit e1c0c2066c2f29bb614e3386b796eec3cb289aea)

13 months agoselftest: fix flapping samba-tool drs showrepl test
Rob van der Linde [Thu, 23 Feb 2023 03:56:30 +0000 (16:56 +1300)]
selftest: fix flapping samba-tool drs showrepl test

Test should have been using "schema_pair_dc", it was picking this up from the variable env in the loop above it.

However, it was hardcoded to use promoted_dc.

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

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
(cherry picked from commit 3687ab318a9553883d8c0d1214e2d49b83ec91ba)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Wed Apr  5 13:02:59 UTC 2023 on atb-devel-224

13 months agoselftest: make two samba-tool drs tests generic
Rob van der Linde [Thu, 23 Feb 2023 03:56:07 +0000 (16:56 +1300)]
selftest: make two samba-tool drs tests generic

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

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
(cherry picked from commit 1368e359b2a75b6b683aff274b2b2084f3cd469b)

13 months agopython: Replace calls to deprecated methods
Joseph Sutton [Wed, 18 Jan 2023 19:37:03 +0000 (08:37 +1300)]
python: Replace calls to deprecated methods

These aliases are deprecated and have been removed in Python 3.12.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 41aa379abb391ffab77238d65ee5ba11b9ab8538)

[abartlet@samba.org BUG tag added as required patch for bug 15316]

13 months agos3: libcli: Refuse to connect to any server with zero values for max_trans_size,...
Jeremy Allison [Tue, 21 Mar 2023 17:34:46 +0000 (10:34 -0700)]
s3: libcli: Refuse to connect to any server with zero values for max_trans_size, max_read_size, max_write_size.

There's nothing we can do to such a server (this
now matches the behavior for SMB1).

Remove knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Mar 29 18:58:33 UTC 2023 on atb-devel-224

(cherry picked from commit 76573d6d8f168d6e6107af26a434b8c71aaf93af)

13 months agotests: Add samba3.blackbox.zero_readsize test.
Jeremy Allison [Tue, 21 Mar 2023 17:31:36 +0000 (10:31 -0700)]
tests: Add samba3.blackbox.zero_readsize test.

smbclient crashes when smbd has "smb2 max read = 0"
in the [global] section of smb.conf.

We should fail the protocol negotiation with
NT_STATUS_INVALID_NETWORK_RESPONSE in this case.

Adds knownfail.

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

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

13 months agopython:netcmd: Decode return value of find_netbios() from bytes into string
Andreas Schneider [Fri, 10 Mar 2023 08:08:48 +0000 (09:08 +0100)]
python:netcmd: Decode return value of find_netbios() from bytes into string

ERROR(<class 'TypeError'>): uncaught exception - replace() argument 1 must be
str, not bytes
  File "bin/python/samba/netcmd/__init__.py", line 230, in _run
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bin/python/samba/netcmd/ldapcmp.py", line 966, in run
    if b1.diff(b2):
       ^^^^^^^^^^^
  File "bin/python/samba/netcmd/ldapcmp.py", line 790, in diff
    if object1 == object2:
       ^^^^^^^^^^^^^^^^^^
  File "bin/python/samba/netcmd/ldapcmp.py", line 557, in __eq__
    return self.cmp_attrs(other)
           ^^^^^^^^^^^^^^^^^^^^^
  File "bin/python/samba/netcmd/ldapcmp.py", line 656, in cmp_attrs
    p = [self.fix_domain_netbios(j) for j in m]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bin/python/samba/netcmd/ldapcmp.py", line 656, in <listcomp>
    p = [self.fix_domain_netbios(j) for j in m]
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bin/python/samba/netcmd/ldapcmp.py", line 542, in fix_domain_netbios
    res = res.replace(self.con.domain_netbios.lower(), self.con.domain_netbios.upper())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 4fa0242b9d34decd8dbd813be40655a593df3db9)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Wed Apr  5 11:41:32 UTC 2023 on atb-devel-224

13 months agodsdb: Avoid ERROR(ldb): uncaught exception - Deleted target CN=NTDS Settings... in...
Andrew Bartlett [Thu, 9 Mar 2023 07:25:06 +0000 (20:25 +1300)]
dsdb: Avoid ERROR(ldb): uncaught exception - Deleted target CN=NTDS Settings... in join

"samba-tool domain join" uses the replication API in a strange way, perhaps no longer
required, except that we often still have folks upgrading from very old Samba versions.

When deferring the writing out to the DB of link replication to the very end, there
is a greater opportunity for the deletion of an object to have been sent with the
other objects, and have the link applied later.

This tells the repl_meta_data code to behave as if GET_TGT had been sent at the
time the link was returned, allowing a link to a deleted object to be silently
discarded.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
(cherry picked from commit bfc33b47bb428233e100f75e7a725ac52179f823)

13 months agoselftest/drs: Demonstrate ERROR(ldb): uncaught exception - Deleted target CN=NTDS...
Andrew Bartlett [Thu, 9 Mar 2023 04:02:35 +0000 (17:02 +1300)]
selftest/drs: Demonstrate ERROR(ldb): uncaught exception - Deleted target CN=NTDS Settings... in join

"samba-tool domain join" uses the replication API in a strange way, perhaps no longer
required, except that we often still have folks upgrading from very old Samba versions.

By deferring the writing out to the DB of link replication to the very end, we have a
better chance that all the objects required are present, however the situation may
have changed during the cycle, and a link could still be sent, pointing to a deleted
object.

We currently fail in this situation.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
(cherry picked from commit 2d41bcce83a976b85636c92d6fc38c63fdde5431)

13 months agotsocket: Increase tcp_user_timeout max_loops
Andrew Bartlett [Wed, 8 Mar 2023 21:06:26 +0000 (10:06 +1300)]
tsocket: Increase tcp_user_timeout max_loops

Often, on rackspace GitLab CI runners, we get:

UNEXPECTED(failure): samba.unittests.tsocket_tstream.test_tstream_more_tcp_user_timeout_spin(none)
REASON: Exception: Exception: 0xf == 0xf
../../lib/tsocket/tests/test_tstream.c:405: error: Failure!

This allows us more spins before we fail the test.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15328
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
(cherry picked from commit 5a7a28cc45870949fc11d30586a06c309aa517dc)

13 months agoidmap_hash: remember new domain sids in idmap_hash_sid_to_id()
Stefan Metzmacher [Thu, 21 Mar 2019 15:54:31 +0000 (16:54 +0100)]
idmap_hash: remember new domain sids in idmap_hash_sid_to_id()

This change means that idmap_hash_id_to_sid() can return mappings
for new domains learned in idmap_hash_sid_to_id().

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Mar 10 11:35:06 UTC 2023 on atb-devel-224

(cherry picked from commit 7ee725f2860d835e9619fa594a2ee6faedbc6d21)

13 months agoidmap_hash: don't return ID_REQUIRE_TYPE if the domain is known in the netsamlogon...
Stefan Metzmacher [Thu, 21 Mar 2019 15:54:31 +0000 (16:54 +0100)]
idmap_hash: don't return ID_REQUIRE_TYPE if the domain is known in the netsamlogon cache

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit ee820553fd2c6ada966a0160cbb0240049f9d9f7)

13 months agoidmap_hash: only return ID_REQUIRE_TYPE if we don't know about the domain yet
Stefan Metzmacher [Thu, 21 Mar 2019 15:54:31 +0000 (16:54 +0100)]
idmap_hash: only return ID_REQUIRE_TYPE if we don't know about the domain yet

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit ede88d9f83fb77fa8eff226fb6a85ac71e415098)

13 months agoidmap_hash: return ID_REQUIRE_TYPE only if there's a chance to get a mapping later
Stefan Metzmacher [Thu, 21 Mar 2019 15:54:31 +0000 (16:54 +0100)]
idmap_hash: return ID_REQUIRE_TYPE only if there's a chance to get a mapping later

If we are going to return ID_UNMAPPED later anyway, there's no need to
defer that decision by returning ID_REQUIRE_TYPE first.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 42dcb3db05530179a991fe58e7b96b52bbbcc607)

13 months agoidmap_hash: split out a idmap_hash_sid_to_id() helper function
Stefan Metzmacher [Thu, 21 Mar 2019 13:05:13 +0000 (14:05 +0100)]
idmap_hash: split out a idmap_hash_sid_to_id() helper function

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit c158b075b0b5035615fa8848f1f3d8ef27696861)

13 months agoidmap_hash: split out a idmap_hash_id_to_sid() helper function
Stefan Metzmacher [Thu, 21 Mar 2019 13:05:13 +0000 (14:05 +0100)]
idmap_hash: split out a idmap_hash_id_to_sid() helper function

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 57150b463fb8e27c048670f7b4902bd091ee3ae9)

13 months agoidmap_hash: mirror the NT_STATUS_NONE_MAPPED/STATUS_SOME_UNMAPPED logic from idmap_au...
Stefan Metzmacher [Thu, 21 Mar 2019 13:00:16 +0000 (14:00 +0100)]
idmap_hash: mirror the NT_STATUS_NONE_MAPPED/STATUS_SOME_UNMAPPED logic from idmap_autorid

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 14102b05f3744c67178bd719d41e67fc3e049ee4)

13 months agoidmap_hash: we don't need to call idmap_hash_initialize() over an over again
Stefan Metzmacher [Thu, 21 Mar 2019 09:54:49 +0000 (10:54 +0100)]
idmap_hash: we don't need to call idmap_hash_initialize() over an over again

It's always the first function that's called from idmap_methods.

This also demonstrates that we currently always return NT_STATUS_OK,
even if we haven't mapped all map entries.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 0da13ab3ad7278eafdcd988f39e891242eb46d37)

13 months agoidmap_hash: remove unused error checks
Stefan Metzmacher [Thu, 21 Mar 2019 12:54:10 +0000 (13:54 +0100)]
idmap_hash: remove unused error checks

id_map_ptrs_init() is used in the callers in order to
set everything up as expected.

Other backends also just trust the caller.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 2cfcff3101fce94b365eccde114432dfa980bbd0)

13 months agoidmap_hash: fix comments about the algorithm
Stefan Metzmacher [Thu, 21 Mar 2019 12:37:16 +0000 (13:37 +0100)]
idmap_hash: fix comments about the algorithm

Only support ~ 50k users per domain.

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

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

13 months agoidmap_hash: provide ID_TYPE_BOTH mappings also for unixids_to_sids
Stefan Metzmacher [Thu, 21 Mar 2019 15:38:35 +0000 (16:38 +0100)]
idmap_hash: provide ID_TYPE_BOTH mappings also for unixids_to_sids

While sids_to_unixids returns ID_TYPE_BOTH mappings,
unixids_to_sids() returns the callers asked for, which
fills gencache with the non ID_TYPE_BOTH mappings.
As a result also the sids_to_unixids fast path via
gencache won't return ID_TYPE_BOTH mappings.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 9a24570d3d69f51b6d50bb04b739815ec67c1a3d)

13 months agoidmap_autorid: fix ID_REQUIRE_TYPE for more than one SID for an unknown domain
Stefan Metzmacher [Fri, 17 Feb 2023 15:51:42 +0000 (16:51 +0100)]
idmap_autorid: fix ID_REQUIRE_TYPE for more than one SID for an unknown domain

When we see a trusted domain SID for the first time,
idmap_autorid returns ID_REQUIRE_TYPE only for the first sid
and leaves the others with ID_TYPE_NOT_SPECIFIED.
It means the winbindd parent only retries the first sid.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit a9583b5f96fe3fbf9c1ee545fa868fd705aef3e0)

13 months agowinbindd: don't call set_domain_online_request() in the idmap child
Stefan Metzmacher [Thu, 16 Feb 2023 15:31:34 +0000 (16:31 +0100)]
winbindd: don't call set_domain_online_request() in the idmap child

Most idmap backends don't need access to the domain controllers.
And the related code is not needed for the backends.

Commit 17c86a2c5a5a5e2b194362e5f36f0f99910222c5 changed
the logic of set_domain_online_request() completely!
Instead of triggering a dc probe in the background,
it is now doing a blocking connection.
And doing this in the idmap child is completely useless.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit ad242a20643c930eb00a8b700f7bd9638f8821a8)

13 months agoVERSION: Bump version up to Samba 4.18.2...
Jule Anger [Wed, 29 Mar 2023 14:36:47 +0000 (16:36 +0200)]
VERSION: Bump version up to Samba 4.18.2...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Jule Anger <janger@samba.org>
13 months agoVERSION: Disable GIT_SNAPSHOT for the 4.18.1 release. samba-4.18.1
Jule Anger [Wed, 22 Mar 2023 09:12:43 +0000 (10:12 +0100)]
VERSION: Disable GIT_SNAPSHOT for the 4.18.1 release.

Signed-off-by: Jule Anger <janger@samba.org>
13 months agoWHATSNEW: Add release notes for Samba 4.18.1.
Jule Anger [Wed, 22 Mar 2023 09:09:57 +0000 (10:09 +0100)]
WHATSNEW: Add release notes for Samba 4.18.1.

Signed-off-by: Jule Anger <janger@samba.org>
14 months agoCVE-2023-0922 set default ldap client sasl wrapping to seal
Rob van der Linde [Mon, 27 Feb 2023 01:06:23 +0000 (14:06 +1300)]
CVE-2023-0922 set default ldap client sasl wrapping to seal

This avoids sending new or reset passwords in the clear
(integrity protected only) from samba-tool in particular.

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

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
14 months agoCVE-2023-0225 s4-acl: Don't return early if dNSHostName element has no values
Joseph Sutton [Sun, 8 Jan 2023 22:22:34 +0000 (11:22 +1300)]
CVE-2023-0225 s4-acl: Don't return early if dNSHostName element has no values

This early return would mistakenly allow an unprivileged user to delete
the dNSHostName attribute by making an LDAP modify request with no
values. We should no longer allow this.

Add or replace operations with no values and no privileges are
disallowed.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0225 pytest/acl: test deleting dNSHostName as unprivileged user
Douglas Bagnall [Wed, 4 Jan 2023 08:37:49 +0000 (21:37 +1300)]
CVE-2023-0225 pytest/acl: test deleting dNSHostName as unprivileged user

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Release LDB 2.7.2 ldb-2.7.2
Andrew Bartlett [Fri, 3 Mar 2023 04:52:13 +0000 (17:52 +1300)]
CVE-2023-0614 ldb: Release LDB 2.7.2

* CVE-2023-0614 Not-secret but access controlled LDAP attributes can be discovered (bug 15270)

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
14 months agoCVE-2023-0614 lib/ldb-samba Ensure ACLs are evaluated on SAMBA_LDAP_MATCH_RULE_TRANSI...
Andrew Bartlett [Thu, 2 Mar 2023 04:24:15 +0000 (17:24 +1300)]
CVE-2023-0614 lib/ldb-samba Ensure ACLs are evaluated on SAMBA_LDAP_MATCH_RULE_TRANSITIVE_EVAL / LDAP_MATCHING_RULE_IN_CHAIN

Setting the LDB_HANDLE_FLAG_UNTRUSTED tells the acl_read module to operate on this request.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
14 months agoCVE-2023-0614 lib/ldb-samba: Add test for SAMBA_LDAP_MATCH_RULE_TRANSITIVE_EVAL ...
Andrew Bartlett [Thu, 2 Mar 2023 03:51:25 +0000 (16:51 +1300)]
CVE-2023-0614 lib/ldb-samba: Add test for SAMBA_LDAP_MATCH_RULE_TRANSITIVE_EVAL / LDAP_MATCHING_RULE_IN_CHAIN with and ACL hidden attributes

The chain for transitive evaluation does consider ACLs, avoiding the disclosure of
confidential information.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
14 months agoCVE-2023-0614 dsdb: Add pre-cleanup and self.addCleanup() of OU created in match_rule...
Andrew Bartlett [Fri, 3 Mar 2023 03:49:00 +0000 (16:49 +1300)]
CVE-2023-0614 dsdb: Add pre-cleanup and self.addCleanup() of OU created in match_rules tests

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
14 months agoCVE-2023-0614 dsdb: Add DSDB_MARK_REQ_UNTRUSTED
Andrew Bartlett [Thu, 2 Mar 2023 03:31:17 +0000 (16:31 +1300)]
CVE-2023-0614 dsdb: Add DSDB_MARK_REQ_UNTRUSTED

This will allow our dsdb helper search functions to mark the new
request as untrusted, forcing read ACL evaluation (per current behaviour).

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
14 months agoCVE-2023-0614 s4-dsdb: Treat confidential attributes as unindexed
Joseph Sutton [Thu, 23 Feb 2023 21:03:25 +0000 (10:03 +1300)]
CVE-2023-0614 s4-dsdb: Treat confidential attributes as unindexed

In the unlikely case that someone adds a confidential indexed attribute
to the schema, LDAP search expressions on that attribute could disclose
information via timing differences. Let's not use the index for searches
on confidential attributes.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Filter on search base before redacting message
Joseph Sutton [Fri, 3 Mar 2023 04:35:55 +0000 (17:35 +1300)]
CVE-2023-0614 ldb: Filter on search base before redacting message

Redaction may be expensive if we end up needing to fetch a security
descriptor to verify rights to an attribute. Checking the search scope
is probably cheaper, so do that first.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Centralise checking for inaccessible matches
Joseph Sutton [Tue, 14 Feb 2023 00:17:24 +0000 (13:17 +1300)]
CVE-2023-0614 ldb: Centralise checking for inaccessible matches

This makes it less likely that we forget to handle a case.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Use binary search to check whether attribute is secret
Joseph Sutton [Wed, 15 Feb 2023 23:35:34 +0000 (12:35 +1300)]
CVE-2023-0614 ldb: Use binary search to check whether attribute is secret

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4-acl: Avoid calling dsdb_module_am_system() if we can help it
Joseph Sutton [Mon, 27 Feb 2023 00:31:44 +0000 (13:31 +1300)]
CVE-2023-0614 s4-acl: Avoid calling dsdb_module_am_system() if we can help it

If the AS_SYSTEM control is present, we know we have system privileges,
and have no need to call dsdb_module_am_system().

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Prevent disclosure of confidential attributes
Joseph Sutton [Fri, 3 Mar 2023 04:34:29 +0000 (17:34 +1300)]
CVE-2023-0614 ldb: Prevent disclosure of confidential attributes

Add a hook, acl_redact_msg_for_filter(), in the aclread module, that
marks inaccessible any message elements used by an LDAP search filter
that the user has no right to access. Make the various ldb_match_*()
functions check whether message elements are accessible, and refuse to
match any that are not. Remaining message elements, not mentioned in the
search filter, are checked in aclread_callback(), and any inaccessible
elements are removed at this point.

Certain attributes, namely objectClass, distinguishedName, name, and
objectGUID, are always present, and hence the presence of said
attributes is always allowed to be checked in a search filter. This
corresponds with the behaviour of Windows.

Further, we unconditionally allow the attributes isDeleted and
isRecycled in a check for presence or equality. Windows is not known to
make this special exception, but it seems mostly harmless, and should
mitigate the performance impact on searches made by the show_deleted
module.

As a result of all these changes, our behaviour regarding confidential
attributes happens to match Windows more closely. For the test in
confidential_attr.py, we can now model our attribute handling with
DC_MODE_RETURN_ALL, which corresponds to the behaviour exhibited by
Windows.

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

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4-acl: Split out function to set up access checking variables
Joseph Sutton [Mon, 27 Feb 2023 00:55:36 +0000 (13:55 +1300)]
CVE-2023-0614 s4-acl: Split out function to set up access checking variables

These variables are often used together, and it is useful to have the
setup code in one place.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4-dsdb: Add samdb_result_dom_sid_buf()
Joseph Sutton [Sun, 26 Feb 2023 23:19:08 +0000 (12:19 +1300)]
CVE-2023-0614 s4-dsdb: Add samdb_result_dom_sid_buf()

This function parses a SID from an ldb_message, similar to
samdb_result_dom_sid(), but does it without allocating anything.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4-acl: Split out logic to remove access checking attributes
Joseph Sutton [Mon, 27 Feb 2023 00:40:33 +0000 (13:40 +1300)]
CVE-2023-0614 s4-acl: Split out logic to remove access checking attributes

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Add ldb_parse_tree_get_attr()
Joseph Sutton [Fri, 3 Mar 2023 04:31:54 +0000 (17:31 +1300)]
CVE-2023-0614 ldb: Add ldb_parse_tree_get_attr()

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 tests/krb5: Add test for confidential attributes timing differences
Joseph Sutton [Thu, 26 Jan 2023 19:32:41 +0000 (08:32 +1300)]
CVE-2023-0614 tests/krb5: Add test for confidential attributes timing differences

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 schema_samba4.ldif: Allocate previously added OID
Joseph Sutton [Mon, 6 Feb 2023 20:25:48 +0000 (09:25 +1300)]
CVE-2023-0614 schema_samba4.ldif: Allocate previously added OID

DSDB_CONTROL_CALCULATED_DEFAULT_SD_OID was added in commit
08187833fee57a8dba6c67546dfca516cd1f9d7a.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4:dsdb:tests: Fix <GUID={}> search in confidential attributes test
Joseph Sutton [Mon, 6 Feb 2023 20:48:37 +0000 (09:48 +1300)]
CVE-2023-0614 s4:dsdb:tests: Fix <GUID={}> search in confidential attributes test

The object returned by schema_format_value() is a bytes object.
Therefore the search expression would resemble:

(lastKnownParent=<GUID=b'00000000-0000-0000-0000-000000000000'>)

which, due to the extra characters, would fail to match anything.

Fix it to be:

(lastKnownParent=<GUID=00000000-0000-0000-0000-000000000000>)

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4:dsdb/extended_dn_in: Don't modify a search tree we don't own
Joseph Sutton [Mon, 6 Feb 2023 20:35:24 +0000 (09:35 +1300)]
CVE-2023-0614 s4:dsdb/extended_dn_in: Don't modify a search tree we don't own

In extended_dn_fix_filter() we had:

    req->op.search.tree = ldb_parse_tree_copy_shallow(req, req->op.search.tree);

which overwrote the parse tree on an existing ldb request with a fixed
up tree. This became a problem if a module performed another search with
that same request structure, as extended_dn_in would try to fix up the
already-modified tree for a second time. The fixed-up tree element now
having an extended DN, it would fall foul of the ldb_dn_match_allowed()
check in extended_dn_filter_callback(), and be replaced with an
ALWAYS_FALSE match rule. In practice this meant that <GUID={}> searches
would only work for one search in an ldb request, and fail for
subsequent ones.

Fix this by creating a new request with the modified tree, and leaving
the original request unmodified.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Make use of ldb_filter_attrs_in_place()
Joseph Sutton [Sun, 26 Feb 2023 21:31:52 +0000 (10:31 +1300)]
CVE-2023-0614 ldb: Make use of ldb_filter_attrs_in_place()

Change all uses of ldb_kv_filter_attrs() to use
ldb_filter_attrs_in_place() instead. This function does less work than
its predecessor, and no longer requires the allocation of a second ldb
message. Some of the work is able to be split out into separate
functions that each accomplish a single task, with a purpose to make the
code clearer.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Make ldb_filter_attrs_in_place() work in place
Joseph Sutton [Fri, 3 Mar 2023 04:30:19 +0000 (17:30 +1300)]
CVE-2023-0614 ldb: Make ldb_filter_attrs_in_place() work in place

ldb_filter_attrs() previously did too much. Now its replacement,
ldb_filter_attrs_in_place(), only does the actual filtering, while
taking ownership of each element's values is handled in a separate
function, ldb_msg_elements_take_ownership().

Also, ldb_filter_attrs_in_place() no longer adds the distinguishedName
to the message if it is missing. That is handled in another function,
ldb_msg_add_distinguished_name().

As we're now modifying the original message rather than copying it into
a new one, we no longer need the filtered_msg parameter.

We adapt a test, based on ldb_filter_attrs_test, to exercise the new
function.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Add function to filter message in place
Joseph Sutton [Fri, 3 Mar 2023 04:29:03 +0000 (17:29 +1300)]
CVE-2023-0614 ldb: Add function to filter message in place

At present this function is an exact duplicate of ldb_filter_attrs(),
but in the next commit we shall modify it to work in place, without the
need for the allocation of a second message.

The test is a near duplicate of the existing test for
ldb_filter_attrs().

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Add function to add distinguishedName to message
Joseph Sutton [Fri, 3 Mar 2023 04:27:38 +0000 (17:27 +1300)]
CVE-2023-0614 ldb: Add function to add distinguishedName to message

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Add function to remove excess capacity from an ldb message
Joseph Sutton [Fri, 3 Mar 2023 04:26:04 +0000 (17:26 +1300)]
CVE-2023-0614 ldb: Add function to remove excess capacity from an ldb message

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Add function to take ownership of an ldb message
Joseph Sutton [Fri, 3 Mar 2023 04:23:42 +0000 (17:23 +1300)]
CVE-2023-0614 ldb: Add function to take ownership of an ldb message

Many places in Samba depend upon various components of an ldb message
being talloc allocated, and hence able to be used as talloc contexts.
The elements and values of an unpacked ldb message point to unowned data
inside the memory-mapped database, and this function ensures that such
messages have talloc ownership of said elements and values.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb:tests: Ensure all tests are accounted for
Joseph Sutton [Wed, 15 Feb 2023 01:08:57 +0000 (14:08 +1300)]
CVE-2023-0614 ldb:tests: Ensure all tests are accounted for

Add ldb_filter_attrs_test to the list of tests so that it actually gets
run.

Remove a duplicate ldb_msg_test that was accidentally added in commit
5ca90e758ade97fb5e335029c7a1768094e70564.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb:tests: Ensure ldb_val data is zero-terminated
Joseph Sutton [Tue, 14 Feb 2023 23:34:51 +0000 (12:34 +1300)]
CVE-2023-0614 ldb:tests: Ensure ldb_val data is zero-terminated

If the value of an ldb message element is not zero-terminated, calling
ldb_msg_find_attr_as_string() will cause the function to read off the
end of the buffer in an attempt to verify that the value is
zero-terminated. This can cause unexpected behaviour and make the test
randomly fail.

To avoid this, we must have a terminating null byte that is *not*
counted as part of the length, and so we must calculate the length with
strlen() rather than sizeof.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4-acl: Use ldb functions for handling inaccessible message elements
Joseph Sutton [Thu, 26 Jan 2023 19:29:33 +0000 (08:29 +1300)]
CVE-2023-0614 s4-acl: Use ldb functions for handling inaccessible message elements

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 ldb: Add functions for handling inaccessible message elements
Joseph Sutton [Thu, 26 Jan 2023 19:28:36 +0000 (08:28 +1300)]
CVE-2023-0614 ldb: Add functions for handling inaccessible message elements

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4-acl: Make some parameters const
Joseph Sutton [Thu, 26 Jan 2023 19:00:32 +0000 (08:00 +1300)]
CVE-2023-0614 s4-acl: Make some parameters const

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 s4:dsdb: Use talloc_get_type_abort() more consistently
Joseph Sutton [Mon, 6 Feb 2023 20:29:51 +0000 (09:29 +1300)]
CVE-2023-0614 s4:dsdb: Use talloc_get_type_abort() more consistently

It is better to explicitly abort than to dereference a NULL pointer or
try to read data cast to the wrong type.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 libcli/security: Make some parameters const
Joseph Sutton [Thu, 26 Jan 2023 18:57:27 +0000 (07:57 +1300)]
CVE-2023-0614 libcli/security: Make some parameters const

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
14 months agoCVE-2023-0614 dsdb: Alter timeout test in large_ldap.py to be slower by matching...
Andrew Bartlett [Thu, 2 Mar 2023 21:31:40 +0000 (10:31 +1300)]
CVE-2023-0614 dsdb: Alter timeout test in large_ldap.py to be slower by matching on large objects

This changes the slow aspect to be the object matching not the filter parsing.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
14 months agoCVE-2023-0614 selftest: Use setUpClass() to reduce "make test TESTS=large_ldap" time
Andrew Bartlett [Mon, 13 Mar 2023 04:20:00 +0000 (17:20 +1300)]
CVE-2023-0614 selftest: Use setUpClass() to reduce "make test TESTS=large_ldap" time

This reduces the elapsed time to 6m from 20m on my laptop.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Mar 14 07:16:04 UTC 2023 on atb-devel-224

(cherry picked from commit b4a6c054ec6acefacd22cb7230a783d20cb07c05)

[abartlet@samba.org Included in the security release as this
 makes working on the large_ldap test practical by reducing
 the elapsed time taken]

14 months agoCVE-2023-0614 lib/ldb: Avoid allocation and memcpy() for every wildcard match candidate
Andrew Bartlett [Mon, 13 Mar 2023 01:25:56 +0000 (14:25 +1300)]
CVE-2023-0614 lib/ldb: Avoid allocation and memcpy() for every wildcard match candidate

The value can be quite large, the allocation will take much
longer than the actual match and is repeated per candidate
record.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
(cherry picked from commit cad96f59a08192df927fb1df4e9787c7f70991a2)

[abartlet@samba.org Included in the security release as this
 makes the new large_ldap.py timeout test more reliable]

14 months agoVERSION: Bump version up to Samba 4.18.1...
Jule Anger [Wed, 8 Mar 2023 12:22:33 +0000 (13:22 +0100)]
VERSION: Bump version up to Samba 4.18.1...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Jule Anger <janger@samba.org>
14 months agoVERSION: Disable GIT_SNAPSHOT for the 4.18.0 release. samba-4.18.0
Jule Anger [Wed, 8 Mar 2023 12:21:53 +0000 (13:21 +0100)]
VERSION: Disable GIT_SNAPSHOT for the 4.18.0 release.

Signed-off-by: Jule Anger <janger@samba.org>
14 months agoWHATSNEW: Add release notes for Samba 4.18.0.
Jule Anger [Wed, 8 Mar 2023 12:20:42 +0000 (13:20 +0100)]
WHATSNEW: Add release notes for Samba 4.18.0.

Signed-off-by: Jule Anger <janger@samba.org>
14 months agos3: smbd: Fix fsp/fd leak when looking up a non-existent stream name on a file.
Jeremy Allison [Tue, 28 Feb 2023 19:20:12 +0000 (11:20 -0800)]
s3: smbd: Fix fsp/fd leak when looking up a non-existent stream name on a file.

When open_stream_pathref_fsp() returns
NT_STATUS_OBJECT_NAME_NOT_FOUND, smb_fname_rel->fsp
has been set to NULL, so we must free base_fsp separately
to prevent fd-leaks when opening a stream that doesn't
exist.

Remove knownfail.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Mar  3 16:37:27 UTC 2023 on atb-devel-224

(cherry picked from commit 3f84a6df4546e0f1e62dfbcd0b823ea29499a787)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Wed Mar  8 11:16:54 UTC 2023 on atb-devel-224

14 months agos3: tests: Add new test_stream_dir_rename.sh test.
Jeremy Allison [Tue, 28 Feb 2023 19:18:10 +0000 (11:18 -0800)]
s3: tests: Add new test_stream_dir_rename.sh test.

Shows we are leaking an fsp/fd if we request a non-existent stream on a file.
This then causes rename of a directory containing the file to be denied, as
it thinks we have an existing open file below it.

Add knownfail.

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

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

14 months agos3: provision: Add new streams_xattr_nostrict share - needs "strict rename = no".
Jeremy Allison [Tue, 28 Feb 2023 19:14:34 +0000 (11:14 -0800)]
s3: provision: Add new streams_xattr_nostrict share - needs "strict rename = no".

The bug we're testing for needs "strict rename = no" (the default),
but the existing streams_xattr share uses "strict rename = yes" from
the [global] section.

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

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

14 months agorpcd: With npa->need_idle_server we can have more than 256 servers
Volker Lendecke [Mon, 20 Feb 2023 17:46:50 +0000 (18:46 +0100)]
rpcd: With npa->need_idle_server we can have more than 256 servers

Before this patch the worker-status cut the worker index such that
samba-dcerpcd could not properly update status of the surplus rpc
daemons. This could lead to those daemons to stay around forever,
samba-dcerpcd will never notice they are idle and can exit.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Mar  6 22:35:00 UTC 2023 on atb-devel-224

(cherry picked from commit a1780ed8d1b46e4760319b27a4978e7ce7a1df80)

14 months agorpcd: Do blocking connects to local pipes
Volker Lendecke [Wed, 1 Mar 2023 13:42:00 +0000 (14:42 +0100)]
rpcd: Do blocking connects to local pipes

We don't have real async callers yet, and this is the simplest way to
fix our missing light-weight deterministic async fallback mechanism.

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

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

14 months agorpcd: Increase listening queue
Volker Lendecke [Wed, 1 Mar 2023 13:40:37 +0000 (14:40 +0100)]
rpcd: Increase listening queue

Allow more waiters under load.

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

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

14 months agotorture3: test rpc scalability
Volker Lendecke [Mon, 6 Mar 2023 09:05:41 +0000 (10:05 +0100)]
torture3: test rpc scalability

With

smbtorture3 //127.0.0.1/ipc\$ rpc-scale -N 50 -o 1000

I am able to immediately trigger bug 15130.

Not running by default, this is a pure load test.

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

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

14 months agolibrpc: Remove unused sync rpc_transport_np_init()
Volker Lendecke [Mon, 6 Mar 2023 12:57:20 +0000 (13:57 +0100)]
librpc: Remove unused sync rpc_transport_np_init()

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

14 months agolibrpc: Make rpc_pipe_open_np() public and async
Volker Lendecke [Mon, 6 Mar 2023 12:55:43 +0000 (13:55 +0100)]
librpc: Make rpc_pipe_open_np() public and async

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

14 months agoVERSION: Bump version up to Samba 4.18.0rc5...
Jule Anger [Wed, 1 Mar 2023 12:41:04 +0000 (13:41 +0100)]
VERSION: Bump version up to Samba 4.18.0rc5...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Jule Anger <janger@samba.org>
14 months agoVERSION: Disable GIT_SNAPSHOT for the 4.18.0rc4 release. samba-4.18.0rc4
Jule Anger [Wed, 1 Mar 2023 12:40:38 +0000 (13:40 +0100)]
VERSION: Disable GIT_SNAPSHOT for the 4.18.0rc4 release.

Signed-off-by: Jule Anger <janger@samba.org>
14 months agoWHATSNEW: Add release notes for Samba 4.18.0rc4.
Jule Anger [Wed, 1 Mar 2023 12:40:09 +0000 (13:40 +0100)]
WHATSNEW: Add release notes for Samba 4.18.0rc4.

Signed-off-by: Jule Anger <janger@samba.org>
14 months agoWHATSNEW: add server addresses option
Jule Anger [Wed, 1 Mar 2023 12:36:46 +0000 (13:36 +0100)]
WHATSNEW: add server addresses option

Signed-off-by: Jule Anger <janger@samba.org>
14 months agoWHATSNEW: SMB Server performance improvements
Stefan Metzmacher [Fri, 24 Feb 2023 14:39:35 +0000 (15:39 +0100)]
WHATSNEW: SMB Server performance improvements

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Wed Mar  1 10:16:41 UTC 2023 on atb-devel-224

14 months agolib:util: File descriptor being closed repeatedly.
baixiangcpp [Fri, 10 Feb 2023 03:01:47 +0000 (11:01 +0800)]
lib:util: File descriptor being closed repeatedly.

In file_load()/file_lines_load(), the file's fd is obtained using
open(), and in fd_load() the fd is converted to a FILE* using
fdopen(). However, after fclose(), the fd is closed again using
close().

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15311
Signed-off-by: baixiangcpp baixiangcpp@gmail.com
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Feb 16 12:13:05 UTC 2023 on atb-devel-224

(cherry picked from commit 206dcf7d426e9e85c896c54839008e194d9a2824)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Fri Feb 24 09:50:59 UTC 2023 on atb-devel-224

14 months agopython:tests: Make sure we delete the OU for movetest
Andreas Schneider [Wed, 8 Feb 2023 14:44:43 +0000 (15:44 +0100)]
python:tests: Make sure we delete the OU for movetest

UNEXPECTED(failure): samba.tests.samba_tool.group.samba.tests.samba_tool.group.GroupCmdTestCase.test_move(ad_dc_default:local)
REASON: Exception: Exception: Traceback (most recent call last):
  File "python/samba/tests/samba_tool/group.py", line 341, in test_move
    self.assertCmdSuccess(result, out, err)
  File "python/samba/tests/samba_tool/base.py", line 97, in assertCmdSuccess
    self.assertIsNone(exit, msg=msg.replace("\n]\n", "\n] \n"))
AssertionError: -1 is not None : exit[-1] stdout[] stderr[ERROR(ldb): Failed to
  add ou "OU=movetest,DC=addom,DC=samba,DC=example,DC=com" - Entry
  OU=movetest,DC=addom,DC=samba,DC=example,DC=com already exists

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

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

14 months agopython:tests: Add missing result checks for samba_tool.gpo tests
Andreas Schneider [Thu, 9 Feb 2023 17:32:59 +0000 (18:32 +0100)]
python:tests: Add missing result checks for samba_tool.gpo tests

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

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