]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
4 years agotorture: Do not call destroy_dlz() on uninitialised memory
Andrew Bartlett [Mon, 23 Nov 2020 07:27:51 +0000 (20:27 +1300)] 
torture: Do not call destroy_dlz() on uninitialised memory

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

Reviewed-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
4 years agowaf: upgrade to 2.0.21
Stefan Metzmacher [Wed, 25 Nov 2020 15:29:06 +0000 (16:29 +0100)] 
waf: upgrade to 2.0.21

This commit message was wrong:

    commit 5fc3a71d0f54b176d3cb2e399718d0468507e797
    Author: David Mulder <dmulder@suse.com>
    Date:   Mon Aug 24 13:12:46 2020 -0600

        waf: upgrade to 2.0.20

        This contain an important change:
        "Fix gccdeps.scan() returning nodes that no longer exist on disk."
        https://gitlab.com/ita1024/waf/-/merge_requests/2293

Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
The fix was in in waf master, but not included in 2.0.20,
but it's now included in 2.0.21.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:lib: Check return code of set_blocking()
Andreas Schneider [Tue, 24 Nov 2020 16:42:24 +0000 (17:42 +0100)] 
s3:lib: Check return code of set_blocking()

Found by covscan.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:smbd: Check return code of set_blocking()
Andreas Schneider [Tue, 24 Nov 2020 16:40:33 +0000 (17:40 +0100)] 
s3:smbd: Check return code of set_blocking()

Found by covscan.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:smb: Check return code of set_blocking
Andreas Schneider [Tue, 24 Nov 2020 16:35:26 +0000 (17:35 +0100)] 
libcli:smb: Check return code of set_blocking

Found by covscan.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:winbind: Check return code of set_blocking()
Andreas Schneider [Tue, 24 Nov 2020 16:33:26 +0000 (17:33 +0100)] 
s3:winbind: Check return code of set_blocking()

Found by covscan.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:smbd: Fix a possible null pointer deref in oplock code
Andreas Schneider [Tue, 24 Nov 2020 15:57:12 +0000 (16:57 +0100)] 
s3:smbd: Fix a possible null pointer deref in oplock code

Found by cppcheck.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agosamba-tool domain backup: Confirm the sidForRestore we will put into the backup is...
Andrew Bartlett [Tue, 17 Nov 2020 23:11:10 +0000 (12:11 +1300)] 
samba-tool domain backup: Confirm the sidForRestore we will put into the backup is free

Otherwise the administrator might only find there is a problem once they
attempt to restore the domain!

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14575
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agos3: smbd: Fix misleading comment I added for commit 382a5c4e7ec08ec9291453ffad9541ab3...
Jeremy Allison [Sat, 21 Nov 2020 23:55:08 +0000 (15:55 -0800)] 
s3: smbd: Fix misleading comment I added for commit 382a5c4e7ec08ec9291453ffad9541ab36aca274

smbd: Fix failure to check dstdir for delete on close

We're preventing ourselves from holding two locks here,
not protecting from waiting for a lock someone else
holds.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sun Nov 22 01:22:36 UTC 2020 on sn-devel-184

4 years agotestprogs: Fix MIT KRB5 export keytab with > 1.18
Andreas Schneider [Thu, 19 Nov 2020 16:04:07 +0000 (17:04 +0100)] 
testprogs: Fix MIT KRB5 export keytab with > 1.18

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Nov 21 00:11:02 UTC 2020 on sn-devel-184

4 years agosmbd: Fix failure to check dstdir for delete on close
Volker Lendecke [Thu, 19 Nov 2020 11:38:06 +0000 (12:38 +0100)] 
smbd: Fix failure to check dstdir for delete on close

In smb2_setinfo.c the call to smbd_do_setfilepathinfo() to perform the
rename takes place while holding a share mode lock. The function
check_parent_access() called below tries to query the destination
directory's locking.tdb entry to check whether the delete on close
flag is set on the destination directory. This fails because the
file to be renamed already has the share mode entry locked, we can't
lock two share mode entries simultaneously.

Convert the check to use fetch_share_mode_unlocked(). This might
introduce races, but this whole check is racy anyway. It does not
really matter whether we do the check for delete_on_close under a lock
or not, fetch_share_mode_unlocked() retrieves a consistent status of
the locking.tdb entry at some point in time as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Nov 20 00:20:06 UTC 2020 on sn-devel-184

4 years agotests: SMB2 rename fails to check del-on-close on dst dir
Volker Lendecke [Tue, 17 Nov 2020 14:24:43 +0000 (15:24 +0100)] 
tests: SMB2 rename fails to check del-on-close on dst dir

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Add rename()
Volker Lendecke [Mon, 16 Nov 2020 11:41:35 +0000 (12:41 +0100)] 
pylibsmb: Add rename()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotests: Factor out prep_creds()
Volker Lendecke [Tue, 17 Nov 2020 15:11:11 +0000 (16:11 +0100)] 
tests: Factor out prep_creds()

3 times the same code can be put together

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Make cli_nt_pipes_close() static
Volker Lendecke [Mon, 9 Nov 2020 18:32:57 +0000 (19:32 +0100)] 
libsmb: Make cli_nt_pipes_close() static

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolib: g_lock.h references "struct server_id", add #include
Volker Lendecke [Wed, 11 Nov 2020 15:52:07 +0000 (16:52 +0100)] 
lib: g_lock.h references "struct server_id", add #include

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolib: Remove unused security_descriptor_append()
Volker Lendecke [Wed, 11 Nov 2020 07:03:46 +0000 (08:03 +0100)] 
lib: Remove unused security_descriptor_append()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agobuild: fcvt() and fcvtl() are not used
Volker Lendecke [Mon, 16 Nov 2020 13:37:43 +0000 (14:37 +0100)] 
build: fcvt() and fcvtl() are not used

No need to check for them in the configure phase

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: avoid a smb_fname copy in call_trans2setfilepathinfo()
Ralph Boehme [Tue, 17 Nov 2020 10:02:31 +0000 (11:02 +0100)] 
smbd: avoid a smb_fname copy in call_trans2setfilepathinfo()

There's no point in doing a copy here, we can just point smb_fname at
fsp->fsp_name.

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): Thu Nov 19 21:24:23 UTC 2020 on sn-devel-184

4 years agosmbd: avoid a smb_fname copy in call_trans2qfilepathinfo()
Ralph Boehme [Tue, 20 Oct 2020 15:07:35 +0000 (17:07 +0200)] 
smbd: avoid a smb_fname copy in call_trans2qfilepathinfo()

No point in making a copy here.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: replace calls to check_access() with smbd_check_access_rights()
Ralph Boehme [Tue, 27 Oct 2020 11:23:00 +0000 (12:23 +0100)] 
smbd: replace calls to check_access() with smbd_check_access_rights()

check_access() is a 1:1 wrapper arounf smbd_check_access_rights().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: use SMB2_INFO_SPECIAL in call_trans2qfilepathinfo()
Ralph Boehme [Mon, 26 Oct 2020 16:57:00 +0000 (17:57 +0100)] 
smbd: use SMB2_INFO_SPECIAL in call_trans2qfilepathinfo()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture: avoid OPLOCK-CANCEL flapping on busy gitlab CI
Ralph Boehme [Mon, 16 Nov 2020 09:44:48 +0000 (10:44 +0100)] 
torture: avoid OPLOCK-CANCEL flapping on busy gitlab CI

I saw this test fail a few times on gitlab CI with
NT_STATUS_SHARING_VIOLATION:

  Running OPLOCK-CANCEL
  cli_unlink failed: NT_STATUS_SHARING_VIOLATION
  TEST OPLOCK-CANCEL FAILED!

The only possible explanation I could come up for
this flapping test is that the fnum1 filehandle in cli1 is still not closed when
cli2 tries to open the file deletion 5 seconds after cli1 is thrown away. As
fnum1 doesn't have FILE_SHARE_DELELE the open-for-delete fails with a
SHARING_VIOLATION.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agodocs-xml: add "smbd force process locks"
Ralph Boehme [Mon, 16 Nov 2020 10:06:08 +0000 (11:06 +0100)] 
docs-xml: add "smbd force process locks"

Avoid a parametric option in a hot codepath.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agoselftest: remove selftest/knownfail.d/samba3.smbtorture_s3
Ralph Boehme [Mon, 26 Oct 2020 09:03:24 +0000 (10:03 +0100)] 
selftest: remove selftest/knownfail.d/samba3.smbtorture_s3

This hunk was inadvertently included in 5161edbdb28.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Multi-threaded use is now possible with SMB2
Volker Lendecke [Wed, 18 Nov 2020 14:00:07 +0000 (15:00 +0100)] 
pylibsmb: Multi-threaded use is now possible with SMB2

No non-async callees are used anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Nov 19 04:12:11 UTC 2020 on sn-devel-184

4 years agopylibsmb: Remove unused py_cli_state->is_smb1
Volker Lendecke [Wed, 18 Nov 2020 13:59:15 +0000 (14:59 +0100)] 
pylibsmb: Remove unused py_cli_state->is_smb1

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Remove unused sync cli_smb2_list()
Volker Lendecke [Tue, 17 Nov 2020 11:31:20 +0000 (12:31 +0100)] 
libsmb: Remove unused sync cli_smb2_list()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Remove SMB2 special case for cli_list()
Volker Lendecke [Mon, 16 Nov 2020 07:26:56 +0000 (08:26 +0100)] 
pylibsmb: Remove SMB2 special case for cli_list()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Use async cli_smb2_list_send() in cli_list_send()
Volker Lendecke [Mon, 16 Nov 2020 07:26:09 +0000 (08:26 +0100)] 
libsmb: Use async cli_smb2_list_send() in cli_list_send()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Prepare cli_list_send()/recv() for single-issue subreqs
Volker Lendecke [Wed, 18 Nov 2020 13:13:22 +0000 (14:13 +0100)] 
libsmb: Prepare cli_list_send()/recv() for single-issue subreqs

This prepares cli_list_recv() for the lowerlevel NT_STATUS_RETRY that
will come in once cli_list_send() uses cli_smb2_list_send() as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Convert cli_list_recv() to single-recv
Volker Lendecke [Mon, 26 Oct 2020 08:21:17 +0000 (09:21 +0100)] 
libsmb: Convert cli_list_recv() to single-recv

This converts the higher-level cli_list_recv() to the new
cli_smb2_list_recv() calling convention to just issue one entry per
recv() call in preparation of using the async cli_smb2_list_send() in
cli_list_send().

For SMB1 this will be a performance degradation, as we have to make
copies out of the arrays that cli_trans_recv() returns, but soon this
will become a performance improvement for the SMB2 directory
listing. And as hopefully most deployments these days are SMB2, I
think we can live with the SMB1 client directory listing
degradation. Also, we can also convert the lowerlevel SMB1 directory
listing routines in case someone actually sees problems from this
here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Make cli_smb2_list() asynchronous
Volker Lendecke [Sat, 14 Nov 2020 17:31:22 +0000 (18:31 +0100)] 
libsmb: Make cli_smb2_list() asynchronous

Return directory entries as soon as possible via
cli_smb2_list_recv(). This returns just one entry per call to
cli_smb2_list_recv() right out of the buffer without assembling
potentially thousands of entries in a big array. You must call
cli_smb2_recv() until an error (except NT_STATUS_RETRY) happens. This
reduces our latency for smbclient's "dir" command significantly for
large directories. In the future I hope I can do the same thing also for
SMBC_readdir_ctx() to improve all users of our published libsmbclient.

Initial attempts of this routine issued fresh smb2_query_directory
requests asynchronously while the receivers of the entries did their
processing, for example showing them in smbclient's "dir"
command. However, this breaks because for example the "showacls"
smbclient option needs to do synchronous smb requests to do their job,
which we can't do while async requests are pending. Thus I came up
with a semi-synchronous approach to issue additional
smb2_query_directory requests from within cli_smb2_list_recv() and
return NT_STATUS_RETRY. This means that we will call back our caller
via the tevent_req_notify function when a fresh entry is available.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agouptodateness.py: remove what appears to be debugging lines
Rowland Penny [Wed, 18 Nov 2020 12:09:16 +0000 (12:09 +0000)] 
uptodateness.py: remove what appears to be debugging lines

They do nothing except confuse users.

Signed-off-by: Rowland Penny <rpenny@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Thu Nov 19 00:36:58 UTC 2020 on sn-devel-184

4 years agobootstrap: Add OpenSUSE 15.2
Samuel Cabrero [Tue, 17 Nov 2020 12:32:19 +0000 (13:32 +0100)] 
bootstrap: Add OpenSUSE 15.2

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Tue Nov 17 18:50:05 UTC 2020 on sn-devel-184

4 years agoautobuild: Encode text/plain into base64 to wrap long-lines
SATOH Fumiyasu [Tue, 10 Nov 2020 08:15:42 +0000 (17:15 +0900)] 
autobuild: Encode text/plain into base64 to wrap long-lines

MIMEText(text, 'plain', 'utf-8') encodes the text into
base64 and adds 'Content-Transfer-Encoding: base64' header.

Signed-off-by: SATOH Fumiyasu <fumiyas@osstech.co.jp>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Nov 16 22:43:35 UTC 2020 on sn-devel-184

4 years agolibsmb: Remove unused sync cli_smb2_rename()
Volker Lendecke [Fri, 13 Nov 2020 15:32:16 +0000 (16:32 +0100)] 
libsmb: Remove unused sync cli_smb2_rename()

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): Mon Nov 16 21:18:16 UTC 2020 on sn-devel-184

4 years agolibsmb: Make cli_rename_send()/recv() smb2-capable
Volker Lendecke [Fri, 13 Nov 2020 15:29:23 +0000 (16:29 +0100)] 
libsmb: Make cli_rename_send()/recv() smb2-capable

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Make cli_rename_send()/_recv() a proper tevent_req engine
Volker Lendecke [Fri, 13 Nov 2020 15:23:48 +0000 (16:23 +0100)] 
libsmb: Make cli_rename_send()/_recv() a proper tevent_req engine

This will make it more obvious to add SMB2 soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Make cli_smb2_rename async
Volker Lendecke [Fri, 13 Nov 2020 14:31:16 +0000 (15:31 +0100)] 
libsmb: Make cli_smb2_rename async

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Make get_fnum_from_path() async
Volker Lendecke [Fri, 13 Nov 2020 11:59:55 +0000 (12:59 +0100)] 
libsmb: Make get_fnum_from_path() async

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Move set_acl() to python
Volker Lendecke [Thu, 12 Nov 2020 08:26:10 +0000 (09:26 +0100)] 
pylibsmb: Move set_acl() to python

The previous code was not available in threaded environments

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Add set_sd()
Volker Lendecke [Tue, 10 Nov 2020 20:25:56 +0000 (21:25 +0100)] 
pylibsmb: Add set_sd()

setacl() on a fnum, available asynchronously

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Remove unused sync cli_smb2_set_security_descriptor()
Volker Lendecke [Mon, 9 Nov 2020 20:43:19 +0000 (21:43 +0100)] 
libsmb: Remove unused sync cli_smb2_set_security_descriptor()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Make cli_set_security_descriptor() async
Volker Lendecke [Tue, 10 Nov 2020 19:55:29 +0000 (20:55 +0100)] 
libsmb: Make cli_set_security_descriptor() async

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture3: cli_set_security_descriptor() does smb2 as well
Volker Lendecke [Mon, 9 Nov 2020 20:40:28 +0000 (21:40 +0100)] 
torture3: cli_set_security_descriptor() does smb2 as well

Remove a direct caller

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Move get_acl() to python
Volker Lendecke [Wed, 11 Nov 2020 12:20:39 +0000 (13:20 +0100)] 
pylibsmb: Move get_acl() to python

The previous code was not available in threaded environments

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Add get_sd()
Volker Lendecke [Tue, 10 Nov 2020 20:25:56 +0000 (21:25 +0100)] 
pylibsmb: Add get_sd()

getacl() on a fnum, available asynchronously

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Remove unused sync cli_smb2_query_security_descriptor()
Volker Lendecke [Mon, 9 Nov 2020 20:43:19 +0000 (21:43 +0100)] 
libsmb: Remove unused sync cli_smb2_query_security_descriptor()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Make cli_query_security_descriptor() async
Volker Lendecke [Mon, 9 Nov 2020 20:37:10 +0000 (21:37 +0100)] 
libsmb: Make cli_query_security_descriptor() async

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture3: cli_query_security_descriptor() does smb2 as well
Volker Lendecke [Mon, 9 Nov 2020 20:40:28 +0000 (21:40 +0100)] 
torture3: cli_query_security_descriptor() does smb2 as well

Remove a direct caller

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Export a few SMB constants
Volker Lendecke [Wed, 11 Nov 2020 10:33:18 +0000 (11:33 +0100)] 
pylibsmb: Export a few SMB constants

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Merge remove_dir() into its only caller
Volker Lendecke [Mon, 9 Nov 2020 18:48:21 +0000 (19:48 +0100)] 
pylibsmb: Merge remove_dir() into its only caller

Now that delete_tree is in python code, align py_smb_rmdir() with the
other functions.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Merge unlink_file() into its only caller
Volker Lendecke [Mon, 9 Nov 2020 18:48:21 +0000 (19:48 +0100)] 
pylibsmb: Merge unlink_file() into its only caller

Now that delete_tree is in python code, align py_smb_unlink() with the
other functions.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Move deltree to python code
Volker Lendecke [Fri, 6 Nov 2020 21:08:00 +0000 (22:08 +0100)] 
pylibsmb: Move deltree to python code

This is much shorter. There's also another aspect: I'm working on
improving cli_list() to not collect all files before starting to call
the callback function. This means that the cli_list cb will be called
from within tevent_loop_once(). In pylibsmb.c's deltree code this
would create a nested event loop. By moving the deltree code into the
python world this nested event loop is avoided. Now the python code
will first collect everything and then start to delete, avoiding the
nesting. A future development should make listing directories a
generator or something like that.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopylibsmb: Add a compatible python-level wrapper
Volker Lendecke [Wed, 11 Nov 2020 10:20:29 +0000 (11:20 +0100)] 
pylibsmb: Add a compatible python-level wrapper

Right now this is empty, but it is the basis for moving complexity out
or pylibsmb.c into python code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibcli: smb2: Never print length if smb2_signing_key_valid() fails for crypto blob.
Jeremy Allison [Fri, 13 Nov 2020 22:18:43 +0000 (14:18 -0800)] 
libcli: smb2: Never print length if smb2_signing_key_valid() fails for crypto blob.

Blob could be NULL.

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

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): Mon Nov 16 09:47:38 UTC 2020 on sn-devel-184

4 years agos4-torture: test file_line_parse as well
Günther Deschner [Tue, 10 Nov 2020 16:10:27 +0000 (17:10 +0100)] 
s4-torture: test file_line_parse as well

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Fri Nov 13 17:47:33 UTC 2020 on sn-devel-184

4 years agolib: Fix file_lines_parse() to do what people expect. Much safer to use.
Jeremy Allison [Tue, 10 Nov 2020 21:52:01 +0000 (13:52 -0800)] 
lib: Fix file_lines_parse() to do what people expect. Much safer to use.

Take an incoming const char * pointer and return an allocated
array that must be freed. Don't expose the internal optimization
of file_lines_parse_internal() breaking the passed in string
into lines.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agolib: create a wrapper for file_lines_parse().
Jeremy Allison [Tue, 10 Nov 2020 21:43:24 +0000 (13:43 -0800)] 
lib: create a wrapper for file_lines_parse().

Make the internal function file_lines_parse_internal().

Currently file_lines_parse() just wraps file_lines_parse_internal(),
but this allows me to change file_lines_parse() to take
a const char * to make it safe for callers (no talloc tricks).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agotests python krb5: add arcfour salt tests
Gary Lockyer [Tue, 10 Nov 2020 03:57:11 +0000 (16:57 +1300)] 
tests python krb5: add arcfour salt tests

MIT kerberos returns a salt when ARCFOUR_HMAC_MD5 encryption selected,
Heimdal does not.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Nov 12 22:54:22 UTC 2020 on sn-devel-184

4 years agotests python krb5: refactor compatability tests
Gary Lockyer [Tue, 10 Nov 2020 03:56:46 +0000 (16:56 +1300)] 
tests python krb5: refactor compatability tests

Refactor to aid the adding of tests for the inclusion of a salt when
ARCFOUR_HMAC_MD5 encryption selected

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agotests python krb5: Convert kdc-heimdal to python
Gary Lockyer [Thu, 5 Nov 2020 20:07:04 +0000 (09:07 +1300)] 
tests python krb5: Convert kdc-heimdal to python

Implement the tests in source4/torture/krb5/kdc-heimdal.c in python.
The following tests were not re-implemented as they are client side
tests for the "Orpheus Lyre" attack:
       TORTURE_KRB5_TEST_CHANGE_SERVER_OUT
       TORTURE_KRB5_TEST_CHANGE_SERVER_IN
       TORTURE_KRB5_TEST_CHANGE_SERVER_BOTH

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agotests python krb5: raw_testcase permit RC4 salts
Gary Lockyer [Tue, 10 Nov 2020 00:51:39 +0000 (13:51 +1300)] 
tests python krb5: raw_testcase permit RC4 salts

MIT kerberos returns a salt when ARCFOUR_HMAC_MD5, this commit removes
the check that a salt is not returned.  A test for the difference
between MIT and Heimdal will be added in the subsequent commits.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agotests python krb5: Refactor compatability test constants
Gary Lockyer [Mon, 9 Nov 2020 22:20:58 +0000 (11:20 +1300)] 
tests python krb5: Refactor compatability test constants

Modify tests to use the constants defined in rfc4120_constants.py

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agotests python krb5: Refactor canonicalization test constants
Gary Lockyer [Mon, 9 Nov 2020 22:20:03 +0000 (11:20 +1300)] 
tests python krb5: Refactor canonicalization test constants

Modify tests to use the constants defined in rfc4120_constants.py

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agotests python krb5: Add constants module
Gary Lockyer [Mon, 9 Nov 2020 22:19:02 +0000 (11:19 +1300)] 
tests python krb5: Add constants module

Extract the constants used in the tests into a separate module.
To reduce code duplication

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agovfs_shadow_copy2: Preserve all open flags assuming ROFS
Anoop C S [Thu, 12 Nov 2020 14:57:24 +0000 (20:27 +0530)] 
vfs_shadow_copy2: Preserve all open flags assuming ROFS

Instead of replacing open flags with just O_RDONLY, filter out all those
flags unrelated to a Read Only File System

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

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Nov 12 17:23:19 UTC 2020 on sn-devel-184

4 years agos3:smbd: Fix possible null pointer dereference in token_contains_name()
Andreas Schneider [Wed, 11 Nov 2020 12:42:06 +0000 (13:42 +0100)] 
s3:smbd: Fix possible null pointer dereference in token_contains_name()

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Alexander Bokovoy <ab@samba.org>
Autobuild-Date(master): Thu Nov 12 15:13:47 UTC 2020 on sn-devel-184

4 years agoauth_sam: use pdb_get_domain_info to look up DNS forest information
Alexander Bokovoy [Wed, 11 Nov 2020 12:42:55 +0000 (14:42 +0200)] 
auth_sam: use pdb_get_domain_info to look up DNS forest information

When Samba is used as a part of FreeIPA domain controller, Windows
clients for a trusted AD forest may try to authenticate (perform logon
operation) as a REALM\name user account.

Fix auth_sam plugins to accept DNS forest name if we are running on a DC
with PASSDB module providing domain information (e.g. pdb_get_domain_info()
returning non-NULL structure). Right now, only FreeIPA or Samba AD DC
PASSDB backends return this information but Samba AD DC configuration is
explicitly ignored by the two auth_sam (strict and netlogon3) modules.

Detailed logs below:

[2020/11/11 09:23:53.281296,  1, pid=42677, effective(65534, 65534), real(65534, 0), class=rpc_parse] ../../librpc/ndr/ndr.c:482(ndr_print_function_debug)
       netr_LogonSamLogonWithFlags: struct netr_LogonSamLogonWithFlags
          in: struct netr_LogonSamLogonWithFlags
              server_name              : *
                  server_name              : '\\master.ipa.test'
              computer_name            : *
                  computer_name            : 'AD1'
              credential               : *
                  credential: struct netr_Authenticator
                      cred: struct netr_Credential
                          data                     : 529f4b087c5f6546
                      timestamp                : Wed Nov 11 09:23:55 AM 2020 UTC
              return_authenticator     : *
                  return_authenticator: struct netr_Authenticator
                      cred: struct netr_Credential
                          data                     : 204f28f622010000
                      timestamp                : Fri May  2 06:37:50 AM 1986 UTC
              logon_level              : NetlogonNetworkTransitiveInformation (6)
              logon                    : *
                  logon                    : union netr_LogonLevel(case 6)
                  network                  : *
                      network: struct netr_NetworkInfo
                          identity_info: struct netr_IdentityInfo
                              domain_name: struct lsa_String
                                  length                   : 0x0010 (16)
                                  size                     : 0x01fe (510)
                                  string                   : *
                                      string                   : 'IPA.TEST'
                              parameter_control        : 0x00002ae0 (10976)
                                     0: MSV1_0_CLEARTEXT_PASSWORD_ALLOWED
                                     0: MSV1_0_UPDATE_LOGON_STATISTICS
                                     0: MSV1_0_RETURN_USER_PARAMETERS
                                     0: MSV1_0_DONT_TRY_GUEST_ACCOUNT
                                     1: MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT
                                     1: MSV1_0_RETURN_PASSWORD_EXPIRY
                                     1: MSV1_0_USE_CLIENT_CHALLENGE
                                     0: MSV1_0_TRY_GUEST_ACCOUNT_ONLY
                                     1: MSV1_0_RETURN_PROFILE_PATH
                                     0: MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY
                                     1: MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT
                                     0: MSV1_0_DISABLE_PERSONAL_FALLBACK
                                     1: MSV1_0_ALLOW_FORCE_GUEST
                                     0: MSV1_0_CLEARTEXT_PASSWORD_SUPPLIED
                                     0: MSV1_0_USE_DOMAIN_FOR_ROUTING_ONLY
                                     0: MSV1_0_ALLOW_MSVCHAPV2
                                     0: MSV1_0_S4U2SELF
                                     0: MSV1_0_CHECK_LOGONHOURS_FOR_S4U
                                     0: MSV1_0_SUBAUTHENTICATION_DLL_EX
                              logon_id                 : 0x0000000000884ef2 (8933106)
                              account_name: struct lsa_String
                                  length                   : 0x000e (14)
                                  size                     : 0x000e (14)
                                  string                   : *
                                      string                   : 'idmuser'
                              workstation: struct lsa_String
                                  length                   : 0x0000 (0)
                                  size                     : 0x0000 (0)
                                  string                   : *
                                      string                   : ''
                         challenge                : 417207867bd33c74
                          nt: struct netr_ChallengeResponse
                              length                   : 0x00c0 (192)
                              size                     : 0x00c0 (192)
                              data                     : *
                                  data: ARRAY(192)
  [0000] A5 24 62 6E 31 DF 69 66   9E DC 54 D6 63 4C D6 2F   .$bn1.if ..T.cL./
  [0010] 01 01 00 00 00 00 00 00   50 37 D7 60 0C B8 D6 01   ........ P7.`....
  [0020] 15 1B 38 4F 47 95 4D 62   00 00 00 00 02 00 0E 00   ..8OG.Mb ........
  [0030] 57 00 49 00 4E 00 32 00   30 00 31 00 36 00 01 00   W.I.N.2. 0.1.6...
  [0040] 06 00 41 00 44 00 31 00   04 00 18 00 77 00 69 00   ..A.D.1. ....w.i.
  [0050] 6E 00 32 00 30 00 31 00   36 00 2E 00 74 00 65 00   n.2.0.1. 6...t.e.
  [0060] 73 00 74 00 03 00 20 00   61 00 64 00 31 00 2E 00   s.t... . a.d.1...
  [0070] 77 00 69 00 6E 00 32 00   30 00 31 00 36 00 2E 00   w.i.n.2. 0.1.6...
  [0080] 74 00 65 00 73 00 74 00   05 00 18 00 77 00 69 00   t.e.s.t. ....w.i.
  [0090] 6E 00 32 00 30 00 31 00   36 00 2E 00 74 00 65 00   n.2.0.1. 6...t.e.
  [00A0] 73 00 74 00 07 00 08 00   50 37 D7 60 0C B8 D6 01   s.t..... P7.`....
  [00B0] 06 00 04 00 02 00 00 00   00 00 00 00 00 00 00 00   ........ ........
                          lm: struct netr_ChallengeResponse
                              length                   : 0x0018 (24)
                              size                     : 0x0018 (24)
                              data                     : *
                                  data                     : 000000000000000000000000000000000000000000000000
              validation_level         : 0x0006 (6)
              flags                    : *
                  flags                    : 0x00000000 (0)
                         0: NETLOGON_SAMLOGON_FLAG_PASS_TO_FOREST_ROOT
                         0: NETLOGON_SAMLOGON_FLAG_PASS_CROSS_FOREST_HOP
                         0: NETLOGON_SAMLOGON_FLAG_RODC_TO_OTHER_DOMAIN
                         0: NETLOGON_SAMLOGON_FLAG_RODC_NTLM_REQUEST

In such case checks for a workgroup name will not match the DNS forest
name used in the username specification:

[2020/11/11 09:23:53.283055,  3, pid=42677, effective(65534, 65534), real(65534, 0), class=auth] ../../source3/auth/auth.c:200(auth_check_ntlm_password)
  check_ntlm_password:  Checking password for unmapped user [IPA.TEST]\[idmuser]@[] with the new password interface
[2020/11/11 09:23:53.283073,  3, pid=42677, effective(65534, 65534), real(65534, 0), class=auth] ../../source3/auth/auth.c:203(auth_check_ntlm_password)
  check_ntlm_password:  mapped user is: [IPA.TEST]\[idmuser]@[]
[2020/11/11 09:23:53.283082, 10, pid=42677, effective(65534, 65534), real(65534, 0), class=auth] ../../source3/auth/auth.c:213(auth_check_ntlm_password)
  check_ntlm_password: auth_context challenge created by fixed
[2020/11/11 09:23:53.283091, 10, pid=42677, effective(65534, 65534), real(65534, 0), class=auth] ../../source3/auth/auth.c:216(auth_check_ntlm_password)
  challenge is:
[2020/11/11 09:23:53.283099,  5, pid=42677, effective(65534, 65534), real(65534, 0)] ../../lib/util/util.c:678(dump_data)
  [0000] 41 72 07 86 7B D3 3C 74                             Ar..{.<t
[2020/11/11 09:23:53.283113, 10, pid=42677, effective(65534, 65534), real(65534, 0), class=auth] ../../source3/auth/auth_sam.c:209(auth_sam_netlogon3_auth)
  auth_sam_netlogon3_auth: Check auth for: [IPA.TEST]\[idmuser]
[2020/11/11 09:23:53.283123,  5, pid=42677, effective(65534, 65534), real(65534, 0), class=auth] ../../source3/auth/auth_sam.c:234(auth_sam_netlogon3_auth)
  auth_sam_netlogon3_auth: IPA.TEST is not our domain name (DC for IPA)
[2020/11/11 09:23:53.283131, 10, pid=42677, effective(65534, 65534), real(65534, 0), class=auth] ../../source3/auth/auth.c:249(auth_check_ntlm_password)
  auth_check_ntlm_password: sam_netlogon3 had nothing to say

and overall authentication attempt will fail: auth_winbind will complain
that this domain is not a trusted one and refuse operating on it:

[2020/11/11 09:23:53.283784, 10, pid=42663, effective(0, 0), real(0, 0), class=winbind] ../../source3/winbindd/winbindd.c:742(process_request_send)
  process_request_send: process_request: Handling async request smbd(42677):PAM_AUTH_CRAP
[2020/11/11 09:23:53.283796,  3, pid=42663, effective(0, 0), real(0, 0), class=winbind] ../../source3/winbindd/winbindd_pam_auth_crap.c:110(winbindd_pam_auth_crap_send)
  [42677]: pam auth crap domain: [IPA.TEST] user: idmuser
[2020/11/11 09:23:53.283810,  3, pid=42663, effective(0, 0), real(0, 0), class=winbind] ../../source3/winbindd/winbindd_pam.c:409(find_auth_domain)
  Authentication for domain [IPA.TEST] refused as it is not a trusted domain
[2020/11/11 09:23:53.283825, 10, pid=42663, effective(0, 0), real(0, 0), class=winbind] ../../source3/winbindd/winbindd.c:810(process_request_done)
  process_request_done: [smbd(42677):PAM_AUTH_CRAP]: NT_STATUS_NO_SUCH_USER
[2020/11/11 09:23:53.283844, 10, pid=42663, effective(0, 0), real(0, 0), class=winbind] ../../source3/winbindd/winbindd.c:855(process_request_written)
  process_request_written: [smbd(42677):PAM_AUTH_CRAP]: delivered response to client

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoselftest/subunithelper: also output as much of unterminated DETAILS
Stefan Metzmacher [Fri, 6 Nov 2020 11:35:04 +0000 (12:35 +0100)] 
selftest/subunithelper: also output as much of unterminated DETAILS

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Nov 11 22:43:46 UTC 2020 on sn-devel-184

4 years agoselftest/subunithelper: only let ']\n' lines to terminate
Stefan Metzmacher [Thu, 5 Nov 2020 13:19:11 +0000 (14:19 +0100)] 
selftest/subunithelper: only let ']\n' lines to terminate

It should not be enough that a line ends with ']\n' is accident,
subunit DETAILS are terminated with '\n]\n'!

This gives a much higher chance to see the actual problem
without having them filtered by various 'filter-subunit' invocations.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 years agoSambaToolCmdTest: let assertCmdSuccess() escape ']\n' lines
Stefan Metzmacher [Thu, 5 Nov 2020 12:46:27 +0000 (13:46 +0100)] 
SambaToolCmdTest: let assertCmdSuccess() escape ']\n' lines

This gives a much higher chance to see the actual problem
without having them filtered by various 'filter-subunit' invocations.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 years agotestprogs/blackbox: make sure subunit.sh always terminates DETAILS with '\n]\n'
Stefan Metzmacher [Fri, 6 Nov 2020 11:32:10 +0000 (12:32 +0100)] 
testprogs/blackbox: make sure subunit.sh always terminates DETAILS with '\n]\n'

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 years agos3: modules: gluster. Fix the error I made in preventing talloc leaks from a function.
Jeremy Allison [Tue, 10 Nov 2020 18:18:18 +0000 (10:18 -0800)] 
s3: modules: gluster. Fix the error I made in preventing talloc leaks from a function.

file_lines_parse() plays horrible tricks with
the passed-in talloc pointers and the hierarcy
which makes freeing hard to get right.

As we know mem_ctx is freed by the caller, after
calling file_lines_parse don't free on exit and let the caller
handle it. This violates good Samba coding practice
but we know we're not leaking here.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Nov 11 15:02:27 UTC 2020 on sn-devel-184

4 years agolookup_name: allow lookup names prefixed with DNS forest root for FreeIPA DC
Alexander Bokovoy [Tue, 10 Nov 2020 15:35:24 +0000 (17:35 +0200)] 
lookup_name: allow lookup names prefixed with DNS forest root for FreeIPA DC

In FreeIPA deployment with active Global Catalog service, when a two-way
trust to Active Directory forest is established, Windows systems can
look up FreeIPA users and groups. When using a security tab in Windows
Explorer on AD side, a lookup over a trusted forest might come as
realm\name instead of NetBIOS domain name:

--------------------------------------------------------------------
[2020/01/13 11:12:39.859134,  1, pid=33253, effective(17324010041732401004), real(1732401004, 0), class=rpc_parse] ../../librpc/ndr/ndr.c:471(ndr_print_function_debug)
       lsa_LookupNames3: struct lsa_LookupNames3
          in: struct lsa_LookupNames3
              handle                   : *
                  handle: struct policy_handle
                      handle_type              : 0x00000000 (0)
                      uuid                     : 0000000e-0000-0000-1c5e-a750e5810000
              num_names                : 0x00000001 (1)
              names: ARRAY(1)
                  names: struct lsa_String
                      length                   : 0x001e (30)
                      size                     : 0x0020 (32)
                      string                   : *
                          string                   : 'ipa.test\admins'
              sids                     : *
                  sids: struct lsa_TransSidArray3
                      count                    : 0x00000000 (0)
                      sids                     : NULL
              level                    : LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2 (6)
              count                    : *
                  count                    : 0x00000000 (0)
              lookup_options           : LSA_LOOKUP_OPTION_SEARCH_ISOLATED_NAMES (0)
              client_revision          : LSA_CLIENT_REVISION_2 (2)
--------------------------------------------------------------------

If we are running as a DC and PASSDB supports returning domain info
(pdb_get_domain_info() returns a valid structure), check domain of the
name in lookup_name() against DNS forest name and allow the request to
be done against the primary domain. This corresponds to FreeIPA's use of
Samba as a DC. For normal domain members a realm-based lookup falls back
to a lookup over to its own domain controller with the help of winbindd.

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Alexander Bokovoy <ab@samba.org>
Autobuild-Date(master): Wed Nov 11 10:59:01 UTC 2020 on sn-devel-184

4 years agoselftest: Windows 2019 implements the RemoveDollar behaviour for Enterprise principals
Andrew Bartlett [Tue, 10 Nov 2020 00:50:37 +0000 (13:50 +1300)] 
selftest: Windows 2019 implements the RemoveDollar behaviour for Enterprise principals

This is documented in MS-KILE.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Wed Nov 11 02:38:46 UTC 2020 on sn-devel-184

4 years agoselftest: Add in encrypted-pa-data from RFC 6806
Andrew Bartlett [Mon, 9 Nov 2020 22:27:06 +0000 (11:27 +1300)] 
selftest: Add in encrypted-pa-data from RFC 6806

This comes from Windows 2019 which supports FAST.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoselftest: Fix formatting of failure (traceback and options swapped in format string)
Andrew Bartlett [Mon, 9 Nov 2020 22:21:24 +0000 (11:21 +1300)] 
selftest: Fix formatting of failure (traceback and options swapped in format string)

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoselftest: Make as_canonicalization_tests.py auto-detect the NT4 domain name
Andrew Bartlett [Tue, 10 Nov 2020 00:47:30 +0000 (13:47 +1300)] 
selftest: Make as_canonicalization_tests.py auto-detect the NT4 domain name

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agosamdb: Add samdb.domain_netbios_name()
Andrew Bartlett [Tue, 10 Nov 2020 00:46:28 +0000 (13:46 +1300)] 
samdb: Add samdb.domain_netbios_name()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoselftest: Make as_canonicalization_tests.py easier to run outside "make test"
Andrew Bartlett [Mon, 9 Nov 2020 22:12:13 +0000 (11:12 +1300)] 
selftest: Make as_canonicalization_tests.py easier to run outside "make test"

This takes the realm from the LDAP base DN and so avoids one
easy mistake to make.  So far the NT4 domain name is not
auto-detected, so much be read from the smb.conf.

By using .guess() the smb.conf is read for the unspecified
parts (eg workstation for an NTLM login to the LDAP server if
the target server is an IP address).

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoselftest: Fix flipped machine and user constants
Andrew Bartlett [Mon, 9 Nov 2020 22:09:59 +0000 (11:09 +1300)] 
selftest: Fix flipped machine and user constants

This naturally does not change the test, but reduces developer
confusion.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoselftest: Send enterprise principals tagged as such
Andrew Bartlett [Mon, 9 Nov 2020 22:09:13 +0000 (11:09 +1300)] 
selftest: Send enterprise principals tagged as such

This test passed against Samba but failed against Windows when
an enterprise principal (user@domain.com@REALM) was encoded as
NT_PRINCIPAL.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agolocking: hide share_mode_lock definition
Volker Lendecke [Wed, 4 Nov 2020 11:39:48 +0000 (12:39 +0100)] 
locking: hide share_mode_lock definition

This makes "struct share_mode_lock" an opaque data structure opened up
only to the code in locking/. This makes it much safer to modify the
data structure with defined accessor functions in share_mode_lock.c.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Nov 10 21:12:48 UTC 2020 on sn-devel-184

4 years agolocking: move share_mode_flags_[gs]et to share_mode_lock.c
Volker Lendecke [Thu, 5 Nov 2020 14:39:51 +0000 (15:39 +0100)] 
locking: move share_mode_flags_[gs]et to share_mode_lock.c

These routines parse and marshall the uint16 summary flag in
share_mode_data. open_file_ntcreate() and open_directory() are the
only real users of this. The user in oplock.c is just the lazy reset
of the "read lease exists somewhere" after asynchronously breaking
read oplocks after a write request.

This moves handling the flags into locking/ to consolidate data
structure handling of "share_mode_data" there.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Avoid references to share_mode_data->id
Volker Lendecke [Thu, 5 Nov 2020 09:42:10 +0000 (10:42 +0100)] 
smbd: Avoid references to share_mode_data->id

When calling open_mode_check() we know the file id. We can pass it to
the lower levels without dereferencing struct share_mode_lock.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Remove a variable used just once
Volker Lendecke [Thu, 5 Nov 2020 09:39:10 +0000 (10:39 +0100)] 
smbd: Remove a variable used just once

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Don't set share_mode_lock modified in grant_new_fsp_lease()
Volker Lendecke [Wed, 4 Nov 2020 14:51:51 +0000 (15:51 +0100)] 
smbd: Don't set share_mode_lock modified in grant_new_fsp_lease()

A new lease never triggers a retry. Setting d->modified to true just
triggered the watchers needlessly.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agonet_tdb: Use share_mode_data_dump()
Volker Lendecke [Wed, 4 Nov 2020 14:28:16 +0000 (15:28 +0100)] 
net_tdb: Use share_mode_data_dump()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolocking: Add share_mode_data_dump() accessor function
Volker Lendecke [Wed, 4 Nov 2020 14:27:56 +0000 (15:27 +0100)] 
locking: Add share_mode_data_dump() accessor function

This is a special case for net tdb dump. The alternative would be to
change the net tdb dump behaviour.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agonet_tdb: Use share_mode_filename()
Volker Lendecke [Wed, 4 Nov 2020 14:12:33 +0000 (15:12 +0100)] 
net_tdb: Use share_mode_filename()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agonet_tdb: Use share_mode_servicepath()
Volker Lendecke [Wed, 4 Nov 2020 14:11:40 +0000 (15:11 +0100)] 
net_tdb: Use share_mode_servicepath()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agonet_tdb: Slightly restructure net_tdb_locking()
Volker Lendecke [Wed, 4 Nov 2020 14:09:40 +0000 (15:09 +0100)] 
net_tdb: Slightly restructure net_tdb_locking()

Remove the net_tdb_locking_fetch() subroutine. All of net_tdb_locking() is
still very simple, and net_tdb_locking_fetch() did the fetch as such plus
parsing the hex key. With this restructuring it was possible to avoid a direct
reference to lck->data->id.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use share_mode_servicepath() in scavenger.c
Volker Lendecke [Wed, 4 Nov 2020 12:46:02 +0000 (13:46 +0100)] 
smbd: Use share_mode_servicepath() in scavenger.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolocking: Add share_mode_servicepath() accessor function
Volker Lendecke [Wed, 4 Nov 2020 12:42:03 +0000 (13:42 +0100)] 
locking: Add share_mode_servicepath() accessor function

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Avoid share_mode_lock dereference in scavenger
Volker Lendecke [Wed, 4 Nov 2020 12:35:26 +0000 (13:35 +0100)] 
smbd: Avoid share_mode_lock dereference in scavenger

Pass "struct file_id" to callees without accessing share_mode_lock
internals

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use share_mode_filename() in scavenger.c
Volker Lendecke [Wed, 4 Nov 2020 12:32:14 +0000 (13:32 +0100)] 
smbd: Use share_mode_filename() in scavenger.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbstatus: Use share_mode_filename()
Volker Lendecke [Wed, 4 Nov 2020 12:20:09 +0000 (13:20 +0100)] 
smbstatus: Use share_mode_filename()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolocking: Add share_mode_filename() accessor function
Volker Lendecke [Wed, 4 Nov 2020 12:19:46 +0000 (13:19 +0100)] 
locking: Add share_mode_filename() accessor function

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>