amitay/samba.git
4 years agoscript/autobuild.py: rm unused mime type text/plain in tasks
Joe Guo [Wed, 22 May 2019 10:17:28 +0000 (22:17 +1200)]
script/autobuild.py: rm unused mime type text/plain in tasks

The mime type `text/plain` is repeated everywhere but not used any more.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoscript/autobuild.py: fix tasks indent
Joe Guo [Wed, 22 May 2019 10:11:28 +0000 (22:11 +1200)]
script/autobuild.py: fix tasks indent

Indent tasks at same level, make it easier to copy/move lines arround.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agogitlab-ci: Add Fedora 30
Andreas Schneider [Mon, 17 Jun 2019 11:18:36 +0000 (13:18 +0200)]
gitlab-ci: Add Fedora 30

Fedora 30 ships with gcc9.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoregfio: Return instead of assert for short blocks
Michael Hanselmann [Thu, 4 Apr 2019 00:26:13 +0000 (02:26 +0200)]
regfio: Return instead of assert for short blocks

Assertions should only be used when there's absolutely no recovery or to
verify data structure invariants. In this case the supplied registry
hive file may have a malformed block with a size of zero. Such a block
should not terminate the whole program.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agosmbd: Remove struct blocking_lock_record
Volker Lendecke [Thu, 20 Jun 2019 18:58:42 +0000 (20:58 +0200)]
smbd: Remove struct blocking_lock_record

Forgot that one in the last patches

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 Jun 20 23:39:34 UTC 2019 on sn-devel-184

4 years agovfs: Remove SMB_VFS_BRL_CANCEL_WINDOWS
Volker Lendecke [Thu, 20 Jun 2019 11:42:12 +0000 (13:42 +0200)]
vfs: Remove SMB_VFS_BRL_CANCEL_WINDOWS

This is not called anymore, bump the VFS version number in a separate
commit

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 Jun 20 18:34:20 UTC 2019 on sn-devel-184

4 years agosmbd: Remove unused brlock code
Volker Lendecke [Thu, 20 Jun 2019 09:07:17 +0000 (11:07 +0200)]
smbd: Remove unused brlock code

No PENDING locks in brlock.tdb anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Cancel smbd_smb1_do_locks requests in reply_ntcancel
Volker Lendecke [Wed, 19 Jun 2019 20:00:25 +0000 (22:00 +0200)]
smbd: Cancel smbd_smb1_do_locks requests in reply_ntcancel

Last link to the specialized brlock queue

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Add a clarifying comment on triggering waiters
Volker Lendecke [Wed, 19 Jun 2019 14:08:49 +0000 (16:08 +0200)]
smbd: Add a clarifying comment on triggering waiters

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Don't call cancel_pending_lock_requests_by_fid on close
Volker Lendecke [Wed, 19 Jun 2019 13:49:46 +0000 (15:49 +0200)]
smbd: Don't call cancel_pending_lock_requests_by_fid on close

We don't use that queue anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Base smb2_lock.c on tevent_req
Volker Lendecke [Sat, 15 Jun 2019 22:23:50 +0000 (15:23 -0700)]
smbd: Base smb2_lock.c on tevent_req

smb2 locking is a lot more regular than reply_lockingX. So this is a
much smaller change.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use smbd_smb1_do_locks_send() in smb_set_posix_lock()
Volker Lendecke [Fri, 14 Jun 2019 22:17:12 +0000 (15:17 -0700)]
smbd: Use smbd_smb1_do_locks_send() in smb_set_posix_lock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use smbd_smb1_do_locks_send() in reply_lockingX()
Volker Lendecke [Thu, 13 Jun 2019 10:59:54 +0000 (03:59 -0700)]
smbd: Use smbd_smb1_do_locks_send() in reply_lockingX()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use smbd_smb1_do_locks_send() in reply_lock()
Volker Lendecke [Thu, 13 Jun 2019 10:56:13 +0000 (03:56 -0700)]
smbd: Use smbd_smb1_do_locks_send() in reply_lock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use smbd_smb1_do_locks_send() in reply_lockread()
Volker Lendecke [Thu, 13 Jun 2019 10:48:31 +0000 (03:48 -0700)]
smbd: Use smbd_smb1_do_locks_send() in reply_lockread()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Remove SMB1 special case handling from brlock.c
Volker Lendecke [Thu, 13 Jun 2019 10:46:01 +0000 (03:46 -0700)]
smbd: Remove SMB1 special case handling from brlock.c

This is now handled in smbd_smb1_do_locks_send/recv.

From here on for a few commits we won't survive make test.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Ping dbwrap_watch on locking.tdb for in smbd_do_unlocking()
Volker Lendecke [Thu, 13 Jun 2019 10:58:02 +0000 (03:58 -0700)]
smbd: Ping dbwrap_watch on locking.tdb for in smbd_do_unlocking()

smbd_smb1_do_locks_send() watches the file's locking.tdb record for
changes, like the oplock code does. Unlocking a byte range thus must
trigger a retry.

With the share mode cache get_existing_share_mode_lock() is pretty
cheap. We have to write out the share mode record with the current
code, but an obvious optimization will be a share_mode_do_locked doing
all this without actually unmarshalling the locking.tdb entry. And --
there's precedence for this pattern in downgrade_lease()...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Add smbd_smb1_do_locks_send/recv()
Volker Lendecke [Thu, 13 Jun 2019 10:38:57 +0000 (03:38 -0700)]
smbd: Add smbd_smb1_do_locks_send/recv()

This contains the SMB1-specific brlock logic. Right now our core
brlock code has specialized code to deal with pending locks. For
dealing with pending requests waiting for something nowadays we
recommend to use tevent_req. This code also provides the basis to
remove the SMB1 special case handling from the core logic, isolating
protocol features specific to SMB1 and not exposed in SMB2 in
SMB1-specific code.

The core brlock code will not see blocking locks anymore. Instead, the
code in this patch will always immediately fail and take care of the
retries and timeouts.

Retries are implemented by a dbwrap_watch_record_send on the
corresponding locking.tdb entry. A later commit will make unlocks
trigger wakeups there. I chose locking.tdb and not brlock itself to
simplify the implementation. We already have oplock break watchers on
locking.tdb, this will only add one more. This might lead to spurious
wakeups, but they are taken care of by careful retries. An advantage
of doing that is the implicit handling of a killed blocker PID through
dbwrap_watch, obsoleting brl_revalidate.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Slightly simplify smbd_smb2_lock_send()
Volker Lendecke [Mon, 27 May 2019 15:03:38 +0000 (17:03 +0200)]
smbd: Slightly simplify smbd_smb2_lock_send()

For unlocking we don't need the error mapping, do an early return

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Return "blocker_pid" from do_lock()
Volker Lendecke [Thu, 20 Jun 2019 10:20:39 +0000 (12:20 +0200)]
smbd: Return "blocker_pid" from do_lock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Add some paranoia against NULL dereference
Volker Lendecke [Thu, 20 Jun 2019 10:42:23 +0000 (12:42 +0200)]
smbd: Add some paranoia against NULL dereference

Quite a few callers set "psmblctx" to NULL, and I could not really
follow 100% that brl_lock only assigns that in the blocking lock
case. Too many layers :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Add "blocker_pid" to brl_lock()
Volker Lendecke [Thu, 20 Jun 2019 10:05:30 +0000 (12:05 +0200)]
smbd: Add "blocker_pid" to brl_lock()

Soon we will wait on a conflicting lock to become free via
dbwrap_watched_watch_send. That routine can take a server_id that
blocks us, watching it to go away. To use that, we need to know which
PID it is that blocks us.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture3: Test cancelling locking&x with ntcancel
Volker Lendecke [Thu, 20 Jun 2019 08:46:21 +0000 (10:46 +0200)]
torture3: Test cancelling locking&x with ntcancel

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmb: Make cli_lockingx cancellable
Volker Lendecke [Wed, 19 Jun 2019 18:47:24 +0000 (20:47 +0200)]
libsmb: Make cli_lockingx cancellable

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture3: Run a blocking lock&x call with a subsequent read
Volker Lendecke [Wed, 19 Jun 2019 15:50:54 +0000 (17:50 +0200)]
torture3: Run a blocking lock&x call with a subsequent read

Samba aborts the read&x after a blocked, but eventually successful
locking&x call. Both Windows and source4/ntvfs do the read properly,
source3/smbd does not. With later code, this will become possible much
easier. Lets see if it's worth it given that we've got away with this
forever.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture3: Test blocking posix locks
Volker Lendecke [Sat, 15 Jun 2019 04:55:09 +0000 (21:55 -0700)]
torture3: Test blocking posix locks

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture3: Test LOCKINGX_CANCEL without locks
Volker Lendecke [Mon, 3 Jun 2019 09:00:25 +0000 (11:00 +0200)]
torture3: Test LOCKINGX_CANCEL without locks

Tested against W2012R2

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture3: Add a test to block a locking&read
Volker Lendecke [Thu, 30 May 2019 08:38:41 +0000 (10:38 +0200)]
torture3: Add a test to block a locking&read

Right now we fail this with smbd, we return LOCK_NOT_GRANTED instead
of FILE_LOCK_CONFLICT. This will change with later commits.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use smbd_do_unlocking() in reply_unlock()
Volker Lendecke [Fri, 14 Jun 2019 12:34:08 +0000 (05:34 -0700)]
smbd: Use smbd_do_unlocking() in reply_unlock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use smbd_do_unlocking() in reply_writeunlock()
Volker Lendecke [Fri, 14 Jun 2019 11:48:58 +0000 (04:48 -0700)]
smbd: Use smbd_do_unlocking() in reply_writeunlock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use smbd_do_unlocking() in smb_set_posix_lock()
Volker Lendecke [Fri, 14 Jun 2019 11:45:05 +0000 (04:45 -0700)]
smbd: Use smbd_do_unlocking() in smb_set_posix_lock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Add "lock_flav" to smbd_do_unlocking()
Volker Lendecke [Fri, 14 Jun 2019 11:39:04 +0000 (04:39 -0700)]
smbd: Add "lock_flav" to smbd_do_unlocking()

The next commits will pass all direct "do_unlock" calls through
smbd_do_unlocking(). Why? Unlocking will later on require that we take
the share mode lock for the file in question while the unlock is
happening, and this should be in one central place.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Simplify smb_set_posix_lock()
Volker Lendecke [Thu, 13 Jun 2019 19:19:35 +0000 (12:19 -0700)]
smbd: Simplify smb_set_posix_lock()

Instead of reading twice from pdata, use a switch statement

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Avoid casts in smb_set_posix_lock()
Volker Lendecke [Thu, 13 Jun 2019 19:12:59 +0000 (12:12 -0700)]
smbd: Avoid casts in smb_set_posix_lock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Use NT_STATUS_IS_OK() in reply_unlock()
Volker Lendecke [Fri, 14 Jun 2019 12:33:03 +0000 (05:33 -0700)]
smbd: Use NT_STATUS_IS_OK() in reply_unlock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Avoid casts in reply_unlock()
Volker Lendecke [Fri, 14 Jun 2019 12:00:35 +0000 (05:00 -0700)]
smbd: Avoid casts in reply_unlock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolib: Fix a typo
Volker Lendecke [Wed, 19 Jun 2019 09:45:30 +0000 (11:45 +0200)]
lib: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Fix a typo
Volker Lendecke [Fri, 14 Jun 2019 17:08:57 +0000 (10:08 -0700)]
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotevent: Fix a typo
Volker Lendecke [Wed, 12 Jun 2019 09:19:32 +0000 (02:19 -0700)]
tevent: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Only remove locks by mid if necessary
Volker Lendecke [Wed, 19 Jun 2019 19:15:38 +0000 (21:15 +0200)]
smbd: Only remove locks by mid if necessary

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agodocs: fix typo in "ntlm auth" doc in smb.conf man page
Björn Baumbach [Wed, 19 Jun 2019 20:35:43 +0000 (22:35 +0200)]
docs: fix typo in "ntlm auth" doc in smb.conf man page

Thanks to Amit Kumar <amitkuma@redhat.com>

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

Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Björn Baumbach <bb@sernet.de>
Autobuild-Date(master): Thu Jun 20 17:14:50 UTC 2019 on sn-devel-184

4 years agodocs: add documentation for the samba-tool ntacl changedomsid command
Björn Baumbach [Wed, 19 Jun 2019 10:22:01 +0000 (12:22 +0200)]
docs: add documentation for the samba-tool ntacl changedomsid command

Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
4 years agoCVE-2019-12436 dsdb/paged_results: ignore successful results without messages
Douglas Bagnall [Fri, 17 May 2019 02:42:24 +0000 (14:42 +1200)]
CVE-2019-12436 dsdb/paged_results: ignore successful results without messages

So that we don't dereference result->msgs[0] when it doesn't exist.
This can happen when the object has changed in such a way that it no
longer matches the original search query.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(master): Wed Jun 19 08:16:39 UTC 2019 on sn-devel-184

4 years agoCVE-2019-12435 rpc/dns: avoid NULL deference if zone not found in DnssrvOperation2
Douglas Bagnall [Wed, 22 May 2019 01:23:25 +0000 (13:23 +1200)]
CVE-2019-12435 rpc/dns: avoid NULL deference if zone not found in DnssrvOperation2

We still want to return DOES_NOT_EXIST when request_filter is not 0.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoCVE-2019-12435 rpc/dns: avoid NULL deference if zone not found in DnssrvOperation
Douglas Bagnall [Wed, 22 May 2019 00:58:01 +0000 (12:58 +1200)]
CVE-2019-12435 rpc/dns: avoid NULL deference if zone not found in DnssrvOperation

We still want to return DOES_NOT_EXIST when request_filter is not 0.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:client: Link smbspool_krb5_wrapper against krb5samba
Andreas Schneider [Tue, 18 Jun 2019 12:43:50 +0000 (14:43 +0200)]
s3:client: Link smbspool_krb5_wrapper against krb5samba

Heimdal doesn't provide krb5_free_unparsed_name(), so we need to use the
function we provide in krb5samba.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Jun 18 18:10:40 UTC 2019 on sn-devel-184

4 years agowafsamba: Use native waf timer
Lukas Slebodnik [Wed, 12 Jun 2019 10:27:04 +0000 (12:27 +0200)]
wafsamba: Use native waf timer

  __main__:1: DeprecationWarning: time.clock has been deprecated in Python 3.3
  and will be removed from Python 3.8: use time.perf_counter
  or time.process_time instead

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

Signed-off-by: Lukas Slebodnik <lslebodn@fedoraproject.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
4 years agoselftest: add tests for samba-tool ntacl changedomsid
Björn Baumbach [Wed, 12 Jun 2019 19:02:43 +0000 (21:02 +0200)]
selftest: add tests for samba-tool ntacl changedomsid

Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Björn Baumbach <bb@sernet.de>
Autobuild-Date(master): Tue Jun 18 16:54:22 UTC 2019 on sn-devel-184

4 years agosamba-tool: add ntacl changedomsid command
Björn Baumbach [Tue, 11 Jun 2019 13:11:20 +0000 (15:11 +0200)]
samba-tool: add ntacl changedomsid command

This tool is meant to locally change all entries in acl_xattr when the
machine's SID has accidentially changed or the data set has been copied
to another box either via backup/restore or rsync.

Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosamba-tool ntacl: consolidate code for getting the local domain sid
Björn Baumbach [Mon, 17 Jun 2019 12:20:56 +0000 (14:20 +0200)]
samba-tool ntacl: consolidate code for getting the local domain sid

Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agopython/ntacls: use correct "state directory" smb.conf option instead of "state dir"
Björn Baumbach [Wed, 12 Jun 2019 19:16:25 +0000 (21:16 +0200)]
python/ntacls: use correct "state directory" smb.conf option instead of "state dir"

samba-tool ntacl get testfile --xattr-backend=tdb --use-ntvfs
Fixes: Unknown parameter encountered: "state dir"
Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agoselftest: add test for samba-tool ntacl get/set --use-ntvfs --xattr-backend=tdb
Björn Baumbach [Wed, 12 Jun 2019 19:00:01 +0000 (21:00 +0200)]
selftest: add test for samba-tool ntacl get/set --use-ntvfs --xattr-backend=tdb

Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Deprecate "blocking locks" parameter
Volker Lendecke [Thu, 13 Jun 2019 19:21:09 +0000 (12:21 -0700)]
smbd: Deprecate "blocking locks" parameter

This parameter adds complexity to our brlock implementation that I don't think
is justified. Not a lot of complexity, but if we would want to really support
it we'd need tests. Instead of doing those, I think removing the parameter is
the better choice.

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 Jun 18 14:47:08 UTC 2019 on sn-devel-184

4 years agosmbd: Slightly simplify smb_set_posix_lock()
Volker Lendecke [Tue, 11 Jun 2019 12:04:39 +0000 (05:04 -0700)]
smbd: Slightly simplify smb_set_posix_lock()

Avoid indentation by an early return;

Best viewed with git show -b

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Add a explanation for num_aio_requests
Volker Lendecke [Mon, 3 Jun 2019 11:41:30 +0000 (13:41 +0200)]
smbd: Add a explanation for num_aio_requests

We could have used talloc_array_length()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Align integer types in reply_lockingX
Volker Lendecke [Mon, 3 Jun 2019 09:16:33 +0000 (11:16 +0200)]
smbd: Align integer types in reply_lockingX

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Avoid casts
Volker Lendecke [Mon, 3 Jun 2019 19:31:26 +0000 (21:31 +0200)]
smbd: Avoid casts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbtorture: Match comment with test
Volker Lendecke [Sun, 2 Jun 2019 10:50:50 +0000 (12:50 +0200)]
smbtorture: Match comment with test

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Fix a typo
Volker Lendecke [Sat, 1 Jun 2019 12:46:55 +0000 (14:46 +0200)]
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: smbd_do_locking() does not use the "type" param anymore
Volker Lendecke [Mon, 3 Jun 2019 09:34:51 +0000 (11:34 +0200)]
smbd: smbd_do_locking() does not use the "type" param anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Simplify smbd_do_locking()
Volker Lendecke [Fri, 31 May 2019 10:19:25 +0000 (12:19 +0200)]
smbd: Simplify smbd_do_locking()

LOCKING_ANDX_CANCEL_LOCK only is used in SMB1. Move its handling out
of the shared smb1/smb2 code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Slightly simplify reply_lockingX()
Volker Lendecke [Thu, 30 May 2019 09:42:16 +0000 (11:42 +0200)]
smbd: Slightly simplify reply_lockingX()

Make the data dependencies more obvious. "locks" and "ulocks" are used
only for short time spans. Any sane compiler will coalesce them to
just one stack variable.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Slightly simplify reply_lockingX()
Volker Lendecke [Thu, 30 May 2019 09:39:10 +0000 (11:39 +0200)]
smbd: Slightly simplify reply_lockingX()

The brltype only depends upon the central locktype, don't calculate it
every time in the loop parsing the lock requests

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Slightly simplify reply_lockingX()
Volker Lendecke [Thu, 30 May 2019 09:31:56 +0000 (11:31 +0200)]
smbd: Slightly simplify reply_lockingX()

Don't do an "else" after an early return

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agolibsmb: Use cli_lockingx() in cli_unlock()
Volker Lendecke [Thu, 30 May 2019 07:52:22 +0000 (09:52 +0200)]
libsmb: Use cli_lockingx() in cli_unlock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agolibsmb: Use cli_lockingx() in cli_locktype()
Volker Lendecke [Thu, 30 May 2019 07:42:36 +0000 (09:42 +0200)]
libsmb: Use cli_lockingx() in cli_locktype()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agolibsmb: Use cli_lockingx() in cli_oplock_ack()
Volker Lendecke [Thu, 30 May 2019 07:25:41 +0000 (09:25 +0200)]
libsmb: Use cli_lockingx() in cli_oplock_ack()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agolibsmb: Add async cli_lockingx()
Volker Lendecke [Wed, 29 May 2019 15:45:19 +0000 (17:45 +0200)]
libsmb: Add async cli_lockingx()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agolibsmb: Remove unused is_andx_req
Volker Lendecke [Thu, 30 May 2019 08:02:47 +0000 (10:02 +0200)]
libsmb: Remove unused is_andx_req

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Use smb1cli_is_andx_req()
Volker Lendecke [Thu, 30 May 2019 08:01:34 +0000 (10:01 +0200)]
smbd: Use smb1cli_is_andx_req()

We have two implementations of this -- use the one from common libs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agolibsmb: Remove unused cli_[un]lock64()
Volker Lendecke [Thu, 30 May 2019 07:55:30 +0000 (09:55 +0200)]
libsmb: Remove unused cli_[un]lock64()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agolibsmb: Align integer types
Volker Lendecke [Thu, 30 May 2019 07:55:11 +0000 (09:55 +0200)]
libsmb: Align integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agosmbd: Avoid a "?true:false" in smbd_do_locking
Volker Lendecke [Sun, 26 May 2019 08:59:01 +0000 (10:59 +0200)]
smbd: Avoid a "?true:false" in smbd_do_locking

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
4 years agolib/replace: Remove #undef TCP_NODELAY
Andrew Bartlett [Tue, 11 Jun 2019 12:44:14 +0000 (14:44 +0200)]
lib/replace: Remove #undef TCP_NODELAY

A duplicate define warning is better than not defining this at all.

Similar to a patch Torsten Werner submitted to the Samba Bugzilla in
2005.

Not tested on HP-UX

reverts fc84e916f628b4fb6f6667ad45d0ced0e9134b23 that was still present in
the new copy of nis.h created in c29d087e1ea4c92717ef86e372fe80f410580fdc

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Jun 18 06:47:05 UTC 2019 on sn-devel-184

4 years agoautobuild: Fix autobuild for python3
Volker Lendecke [Fri, 14 Jun 2019 12:55:03 +0000 (14:55 +0200)]
autobuild: Fix autobuild for python3

"keys()" in python3 returns an unmodifiable view object. Two lines
down we might want to modify it, which python3 does not allow.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild unused parm ldb_kv
Gary Lockyer [Wed, 12 Jun 2019 20:49:16 +0000 (08:49 +1200)]
lib ldb ldb_key_value: csbuild unused parm ldb_kv

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_search.c: scope_hint: In
function ‘search_func’ lib/ldb/ldb_key_value/ldb_kv_search.c:308:47:
warning: unused parameter ‘ldb_kv’ [-Wunused-parameter]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Jun 13 08:27:12 UTC 2019 on sn-devel-184

4 years agolib ldb_key_value: csbuild unused parm key
Gary Lockyer [Fri, 7 Jun 2019 03:25:50 +0000 (15:25 +1200)]
lib ldb_key_value: csbuild unused parm key

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c: scope_hint: In function ‘re_pack’
lib/ldb/ldb_key_value/ldb_kv_index.c:3416:21: warning: unused parameter
‘key’ [-Wunused-parameter]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild fix unused parm data
Gary Lockyer [Fri, 7 Jun 2019 03:22:45 +0000 (15:22 +1200)]
lib ldb ldb_key_value: csbuild fix unused parm data

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c: scope_hint: In function
‘delete_index’
lib/ldb/ldb_key_value/ldb_kv_index.c:3221:19: warning: unused parameter
‘data’ [-Wunused-parameter]

Tags unused parameters in callback delete_index with _UNUSED_

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild fix signed unsigned compare
Gary Lockyer [Fri, 7 Jun 2019 03:19:25 +0000 (15:19 +1200)]
lib ldb ldb_key_value: csbuild fix signed unsigned compare

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c: scope_hint: In function
‘ldb_kv_index_add1’
lib/ldb/ldb_key_value/ldb_kv_index.c:2601:15: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild unused parms ldb_kv, key
Gary Lockyer [Fri, 7 Jun 2019 03:17:01 +0000 (15:17 +1200)]
lib ldb ldb_key_value: csbuild unused parms ldb_kv, key

Fixes csbuild errors.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c: scope_hint: In function
‘traverse_range_index’
lib/ldb/ldb_key_value/ldb_kv_index.c:1653:56: warning: unused parameter
‘ldb_kv’ [-Wunused-parameter]

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c:1654:20: warning: unused parameter
‘key’ [-Wunused-parameter]

Tags unused parameters in the callback function traverse_range_index with
_UNUSED_

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild ldb_kv_index_dn_not unused parms
Gary Lockyer [Fri, 7 Jun 2019 03:12:11 +0000 (15:12 +1200)]
lib ldb ldb_key_value: csbuild ldb_kv_index_dn_not unused parms

Fixes csbuild errors.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c: scope_hint: In function
‘ldb_kv_index_dn_not’
lib/ldb/ldb_key_value/ldb_kv_index.c:1503:51: warning: unused parameter
‘module’ [-Wunus ed-parameter]

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c:1504:34: warning: unused parameter
‘ldb_kv’ [-Wunused-parameter]

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c:1505:40: warning: unused parameter
‘tree’ [-Wunused-parameter]

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c:1506:27: warning: unused parameter
‘list’ [-Wunused-parameter]

Tag unused parameters in ldb_kv_index_dn_not with _UNUSED_

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild unused parm ldb
Gary Lockyer [Fri, 7 Jun 2019 02:57:19 +0000 (14:57 +1200)]
lib ldb ldb_key_value: csbuild unused parm ldb

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c: scope_hint: In function
‘list_intersect’
lib/ldb/ldb_key_value/ldb_kv_index.c:1275:48: warning: unused parameter
‘ldb’ [-Wunused-parameter]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild unused parm tdb
Gary Lockyer [Fri, 7 Jun 2019 02:54:03 +0000 (14:54 +1200)]
lib ldb ldb_key_value: csbuild unused parm tdb

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c: scope_hint: In function
‘ldb_kv_index_traverse_store’
lib/ldb/ldb_key_value/ldb_kv_index.c:779:60: warning: unused parameter
‘tdb’ [-Wunused-parameter]

By tagging the tdb_context parameter in ldb_kv_index_traverse_store as
_UNUSED_

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild fix integer comparison
Gary Lockyer [Fri, 7 Jun 2019 02:48:53 +0000 (14:48 +1200)]
lib ldb ldb_key_value: csbuild fix integer comparison

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv_index.c: scope_hint: In function
‘ldb_kv_key_dn_from_idx’
lib/ldb/ldb_key_value/ldb_kv_index.c:545:15: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild unused parm ldb_kv_timeout
Gary Lockyer [Fri, 7 Jun 2019 02:45:31 +0000 (14:45 +1200)]
lib ldb ldb_key_value: csbuild unused parm ldb_kv_timeout

Fixes csbuild errors.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv.c: scope_hint: In function ‘ldb_kv_timeout’
lib/ldb/ldb_key_value/ldb_kv.c:1675:51: warning: unused parameter ‘ev’
[-Wunused-parameter]

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv.c:1676:28: warning: unused parameter ‘te’
[-Wunused-parameter]

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv.c:1677:22: warning: unused parameter ‘t’
[-Wunused-parameter]

Tag the unused variables in ldb_kv_timeout with _UNUSED_

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb: csbuild add lib/util/attr.h to dist
Gary Lockyer [Wed, 12 Jun 2019 20:51:05 +0000 (08:51 +1200)]
lib ldb: csbuild add lib/util/attr.h to dist

Add lib/util/attr.h to the ldb distribution, to make the _UNUSED_ macro
available.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild unused parm ldb_kv
Gary Lockyer [Fri, 7 Jun 2019 02:38:59 +0000 (14:38 +1200)]
lib ldb ldb_key_value: csbuild unused parm ldb_kv

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv.c:158:33: warning: unused parameter
‘ldb_kv’ [-Wunused-parameter]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild unused parm module
Gary Lockyer [Fri, 7 Jun 2019 02:34:44 +0000 (14:34 +1200)]
lib ldb ldb_key_value: csbuild unused parm module

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv.c: scope_hint: In function
‘ldb_kv_guid_to_key’
lib/ldb/ldb_key_value/ldb_kv.c:157:43: warning: unused parameter
‘module’ [-Wunused-parameter]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib ldb ldb_key_value: csbuild unused parm module
Gary Lockyer [Fri, 7 Jun 2019 02:29:44 +0000 (14:29 +1200)]
lib ldb ldb_key_value: csbuild unused parm module

Fixes csbuild error.

Error: COMPILER_WARNING:
lib/ldb/ldb_key_value/ldb_kv.c: scope_hint: In function ‘ldb_kv_key_dn’
lib/ldb/ldb_key_value/ldb_kv.c:109:49: warning: unused parameter
‘module’ [-Wunused-para
meter]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolib audit_logging tests: csbuild unused parms
Gary Lockyer [Fri, 7 Jun 2019 02:21:41 +0000 (14:21 +1200)]
lib audit_logging tests: csbuild unused parms

Fixes csbuild unused parameter error:
   warning: unused parameter ‘state’
   warning: unused parameter ‘argc’
   warning: unused parameter ‘argv’

By adding _UNUSED_ to paramter declaration.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoauth auth_log: csbuild unused parm transport_protection
Gary Lockyer [Fri, 7 Jun 2019 01:53:58 +0000 (13:53 +1200)]
auth auth_log: csbuild unused parm transport_protection

Fixes csbuild errors.

Error: COMPILER_WARNING:
auth/auth_log.c: scope_hint: In function
‘log_successful_authz_event_human_readable’
auth/auth_log.c:728:14: warning: unused parameter ‘transport_protection’
[-Wunused-param
eter]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoauth auth_log: csbuild unused parm unix_username
Gary Lockyer [Fri, 7 Jun 2019 01:41:35 +0000 (13:41 +1200)]
auth auth_log: csbuild unused parm unix_username

Fixes csbuild errors

Error: COMPILER_WARNING:
auth/auth_log.c: scope_hint: In function ‘log_authentication_event_json’
auth/auth_log.c:146:14: warning: unused parameter ‘unix_username’
[-Wunused-parameter]

Error: COMPILER_WARNING:
auth/auth_log.c: scope_hint: In function
‘log_authentication_event_human_readable’
auth/auth_log.c:586:14: warning: unused parameter ‘unix_username’
[-Wunused-parameter]

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agotorture: Use two connections in SMB2 sharemode tests
Christof Schmitt [Mon, 3 Jun 2019 18:51:14 +0000 (11:51 -0700)]
torture: Use two connections in SMB2 sharemode tests

This allows using the unclist option to specify multiple targets, e.g.
for testing against multiple nodes in a clustered Samba environment.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jun 12 20:02:26 UTC 2019 on sn-devel-184

4 years agolibcli/smb: harden smbXcli_session_shallow_copy against nonce reusage
Stefan Metzmacher [Tue, 11 Jun 2019 15:44:04 +0000 (17:44 +0200)]
libcli/smb: harden smbXcli_session_shallow_copy against nonce reusage

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jun 12 13:56:19 UTC 2019 on sn-devel-184

4 years agolibcli/smb: s/smbXcli_session_copy/smbXcli_session_shallow_copy
Stefan Metzmacher [Tue, 11 Jun 2019 15:42:38 +0000 (17:42 +0200)]
libcli/smb: s/smbXcli_session_copy/smbXcli_session_shallow_copy

We should make clear that this is a function for testing only,
with possible strange side effects.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agos4:torture: force signing in the smb2.session.bind1 test
Stefan Metzmacher [Fri, 7 Jun 2019 17:38:26 +0000 (19:38 +0200)]
s4:torture: force signing in the smb2.session.bind1 test

This test is supposed to test which signing keys are used on
each of the channels, so it's important to require signing.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agolibcli/smb: only fallback to the global smb2 signing key if we should sign
Andreas Schneider [Fri, 7 Jun 2019 17:00:25 +0000 (19:00 +0200)]
libcli/smb: only fallback to the global smb2 signing key if we should sign

We should only sign if we're asked for it. The signing keys are
always generated, so we were always using global signing key
and signed with it when signing was not asked for.

By luck this was the correct signing key for the 1st channel.

But multi channel connections where broken is the server nor the client
require/desire signing. It seems the tests only ever run against
Windows domain controllers, which always require signing.

Note that the following code in smb2cli_req_create() makes
sure that we always sign session binds:

  if (cmd == SMB2_OP_SESSSETUP &&
      !smb2_signing_key_valid(session->smb2_channel.signing_key) &&
      smb2_signing_key_valid(session->smb2->signing_key))
  {
          /*
           * a session bind needs to be signed
           */
          state->smb2.should_sign = true;
  }

This removed a logic changed introduced in commit
17e22e020fcb84fb9ddda350915369dc9ea28ef1. As

  if (!smb2_signing_key_valid(signing_key)) {

is not the same as:

  if (signing_key && signing_key->length == 0) {

it's the same as:

  if (signing_key == NULL || signing_key->length == 0) {

so we need:

  if (signing_key != NULL && !smb2_signing_key_valid(signing_key)) {

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
4 years agolibcli/smb: make sure the session->{smb2->,smb2_channel.}signing_key is never NULL!
Stefan Metzmacher [Fri, 7 Jun 2019 16:58:43 +0000 (18:58 +0200)]
libcli/smb: make sure the session->{smb2->,smb2_channel.}signing_key is never NULL!

Before commit 17e22e020fcb84fb9ddda350915369dc9ea28ef1 they we not a
pointer and always be present.

We used the local pointer variable 'signing_key = NULL' and logic like
this:

    if (state->smb2.should_sign) {
        signing_key = state->session->smb2_channel.signing_key;
    }

    if (signing_key != NULL ...

In order to keep this we need to nake sure
state->session->smb2_channel.signing_key is never NULL!

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoRevert "libcli:smb: Fix signing with multichannel"
Stefan Metzmacher [Tue, 11 Jun 2019 15:47:33 +0000 (17:47 +0200)]
Revert "libcli:smb: Fix signing with multichannel"

This reverts commit 1817db965dc0caf55e4308fa4d9203ab4381dc90.

This was pushed to fast, the corrected commit follows.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoRevert "libcli/smb: add missing struct smb2_signing_key allocation in smb2cli_session...
Stefan Metzmacher [Tue, 11 Jun 2019 15:47:24 +0000 (17:47 +0200)]
Revert "libcli/smb: add missing struct smb2_signing_key allocation in smb2cli_session_set_channel_key()"

This reverts commit 08750166542f46644038d1ff9d839b270436addf.

This was pushed to fast, the corrected commit follows.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>