amitay/samba.git
3 years agoctdb-common: Avoid aliasing errors during code optimization checksum2
Amitay Isaacs [Mon, 27 Jul 2020 02:51:41 +0000 (12:51 +1000)]
ctdb-common: Avoid aliasing errors during code optimization

When this function gets inlined during optimization, the checksum is
calculated wrong due to aliasing.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
3 years agoWHATSNEW: Fix description of CTDB NAT gateway and LVS changes
Martin Schwenke [Sat, 25 Jul 2020 20:50:22 +0000 (06:50 +1000)]
WHATSNEW: Fix description of CTDB NAT gateway and LVS changes

Oops!  Using parentheses makes it harder to get this wrong.

Reported-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sun Jul 26 13:01:09 UTC 2020 on sn-devel-184

3 years agoWHATSNEW: Document CTDB NAT gateway and LVS changes
Martin Schwenke [Fri, 17 Jul 2020 10:38:12 +0000 (20:38 +1000)]
WHATSNEW: Document CTDB NAT gateway and LVS changes

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): Fri Jul 24 09:58:53 UTC 2020 on sn-devel-184

3 years agoctdb: Change LVS to use leader/follower
Martin Schwenke [Fri, 17 Jul 2020 10:46:07 +0000 (20:46 +1000)]
ctdb: Change LVS to use leader/follower

Instead of master/slave.

Nearly all of these are simple textual substitutions, which preserve
the case of the original.    A couple of minor cleanups were made in the
documentation (such as "LVSMASTER" -> "LVS leader").

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb: Change NAT gateway to use leader/follower
Martin Schwenke [Wed, 24 Jun 2020 01:20:24 +0000 (11:20 +1000)]
ctdb: Change NAT gateway to use leader/follower

Instead of master/slave.

Nearly all of these are simple textual substitutions, which preserve
the case of the original.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Simplify calculation of new flags
Martin Schwenke [Tue, 14 Jul 2020 04:29:09 +0000 (14:29 +1000)]
ctdb-recoverd: Simplify calculation of new flags

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

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Do not retrieve nodemap from recovery master
Martin Schwenke [Tue, 5 May 2020 13:49:05 +0000 (23:49 +1000)]
ctdb-recoverd: Do not retrieve nodemap from recovery master

It is already in rec->nodemap.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Flatten update_flags_on_all_nodes()
Martin Schwenke [Fri, 28 Sep 2018 00:46:17 +0000 (10:46 +1000)]
ctdb-recoverd: Flatten update_flags_on_all_nodes()

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

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

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Move ctdb_ctrl_modflags() to ctdb_recoverd.c
Martin Schwenke [Tue, 5 May 2020 13:37:57 +0000 (23:37 +1000)]
ctdb-recoverd: Move ctdb_ctrl_modflags() to ctdb_recoverd.c

This file is the only user of this function.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Improve a call to update_flags_on_all_nodes()
Martin Schwenke [Tue, 14 Jul 2020 04:43:04 +0000 (14:43 +1000)]
ctdb-recoverd: Improve a call to update_flags_on_all_nodes()

This should take a PNN, not an array index.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Use update_flags_on_all_nodes()
Martin Schwenke [Fri, 14 Jun 2019 21:20:19 +0000 (07:20 +1000)]
ctdb-recoverd: Use update_flags_on_all_nodes()

This is clearer than using the MODFLAGS control directly.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Introduce some local variables to improve readability
Martin Schwenke [Fri, 14 Jun 2019 21:19:26 +0000 (07:19 +1000)]
ctdb-recoverd: Introduce some local variables to improve readability

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Change update_flags_on_all_nodes() to take rec argument
Martin Schwenke [Tue, 5 May 2020 13:45:15 +0000 (23:45 +1000)]
ctdb-recoverd: Change update_flags_on_all_nodes() to take rec argument

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-recoverd: Drop unused nodemap argument from update_flags_on_all_nodes()
Martin Schwenke [Thu, 18 Jan 2018 09:25:07 +0000 (20:25 +1100)]
ctdb-recoverd: Drop unused nodemap argument from update_flags_on_all_nodes()

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Improve test portability/quality
Martin Schwenke [Thu, 5 Mar 2020 18:10:05 +0000 (05:10 +1100)]
ctdb-tests: Improve test portability/quality

Avoid use of non-portable md5sum by constructing database names using
index.  Improve indentation, use more modern commands, code
improvements (shellcheck).

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): Wed Jul 22 09:14:35 UTC 2020 on sn-devel-184

3 years agoctdb-tests: Improve test quality
Martin Schwenke [Thu, 5 Mar 2020 10:53:33 +0000 (21:53 +1100)]
ctdb-tests: Improve test quality

Simplify code, use more modern commands, code improvements (shellcheck).

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Improve test portability
Martin Schwenke [Thu, 5 Mar 2020 10:48:59 +0000 (21:48 +1100)]
ctdb-tests: Improve test portability

"wc -l" on some platforms (e.g. FreeBSD) contains leading spaces, so
strip them.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Improve test quality
Martin Schwenke [Thu, 5 Mar 2020 09:42:01 +0000 (20:42 +1100)]
ctdb-tests: Improve test quality

Select test node with IPs instead of using a fixed node.  Remove
unnecessary code, use more modern commands, code
improvements (shellcheck).

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Improve test portability
Martin Schwenke [Thu, 5 Mar 2020 09:21:26 +0000 (20:21 +1100)]
ctdb-tests: Improve test portability

"wc -l" on some platforms (e.g. FreeBSD) contains leading spaces and
stops "$num from being a number.  Create a more portable solution and
put it in a function instead of repeating the logic.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Drop uses of "onnode any ..." in testcases
Martin Schwenke [Tue, 10 Dec 2019 00:33:02 +0000 (11:33 +1100)]
ctdb-tests: Drop uses of "onnode any ..." in testcases

It would be nice to get rid of "onnode any".  There's no use making
tests nondeterministic.  If covering different cases matters then they
should be explicitly handled.

In most places "any" is replaced by "$test_node".  In some cases,
where $test_node is not set, a fixed node that is already used
elsewhere can be reused.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Don't bother shutting down daemons in ctdb_init()
Martin Schwenke [Tue, 10 Dec 2019 03:47:23 +0000 (14:47 +1100)]
ctdb-tests: Don't bother shutting down daemons in ctdb_init()

They'll never be up here...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Separate custom cluster startup from test initialisation
Martin Schwenke [Tue, 10 Dec 2019 03:44:45 +0000 (14:44 +1100)]
ctdb-tests: Separate custom cluster startup from test initialisation

Separate cluster startup from test initialisation for tests that start
the cluster with customised configuration.  In these cases the result
of the cluster startup is actually the point of the test.
Additionally, pubips.013.failover_noop.sh claims to have completed
test initialisation twice, which just seems wrong.

The result is:

* ctdb_test_init() takes one option (-n) to indicate when it should
  not configure/start the cluster

* New function ctdb_nodes_start_custom() accepts options for special
  cluster configuration, only operates on local daemons and triggers a
  test failure rather than a test error on failure.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Do not trigger ctdb_test_error() from ctdb_init()
Martin Schwenke [Mon, 6 Jul 2020 01:56:16 +0000 (11:56 +1000)]
ctdb-tests: Do not trigger ctdb_test_error() from ctdb_init()

The only caller calls ctdb_test_error() on failure and nesting this
calls can be confusing.  A future change will make this even more
confusing.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Make unit.sh pass shellcheck
Martin Schwenke [Thu, 30 Apr 2020 04:35:12 +0000 (14:35 +1000)]
ctdb-tests: Make unit.sh pass shellcheck

Mostly avoidance of quoting warnings.

Silencing warnings about unquoted $CTDB_TEST_CAT_RESULTS_OPTS is
handled by passing '-' to cat when that variable's value is empty.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Make integration.bash pass shellcheck
Martin Schwenke [Thu, 5 Mar 2020 18:58:26 +0000 (05:58 +1100)]
ctdb-tests: Make integration.bash pass shellcheck

Apart from the non-constant sourcing of include files.

Mostly avoidance of quoting warnings.

One subtle change is to simply pass "120" to wait_until_ready() to
stop warnings that it expects arguments but none are passed (both
SC2119 and SC2120).  There seems no way to indicate to structure
function argument handling so that shellcheck realises arguments are
optional.  In later shellcheck versions, disabling SC2120 for a
function also silences complaints about its callers... but not all of
our testing uses "later" shellcheck versions.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Use "#!/usr/bin/env bash" for improved portability
Martin Schwenke [Wed, 4 Mar 2020 02:55:07 +0000 (13:55 +1100)]
ctdb-tests: Use "#!/usr/bin/env bash" for improved portability

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Update preamble for INTEGRATION tests
Martin Schwenke [Tue, 10 Dec 2019 03:50:42 +0000 (14:50 +1100)]
ctdb-tests: Update preamble for INTEGRATION tests

* Use "#!/usr/bin/env bash" for improved portability

* Drop test_info() definition and replace it with a comment

  The use of test_info() is pointless.

* Drop call to cluster_is_healthy()

  This is a holdover from when the previous test would restart daemons
  to get things ready for a test.  There was also a bug where going
  into recovery during the restart would sometimes cause the cluster
  to become unhealthy.  If we really need something like this then we
  can add it to ctdb_test_init().

* Make order of preamble consistent

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Drop unreachable line
Martin Schwenke [Thu, 30 Apr 2020 04:14:43 +0000 (14:14 +1000)]
ctdb-tests: Drop unreachable line

ctdb_test_skip() will exit.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Redirect stderr too when checking for shellcheck
Martin Schwenke [Wed, 11 Mar 2020 05:33:27 +0000 (16:33 +1100)]
ctdb-tests: Redirect stderr too when checking for shellcheck

Avoid:

  .../UNIT/shellcheck/scripts/local.sh: line 14: type: shellcheck: not found

The "type" command in dash prints the "not found" message to stdout
but the bash version prints to stderr, so redirect stderr too.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Show hung script debugging output
Martin Schwenke [Tue, 21 Apr 2020 01:34:12 +0000 (11:34 +1000)]
ctdb-tests: Show hung script debugging output

The output in a test failure appears to contain no pstree output
because "00\.test\.script,.*" does not match.  However, this is just a
guess because the output is not shown.

Showing the output makes it easier to understand test failures.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Enable SOCKET_WRAPPER_DIR_ALLOW_ORIG
Martin Schwenke [Wed, 13 May 2020 04:04:36 +0000 (14:04 +1000)]
ctdb-tests: Enable SOCKET_WRAPPER_DIR_ALLOW_ORIG

This will allow local daemons to be used in more contexts, especially
in tests run by Jenkins where the directory names for some targets can
be very long.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-build: Don't build/install tests in top-level build by default
Martin Schwenke [Thu, 16 Feb 2017 08:23:44 +0000 (19:23 +1100)]
ctdb-build: Don't build/install tests in top-level build by default

The standalone build still includes tests, as does the top-level build
when --enable-selftest is used.  The latter is consistent with the use
of --enable-selftest in the rest of the tree.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Stop cat command failure from causing test failure
Martin Schwenke [Mon, 6 Jul 2020 04:02:49 +0000 (14:02 +1000)]
ctdb-tests: Stop cat command failure from causing test failure

In certain circumstance, which aren't obvious, cat(1) can fail when
attempting to write a lot of data.  This is due to something (probably
write(2)) returning EAGAIN.

Given that the -v option should only really be used for test
debugging, ignore the failure instead of spending time debugging it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14446
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-build: Don't build/install tests in top-level build by default"
Martin Schwenke [Wed, 22 Jul 2020 04:43:43 +0000 (14:43 +1000)]
Revert "ctdb-build: Don't build/install tests in top-level build by default"

Fix missing Reviewed-by: tag.

This reverts commit 91c36c16c8516359380a00ee3d2229422b048d9f.

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): Wed Jul 22 06:29:43 UTC 2020 on sn-devel-184

3 years agoRevert "ctdb-tests: Enable SOCKET_WRAPPER_DIR_ALLOW_ORIG"
Martin Schwenke [Wed, 22 Jul 2020 04:43:40 +0000 (14:43 +1000)]
Revert "ctdb-tests: Enable SOCKET_WRAPPER_DIR_ALLOW_ORIG"

Fix missing Reviewed-by: tag.

This reverts commit 9694ba6fe4d073c653f49080127ee9efa21a8e9e.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Show hung script debugging output"
Martin Schwenke [Wed, 22 Jul 2020 04:43:36 +0000 (14:43 +1000)]
Revert "ctdb-tests: Show hung script debugging output"

Fix missing Reviewed-by: tag.

This reverts commit c78de201f84f9fae9916af9592d42cbc71f805c5.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Redirect stderr too when checking for shellcheck"
Martin Schwenke [Wed, 22 Jul 2020 04:43:31 +0000 (14:43 +1000)]
Revert "ctdb-tests: Redirect stderr too when checking for shellcheck"

Fix missing Reviewed-by: tag.

This reverts commit 847aa0e367c721944650aa34d67f8073461ae272.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Drop unreachable line"
Martin Schwenke [Wed, 22 Jul 2020 04:43:28 +0000 (14:43 +1000)]
Revert "ctdb-tests: Drop unreachable line"

Fix missing Reviewed-by: tag.

This reverts commit a55dd6f17b6d65db77bcd4f5a011e9aef64729e5.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Update preamble for INTEGRATION tests"
Martin Schwenke [Wed, 22 Jul 2020 04:43:24 +0000 (14:43 +1000)]
Revert "ctdb-tests: Update preamble for INTEGRATION tests"

Fix missing Reviewed-by: tag.

This reverts commit 65f56505e29c01d5891e5bc1050b6c37b8cbdee7.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Use "#!/usr/bin/env bash" for improved portability"
Martin Schwenke [Wed, 22 Jul 2020 04:43:21 +0000 (14:43 +1000)]
Revert "ctdb-tests: Use "#!/usr/bin/env bash" for improved portability"

Fix missing Reviewed-by: tag.

This reverts commit 9a7cabd342d0aed450ed3305931702a7351f814a.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Make integration.bash pass shellcheck"
Martin Schwenke [Wed, 22 Jul 2020 04:43:18 +0000 (14:43 +1000)]
Revert "ctdb-tests: Make integration.bash pass shellcheck"

Fix missing Reviewed-by: tag.

This reverts commit 0f04b8a70be3b8e157a4a88e9e54e87fa380022e.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Make unit.sh pass shellcheck"
Martin Schwenke [Wed, 22 Jul 2020 04:43:11 +0000 (14:43 +1000)]
Revert "ctdb-tests: Make unit.sh pass shellcheck"

Fix missing Reviewed-by: tag.

This reverts commit 30293baae5f22628405d327fc0b6bae993e96cd8.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Do not trigger ctdb_test_error() from ctdb_init()"
Martin Schwenke [Wed, 22 Jul 2020 04:43:07 +0000 (14:43 +1000)]
Revert "ctdb-tests: Do not trigger ctdb_test_error() from ctdb_init()"

Fix missing Reviewed-by: tag.

This reverts commit 44e05ac8515be3220a334ae8001db83b06bec59f.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Separate custom cluster startup from test initialisation"
Martin Schwenke [Wed, 22 Jul 2020 04:43:04 +0000 (14:43 +1000)]
Revert "ctdb-tests: Separate custom cluster startup from test initialisation"

Fix missing Reviewed-by: tag.

This reverts commit e9df17b500146e62539feac66d0cd4b3ef7aa47a.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Don't bother shutting down daemons in ctdb_init()"
Martin Schwenke [Wed, 22 Jul 2020 04:43:01 +0000 (14:43 +1000)]
Revert "ctdb-tests: Don't bother shutting down daemons in ctdb_init()"

Fix missing Reviewed-by: tag.

This reverts commit 58f9f699f181ac217cda8de512b8385da173f884.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Drop uses of "onnode any ..." in testcases"
Martin Schwenke [Wed, 22 Jul 2020 04:42:57 +0000 (14:42 +1000)]
Revert "ctdb-tests: Drop uses of "onnode any ..." in testcases"

Fix missing Reviewed-by: tag.

This reverts commit aa5b214eaa88414c87410fd068fe7624e9790185.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Improve test portability"
Martin Schwenke [Wed, 22 Jul 2020 04:42:53 +0000 (14:42 +1000)]
Revert "ctdb-tests: Improve test portability"

Fix missing Reviewed-by: tag.

This reverts commit 1079d6e3ae5805ef65a3628edf0a3ac2cd7fac1c.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Improve test quality"
Martin Schwenke [Wed, 22 Jul 2020 04:42:49 +0000 (14:42 +1000)]
Revert "ctdb-tests: Improve test quality"

Fix missing Reviewed-by: tag.

This reverts commit ea1cbff624383fb9d5b83b863fa6bd00a8fb77fa.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Improve test portability"
Martin Schwenke [Wed, 22 Jul 2020 04:42:43 +0000 (14:42 +1000)]
Revert "ctdb-tests: Improve test portability"

Fix missing Reviewed-by: tag.

This reverts commit 1f6556916e7f3a731d7d760fa6fd857e7f571541.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Improve test quality"
Martin Schwenke [Wed, 22 Jul 2020 04:42:36 +0000 (14:42 +1000)]
Revert "ctdb-tests: Improve test quality"

Fix missing Reviewed-by: tag.

This reverts commit a308f2534d3991866efa2c662921ec63b4238888.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Improve test portability/quality"
Martin Schwenke [Wed, 22 Jul 2020 04:42:11 +0000 (14:42 +1000)]
Revert "ctdb-tests: Improve test portability/quality"

Fix missing Reviewed-by: tag.

This reverts commit d2f8cd835da39784f2d99231f9a1067ae56ede7a.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoRevert "ctdb-tests: Stop cat command failure from causing test failure"
Martin Schwenke [Wed, 22 Jul 2020 04:41:01 +0000 (14:41 +1000)]
Revert "ctdb-tests: Stop cat command failure from causing test failure"

Fix missing Reviewed-by: tag.

This reverts commit 5707781ccf682d95a5a05a7c3e00a43003dbe62e.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
3 years agoctdb-tests: Stop cat command failure from causing test failure
Martin Schwenke [Mon, 6 Jul 2020 04:02:49 +0000 (14:02 +1000)]
ctdb-tests: Stop cat command failure from causing test failure

In certain circumstance, which aren't obvious, cat(1) can fail when
attempting to write a lot of data.  This is due to something (probably
write(2)) returning EAGAIN.

Given that the -v option should only really be used for test
debugging, ignore the failure instead of spending time debugging it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14446
Signed-off-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Jul 22 04:10:47 UTC 2020 on sn-devel-184

3 years agoctdb-tests: Improve test portability/quality
Martin Schwenke [Thu, 5 Mar 2020 18:10:05 +0000 (05:10 +1100)]
ctdb-tests: Improve test portability/quality

Avoid use of non-portable md5sum by constructing database names using
index.  Improve indentation, use more modern commands, code
improvements (shellcheck).

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Improve test quality
Martin Schwenke [Thu, 5 Mar 2020 10:53:33 +0000 (21:53 +1100)]
ctdb-tests: Improve test quality

Simplify code, use more modern commands, code improvements (shellcheck).

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Improve test portability
Martin Schwenke [Thu, 5 Mar 2020 10:48:59 +0000 (21:48 +1100)]
ctdb-tests: Improve test portability

"wc -l" on some platforms (e.g. FreeBSD) contains leading spaces, so
strip them.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Improve test quality
Martin Schwenke [Thu, 5 Mar 2020 09:42:01 +0000 (20:42 +1100)]
ctdb-tests: Improve test quality

Select test node with IPs instead of using a fixed node.  Remove
unnecessary code, use more modern commands, code
improvements (shellcheck).

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Improve test portability
Martin Schwenke [Thu, 5 Mar 2020 09:21:26 +0000 (20:21 +1100)]
ctdb-tests: Improve test portability

"wc -l" on some platforms (e.g. FreeBSD) contains leading spaces and
stops "$num from being a number.  Create a more portable solution and
put it in a function instead of repeating the logic.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Drop uses of "onnode any ..." in testcases
Martin Schwenke [Tue, 10 Dec 2019 00:33:02 +0000 (11:33 +1100)]
ctdb-tests: Drop uses of "onnode any ..." in testcases

It would be nice to get rid of "onnode any".  There's no use making
tests nondeterministic.  If covering different cases matters then they
should be explicitly handled.

In most places "any" is replaced by "$test_node".  In some cases,
where $test_node is not set, a fixed node that is already used
elsewhere can be reused.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Don't bother shutting down daemons in ctdb_init()
Martin Schwenke [Tue, 10 Dec 2019 03:47:23 +0000 (14:47 +1100)]
ctdb-tests: Don't bother shutting down daemons in ctdb_init()

They'll never be up here...

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Separate custom cluster startup from test initialisation
Martin Schwenke [Tue, 10 Dec 2019 03:44:45 +0000 (14:44 +1100)]
ctdb-tests: Separate custom cluster startup from test initialisation

Separate cluster startup from test initialisation for tests that start
the cluster with customised configuration.  In these cases the result
of the cluster startup is actually the point of the test.
Additionally, pubips.013.failover_noop.sh claims to have completed
test initialisation twice, which just seems wrong.

The result is:

* ctdb_test_init() takes one option (-n) to indicate when it should
  not configure/start the cluster

* New function ctdb_nodes_start_custom() accepts options for special
  cluster configuration, only operates on local daemons and triggers a
  test failure rather than a test error on failure.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Do not trigger ctdb_test_error() from ctdb_init()
Martin Schwenke [Mon, 6 Jul 2020 01:56:16 +0000 (11:56 +1000)]
ctdb-tests: Do not trigger ctdb_test_error() from ctdb_init()

The only caller calls ctdb_test_error() on failure and nesting this
calls can be confusing.  A future change will make this even more
confusing.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Make unit.sh pass shellcheck
Martin Schwenke [Thu, 30 Apr 2020 04:35:12 +0000 (14:35 +1000)]
ctdb-tests: Make unit.sh pass shellcheck

Mostly avoidance of quoting warnings.

Silencing warnings about unquoted $CTDB_TEST_CAT_RESULTS_OPTS is
handled by passing '-' to cat when that variable's value is empty.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Make integration.bash pass shellcheck
Martin Schwenke [Thu, 5 Mar 2020 18:58:26 +0000 (05:58 +1100)]
ctdb-tests: Make integration.bash pass shellcheck

Apart from the non-constant sourcing of include files.

Mostly avoidance of quoting warnings.

One subtle change is to simply pass "120" to wait_until_ready() to
stop warnings that it expects arguments but none are passed (both
SC2119 and SC2120).  There seems no way to indicate to structure
function argument handling so that shellcheck realises arguments are
optional.  In later shellcheck versions, disabling SC2120 for a
function also silences complaints about its callers... but not all of
our testing uses "later" shellcheck versions.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Use "#!/usr/bin/env bash" for improved portability
Martin Schwenke [Wed, 4 Mar 2020 02:55:07 +0000 (13:55 +1100)]
ctdb-tests: Use "#!/usr/bin/env bash" for improved portability

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Update preamble for INTEGRATION tests
Martin Schwenke [Tue, 10 Dec 2019 03:50:42 +0000 (14:50 +1100)]
ctdb-tests: Update preamble for INTEGRATION tests

* Use "#!/usr/bin/env bash" for improved portability

* Drop test_info() definition and replace it with a comment

  The use of test_info() is pointless.

* Drop call to cluster_is_healthy()

  This is a holdover from when the previous test would restart daemons
  to get things ready for a test.  There was also a bug where going
  into recovery during the restart would sometimes cause the cluster
  to become unhealthy.  If we really need something like this then we
  can add it to ctdb_test_init().

* Make order of preamble consistent

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Drop unreachable line
Martin Schwenke [Thu, 30 Apr 2020 04:14:43 +0000 (14:14 +1000)]
ctdb-tests: Drop unreachable line

ctdb_test_skip() will exit.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Redirect stderr too when checking for shellcheck
Martin Schwenke [Wed, 11 Mar 2020 05:33:27 +0000 (16:33 +1100)]
ctdb-tests: Redirect stderr too when checking for shellcheck

Avoid:

  .../UNIT/shellcheck/scripts/local.sh: line 14: type: shellcheck: not found

The "type" command in dash prints the "not found" message to stdout
but the bash version prints to stderr, so redirect stderr too.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Show hung script debugging output
Martin Schwenke [Tue, 21 Apr 2020 01:34:12 +0000 (11:34 +1000)]
ctdb-tests: Show hung script debugging output

The output in a test failure appears to contain no pstree output
because "00\.test\.script,.*" does not match.  However, this is just a
guess because the output is not shown.

Showing the output makes it easier to understand test failures.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-tests: Enable SOCKET_WRAPPER_DIR_ALLOW_ORIG
Martin Schwenke [Wed, 13 May 2020 04:04:36 +0000 (14:04 +1000)]
ctdb-tests: Enable SOCKET_WRAPPER_DIR_ALLOW_ORIG

This will allow local daemons to be used in more contexts, especially
in tests run by Jenkins where the directory names for some targets can
be very long.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agoctdb-build: Don't build/install tests in top-level build by default
Martin Schwenke [Thu, 16 Feb 2017 08:23:44 +0000 (19:23 +1100)]
ctdb-build: Don't build/install tests in top-level build by default

The standalone build still includes tests, as does the top-level build
when --enable-selftest is used.  The latter is consistent with the use
of --enable-selftest in the rest of the tree.

Signed-off-by: Martin Schwenke <martin@meltin.net>
3 years agosmbd: build smb_fname per file to delete in unlink_internals()
Ralph Boehme [Fri, 19 Jun 2020 10:31:23 +0000 (12:31 +0200)]
smbd: build smb_fname per file to delete in unlink_internals()

Make sure to pass fresh smb_fname's to do_unlink(). Needed for path-ref fsps in
the future.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Jul 18 07:21:11 UTC 2020 on sn-devel-184

3 years agosmbd: consolidate fsp allocation for open_directory() and open_file_ntcreate()
Ralph Boehme [Fri, 19 Jun 2020 07:40:37 +0000 (09:40 +0200)]
smbd: consolidate fsp allocation for open_directory() and open_file_ntcreate()

...at one place in the caller create_file_unixpath().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: factor out fsp_bind_smb()
Ralph Boehme [Fri, 19 Jun 2020 05:31:51 +0000 (07:31 +0200)]
smbd: factor out fsp_bind_smb()

Needed for path-ref fsps in the future.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: don't mess with smb_dname->base_name in call_trans2findfirst()
Ralph Boehme [Thu, 18 Jun 2020 08:54:30 +0000 (10:54 +0200)]
smbd: don't mess with smb_dname->base_name in call_trans2findfirst()

Create a fresh name instead. Needed to proper support for path-ref fsps in the
future.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agos3/lib: fsp_str_dbg() doesn't show a possible stream name
Ralph Boehme [Tue, 23 Jun 2020 10:14:48 +0000 (12:14 +0200)]
s3/lib: fsp_str_dbg() doesn't show a possible stream name

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: use helper variable for fd in fd_open()
Ralph Boehme [Wed, 15 Jul 2020 10:04:10 +0000 (12:04 +0200)]
smbd: use helper variable for fd in fd_open()

No change in behaviour. Fwiw, no need to set fsp->fh->fd to -1 in the error case,
as that is initialized to -1 in fsp_new().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: remove errno saving from fd_open()
Ralph Boehme [Wed, 15 Jul 2020 10:01:18 +0000 (12:01 +0200)]
smbd: remove errno saving from fd_open()

This is not needed anymore since 97d061237b0f2e07ae9c8e893734e222e58cfa4e.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: remove a nested block in non_widelink_open()
Ralph Boehme [Thu, 2 Jul 2020 06:02:45 +0000 (08:02 +0200)]
smbd: remove a nested block in non_widelink_open()

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: use (global) POSIX pathname state in non_widelink_open()
Ralph Boehme [Thu, 2 Jul 2020 05:57:57 +0000 (07:57 +0200)]
smbd: use (global) POSIX pathname state in non_widelink_open()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: check for conn->cwd_fsp in fd_close()
Ralph Boehme [Sat, 13 Jun 2020 14:22:20 +0000 (16:22 +0200)]
smbd: check for conn->cwd_fsp in fd_close()

This avoids doing the check in all callers.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: check for conn->cwd_fsp in file_free()
Ralph Boehme [Sat, 13 Jun 2020 14:21:22 +0000 (16:21 +0200)]
smbd: check for conn->cwd_fsp in file_free()

This avoids doing the check in all callers.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: use a helper variable in open_file()
Ralph Boehme [Sun, 7 Jun 2020 14:42:50 +0000 (16:42 +0200)]
smbd: use a helper variable in open_file()

No change in behaviour, this just prepares for changes to come.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: remove unused NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE
Ralph Boehme [Mon, 8 Jun 2020 07:29:01 +0000 (09:29 +0200)]
smbd: remove unused NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE

The previous commit removed the only consumer of the flags.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: ensure we do a base open for internal stream deletes
Ralph Boehme [Mon, 8 Jun 2020 07:26:41 +0000 (09:26 +0200)]
smbd: ensure we do a base open for internal stream deletes

Otherwise we're not opening the basefile so fsp->base_fsp remains NULL for fsp
handles on streams. As there are some places that use the check (fsp->base_fsp
!= NULL) to check for stream handles, eg streams_xattr_fstat(), we must ensure
it is set otherwise we open a pretty big window for undefined behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agovfs_posixacl: Remove unnecessary call to acl_set_permset
Christof Schmitt [Tue, 7 Jul 2020 05:27:59 +0000 (22:27 -0700)]
vfs_posixacl: Remove unnecessary call to acl_set_permset

After the initial acl_get_permset, the permset is alreadying pointing to
the ACL entry and all changes are done on the ACL entry. There is no
need to overwrite the permissions in the ACL entry again with the same
value in the acl_set_permset call.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Christof Schmitt <cs@samba.org>
Autobuild-Date(master): Fri Jul 17 18:33:41 UTC 2020 on sn-devel-184

3 years agotest_vfs_posixacl: Add unit test for Linux POSIX ACL mapping
Christof Schmitt [Wed, 8 Jul 2020 03:02:42 +0000 (20:02 -0700)]
test_vfs_posixacl: Add unit test for Linux POSIX ACL mapping

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agopam_winbind: Fix CID 242274 Time of check time of use
Christof Schmitt [Thu, 9 Jul 2020 03:03:44 +0000 (20:03 -0700)]
pam_winbind: Fix CID 242274 Time of check time of use

Always issue the mkdir call to avoid the TOCTOU issue. Only if there is
already an object with the requested name, check whether it is a
directory.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agodocs: Fix documentation for require_membership_of of pam_winbind.conf
Andreas Schneider [Fri, 17 Jul 2020 10:14:16 +0000 (12:14 +0200)]
docs: Fix documentation for require_membership_of of pam_winbind.conf

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jul 17 13:07:44 UTC 2020 on sn-devel-184

3 years agopython: samba.compat rejects Python 2
Douglas Bagnall [Sat, 4 Jul 2020 01:30:28 +0000 (13:30 +1200)]
python: samba.compat rejects Python 2

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jul 17 08:39:38 UTC 2020 on sn-devel-184

3 years agopython: wrap 'import dckeytab' in an explanatory function
Douglas Bagnall [Sat, 4 Jul 2020 04:20:47 +0000 (16:20 +1200)]
python: wrap 'import dckeytab' in an explanatory function

The samba.dckeytab module has magic effects on samba.net, but never
appears to be used. That can be confusing, both to people and to
linters. Here we wrap that confusion up into a well-commented
function, so we never again have to wonder why the unused import is
there.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
3 years agopython/join: use the provided krbtgt link in cleanup_old_accounts
Douglas Bagnall [Thu, 11 Oct 2018 00:08:38 +0000 (13:08 +1300)]
python/join: use the provided krbtgt link in cleanup_old_accounts

Before we were putting it in an otherwise unused variable, and
deleting the previous krbtgt_dn, if any.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
3 years agopython/upgradehelpers: remove unused imports and variables
Douglas Bagnall [Thu, 11 Oct 2018 00:14:02 +0000 (13:14 +1300)]
python/upgradehelpers: remove unused imports and variables

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
3 years agosamba-tool ntacl: remove unused imports and variables
Douglas Bagnall [Wed, 10 Oct 2018 23:40:50 +0000 (12:40 +1300)]
samba-tool ntacl: remove unused imports and variables

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
3 years agos4/scripting/samba_dnsupdate: remove unreachable code
Douglas Bagnall [Thu, 11 Oct 2018 09:54:32 +0000 (22:54 +1300)]
s4/scripting/samba_dnsupdate: remove unreachable code

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
3 years agopython/ms_forest_updates_markdown: avoid implicit global variable
Douglas Bagnall [Sat, 27 Oct 2018 21:37:51 +0000 (10:37 +1300)]
python/ms_forest_updates_markdown: avoid implicit global variable

out_dict would have been shared across all calls, aggregating values as it went.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
3 years agodbcheck: omit unused argument in err_wrong_default_sd
Douglas Bagnall [Wed, 31 Oct 2018 20:46:46 +0000 (09:46 +1300)]
dbcheck: omit unused argument in err_wrong_default_sd

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
3 years agos4/torture: fix compilation in smb2/multichannel
Douglas Bagnall [Tue, 14 Jul 2020 10:49:51 +0000 (22:49 +1200)]
s4/torture: fix compilation in smb2/multichannel

GCC 9.3.0 doesn't like a true array being compared to NULL.

[3628/3972] Compiling source4/torture/smb2/multichannel.c
../../source4/torture/smb2/multichannel.c:1077:7: error: comparison of array 'trees2' equal to a null pointer is always false [-Werror,-Wtautological-pointer-compare]
                if (trees2 == NULL || trees2[i] == NULL) {
                    ^~~~~~    ~~~~
../../source4/torture/smb2/multichannel.c:1284:7: error: comparison of array 'trees2' equal to a null pointer is always false [-Werror,-Wtautological-pointer-compare]
                if (trees2 == NULL || trees2[i] == NULL) {
                    ^~~~~~    ~~~~
../../source4/torture/smb2/multichannel.c:2337:7: error: comparison of array 'trees2' equal to a null pointer is always false [-Werror,-Wtautological-pointer-compare]
                if (trees2 == NULL || trees2[i] == NULL) {
                    ^~~~~~    ~~~~
3 errors generated.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Jul 17 07:16:31 UTC 2020 on sn-devel-184

3 years agos4/torture/smb2/oplock: fix compilation by initialising variable
Douglas Bagnall [Tue, 14 Jul 2020 10:31:02 +0000 (22:31 +1200)]
s4/torture/smb2/oplock: fix compilation by initialising variable

With gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0:

../../source4/torture/smb2/oplock.c:2709:2: error: variable 'h2' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
        torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "Incorrect status");
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../lib/torture/torture.h:734:3: note: expanded from macro 'torture_assert_ntstatus_ok_goto'
                torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../lib/torture/torture.h:302:6: note: expanded from macro 'torture_assert_ntstatus_equal_goto'
        if (!NT_STATUS_EQUAL(__got, __expected)) { \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../source4/torture/smb2/oplock.c:2730:25: note: uninitialized use occurs here
        smb2_util_close(tree1, h2);
                               ^~
../../source4/torture/smb2/oplock.c:2709:2: note: remove the 'if' if its condition is always false
        torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "Incorrect status");
        ^
../../lib/torture/torture.h:734:3: note: expanded from macro 'torture_assert_ntstatus_ok_goto'
                torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt)
                ^
../../lib/torture/torture.h:302:2: note: expanded from macro 'torture_assert_ntstatus_equal_goto'
        if (!NT_STATUS_EQUAL(__got, __expected)) { \
        ^
../../source4/torture/smb2/oplock.c:2652:2: note: variable 'h2' is declared here
        struct smb2_handle h, h1, h2;
        ^
1 error generated.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Ralph Boehme <slow@samba.org>