anoopcs/samba-autobuild/.git
3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.11.14 release. samba-4.11.14
Karolin Seeger [Fri, 25 Sep 2020 09:26:44 +0000 (11:26 +0200)]
VERSION: Disable GIT_SNAPSHOT for the 4.11.14 release.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.11.14.
Karolin Seeger [Fri, 25 Sep 2020 09:25:41 +0000 (11:25 +0200)]
WHATSNEW: Add release notes for Samba 4.11.14.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agowinbind: Fix a memleak
Laurent Menase [Wed, 20 May 2020 10:31:53 +0000 (12:31 +0200)]
winbind: Fix a memleak

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14388
Signed-off-by: Laurent Menase <laurent.menase@hpe.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Sep 14 13:33:13 UTC 2020 on sn-devel-184

(cherry picked from commit 8f868b0ea0b4795668f7bc0b028cd85686b249fb)

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Mon Oct  5 11:17:23 UTC 2020 on sn-devel-184

3 years agoVERSION: Bump version up to 4.11.14...
Stefan Metzmacher [Fri, 18 Sep 2020 13:39:47 +0000 (15:39 +0200)]
VERSION: Bump version up to 4.11.14...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoMerge tag 'samba-4.11.13' into v4-11-test
Stefan Metzmacher [Fri, 18 Sep 2020 13:38:14 +0000 (15:38 +0200)]
Merge tag 'samba-4.11.13' into v4-11-test

samba: tag release samba-4.11.13

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.11.13 release. samba-4.11.13
Karolin Seeger [Fri, 18 Sep 2020 10:58:56 +0000 (12:58 +0200)]
VERSION: Disable GIT_SNAPSHOT for the 4.11.13 release.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.11.13.
Karolin Seeger [Fri, 18 Sep 2020 10:56:10 +0000 (12:56 +0200)]
WHATSNEW: Add release notes for Samba 4.11.13.

CVE-2020-1472: Samba impact of "ZeroLogon".

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s4 torture rpc: repeated bytes in client challenge
Gary Lockyer [Fri, 18 Sep 2020 03:57:34 +0000 (15:57 +1200)]
CVE-2020-1472(ZeroLogon): s4 torture rpc: repeated bytes in client challenge

Ensure that client challenges with the first 5 bytes identical are
rejected.

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
[abartlet@samba.org: backported from master as test order was flipped]

3 years agoCVE-2020-1472(ZeroLogon): s4 torture rpc: Test empty machine acct pwd
Gary Lockyer [Fri, 18 Sep 2020 00:39:54 +0000 (12:39 +1200)]
CVE-2020-1472(ZeroLogon): s4 torture rpc: Test empty machine acct pwd

Ensure that an empty machine account password can't be set by
netr_ServerPasswordSet2

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
3 years agoCVE-2020-1472(ZeroLogon): docs-xml: document 'server require schannel:COMPUTERACCOUNT'
Stefan Metzmacher [Thu, 17 Sep 2020 15:27:54 +0000 (17:27 +0200)]
CVE-2020-1472(ZeroLogon): docs-xml: document 'server require schannel:COMPUTERACCOUNT'

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: log warnings about unsecure configu...
Günther Deschner [Thu, 17 Sep 2020 12:42:52 +0000 (14:42 +0200)]
CVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: log warnings about unsecure configurations

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

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

Signed-off-by: Günther Deschner <gd@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: support "server require schannel...
Günther Deschner [Thu, 17 Sep 2020 12:23:16 +0000 (14:23 +0200)]
CVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: support "server require schannel:WORKSTATION$ = no"

This allows to add expections for individual workstations, when using "server schannel = yes".
"server schannel = auto" is very insecure and will be removed soon.

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

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

Signed-off-by: Günther Deschner <gd@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: refactor dcesrv_netr_creds_server_s...
Günther Deschner [Thu, 17 Sep 2020 12:57:22 +0000 (14:57 +0200)]
CVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: refactor dcesrv_netr_creds_server_step_check()

We should debug more details about the failing request.

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

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

Signed-off-by: Günther Deschner <gd@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s4:rpc_server/netlogon: log warnings about unsecure configu...
Stefan Metzmacher [Thu, 17 Sep 2020 11:37:26 +0000 (13:37 +0200)]
CVE-2020-1472(ZeroLogon): s4:rpc_server/netlogon: log warnings about unsecure configurations

This should give admins wawrnings until they have a secure
configuration.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s4:rpc_server/netlogon: support "server require schannel...
Stefan Metzmacher [Wed, 16 Sep 2020 08:56:53 +0000 (10:56 +0200)]
CVE-2020-1472(ZeroLogon): s4:rpc_server/netlogon: support "server require schannel:WORKSTATION$ = no"

This allows to add expections for individual workstations, when using "server schannel = yes".
"server schannel = auto" is very insecure and will be removed soon.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s4:rpc_server/netlogon: refactor dcesrv_netr_creds_server_s...
Stefan Metzmacher [Wed, 16 Sep 2020 08:18:45 +0000 (10:18 +0200)]
CVE-2020-1472(ZeroLogon): s4:rpc_server/netlogon: refactor dcesrv_netr_creds_server_step_check()

We should debug more details about the failing request.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: protect netr_ServerPasswordSet2...
Jeremy Allison [Wed, 16 Sep 2020 19:53:50 +0000 (12:53 -0700)]
CVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: protect netr_ServerPasswordSet2 against unencrypted passwords

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

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: Fix mem leak onto p->mem_ctx in...
Jeremy Allison [Wed, 16 Sep 2020 19:48:21 +0000 (12:48 -0700)]
CVE-2020-1472(ZeroLogon): s3:rpc_server/netlogon: Fix mem leak onto p->mem_ctx in error path of _netr_ServerPasswordSet2().

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

Signed-off-by: Jeremy Allison <jra@samba.org>
[dbagnall@samba.org, abartlet@samba.org: adapt for indentation
changes]

3 years agoCVE-2020-1472(ZeroLogon): s4:rpc_server/netlogon: protect netr_ServerPasswordSet2...
Stefan Metzmacher [Wed, 16 Sep 2020 17:20:25 +0000 (19:20 +0200)]
CVE-2020-1472(ZeroLogon): s4:rpc_server/netlogon: protect netr_ServerPasswordSet2 against unencrypted passwords

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): libcli/auth: reject weak client challenges in netlogon_cred...
Stefan Metzmacher [Wed, 16 Sep 2020 14:17:29 +0000 (16:17 +0200)]
CVE-2020-1472(ZeroLogon): libcli/auth: reject weak client challenges in netlogon_creds_server_init()

This implements the note from MS-NRPC 3.1.4.1 Session-Key Negotiation:

 7. If none of the first 5 bytes of the client challenge is unique, the
    server MUST fail session-key negotiation without further processing of
    the following steps.

It lets ./zerologon_tester.py from
https://github.com/SecuraBV/CVE-2020-1472.git
report: "Attack failed. Target is probably patched."

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): libcli/auth: add netlogon_creds_is_random_challenge() to...
Stefan Metzmacher [Wed, 16 Sep 2020 14:15:26 +0000 (16:15 +0200)]
CVE-2020-1472(ZeroLogon): libcli/auth: add netlogon_creds_is_random_challenge() to avoid weak values

This is the check Windows is using, so we won't generate challenges,
which are rejected by Windows DCs (and future Samba DCs).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s4:rpc_server:netlogon: make use of netlogon_creds_random_c...
Stefan Metzmacher [Wed, 16 Sep 2020 14:10:53 +0000 (16:10 +0200)]
CVE-2020-1472(ZeroLogon): s4:rpc_server:netlogon: make use of netlogon_creds_random_challenge()

This is not strictly needed, but makes things more clear.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s3:rpc_server:netlogon: make use of netlogon_creds_random_c...
Stefan Metzmacher [Wed, 16 Sep 2020 14:10:53 +0000 (16:10 +0200)]
CVE-2020-1472(ZeroLogon): s3:rpc_server:netlogon: make use of netlogon_creds_random_challenge()

This is not strictly needed, but makes things more clear.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): libcli/auth: make use of netlogon_creds_random_challenge...
Stefan Metzmacher [Wed, 16 Sep 2020 14:08:38 +0000 (16:08 +0200)]
CVE-2020-1472(ZeroLogon): libcli/auth: make use of netlogon_creds_random_challenge() in netlogon_creds_cli.c

This will avoid getting rejected by the server if we generate
a weak challenge.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): s4:torture/rpc: make use of netlogon_creds_random_challenge()
Stefan Metzmacher [Wed, 16 Sep 2020 14:07:30 +0000 (16:07 +0200)]
CVE-2020-1472(ZeroLogon): s4:torture/rpc: make use of netlogon_creds_random_challenge()

This will avoid getting flakey tests once our server starts to
reject weak challenges.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agoCVE-2020-1472(ZeroLogon): libcli/auth: add netlogon_creds_random_challenge()
Stefan Metzmacher [Wed, 16 Sep 2020 14:04:57 +0000 (16:04 +0200)]
CVE-2020-1472(ZeroLogon): libcli/auth: add netlogon_creds_random_challenge()

It's good to have just a single isolated function that will generate
random challenges, in future we can add some logic in order to
avoid weak values, which are likely to be rejected by a server.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: don't log success as error
Philipp Gesang [Fri, 11 Sep 2020 07:55:18 +0000 (09:55 +0200)]
smbd: don't log success as error

In 58bc493c77 the check for NT_STATUS_OK was removed, causing
smbd to spam syslog with misleading ``failure`` messages:

    Sep 11 03:57:54 mail smbd[4813]:   remove_share_mode_lease: leases_db_del failed: NT_STATUS_OK
    Sep 11 03:58:54 mail smbd[4813]:   remove_share_mode_lease: leases_db_del failed: NT_STATUS_OK
    Sep 11 03:59:54 mail smbd[4813]:   remove_share_mode_lease: leases_db_del failed: NT_STATUS_OK
    Sep 11 04:00:03 mail smbd[4798]:   remove_share_mode_lease: leases_db_del failed: NT_STATUS_OK
    Sep 11 04:00:05 mail smbd[4798]:   remove_share_mode_lease: leases_db_del failed: NT_STATUS_OK

Reinstate the check; the code now follows the error handling
logic as in 4.13.

Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com>
Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Wed Sep 16 08:20:34 UTC 2020 on sn-devel-184

3 years agolib/replace: move lib/replace/closefrom.c from ROKEN_HOSTCC_SOURCE to REPLACE_HOSTCC_...
Stefan Metzmacher [Tue, 8 Sep 2020 10:13:20 +0000 (10:13 +0000)]
lib/replace: move lib/replace/closefrom.c from ROKEN_HOSTCC_SOURCE to REPLACE_HOSTCC_SOURCE

This is where it really belongs and we avoid the strange interaction
with source4/heimdal_build/config.h. This a follow up for commit
f31333d40e6fa38daa32a3ebb32d5a317c06fc62.

This fixes a build problem if libbsd-dev is not installed.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Björn Jacke <bjacke@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Sep  8 13:59:58 UTC 2020 on sn-devel-184

(cherry picked from commit 0022cd94587b805a525b0b9ef71ff0f15780424a)

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Thu Sep 10 07:24:07 UTC 2020 on sn-devel-184

3 years agotldap: Receiving "msgid == 0" means the connection is dead
Volker Lendecke [Tue, 11 Aug 2020 16:09:14 +0000 (18:09 +0200)]
tldap: Receiving "msgid == 0" means the connection is dead

We never use msgid=0, see tldap_next_msgid(). RFC4511 section 4.4.1
says that the unsolicited disconnect response uses msgid 0. We don't
parse this message, which supposedly is an extended response: Windows
up to 2019 sends an extended response in an ASN.1 encoding that does
not match RFC4511.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Aug 21 20:37:25 UTC 2020 on sn-devel-184

(cherry picked from commit ccaf661f7c75717341140e3fbfb2a48f96ea952c)

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Mon Aug 31 09:26:18 UTC 2020 on sn-devel-184

3 years agotest: Test winbind idmap_ad ticket expiry behaviour
Volker Lendecke [Thu, 13 Aug 2020 12:59:58 +0000 (14:59 +0200)]
test: Test winbind idmap_ad ticket expiry behaviour

We need to make sure that winbind's idmap_ad deals fine with an
expired krb ticket used to connect to AD via LDAP. In a customer
situation we have seen the RFC4511 section 4.4.1 unsolicited ldap exop
response coming through, but the TCP disconnect that Windows seems to
do after that did not make it. Winbind deals fine with a TCP
disconnect, but right now it does not handle just the section 4.4.1
response properly: It completely hangs.

This test requests a ticket valid for 5 seconds and makes the LDAP
server postpone the TCP disconnect after the ticket expiry for 10
seconds. The tests that winbind reacts to the ticket expiry exop
response by making sure in this situation the wbinfo call running into
the issue takes less than 8 seconds. If it did not look at the expiry
exop response, it would take more than 10 seconds.

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

3 years agoidmap_ad: Pass tldap debug messages on to DEBUG()
Stefan Metzmacher [Tue, 11 Aug 2020 16:24:39 +0000 (18:24 +0200)]
idmap_ad: Pass tldap debug messages on to DEBUG()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit 7af2df01dff62d6d9ca572f320ef60dea41d6064)

3 years agotldap: Add PRINTF_ATTRIBUTE declaration to tldap_debug()
Volker Lendecke [Wed, 12 Aug 2020 11:26:18 +0000 (13:26 +0200)]
tldap: Add PRINTF_ATTRIBUTE declaration to tldap_debug()

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit a2b281bed022c04427ef478529462ff84fe42908)

3 years agotldap: Make sure all requests are cancelled on rundown
Volker Lendecke [Tue, 11 Aug 2020 15:44:42 +0000 (17:44 +0200)]
tldap: Make sure all requests are cancelled on rundown

Put messages into the ld->pending array before sending them out, not
after they have been sent.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 2a2a6b27cccb2409d321c7e03feb8baa047d1bf4)

3 years agotldap: Centralize connection rundown on error
Volker Lendecke [Tue, 11 Aug 2020 15:30:22 +0000 (17:30 +0200)]
tldap: Centralize connection rundown on error

Whenever send or recv return -1, we have to cancel all pending
requests and our transport stream is no longer usable: Discard it upon
such an error.

To avoid duplicate state, tldap_connection_ok() now looks at whether
we have a tstream_context around.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit f745f5b12560dbcb7be6f3ffb3bc10704c87149c)

3 years agotldap: Maintain the ldap read request in tldap_context
Volker Lendecke [Tue, 11 Aug 2020 15:14:14 +0000 (17:14 +0200)]
tldap: Maintain the ldap read request in tldap_context

Required for proper connection rundown, we need to TALLOC_FREE() the
read request before shutting down the tstream

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit cb852c9dc0d0fa1d3e7473082ad6b460106b314b)

3 years agotldap: Always remove ourselves from ld->pending at cleanup time
Volker Lendecke [Mon, 17 Aug 2020 19:59:48 +0000 (21:59 +0200)]
tldap: Always remove ourselves from ld->pending at cleanup time

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 14f6d1996ec38620b1c05a3b6c0e26dd21801fac)

3 years agotldap: Fix tldap_msg_received()
Volker Lendecke [Tue, 11 Aug 2020 14:54:34 +0000 (16:54 +0200)]
tldap: Fix tldap_msg_received()

The callback of "req" might have destroyed "ld", we can't reference
this anymore after calling tevent_req_done(req). Defer calling the
callbacks, which also means that the callbacks can't have added
anything to ld->pending.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit f816ccb8f4d212fe7f6bf36f90cbb9297c899786)

3 years agotldap: Only free() ld->pending if "req" is part of it
Volker Lendecke [Tue, 11 Aug 2020 14:16:12 +0000 (16:16 +0200)]
tldap: Only free() ld->pending if "req" is part of it

Best reviewed with "git show -U10". We need to check that "req" is
actually the last request that is being freed before freeing the whole
array.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit b85dbc9ccf80d8c19aff33c1da83954e5d6a37ef)

3 years agoldap_server: Terminate LDAP connections on krb ticket expiry
Volker Lendecke [Mon, 10 Aug 2020 14:24:04 +0000 (16:24 +0200)]
ldap_server: Terminate LDAP connections on krb ticket expiry

See RFC4511 section 4.4.1 and

https://lists.samba.org/archive/cifs-protocol/2020-August/003515.html

for details: Windows terminates LDAP connections when the krb5 ticket
expires, Samba should do the same. This patch slightly deviates from
Windows behaviour by sending a LDAP exop response with msgid 0 that is
ASN1-encoded conforming to RFC4511.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit eb72f887b0bf91c050fd5d911f58a1b3ff9b8bcc)

3 years agoldap_server: Add the krb5 expiry to conn->limits
Volker Lendecke [Fri, 7 Aug 2020 11:40:58 +0000 (13:40 +0200)]
ldap_server: Add the krb5 expiry to conn->limits

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 77f72fb01faba45babfe6080f805361492ce49e5)

3 years agotorture: Test ldap session expiry
Volker Lendecke [Wed, 12 Aug 2020 13:50:58 +0000 (15:50 +0200)]
torture: Test ldap session expiry

LDAP connections should time out when the kerberos ticket used to authenticate
expires. Windows does this with a RFC4511 section 4.4.1 message (that as of
August 2020 is encoded not according to the RFC) followed by a TCP disconnect.

ldb sees the section 4.4.1 as a protocol violation and returns
LDB_ERR_PROTOCOL_ERROR.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 35c4bb0b0c55a65490fe199edb1a534548104e95)

3 years agobuild: Wrap a long line
Volker Lendecke [Wed, 12 Aug 2020 13:48:01 +0000 (15:48 +0200)]
build: Wrap a long line

There will be another entry in the next commit

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit c8c2f8ba73324ba43ccef9f6d1c0c726d7ec0d25)

3 years agoctdb-recoverd: Rename update_local_flags() -> update_flags()
Martin Schwenke [Tue, 23 Jan 2018 23:21:37 +0000 (10:21 +1100)]
ctdb-recoverd: Rename update_local_flags() -> update_flags()

This also updates remote flags so the name is misleading.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 4aa8e72d60e92951b35190d2ffcfdb1bfb756609)

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Tue Aug 25 15:13:03 UTC 2020 on sn-devel-184

3 years agoctdb-recoverd: Change update_local_flags() to use already retrieved nodemaps
Martin Schwenke [Thu, 18 Jan 2018 09:35:55 +0000 (20:35 +1100)]
ctdb-recoverd: Change update_local_flags() to use already retrieved nodemaps

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 702c7c4934e79a9161fdc59df70df30ae492d89f)

3 years agoctdb-recoverd: Get remote nodemaps earlier
Martin Schwenke [Thu, 13 Jun 2019 17:51:01 +0000 (03:51 +1000)]
ctdb-recoverd: Get remote nodemaps earlier

update_local_flags() will be changed to use these nodemaps.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 910a0b3b747a987ba69b6a0b6256e964b7d85dfe)

3 years agoctdb-recoverd: Do not fetch the nodemap from the recovery master
Martin Schwenke [Thu, 13 Jun 2019 14:23:22 +0000 (00:23 +1000)]
ctdb-recoverd: Do not fetch the nodemap from the recovery master

The nodemap has already been fetched from the local node and is
actually passed to this function.  Care must be taken to avoid
referencing the "remote" nodemap for the recovery master.  It also
isn't useful to do so, since it would be the same nodemap.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit d50919b0cb28f299c9b6985271b29d4f27c5f619)

3 years agoctdb-recoverd: Change get_remote_nodemaps() to use connected nodes
Martin Schwenke [Thu, 18 Jan 2018 09:02:42 +0000 (20:02 +1100)]
ctdb-recoverd: Change get_remote_nodemaps() to use connected nodes

The plan here is to use the nodemaps retrieved by get_remote_nodes()
in update_local_flags().  This will improve efficiency, since
get_remote_nodes() fetches flags from nodes in parallel.  It also
means that get_remote_nodes() can be used exactly once early on in
main_loop() to retrieve remote nodemaps.  Retrieving nodemaps multiple
times is unnecessary and racy - a single monitoring iteration should
not fetch flags multiple times and compare them.

This introduces a temporary behaviour change but it will be of no
consequence when the above changes are made.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 762d1d8a9605f97973a2c1176de5d29fcc61d15a)

3 years agoctdb-recoverd: Fix node_pnn check and assignment of nodemap into array
Martin Schwenke [Thu, 30 Jul 2020 01:57:51 +0000 (11:57 +1000)]
ctdb-recoverd: Fix node_pnn check and assignment of nodemap into array

This array is indexed by the same index as nodemap, not the PNN.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 368c83bfe3bbfff568d14f65e7b1ffa41d5349ac)

3 years agoctdb-recoverd: Add fail callback to assign banning credits
Martin Schwenke [Thu, 18 Jan 2018 08:58:15 +0000 (19:58 +1100)]
ctdb-recoverd: Add fail callback to assign banning credits

Also drop error handling in main_loop() that is replaced by this
change.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 10ce0dbf1c11eaaab7b28b6bbd014235a36d1962)

3 years agoctdb-recoverd: Add an intermediate state struct for nodemap fetching
Martin Schwenke [Thu, 18 Jan 2018 08:52:22 +0000 (19:52 +1100)]
ctdb-recoverd: Add an intermediate state struct for nodemap fetching

This will allow an error callback to be added.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit a079ee31690cf7110f46b41989ffcfb83b7626d6)

3 years agoctdb-recoverd: Move memory allocation into get_remote_nodemaps()
Martin Schwenke [Thu, 18 Jan 2018 05:31:39 +0000 (16:31 +1100)]
ctdb-recoverd: Move memory allocation into get_remote_nodemaps()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 2eaa0af6160588b6e3364b181d0976477d12b51b)

3 years agoctdb-recoverd: Change signature of get_remote_nodemaps()
Martin Schwenke [Thu, 18 Jan 2018 05:41:19 +0000 (16:41 +1100)]
ctdb-recoverd: Change signature of get_remote_nodemaps()

Change 1st argument to a rec context, since this will be needed later.
Drop the nodemap argument and access it via rec->nodemap instead.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 3324dd272c7dafa92cd9c3fd0af8f50084bcdaaa)

3 years agoctdb-recoverd: Fix a local memory leak
Martin Schwenke [Mon, 17 Aug 2020 10:27:18 +0000 (20:27 +1000)]
ctdb-recoverd: Fix a local memory leak

The memory is allocated off the memory context used by the current
iteration of main loop.  It is freed when main loop completes the fix
doesn't require backporting to stable branches.  However, it is sloppy
so it is worth fixing.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit d2d90f250214582d7124b8137aa2cf5032b2f285)

3 years agoctdb-recoverd: Basic cleanups for get_remote_nodemaps()
Martin Schwenke [Thu, 18 Jan 2018 05:19:36 +0000 (16:19 +1100)]
ctdb-recoverd: Basic cleanups for get_remote_nodemaps()

Don't log an error on failure - let the caller can do this.  Apart
from this: fix up coding style and modernise the remaining error
message.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 52f520d39cd92e1cf2413fd7e0dd362debd6f463)

3 years agoctdb-recoverd: Simplify calculation of new flags
Martin Schwenke [Tue, 14 Jul 2020 04:29:09 +0000 (14:29 +1000)]
ctdb-recoverd: Simplify calculation of new flags

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Jul 24 06:03:23 UTC 2020 on sn-devel-184

(cherry picked from commit 5ce6133a75107abdcb9fcfd93bc7594812dc5055)

3 years agoctdb-recoverd: Correctly find nodemap entry for pnn
Martin Schwenke [Tue, 14 Jul 2020 04:22:15 +0000 (14:22 +1000)]
ctdb-recoverd: Correctly find nodemap entry for pnn

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 3654e416770cc7521dcc3c15976daeba37023304)

3 years agoctdb-recoverd: Do not retrieve nodemap from recovery master
Martin Schwenke [Tue, 5 May 2020 13:49:05 +0000 (23:49 +1000)]
ctdb-recoverd: Do not retrieve nodemap from recovery master

It is already in rec->nodemap.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 9475ab044161e687b9ced3a477746393565b49b1)

3 years agoctdb-recoverd: Flatten update_flags_on_all_nodes()
Martin Schwenke [Fri, 28 Sep 2018 00:46:17 +0000 (10:46 +1000)]
ctdb-recoverd: Flatten update_flags_on_all_nodes()

The logic currently in ctdb_ctrl_modflags() will be optimised so that
it no longer matches the pattern for a control function.  So, remove
this function and squash its functionality into the only caller.

Although there are some superficial changes, the behaviour is
unchanged.

Flattening the 2 functions produces some seriously weird logic for
setting the new flags, to the point where using ctdb_ctrl_modflags()
for this purpose now looks very strange.  The weirdness will be
cleaned up in a subsequent commit.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 0c6a7db3ba84b8355359b0a8c52690b234bb866d)

3 years agoctdb-recoverd: Move ctdb_ctrl_modflags() to ctdb_recoverd.c
Martin Schwenke [Tue, 5 May 2020 13:37:57 +0000 (23:37 +1000)]
ctdb-recoverd: Move ctdb_ctrl_modflags() to ctdb_recoverd.c

This file is the only user of this function.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit a88c10c5a9afcf0a3dcadef07dd95af498bfa47a)

3 years agoctdb-recoverd: Improve a call to update_flags_on_all_nodes()
Martin Schwenke [Tue, 14 Jul 2020 04:43:04 +0000 (14:43 +1000)]
ctdb-recoverd: Improve a call to update_flags_on_all_nodes()

This should take a PNN, not an array index.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit b1e631ff929fd87392a80895d1c8d265d9df42dc)

3 years agoctdb-recoverd: Use update_flags_on_all_nodes()
Martin Schwenke [Fri, 14 Jun 2019 21:20:19 +0000 (07:20 +1000)]
ctdb-recoverd: Use update_flags_on_all_nodes()

This is clearer than using the MODFLAGS control directly.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 915d24ac12d27c21649d9e64d201d9df9d583129)

3 years agoctdb-recoverd: Introduce some local variables to improve readability
Martin Schwenke [Fri, 14 Jun 2019 21:19:26 +0000 (07:19 +1000)]
ctdb-recoverd: Introduce some local variables to improve readability

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit f681c0e947741151f8fb95d88edddfd732166dc1)

3 years agoctdb-recoverd: Change update_flags_on_all_nodes() to take rec argument
Martin Schwenke [Tue, 5 May 2020 13:45:15 +0000 (23:45 +1000)]
ctdb-recoverd: Change update_flags_on_all_nodes() to take rec argument

This makes fields such as recmaster and nodemap easily available if
required.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit cb3a3147b7a3a29d7806733791e1fa6ba2e46680)

3 years agoctdb-recoverd: Drop unused nodemap argument from update_flags_on_all_nodes()
Martin Schwenke [Thu, 18 Jan 2018 09:25:07 +0000 (20:25 +1100)]
ctdb-recoverd: Drop unused nodemap argument from update_flags_on_all_nodes()

An unused argument needlessly extends the length of function calls.  A
subsequent change will allow rec->nodemap to be used if necessary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 6982fcb3e6c940d0047aac3b6bfbc9dfdc8d7214)

3 years agolib/util: do not install /usr/bin/test_util
Günther Deschner [Tue, 25 Aug 2020 08:37:18 +0000 (10:37 +0200)]
lib/util: do not install /usr/bin/test_util

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

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
3 years agoVERSION: Bump version up to 4.11.13...
Karolin Seeger [Tue, 25 Aug 2020 07:46:42 +0000 (09:46 +0200)]
VERSION: Bump version up to 4.11.13...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.11.12 release. samba-4.11.12
Karolin Seeger [Tue, 25 Aug 2020 07:45:14 +0000 (09:45 +0200)]
VERSION: Disable GIT_SNAPSHOT for the 4.11.12 release.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoWHATSNEW: Add release notes for Samba 4.11.12.
Karolin Seeger [Tue, 25 Aug 2020 07:44:25 +0000 (09:44 +0200)]
WHATSNEW: Add release notes for Samba 4.11.12.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoutil: Add cmocka unit test for directory_create_or_exists
Christof Schmitt [Fri, 14 Aug 2020 19:18:51 +0000 (12:18 -0700)]
util: Add cmocka unit test for directory_create_or_exists

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

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): Sun Aug 16 07:06:59 UTC 2020 on sn-devel-184

(cherry picked from commit e89ec78e9a262a6e7bb9082323083eb5f1609655)

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Mon Aug 17 14:27:37 UTC 2020 on sn-devel-184

3 years agoutil: Allow symlinks in directory_create_or_exist
Christof Schmitt [Fri, 14 Aug 2020 16:36:26 +0000 (09:36 -0700)]
util: Allow symlinks in directory_create_or_exist

Commit 9f60a77e0b updated the check to avoid having files or other
objects instead of a directory. This missed the valid case that there
might be a symlink to a directory. Updated the check accordingly to
allow symlinks to directories.

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

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

3 years agodbcheck: Allow a dangling forward link outside our known NCs
Andrew Bartlett [Sun, 26 Jul 2020 23:37:29 +0000 (11:37 +1200)]
dbcheck: Allow a dangling forward link outside our known NCs

If we do not have the NC of the target object we can not be really sure
that the object is redundent and so we want to keep it for now
and not (as happened until now) break the dbcheck run made during the
replication stage of a "samba-tool domain backup rename".

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

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

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Thu Aug  6 13:32:29 UTC 2020 on sn-devel-184

3 years agos3:smbd: check for stale pid in delay_for_oplock_fn() when leases_db_get() fails
Stefan Metzmacher [Mon, 6 Jul 2020 06:58:22 +0000 (08:58 +0200)]
s3:smbd: check for stale pid in delay_for_oplock_fn() when leases_db_get() fails

If leases_db_get() failed the leases_db record might have been cleaned up for
stale processes. Check if the share-mode-entry owner is stale in this case and
return ignore the entry. In any other case, log a debug messages and panic.

Commit 05d4466a6d1ad048fa86aea09ec0a56a7b961369
"smbd: check for stale pid in get_lease_type()" fixed only one half of
this.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jul  7 02:47:46 UTC 2020 on sn-devel-184

(backported from commit 58adf349edfd3001ad071cc7ed8cfc551f67f8a2)
[metze@samba.org: use share_mode_stale_pid() instead of share_entry_stale_pid()]
[metze@samba.org: use file_id_string_tos() instead of file_id_str_buf()]

3 years agos3:leases: log errors with level 0 in leases_db_do_locked_fn()
Stefan Metzmacher [Mon, 6 Jul 2020 12:03:39 +0000 (14:03 +0200)]
s3:leases: log errors with level 0 in leases_db_do_locked_fn()

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

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

3 years agosmbd: check for stale pid in get_lease_type()
Ralph Boehme [Thu, 2 Jul 2020 12:47:12 +0000 (14:47 +0200)]
smbd: check for stale pid in get_lease_type()

If leases_db_get() failed the leases_db record might have been cleaned up for
stale processes. Check if the share-mode-entry owner is stale in this case and
return a 0 lease state. In any other case, log a debug messages and panic.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jul  2 16:45:42 UTC 2020 on sn-devel-184

(backported from commit 05d4466a6d1ad048fa86aea09ec0a56a7b961369)
[slow@samba.org: use share_mode_stale_pid() instead of share_entry_stale_pid()]
[metze@samba.org: use file_id_string_tos() instead of file_id_str_buf()]

3 years agosmbd: let get_lease_type() take a non-const share_mode_entry
Ralph Boehme [Thu, 2 Jul 2020 12:45:59 +0000 (14:45 +0200)]
smbd: let get_lease_type() take a non-const share_mode_entry

We're going to add a call to share_entry_stale_pid(share_mode_entry) which takes
a non-const pointer (in order to eventually set e->state = true).

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(backported from commit 3f4a865821da27efbed4f7c38ad3efbcaae77a02)
[slow@samba.org: get_lease_type() takes arg d in 4.11]

3 years agosmbd: inverse if/else logic in get_lease_type()
Ralph Boehme [Thu, 2 Jul 2020 12:08:44 +0000 (14:08 +0200)]
smbd: inverse if/else logic in get_lease_type()

No change in behaviour.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(backported from commit e4328db1c94837a8ea5652971cea20055d3d24ff)
[slow@samba.org: take id from d as it's not passed as arg]

3 years agos3/leases: log NDR decoding failure with level 0 in leases_db_get_fn()
Ralph Boehme [Thu, 2 Jul 2020 12:10:05 +0000 (14:10 +0200)]
s3/leases: log NDR decoding failure with level 0 in leases_db_get_fn()

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

Signed-off-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 383a2457bd6cbe0acd571a8d601f8bdc5365f0b4)

3 years agosmbd: increase loglevel when leases_db_del() with anything then NT_STATUS_NOT_FOUND
Ralph Boehme [Thu, 2 Jul 2020 12:09:15 +0000 (14:09 +0200)]
smbd: increase loglevel when leases_db_del() with anything then NT_STATUS_NOT_FOUND

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(backported from commit fbb8bbe1243eb2a0351dc2422929278f85a99e26)
[slow@samba.org: remove_lease_if_stale() does not exist in 4.11]

3 years agodocs: Fix documentation for require_membership_of of pam_winbind.conf
Andreas Schneider [Fri, 17 Jul 2020 10:14:16 +0000 (12:14 +0200)]
docs: Fix documentation for require_membership_of of pam_winbind.conf

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
(cherry picked from commit 71b7140fd0a33e7e8c5bf37c2897cea8224b3f01)

3 years agodocs: Fix documentation for require_membership_of of pam_winbind
Andreas Schneider [Thu, 9 Jul 2020 09:48:26 +0000 (11:48 +0200)]
docs: Fix documentation for require_membership_of of pam_winbind

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 4c74db6978c682f8ba4e74a6ee8157cfcbb54971)

3 years agolib/debug: set the correct default backend loglevel to MAX_DEBUG_LEVEL
Ralph Boehme [Tue, 30 Jun 2020 15:03:05 +0000 (17:03 +0200)]
lib/debug: set the correct default backend loglevel to MAX_DEBUG_LEVEL

This fixed a regression introduced by commit
c83ce5f4f99aef94530411ec82cc03e9935b352d for bug #14345.

The backend loglevel globally restricts logging of a particular backend. If this
value is smaller then any explicitly configured logging class, logging for this
class is skipped.

Eg, given the following logging config in smb.conf:

  log level = 1 auth_json_audit:3@/var/log/samba/samba_auth_audit.log

the default class loglevel of 1 (dbgc_config[DBGC_ALL].loglevel) will be
assigned to the backend loglevel.

So even though the logging class auth_json_audit is configured at level 3, this
doesn't become effective as the file backend drops all log messages with a level
below 1.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Jul  2 13:25:29 UTC 2020 on sn-devel-184

(cherry picked from commit 71488b812fe737df2d3439a6ff3f95bb69b4a5bd)

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Thu Jul  9 11:40:15 UTC 2020 on sn-devel-184

3 years agolib/debug: assert file backend
Ralph Boehme [Tue, 30 Jun 2020 15:02:07 +0000 (17:02 +0200)]
lib/debug: assert file backend

The debug file backend is a built-in default, if it's missing we're totally
screwed.

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

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

3 years agolib:util: Fix smbclient -l basename dir
Amit Kumar [Wed, 22 Apr 2020 11:53:42 +0000 (06:53 -0500)]
lib:util: Fix smbclient -l basename dir

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

Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Amit Kumar <amitkuma@redhat.com>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit c83ce5f4f99aef94530411ec82cc03e9935b352d)

3 years agoAdd a test for smbclient -l basename
Amit Kumar [Wed, 22 Apr 2020 11:53:33 +0000 (06:53 -0500)]
Add a test for smbclient -l basename

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

Signed-off-by: Amit Kumar <amitkuma@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 2a7fc40fb3f3ca994cecad3e2957433d7a411208)

3 years agos3:winbind:idmap_ad - make failure to get attrnames for schema mode fatal
Andrew [Tue, 30 Jun 2020 10:54:06 +0000 (06:54 -0400)]
s3:winbind:idmap_ad - make failure to get attrnames for schema mode fatal

Add check for failure to resolve the OID array for the schema mode into
names.

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

Signed-off-by: Andrew <awalker@ixsystems.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit b5b801026edd3a8fd8d0ba1752e891453cf675c9)

3 years agolib/util: do not install "test_util_paths"
Günther Deschner [Thu, 2 Jul 2020 16:56:20 +0000 (18:56 +0200)]
lib/util: do not install "test_util_paths"

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

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Tue Jul  7 08:16:40 UTC 2020 on sn-devel-184

3 years agoselftest: Run test of how userPassword / crypt() style passwords are stored in quicktest
Andrew Bartlett [Wed, 1 Jul 2020 02:31:54 +0000 (14:31 +1200)]
selftest: Run test of how userPassword / crypt() style passwords are stored in quicktest

This ensures that the crypt_r()/crypt_rn()/crypt() behaviour is tested in all
the samba-o3 builds and so is checked on RHEL7 in GitLab CI.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit cabf873b75b1d4d456190358bc3ed051bca16978)

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Mon Jul  6 15:10:27 UTC 2020 on sn-devel-184

3 years agoselftest: Split samba.tests.samba_tool.user_virtualCryptSHA into GPG and not GPG...
Andrew Bartlett [Wed, 1 Jul 2020 02:30:24 +0000 (14:30 +1200)]
selftest: Split samba.tests.samba_tool.user_virtualCryptSHA into GPG and not GPG parts

This allows the userPassword (not GPG) part of the test to run on hosts without
python3-gpg (eg RHEL7) while still testing the userPassword handling.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 2c4ecf002a3fbbe8be061814468529c8bd6bb7aa)

3 years agodsdb: Allow "password hash userPassword schemes = CryptSHA256" to work on RHEL7
Andrew Bartlett [Wed, 1 Jul 2020 02:35:39 +0000 (14:35 +1200)]
dsdb: Allow "password hash userPassword schemes = CryptSHA256" to work on RHEL7

On RHEL7 crypt_r() will set errno.  This is a problem because the implementation of crypt_r()
in RHEL8 and elsewhere in libcrypt will return non-NULL but set errno on failure.

The workaround is to use crypt_rn(), provided only by libcrypt, which will return NULL
on failure, and so avoid checking errno in the non-failure case.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 91453f110fa72062291eb59ad9d95fab0f423557)

3 years agoutil: fix build on AIX by fixing the order of replace.h include
Bjoern Jacke [Mon, 29 Jun 2020 12:00:46 +0000 (12:00 +0000)]
util: fix build on AIX by fixing the order of replace.h include

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

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit d93a6d2663a25bca072cd5623aea16e21ed650b8)

3 years agoutil: Reallocate larger buffer if getpwuid_r() returns ERANGE
Martin Schwenke [Fri, 5 Jun 2020 12:05:42 +0000 (22:05 +1000)]
util: Reallocate larger buffer if getpwuid_r() returns ERANGE

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Bjoern Jacke <bjacke@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Jun  9 21:07:24 UTC 2020 on sn-devel-184

(cherry picked from commit ddac6b2eb4adaec8fc5e25ca07387d2b9417764c)

3 years agoutil: Fix build on FreeBSD by avoiding NSS_BUFLEN_PASSWD
Martin Schwenke [Fri, 5 Jun 2020 11:52:23 +0000 (21:52 +1000)]
util: Fix build on FreeBSD by avoiding NSS_BUFLEN_PASSWD

NSS_BUFLEN_PASSWD is not defined on FreeBSD.  Use
sysconf(_SC_GETPW_R_SIZE_MAX) instead, as per POSIX.

Use a dynamically allocated buffer instead of trying to cram all of
the logic into the declarations.  This will come in useful later
anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Bjoern Jacke <bjacke@samba.org>
(cherry picked from commit 847208cd8ac68c4c7d1dae63767820db1c69292b)

3 years agoutil: Simplify input validation
Martin Schwenke [Tue, 9 Jun 2020 01:52:50 +0000 (11:52 +1000)]
util: Simplify input validation

It appears that snprintf(3) is being used for input validation.
However, this seems like overkill because it causes szPath to be
copied an extra time.  The mostly likely protections being sought
here, according to https://cwe.mitre.org/data/definitions/20.html,
look to be DoS attacks involving CPU and memory usage.  A simpler
check that uses strnlen(3) can mitigate against both of these and is
simpler.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Bjoern Jacke <bjacke@samba.org>
(cherry picked from commit 922bce2668994dd2a5988c17060f977e9bb0c229)

3 years agos3: libsmb: Fix SMB2 client rename bug to a Windows server.
Jeremy Allison [Tue, 30 Jun 2020 21:00:41 +0000 (14:00 -0700)]
s3: libsmb: Fix SMB2 client rename bug to a Windows server.

Fix bug where renaming to a target name of one
UCS2 character (name length 2 bytes) fails to
a Windows 10 SMB2 server.

The Windows 10 SMB2 server has a minimum length
for a SMB2_FILE_RENAME_INFORMATION buffer of
24 bytes. It returns NT_STATUS_INFO_LENGTH_MISMATCH
if the length is less. This isn't an alignment
issue as Windows client happily 2-byte align
for larget target name sizes. Also the Windows 10
SMB1 server doesn't have this restriction.

If the name length is too short, pad out with
zeros to 24 bytes.

Hard to add a test for this as we don't want to
add this silly restriction to the Samba server
as it would break all non-Windows clients.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jul  1 18:59:53 UTC 2020 on sn-devel-184

(cherry picked from commit f59490dc2d07107d32d6e888f2814011ab2845b7)

3 years agoVERSION: Bump version up to 4.11.12.
Karolin Seeger [Thu, 2 Jul 2020 09:04:19 +0000 (11:04 +0200)]
VERSION: Bump version up to 4.11.12.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoMerge tag 'samba-4.11.11' into v4-11-test
Karolin Seeger [Thu, 2 Jul 2020 09:03:55 +0000 (11:03 +0200)]
Merge tag 'samba-4.11.11' into v4-11-test

samba: tag release samba-4.11.11

3 years agoVERSION: Disable GIT_SNAPSHOT for the 4.11.11 release. samba-4.11.11
Karolin Seeger [Wed, 1 Jul 2020 08:14:05 +0000 (10:14 +0200)]
VERSION: Disable GIT_SNAPSHOT for the 4.11.11 release.

This is a security release in order to address the following CVEs:

o CVE-2020-10730: NULL pointer de-reference and use-after-free in Samba AD DC
                  LDAP Server with ASQ, VLV and paged_results.
o CVE-2020-10745: Parsing and packing of NBT and DNS packets can consume
                  excessive CPU.
o CVE-2020-10760: LDAP Use-after-free in Samba AD DC Global Catalog with
                  paged_results and VLV.
o CVE-2020-14303: Empty UDP packet DoS in Samba AD DC nbtd.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoAdd release notes for Samba 4.11.11.
Karolin Seeger [Wed, 1 Jul 2020 08:13:42 +0000 (10:13 +0200)]
Add release notes for Samba 4.11.11.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
3 years agoCVE-2020-10760 dsdb: Add tests for paged_results and VLV over the Global Catalog...
Andrew Bartlett [Mon, 8 Jun 2020 04:32:14 +0000 (16:32 +1200)]
CVE-2020-10760 dsdb: Add tests for paged_results and VLV over the Global Catalog port

This should avoid a regression.

(backported from master patch)
[abartlet@samba.org: sort=True parameter on test_paged_delete_during_search
 is not in 4.11]

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-10760 dsdb: Ensure a proper talloc tree for saved controls
Andrew Bartlett [Fri, 5 Jun 2020 10:14:48 +0000 (22:14 +1200)]
CVE-2020-10760 dsdb: Ensure a proper talloc tree for saved controls

Otherwise a paged search on the GC port will fail as the ->data was
not kept around for the second page of searches.

An example command to produce this is
 bin/ldbsearch --paged -H ldap://$SERVER:3268 -U$USERNAME%$PASSWORD

This shows up later in the partition module as:

ERROR: AddressSanitizer: heap-use-after-free on address 0x60b00151ef20 at pc 0x7fec3f801aac bp 0x7ffe8472c270 sp 0x7ffe8472c260
READ of size 4 at 0x60b00151ef20 thread T0 (ldap(0))
    #0 0x7fec3f801aab in talloc_chunk_from_ptr ../../lib/talloc/talloc.c:526
    #1 0x7fec3f801aab in __talloc_get_name ../../lib/talloc/talloc.c:1559
    #2 0x7fec3f801aab in talloc_check_name ../../lib/talloc/talloc.c:1582
    #3 0x7fec1b86b2e1 in partition_search ../../source4/dsdb/samdb/ldb_modules/partition.c:780

or

smb_panic_default: PANIC (pid 13287): Bad talloc magic value - unknown value
(from source4/dsdb/samdb/ldb_modules/partition.c:780)

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>