]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
5 years agotstream_npa: Return named_pipe_auth_req_info4 from accept_existing
Volker Lendecke [Mon, 18 Jan 2021 16:30:42 +0000 (17:30 +0100)] 
tstream_npa: Return named_pipe_auth_req_info4 from accept_existing

Callers might want the full picture. We need to make
named_pipe_auth_req_info4 public for that.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agotstream_npa: Keep "named_pipe_auth_req" around in tstream_npa_accept_existing_send...
Volker Lendecke [Mon, 18 Jan 2021 15:54:07 +0000 (16:54 +0100)] 
tstream_npa: Keep "named_pipe_auth_req" around in tstream_npa_accept_existing_send()/recv()

This will make it simpler to return a copy of the struct
named_pipe_auth_req_info4 in the next commit.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agowbinfo: Allow SID for -R
Volker Lendecke [Tue, 23 Feb 2021 15:04:02 +0000 (16:04 +0100)] 
wbinfo: Allow SID for -R

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agodynconfig: Introduce and expose SAMBA_LIBEXECDIR
Volker Lendecke [Tue, 2 Feb 2021 15:50:48 +0000 (16:50 +0100)] 
dynconfig: Introduce and expose SAMBA_LIBEXECDIR

Right now the smbspool_krb5_wrapper lives there, but we'll have more
in the future.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosrv_winreg: Align integer types
Volker Lendecke [Sat, 27 Mar 2021 15:42:29 +0000 (16:42 +0100)] 
srv_winreg: Align integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: Align integer types
Volker Lendecke [Sat, 27 Mar 2021 15:42:52 +0000 (16:42 +0100)] 
printing: Align integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbd: Factor out a bool expr into a descriptive variable
Volker Lendecke [Fri, 26 Mar 2021 17:50:00 +0000 (18:50 +0100)] 
smbd: Factor out a bool expr into a descriptive variable

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agotest: Add a test for background_job_send crash
Volker Lendecke [Wed, 31 Mar 2021 11:22:16 +0000 (11:22 +0000)] 
test: Add a test for background_job_send crash

I haven't figured out how to properly add a crashing test to
"knownfail", so this is added after the fix.

Signed-off-by: Volker Lendecke <vl@samba.org>
5 years agolib: Fix rundown of jobs sent with background_job_send()
Volker Lendecke [Tue, 30 Mar 2021 15:18:10 +0000 (17:18 +0200)] 
lib: Fix rundown of jobs sent with background_job_send()

When using this with a trigger message in smbd it will crash at
rundown in messaging_deregister because the global messaging context
can be TALLOC_FREE'ed before the background job is freed.

Using messaging_filtered_send already takes care of this situation
properly.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agolib: Add required includes to source3/lib/background.h
Volker Lendecke [Wed, 31 Mar 2021 11:21:52 +0000 (11:21 +0000)] 
lib: Add required includes to source3/lib/background.h

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoasn1: Remove unused function asn1_check_enumerated()
Joseph Sutton [Thu, 18 Mar 2021 23:47:57 +0000 (12:47 +1300)] 
asn1: Remove unused function asn1_check_enumerated()

This function was reported as containing a bug, but it is unused and so
can be safely removed.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr  1 17:50:49 UTC 2021 on sn-devel-184

5 years agoselftest: Allow to set the 'log level' for clients
Andreas Schneider [Wed, 31 Mar 2021 13:24:20 +0000 (15:24 +0200)] 
selftest: Allow to set the 'log level' for clients

This allows to set the 'log level' for clients on the command line:

    make test TESTS=wurst CLIENT_LOG_LEVEL=10

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Mar 31 21:20:23 UTC 2021 on sn-devel-184

5 years agorpc_server3: Fix a memleak for internal pipes
Volker Lendecke [Tue, 23 Mar 2021 16:06:15 +0000 (17:06 +0100)] 
rpc_server3: Fix a memleak for internal pipes

state->call should not be talloc'ed off a long-lived context

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Mar 31 12:14:01 UTC 2021 on sn-devel-184

5 years agospools: avoid leaking memory into the callers mem_ctx
Ralph Boehme [Mon, 22 Mar 2021 11:06:39 +0000 (12:06 +0100)] 
spools: avoid leaking memory into the callers mem_ctx

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agopidl: set the per-request memory context in the pidl generator
Ralph Boehme [Tue, 23 Mar 2021 10:40:21 +0000 (11:40 +0100)] 
pidl: set the per-request memory context in the pidl generator

The talloc memory context referenced by the pipe_struct mem_ctx member is used
as talloc parent for RPC response data by the RPC service implementations.

In Samba versions up to 4.10 all talloc children of p->mem_ctx were freed after
a RPC response was delivered by calling talloc_free_children(p->mem_ctx). Commit
60fa8e255254d38e9443bf96f2c0f31430be6ab8 removed this call which resulted in all
memory allocations on this context not getting released, which can consume
significant memory in long running RPC connections.

Instead of putting the talloc_free_children(p->mem_ctx) back, just use the
mem_ctx argument of the ${pipename}_op_dispatch_internal() function which is a
dcesrv_call_state object created by dcesrv_process_ncacn_packet() and released
by the RPC server when the RPC request processing is finished.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
5 years agos3: smbd: fix deferred renames
Ralph Boehme [Mon, 29 Mar 2021 10:24:39 +0000 (12:24 +0200)] 
s3: smbd: fix deferred renames

This was broken by c7a9e0e4cdfb22e66533b5c8e20af3cfdb8ae78c.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14679
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1875

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@amba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Mar 31 06:13:39 UTC 2021 on sn-devel-184

5 years agos4: torture. Add smb2.lease.rename_wait test to reproduce regression in delay rename...
Jeremy Allison [Tue, 30 Mar 2021 22:05:47 +0000 (15:05 -0700)] 
s4: torture. Add smb2.lease.rename_wait test to reproduce regression in delay rename for lease break code.

Passes against Windows 10. Add to knownfail, the
next commit will fix this.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14679
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1875

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos3: smbd: Fix SMB_VFS_FGET_NT_ACL/SMB_VFS_FSET_NT_ACL on stream handles.
Jeremy Allison [Thu, 25 Mar 2021 22:46:45 +0000 (15:46 -0700)] 
s3: smbd: Fix SMB_VFS_FGET_NT_ACL/SMB_VFS_FSET_NT_ACL on stream handles.

As this is done on existing files, we know that
fsp->base_fsp != NULL and fsp->base_fsp->fh->fd != -1
(i.e. it's a pathref fd) for stream handles.

When getting and setting ACLs on stream handles,
use the fsp->base_fsp instead (as Windows does).

This not only fixes streams_xattr, but will
allow us to later analyze and remove all
special casing code for get/set ACLs on streams
handles.

Remove the knownfail.d/stream-acl file.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Mar 30 20:14:35 UTC 2021 on sn-devel-184

5 years agos3: torture: Add a test for setting and getting ACLs on stream handles (SMB2-STREAM...
Jeremy Allison [Thu, 25 Mar 2021 22:43:16 +0000 (15:43 -0700)] 
s3: torture: Add a test for setting and getting ACLs on stream handles (SMB2-STREAM-ACL).

It shows this isn't done correctly for streams_xattr.

A common config is:

vfs_objects = streams_xattr acl_xattr

to store both streams and Windows ACLs in xattrs.

Unfortunately getting and setting ACLs using handles
opened on stream files isn't being done correctly
in Samba.

This test passes against Windows 10.

This adds tests that prove this doesn't work. Next
patch will add the fix and remove the knownfail.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agoldb-samba: remove redundant negative check
Douglas Bagnall [Sun, 21 Mar 2021 07:49:32 +0000 (20:49 +1300)] 
ldb-samba: remove redundant negative check

smb_strtoull() already checks for negative numbers, but does
it properly, catching " -2" as well as "-2".

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Mar 30 18:55:28 UTC 2021 on sn-devel-184

5 years agoldb-samba: avoid VLA in dsdb match dns tombstone
Douglas Bagnall [Wed, 10 Mar 2021 03:23:07 +0000 (16:23 +1300)] 
ldb-samba: avoid VLA in dsdb match dns tombstone

We don't need it (only 64 bytes) and, well, they annoy people.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoldb-samba: avoid leak in dsdb_match_for_dns_to_tombstone_time
Douglas Bagnall [Wed, 10 Mar 2021 03:30:16 +0000 (16:30 +1300)] 
ldb-samba: avoid leak in dsdb_match_for_dns_to_tombstone_time

After the first time through the loop, tmp_ctx has been freed and
NULLed, so we end up allocating on NULL and never freeing.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos3:utils: The 'net ads keytab' commands should use machine credentials
Andreas Schneider [Mon, 29 Mar 2021 11:16:28 +0000 (13:16 +0200)] 
s3:utils: The 'net ads keytab' commands should use machine credentials

If the user doesn't specify a username/password on the command line, we
should use the machine credentials to connect to AD. This is how it is
used by default and we should be able to retrieve SPNs.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Mar 30 06:48:18 UTC 2021 on sn-devel-184

5 years agos3:utils: Use secrets_store_creds() in net utility
Andreas Schneider [Wed, 24 Mar 2021 09:08:04 +0000 (10:08 +0100)] 
s3:utils: Use secrets_store_creds() in net utility

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos3:passdb: Add secrets_store_creds()
Andreas Schneider [Wed, 24 Mar 2021 09:06:18 +0000 (10:06 +0100)] 
s3:passdb: Add secrets_store_creds()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos3:utils: Use libnetapi_set_creds() in net_dom
Andreas Schneider [Thu, 25 Mar 2021 10:39:22 +0000 (11:39 +0100)] 
s3:utils: Use libnetapi_set_creds() in net_dom

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos3:utils: Use libnetapi_set_creds() in net_rpc_shell
Andreas Schneider [Wed, 24 Mar 2021 13:37:26 +0000 (14:37 +0100)] 
s3:utils: Use libnetapi_set_creds() in net_rpc_shell

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos3:utils: Use libnetapi_set_creds() in net_rpc
Andreas Schneider [Thu, 25 Mar 2021 10:44:36 +0000 (11:44 +0100)] 
s3:utils: Use libnetapi_set_creds() in net_rpc

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos3:utils: Fix net_context_creds() with machine password
Andreas Schneider [Thu, 25 Mar 2021 11:03:22 +0000 (12:03 +0100)] 
s3:utils: Fix net_context_creds() with machine password

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agos3:libnetapi: Remove unused header file
Andreas Schneider [Fri, 26 Mar 2021 08:56:11 +0000 (09:56 +0100)] 
s3:libnetapi: Remove unused header file

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
5 years agorpc/idl dnsserver s/DNS_RPC_DATA/DNS_RPC_RECORD_DATA/
Douglas Bagnall [Wed, 24 Mar 2021 00:36:18 +0000 (13:36 +1300)] 
rpc/idl dnsserver s/DNS_RPC_DATA/DNS_RPC_RECORD_DATA/

Following MS-DNSP.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Mar 30 00:20:53 UTC 2021 on sn-devel-184

5 years agolibrpc/idl: dnsp tombstone timestamp name matches MS-DNSP
Douglas Bagnall [Tue, 23 Mar 2021 23:49:22 +0000 (12:49 +1300)] 
librpc/idl: dnsp tombstone timestamp name matches MS-DNSP

MS-DNSP uses the term "EntombedTime" in e.g. "2.2.2.2.4.23 DNS_RPC_RECORD_TS"
which is more descriptive than the generic "timestamp", and less likely to be
confused with dwTimestamp, which has been our curse. Let's make it grep-able,
google-able, and evocative.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopytest/dnsserver: extend record_type_int to all types
Douglas Bagnall [Thu, 25 Mar 2021 04:47:04 +0000 (17:47 +1300)] 
pytest/dnsserver: extend record_type_int to all types

with improved diagnostics on bad arguments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopytest/dns: use self.assertIn() and .assertNotIn()
Douglas Bagnall [Wed, 24 Mar 2021 02:16:21 +0000 (15:16 +1300)] 
pytest/dns: use self.assertIn() and .assertNotIn()

These give a more detailed message than assertTrue(x in y).

They were new in Python 3.1, so we avoided them until recently.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopytest/dns: remove redundant argument
Douglas Bagnall [Wed, 24 Mar 2021 01:57:32 +0000 (14:57 +1300)] 
pytest/dns: remove redundant argument

We are always setting zone to the same thing which we already know,
and we can reduce cognative stress by mentioning it less and not doing
that weird pop thing.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agodsdb/dns scavange: make a helper function static
Douglas Bagnall [Sat, 27 Mar 2021 22:20:25 +0000 (11:20 +1300)] 
dsdb/dns scavange: make a helper function static

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agodsdb/scavange dns: reserve NTTIME type for NTTIME values
Douglas Bagnall [Sat, 27 Mar 2021 22:20:48 +0000 (11:20 +1300)] 
dsdb/scavange dns: reserve NTTIME type for NTTIME values

We know it "really" just means uint64_t, but we also know it means
100-nanosecond intervals since 1601, and that makes any other use very
confusing (and not just to me, or there wouldn't be these bugs we're
chasing).

In these cases we are talking about 32 bit hours-since-1601 timestamps.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agodns: use unix_to_dns_timestamp almost everywhere
Douglas Bagnall [Thu, 11 Mar 2021 02:58:37 +0000 (15:58 +1300)] 
dns: use unix_to_dns_timestamp almost everywhere

In places we change NTTIME to uint32_t, because that is what is
actually wanted.

There is one instance of the calculation that we are not changing,
because there are other problems there.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agopydns: expose dns timestamp utils to python, and test
Douglas Bagnall [Sat, 27 Mar 2021 09:09:56 +0000 (09:09 +0000)] 
pydns: expose dns timestamp utils to python, and test

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agodns: add common dns_timestamp util functions
Douglas Bagnall [Thu, 11 Mar 2021 02:17:28 +0000 (15:17 +1300)] 
dns: add common dns_timestamp util functions

The dns structs have an unsigned 32 bit timestamp in hours since the
beginning of 1601. In a number of places we need to convert from unix
time to this timestamp, or from the timestamp to NTTIME.

You'll see subsequent patches that make use of these functions.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agodns common: always check a talloc NULL.
Douglas Bagnall [Wed, 24 Mar 2021 04:38:15 +0000 (17:38 +1300)] 
dns common: always check a talloc NULL.

Also, since we're there, avoid sorting an array of 1 element.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agolibcli smb smb2: Use correct enumeration type
Gary Lockyer [Thu, 25 Mar 2021 01:36:50 +0000 (14:36 +1300)] 
libcli smb smb2: Use correct enumeration type

Clang gives the following error:
../../libcli/smb/smb2_signing.c:547:48: error:
   implicit conversion from enumeration type 'gnutls_mac_algorithm_t'
   to different enumeration type 'gnutls_digest_algorithm_t'
   [-Werror,-Wenum-conversion]
   const size_t digest_len = gnutls_hash_get_len(GNUTLS_MAC_SHA256);
~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~

Should be using GNUTLS_DIG_SHA256, which is set to GNUTLS_MAC_SHA256.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Mon Mar 29 23:19:24 UTC 2021 on sn-devel-184

5 years agosmb2_tcon: also try to cancel pending compound requests on tdis
Stefan Metzmacher [Tue, 23 Mar 2021 10:10:22 +0000 (11:10 +0100)] 
smb2_tcon: also try to cancel pending compound requests on tdis

There's no reason to do something special here.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Mar 29 20:43:28 UTC 2021 on sn-devel-184

5 years agosmbXsrv_session: always cancel pending requests in smb2srv_session_shutdown_send...
Stefan Metzmacher [Thu, 11 Mar 2021 16:04:37 +0000 (17:04 +0100)] 
smbXsrv_session: always cancel pending requests in smb2srv_session_shutdown_send() in the same way

The session is valid for the lifetime of the requests anyway
and there's no point in having special handling for compound requests.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmb2_server: don't cancel pending request if at least one channel is still alive
Stefan Metzmacher [Wed, 24 Feb 2021 16:44:12 +0000 (17:44 +0100)] 
smb2_server: don't cancel pending request if at least one channel is still alive

In order to allow replays of requests on a channel failure, we should
not cancel pending requests, the strategie that seems to make windows
clients happy is to let the requests running and return
NT_STATUS_FILE_NOT_AVAILABLE as long as the original request is still
pending.

Here we introduce xconn->transport.shutdown_wait_queue, this is used
to keep the xconn alive for the lifetime of pending requests.

Now we only cancel pending requests if the disconnected connection
is the last channel for a session.

In that case smbXsrv_session_remove_channel() and
smb2srv_session_shutdown_send() will take care of it.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmb2_server: let smbd_smb2_flush_send_queue() destroy pending elements on dead connection
Stefan Metzmacher [Fri, 12 Mar 2021 17:34:06 +0000 (18:34 +0100)] 
smb2_server: let smbd_smb2_flush_send_queue() destroy pending elements on dead connection

Otherwise we'll keep the state of already finished requests arround.

This becomes critical as the next commit will cause us to
let pending requests running and keep the xconn alive for
the lifetime of pending requests, so we would not ever
make progress and deadlock.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbXsrv_open: intruduce smbXsrv_open_replay_cache to support FILE_NOT_AVAILABLE
Stefan Metzmacher [Fri, 12 Mar 2021 14:10:46 +0000 (15:10 +0100)] 
smbXsrv_open: intruduce smbXsrv_open_replay_cache to support FILE_NOT_AVAILABLE

Before processing an open we need to reserve the replay cache entry
in order to signal that we're still in progress.
If a reserved record is already present we need to return
FILE_NOT_AVAILABLE in order to let the client retry again.

[MS-SMB2] contains this:

  <152> Section 3.2.5.1: For the following error codes, Windows-based clients
  will retry the operation up to three times and then retry the operation every 5
  seconds until the count of milliseconds specified by Open.ResilientTimeout is
  exceeded:
  - STATUS_SERVER_UNAVAILABLE
  - STATUS_FILE_NOT_AVAILABLE
  - STATUS_SHARE_UNAVAILABLE

This works fine for windows clients, but current windows servers seems to
return ACCESS_DENIED instead of FILE_NOT_AVAILABLE.

A Windows server doesn't do any replay detection on pending opens,
which wait for a HANDLE lease to be broken (because of a
SHARING_VIOLATION), at all.

As this is not really documented for the server part of the current [MS-SMB2],
I found the key hint in "SMB 2.2: Bigger. Faster. Scalier - (Parts 1 and 2)"
on page 24. There's a picture showing that a replay gets FILE_NOT_AVAILABLE
as long as the original request is still in progress. See:
https://www.snia.org/educational-library/smb-22-bigger-faster-scalier-parts-1-and-2-2011

A Windows client is unhappy with the current windows server behavior if it
such a situation happens. There's also a very strange interaction with oplock
where the replay gets SHARING_VIOLATION after 35 seconds because it conflicts with
the original open.

I think it's good to follow the intial design from the 2011 presentation and
make the clients happy by using FILE_NOT_AVAILABLE (and differ from Windows).
I'll report that to dochelp@microsoft.com in order to get this hopefully fixed in
their server too).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmbXsrv_session: smbXsrv_session_remove_channel() should also remove the last channel
Stefan Metzmacher [Wed, 24 Feb 2021 16:44:12 +0000 (17:44 +0100)] 
smbXsrv_session: smbXsrv_session_remove_channel() should also remove the last channel

There's nothing special regarding the last channel,
as the smb2.session.bind2 test demonstrates.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos4:torture/smb2: add smb2.session.bind2
Stefan Metzmacher [Thu, 18 Mar 2021 13:38:16 +0000 (14:38 +0100)] 
s4:torture/smb2: add smb2.session.bind2

This demonstrates that a session and it's open handles is destroyed
when the last explicitly bound channel gets disconnected.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos4:torture/smb2: add smb2.replay.dhv2-pending* tests
Stefan Metzmacher [Fri, 12 Mar 2021 16:21:47 +0000 (17:21 +0100)] 
s4:torture/smb2: add smb2.replay.dhv2-pending* tests

These demonstrate that the replay detection for pending opens
either doesn't exist (for the share_access=NONE => SHARING_VIOLATION
case) or return the wrong status code => ACCESS_DENIED instead of
FILE_NOT_AVAILABLE.

Windows clients transparently retry after FILE_NOT_AVAILABLE,
while they pass ACCESS_DENIED directly to the application.

I'll report that to dochelp@microsoft.com in order to
clarify the situation.

In the meantime I added tests with a '-windows' suffix,
which demostrate the current windows server behavior,
while the tests with a '-sane' suffix expect the behavior
that whould make windows clients happy.

For Samba I'll implement the '-sane' behavior that
detects all replays and returns FILE_NOT_AVAILABLE
if the original request is still pending.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos4:torture/smb2: provide verbose output when we're waiting for potential lease/oplock...
Stefan Metzmacher [Wed, 17 Mar 2021 12:49:28 +0000 (13:49 +0100)] 
s4:torture/smb2: provide verbose output when we're waiting for potential lease/oplock breaks

It makes it easier to follow manual tests.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos4:torture/smb2: add smb2_util_lease_state_string()
Stefan Metzmacher [Mon, 22 Mar 2021 15:34:36 +0000 (16:34 +0100)] 
s4:torture/smb2: add smb2_util_lease_state_string()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos4:torture/smb2: make use of torture_reset_break_info() in replay.c
Stefan Metzmacher [Mon, 22 Mar 2021 23:58:38 +0000 (00:58 +0100)] 
s4:torture/smb2: make use of torture_reset_break_info() in replay.c

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos4:torture/smb2: make use of torture_reset_lease_break_info() in lease.c
Stefan Metzmacher [Mon, 22 Mar 2021 23:53:08 +0000 (00:53 +0100)] 
s4:torture/smb2: make use of torture_reset_lease_break_info() in lease.c

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agovfs_aio_pthread: don't allow async opens when multi channel is enabled.
Stefan Metzmacher [Fri, 26 Feb 2021 11:31:29 +0000 (12:31 +0100)] 
vfs_aio_pthread: don't allow async opens when multi channel is enabled.

We will get this supported later, but for now just disable async
opens as fsp->mid may not belong the first xconn of client->connections.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoRename mdfind to mdsearch
Mathieu Parent [Sat, 4 Jul 2020 21:16:40 +0000 (23:16 +0200)] 
Rename mdfind to mdsearch

GNUstep as an mdfind binary, and both should be co-instalable.

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

Signed-off-by: Mathieu Parent <math.parent@gmail.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Björn Baumbach <bb@sernet.de>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Mar 29 16:18:54 UTC 2021 on sn-devel-184

5 years agobuild: Notice if flex is missing at configure time
Andrew Bartlett [Fri, 26 Mar 2021 08:48:45 +0000 (21:48 +1300)] 
build: Notice if flex is missing at configure time

This may also fix the coverage build by ensuring --noline
is always specified to flex.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Mar 29 02:12:23 UTC 2021 on sn-devel-184

5 years agobuild: Consolidate --with-dnsupdate with --with-ads (which implied HAVE_KRB5)
Andrew Bartlett [Wed, 24 Mar 2021 21:48:28 +0000 (10:48 +1300)] 
build: Consolidate --with-dnsupdate with --with-ads (which implied HAVE_KRB5)

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Mar 26 04:06:41 UTC 2021 on sn-devel-184

5 years agobuild: Consolidate --with-ntvfs-fileserver into --enable-selftest when building the...
Andrew Bartlett [Wed, 24 Mar 2021 21:46:49 +0000 (10:46 +1300)] 
build: Consolidate --with-ntvfs-fileserver into --enable-selftest when building the AD DC

This removes from our configure help a feature which we retain only
to support our selftest system.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agosmb.conf: Remove "share backend" option
Andrew Bartlett [Wed, 24 Mar 2021 22:50:14 +0000 (11:50 +1300)] 
smb.conf: Remove "share backend" option

This is a confusing hold-over from the NTVFS fileserver that never became part of
the merged architecture.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agos3: smbd: Raise debug level when synthetic_pathref() can't find the file.
Stefan Metzmacher [Thu, 25 Mar 2021 22:03:32 +0000 (15:03 -0700)] 
s3: smbd: Raise debug level when synthetic_pathref() can't find the file.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agorpc_client: cli_winreg_spoolss.h references spoolss structs
Volker Lendecke [Tue, 23 Mar 2021 13:34:21 +0000 (14:34 +0100)] 
rpc_client: cli_winreg_spoolss.h references spoolss structs

Add required includes

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): Wed Mar 24 21:28:48 UTC 2021 on sn-devel-184

5 years agonmbd: Fix socket cleanup in make_subnet()
Volker Lendecke [Tue, 23 Mar 2021 10:58:58 +0000 (11:58 +0100)] 
nmbd: Fix socket cleanup in make_subnet()

We can have -errno in the in those variables

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agonmbd: Fix CID 1474439: Incorrect expression
Volker Lendecke [Tue, 23 Mar 2021 10:58:19 +0000 (11:58 +0100)] 
nmbd: Fix CID 1474439: Incorrect expression

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agovfs_ceph: Fix CID 1474440: Null pointer dereferences
Volker Lendecke [Tue, 23 Mar 2021 10:55:43 +0000 (11:55 +0100)] 
vfs_ceph: Fix CID 1474440: Null pointer dereferences

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: Align a few integer types
Volker Lendecke [Mon, 22 Mar 2021 16:16:06 +0000 (17:16 +0100)] 
printing: Align a few integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: Remove "else" branches, reduce indentation
Volker Lendecke [Mon, 22 Mar 2021 16:12:40 +0000 (17:12 +0100)] 
printing: Remove "else" branches, reduce indentation

Best reviewed with "git show -b"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: Fix typos
Volker Lendecke [Sun, 21 Mar 2021 08:45:13 +0000 (09:45 +0100)] 
printing: Fix typos

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: Remove code to upgrade from before b0909cfa14f
Volker Lendecke [Mon, 22 Mar 2021 15:35:38 +0000 (16:35 +0100)] 
printing: Remove code to upgrade from before b0909cfa14f

I think even back then "printing.tdb" would have just been a stale
tdb that would have been better handled externally. It might have been
a product requirement back then, but I think a startup script and not
core code might have been a better choice to handle this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoprinting: Passing a fn pointer does not need "&"
Volker Lendecke [Mon, 22 Mar 2021 15:11:21 +0000 (16:11 +0100)] 
printing: Passing a fn pointer does not need "&"

Just looked a bit weird and different from all other fn pointer
references in Samba.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agolibcli: Add file specific access flags to sddl
Volker Lendecke [Mon, 22 Mar 2021 13:43:54 +0000 (14:43 +0100)] 
libcli: Add file specific access flags to sddl

See

https://docs.microsoft.com/en-us/windows/win32/secauthz/ace-strings

for reference.

We can only use them for decoding, many of our tests depend on our
string representation of the flags.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agowinbindd: Fix a startup race with allocate_gid
Volker Lendecke [Tue, 23 Mar 2021 14:13:55 +0000 (15:13 +0100)] 
winbindd: Fix a startup race with allocate_gid

If you try to allocate a GID before winbind is fully set up,
idmap_child_handle() is still NULL. Add the required
wb_parent_idmap_setup_send()/recv() to allocate_gid().

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14678
RN: Fix a crash in winbind when allocate-gid is called early

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agodosmode: retry reading dos attributes as root for unreadable files
Björn Jacke [Thu, 4 Mar 2021 18:37:37 +0000 (19:37 +0100)] 
dosmode: retry reading dos attributes as root for unreadable files

if there are files that the user can't access, he is still allowed to read the
dos attributes information, so we need to try reading them as root also.

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

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
5 years agoldb: bump version to 2.4.0, in order to be used for Samba 4.15
Stefan Metzmacher [Wed, 24 Mar 2021 11:54:31 +0000 (12:54 +0100)] 
ldb: bump version to 2.4.0, in order to be used for Samba 4.15

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Mar 24 13:11:52 UTC 2021 on sn-devel-184

5 years agoCVE-2020-27840: pytests: move Dn.validate test to ldb
Douglas Bagnall [Thu, 11 Feb 2021 03:28:43 +0000 (16:28 +1300)] 
CVE-2020-27840: pytests: move Dn.validate test to ldb

We had the test in the Samba Python segfault suite because
a) the signal catching infrastructure was there, and
b) the ldb tests lack Samba's knownfail mechanism, which allowed us to
   assert the failure.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agoCVE-2020-27840 ldb_dn: avoid head corruption in ldb_dn_explode
Douglas Bagnall [Fri, 11 Dec 2020 03:32:25 +0000 (16:32 +1300)] 
CVE-2020-27840 ldb_dn: avoid head corruption in ldb_dn_explode

A DN string with lots of trailing space can cause ldb_dn_explode() to
put a zero byte in the wrong place in the heap.

When a DN string has a value represented with trailing spaces,
like this

     "CN=foo   ,DC=bar"

the whitespace is supposed to be ignored. We keep track of this in the
`t` pointer, which is NULL when we are not walking through trailing
spaces, and points to the first space when we are. We are walking with
the `p` pointer, writing the value to `d`, and keeping the length in
`l`.

     "CN=foo   ,DC= "       ==>       "foo   "
            ^  ^                             ^
            t  p                             d
                                       --l---

The value is finished when we encounter a comma or the end of the
string. If `t` is not NULL at that point, we assume there are trailing
spaces and wind `d and `l` back by the correct amount. Then we switch
to expecting an attribute name (e.g. "CN"), until we get to an "=",
which puts us back into looking for a value.

Unfortunately, we forget to immediately tell `t` that we'd finished
the last value, we can end up like this:

     "CN=foo   ,DC= "       ==>        ""
            ^      ^                    ^
            t      p                    d
                                        l=0

where `p` is pointing to a new value that contains only spaces, while
`t` is still referring to the old value. `p` notices the value ends,
and we subtract `p - t` from `d`:

     "CN=foo   ,DC= "       ==>  ?     ""
            ^       ^            ^
            t       p            d
                                      l ~= SIZE_MAX - 8

At that point `d` wants to terminate its string with a '\0', but
instead it terminates someone else's byte. This does not crash if the
number of trailing spaces is small, as `d` will point into a previous
value (a copy of "foo" in this example). Corrupting that value will
ultimately not matter, as we will soon try to allocate a buffer `l`
long, which will be greater than the available memory and the whole
operation will fail properly.

However, with more spaces, `d` will point into memory before the
beginning of the allocated buffer, with the exact offset depending on
the length of the earlier attributes and the number of spaces.

What about a longer DN with more attributes? For example,
"CN=foo     ,DC= ,DC=example,DC=com" -- since `d` has moved out of
bounds, won't we continue to use it and write more DN values into
mystery memory? Fortunately not, because the aforementioned allocation
of `l` bytes must happen first, and `l` is now huge. The allocation
happens in a talloc_memdup(), which is by default restricted to
allocating 256MB.

So this allows a person who controls a string parsed by ldb_dn_explode
to corrupt heap memory by placing a single zero byte at a chosen
offset before the allocated buffer.

An LDAP bind request can send a string DN as a username. This DN is
necessarily parsed before the password is checked, so an attacker does
not need proper credentials. The attacker can easily cause a denial of
service and we cannot rule out more subtle attacks.

The immediate solution is to reset `t` to NULL when a comma is
encountered, indicating that we are no longer looking at trailing
whitespace.

Found with the help of Honggfuzz.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agoCVE-2020-27840: pytests:segfault: add ldb.Dn validate test
Douglas Bagnall [Thu, 11 Feb 2021 04:05:14 +0000 (17:05 +1300)] 
CVE-2020-27840: pytests:segfault: add ldb.Dn validate test

ldb.Dn.validate wraps ldb_dn_explode.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agoCVE-2021-20277 ldb/attrib_handlers casefold: stay in bounds
Douglas Bagnall [Tue, 8 Dec 2020 08:32:09 +0000 (21:32 +1300)] 
CVE-2021-20277 ldb/attrib_handlers casefold: stay in bounds

For a string that had N spaces at the beginning, we would
try to move N bytes beyond the end of the string.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agoCVE-2021-20277 ldb tests: ldb_match tests with extra spaces
Douglas Bagnall [Fri, 5 Mar 2021 07:13:01 +0000 (20:13 +1300)] 
CVE-2021-20277 ldb tests: ldb_match tests with extra spaces

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agoauth:creds: Free the uname pointer in cli_credentials_parse_string()
Andreas Schneider [Mon, 22 Mar 2021 17:11:33 +0000 (18:11 +0100)] 
auth:creds: Free the uname pointer in cli_credentials_parse_string()

The data is duplicated and we don't need it anymore.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Mar 24 03:13:05 UTC 2021 on sn-devel-184

5 years agoauth:creds: Don't include credentials_internal.h twice
Andreas Schneider [Thu, 3 Dec 2020 16:10:22 +0000 (17:10 +0100)] 
auth:creds: Don't include credentials_internal.h twice

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agonetcmd: Fix opening SamDB database for offline backup
Joseph Sutton [Sun, 21 Mar 2021 22:06:30 +0000 (11:06 +1300)] 
netcmd: Fix opening SamDB database for offline backup

When opening the backed-up SamDB database, open the top-level database
without loading any modules so the backend database files aren't
unnecessarily opened. The domain SID is now fetched from the original
database rather than from the backup.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
5 years agonetcmd: Workaround issue backing up offline domain with lmdb >= 0.9.26
Samuel Cabrero [Thu, 18 Mar 2021 16:54:33 +0000 (17:54 +0100)] 
netcmd: Workaround issue backing up offline domain with lmdb >= 0.9.26

The LMDB change "ITS#9278 fix robust mutex cleanup for FreeBSD" released
in version 0.9.26 makes samba-tool domain backup offline to fail with
the following error:

Failed to connect to 'mdb:///tmp/foo/private/sam.ldb.d/CN=CONFIGURATION,DC=FOO,DC=EXAMPLE,DC=COM.ldb' with backend 'mdb': Unable to load ltdb cache records for backend 'ldb_mdb backend'
module samba_dsdb initialization failed : Operations error
Unable to load modules for /tmp/foo/private/sam.ldb.bak-offline: Unable to load ltdb cache records for backend 'ldb_mdb backend'
ERROR(ldb): uncaught exception - Unable to load ltdb cache records for backend 'ldb_mdb backend'
  File "/usr/local/samba/lib64/python3.6/site-packages/samba/netcmd/__init__.py", line 186, in _run
    return self.run(*args, **kwargs)
  File "/usr/local/samba/lib64/python3.6/site-packages/samba/netcmd/domain_backup.py", line 1147, in run
    session_info=system_session(), lp=lp)
  File "/usr/local/samba/lib64/python3.6/site-packages/samba/samdb.py", line 72, in __init__
    options=options)
  File "/usr/local/samba/lib64/python3.6/site-packages/samba/__init__.py", line 114, in __init__
    self.connect(url, flags, options)
  File "/usr/local/samba/lib64/python3.6/site-packages/samba/samdb.py", line 87, in connect
    options=options)

The error occurs opening the backed ldb to write the backup date and the
next SID, a call to pthread_mutex_lock in mdb_txn_renew0 (frame 8) returns
EINVAL:

  #0  0x00007ff63c2f1bea in wait4 () from /lib64/libc.so.6
  #1  0x00007ff63c26f3a3 in do_system () from /lib64/libc.so.6
  #2  0x00007ff63bc71e94 in smb_panic_default (why=0x7ffed481b7d0 "Signal 6: Aborted") at ../../lib/util/fault.c:153
  #3  0x00007ff63bc72168 in smb_panic (why=0x7ffed481b7d0 "Signal 6: Aborted") at ../../lib/util/fault.c:200
  #4  0x00007ff63bc71c82 in fault_report (sig=6) at ../../lib/util/fault.c:81
  #5  0x00007ff63bc71c97 in sig_fault (sig=6) at ../../lib/util/fault.c:92
  #6  <signal handler called>
  #7  0x00007ff63c2178b5 in raise () from /lib64/libpthread.so.0
  #8  0x00007ff637602e65 in mdb_txn_renew0 (txn=txn@entry=0x55d6f97fb800) at mdb.c:2710
  #9  0x00007ff637603ae8 in mdb_txn_begin (env=0x55d6f85dfa80, parent=0x0, flags=131072, ret=0x55d6f89c0928)
      at mdb.c:2912
  #10 0x00007ff6376236cc in lmdb_lock_read (module=0x55d6f8c5f4b0) at ../../lib/ldb/ldb_mdb/ldb_mdb.c:585
  #11 0x00007ff637641de6 in ldb_kv_cache_load (module=0x55d6f8c5f4b0) at ../../lib/ldb/ldb_key_value/ldb_kv_cache.c:450
  #12 0x00007ff637638792 in ldb_kv_init_store (ldb_kv=0x55d6f8af2a80, name=0x7ff637625675 "ldb_mdb backend",
      ldb=0x55d6f8cd22b0, options=0x0, _module=0x7ffed481c248) at ../../lib/ldb/ldb_key_value/ldb_kv.c:2166
  #13 0x00007ff6376247ba in lmdb_connect (ldb=0x55d6f8cd22b0,
      url=0x55d6f85d41f0 "mdb:///tmp/foo/private/sam.ldb.d/CN=CONFIGURATION,DC=FOO,DC=EXAMPLE,DC=COM.ldb", flags=64,
      options=0x0, _module=0x7ffed481c248) at ../../lib/ldb/ldb_mdb/ldb_mdb.c:1143
  #14 0x00007ff63bd94d2f in ldb_module_connect_backend (ldb=0x55d6f8cd22b0,
      url=0x55d6f85d41f0 "mdb:///tmp/foo/private/sam.ldb.d/CN=CONFIGURATION,DC=FOO,DC=EXAMPLE,DC=COM.ldb",
      options=0x0, backend_module=0x7ffed481c248) at ../../lib/ldb/common/ldb_modules.c:221
  #15 0x00007ff6375a4baf in new_partition_from_dn (ldb=0x55d6f8cd22b0, data=0x55d6f858bed0, mem_ctx=0x55d6f8a03cd0,
      dn=0x55d6f9865450, filename=0x55d6f860b6da "sam.ldb.d/CN=CONFIGURATION,DC=FOO,DC=EXAMPLE,DC=COM.ldb",
      backend_db_store=0x55d6f9d378e0 "mdb", partition=0x7ffed481c308)
      at ../../source4/dsdb/samdb/ldb_modules/partition_init.c:257
  #16 0x00007ff6375a57b9 in partition_reload_if_required (module=0x55d6f8972d10, data=0x55d6f858bed0, parent=0x0)
      at ../../source4/dsdb/samdb/ldb_modules/partition_init.c:513
  #17 0x00007ff6375a3b04 in partition_read_lock (module=0x55d6f8972d10)
      at ../../source4/dsdb/samdb/ldb_modules/partition.c:1492
  #18 0x00007ff63bd9631e in ldb_next_read_lock (module=0x55d6f8972d10) at ../../lib/ldb/common/ldb_modules.c:662
  #19 0x00007ff637484857 in schema_read_lock (module=0x55d6f9377e40)
      at ../../source4/dsdb/samdb/ldb_modules/schema_load.c:614
  #20 0x00007ff63bd9631e in ldb_next_read_lock (module=0x55d6f9377e40) at ../../lib/ldb/common/ldb_modules.c:662
  #21 0x00007ff6374b5402 in samba_dsdb_init (module=0x55d6f91c3cd0)
      at ../../source4/dsdb/samdb/ldb_modules/samba_dsdb.c:483
  #22 0x00007ff63bd95283 in ldb_module_init_chain (ldb=0x55d6f8cd22b0, module=0x55d6f91c3cd0)
      at ../../lib/ldb/common/ldb_modules.c:363
  #23 0x00007ff63bd95645 in ldb_load_modules (ldb=0x55d6f8cd22b0, options=0x0)
      at ../../lib/ldb/common/ldb_modules.c:445
  #24 0x00007ff63bd90663 in ldb_connect (ldb=0x55d6f8cd22b0,
      url=0x7ff6377d98f8 "/tmp/foo/private/sam.ldb.bak-offline", flags=64, options=0x0)
      at ../../lib/ldb/common/ldb.c:274
  #25 0x00007ff63bddb32f in py_ldb_connect (self=0x7ff63778afc0, args=(), Python Exception <class 'gdb.error'> There is no member named ma_keys.:
  kwargs=) at ../../lib/ldb/pyldb.c:1235

Deleting the previous samdb instance by setting it to None before opening the
backed ldb workaround the problem until we find the real problem here.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
5 years agos3:netapi: Add libnetapi_set_creds()
Andreas Schneider [Thu, 18 Mar 2021 12:34:15 +0000 (13:34 +0100)] 
s3:netapi: Add libnetapi_set_creds()

This will be used by the 'net' command in future!

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Mar 24 02:07:20 UTC 2021 on sn-devel-184

5 years agos3:netapi: Get rid of set_cmdline_auth_info_*()
Andreas Schneider [Thu, 18 Mar 2021 12:49:27 +0000 (13:49 +0100)] 
s3:netapi: Get rid of set_cmdline_auth_info_*()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agoauth:creds: Use our own cli_credentials_set_cmdline_callbacks()
Andreas Schneider [Thu, 3 Dec 2020 16:07:53 +0000 (17:07 +0100)] 
auth:creds: Use our own cli_credentials_set_cmdline_callbacks()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agoauth:creds: Add command line function for standard password callback
Andreas Schneider [Wed, 7 Aug 2019 09:36:28 +0000 (11:36 +0200)] 
auth:creds: Add command line function for standard password callback

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos4:lib:cmdline: Rename cli_credentials_set_cmdline_callbacks()
Andreas Schneider [Tue, 23 Mar 2021 15:27:38 +0000 (16:27 +0100)] 
s4:lib:cmdline: Rename cli_credentials_set_cmdline_callbacks()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Remove use_ccache from 'struct libnetapi_ctx'
Andreas Schneider [Thu, 18 Mar 2021 12:39:54 +0000 (13:39 +0100)] 
s3:netapi: Remove use_ccache from 'struct libnetapi_ctx'

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Remove use_kerberos from struct libnetapi_ctx
Andreas Schneider [Thu, 18 Mar 2021 12:39:54 +0000 (13:39 +0100)] 
s3:netapi: Remove use_kerberos from struct libnetapi_ctx

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Remove workgroup from 'struct libnetapi_ctx'
Andreas Schneider [Thu, 18 Mar 2021 10:37:50 +0000 (11:37 +0100)] 
s3:netapi: Remove workgroup from 'struct libnetapi_ctx'

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Remove password from 'struct libnetapi_ctx'
Andreas Schneider [Thu, 18 Mar 2021 10:37:03 +0000 (11:37 +0100)] 
s3:netapi: Remove password from 'struct libnetapi_ctx'

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Remove username from 'struct libnetapi_ctx'
Andreas Schneider [Thu, 18 Mar 2021 10:36:37 +0000 (11:36 +0100)] 
s3:netapi: Remove username from 'struct libnetapi_ctx'

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Use public functions for username/password
Andreas Schneider [Thu, 18 Mar 2021 10:14:39 +0000 (11:14 +0100)] 
s3:netapi: Use public functions for username/password

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Get username/password from cli_credentials in joindomain.c
Andreas Schneider [Thu, 18 Mar 2021 10:08:57 +0000 (11:08 +0100)] 
s3:netapi: Get username/password from cli_credentials in joindomain.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Get username/password from cli_credentials in netapi.c
Andreas Schneider [Thu, 18 Mar 2021 10:12:09 +0000 (11:12 +0100)] 
s3:netapi: Get username/password from cli_credentials in netapi.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Fill also cli_credentials with netapi setters
Andreas Schneider [Thu, 18 Mar 2021 09:57:10 +0000 (10:57 +0100)] 
s3:netapi: Fill also cli_credentials with netapi setters

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Add a cli_credentials pointer to struct libnetapi_ctx
Andreas Schneider [Thu, 18 Mar 2021 09:43:26 +0000 (10:43 +0100)] 
s3:netapi: Add a cli_credentials pointer to struct libnetapi_ctx

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Remove unused ctx->krb5_cc_env
Andreas Schneider [Thu, 18 Mar 2021 10:00:05 +0000 (11:00 +0100)] 
s3:netapi: Remove unused ctx->krb5_cc_env

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
5 years agos3:netapi: Make 'struct libnetapi_ctx' opaque
Andreas Schneider [Thu, 18 Mar 2021 09:06:53 +0000 (10:06 +0100)] 
s3:netapi: Make 'struct libnetapi_ctx' opaque

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>