vlendec/samba-autobuild/.git
6 years agoctdb-tests: Implement control CHECK_PID_SRVID in fake daemon
Amitay Isaacs [Wed, 30 Aug 2017 07:04:44 +0000 (17:04 +1000)]
ctdb-tests: Implement control CHECK_PID_SRVID in fake daemon

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-tests: Reimplement message handlers using srvid abstraction
Amitay Isaacs [Wed, 30 Aug 2017 06:59:16 +0000 (16:59 +1000)]
ctdb-tests: Reimplement message handlers using srvid abstraction

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

This is required for CHECK_PID_SRVID control implementation.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-tool: Update process-exists command to pass optional srvid
Amitay Isaacs [Wed, 30 Aug 2017 06:29:01 +0000 (16:29 +1000)]
ctdb-tool: Update process-exists command to pass optional srvid

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-client: Add client code for control CHECK_PID_SRVID
Amitay Isaacs [Thu, 21 Sep 2017 05:52:14 +0000 (15:52 +1000)]
ctdb-client: Add client code for control CHECK_PID_SRVID

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-daemon: Add implementation of control CHECK_PID_SRVID
Amitay Isaacs [Wed, 30 Aug 2017 06:18:02 +0000 (16:18 +1000)]
ctdb-daemon: Add implementation of control CHECK_PID_SRVID

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-protocol: Add marshalling for control CHECK_PID_SRVID
Amitay Isaacs [Wed, 30 Aug 2017 05:13:53 +0000 (15:13 +1000)]
ctdb-protocol: Add marshalling for control CHECK_PID_SRVID

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-protocol: Add marshalling for struct ctdb_pid_srvid
Amitay Isaacs [Wed, 30 Aug 2017 05:13:12 +0000 (15:13 +1000)]
ctdb-protocol: Add marshalling for struct ctdb_pid_srvid

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-protocol: Add new control CTDB_CONTROL_CHECK_PID_SRVID
Amitay Isaacs [Wed, 30 Aug 2017 05:10:56 +0000 (15:10 +1000)]
ctdb-protocol: Add new control CTDB_CONTROL_CHECK_PID_SRVID

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-common: Extend srvid_exists() check to support optional private_data
Amitay Isaacs [Wed, 30 Aug 2017 03:27:12 +0000 (13:27 +1000)]
ctdb-common: Extend srvid_exists() check to support optional private_data

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

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agotestsuite: Fix the 32-bit test build
Volker Lendecke [Wed, 20 Sep 2017 00:12:33 +0000 (00:12 +0000)]
testsuite: Fix the 32-bit test build

samba_init_module returns 32-bit. For some reason on my
32-bit lxc "return 0" was converted to something but
NT_STATUS_OK, making initialization fail.

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): Thu Sep 21 02:49:32 CEST 2017 on sn-devel-144

6 years agoWHATSNEW: Mention code removal from "net" and "rpcclient"
Volker Lendecke [Tue, 19 Sep 2017 22:26:55 +0000 (15:26 -0700)]
WHATSNEW: Mention code removal from "net" and "rpcclient"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agolibnet: Remove libnet_samsync
Volker Lendecke [Tue, 19 Sep 2017 22:17:38 +0000 (15:17 -0700)]
libnet: Remove libnet_samsync

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agonet: Don't depend on libnet_samsync anymore
Volker Lendecke [Tue, 19 Sep 2017 22:14:32 +0000 (15:14 -0700)]
net: Don't depend on libnet_samsync anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agonet: Remove NT4-based vampire keytab
Volker Lendecke [Tue, 19 Sep 2017 22:09:05 +0000 (15:09 -0700)]
net: Remove NT4-based vampire keytab

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agonet: Remove NT4-based rpc vampire ldif
Volker Lendecke [Tue, 19 Sep 2017 22:06:11 +0000 (15:06 -0700)]
net: Remove NT4-based rpc vampire ldif

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agonet: Remove rpc vampire from NT4 domains
Volker Lendecke [Tue, 19 Sep 2017 22:03:43 +0000 (15:03 -0700)]
net: Remove rpc vampire from NT4 domains

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agonet: Remove rpc samdump
Volker Lendecke [Tue, 19 Sep 2017 22:02:09 +0000 (15:02 -0700)]
net: Remove rpc samdump

This uses the NT4 replication commands. Samba does not have a server
for this, no tests, and whoever needs to migrate a native domain can
use an old Samba version

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agorpcclient: Remove sam_sync related commands
Volker Lendecke [Tue, 19 Sep 2017 21:33:07 +0000 (14:33 -0700)]
rpcclient: Remove sam_sync related commands

These three commands don't use the netlogon credential chain
correctly. They are missing the netlogon_creds_store after the dcerpc
call, so they destroy the correct use of the netlogon creds.

The only valid server for these calls that I know of would be NT4, and
that should be gone long ago.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agoMake sure smbtorture tests can run if someone has set their min protocol above NT1.
Richard Sharpe [Sun, 10 Sep 2017 19:50:57 +0000 (12:50 -0700)]
Make sure smbtorture tests can run if someone has set their min protocol above NT1.

This code is SMB1 only, and already modifies
maxprotocol, so this change is appropriate.

Signed-off-by: Richard Sharpe <richard.sharpe@primarydata.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
6 years agoCVE-2017-12163: s3:smbd: Prevent client short SMB1 write from writing server memory...
Jeremy Allison [Fri, 8 Sep 2017 17:13:14 +0000 (10:13 -0700)]
CVE-2017-12163: s3:smbd: Prevent client short SMB1 write from writing server memory to file.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(master): Wed Sep 20 17:06:23 CEST 2017 on sn-devel-144

6 years agoCVE-2017-12150: s3:libsmb: only fallback to anonymous if authentication was not requested
Stefan Metzmacher [Mon, 12 Dec 2016 05:07:56 +0000 (06:07 +0100)]
CVE-2017-12150: s3:libsmb: only fallback to anonymous if authentication was not requested

With forced encryption or required signing we should also don't fallback.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agoCVE-2017-12150: libcli/smb: add smbXcli_conn_signing_mandatory()
Stefan Metzmacher [Tue, 29 Aug 2017 13:35:49 +0000 (15:35 +0200)]
CVE-2017-12150: libcli/smb: add smbXcli_conn_signing_mandatory()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agoCVE-2017-12150: auth/credentials: cli_credentials_authentication_requested() should...
Stefan Metzmacher [Tue, 29 Aug 2017 13:24:14 +0000 (15:24 +0200)]
CVE-2017-12150: auth/credentials: cli_credentials_authentication_requested() should check for NTLM_CCACHE/SIGN/SEAL

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agoCVE-2017-12150: libgpo: make use of SMB_SIGNING_REQUIRED in gpo_connect_server()
Stefan Metzmacher [Mon, 12 Dec 2016 04:49:46 +0000 (05:49 +0100)]
CVE-2017-12150: libgpo: make use of SMB_SIGNING_REQUIRED in gpo_connect_server()

It's important that we use a signed connection to get the GPOs!

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agoCVE-2017-12150: s3:pylibsmb: make use of SMB_SIGNING_DEFAULT for 'samba.samba3.libsmb...
Stefan Metzmacher [Fri, 9 Dec 2016 08:26:32 +0000 (09:26 +0100)]
CVE-2017-12150: s3:pylibsmb: make use of SMB_SIGNING_DEFAULT for 'samba.samba3.libsmb_samba_internal'

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agoCVE-2017-12150: s3:lib: get_cmdline_auth_info_signing_state smb_encrypt SMB_SIGNING_R...
Stefan Metzmacher [Thu, 3 Nov 2016 16:16:43 +0000 (17:16 +0100)]
CVE-2017-12150: s3:lib: get_cmdline_auth_info_signing_state smb_encrypt SMB_SIGNING_REQUIRED

This is an addition to the fixes for CVE-2015-5296.

It applies to smb2mount -e, smbcacls -e and smbcquotas -e.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agoCVE-2017-12150: s3:popt_common: don't turn a guessed username into a specified one
Stefan Metzmacher [Tue, 29 Aug 2017 15:06:21 +0000 (17:06 +0200)]
CVE-2017-12150: s3:popt_common: don't turn a guessed username into a specified one

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agoCVE-2017-12151: s3:libsmb: make use of cli_state_is_encryption_on()
Stefan Metzmacher [Sat, 17 Dec 2016 09:36:49 +0000 (10:36 +0100)]
CVE-2017-12151: s3:libsmb: make use of cli_state_is_encryption_on()

This will keep enforced encryption across dfs referrals.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agoCVE-2017-12151: s3:libsmb: add cli_state_is_encryption_on() helper function
Stefan Metzmacher [Mon, 14 Aug 2017 10:13:18 +0000 (12:13 +0200)]
CVE-2017-12151: s3:libsmb: add cli_state_is_encryption_on() helper function

This allows to check if the current cli_state uses encryption
(either via unix extentions or via SMB3).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
6 years agodsdb: Only trigger a re-index once per @INDEXLIST modification
Andrew Bartlett [Mon, 11 Sep 2017 01:53:19 +0000 (13:53 +1200)]
dsdb: Only trigger a re-index once per @INDEXLIST modification

A modify of both @INDEXLIST and @ATTRIBUTES will still trigger two re-index passes
but that is a task for later.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Sep 20 12:29:49 CEST 2017 on sn-devel-144

6 years agoselftest: sort dbcheck output to avoid sort order impacting results
Andrew Bartlett [Fri, 25 Aug 2017 05:37:05 +0000 (17:37 +1200)]
selftest: sort dbcheck output to avoid sort order impacting results

The GUID index code will change the returned results order

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agos4-dnsserver: Check for too many DNS results
Andrew Bartlett [Tue, 29 Aug 2017 02:19:22 +0000 (14:19 +1200)]
s4-dnsserver: Check for too many DNS results

If we had this check in when the wildcard DNS tests were written, we would have
noticed that the name needed to be escaped (see previous commit).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12994
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agos4-dnsserver: Always encode user-supplied names when looking up DNS records
Andrew Bartlett [Mon, 28 Aug 2017 23:48:46 +0000 (11:48 +1200)]
s4-dnsserver: Always encode user-supplied names when looking up DNS records

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agokcc: Remove unused, untested KCC code
Garming Sam [Sun, 17 Sep 2017 21:55:21 +0000 (09:55 +1200)]
kcc: Remove unused, untested KCC code

This code tries to implement the full KCC algorithm, but never
actually worked correctly.

Removing this doesn't affect the full-mesh KCC. This code only
attempted to calculate a graph using the "proper" algorithm, though it
neglected to write its results back into the database. The full-mesh
calculation occurs elsewhere.

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Sep 20 06:28:07 CEST 2017 on sn-devel-144

6 years agoldap_server: Plumb ldb error string from a failed connect to ldapsrv_terminate_connec...
Andrew Bartlett [Thu, 14 Sep 2017 03:07:10 +0000 (15:07 +1200)]
ldap_server: Plumb ldb error string from a failed connect to ldapsrv_terminate_connection()

However, do not plumb it to the client-seen error string, as it could contain server paths.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 years agosamdb: Rework samdb_connect_url() to return LDB error code and an error string
Andrew Bartlett [Thu, 14 Sep 2017 03:02:36 +0000 (15:02 +1200)]
samdb: Rework samdb_connect_url() to return LDB error code and an error string

This allows debugging of why the LDB failed to start up.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 years agoldb: Release 1.2.3
Andrew Bartlett [Thu, 14 Sep 2017 02:44:39 +0000 (14:44 +1200)]
ldb: Release 1.2.3

 * Bug #13033 LDB open with LDB_FLG_RDONLY can cause the database
   to fail to open

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 years agoldb: Add tests for read only behaviour
Gary Lockyer [Wed, 13 Sep 2017 23:37:41 +0000 (11:37 +1200)]
ldb: Add tests for read only behaviour

As the kernel is no longer enforcing the read-only DB
add some tests.

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 years agoldb_tdb: Change ltdb_connect() NOT to request a kernel-level read only TDB
Andrew Bartlett [Sun, 17 Sep 2017 22:43:32 +0000 (10:43 +1200)]
ldb_tdb: Change ltdb_connect() NOT to request a kernel-level read only TDB

We support opening and LDB multiple times in a process, but do not support this in tdb.

As we can open the ldb with different flags, we must ensure a later read-write
open is possible.

Additionally, a read-only TDB will refuse the all-record lock, preventing
the ldb from even loading.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 years agoldb_tdb: Give a debug message as well as setting the error string if prepare_commit...
Andrew Bartlett [Thu, 14 Sep 2017 03:01:39 +0000 (15:01 +1200)]
ldb_tdb: Give a debug message as well as setting the error string if prepare_commit() fails

This is a serious condition, and should be logged.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 years agoldb_tdb: Map TDB error codes into LDB error codes in ltdb_lock_read()
Andrew Bartlett [Thu, 14 Sep 2017 02:04:51 +0000 (14:04 +1200)]
ldb_tdb: Map TDB error codes into LDB error codes in ltdb_lock_read()

The ltdb_lock_read() routine did not return an LDB error code, but -1.

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
6 years agoctdb-tools: Fix a typo for a talloc context
Martin Schwenke [Wed, 6 Sep 2017 08:11:41 +0000 (18:11 +1000)]
ctdb-tools: Fix a typo for a talloc context

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): Tue Sep 19 17:31:18 CEST 2017 on sn-devel-144

6 years agoctdb-tools: Add debug to ctdb_killtcp
Martin Schwenke [Tue, 4 Jul 2017 02:11:20 +0000 (12:11 +1000)]
ctdb-tools: Add debug to ctdb_killtcp

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-tools: Move special case of 0 connections into computation
Martin Schwenke [Tue, 4 Jul 2017 04:02:14 +0000 (14:02 +1000)]
ctdb-tools: Move special case of 0 connections into computation

This avoids other potential users from unnecessarily setting up file
descriptors and such.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-tools: Rework killtcp logic into a tevent_req-based computation
Martin Schwenke [Fri, 30 Jun 2017 09:50:43 +0000 (19:50 +1000)]
ctdb-tools: Rework killtcp logic into a tevent_req-based computation

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-tools: New function ctdb_kill_tcp_init()
Martin Schwenke [Thu, 29 Jun 2017 06:35:06 +0000 (16:35 +1000)]
ctdb-tools: New function ctdb_kill_tcp_init()

This replaces ctdb_killtcp(), which did the initialisation inside a
loop.  The new logic is inverted, making it more natural.

The variable containing all the state is called "state" in
anticipation of the next commit that will convert this to a tevent_req
computation.  This will mean less churn.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-tools: Improve error handling
Martin Schwenke [Thu, 14 Sep 2017 05:19:43 +0000 (15:19 +1000)]
ctdb-tools: Improve error handling

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-tools: Drop global variable prog
Martin Schwenke [Fri, 30 Jun 2017 07:12:48 +0000 (17:12 +1000)]
ctdb-tools: Drop global variable prog

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-tools: Use db_hash in ctdb_killtcp
Martin Schwenke [Thu, 29 Jun 2017 05:57:19 +0000 (15:57 +1000)]
ctdb-tools: Use db_hash in ctdb_killtcp

One less use of trbt_tree_t.  The code is easier to read and is
significantly smaller.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-tools: Use ctdb_connection and ctdb_connection_list structs
Martin Schwenke [Thu, 29 Jun 2017 04:46:31 +0000 (14:46 +1000)]
ctdb-tools: Use ctdb_connection and ctdb_connection_list structs

Also use new connection and sock addr utilities.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Add ctdb_connection_list utilities
Martin Schwenke [Mon, 4 Sep 2017 07:01:05 +0000 (17:01 +1000)]
ctdb-protocol: Add ctdb_connection_list utilities

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Add marshalling for ctdb_connection_list
Martin Schwenke [Tue, 5 Sep 2017 00:52:58 +0000 (10:52 +1000)]
ctdb-protocol: Add marshalling for ctdb_connection_list

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Add new data structure ctdb_connection_list
Martin Schwenke [Mon, 4 Sep 2017 06:48:40 +0000 (16:48 +1000)]
ctdb-protocol: Add new data structure ctdb_connection_list

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Add ctdb_connection utilities
Martin Schwenke [Mon, 4 Sep 2017 06:41:30 +0000 (16:41 +1000)]
ctdb-protocol: Add ctdb_connection utilities

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Factor out static function ctdb_sock_addr_cmp_family()
Martin Schwenke [Wed, 13 Sep 2017 06:18:29 +0000 (16:18 +1000)]
ctdb-protocol: Factor out static function ctdb_sock_addr_cmp_family()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Add ctdb_sock_addr_from_string()
Martin Schwenke [Mon, 11 Sep 2017 06:39:38 +0000 (16:39 +1000)]
ctdb-protocol: Add ctdb_sock_addr_from_string()

This and the supporting functions duplicate functionality (parse_ip()
and parse_ip_port()) from common/system_util.c.  The old functions
will be removed at a later time.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Optionally print port for address printing functions
Martin Schwenke [Mon, 11 Sep 2017 05:00:10 +0000 (15:00 +1000)]
ctdb-protocol: Optionally print port for address printing functions

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Add utility function ctdb_sock_addr_to_buf()
Martin Schwenke [Fri, 30 Jun 2017 05:11:04 +0000 (15:11 +1000)]
ctdb-protocol: Add utility function ctdb_sock_addr_to_buf()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Add ctdb_sock_addr_port() and sock_addr_set_port()
Martin Schwenke [Fri, 2 Jun 2017 06:17:22 +0000 (16:17 +1000)]
ctdb-protocol: Add ctdb_sock_addr_port() and sock_addr_set_port()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-protocol: Add server and client aliases in ctdb_connection
Martin Schwenke [Mon, 4 Sep 2017 06:20:55 +0000 (16:20 +1000)]
ctdb-protocol: Add server and client aliases in ctdb_connection

The current code is ambiguous in its use of src and dst.  This allows
new code to use server and client for clarity.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
6 years agoctdb-common: Initialise socket addresses before reading into them
Martin Schwenke [Tue, 19 Sep 2017 04:54:26 +0000 (14:54 +1000)]
ctdb-common: Initialise socket addresses before reading into them

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-build: Split protocol-util as a separate subsystem
Martin Schwenke [Mon, 4 Sep 2017 06:00:48 +0000 (16:00 +1000)]
ctdb-build: Split protocol-util as a separate subsystem

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoctdb-build: Fix dependency for ctdbd
Martin Schwenke [Mon, 4 Sep 2017 06:00:27 +0000 (16:00 +1000)]
ctdb-build: Fix dependency for ctdbd

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agos4-torture: move lease break handler outside the lease testsuite.
Günther Deschner [Thu, 29 Sep 2016 06:41:01 +0000 (08:41 +0200)]
s4-torture: move lease break handler outside the lease testsuite.

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Pair-Programmed-With: Jose A. Rivera <jarrpa@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Sep 19 09:36:40 CEST 2017 on sn-devel-144

6 years agoselftest: Avoid a build started just before midnight failing
Martin Schwenke [Mon, 18 Sep 2017 22:33:11 +0000 (08:33 +1000)]
selftest: Avoid a build started just before midnight failing

It looks like commit 070f24bc9d2 was incomplete because it doesn't
match on the trailing fullstop and newline.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Sep 19 05:32:22 CEST 2017 on sn-devel-144

6 years agoRevert "ctdb-daemon: Don't explicitly stop monitoring during shutdown"
Martin Schwenke [Mon, 18 Sep 2017 06:36:32 +0000 (16:36 +1000)]
Revert "ctdb-daemon: Don't explicitly stop monitoring during shutdown"

This reverts commit 19318d28354190a9cfafa1696e41c90351f85af9.

With this commit, a shutdown that occurs while the startup event is
running can cause an abort because the startup callback will try to
decrease the run state from SHUTDOWN to RUNNING.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoRevert "ctdb-daemon: Remove unused function ctdb_stop_monitoring()"
Martin Schwenke [Mon, 18 Sep 2017 06:36:08 +0000 (16:36 +1000)]
Revert "ctdb-daemon: Remove unused function ctdb_stop_monitoring()"

This reverts commit b119104267635d96b1f99a2e98d35438841585bf.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
6 years agoselftest: Add some tests for linked attribute conflicts
Tim Beale [Wed, 23 Aug 2017 00:45:09 +0000 (12:45 +1200)]
selftest: Add some tests for linked attribute conflicts

Currently we have tests that check we can resolve object conflicts, but
these don't test anything related to conflicting linked attributes.
This patch adds some basic tests that checks that Samba can resolve
conflicting linked attributes.

This highlights some problems with Samba, as the following tests
currently fail:
- test_conflict_single_valued_link: Samba currently can't resolve a
  conflicting targets for a single-valued linked attribute - the
  replication exits with an error.
- test_link_deletion_conflict: If 2 DCs add the same linked attribute,
  currently when they resolve this conflict the RMD_VERSION for the
  linked attribute incorrectly gets incremented. This means the version
  numbers get out of step and subsequent changes to the linked attribute
  can be dropped/ignored.
- test_full_sync_link_conflict: fails for the same reason as above.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Autobuild-User(master): Garming Sam <garming@samba.org>
Autobuild-Date(master): Mon Sep 18 09:56:41 CEST 2017 on sn-devel-144

6 years agogetncchanges.c: max_links calculation didn't work well in some cases
Tim Beale [Tue, 15 Aug 2017 04:15:14 +0000 (16:15 +1200)]
getncchanges.c: max_links calculation didn't work well in some cases

The max_links calculation didn't work particularly well if max_links was
set to a value lower than max_objects.

As soon as repl_chunk->object_count exceeded repl_chunk->max_links, the
chunk would be deemed full, even if there was only one link to send (or
even worse, no links to send). For example, if max_objects=100 and
max_links=10, then it would send back chunks of 10 objects (or 9 objects
and 1 link).

I believe the historic reason this logic exists is to avoid overfilling
the response message. It's hard to tell what the appropriate limit would
be because the total message size would depend on how many attributes
each object has.

I couldn't think of logic that would be suitable for all cases. I toyed
with the idea of working out a percentage of how full the message is.
However, adjusting the max_links doesn't really make sense when the
settings are small enough, e.g. max_objects=100 and max_links=100 is
never going to overfill the message, so there's no reason to alter the
values.

In the end I went with:
- If the user is using non-default values, just use those.
- In the default value case, just use the historic calculation

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12972
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agoreplmd: Avoid duplicated debug/warnings
Tim Beale [Fri, 11 Aug 2017 03:39:35 +0000 (15:39 +1200)]
replmd: Avoid duplicated debug/warnings

We display warnings if a target object is missing but it's still OK to
continue the replication. Currently we need to check the target twice -
once to verify it when we first receive it, and once when we actually
commit it (we can't skip the 2nd check altogether because in the join
case, they could occur quite far apart).

One annoying side-effect is we get the same warning message coming out
twice in these special cases.

In the cases where we're checking the dsdb_repl_flags, we can actually
just bypass the verification checks for the target object (if it doesn't
exist we still continue anyway). This may save us a tiny bit of
unnecessary work.

For cross-partition links, we can limit logging these warnings to when
the objects are actually being committed. This avoids spurious warnings
in the join case (i.e. we receive the link before we receive the target
object's partition, but we have received all partitions by the time we
actually commit the objects).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12972
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agoreplmd: Allow missing targets if GET_TGT has already been set
Tim Beale [Fri, 11 Aug 2017 01:53:31 +0000 (13:53 +1200)]
replmd: Allow missing targets if GET_TGT has already been set

While running the selftests, I noticed a case where DC replication
unexpectedly sends a linked attribute for a deleted object (created in
the drs.ridalloc_exop tests). The problem is due to the
msDS-NC-Replica-Locations attribute, which is a (known) one-way link.
Because it is a one-way link, when the test demotes the DC and deletes
the link target, there is no backlink to delete the link from the source
object.

After much debate and head-scratching, we decided that there wasn't an
ideal way to resolve this problem. Any automated intervention could
potentially do the wrong thing, especially if the link spans partitions.
Running dbcheck will find this problem and is able to fix it (providing
the deleted object is still a tombstone). So the recommendation is to
run dbcheck on your DCs every 6 months (or more frequently if using a
lower tombstone lifetime setting).

However, it does highlight a problem with the current GET_TGT
implementation. If the tombstone object had been expunged and you
upgraded to 4.8, then you would be stuck - replication would fail
because the target object can't be resolved, even with GET_TGT, and
dbcheck would not be able to fix the hanging link. The solution is to
not fail the replication for an unknown target if GET_TGT has already
been set (i.e. the dsdb_repl_flags contains
DSDB_REPL_FLAG_TARGETS_UPTODATE).

It's debatable whether we should add a hanging link in this case or
ignore/drop the link. Some cases to consider:
- If you're talking to a DC that still sends all the links last, you
  could still get object deletion between processing the source object's
  links and sending the target (GET_TGT just restarts the replication
  cycle from scratch). Adding a hanging link in this case would be
  incorrect and would add spurious information to the DB.
- Suppose there's a bug in Samba that incorrectly results in an object
  disappearing. If other DCs then remove any links that pointed to that
  object, it makes recovering from the problem harder. However, simply
  ignoring the link shouldn't result in data loss, i.e. replication won't
  remove the existing link information from other DCs. Data loss in this
  case would only occur if a new DC were brought online, or if it were a
  new link that was affected.
Based on this, I think ignoring the link does the least harm.

This problem also highlights that we should really be using the same
logic in both the unknown target and the deleted target cases.
Combining the logic and moving it into a common
replmd_allow_missing_target() function fixes the problem. (This also has
the side-effect of fixing another logic flaw - in the deleted object
case we would unnecessarily retry with GET_TGT if the target object was
in another partition. This is pointless work, because GET_TGT won't
resolve the target).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12972
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetncchanges.c: Support GET_TGT better with large numbers of links
Tim Beale [Fri, 11 Aug 2017 04:08:15 +0000 (16:08 +1200)]
getncchanges.c: Support GET_TGT better with large numbers of links

A source object can potentially link to thousands of target objects.
We have to be careful not to overfill the GetNCChanges response message
with more data than it's possible to send. We also don't want the client
to timeout while we're busy checking the linked attributes. The GET_TGT
support added so far is fairly dumb - this patch extends it to better
handle larger numbers of links.

To do so, this extends the repl_chunk usage so that it also works out if
the current chunk is full of links. Now as soon as the chunk is full of
either links or objects, we stop and send it back.

These changes now mean that we need to also check:
- that all the links for the last source object in the previous chunk
  have been sent, before we move on and send the next object. This only
  takes effect when immediate_link_sync is configured. It also means
  that a chunk in the middle of the replication cycle can now contain
  only links, and no objects.
- when GET_TGT is used, we only send back the links that we've verified
  the target object for. i.e. if we stop checking links because we timed
  out, we only send back the links whose targets were checked.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetncchanges.c: Refactor to track more state using repl_chunk
Garming Sam [Tue, 8 Aug 2017 04:27:18 +0000 (16:27 +1200)]
getncchanges.c: Refactor to track more state using repl_chunk

To prepare GET_TGT to deal with a large number of links better, there
is now a 'repl_chunk' struct to help keep track of all the factors
relating to the current chunk of replication data (i.e. how many
objects/links we can send and how many we've already processed). This
means we can have a consistent way of working out whether the current
chunk is full (whether that be due to objects, links, or just too much
time taken).

This patch should not alter functionality. This is just a refactor to
add the basic framework, which will be used in the next patch.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agogetncchanges.py: Add a multi-valued linked attribute test
Tim Beale [Tue, 15 Aug 2017 00:18:02 +0000 (12:18 +1200)]
getncchanges.py: Add a multi-valued linked attribute test

Add a test where a source object links to multiple different targets.
First we do the replication without GET_TGT and check that the server
can handle sending a chunk containing only links (in the middle of the
replication). Then we repeat the replication forcing GET_TGT to be used.

To avoid having to create 1500 objects/links, I've lowered the 'max
link sync' setting on the vampire_dc testenv to 250.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetncchanges.py: Add a test for dropped cross-partition links
Tim Beale [Mon, 24 Jul 2017 02:43:54 +0000 (14:43 +1200)]
getncchanges.py: Add a test for dropped cross-partition links

Samba would drop linked attributes that span partitions if it didn't
know about the target object. This patch adds a test that exposes the
problem.

I've re-used the code from the previous re-animation test to do this.
I've also added a very basic DcConnection helper class that basically
stores the connection state information the drs_base.py uses for
replication. This allows us to switch the DC we want to replicate from
easily. This approach could potentially be retro-fitted to some of the
existing test cases, as it allows us to test both the DRS client code
and server code at the same time.

Note this test case relates to the code change for commit
fae5df891c11f642cb.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12972
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetncchanges.py: Add test for replicating reanimated objects
Tim Beale [Thu, 20 Jul 2017 05:06:14 +0000 (17:06 +1200)]
getncchanges.py: Add test for replicating reanimated objects

Reading between the lines, this scenario seems to be the main reason
that Microsoft added the GET_TGT flag. MS AD can handle getting links
for unknown targets OK, but if it receives links for a deleted/recycled
target then it would tend to drop the received links. Samba client also
used to drop the links if talking to a Microsoft DC (or a Samba server
with GET_TGT support).

The specific scenario is the client side already knows about a deleted
object. That object is then re-animated and used as the target for a
linked attribute. *Then* the target object gets updated again so it gets
sent in a later replication chunk to the linked attribute, i.e. the
client receives the link before it learns that the target object has
been re-animated.

In this test we're interested in particular at how the client behaves
when it receives a linked attribute for a deleted object. (It *should*
retry with GET_TGT to make sure the target is up-to-date. However, it
was just dropping the linked attribute).

To exercise the client-side, we disable replication, setup the
links/objects on one DC the way we want them, then force a replication
to the second DC. We then check that when we query each DC, they both
tell us about the links/objects we're expecting (i.e. no links got
lost).

Note that this wasn't a problem with older versions of Samba-to-Samba
because sending the links last guaranteed that the target objects were
always up-to-date.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agodrs: Add basic GET_TGT support
Tim Beale [Tue, 22 Aug 2017 22:23:10 +0000 (10:23 +1200)]
drs: Add basic GET_TGT support

This adds basic DRS_GET_TGT support. If the GET_TGT flag is specified
then the server will use the object cache to store the objects it sends
back. If the target object for a linked attribute is not in the cache
(i.e. it has not been sent already), then it is added to the response
message.

Note that large numbers of linked attributes will not be handled well
yet - the server could potentially try to send more than will fit in a
single repsonse message.

Also note that the client can sometimes set the GET_TGT flag even if the
server is still sending the links last. In this case, we know the client
supports GET_TGT so it's safe to send the links interleaved with the
source objects (the alternative of fetching the target objects but not
sending the links until last doesn't really make any sense).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetncchanges.py: Add tests for object deletion during replication
Tim Beale [Tue, 18 Jul 2017 23:38:55 +0000 (11:38 +1200)]
getncchanges.py: Add tests for object deletion during replication

Add tests that delete the source and target objects for linked
attributes in the middle of a replication cycle.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetnc_exop.py: Extend EXOP_REPL_OBJ test case to use GET_TGT
Tim Beale [Mon, 17 Jul 2017 02:04:38 +0000 (14:04 +1200)]
getnc_exop.py: Extend EXOP_REPL_OBJ test case to use GET_TGT

We already check that when we use GET_ANC that we still only receive a
single object when EXOP_REPL_OBJ is used. This extends the test to also
check that only a single object is returned when GET_TGT is used.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetncchanges.py: Add test for GET_ANC and GET_TGT combined
Tim Beale [Wed, 12 Jul 2017 23:47:16 +0000 (11:47 +1200)]
getncchanges.py: Add test for GET_ANC and GET_TGT combined

The code has to handle needing GET_ANC and GET_TGT in combination, i.e.
where we fetch the target object for the linked attribute and the target
object's parent is unknown as well. This patch adds a test case to
exercise this code path.

The second part of this test exercises GET_ANC/GET_TGT for an
incremental replication, where the objects are getting filtered by an
uptodateness-vector/HWM.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetncchanges.py: Add test for adding links during replication
Tim Beale [Tue, 13 Jun 2017 00:14:45 +0000 (12:14 +1200)]
getncchanges.py: Add test for adding links during replication

We have identified a case where the Samba server can send linked
attributes but not the target object. In this case, the Samba DRS client
would hit the "Failed to re-resolve GUID" case in replmd and silently
discard the linked attribute.

However, Samba will resend the linked attribute in the next cycle
(because its USN is still higher than the committed HWM), so it should
recover OK. On older releases, this may have caused problems if the
first error resulting in a hanging link (which might mean the second
time it's processed it still fails to be added).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetncchanges.py: Add some GET_TGT test cases
Tim Beale [Wed, 12 Jul 2017 02:23:35 +0000 (14:23 +1200)]
getncchanges.py: Add some GET_TGT test cases

test_repl_get_tgt:
- Adds 2 sets of objects
- Links one set to the other
- Changes the order so the target object comes last in the
  replication (which means the client has to use GET_TGT)
- Checks that when GET_TGT is used that we have received all target
  objects we need to resolve the linked attibutes
- Checks that we expect to receive the linked attributes *before*
  the last chunk is sent (by default, Samba sends all the links at
  the end, so this fails)
- Checks that we eventually receive all expected objects, and all
  links we receive match what is expected

test_repl_get_tgt_chain:
  This adds the linked attributes in a more complicated chain. We add
  300 objects, but the links for 100 objects will point to a linked
  chain of 200 objects.
  This was mainly to determine whether or not Windows follows the
  target object (i.e. whether it sends all the links for the target
  object as well). It turns out Windows maintains its own linked
  attribute DB, so it sends the links based on USN.

Note that the 2 testenvs fail for different reasons. promoted_dc fails
because it is sending all the linked attributes last. vampire_dc fails
because it doesn't support GET_TGT yet, so it sends the link before the
peer knows about the target object.

Note that to test against vampire_dc (rather than the ad_dc_ntvfs DC),
we need to send the GetNCChanges requests to DC2 instead of DC1.
I've left the DC numbering scheme as is, but I've addeed a test_ldb_dc
handle to drs_base.py - it defaults to DC1, but tests can override it
easily and still have everything work.

While running the new tests through autobuild, I noticed an intermittent
LDAP_ENTRY_ALREADY_EXISTS failure in the test setup(). This appears to
be due to a timing issue in the background replication between the
multiple testenvs. Adding some randomness so that the test base OU is
unique seems to avoid the problem.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agogetnc_exop.py: Fix GET_TGT behaviour in DRS tests
Tim Beale [Tue, 23 May 2017 02:37:56 +0000 (14:37 +1200)]
getnc_exop.py: Fix GET_TGT behaviour in DRS tests

The existing code never passed the more_flags parameter into the
actual getNCChanges request, i.e. _getnc_req10(). This meant the
existing GET_TGT tests effectively did nothing.

Passing the flag through properly means we have to now change the tests
as the DNs returned by Windows now include any target objects in the
linked attributes. These tests now fail against Samba (because it
doesn't support GET_TGT yet).

Also added comments to the tests to help explain what they are actually
doing.

Note that Samba and Windows can return the objects in different orders,
due to significant differences in their underlying DB implementations
(Windows stores links in a separate DB, so sends links ordered strictly
by USN, whereas Samba sends links based on the USN of the source
object). To make the test a fair comparison between Windows and Samba,
we need to use dn_ordered=False.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
6 years agos4/smbd: set the process group.
Gary Lockyer [Mon, 21 Aug 2017 03:12:04 +0000 (15:12 +1200)]
s4/smbd: set the process group.

Set the process group in the samba daemon, the --no-process-group option
allows this to be disabled.  The no-process-group option needs to be
disabled in self test.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Sep 18 04:39:50 CEST 2017 on sn-devel-144

6 years agowinbindd: Remove an obsolete comment
Volker Lendecke [Sun, 17 Sep 2017 17:40:00 +0000 (10:40 -0700)]
winbindd: Remove an obsolete comment

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): Sun Sep 17 23:35:51 CEST 2017 on sn-devel-144

6 years agoutil_runcmd: Free the fde in event handler.
Gary Lockyer [Fri, 8 Sep 2017 02:03:25 +0000 (14:03 +1200)]
util_runcmd: Free the fde in event handler.

Free the fde in the event handler to prevent the event triggering again
While not strictly necessary in this case, this code serves as an
example of the usage of tfork.

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sat Sep 16 23:50:27 CEST 2017 on sn-devel-144

6 years agolib/util: only close the event_fd in tfork if the caller didn't call tfork_event_fd()
Ralph Boehme [Sat, 16 Sep 2017 08:22:31 +0000 (01:22 -0700)]
lib/util: only close the event_fd in tfork if the caller didn't call tfork_event_fd()

Make closing of the event_fd the global responsibility of the
parent process if it called tfork_event_fd().

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
6 years agoutil/tfork: Write to the status pipe
Gary Lockyer [Sun, 10 Sep 2017 22:25:49 +0000 (10:25 +1200)]
util/tfork: Write to the status pipe

The previous design relied on only calling close() of the status pipe.

We now write a single 0 byte to the status FD as well as closing it in the
parent process.  Both of these operations typically trigger a read
event on the other end of the FD, held in the waiter process (the child).

The child process blocks on the status FD, until it becomes readable.

However if there is a sibling process that was launched after the waiter
process they also will hold the status FD open and the status FD would,
until this change, never become readable to the waiter process (the child).

This caused the waiter process (child) not to exit and the parent process
to hang in tfork_status() while expecting the waitpid() to return.

That is, file descriptors are essentially global variables copied
to children in the process tree.  The last child that (unwittingly) holds
the file descriptor open is the one that needs to trigger the close() this
code previously depended on.

Without this change, there is no notification of process death until
all these unrelated children exit for their own reasons.

We can write up to 4K (PIPE_BUF) into this pipe before blocking,
but we only write one byte.  Additionally sys_write() refuses to block.

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
6 years agotests util/tfork: Tests for status and event fd
Gary Lockyer [Mon, 11 Sep 2017 02:48:21 +0000 (14:48 +1200)]
tests util/tfork: Tests for status and event fd

Add tests to ensure that:
- The event_fd becomes readable once the worker process has terminated
- That the event_fd is not closed by the tfork code.
  - If this is done in tevent code and the event fde has not been
    freed, "Bad talloc magic value - " errors can result.
- That the status call does not block if the parent process launches
  more than one child process.
  - The status file descriptor for a child is passed to the
    subsequent children.  These processes hold the FD open, so that
    closing the fd does not make the read end go readable, and the
    process calling status blocks.

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
6 years agocli_credentials: Apply some const
Volker Lendecke [Thu, 7 Sep 2017 10:34:34 +0000 (12:34 +0200)]
cli_credentials: Apply some const

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Sat Sep 16 12:28:17 CEST 2017 on sn-devel-144

6 years agolibcli: Apply some const
Volker Lendecke [Thu, 7 Sep 2017 10:34:03 +0000 (12:34 +0200)]
libcli: Apply some const

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agonotifyd: Clarify a comment
Volker Lendecke [Wed, 6 Sep 2017 16:20:25 +0000 (18:20 +0200)]
notifyd: Clarify a comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agonetlogon_creds_cli: Use data_blob_cmp in netlogon_creds_cli_validate
Volker Lendecke [Mon, 21 Aug 2017 10:00:23 +0000 (12:00 +0200)]
netlogon_creds_cli: Use data_blob_cmp in netlogon_creds_cli_validate

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agonetlogon_creds_cli: Simplify netlogon_creds_cli_context_global
Volker Lendecke [Mon, 21 Aug 2017 09:54:29 +0000 (11:54 +0200)]
netlogon_creds_cli: Simplify netlogon_creds_cli_context_global

(require_sign_or_seal == false) looks odd :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agonetlogon_creds_cli: Simplify netlogon_creds_cli_context_common
Volker Lendecke [Mon, 21 Aug 2017 09:34:45 +0000 (11:34 +0200)]
netlogon_creds_cli: Simplify netlogon_creds_cli_context_common

IMHO a full talloc_stackframe is overkill for the one allocation that is left
here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agonetlogon_creds_cli: Simplify netlogon_creds_cli_context_common
Volker Lendecke [Mon, 21 Aug 2017 09:34:45 +0000 (11:34 +0200)]
netlogon_creds_cli: Simplify netlogon_creds_cli_context_common

printf knows to only print part of a string. No need to talloc_strdup.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agorpc_client3: Fix a debug message
Volker Lendecke [Tue, 5 Sep 2017 12:08:41 +0000 (14:08 +0200)]
rpc_client3: Fix a debug message

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agonetlogon_creds_cli: A netlogon_creds_cli_context needs a msg_ctx
Volker Lendecke [Tue, 5 Sep 2017 12:56:58 +0000 (14:56 +0200)]
netlogon_creds_cli: A netlogon_creds_cli_context needs a msg_ctx

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agonetlogon_creds_cli: Remove an obsolete comment
Volker Lendecke [Fri, 25 Aug 2017 09:39:16 +0000 (11:39 +0200)]
netlogon_creds_cli: Remove an obsolete comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
6 years agonetlogon_creds_cli: Avoid a static const struct
Volker Lendecke [Fri, 25 Aug 2017 09:27:30 +0000 (11:27 +0200)]
netlogon_creds_cli: Avoid a static const struct

Same number of .text bytes, but simpler code.

Yes, this is {{0}} instead of {0}, which I always promote. I've just read a
comment on stackoverflow (which I've unfortunately just closed the tab for :-()
that {{0}} might actually be the correct way to init a struct to zero if the
first struct element is again a struct. I'm lost. 25 years of C coding and I
have no clue of the language :-(

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>