samba.git
4 years agoctdb: Make TDB_SEQNUM work synchronously with ctdb
Volker Lendecke [Mon, 20 May 2019 14:01:03 +0000 (16:01 +0200)]
ctdb: Make TDB_SEQNUM work synchronously with ctdb

Old war story completely from memory, I could not find the commit that
introduced TDB_SEQNUM so far...:

Back in the days when ctdb was initially developed, TDB_SEQNUM's only
user was the notify.tdb that held one huge record for all notify
records. With that use case in mind it made perfect sense to keep the
SEQNUM stable locally, sacrificing precision. By now notify.tdb is
long gone, an the only user of TDB_SEQNUM right now is brlock.tdb,
which contains special case code for the imprecise ctdb implementation
of TDB_SEQNUM.

With this commit, that special code can go: The TDB_SEQNUM will also
increment when just the DMASTER header field changes, indicating to
smbd that someone else might have changed the record. This will of
course increase the SEQNUM frequency, but it should not increase the
load on ctdb: If you look at the brlock.c workaround, it just does not
do the caching that is possible with precise TDB_SEQNUMs working.

How did I get here? I want to move brl_num_read_oplocks() from
brlock.tdb into locking.tdb, and for that I need precise TDB_SEQNUMs
for locking.tdb.

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 May 24 00:42:17 UTC 2019 on sn-devel-184

4 years agovfs_fruit: change trigger points of AppleDouble conversion
Ralph Boehme [Tue, 21 May 2019 14:00:53 +0000 (16:00 +0200)]
vfs_fruit: change trigger points of AppleDouble conversion

This moves the trigger points where AppleDouble file conversion is run by
ad_convert() from deep down the callchain in ad_read_rsrc_adouble() to high
level VFS entry points.

Currently ad_convert() will be triggered as part of open_file_ntcreate(...,
"file:AFP_AfpResource", ...): after SMB_VFS_OPEN() has been called with O_CREAT,
what created the file, we call SMB_VFS_FSTAT() on the just created
filehandle. This ends up in ad_convert(), finds the resource fork empty and thus
deletes the file.

This commit moves calling of the conversion funtion to the high level VFS entry
points where the converted metadata is needed:

o for directory enumerations SMB_VFS_READDIR_ATTR() is called to fill in the
  repurposed fields in the directory entry metadata

o obviously for SMB_VFS_CREATE_FILE() on an macOS stream

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: add a forward declaration for ad_get()
Ralph Boehme [Tue, 21 May 2019 14:00:00 +0000 (16:00 +0200)]
vfs_fruit: add a forward declaration for ad_get()

Will be needed in the next commit.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agoselftest: run vfs.fruit test against a share that deletes empty resource forks
Ralph Boehme [Tue, 21 May 2019 12:05:04 +0000 (14:05 +0200)]
selftest: run vfs.fruit test against a share that deletes empty resource forks

This reveals a bug in the AppleDouble conversion code: the conversion code that
unlinks an empty resource fork AppleDouble sidecar file ("._file") gets
triggered as part of open_file_ntcreate(..., "file:AFP_AfpResource", ...):

after SMB_VFS_OPEN() has been called with O_CREAT, what created the file, we
call SMB_VFS_FSTAT() on the just created filehandle. This ends up in
ad_convert(), finds the resource fork empty and thus deletes the file.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agos4:torture/vfs/fruit: ensure test_adouble_conversion_wo_xattr() uses a non-emtpy...
Ralph Boehme [Tue, 21 May 2019 16:39:52 +0000 (18:39 +0200)]
s4:torture/vfs/fruit: ensure test_adouble_conversion_wo_xattr() uses a non-emtpy resourcefork

This ensures the resource fork is not deleted as part of the AppleDouble file
conversion for the option fruit:wipe_intentionally_left_blank_rfork=yes.

This is currently not a problem in selftest, as we don't enable the option, but
a subsequent commit will run all vfs.fruit tests against a share with this
option enabled.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agos4:torture/vfs/fruit: ensure test_adouble_conversion() uses a non-emtpy resourcefork
Ralph Boehme [Tue, 21 May 2019 16:39:52 +0000 (18:39 +0200)]
s4:torture/vfs/fruit: ensure test_adouble_conversion() uses a non-emtpy resourcefork

This ensures the resource fork is not deleted as part of the AppleDouble file
conversion for the option fruit:wipe_intentionally_left_blank_rfork=yes.

This is currently not a problem in selftest, as we don't enable the option, but
a subsequent commit will run all vfs.fruit tests against a share with this
option enabled.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibsmbconf:registry: Return correct case for get_share
Christof Schmitt [Wed, 15 May 2019 23:05:26 +0000 (16:05 -0700)]
libsmbconf:registry: Return correct case for get_share

get_share (called from 'net conf showshare') does a lookup of the share
name case-insensitively. As the registry stores the share name in the
correct case and 'net conf list' prints the correct case, also lookup
the correct case for get_share.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agonet: Return share name in correct case from net rpc conf showshare
Christof Schmitt [Tue, 21 May 2019 18:11:56 +0000 (11:11 -0700)]
net: Return share name in correct case from net rpc conf showshare

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agoselftest: Add test for case-preserving in 'net [rpc] conf showshare'
Christof Schmitt [Wed, 15 May 2019 22:55:00 +0000 (15:55 -0700)]
selftest: Add test for case-preserving in 'net [rpc] conf showshare'

Add a test to verify that 'net [rpc] conf showshare' returns the correct
upper/lower case.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agoctdb: Remove unused ctdb_ltdb_fetch_with_header()
Volker Lendecke [Mon, 20 May 2019 13:12:56 +0000 (15:12 +0200)]
ctdb: Remove unused ctdb_ltdb_fetch_with_header()

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 May 23 18:08:36 UTC 2019 on sn-devel-184

4 years agosmbd: Calculate delay_mask only once in delay_for_oplock
Volker Lendecke [Fri, 17 May 2019 13:29:59 +0000 (15:29 +0200)]
smbd: Calculate delay_mask only once in delay_for_oplock

"const" ist just a hint to make sure it's actually not modified inside
the loop

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotdb: Fix typo in README
Volker Lendecke [Mon, 20 May 2019 12:55:31 +0000 (14:55 +0200)]
tdb: Fix typo in README

README is far from a complete, good and accurate document, but what's
in there should at least not have obvious errors.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Merge "print_lock_struct" into one DBG
Volker Lendecke [Mon, 20 May 2019 11:52:12 +0000 (13:52 +0200)]
smbd: Merge "print_lock_struct" into one DBG

Also, avoid some casts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosambaundoguididx: Add flags=ldb.FLG_DONT_CREATE_DB and port to Python3
Andrew Bartlett [Mon, 20 May 2019 04:29:10 +0000 (16:29 +1200)]
sambaundoguididx: Add flags=ldb.FLG_DONT_CREATE_DB and port to Python3

In py3 we need to add an extra str() around the returned ldb value to
enable .split() to be used.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed By: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Thu May 23 14:25:52 UTC 2019 on sn-devel-184

4 years agothird_party: Update nss_wrapper to version 1.1.6
Andreas Schneider [Tue, 21 May 2019 06:00:05 +0000 (08:00 +0200)]
third_party: Update nss_wrapper to version 1.1.6

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu May 23 11:10:28 UTC 2019 on sn-devel-184

4 years agos3:smbspool: Use NTSTATUS return codes
Andreas Schneider [Tue, 14 May 2019 09:35:46 +0000 (11:35 +0200)]
s3:smbspool: Use NTSTATUS return codes

This allows us to simplify some code and return better errors.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agos3:smbspool: Add debug messages to kerberos_ccache_is_valid()
Andreas Schneider [Thu, 16 May 2019 16:24:32 +0000 (18:24 +0200)]
s3:smbspool: Add debug messages to kerberos_ccache_is_valid()

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agos3:smbspool: Always try to authenticate using Kerberos
Andreas Schneider [Mon, 13 May 2019 16:54:02 +0000 (18:54 +0200)]
s3:smbspool: Always try to authenticate using Kerberos

If username and password is given, then fallback to NTLM. However try
kinit first. Also we correctly handle NULL passwords in the meantime and
this makes it easier to deal with issues.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agos3:smbspool: Print the filename we failed to open
Andreas Schneider [Mon, 13 May 2019 14:48:31 +0000 (16:48 +0200)]
s3:smbspool: Print the filename we failed to open

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agos3:smbspool: Fallback to default ccache if KRB5CCNAME is not set
Andreas Schneider [Thu, 16 May 2019 15:40:43 +0000 (17:40 +0200)]
s3:smbspool: Fallback to default ccache if KRB5CCNAME is not set

This could also support the new KCM credential cache storage.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agos3:smbspool: Use %u format specifier to print uid
Andreas Schneider [Thu, 16 May 2019 15:10:57 +0000 (17:10 +0200)]
s3:smbspool: Use %u format specifier to print uid

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agos3:smbspool: Add debug for finding KRB5CCNAME
Andreas Schneider [Thu, 16 May 2019 12:25:00 +0000 (14:25 +0200)]
s3:smbspool: Add debug for finding KRB5CCNAME

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agos3:smbspool: Print the principal we use to authenticate with
Andreas Schneider [Thu, 16 May 2019 11:41:02 +0000 (13:41 +0200)]
s3:smbspool: Print the principal we use to authenticate with

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agos3:smbspool: Add the 'lp' group to the users groups
Andreas Schneider [Mon, 13 May 2019 14:55:49 +0000 (16:55 +0200)]
s3:smbspool: Add the 'lp' group to the users groups

This is required to access files in /var/spool/cups which have been
temporarily created in there by CUPS.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
4 years agosmbd: Fix a panic
Volker Lendecke [Tue, 21 May 2019 13:26:55 +0000 (15:26 +0200)]
smbd: Fix a panic

Opening a file with a stale (smbd died) LEVEL_II oplock makes

vfs_set_filelen-> ... ->contend_level2_oplocks_begin_default

trigger the immediate leading to do_break_to_none. This goes through
because fsp->oplock_type is not initialized yet, thus 0. Also,
file_has_read_oplocks is still valid, because the smbd that has died
could not clean up the brlock.tdb entry.

Later in the code the exclusive oplock is granted, which is then found
by do_break_to_none, making it panic.

This patch just runs the direct FTRUNCATE instead of vfs_set_filelen.
This means the contend_level2_oplock code is skipped.

The relevant break (LEVEL_II to NONE) is now done in delay_for_oplock()
with the nice effect of removing a comment that was very confusing to
me.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13957
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed May 22 20:09:29 UTC 2019 on sn-devel-184

4 years agosmbtorture: Add a test to make smbd panic
Volker Lendecke [Tue, 21 May 2019 12:53:46 +0000 (14:53 +0200)]
smbtorture: Add a test to make smbd panic

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13957
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agosmbd: Enable "smbd:suicide mode" for smb2
Volker Lendecke [Tue, 21 May 2019 12:52:22 +0000 (14:52 +0200)]
smbd: Enable "smbd:suicide mode" for smb2

The next commit needs an smbd to just exit and leave data behind in the
locking.tdb file. Don't make it harder to eventually phase out SMB1: Do
the test in SMB2.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13957
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos4-ntvfs: Remove untested ntvfs_cifsposix backend
Andrew Bartlett [Tue, 21 May 2019 01:57:57 +0000 (13:57 +1200)]
s4-ntvfs: Remove untested ntvfs_cifsposix backend

It had a note:

WARNING: All file access is done as user root!!!
         Only use this module for testing, with only test data!!!

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 May 22 07:15:43 UTC 2019 on sn-devel-184

4 years agos4-ntvfs: Remove untested stub vfs_print backend
Andrew Bartlett [Tue, 21 May 2019 01:55:16 +0000 (13:55 +1200)]
s4-ntvfs: Remove untested stub vfs_print backend

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agontvfs: Remove unused and untested SMB1 -> SMB2 proxy module
Andrew Bartlett [Mon, 6 May 2019 03:12:56 +0000 (15:12 +1200)]
ntvfs: Remove unused and untested SMB1 -> SMB2 proxy module

While this could have been a very interesting idea (particularly
if it allowed our main SMB server to disable SMB1), it has never
been enabled in our testsuite so relying on it would be quite
brave.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agontvfs: Remove unused nbench vfs module
Andrew Bartlett [Mon, 6 May 2019 03:07:52 +0000 (15:07 +1200)]
ntvfs: Remove unused nbench vfs module

A pass-though NTVFS module to write nbench files is a cute idea,
but this is untested and almost certainly unused.

Found by looking at the LCOV results.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agolibcli/ldap: Remove unsued ldap_transaction()
Andrew Bartlett [Tue, 21 May 2019 03:42:39 +0000 (15:42 +1200)]
libcli/ldap: Remove unsued ldap_transaction()

This is unsued since a87dea2a0894015cf4a3140995791f5468c40038 in 2007
when we moved to using LDB for LDAP in this area of the code.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agolibcli/security: Remove unused dup_sec_desc_buf()
Andrew Bartlett [Tue, 21 May 2019 03:03:06 +0000 (15:03 +1200)]
libcli/security: Remove unused dup_sec_desc_buf()

This has been unused since before
762e7e1dff89cc14b0130fc9a22038b0845630a2 in 2003.

Found by callcatcher

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agolib: Remove "tdb based replacement for gettext"
Andrew Bartlett [Tue, 21 May 2019 02:59:00 +0000 (14:59 +1200)]
lib: Remove "tdb based replacement for gettext"

This is unused since SWAT was removed in Samba 4.1

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agos4-rpc_server: Remove unused dnsserver_find_partition()
Andrew Bartlett [Tue, 21 May 2019 02:41:06 +0000 (14:41 +1200)]
s4-rpc_server: Remove unused dnsserver_find_partition()

This has been unused since it was introduced by
5673e2cec946502da84956f866658718e7632a3e in 2011.

Found by callcatcher

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agolibcli/auth: Remove des_crypt64() from smbdes
Andrew Bartlett [Tue, 21 May 2019 02:35:52 +0000 (14:35 +1200)]
libcli/auth: Remove des_crypt64() from smbdes

This has been unused since it was introduced by
ad8b47a2ba4e81420bc2272e8438a727cc2223ee in 2006

Found by callcatcher

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agodsdb: Remove unsued dsdb_class_by_cn()
Andrew Bartlett [Tue, 21 May 2019 02:24:43 +0000 (14:24 +1200)]
dsdb: Remove unsued dsdb_class_by_cn()

The callers moved to dsdb_class_by_cn_ldb_val() with
43aa546ecc3f05845793b1a7354685d50a77c170 in 2009.

Found by callcatcher

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoRemove unused auth_get_challenge_not_implemented
Andrew Bartlett [Tue, 21 May 2019 02:15:36 +0000 (14:15 +1200)]
Remove unused auth_get_challenge_not_implemented

This became unused after eba87995145b0e14672c1f6993f7aa3422d62541 in 2012

Found by callcatcher

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoMakefile: add lcov command
Joe Guo [Thu, 16 May 2019 02:38:25 +0000 (14:38 +1200)]
Makefile: add lcov command

A helper cmd to generate .info file from .gcno and .gcda file,
and then generate html report from .info file.

Usage:

./configure --enable-coverage
make -j
make test TESTS=mytest
make lcov

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldb: ldbdump key and pack format version comments
Aaron Haslett [Mon, 20 May 2019 04:19:51 +0000 (16:19 +1200)]
ldb: ldbdump key and pack format version comments

For testing we need to know the actual KV level key of records and each
record's pack format version. This patch makes ldbdump add comments with
that info. We will parse it out in python tests.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed May 22 05:58:17 UTC 2019 on sn-devel-184

4 years agoldb: ldb_key_value_test fix
Aaron Haslett [Fri, 17 May 2019 01:27:20 +0000 (13:27 +1200)]
ldb: ldb_key_value_test fix

In future commits we'll be adding more logging to LDB, which breaks the
ldb_key_value_test suite. By removing the debug handler, a bug
involving an expired debug_string variable being written to is avoided.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldb: removing unnecessary module pointer
Aaron Haslett [Wed, 15 May 2019 22:53:38 +0000 (10:53 +1200)]
ldb: removing unnecessary module pointer

We want to reuse the reindex context struct for repacking, but it has an
unnecessary module pointer on it. Turns out the existing code doesn't
need it either, so this patch deletes the pointer.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldb: Release ldb 2.0.2
Aaron Haslett [Tue, 21 May 2019 00:34:38 +0000 (12:34 +1200)]
ldb: Release ldb 2.0.2

 * Checking pack format is version 1 and erroring if not (will change soon)
 * Pack format routines for unpack and pack version 2 (but not used)
 * Test fixes for issues caused by upcoming repack functionality for upgrade
 * Making ldbdump print out pack format info and keys so we have low level visibility for testing in python

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldb: pack function for new pack format
Aaron Haslett [Fri, 10 May 2019 06:10:55 +0000 (18:10 +1200)]
ldb: pack function for new pack format

Pack function for new pack format with values separated from other data
so that while unpacking, the value section (which is probably large)
doesn't have to be loaded into cache/memory.
The new format is disabled for now.
Two tests are added that operate on a detailed binary breakdown of the
new format.

NOTE: Configure with --abi-check-disable to build this commit. This
patch is part of a set of LDB ABI changes, and the version update is
done on the last commit.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldb: unpack function for new pack format
Aaron Haslett [Wed, 1 May 2019 01:36:36 +0000 (13:36 +1200)]
ldb: unpack function for new pack format

Unpack function for new pack format with values separated from other
data so that while unpacking, the value section (which is probably large)
doesn't have to be loaded into cache/memory.
Additionally, width of length field can now vary per-element to save space.
The old unpack routine is still present and is called if the old pack
format version number is found.
LDB torture suite is modified to run relevant tests on both old and new
pack format.

NOTE: Configure with --abi-check-disable to build this commit. This
patch is part of a set of LDB ABI changes, and the version update is
done on the last commit.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldb: replacing length increments with constants in pack
Aaron Haslett [Tue, 21 May 2019 03:18:10 +0000 (15:18 +1200)]
ldb: replacing length increments with constants in pack

Since we're about to introduce a new packing format, it's a good time to
improve our code style and change some magic numbers into explicit
constants.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldb: push and pull macros for pack format
Aaron Haslett [Fri, 17 May 2019 04:34:52 +0000 (16:34 +1200)]
ldb: push and pull macros for pack format

Replacing push and pull functions (which may cause issues with Undefined
Sanitizer) with Andreas Schneider's excellent macros which are a work in
progress and not yet merged into master. Once his work is upstream, I'll
rebase and change this code to import his headers.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldb: baseinfo pack format check on init
Aaron Haslett [Fri, 10 May 2019 06:10:51 +0000 (18:10 +1200)]
ldb: baseinfo pack format check on init

We will be adding a new packing format in forthcoming commits and there
may be more versions in the future. We need to make sure the database
contains records in a format we know how to read and write.
Done by fetching the @BASEINFO record and reading the first 4
bytes which contain the packing format version.

NOTE: Configure with --abi-check-disable to build this commit. This
patch is part of a set of LDB ABI changes, and the version update is
done on the last commit.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agos4 librpc rpc pyrpc: Fix flapping dcerpc.bare tests
Gary Lockyer [Tue, 21 May 2019 23:43:54 +0000 (11:43 +1200)]
s4 librpc rpc pyrpc: Fix flapping dcerpc.bare tests

Commit d65b7641c84976c543ded8f0de5ab2da3c19b407 had the parameters to
talloc_reparent reversed.  This caused the dcerpc.bare tests to flap.

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Wed May 22 03:03:43 UTC 2019 on sn-devel-184

4 years agolib:crypto: Remove obsolete MD5 and HMAC MD5
Andreas Schneider [Tue, 6 Nov 2018 16:22:53 +0000 (17:22 +0100)]
lib:crypto: Remove obsolete MD5 and HMAC MD5

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue May 21 01:18:08 UTC 2019 on sn-devel-184

4 years agos4:torture: Use GnuTLS MD5 for samba3rpc
Andreas Schneider [Tue, 6 Nov 2018 16:13:23 +0000 (17:13 +0100)]
s4:torture: Use GnuTLS MD5 for samba3rpc

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:torture: Use GnuTLS MD5 for samr password
Andreas Schneider [Tue, 6 Nov 2018 15:30:39 +0000 (16:30 +0100)]
s4:torture: Use GnuTLS MD5 for samr password

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:torture: Use GnuTLS MD5 in samr password tests
Andreas Schneider [Tue, 6 Nov 2018 16:07:24 +0000 (17:07 +0100)]
s4:torture: Use GnuTLS MD5 in samr password tests

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:torture: Use GnuTLS MD5 in ntp_signd test
Andreas Schneider [Tue, 6 Nov 2018 16:00:59 +0000 (17:00 +0100)]
s4:torture: Use GnuTLS MD5 in ntp_signd test

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:torture: Use GnuTLS MD5 and HMAC MD5 in samlogon test
Andreas Schneider [Tue, 30 Oct 2018 15:52:26 +0000 (16:52 +0100)]
s4:torture: Use GnuTLS MD5 and HMAC MD5 in samlogon test

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:torture: Use GnuTLS MD5
Andreas Schneider [Mon, 5 Nov 2018 17:26:02 +0000 (18:26 +0100)]
s3:torture: Use GnuTLS MD5

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:messaging: Use GnuTLS MD5 in messaging test
Andreas Schneider [Tue, 6 Nov 2018 11:49:35 +0000 (12:49 +0100)]
s4:messaging: Use GnuTLS MD5 in messaging test

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:rpc_server: Use GnuTLS MD5 for samr password
Andreas Schneider [Tue, 6 Nov 2018 15:30:39 +0000 (16:30 +0100)]
s4:rpc_server: Use GnuTLS MD5 for samr password

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:ntp_signd: Use GnuTLS MD5 in signd
Andreas Schneider [Tue, 6 Nov 2018 15:25:00 +0000 (16:25 +0100)]
s4:ntp_signd: Use GnuTLS MD5 in signd

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:libnet: Use GnuTLS MD5 for samr passwords
Andreas Schneider [Tue, 6 Nov 2018 14:13:40 +0000 (15:13 +0100)]
s4:libnet: Use GnuTLS MD5 for samr passwords

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:libcli: Use GnuTLS MD5 for smb singing
Andreas Schneider [Tue, 6 Nov 2018 13:42:17 +0000 (14:42 +0100)]
s3:libcli: Use GnuTLS MD5 for smb singing

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:dsdb: Use GnuTLS MD5 in password_hash module
Andreas Schneider [Mon, 5 Nov 2018 17:31:35 +0000 (18:31 +0100)]
s4:dsdb: Use GnuTLS MD5 in password_hash module

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:rpc_client: Use GnuTLS MD5 for samr
Andreas Schneider [Mon, 5 Nov 2018 17:10:55 +0000 (18:10 +0100)]
s3:rpc_client: Use GnuTLS MD5 for samr

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:profile: Use GnuTLS MD5
Andreas Schneider [Mon, 5 Nov 2018 17:03:51 +0000 (18:03 +0100)]
s3:profile: Use GnuTLS MD5

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:vfs: Use GnuTLS MD5 in vfs_fruit
Andreas Schneider [Mon, 5 Nov 2018 16:58:37 +0000 (17:58 +0100)]
s3:vfs: Use GnuTLS MD5 in vfs_fruit

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:vfs: Use GnuTLS MD5 in vfs_streams_xattr
Andreas Schneider [Mon, 5 Nov 2018 16:41:42 +0000 (17:41 +0100)]
s3:vfs: Use GnuTLS MD5 in vfs_streams_xattr

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3:smbd: Return NTSTATUS for srv_calculate_sign_mac()
Andreas Schneider [Thu, 11 Apr 2019 08:22:26 +0000 (10:22 +0200)]
s3:smbd: Return NTSTATUS for srv_calculate_sign_mac()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoauth:gensec: Return NTSTATUS for netsec_do_seq_num()
Andreas Schneider [Thu, 11 Apr 2019 08:43:13 +0000 (10:43 +0200)]
auth:gensec: Return NTSTATUS for netsec_do_seq_num()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoauth:gensec: Use GnuTLS HMAC MD5 and MD5 in netsec_do_sign()
Andreas Schneider [Wed, 15 May 2019 06:33:18 +0000 (08:33 +0200)]
auth:gensec: Use GnuTLS HMAC MD5 and MD5 in netsec_do_sign()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoauth:gensec: Use GnuTLS HMAC MD5 in netsec_do_seal()
Andreas Schneider [Wed, 15 May 2019 06:32:58 +0000 (08:32 +0200)]
auth:gensec: Use GnuTLS HMAC MD5 in netsec_do_seal()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoauth:gensec: Use GnuTLS HMAC MD5 in netsec_do_seq_num()
Andreas Schneider [Wed, 15 May 2019 06:32:24 +0000 (08:32 +0200)]
auth:gensec: Use GnuTLS HMAC MD5 in netsec_do_seq_num()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoauth:creds: Use GnuTLS MD5 in ntlm creds
Andreas Schneider [Tue, 30 Oct 2018 15:56:54 +0000 (16:56 +0100)]
auth:creds: Use GnuTLS MD5 in ntlm creds

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoauth:ntlmssp: Use GnuTLS MD5 and HMAC MD5 in ntlmssp sign
Andreas Schneider [Tue, 30 Oct 2018 15:43:03 +0000 (16:43 +0100)]
auth:ntlmssp: Use GnuTLS MD5 and HMAC MD5 in ntlmssp sign

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoauth:ntlmssp: Use GnuTLS MD5 and HMAC MD5 in ntlmssp server
Andreas Schneider [Tue, 30 Oct 2018 09:31:11 +0000 (10:31 +0100)]
auth:ntlmssp: Use GnuTLS MD5 and HMAC MD5 in ntlmssp server

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoauth:ntlmssp: Use GnuTLS HMAC MD5 in ntlmssp client
Andreas Schneider [Tue, 30 Oct 2018 08:31:19 +0000 (09:31 +0100)]
auth:ntlmssp: Use GnuTLS HMAC MD5 in ntlmssp client

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:smb: Return NTSTATUS for smb_key_derivation()
Andreas Schneider [Thu, 11 Apr 2019 08:29:04 +0000 (10:29 +0200)]
libcli:smb: Return NTSTATUS for smb_key_derivation()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:smb: Check return code of smb_signing_md5()
Andreas Schneider [Thu, 11 Apr 2019 08:24:49 +0000 (10:24 +0200)]
libcli:smb: Check return code of smb_signing_md5()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:smb: Return NTSTATUS for smb_signing_sign_pdu()
Andreas Schneider [Thu, 11 Apr 2019 08:19:16 +0000 (10:19 +0200)]
libcli:smb: Return NTSTATUS for smb_signing_sign_pdu()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:smb: Return NTSTATUS for smb_signing_md5()
Andreas Schneider [Thu, 11 Apr 2019 08:14:43 +0000 (10:14 +0200)]
libcli:smb: Return NTSTATUS for smb_signing_md5()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:smb: Use GnuTLS HMAC MD5 in smb_key_derivation()
Andreas Schneider [Wed, 15 May 2019 06:09:35 +0000 (08:09 +0200)]
libcli:smb: Use GnuTLS HMAC MD5 in smb_key_derivation()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:smb: Use GnuTLS MD5 and HMAC MD5 in smb_signing_md5()
Andreas Schneider [Mon, 29 Oct 2018 17:16:09 +0000 (18:16 +0100)]
libcli:smb: Use GnuTLS MD5 and HMAC MD5 in smb_signing_md5()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:drsuapi: Use GnuTLS MD5 in drsuapi_encrypt_attribute_value()
Andreas Schneider [Wed, 15 May 2019 06:08:15 +0000 (08:08 +0200)]
libcli:drsuapi: Use GnuTLS MD5 in drsuapi_encrypt_attribute_value()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:drsuapi: Use GnuTLS MD5 in drsuapi_decrypt_attribute_value()
Andreas Schneider [Wed, 15 May 2019 06:07:32 +0000 (08:07 +0200)]
libcli:drsuapi: Use GnuTLS MD5 in drsuapi_decrypt_attribute_value()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Add return codes for netlogon_creds_init_128bit()
Andreas Schneider [Thu, 6 Dec 2018 13:49:40 +0000 (14:49 +0100)]
libcli:auth: Add return codes for netlogon_creds_init_128bit()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 and HMAC MD5 in netlogon_creds_init_128bit
Andreas Schneider [Fri, 26 Oct 2018 12:59:58 +0000 (14:59 +0200)]
libcli:auth: Use GnuTLS MD5 and HMAC MD5 in netlogon_creds_init_128bit

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use 'bool ok' in ntv2_owf_gen()
Andreas Schneider [Tue, 4 Dec 2018 08:49:17 +0000 (09:49 +0100)]
libcli:auth: Use 'bool ok' in ntv2_owf_gen()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 HMAC in SMBsesskeygen_ntv2()
Andreas Schneider [Wed, 15 May 2019 06:25:36 +0000 (08:25 +0200)]
libcli:auth: Use GnuTLS MD5 HMAC in SMBsesskeygen_ntv2()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 HMAC in SMBOWFencrypt_ntv2()
Andreas Schneider [Wed, 15 May 2019 06:05:38 +0000 (08:05 +0200)]
libcli:auth: Use GnuTLS MD5 HMAC in SMBOWFencrypt_ntv2()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 HMAC in ntv2_owf_gen()
Andreas Schneider [Wed, 15 May 2019 06:05:11 +0000 (08:05 +0200)]
libcli:auth: Use GnuTLS MD5 HMAC in ntv2_owf_gen()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 in decode_wkssvc_join_password_buffer()
Andreas Schneider [Wed, 15 May 2019 06:04:08 +0000 (08:04 +0200)]
libcli:auth: Use GnuTLS MD5 in decode_wkssvc_join_password_buffer()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 in encode_or_decode_arc4_passwd_buffer()
Andreas Schneider [Wed, 15 May 2019 06:02:59 +0000 (08:02 +0200)]
libcli:auth: Use GnuTLS MD5 in encode_or_decode_arc4_passwd_buffer()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 in encode_wkssvc_join_password_buffer()
Andreas Schneider [Wed, 15 May 2019 06:03:31 +0000 (08:03 +0200)]
libcli:auth: Use GnuTLS MD5 in encode_wkssvc_join_password_buffer()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 in encode_or_decode_arc4_passwd_buffer()
Andreas Schneider [Wed, 15 May 2019 06:02:59 +0000 (08:02 +0200)]
libcli:auth: Use GnuTLS MD5 in encode_or_decode_arc4_passwd_buffer()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibcli:auth: Use GnuTLS MD5 for E_md5hash() in smbcrypt
Andreas Schneider [Wed, 15 May 2019 06:02:18 +0000 (08:02 +0200)]
libcli:auth: Use GnuTLS MD5 for E_md5hash() in smbcrypt

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agotorture: Address flapping samba4.rpc.altercontext test
Andrew Bartlett [Wed, 15 May 2019 04:07:16 +0000 (16:07 +1200)]
torture: Address flapping samba4.rpc.altercontext test

NT_STATUS_CONNECTION_DISCONNECTED and NT_STATUS_CONNECTION_RESET are
equivilent for the purposes of this test, both come from the server
shutting down the connection, the difference comes from two different
unix error numbers that can come from this.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon May 20 05:17:42 UTC 2019 on sn-devel-184

4 years agoldap_server: Run ldapsrv_queue_reply() in the ldb callback, rather than waiting for...
Andrew Bartlett [Wed, 3 Apr 2019 04:11:01 +0000 (17:11 +1300)]
ldap_server: Run ldapsrv_queue_reply() in the ldb callback, rather than waiting for the full result

Based on earlier work by Garming Sam.

This allows the server to stop working on a reply that will never
be sent to the client as it is too large.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldap_server: chunk the writev() calls at 25MB
Andrew Bartlett [Tue, 14 May 2019 00:08:03 +0000 (12:08 +1200)]
ldap_server: chunk the writev() calls at 25MB

This should limit the amount we send to GENSEC at a
time where it may help avoid large realloc or memcpy calls.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldap_server: Add explict repsonse size limit of 256MB
Andrew Bartlett [Wed, 8 May 2019 02:03:50 +0000 (14:03 +1200)]
ldap_server: Add explict repsonse size limit of 256MB

This allows us to replace the implicit limit via data_blob_append()
removed in the previous commit.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldap_server: Use an array of struct iovec to avoid data_blob_append()
Andrew Bartlett [Thu, 4 Apr 2019 04:25:30 +0000 (17:25 +1300)]
ldap_server: Use an array of struct iovec to avoid data_blob_append()

This avoids a the implicit 256MB limit on LDAP replies (allowing this
to be increased in the future) and means we copy less memory around.

However because we can only have 1024 entries in a struct iovec (on Linux)
we will need to call tstream_writev_queue_send() multiple times.

Calling it in chunks of 1024 seems a reasonable compromise, the
gensec layer will chunk it out smaller if required.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
4 years agoldap_server: Run the ldap_encode() step in ldapsrv_queue_reply()
Andrew Bartlett [Thu, 4 Apr 2019 03:52:17 +0000 (16:52 +1300)]
ldap_server: Run the ldap_encode() step in ldapsrv_queue_reply()

This avoids holding the memory for the response twice,
by the time the result is queued it is only ASN.1 encoded.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>