]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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

5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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

5 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>
5 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>
5 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

5 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

5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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

5 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>
5 years agos3: libsmb: Namecache. Fix bug missed by me in previous cleanup.
Jeremy Allison [Thu, 16 Jul 2020 22:47:04 +0000 (15:47 -0700)] 
s3: libsmb: Namecache. Fix bug missed by me in previous cleanup.

In ipstr_list_make() we need to look at the correct array entry
to determine the ss_family for the sockaddr_storage.

Otherwise we are always storing the type of the first entry.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Jul 17 05:54:31 UTC 2020 on sn-devel-184

5 years agos3-libads: Pass timeout to open_socket_out in ms
Isaac Boukris [Tue, 14 Jul 2020 20:38:06 +0000 (22:38 +0200)] 
s3-libads: Pass timeout to open_socket_out in ms

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

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Jul 16 10:41:40 UTC 2020 on sn-devel-184

5 years agos3: libsmb: Cleanup - Make ipstr_list_make() talloc rather than malloc.
Jeremy Allison [Wed, 15 Jul 2020 22:02:02 +0000 (15:02 -0700)] 
s3: libsmb: Cleanup - Make ipstr_list_make() talloc rather than malloc.

Remove the excessive and unneeded ipstr_list_add() function,
fold it into ipstr_list_make() to make it much clearer what
we're doing.

The only use of MALLOC now is in ipstr_list_parse() returned
by namecache_fetch(). We need to fix the caller before
we can move that to talloc. As that is used inside internal_resolve_name()
which is designed to return a MALLOC'ed ip list from all
name resolution mechanisms leave that fix for another day.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jul 16 08:16:31 UTC 2020 on sn-devel-184

5 years agos3: libsmb: Cleanup - Move DEBUG -> DBG_XXX() macros.
Jeremy Allison [Wed, 15 Jul 2020 21:41:45 +0000 (14:41 -0700)] 
s3: libsmb: Cleanup - Move DEBUG -> DBG_XXX() macros.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: libsmb: Cleanup - make namecache_status_record_key() use talloc.
Jeremy Allison [Wed, 15 Jul 2020 21:38:23 +0000 (14:38 -0700)] 
s3: libsmb: Cleanup - make namecache_status_record_key() use talloc.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: libsmb: Cleanup - make namecache_key() use talloc.
Jeremy Allison [Wed, 15 Jul 2020 20:37:59 +0000 (13:37 -0700)] 
s3: libsmb: Cleanup - make namecache_key() use talloc.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: libsmb: Cleanup - namecache_store() - use common out.
Jeremy Allison [Wed, 15 Jul 2020 20:33:27 +0000 (13:33 -0700)] 
s3: libsmb: Cleanup - namecache_store() - use common out.

Prepare for moving malloc values to talloc.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: libsmb: Cleanup - namecache_store() initialize stack variables.
Jeremy Allison [Wed, 15 Jul 2020 20:31:38 +0000 (13:31 -0700)] 
s3: libsmb: Cleanup - namecache_store() initialize stack variables.

Preparing for common out: exit.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: libsmb: Cleanup - move talloc frame out of inner scope.
Jeremy Allison [Wed, 15 Jul 2020 20:28:33 +0000 (13:28 -0700)] 
s3: libsmb: Cleanup - move talloc frame out of inner scope.

Make it available thoughout the function. Prepare to use
talloc for namecache_key().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: libsmb: Cleanup modern coding standards. 'True/False' -> 'true/false'.
Jeremy Allison [Wed, 15 Jul 2020 19:12:23 +0000 (12:12 -0700)] 
s3: libsmb: Cleanup modern coding standards. 'True/False' -> 'true/false'.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: lib: Cleanup - make ipstr_list_make() and ipstr_list_parse() private to the only...
Jeremy Allison [Wed, 15 Jul 2020 18:58:45 +0000 (11:58 -0700)] 
s3: lib: Cleanup - make ipstr_list_make() and ipstr_list_parse() private to the only user.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: lib: Cleanup - nothing uses ipstr_list_free(). Remove it.
Jeremy Allison [Wed, 15 Jul 2020 18:48:30 +0000 (11:48 -0700)] 
s3: lib: Cleanup - nothing uses ipstr_list_free(). Remove it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: lib: Cleanup - all the ipstr_XXX() functions are only used in namecache.c.
Jeremy Allison [Wed, 15 Jul 2020 18:43:03 +0000 (11:43 -0700)] 
s3: lib: Cleanup - all the ipstr_XXX() functions are only used in namecache.c.

Move them there. Will remove from the global namespace next.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agoctdb-tools: Improve onnode's ShellCheck credibility
Martin Schwenke [Wed, 3 Jun 2020 23:59:59 +0000 (09:59 +1000)] 
ctdb-tools: Improve onnode's ShellCheck credibility

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): Thu Jul 16 06:51:47 UTC 2020 on sn-devel-184

5 years agoctdb-tools: Allow onnode -P to respect ONNODE_SSH
Martin Schwenke [Wed, 3 Jun 2020 23:58:41 +0000 (09:58 +1000)] 
ctdb-tools: Allow onnode -P to respect ONNODE_SSH

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
5 years agoctdb-tools: Whitespace fixups
Martin Schwenke [Wed, 3 Jun 2020 23:48:03 +0000 (09:48 +1000)] 
ctdb-tools: Whitespace fixups

Drop some unnecessary whitespace and re-indent push().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
5 years agoctdb-tools: Drop undocumented ONNODE_SSH_OPTS variable
Martin Schwenke [Wed, 3 Jun 2020 23:45:26 +0000 (09:45 +1000)] 
ctdb-tools: Drop undocumented ONNODE_SSH_OPTS variable

Options can be set in ONNODE_SSH, so this variable is unnecessary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
5 years agoutil: Fix a signed/unsigned comparison
Martin Schwenke [Thu, 7 May 2020 07:14:34 +0000 (17:14 +1000)] 
util: Fix a signed/unsigned comparison

[107/390] Compiling lib/util/time.c
../../../lib/util/time.c: In function ‘timespec_string_buf’:
../../../lib/util/time.c:416:10: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  416 |  if (len == -1) {
      |          ^~

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jul 16 04:00:52 UTC 2020 on sn-devel-184

5 years agotdb: Fix some signed/unsigned comparisons
Martin Schwenke [Thu, 7 May 2020 06:57:07 +0000 (16:57 +1000)] 
tdb: Fix some signed/unsigned comparisons

[207/389] Compiling lib/tdb/tools/tdbdump.c
../../../lib/tdb/tools/tdbrestore.c: In function ‘read_linehead’:
../../../lib/tdb/tools/tdbrestore.c:43:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
   43 |  for (i=0; i<sizeof(prefix); i++) {
      |             ^
../../../lib/tdb/tools/tdbrestore.c: In function ‘read_data’:
../../../lib/tdb/tools/tdbrestore.c:95:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
   95 |  for (i=0; i<size; i++) {
      |             ^

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agosmbd: Remove code inside #ifdef HAVE_BROKEN_READDIR_NAME
Christof Schmitt [Tue, 23 Jun 2020 18:55:05 +0000 (11:55 -0700)] 
smbd: Remove code inside #ifdef HAVE_BROKEN_READDIR_NAME

This is dead code, the define is never set.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agolib/util: Remove code inside #ifdef HAVE_BROKEN_READDIR_NAME
Christof Schmitt [Tue, 23 Jun 2020 18:51:41 +0000 (11:51 -0700)] 
lib/util: Remove code inside #ifdef HAVE_BROKEN_READDIR_NAME

This is dead code, the define is never set.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agolib/util: Remove code inside #ifdef NEXT2
Christof Schmitt [Tue, 23 Jun 2020 18:49:46 +0000 (11:49 -0700)] 
lib/util: Remove code inside #ifdef NEXT2

This is dead code, the define is never set.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos4:client: Remove code inside #ifdef NEXT2
Christof Schmitt [Tue, 23 Jun 2020 18:48:53 +0000 (11:48 -0700)] 
s4:client: Remove code inside #ifdef NEXT2

This is dead code, the define is never set.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agosmbd: Remove code inside #ifdef NEXT2
Christof Schmitt [Tue, 23 Jun 2020 18:46:38 +0000 (11:46 -0700)] 
smbd: Remove code inside #ifdef NEXT2

This is dead code, the define is never set.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3:smbd: stop accepting multichannel connections early in exit_server_common()
Stefan Metzmacher [Mon, 6 Jul 2020 14:51:05 +0000 (16:51 +0200)] 
s3:smbd: stop accepting multichannel connections early in exit_server_common()

This is just a step in the correct direction, but there's still a
possible race...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Tue Jul 14 14:59:19 UTC 2020 on sn-devel-184

5 years agos3:smbd: move exit_firsttime checking to the start of exit_server_common()
Stefan Metzmacher [Mon, 6 Jul 2020 14:42:46 +0000 (16:42 +0200)] 
s3:smbd: move exit_firsttime checking to the start of exit_server_common()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos4:torture/smb2: make smb2.durable-v2-delay tests more robust
Stefan Metzmacher [Sat, 4 Jul 2020 09:50:14 +0000 (11:50 +0200)] 
s4:torture/smb2: make smb2.durable-v2-delay tests more robust

We should not crash when the test fails, so we use a 2nd independent
connection to unlink the file at the end.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos4:torture/smb2: split replay_smb3_specification into durable handle and multichannel
Stefan Metzmacher [Fri, 3 Jul 2020 08:09:16 +0000 (10:09 +0200)] 
s4:torture/smb2: split replay_smb3_specification into durable handle and multichannel

It's better to have durable handles and multichannel tested separate:
1. we test both cases in the server
2. it makes it easier to deal with knownfail entries if only one
   of these features is active on the server.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3: lib: Fix missing TALLOC_FREE in error code path.
Jeremy Allison [Mon, 13 Jul 2020 17:08:47 +0000 (10:08 -0700)] 
s3: lib: Fix missing TALLOC_FREE in error code path.

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

Reported by Alexander Pyhalov <apyhalov@gmail.com>

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Jul 14 07:42:54 UTC 2020 on sn-devel-184

5 years agonet: ignore possible SIGPIPE upon ldap_unbind when over TLS
Isaac Boukris [Sat, 11 Jul 2020 03:04:59 +0000 (05:04 +0200)] 
net: ignore possible SIGPIPE upon ldap_unbind when over TLS

From local tests with strace:

socket(AF_UNIX, SOCK_STREAM, 0) = 12
write(2, "Connecting to 10.53.57.21 at por"..., 38) = 38
...
write(2, "ads_domain_func_level: 3\n", 25) = 25
write(12, "\27\3\3\0\37\0\0\0\0\0\0\0\16nl[\374\375i\325\334\25\227kxG@\326\311R\225x"..., 36) = 36
write(12, "\25\3\3\0\32\0\0\0\0\0\0\0\17Hh\304\254\244\17\342<\334\210L&\20_\177\307\232P", 31) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=12089, si_uid=1000} ---
+++ killed by SIGPIPE +++

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

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

5 years agoads: set sasl-wrapping to plain when over TLS
Isaac Boukris [Thu, 2 Jul 2020 07:33:12 +0000 (09:33 +0200)] 
ads: set sasl-wrapping to plain when over TLS

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

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agoFix ads_set_sasl_wrap_flags to only change sasl flags
Isaac Boukris [Thu, 2 Jul 2020 08:59:18 +0000 (10:59 +0200)] 
Fix ads_set_sasl_wrap_flags to only change sasl flags

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

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agoDecouple ldap-ssl-ads from ldap-ssl option
Isaac Boukris [Wed, 24 Jun 2020 12:28:45 +0000 (15:28 +0300)] 
Decouple ldap-ssl-ads from ldap-ssl option

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

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agoselftest: add tests for net-ads over TLS
Isaac Boukris [Mon, 29 Jun 2020 13:55:33 +0000 (16:55 +0300)] 
selftest: add tests for net-ads over TLS

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

Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
5 years agodocs: Fix documentation for require_membership_of of pam_winbind
Andreas Schneider [Thu, 9 Jul 2020 09:48:26 +0000 (11:48 +0200)] 
docs: Fix documentation for require_membership_of of pam_winbind

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jul 10 09:40:37 UTC 2020 on sn-devel-184

5 years agowinbind: Fix lookuprids cache problem
Volker Lendecke [Wed, 8 Jul 2020 13:09:45 +0000 (15:09 +0200)] 
winbind: Fix lookuprids cache problem

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14435
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jul  9 21:40:52 UTC 2020 on sn-devel-184

5 years agowinbind: Add test for lookuprids cache problem
Volker Lendecke [Wed, 8 Jul 2020 13:00:49 +0000 (15:00 +0200)] 
winbind: Add test for lookuprids cache problem

When reading entries from gencache, wb_cache_rids_to_names() can
return STATUS_SOME_UNMAPPED, which _wbint_LookupRids() does not handle
correctly.

This test enforces this situation by filling gencache with one wbinfo
-R and then erasing the winbindd_cache.tdb. This forces winbind to
enter the domain helper process, which will then read from gencache
filled with the previous wbinfo -R.

Without having the entries cached this does not happen because
wb_cache_rids_to_names() via the do_query: path calls deep inside
calls dcerpc_lsa_lookup_sids_noalloc(), which hides the
STATUS_SOME_UNMAPPED that came in as lsa_LookupSids result value.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14435
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotorture3: Align integer types
Volker Lendecke [Tue, 7 Jul 2020 06:50:31 +0000 (08:50 +0200)] 
torture3: Align integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agotorture3: Silence two signed/unsigned warnings
Volker Lendecke [Tue, 7 Jul 2020 06:48:58 +0000 (08:48 +0200)] 
torture3: Silence two signed/unsigned warnings

A longer fix would be to change the callbacks to use "int" instead of
"unsigned". Arguably that might be cleaner, but as this is torture
code I opted for the minimum necessary change.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agolibcli/ldap: Fix decoding struct ldap_ExtendedResponse
Volker Lendecke [Tue, 23 Jun 2020 17:09:28 +0000 (19:09 +0200)] 
libcli/ldap: Fix decoding struct ldap_ExtendedResponse

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
5 years agolibcli/ldap: Test decoding an exop response
Volker Lendecke [Tue, 23 Jun 2020 17:14:37 +0000 (19:14 +0200)] 
libcli/ldap: Test decoding an exop response

ldap-starttls-response.dat is a reply to a starttls extended
operation. Right now ldap_decode() does not handle this correctly.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
5 years agoWHATSNEW: Start release notes for Samba 4.14.0pre1.
Karolin Seeger [Thu, 9 Jul 2020 04:48:47 +0000 (06:48 +0200)] 
WHATSNEW: Start release notes for Samba 4.14.0pre1.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
Autobuild-User(master): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(master): Thu Jul  9 08:43:25 UTC 2020 on sn-devel-184

5 years agoVERSION: Bump version to 4.14.0pre1...
Karolin Seeger [Thu, 9 Jul 2020 04:46:58 +0000 (06:46 +0200)] 
VERSION: Bump version to 4.14.0pre1...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
5 years agoVERSION: Disable GIT_SNAPSHOT for the 4.13.0rc1 release. samba-4.13.0rc1
Karolin Seeger [Thu, 9 Jul 2020 04:44:53 +0000 (06:44 +0200)] 
VERSION: Disable GIT_SNAPSHOT for the 4.13.0rc1 release.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
5 years agoWHATSNEW: Add release notes for Samba 4.13.0rc1.
Karolin Seeger [Wed, 8 Jul 2020 11:36:43 +0000 (13:36 +0200)] 
WHATSNEW: Add release notes for Samba 4.13.0rc1.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
5 years agos3:smbd: skip ctdb public ips in fsctl_network_iface_info()
Stefan Metzmacher [Thu, 25 Jun 2020 13:32:11 +0000 (15:32 +0200)] 
s3:smbd: skip ctdb public ips in fsctl_network_iface_info()

Multi-Channel clients should not connect to ctdb public ip addresses
(which move between nodes).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jul  8 17:16:40 UTC 2020 on sn-devel-184

5 years agos3:smbd: disconnect the all client connections if a ctdb public ip dropped
Stefan Metzmacher [Thu, 25 Jun 2020 13:59:42 +0000 (15:59 +0200)] 
s3:smbd: disconnect the all client connections if a ctdb public ip dropped

For now we keep it simple and any disconnect on a connection that
used a ctdb public address, will disconnect all other remaining
connections.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:smbd: make smbXsrv_client_connection_pass_loop() more robust
Stefan Metzmacher [Fri, 3 Jul 2020 08:08:08 +0000 (10:08 +0200)] 
s3:smbd: make smbXsrv_client_connection_pass_loop() more robust

Don't leak fds in the error paths.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:smbd: make sure smbXsrv_connection_disconnect_transport() closes the socket fd
Stefan Metzmacher [Fri, 3 Jul 2020 07:55:57 +0000 (09:55 +0200)] 
s3:smbd: make sure smbXsrv_connection_disconnect_transport() closes the socket fd

I assumed that TALLOC_FREE(xconn->transport.fde) would close the socket,
but until now we didn't use tevent_fd_set_auto_close().

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:smbd: make sure we detect stale smbXsrv_connection pointers in smbXsrv_session_auth0
Stefan Metzmacher [Wed, 1 Jul 2020 16:02:16 +0000 (18:02 +0200)] 
s3:smbd: make sure we detect stale smbXsrv_connection pointers in smbXsrv_session_auth0

Pointer values can be reused (yes, I hit that during my testing!).
Introduce a channel_id to identify connections and also add
some timestamps to make debugging easier.

This makes smbXsrv_session_find_auth() much more robust.

This is a similar change as 0cec96526bf4d3209caf36c4a19632ff5d5dd112:
 "smb2_server: make sure we detect stale smbXsrv_connection pointers in smbXsrv_channel_global"

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:smbd: fill in xconn->client early in smbd_add_connection()
Stefan Metzmacher [Thu, 25 Jun 2020 20:45:07 +0000 (22:45 +0200)] 
s3:smbd: fill in xconn->client early in smbd_add_connection()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:smbd: handle NETWORK_ACCESS_DENIED in smbXsrv_client_connection_pass_loop()
Stefan Metzmacher [Thu, 25 Jun 2020 20:43:47 +0000 (22:43 +0200)] 
s3:smbd: handle NETWORK_ACCESS_DENIED in smbXsrv_client_connection_pass_loop()

smbd_add_connection() may return a valid connection together with
NT_STATUS_NETWORK_ACCESS_DENIED.

We need additional cleanup for that case.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:smbd: consistently use DLIST_ADD* to fill client->connections in smbd_add_connection()
Stefan Metzmacher [Thu, 25 Jun 2020 20:42:18 +0000 (22:42 +0200)] 
s3:smbd: consistently use DLIST_ADD* to fill client->connections in smbd_add_connection()

We should not just overwrite the client->connections pointer if we
reject the connection.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:ctdbd_conn: add ctdbd_control_get_public_ips() and ctdbd_find_in_public_ips()
Stefan Metzmacher [Thu, 25 Jun 2020 13:14:04 +0000 (15:14 +0200)] 
s3:ctdbd_conn: add ctdbd_control_get_public_ips() and ctdbd_find_in_public_ips()

These will be used in the multi channel code in order to handle
public ip addresses, which can move arround ctdb nodes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:ctdbd_conn: make use of samba_sockaddr in ctdbd_connect()
Stefan Metzmacher [Thu, 25 Jun 2020 13:11:44 +0000 (15:11 +0200)] 
s3:ctdbd_conn: make use of samba_sockaddr in ctdbd_connect()

This avoids compiler warnings like this:
dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing]

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
5 years agos3:ctdbd_conn: make use of ctdbd_control_local() in ctdbd_register_ips()
Stefan Metzmacher [Thu, 25 Jun 2020 12:00:27 +0000 (14:00 +0200)] 
s3:ctdbd_conn: make use of ctdbd_control_local() in ctdbd_register_ips()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>