amitay/samba.git
9 months agomdb_util: Better error message if lmdb-utils not installed
Tim Beale [Thu, 8 Nov 2018 23:17:40 +0000 (12:17 +1300)]
mdb_util: Better error message if lmdb-utils not installed

mdb_copy() was dutifully checking the PATH for the mdb_copy executable,
then, if it didn't find it, blindly proceeding anyway and trying to run
a non-existent executable. This resulted in a cryptic error:

  ERROR(<type 'exceptions.OSError'>): uncaught exception - [Errno 2] No
    such file or directory

Add in an extra check that we actually find the executable and raise a
better human-readable exception if we don't.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Nov  9 21:07:47 CET 2018 on sn-devel-144

9 months agoselftest: Fix backup testenv creation on certain host machines
Tim Beale [Thu, 8 Nov 2018 22:49:12 +0000 (11:49 +1300)]
selftest: Fix backup testenv creation on certain host machines

When we created the backup-file for the restoredc/renamedc/labdc
testenvs we weren't explicitly a --configfile on the samba-tool command.
This meant the command tried to use the smb.conf form the default
install location, i.e. /usr/local/samba/etc/smb.conf. On the gitlab CI
runner, there's no samba installed, so it ends up using the default
settings, which is fine. However, if the host machine had an invalid
smb.conf installed there, creating the testenv would fail with an error
like:

ERROR(runtime): uncaught exception - Unable to load default file
File "bin/python/samba/netcmd/__init__.py", line 184, in _run
return self.run(*args, **kwargs)
File "bin/python/samba/netcmd/domain_backup.py", line 222, in run
lp = sambaopts.get_loadparm()
  File "bin/python/samba/getopt.py", line 94, in get_loadparm
    self._lp.load_default()

We can avoid this by always explictly specifying the backupfromdc's
smb.conf when creating the backup file.

Likewise, labdc/customdc also need the config specified when the admin
password is reset.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
9 months agoselftest: Add README note: always use --configfile in testenv creation
Tim Beale [Thu, 8 Nov 2018 22:44:18 +0000 (11:44 +1300)]
selftest: Add README note: always use --configfile in testenv creation

We always need to specify "env->{CONFIGURATION}" when running a samba-tool
command to setup a testenv. Add a note to the README as this wasn't at
all clear.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
9 months agos4-kdc: restore MIT KDC backend
Philipp Gesang [Mon, 5 Nov 2018 14:54:35 +0000 (15:54 +0100)]
s4-kdc: restore MIT KDC backend

Fix fallout from the KDC prefork patchset (99aea42520fc..).

GCC warns when Samba is being built with --with-system-mitkrb5.
Fix this by adapting the signature of mitkdc_task_init() to match
task_init which has been extended to return a status code.

Status codes try to mimick those of kdc-heimdal.c:kdc_task_init()
as closely as possible.

Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
9 months agoselftest: Test hide new files timeout
Volker Lendecke [Thu, 8 Nov 2018 12:27:58 +0000 (13:27 +0100)]
selftest: Test hide new files timeout

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): Fri Nov  9 03:49:55 CET 2018 on sn-devel-144

9 months agosmbd: Add "hide new files" option
Volker Lendecke [Thu, 23 Aug 2018 11:51:26 +0000 (13:51 +0200)]
smbd: Add "hide new files" option

See the manpage for the description

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agodebug: Use debuglevel_(get|set) function
Andreas Schneider [Wed, 7 Nov 2018 13:14:05 +0000 (14:14 +0100)]
debug: Use debuglevel_(get|set) function

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Nov  8 11:03:11 CET 2018 on sn-devel-144

9 months agolib:util: Fix DEBUGCLASS pointer initializiation
Andreas Schneider [Wed, 7 Nov 2018 13:32:29 +0000 (14:32 +0100)]
lib:util: Fix DEBUGCLASS pointer initializiation

This fixes a segfault in pyglue:

==10142== Process terminating with default action of signal 11 (SIGSEGV)
==10142==  Bad permissions for mapped region at address 0x6F00A20
==10142==    at 0x6F1074B: py_set_debug_level (pyglue.c:165)

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agonsswitch:tests: Pass the envname to the script
Andreas Schneider [Wed, 7 Nov 2018 10:35:59 +0000 (11:35 +0100)]
nsswitch:tests: Pass the envname to the script

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agoWHATSNEW: NETLOGON prefork support
Gary Lockyer [Wed, 19 Sep 2018 03:04:35 +0000 (15:04 +1200)]
WHATSNEW: NETLOGON prefork support

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Nov  7 21:17:59 CET 2018 on sn-devel-144

9 months agosource4 smdb rpc_server: Support prefork process model.
Gary Lockyer [Wed, 29 Aug 2018 03:07:32 +0000 (15:07 +1200)]
source4 smdb rpc_server: Support prefork process model.

Allow the rpc_server to run in the prefork process model. Due to the use
of shared handles and resources all of the rpc end points are serviced
in the first worker process. Those end points that can be run in
multiple processes (currently only Netlogon and management) are serviced in
the first and any subsequent workers.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agosource4 smbd: pass instance number to post_fork
Gary Lockyer [Wed, 29 Aug 2018 01:16:08 +0000 (13:16 +1200)]
source4 smbd: pass instance number to post_fork

Pass the instance number to the post_fork hook. This is required to
allow the rpc_server to support the prefork process model.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agoWHATSNEW: 'prefork children' default
Gary Lockyer [Wed, 19 Sep 2018 03:13:49 +0000 (15:13 +1200)]
WHATSNEW: 'prefork children' default

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agosource4 smbd prefork: Increase default worklers to 4
Gary Lockyer [Wed, 5 Sep 2018 01:59:34 +0000 (13:59 +1200)]
source4 smbd prefork: Increase default worklers to 4

Increase the default number of worker processes started by the pre-fork
process model from 1 to 4.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agoautobuild: make ad_dc use prefork process model
Gary Lockyer [Tue, 28 Aug 2018 03:26:03 +0000 (15:26 +1200)]
autobuild: make ad_dc use prefork process model

Convert the ad_dc environment from single process model to the prefork
process model.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agotraffic_replay: Rework machine accounts to remove redundant code
Tim Beale [Mon, 5 Nov 2018 22:27:42 +0000 (11:27 +1300)]
traffic_replay: Rework machine accounts to remove redundant code

generate_users_and_groups() now generates the machine acounts as well as
the user accounts, so it seems there's no need to also have
generate_traffic_accounts(), which does the same job.

Instead, we can just pass through the number of machine acounts to
generate_users_and_groups() and delete the other function.

Also updated generate_users_and_groups() so that machine_accounts is
no longer optional (we want to create machine accounts in all cases).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agotraffic_replay: Make packet generation work on a pre-populated DB again
Tim Beale [Mon, 5 Nov 2018 22:14:41 +0000 (11:14 +1300)]
traffic_replay: Make packet generation work on a pre-populated DB again

Generate separate machine accounts for populating a large DB vs
replaying network traffic.

We want to use different userAccountControl flags in each of the above
cases (i.e. commit 3338a3e257fa9f28). However, this means that once you
use the --generate-users-only option, you can't replay network packets
against the machine accounts.

We can avoid this problem by creating separate machine accounts for each
of 2 different cases, e.g. STGM-0-x machines for traffic-replay, and
PC-0-x machines for padding out the database.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agotraffic_replay: Make sure naming assumptions are in a single place
Tim Beale [Mon, 5 Nov 2018 20:35:41 +0000 (09:35 +1300)]
traffic_replay: Make sure naming assumptions are in a single place

The traffic_replay group/user/machine account names follow a standard
format. This adds a function to generate the machine-name. It also makes
sure the existing user_name() function gets called in all applicable
places.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agotraffic_replay: Move 'traffic account' flag up a level
Tim Beale [Mon, 5 Nov 2018 21:58:56 +0000 (10:58 +1300)]
traffic_replay: Move 'traffic account' flag up a level

We create machine accounts for 2 different purposes:
1). For traffic generation, i.e. testing realistic network packets.
2). For generating a realistic large DB.

Unfortunately, we want to use different userAccountControl flags for
the 2 different cases. Commit 3338a3e257fa9f28 changed the flags used
for case #2, but this breaks case #1.

The problem is generate_users_and_groups() is called in both cases,
so we want the 'traffic account' flag passed into that function.
This ensures that the machine accounts get created with the appropriate
userAccountControl flags for the particular case you want to test.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agotraffic_replay: Move machine account creation
Tim Beale [Mon, 5 Nov 2018 21:52:38 +0000 (10:52 +1300)]
traffic_replay: Move machine account creation

I was assuming that generate_users_and_groups() only gets called in the
--generate-users-only case. However, it also gets called in the default
traffic replay case.

This patch reworks the code so that the number of machine accounts to
create gets passed in, and the 'create 25% more computers than users'
assumption only applies to the --generate-users-only case.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agosamba-tool gpo: convert pseudo-method into method
Douglas Bagnall [Tue, 6 Nov 2018 23:15:12 +0000 (12:15 +1300)]
samba-tool gpo: convert pseudo-method into method

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agosamba-tool gpo: add helper method for tmpdir construction
Douglas Bagnall [Tue, 6 Nov 2018 22:57:13 +0000 (11:57 +1300)]
samba-tool gpo: add helper method for tmpdir construction

A few of the gpo commands use an identical temporary directory structure
that can be constructed using shared code.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agosamba-tool gpo: do not use predictable temp directory
Douglas Bagnall [Tue, 6 Nov 2018 22:43:26 +0000 (11:43 +1300)]
samba-tool gpo: do not use predictable temp directory

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agopython/upgradehelpers: use mkstemp, not mktemp
Douglas Bagnall [Thu, 1 Nov 2018 20:02:15 +0000 (09:02 +1300)]
python/upgradehelpers: use mkstemp, not mktemp

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agoselftest: Add some more testenv descriptions
Tim Beale [Mon, 5 Nov 2018 01:45:34 +0000 (14:45 +1300)]
selftest: Add some more testenv descriptions

This still doesn't cover all the testenvs comprehensively, but it
pretty much exhausts my knowledge of what the various testenvs do.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Nov  7 04:39:05 CET 2018 on sn-devel-144

9 months agoselftest: Add README documenting the customdc testenv
Tim Beale [Mon, 5 Nov 2018 00:41:08 +0000 (13:41 +1300)]
selftest: Add README documenting the customdc testenv

Also documented the other backup/restore testenvs as well.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agotdb: Align integer types
Volker Lendecke [Sat, 3 Nov 2018 09:11:26 +0000 (10:11 +0100)]
tdb: Align integer types

tdb->max_dead_records is "int", as is the corresponding parameter to
tdb_set_max_dead(). Not that a signed variable makes any sense, but
this is old code and tdb_set_max_dead() is a public API which we
should not change for this.

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): Tue Nov  6 21:52:32 CET 2018 on sn-devel-144

9 months agogencache: Prune expired entries
Volker Lendecke [Wed, 24 Oct 2018 08:51:40 +0000 (10:51 +0200)]
gencache: Prune expired entries

This solves the problem that gencache never shrinks right
now. Whenever we write an entry, we now walk that entry's chain and
delete expired entries. This should be a good balance between
performance and cleanup actions: Reading is still unaffected, and
those who write pay a small penalty while keeping gencache size under
control.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agogencache: Wipe corrupt databases
Volker Lendecke [Fri, 2 Nov 2018 15:58:53 +0000 (16:58 +0100)]
gencache: Wipe corrupt databases

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agogencache: Remove transaction-based tdb
Volker Lendecke [Thu, 11 Oct 2018 10:52:40 +0000 (12:52 +0200)]
gencache: Remove transaction-based tdb

At more than one large site I've seen significant problems due to
gencache_stabilize. gencache_stabilize was mainly introduced to
survive machine crashes with the cache still being in place. Given
that most installations crash rarely and this is still a cache, this
safety is overkill and causes real problems.

With the recent changes to tdb, we should be safe enough to run on
completely corrupted databases and properly detect errors. A further
commit will introduce code that wipes the gencache.tdb if such a
corruption is detected.

There is one kind of corruption that we don't properly handle:
Orphaned space in the database. I don't have a good idea yet how to
handle this in a graceful and efficient way during normal operations,
but maybe this idea pops up at some point.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agogencache: Add crc check
Volker Lendecke [Wed, 10 Oct 2018 14:53:10 +0000 (16:53 +0200)]
gencache: Add crc check

This covers key, timestamp and data. This will detect silent
corruption of gencache data after a system crash

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agogencache: Convert to a binary timestamp
Volker Lendecke [Wed, 10 Oct 2018 14:12:28 +0000 (16:12 +0200)]
gencache: Convert to a binary timestamp

Two reasons:

The ascii conversion shows up on profiles.

In a further commit we will get checksums for gencache entries to
protect at hidden corruption due to a crash on the non-transactioned
gencache.tdb. Next to the timestamp this is a second field that is
gencache metadata, and I don't want to deal with a second ascii number
when at least some of the gencache values are binary already.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agotdb: Allow !CLEAR_IF_FIRST & MUTEX_LOCKING
Volker Lendecke [Mon, 22 Oct 2018 06:57:00 +0000 (08:57 +0200)]
tdb: Allow !CLEAR_IF_FIRST & MUTEX_LOCKING

This is a prerequisite to allow gencache to run on a non-transactioned
database with mutexes.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agotdb: Version 1.3.17 for tdb_traverse_chain
Volker Lendecke [Mon, 29 Oct 2018 06:43:43 +0000 (07:43 +0100)]
tdb: Version 1.3.17 for tdb_traverse_chain

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agotdb: Add test for tdb_traverse_chain
Volker Lendecke [Sun, 7 Oct 2018 20:03:09 +0000 (22:03 +0200)]
tdb: Add test for tdb_traverse_chain

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agotdb: Add tdb_traverse_chain
Volker Lendecke [Sun, 28 Oct 2018 08:06:39 +0000 (09:06 +0100)]
tdb: Add tdb_traverse_chain

This is a lightweight readonly traverse of a single chain, see the
comment in the header file.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
9 months agoctdb-daemon: Do not fork when CTDB_TEST_MODE is set
Martin Schwenke [Thu, 18 Oct 2018 07:02:13 +0000 (18:02 +1100)]
ctdb-daemon: Do not fork when CTDB_TEST_MODE is set

Explicitly background ctdbd instead.

This has the advantage of leaving stdin open.  ctdbd can then be
enhanced to exit when stdin closes, allowing better cleanup in a test
environment.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Tue Nov  6 10:30:14 CET 2018 on sn-devel-144

9 months agoctdb-daemon: Switch interactive variable to a bool
Martin Schwenke [Tue, 6 Nov 2018 03:06:14 +0000 (14:06 +1100)]
ctdb-daemon: Switch interactive variable to a bool

popt uses an int in place of a bool, so declare an extra int and make
the conversion explicit.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Add local_daemons.sh onnode and socket commands
Martin Schwenke [Fri, 12 Oct 2018 02:49:58 +0000 (13:49 +1100)]
ctdb-tests: Add local_daemons.sh onnode and socket commands

These aren't used by simple tests but they will be useful for
integrating ctdbd local daemons into other test suites and for
debugging.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Use local_daemons.sh in local_daemons.bash
Martin Schwenke [Thu, 11 Oct 2018 10:55:10 +0000 (21:55 +1100)]
ctdb-tests: Use local_daemons.sh in local_daemons.bash

The etc-ctdb/ subdirectory containing the event script moves into the
top-level tests/ directory because the subdirectory is really now
owned by local_daemons.sh instead of simple/.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Add local_daemons.sh
Martin Schwenke [Thu, 11 Oct 2018 08:32:09 +0000 (19:32 +1100)]
ctdb-tests: Add local_daemons.sh

This provides a separate script for handling local daemons.  It can be
used for testing outside of the CTDB simple test suite.  It is
installed as ctdb_local_daemons.

The logic is copied from ctdb/tests/simple/scripts/local_daemons.bash.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Allow use of setup_ctdb_base() outside of test cases
Martin Schwenke [Thu, 11 Oct 2018 09:23:07 +0000 (20:23 +1100)]
ctdb-tests: Allow use of setup_ctdb_base() outside of test cases

Always create an empty event script directory.  If $TEST_SUBDIR is
unset then don't use it to look for etc-ctdb/.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-build: Don't set unused variable TEST_BIN_DIR
Martin Schwenke [Tue, 9 Oct 2018 05:43:12 +0000 (16:43 +1100)]
ctdb-build: Don't set unused variable TEST_BIN_DIR

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Move setting of ctdb_dir and top_dir
Martin Schwenke [Tue, 9 Oct 2018 05:37:11 +0000 (16:37 +1100)]
ctdb-tests: Move setting of ctdb_dir and top_dir

These are only used in script_install_paths.sh.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Use $CTDB_SCRIPTS_TOOLS_BIN_DIR
Martin Schwenke [Tue, 9 Oct 2018 05:33:51 +0000 (16:33 +1100)]
ctdb-tests: Use $CTDB_SCRIPTS_TOOLS_BIN_DIR

Don't calculate this locally as _tools_dir.  Add it to PATH
unconditionally - this may result in duplicate entries in PATH but the
resulting code is simpler.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Use $CTDB_SCRIPTS_TESTS_BINDIR
Martin Schwenke [Tue, 9 Oct 2018 05:30:15 +0000 (16:30 +1100)]
ctdb-tests: Use $CTDB_SCRIPTS_TESTS_BINDIR

Don't calculate this locally as _test_bin_dir.  Just calculate
top_dir, source script_install_paths.sh and use
$CTDB_SCRIPT_TESTS_BINDIR.

Don't bother sanity checking if TEST_BIN_DIR is set.  It will go away
soon.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Add new variable CTDB_SCRIPTS_TESTS_BINDIR
Martin Schwenke [Tue, 9 Oct 2018 05:18:49 +0000 (16:18 +1100)]
ctdb-tests: Add new variable CTDB_SCRIPTS_TESTS_BINDIR

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Change all cluster setup to use ctdb_test_init()
Martin Schwenke [Mon, 8 Oct 2018 06:25:48 +0000 (17:25 +1100)]
ctdb-tests: Change all cluster setup to use ctdb_test_init()

ctdb_test_init() now passes any arguments to setup_ctdb().

Update tests that have custom local daemon configuration to call
ctdb_test_init() directly.  Remove the redundant, initial call to
ctdb_test_init() to avoid starting the cluster an extra time.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop passing of test arguments to ctdb_test_init()
Martin Schwenke [Mon, 8 Oct 2018 04:04:24 +0000 (15:04 +1100)]
ctdb-tests: Drop passing of test arguments to ctdb_test_init()

Arguments are currently ignored anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop ctdb_restart_when_done()
Martin Schwenke [Mon, 8 Oct 2018 02:51:01 +0000 (13:51 +1100)]
ctdb-tests: Drop ctdb_restart_when_done()

This no longer does anything.  Integration test cases now start and
shut down the cluster.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop dependency on variable ctdb_test_restart_scheduled
Martin Schwenke [Mon, 8 Oct 2018 02:53:16 +0000 (13:53 +1100)]
ctdb-tests: Drop dependency on variable ctdb_test_restart_scheduled

The remainder of the scheduled restart logic is about to be removed,
so produce debugging information any time the cluster is not healthy.

While here, reindent and drop the else since there is already an early
return before it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop tests that only start and stop daemons
Martin Schwenke [Mon, 8 Oct 2018 02:41:39 +0000 (13:41 +1100)]
ctdb-tests: Drop tests that only start and stop daemons

Integration test cases now start and shut down the cluster.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Move enabling of event scripts to setup_ctdb()
Martin Schwenke [Tue, 9 Oct 2018 04:09:38 +0000 (15:09 +1100)]
ctdb-tests: Move enabling of event scripts to setup_ctdb()

This is for the real cluster case.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Improve signal handling trap
Martin Schwenke [Mon, 8 Oct 2018 02:39:30 +0000 (13:39 +1100)]
ctdb-tests: Improve signal handling trap

Interrupting a test run currently moves on to the next test.  It
should exit.

Follow the practice of exiting with 128 + signal number.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop cleanup_handler()
Martin Schwenke [Mon, 8 Oct 2018 02:38:10 +0000 (13:38 +1100)]
ctdb-tests: Drop cleanup_handler()

Running testsuite-specific code here isn't a good option.

Daemons are now shut down in ctdb_test_exit(), even when testing is
interrupted.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Start daemons in ctdb_test_init(), stop them in ctdb_test_exit()
Martin Schwenke [Mon, 8 Oct 2018 02:30:55 +0000 (13:30 +1100)]
ctdb-tests: Start daemons in ctdb_test_init(), stop them in ctdb_test_exit()

This makes tests self-contained.  They can also now be individually
looped, if necessary.

Most tests (all but 1 complex, more than 50% of simple) restart the
daemons anyway, so this simplification is worth it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Ignore SIGPIPE during simple test cleanup
Martin Schwenke [Fri, 2 Nov 2018 05:21:26 +0000 (16:21 +1100)]
ctdb-tests: Ignore SIGPIPE during simple test cleanup

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop setting of unused variable scriptname
Martin Schwenke [Mon, 8 Oct 2018 02:55:08 +0000 (13:55 +1100)]
ctdb-tests: Drop setting of unused variable scriptname

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop use of confusing testfailures variable
Martin Schwenke [Mon, 8 Oct 2018 01:59:33 +0000 (12:59 +1100)]
ctdb-tests: Drop use of confusing testfailures variable

Exit on first test failure instead of setting a variable.  The bizarre
logic in ctdb_test_exit() makes this worth dropping.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop useless "ctdb version" test
Martin Schwenke [Mon, 8 Oct 2018 01:07:38 +0000 (12:07 +1100)]
ctdb-tests: Drop useless "ctdb version" test

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Rationalise tunable simple tests
Martin Schwenke [Mon, 8 Oct 2018 01:05:42 +0000 (12:05 +1100)]
ctdb-tests: Rationalise tunable simple tests

These 3 tests duplicate various checks and can easily be handled as a
single test.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Rationalise ctdb stop/continue/disable/enable simple tests
Martin Schwenke [Mon, 8 Oct 2018 00:33:08 +0000 (11:33 +1100)]
ctdb-tests: Rationalise ctdb stop/continue/disable/enable simple tests

The "continue" and "enable" tests are just extensions of the "stop"
and "disable" tests, so drop the latter 2.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Use wait_until_node_has_no_ips() in some tests
Martin Schwenke [Mon, 8 Oct 2018 00:13:15 +0000 (11:13 +1100)]
ctdb-tests: Use wait_until_node_has_no_ips() in some tests

This strengthens those tests to ensure that released IPs aren't
replaced with others.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Add function wait_until_node_has_no_ips()
Martin Schwenke [Mon, 8 Oct 2018 00:05:41 +0000 (11:05 +1100)]
ctdb-tests: Add function wait_until_node_has_no_ips()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agolib: ldb: Remove use of talloc_autofree_context().
Jeremy Allison [Tue, 6 Nov 2018 00:57:51 +0000 (16:57 -0800)]
lib: ldb: Remove use of talloc_autofree_context().

Just use NULL in test case. talloc_autofree_context() is deprecated.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agolib: talloc: Mark talloc_autofree_context() as deprecated.
Jeremy Allison [Tue, 6 Nov 2018 00:56:05 +0000 (16:56 -0800)]
lib: talloc: Mark talloc_autofree_context() as deprecated.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-event: Only run talloc report if CTDB_INTERACTIVE is set
Martin Schwenke [Fri, 19 Oct 2018 06:27:15 +0000 (17:27 +1100)]
ctdb-event: Only run talloc report if CTDB_INTERACTIVE is set

This is only really wanted for interactive testing when logging to
stderr.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-event: Never fork to become daemon in eventd
Martin Schwenke [Fri, 19 Oct 2018 05:18:13 +0000 (16:18 +1100)]
ctdb-event: Never fork to become daemon in eventd

This stops ctdbd from being able to shut down eventd, since the PID it
records will be invalid.  There's no need for eventd to fork.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-daemon: Improve documentation for -i option
Martin Schwenke [Thu, 18 Oct 2018 06:50:09 +0000 (17:50 +1100)]
ctdb-daemon: Improve documentation for -i option

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-daemon: Don't set log_to_stdout for become_daemon()
Martin Schwenke [Thu, 18 Oct 2018 06:47:55 +0000 (17:47 +1100)]
ctdb-daemon: Don't set log_to_stdout for become_daemon()

ctdbd logs to stderr in interactive mode, not stdout.  This way stdout
is always closed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-daemon: Avoid unnecessarily spamming the logs when in test mode
Martin Schwenke [Wed, 17 Oct 2018 10:24:07 +0000 (21:24 +1100)]
ctdb-daemon: Avoid unnecessarily spamming the logs when in test mode

Logging the logging location to syslog can be useful on production
systems when the configuration goes unexpectedly missing.  However, in
test mode this just adds noise to the logs on the test system.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tools: Detect unknown node number
Martin Schwenke [Fri, 12 Oct 2018 03:41:42 +0000 (14:41 +1100)]
ctdb-tools: Detect unknown node number

If there aren't enough addresses in the list then the shift will
silently fail and the printed address will be the unshifted value of
$1, which is incorrect/unexpected.  So, sanity check the node number.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: README updates
Martin Schwenke [Thu, 5 Jul 2018 09:04:37 +0000 (19:04 +1000)]
ctdb-tests: README updates

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Remove export of CTDB_SOCKET
Martin Schwenke [Thu, 10 May 2018 06:48:31 +0000 (16:48 +1000)]
ctdb-tests: Remove export of CTDB_SOCKET

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Use path_socket() in dummy client
Martin Schwenke [Tue, 28 Aug 2018 22:23:51 +0000 (08:23 +1000)]
ctdb-tests: Use path_socket() in dummy client

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop incorrect comment, unused function
Martin Schwenke [Fri, 11 May 2018 11:55:55 +0000 (21:55 +1000)]
ctdb-tests: Drop incorrect comment, unused function

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Drop setting of CTDB_SOCKET and CTDB_PIDFILE
Martin Schwenke [Thu, 10 May 2018 07:36:04 +0000 (17:36 +1000)]
ctdb-tests: Drop setting of CTDB_SOCKET and CTDB_PIDFILE

The local daemons ssh stub doesn't need to do this because the ctdbd
and the ctdb tool now only need CTDB_TEST_MODE and CTDB_BASE for local
daemon tests.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-daemon: Drop unused function ctdb_set_socketname()
Martin Schwenke [Thu, 10 May 2018 07:34:19 +0000 (17:34 +1000)]
ctdb-daemon: Drop unused function ctdb_set_socketname()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-daemon: Use path functions for socket and PID file
Martin Schwenke [Thu, 10 May 2018 07:32:33 +0000 (17:32 +1000)]
ctdb-daemon: Use path functions for socket and PID file

Drop the use of ctdb_set_sockname() because it complicates the memory
allocation and this is the only place it is used.  Just assign to the
relevant pointer.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Use path_socket() in test client tools
Martin Schwenke [Fri, 6 Jul 2018 05:30:31 +0000 (15:30 +1000)]
ctdb-tests: Use path_socket() in test client tools

Just leak the memory allocated by path_socket().  This is only used in
short-lived test programs, so it isn't worth the hassle of plumbing a
talloc context through several layers to get here.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tools: Use path_socket() in ctdb tool
Martin Schwenke [Thu, 10 May 2018 06:46:18 +0000 (16:46 +1000)]
ctdb-tools: Use path_socket() in ctdb tool

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Use ctdb-path for fake_ctdbd directory setup
Martin Schwenke [Thu, 10 May 2018 03:27:28 +0000 (13:27 +1000)]
ctdb-tests: Use ctdb-path for fake_ctdbd directory setup

This needs to be done before any of the code changes are made,
including updating the ctdb tool.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-tests: Use ctdb-path-like values for local daemons socket and PID file
Martin Schwenke [Fri, 20 Apr 2018 03:18:09 +0000 (13:18 +1000)]
ctdb-tests: Use ctdb-path-like values for local daemons socket and PID file

However, don't use ctdb-path itself because some tests use nested
instances of onnode.  The outermost instance would set CTDB_SOCKET and
any inner instance would pick up that value, regardless of CTDB_BASE.

This is a temporary measure to avoid breaking testing while use of the
path functions is added to ctdbd and the ctdb tool.  When this is
complete these variables can be removed altogether because the code
will just depend on CTDB_TEST_MODE and CTDB_BASE.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agoctdb-common: Allow path_socket() to use $CTDB_SOCKET
Martin Schwenke [Tue, 18 Sep 2018 06:19:40 +0000 (16:19 +1000)]
ctdb-common: Allow path_socket() to use $CTDB_SOCKET

Use of CTDB_SOCKET is being generally removed.  However, this override
is being added to allow test code outside of ctdb/ to be able to
specify the socket, if desired.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
9 months agodrs_utils: Avoid invalid dereference of v8 requests
Tim Beale [Mon, 5 Nov 2018 04:01:55 +0000 (17:01 +1300)]
drs_utils: Avoid invalid dereference of v8 requests

req.more_flags only exists for v10 requests, so we throw an exception if
we try to dereference that field on a v8 (or v5) request. Unfortunately,
we were checking that we support v10 *after* we had tried to access the
more_flags. This patch fixes up the order of the checks.

This may be a problem trying to replicate with an older Windows DC
(pre-2008R2), and was reported on the samba mailing-list at one point:
https://lists.samba.org/archive/samba/2018-June/216541.html

Unfortunately this patch doesn't help the overall situation at all (the
join will fail because we can't resolve the link target and we can't use
GET_TGT). But it now gives you a more meaningful error, i.e.

  ERROR(runtime): uncaught exception - (8639, "Failed to process 'chunk'
    of DRS replicated objects: DOS code 0x000021bf"
instead of:
  ERROR(<type 'exceptions.AttributeError'>): uncaught exception -
    'drsuapi.DsGetNCChangesRequest8' object has no attribute 'more_flags'

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Tim Beale <timbeale@samba.org>
Autobuild-Date(master): Tue Nov  6 07:15:33 CET 2018 on sn-devel-144

9 months agodrs_utils: Fix some long lines
Tim Beale [Mon, 5 Nov 2018 03:54:05 +0000 (16:54 +1300)]
drs_utils: Fix some long lines

Tweak the code slightly to avoid some 80+ character lines.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agolibnet: Reset debug counters after replicating critical objects
Tim Beale [Mon, 5 Nov 2018 03:34:15 +0000 (16:34 +1300)]
libnet: Reset debug counters after replicating critical objects

Reset the debug counters once we have finished replicating a given
partition. This helps if we replicate the same partition immediately
afterward with different options.

This helps the DC join debug look less weird. Because it replicates the
critical objects first, and then the base partition, previously it
always ended up overcounting, e.g.

Partition[DC=addom,DC=samba,DC=example,DC=com] objects[314/218]
  linked_values[48/24]

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agojoin: Fix join large-DB timeout against Windows
Tim Beale [Mon, 5 Nov 2018 01:30:14 +0000 (14:30 +1300)]
join: Fix join large-DB timeout against Windows

The LDAP connection can also timeout when trying to join a Windows DC
with a very large database. However, in this case Windows gives a
slightly different error message (NT_STATUS_CONNECTION_RESET instead of
NT_STATUS_CONNECTION_DISCONNECTED).

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
9 months agos4/selftest: enable samba.tests.samba_tool.gpo for PY3
Noel Power [Tue, 4 Sep 2018 19:33:35 +0000 (20:33 +0100)]
s4/selftest: enable samba.tests.samba_tool.gpo for PY3

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Nov  5 23:04:48 CET 2018 on sn-devel-144

9 months agopython/samba/gp_parse: PY2/PY3 Decode only when necessary
Noel Power [Wed, 5 Sep 2018 16:01:17 +0000 (17:01 +0100)]
python/samba/gp_parse: PY2/PY3 Decode only when necessary

In python2 we decode str types in load_xml, in python3 these are
str class(s) which we cannot decode.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samba/tests/samba_tool: PY2/PY3 compat port for test
Noel Power [Wed, 5 Sep 2018 15:14:32 +0000 (16:14 +0100)]
python/samba/tests/samba_tool: PY2/PY3 compat port for test

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samba/gp_parse: Fix mulitple encode step with write_section
Noel Power [Wed, 5 Sep 2018 14:23:01 +0000 (15:23 +0100)]
python/samba/gp_parse: Fix mulitple encode step with write_section

In python2 as far as I can see GptTmplInfParser.write_binary more
or less works by accident.

write_binary creates a writer for the 'utf8' codec, such a writer
should consume unicode and emit utf8 encoded bytes. This writer
is passed to each of the sections managed by GptTmplInfParser as
follows

    def write_binary(self, filename):
        with codecs.open(filename, 'wb+',
                         self.encoding) as f:
            for s in self.sections:
                self.sections[s].write_section(s, f)

And each section type itself is encoding its result to 'utf-16-le'
e.g.
    class UnicodeParam(AbstractParam):
         def write_section(self, header, fp):
            fp.write(u'[Unicode]\r\nUnicode=yes\r\n'.encode(self.encoding)

But this makes little sense, it seems like sections are encoded to one
encoding but the total file is supposed to be encoded as ut8??? Also
having an encoding per ParamType doesn't seem correct.

Bizarely in PY2 this works and it actually encodes the whole file as utf-16le
In PY3 you can't do this as the writer wants to deal with strings not bytes
(after the extra encode phase in 'write_section'.

So, changes here are to remove the unnecessary encoding in each 'write_section'
method, additionally in GptTmplInfParser.write_binary the
codecs.open call now uses the correct codec (e.g. 'utf-16-le') to write

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samba/netcmd: misc PY2/PY3 compat changes for gpo.py
Noel Power [Wed, 5 Sep 2018 13:54:24 +0000 (14:54 +0100)]
python/samba/netcmd: misc PY2/PY3 compat changes for gpo.py

Fixes:
1) various ldb.bytes that should be displayed as strings in PY3
2) sorting of lists of xml Element in PY3
3) various 'open' need to be opened in binary mode (to accept binary
   data)

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samab/gp_parse: remove unused code
Noel Power [Wed, 5 Sep 2018 13:39:11 +0000 (14:39 +0100)]
python/samab/gp_parse: remove unused code

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samba/gp_parse: Use csv.reader for parsing cvs files
Noel Power [Wed, 5 Sep 2018 13:18:16 +0000 (14:18 +0100)]
python/samba/gp_parse: Use csv.reader for parsing cvs files

The previous version here was using UnicodeReader which was
wrapping the UTF8Recoder class and passing that to csv.reader.
It looks like the intention was to read a bytestream in a
certain encoding and then reencode it to a different encoding.
And then UnicodeReader creates unicode from the newly encoded stream.
This is unnecssary, we know the encoding of the bytesstream and
codec.getreader will happily consume the bytstream and give back
unicode. The unicode can be fed directly into csv.writer.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samba/gp_parse: PY2/PY3 compat porting for gp_init.py
Noel Power [Wed, 5 Sep 2018 12:00:59 +0000 (13:00 +0100)]
python/samba/gp_parse: PY2/PY3 compat porting for gp_init.py

Fixes
1) use compat versions of ConfigParser and StringIO
2) fix sort list of XML Elements
3) open file needs to be opened in binary mode as write_pretty_xml
   routing uses BytesIO() object.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samba/gp_parse: PY3 open file non-binary mode for write_binary
Noel Power [Wed, 5 Sep 2018 11:52:30 +0000 (12:52 +0100)]
python/samba/gp_parse: PY3 open file non-binary mode for write_binary

Although this is unintuitive it's because we are writing unicode
not bytes (both in PY2 & PY3). using the 'b' mode causes an error in
PY3.

In PY3 we can define the encoding, but not in PY2.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samba/gp_parse: PY3 file -> open
Noel Power [Wed, 5 Sep 2018 11:46:44 +0000 (12:46 +0100)]
python/samba/gp_parse: PY3 file -> open

'file' no longer exists in PY3 replace with 'open'

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agopython/samba/gp_parse: PY2/PY3 compat changes for __init__.py
Noel Power [Wed, 5 Sep 2018 11:36:00 +0000 (12:36 +0100)]
python/samba/gp_parse: PY2/PY3 compat changes for __init__.py

Fixes.

1) sorting of xml.etree.ElementTree.Element, in PY2 sort
   seems to sort lists of these. In PY3 this no longer works.
   Choosing tag as the sort key for py3 so at least in python3
   there is a consistent sort (probably won't match how it is
   sorted in PY2 but nothing seems to depend on that)
2) md5 requires bytes
3) tostring returns bytes in PY3, adjust code for that

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
9 months agoctdb-recovery: Ban a node that causes recovery failure
Martin Schwenke [Mon, 29 Oct 2018 03:33:08 +0000 (14:33 +1100)]
ctdb-recovery: Ban a node that causes recovery failure

... instead of applying banning credits.

There have been a couple of cases where recovery repeatedly takes just
over 2 minutes to fail.  Therefore, banning credits expire between
failures and a continuously problematic node is never banned,
resulting in endless recoveries.  This is because it takes 2
applications of banning credits before a node is banned, which
generally involves 2 recovery failures.

The recovery helper makes up to 3 attempts to recover each database
during a single run.  If a node causes 3 failures then this is really
equivalent to 3 recovery failures in the model that existed before the
recovery helper added retries.  In that case the node would have been
banned after 2 failures.

So, instead of applying banning credits to the "most failing" node,
simply ban it directly from the recovery helper.

If multiple nodes are causing recovery failures then this can cause a
node to be banned more quickly than it might otherwise have been, even
pre-recovery-helper.  However, 90 seconds (i.e. 3 failures) is a long
time to be in recovery, so banning earlier seems like the best
approach.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Nov  5 06:52:33 CET 2018 on sn-devel-144