samba.git
7 months agotests/samba-tool: test dns serverinfo/zoneinfo
Douglas Bagnall [Wed, 29 May 2019 01:38:12 +0000 (13:38 +1200)]
tests/samba-tool: test dns serverinfo/zoneinfo

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
7 months agos3/smbd: cppcheck: Fix ctunullpointer error
Noel Power [Tue, 21 May 2019 13:36:45 +0000 (13:36 +0000)]
s3/smbd: cppcheck: Fix ctunullpointer error

Fixes:

source3/smbd/files.c:783: error: ctunullpointer: Null pointer dereference: buf <--[cppcheck]

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agos3/printing: cppcheck avoid 'nullPointerArithmetic:' error
Noel Power [Tue, 21 May 2019 11:56:06 +0000 (12:56 +0100)]
s3/printing: cppcheck avoid 'nullPointerArithmetic:' error

source3/printing/notify.c:94: error: nullPointerArithmetic: Pointer addition with NULL pointer. <--[cppcheck]
/home/samba/samba-pidl/source3/printing/notify.c:96: error: nullPointerArithmetic: Pointer addition with NULL pointer. <--[cppcheck]
/home/samba/samba-pidl/source3/printing/notify.c:103: error: nullPointerArithmetic: Pointer addition with NULL pointer. <--[cppcheck]

flatten_message function depends on behaviour of tdb_pack which will
return the bytes that would be written (without actually writing to the
buffer) if the bufsize passed is <=0. What we need to avoid here is the
default modification of buf (when it is initially NULL)

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agos3/lib: don't write to buffer (which might be NULL) if bufsize <=0
Noel Power [Tue, 21 May 2019 13:08:15 +0000 (13:08 +0000)]
s3/lib: don't write to buffer (which might be NULL) if bufsize <=0

Some code depends that tdb_pack[va] will return the bytes it would
write to 'buf' if the bufsize passed in is <=0, writing to the
buffer is protected by with lines like
   if (bufsize && bufsize >= len) {
      /* write to 'buf' */
   }

however in these instances the local pointer to the buffer is still
modified
   buf += len;

It's quite probable if bufsize == 0 that buf itself is NULL,
in this case we should protect against performing pointer arithmetic.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agos3/lib/netapi: Fix 'Possible null pointer dereference' warning
Noel Power [Tue, 21 May 2019 11:00:42 +0000 (11:00 +0000)]
s3/lib/netapi: Fix 'Possible null pointer dereference' warning

source3/lib/netapi/localgroup.c:1103: warning: nullPointer: Possible null pointer dereference: r <--[cppcheck]

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agos3/libads: cppcheck fix error: shiftTooManyBitsSigned: error
Noel Power [Tue, 21 May 2019 10:52:56 +0000 (10:52 +0000)]
s3/libads: cppcheck fix error: shiftTooManyBitsSigned: error

Squash 'Shifting signed 32-bit value by 31 bits is undefined behaviour'
error

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agolib/util: Fix cppcheck null pointer dereference warning
Noel Power [Tue, 21 May 2019 10:48:18 +0000 (10:48 +0000)]
lib/util: Fix cppcheck null pointer dereference warning

lib/util/talloc_report.c:58: warning: nullPointer: Possible null pointer dereference: start <--[cppcheck]

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb: Release ldb 2.0.3
Aaron Haslett [Fri, 24 May 2019 03:34:43 +0000 (15:34 +1200)]
ldb: Release ldb 2.0.3

* Default pack format changed to version 2 for GUID Indexed databases
  (essentially Samba's sam.ldb). This means faster unpacking for records
  with lots of attributes.

* Enforce link between all new database features, following toggling of
  GUID indexing. If user toggles GUID indexing on/off, target pack format
  is changed. Likewise the special ORDERED_INTEGER index format is used
  (when GUID indexing on) or behaves like INTEGER (when GUID indexing off).

* Database repacked if packing format not as expected.

* In the case of MDB, since GUID indexing is mandatory, feature toggling
  provided by pack_format_override LDB option.

* Check for errors from ldb_unpack_data() in ldb_tdb

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed May 29 05:56:59 UTC 2019 on sn-devel-184

7 months agodowngradedatabase: blackbox: MDB backend
Aaron Haslett [Fri, 24 May 2019 02:54:03 +0000 (14:54 +1200)]
downgradedatabase: blackbox: MDB backend

When Samba uses TDB as a backend store, all new database features are
toggled on/off when GUID indexing is toggled. But, GUID indexing can't
be disabled on MDB, so the other features are toggled separately.
Consequently, the downgradedatabase script behaves differently depending
on the database backend. This patch adds testing for the MDB behaviour.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

7 months agodowngradedatabase: adding special case for MDB
Aaron Haslett [Thu, 23 May 2019 08:06:56 +0000 (20:06 +1200)]
downgradedatabase: adding special case for MDB

Though this script was initially written for undoing GUID indexing on
TDB databases, we're repurposing it to do a full downgrade of any
database. MDB databases can't be DN indexed, but they can have pack
format version 2 and ORDERED_INTEGER data types, which must be removed
during a downgrade.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

7 months agodsdb: disable ORDERED_INTEGER with MDB pack format v1
Aaron Haslett [Thu, 23 May 2019 08:13:05 +0000 (20:13 +1200)]
dsdb: disable ORDERED_INTEGER with MDB pack format v1

For TDB databases, the new ORDERED_INTEGER type is disabled along with
repacking at format version 1 if GUID indexing is disabled, so all the new
database features are toggled together. This scheme doesn't work with
MDB because GUID indexing is mandatory when using MDB. However, a
downgrade path is still required so in a previous commit we added
a pack_format_override option which allows a downgrade script to force
the database to use an earlier packing format. But, the new
ORDERED_INTEGER type would still be present in MDB databases so this
patch reads the pack_format_override opaque and converts ORDERED_INTEGER
types in @ATTRIBUTES to INTEGER and doesn't write any indexes of that
type to @INDEXLIST. The @INDEXLIST will be refreshed later, on the first
transaction.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

7 months agoldb: pack_format_override option
Aaron Haslett [Thu, 23 May 2019 07:49:39 +0000 (19:49 +1200)]
ldb: pack_format_override option

For TDB databases, toggling GUID indexing mode will also toggle
pack format version 2. This provides a convenient downgrade path for
Samba databases, but the process doesn't work for MDB databases because
GUID indexing cannot be disabled when the MDB backend is used. This patch
addresses that corner case by providing support for a pack_format_override
option which will force the database to use pack format version 2.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

7 months agodowngradedatabase: blackbox: database repacked
Aaron Haslett [Thu, 23 May 2019 02:42:35 +0000 (14:42 +1200)]
downgradedatabase: blackbox: database repacked

Now that the database is repacked when GUID indexing is toggled on TDB,
test that downgradedatabase repacks a TDB-backed database with V2 pack
format database with V1.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agoldb: python test for repack
Aaron Haslett [Mon, 20 May 2019 05:59:33 +0000 (17:59 +1200)]
ldb: python test for repack

Python test to confirm that after enabling or disabling GUID indexing,
the database is repacked on the next transaction with V1 if GUID
indexing was disabled, or V2 if it was enabled.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agoldb: repack old format database if GUID indexing enabled
Aaron Haslett [Mon, 13 May 2019 04:37:25 +0000 (16:37 +1200)]
ldb: repack old format database if GUID indexing enabled

VERY IMPORTANT PATCH
Now that we have a new packing format, we need to enable it by repacking
the database. We've decided to link all new database features together,
so once GUID indexing is enabled, the database will be repacked with
version 2 format. Repacking is done following the same iterate pattern as
reindexing.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agodowngradedatabase: blackbox: check ordered integer removed
Aaron Haslett [Thu, 23 May 2019 02:35:22 +0000 (14:35 +1200)]
downgradedatabase: blackbox: check ordered integer removed

Test that when we undo GUID indexing on a TDB-backed database with
downgradedatabase, ORDERED_INTEGER is removed from @ATTRIBUTES

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agoldb: binding ordered indexes to GUID indexing
Aaron Haslett [Wed, 22 May 2019 02:07:19 +0000 (14:07 +1200)]
ldb: binding ordered indexes to GUID indexing

To reduce the number of potential combinations of database features in
ldb, we want to link all new database features since 4.7. GUID indexing,
ordered integers, and pack format changes will all upgrade together.
This patch makes ordered integers only function if GUID indexing is
enabled. If GUID indexing is disabled, ORDERED_INTEGER will not be
written to @ATTRIBUTES and a syntax's index_format_fn will never be
used.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agoldb: only used a->syntax->index_format_fn if GUID indexing is enabled
Aaron Haslett [Tue, 28 May 2019 01:00:43 +0000 (13:00 +1200)]
ldb: only used a->syntax->index_format_fn if GUID indexing is enabled

Only enable ORDERED_INTEGER and index_format_fn functionality if GUID
indexing is enabled.  This is in line with the rest of ldb_kv which binds
the new ORDERED_INTEGER to GUID indexed databases, and allows a practical
way to create the old index format (by disabling the GUID index).

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

7 months agodowngradedatabase: blackbox test
Aaron Haslett [Thu, 23 May 2019 01:21:19 +0000 (13:21 +1200)]
downgradedatabase: blackbox test

This test confirms that running downgradedatabase causes all GUID keys to be
replaced with DN keys at the KV level

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agosambadowngradedatabase: Add "or later" to warning about using tools from Samba 4.8
Andrew Bartlett [Wed, 29 May 2019 04:36:00 +0000 (16:36 +1200)]
sambadowngradedatabase: Add "or later" to warning about using tools from Samba 4.8

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agosambaundoguididx: renamed to downgradedatabase
Aaron Haslett [Fri, 24 May 2019 02:37:50 +0000 (14:37 +1200)]
sambaundoguididx: renamed to downgradedatabase

In forthcoming commits we're going to repurpose this script to do an
entire downgrade of a database, disabling all new database features.
downgradedatabase is a more appropriate name.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agosambaundoguididx: fix for -s
Andrew Bartlett [Mon, 20 May 2019 04:29:10 +0000 (16:29 +1200)]
sambaundoguididx: fix for -s

Quick fix running this script with -s instead of -H. samdb_url() returns
a url with a protocol prefix, which causes issues further down in the
script.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agoldb: Fix segfault parsing new pack formats
Andrew Bartlett [Wed, 22 May 2019 04:38:08 +0000 (16:38 +1200)]
ldb: Fix segfault parsing new pack formats

We need to check for the errors given by ldb_unpack() et al by preserving
the error code from kv_ctx->parser() called by tdb_parse_record() in
ltdb_parse_record().

Otherwise we will silently accept corrupt records and segfault later.

Likewise new pack formats will confuse the parser but not be
detected except by the incomplete struct ldb_message.

With this patch, the user will see a message like:

 Invalid data for index  DN=@BASEINFO

 Failed to connect to 'st/ad_dc/private/sam.ldb' with backend 'tdb': Unable to load ltdb cache records for backend 'ldb_tdb backend'
 Failed to connect to st/ad_dc/private/sam.ldb - Unable to load ltdb cache records for backend 'ldb_tdb backend'

This can be refined in the future by a specific check for
pack format versions in a higher caller, but this much is
needed regardless to detect corrupt records.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agoldb: test for parse errors
Aaron Haslett [Tue, 28 May 2019 05:22:10 +0000 (17:22 +1200)]
ldb: test for parse errors

Parse errors aren't passed up correctly by the tdb backend. This
patch modifies a test to expose the issue, next patch will fix it.

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

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
7 months agosmbd: Adapt brl_pending_overlap to README.Coding
Volker Lendecke [Mon, 27 May 2019 14:21:12 +0000 (16:21 +0200)]
smbd: Adapt brl_pending_overlap to README.Coding

Just reformatting, no behaviour change. This just looked too ugly to me.

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

7 months agosmbd: Avoid casts in smbd_smb2_lock_send()
Volker Lendecke [Mon, 27 May 2019 14:15:17 +0000 (16:15 +0200)]
smbd: Avoid casts in smbd_smb2_lock_send()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Avoid casts in do_unlock()
Volker Lendecke [Mon, 27 May 2019 11:49:34 +0000 (13:49 +0200)]
smbd: Avoid casts in do_unlock()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Avoid casts in smbd_do_unlocking()
Volker Lendecke [Mon, 27 May 2019 11:45:59 +0000 (13:45 +0200)]
smbd: Avoid casts in smbd_do_unlocking()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Align integer types in smbd_do_unlocking()
Volker Lendecke [Mon, 27 May 2019 11:45:42 +0000 (13:45 +0200)]
smbd: Align integer types in smbd_do_unlocking()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Simplify an if-expression in smbd_do_locking()
Volker Lendecke [Mon, 27 May 2019 11:45:10 +0000 (13:45 +0200)]
smbd: Simplify an if-expression in smbd_do_locking()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbtorture: Fix a typo
Volker Lendecke [Tue, 28 May 2019 14:54:34 +0000 (16:54 +0200)]
smbtorture: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Use tevent_req_simple_recv_ntstatus() in smbd_smb2_lock_recv()
Volker Lendecke [Tue, 28 May 2019 15:00:30 +0000 (17:00 +0200)]
smbd: Use tevent_req_simple_recv_ntstatus() in smbd_smb2_lock_recv()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Avoid casts in smbd_do_locking()
Volker Lendecke [Tue, 21 May 2019 07:17:24 +0000 (09:17 +0200)]
smbd: Avoid casts in smbd_do_locking()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Fix a typo
Volker Lendecke [Tue, 21 May 2019 18:37:30 +0000 (20:37 +0200)]
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Factor out fsps_lease_update()
Volker Lendecke [Fri, 24 May 2019 14:50:30 +0000 (16:50 +0200)]
smbd: Factor out fsps_lease_update()

Less lines of code, less .text bytes with -O3

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Simplify fsp_lease_update()
Volker Lendecke [Fri, 24 May 2019 13:58:09 +0000 (15:58 +0200)]
smbd: Simplify fsp_lease_update()

We don't need a share mode lock from a data dependency point of view
anymore, the leases data moved to leases.tdb. However, from a
coherency point of view it's probably wise to do this under a share
mode lock.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Use "fsp->lease" instead of "lease"
Volker Lendecke [Fri, 24 May 2019 13:50:02 +0000 (15:50 +0200)]
smbd: Use "fsp->lease" instead of "lease"

See the SMB_ASSERT a few lines above. Why this? It makes the next
commit more obvious.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Fix a typo
Volker Lendecke [Fri, 24 May 2019 12:46:19 +0000 (14:46 +0200)]
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agodbwrap: Use sizeof, not an integer constant
Volker Lendecke [Fri, 24 May 2019 12:37:20 +0000 (14:37 +0200)]
dbwrap: Use sizeof, not an integer constant

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agobrlock: Remove clustering special case
Volker Lendecke [Sun, 26 May 2019 06:20:47 +0000 (08:20 +0200)]
brlock: Remove clustering special case

With e7424897a127 we don't need this special case for clustering
anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Fix a typo
Volker Lendecke [Mon, 27 May 2019 09:48:13 +0000 (11:48 +0200)]
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agolib: Fix CID 1445648 Null pointer dereferences
Volker Lendecke [Tue, 28 May 2019 06:49:52 +0000 (08:49 +0200)]
lib: Fix CID 1445648 Null pointer dereferences

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agos3:mdssvc: fix flex compilation error
Ralph Boehme [Mon, 27 May 2019 10:27:57 +0000 (12:27 +0200)]
s3:mdssvc: fix flex compilation error

[4440/4495] Compiling bin/default/source3/rpc_server/mdssvc/sparql_lexer.lex.c
../../source3/rpc_server/mdssvc/sparql_lexer.l:26: error: "yyalloc" redefined [-Werror]
26 | #define yyalloc SMB_MALLOC

Looks like the dirty redefine trick doesn't work anymore with newer flex
versions. According to the flex manual the right thing to do is to provide own
functions for yyalloc and yyrealloc when passing the options "noyyalloc
noyyrealloc".

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue May 28 11:49:06 UTC 2019 on sn-devel-184

7 months agobootstrap: add mingw packages
Stefan Metzmacher [Thu, 23 May 2019 13:01:52 +0000 (15:01 +0200)]
bootstrap: add mingw packages

This makes sure we at least compile the example/winexe code

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agowinexe: Use C99 initializer for poptOption in winexe.c
Stefan Metzmacher [Thu, 23 May 2019 07:16:51 +0000 (09:16 +0200)]
winexe: Use C99 initializer for poptOption in winexe.c

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agodbcheck: fallback to the default tombstoneLifetime of 180 days
Stefan Metzmacher [Mon, 29 Apr 2019 09:59:50 +0000 (11:59 +0200)]
dbcheck: fallback to the default tombstoneLifetime of 180 days

If a domain was provisioned by Windows 2000 this value is missing in the
database.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue May 28 08:32:10 UTC 2019 on sn-devel-184

7 months agopython/ntacls: we only need security.SEC_STD_READ_CONTROL in order to get the ACL
Stefan Metzmacher [Fri, 26 Apr 2019 15:07:20 +0000 (17:07 +0200)]
python/ntacls: we only need security.SEC_STD_READ_CONTROL in order to get the ACL

We should avoid security.SEC_FLAG_MAXIMUM_ALLOWED otherwise
we may get NT_STATUS_SHARING_VIOLATION when we run
'samba-tool domain backup online' against a Windows DC.
Windows DCs have hidden folders for the NtFrs or Dfsr services,
which are locked by the running service.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agodsdb:audit_log: avoid printing "... remote host [Unknown] SID [(NULL SID)] ..."
Stefan Metzmacher [Fri, 26 Apr 2019 14:31:46 +0000 (14:31 +0000)]
dsdb:audit_log: avoid printing "... remote host [Unknown] SID [(NULL SID)] ..."

We better print "... remote host [Unknown] SID [S-1-5-18] ..."
in 'dsdb_audit' message, this matches what we print for
'dsdb_json_audit'.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agolib/util: set current_msg_{level,class} also during a DEBUGADD[C]() call
Stefan Metzmacher [Fri, 26 Apr 2019 11:40:58 +0000 (13:40 +0200)]
lib/util: set current_msg_{level,class} also during a DEBUGADD[C]() call

In some situations we use DEBUGADDC() in order to print out content
without a related debug header line.

This is important with the new per class logfile with:

 log level = 1 dsdb_json_audit:10@/var/log/samba/log.dsdb_json_audit

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agolib/util: remove unused prototypes in debug.h
Stefan Metzmacher [Fri, 26 Apr 2019 11:32:43 +0000 (13:32 +0200)]
lib/util: remove unused prototypes in debug.h

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agolib/util: fix call to dbghdrclass() for DEBUGC()
Stefan Metzmacher [Fri, 26 Apr 2019 11:21:15 +0000 (13:21 +0200)]
lib/util: fix call to dbghdrclass() for DEBUGC()

dbghdrclass() sets the global 'current_msg_class' and for that
DEBUGC() should pass the given dbgc_class instead of the per file
DBGC_CLASS.

This is important with the new per class logfile with:

 log level = 1 dsdb_audit:10@/var/log/samba/log.dsdb_audit

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agoregistry: add a missing include
Ralph Boehme [Thu, 16 May 2019 14:05:31 +0000 (16:05 +0200)]
registry: add a missing include

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon May 27 14:29:36 UTC 2019 on sn-devel-184

7 months agos3: winbind: Fix crash when invoking winbind idmap scripts.
Jeremy Allison [Thu, 23 May 2019 20:33:21 +0000 (13:33 -0700)]
s3: winbind: Fix crash when invoking winbind idmap scripts.

Previously the private context was caching a pointer to
a string returned from lp_XXX(). This string can change
on config file reload. Ensure the string is talloc_strup'ed
onto the owning context instead.

Reported by Heinrich Mislik <Heinrich.Mislik@univie.ac.at>

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agoFix ubsan null pointer passed as argument 2
Gary Lockyer [Thu, 23 May 2019 23:00:05 +0000 (11:00 +1200)]
Fix ubsan null pointer passed as argument 2

Fix ubsan warning null pointer passed as argument 2 when the source
pointer is NULL.  The calls to memcpy are now guarded by an
if (len > 0)

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Mon May 27 01:29:48 UTC 2019 on sn-devel-184

7 months agolib: Only compile resolvconftest if fmemopen exists
Volker Lendecke [Thu, 23 May 2019 09:11:11 +0000 (11:11 +0200)]
lib: Only compile resolvconftest if fmemopen exists

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13961
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat May 25 00:05:25 UTC 2019 on sn-devel-184

7 months agodocs: dfree command. Correct usage of dfree scripts.
Jeremy Allison [Sat, 18 May 2019 18:41:56 +0000 (11:41 -0700)]
docs: dfree command. Correct usage of dfree scripts.

Add quotes to the sample scripts to prevent incorrect
parameter usage.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May 24 20:12:02 UTC 2019 on sn-devel-184

7 months agolib: util: Finally remove possibilities of using sys_popen() unsafely.
Jeremy Allison [Sat, 18 May 2019 18:40:26 +0000 (11:40 -0700)]
lib: util: Finally remove possibilities of using sys_popen() unsafely.

All code now uses sys_popenv() which is much
harder to use incorrectly.

Remove the extract_args() function that was the
cause of possible issues.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: lib: Rename all uses of file_pload_XXX -> file_ploadv_XXX.
Ralph Boehme [Fri, 24 May 2019 17:08:10 +0000 (19:08 +0200)]
s3: lib: Rename all uses of file_pload_XXX -> file_ploadv_XXX.

Keep naming consistent across all usage.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: lib: Remove file_pload_send().
Jeremy Allison [Sat, 18 May 2019 18:32:05 +0000 (11:32 -0700)]
s3: lib: Remove file_pload_send().

No longer used.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: winbind: Convert idmap to use file_ploadv_send().
Jeremy Allison [Sat, 18 May 2019 18:25:01 +0000 (11:25 -0700)]
s3: winbind: Convert idmap to use file_ploadv_send().

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: lib: Add file_ploadv_send().
Jeremy Allison [Sat, 18 May 2019 18:18:19 +0000 (11:18 -0700)]
s3: lib: Add file_ploadv_send().

Not yet used. Preparing to remove file_pload_send()
with this safer alternative.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agolib: util: Remove file_pload()
Jeremy Allison [Sat, 18 May 2019 18:14:53 +0000 (11:14 -0700)]
lib: util: Remove file_pload()

No longer used.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: lib: Remove file_lines_pload().
Jeremy Allison [Sat, 18 May 2019 18:10:40 +0000 (11:10 -0700)]
s3: lib: Remove file_lines_pload().

No longer used.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: smbd: Convert sysquotas.c code to use file_lines_ploadv().
Jeremy Allison [Sat, 18 May 2019 18:08:15 +0000 (11:08 -0700)]
s3: smbd: Convert sysquotas.c code to use file_lines_ploadv().

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: smbd: Convert print_svid code to use file_lines_ploadv().
Jeremy Allison [Fri, 17 May 2019 05:18:40 +0000 (22:18 -0700)]
s3: smbd: Convert print_svid code to use file_lines_ploadv().

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: smbd: Convert dfree code to use file_lines_ploadv().
Jeremy Allison [Fri, 17 May 2019 05:11:49 +0000 (22:11 -0700)]
s3: smbd: Convert dfree code to use file_lines_ploadv().

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3: lib: util: Add file_lines_ploadv().
Jeremy Allison [Fri, 17 May 2019 05:10:51 +0000 (22:10 -0700)]
s3: lib: util: Add file_lines_ploadv().

Not yet used.

Duplicate code to file_lines_pload() except uses vectored
argument list. file_lines_pload() will be removed once all
callers are converted.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agolib: util: Add file_ploadv().
Jeremy Allison [Fri, 17 May 2019 04:56:13 +0000 (21:56 -0700)]
lib: util: Add file_ploadv().

Not yet used.

Duplicate code to file_pload() except uses vectored
argument list. file_pload() will be removed once all
callers are converted.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agolib: popen: Prepare to remove sys_popen().
Jeremy Allison [Fri, 17 May 2019 04:45:21 +0000 (21:45 -0700)]
lib: popen: Prepare to remove sys_popen().

Add sys_popenv(char * const argl[]) that uses a NULL
terminated vector array of args. Change sys_popen() to
split up its command string and call sys_popenv().

Once all callers are converted to sys_popenv() we
can remove sys_popen().

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agodocs: Add another dns forwarder in the example.
Karolin Seeger [Tue, 21 May 2019 08:41:22 +0000 (10:41 +0200)]
docs: Add another dns forwarder in the example.

Clarify how to list several dns forwarders.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
Reviewed-by: Björn Baumbach <bb@samba.org>
Autobuild-User(master): Björn Baumbach <bb@sernet.de>
Autobuild-Date(master): Fri May 24 11:02:18 UTC 2019 on sn-devel-184

7 months agos3:lib: Move up NULL check
Andreas Schneider [Mon, 20 May 2019 14:21:00 +0000 (16:21 +0200)]
s3:lib: Move up NULL check

Found by covscan.

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): Fri May 24 07:23:42 UTC 2019 on sn-devel-184

7 months agos3:utils: Only declare variables if we're gonna use them
Andreas Schneider [Mon, 20 May 2019 14:07:08 +0000 (16:07 +0200)]
s3:utils: Only declare variables if we're gonna use them

Found by covscan.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@samba.org>
7 months agolib:mscat: Add missing return check for error in dumpsmcat
Andreas Schneider [Mon, 20 May 2019 13:57:45 +0000 (15:57 +0200)]
lib:mscat: Add missing return check for error in dumpsmcat

Found by csbuild.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@samba.org>
7 months agoctdb:tests: Add missing va_end() in ctdb_set_error()
Andreas Schneider [Mon, 20 May 2019 13:52:12 +0000 (15:52 +0200)]
ctdb:tests: Add missing va_end() in ctdb_set_error()

Found by csbuild.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@samba.org>
7 months agoldap server: generate correct referral schemes
Gary Lockyer [Tue, 21 May 2019 01:17:22 +0000 (13:17 +1200)]
ldap server: generate correct referral schemes

Ensure that the referrals returned in a search request use the same
scheme as the request, i.e. referrals recieved via ldap are prefixed
with "ldap://" and those over ldaps are prefixed with "ldaps://"

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

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): Fri May 24 05:12:14 UTC 2019 on sn-devel-184

7 months agoldap tests: test scheme for referrals
Gary Lockyer [Tue, 21 May 2019 01:14:08 +0000 (13:14 +1200)]
ldap tests: test scheme for referrals

Ensure that the referrals returned in a search request use the same
scheme as the request, i.e. referrals recieved via ldap are prefixed
with "ldap://" and those over ldaps are prefixed with "ldaps://"

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Use scalar variable for new daemon_ctx hashmap
Tim Beale [Thu, 23 May 2019 04:58:20 +0000 (16:58 +1200)]
selftest: Use scalar variable for new daemon_ctx hashmap

The selftest code typically stores hashmaps as scalar variables (i.e.
it only ever uses references to hashmaps). So much so that using a regular
hashmap (and passing it by reference via \%daemon_ctx) looks out of
place.

Using the hashmap directly made more sense when it was only being used
locally, but now the hashmap is being passed by reference into a function
anyway, so storing it as a scalar doesn't make much difference.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Add common fork_and_exec() function
Tim Beale [Thu, 23 May 2019 04:35:07 +0000 (16:35 +1200)]
selftest: Add common fork_and_exec() function

Now the code has been refactored, we can move it into a common function.
This reduces code duplication and means we have a common place where we
start samba daemons from.

Note that some daemons behave slightly different, but the $daemon_ctx
allows us to customize their behaviour a bit.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Rework setting env variables for other forked binaries
Tim Beale [Thu, 23 May 2019 03:47:46 +0000 (15:47 +1200)]
selftest: Rework setting env variables for other forked binaries

Final refactor to merge the fork-and-exec code into a common function.

We can now use $daemon_ctx{ENV_VARS} to customize differences between
the forked binaries:
- samba: add in extra env variables on top of the defaults.
- dns_hub: there are no ENV variables we need to export.
- winbindd/smbd: these use the defaults, so they pass through an
undefined $daemon_ctx{ENV_VARS} (purely to make the code common across
all 5 places).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Rework setting env variables for nmbd
Tim Beale [Thu, 23 May 2019 03:47:46 +0000 (15:47 +1200)]
selftest: Rework setting env variables for nmbd

Instead of having a special $skip_resolv_conf parameter just for nmbd,
use the get_env_for_process() API and customize the hashmap returned.
Pass the customized hashmap in as an optional part of the daemon_ctx.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Store fork-and-exec daemon info in a hashmap
Tim Beale [Thu, 23 May 2019 01:45:49 +0000 (13:45 +1200)]
selftest: Store fork-and-exec daemon info in a hashmap

This intermediary refactor adds a hashmap that stores the values needed
to run each samba daemon. This adds a bit more code in the short term,
but it basically means the code in 5 different places now becomes
identical, and we can extract it out to a common function.

The converting FULL_CMD from an array reference back to an array is a
bit ugly, but we can clean this up a bit once the code is all in one
place.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Add helper function to build up s3 daemon cmd
Tim Beale [Thu, 23 May 2019 00:37:04 +0000 (12:37 +1200)]
selftest: Add helper function to build up s3 daemon cmd

The s3 daemons all basically use the same command logic, it's just they
use slightly different environment variables.

This adds a common helper function, which we can pass the specific
environment variables into.

(Note the slight parameter difference for winbind with --stdout vs
--log-stdout).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Move fork cmd args up a level
Tim Beale [Thu, 23 May 2019 00:12:44 +0000 (12:12 +1200)]
selftest: Move fork cmd args up a level

This is a fairly simple move of code and is the first step in a larger
refactor.

It doesn't matter if we build up the command args prior to the fork (we
only use them in the forked child). But moving the code means the code
to handle the fork-and-exec becomes common code that is repeated in
several places throughout Samba3.pm and Samba4.pm.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: remove unused variable (@optargs)
Tim Beale [Tue, 21 May 2019 21:33:34 +0000 (09:33 +1200)]
selftest: remove unused variable (@optargs)

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Refactor duplicated code to set ENV vars
Tim Beale [Mon, 20 May 2019 23:27:45 +0000 (11:27 +1200)]
selftest: Refactor duplicated code to set ENV vars

Whenever we started a process, we basically used the same code to setup
the ENV variables.

The s4 ENVNAME may now be slightly different in the child process that
runs samba (i.e. '$testenv.samba'), but that ENV var did not appeared to
be used much.

I'm not sure if the current difference in $skip_resolv_wrapper logic for
nmbd was deliberate or accidental, but I've preserved the logic for now.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agoselftest: Run samba3.srvsvc tests covering more of the srvsvc server
Andrew Bartlett [Thu, 23 May 2019 00:21:46 +0000 (12:21 +1200)]
selftest: Run samba3.srvsvc tests covering more of the srvsvc server

Found by LCOV.

Some of the failures should be fixed by setting "restrict anonymous = 2"
as requested by bug 12775

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
7 months agoselftest: Remove infinite client/server loop in srvsvc_NetNameValidate test
Andrew Bartlett [Thu, 23 May 2019 00:20:35 +0000 (12:20 +1200)]
selftest: Remove infinite client/server loop in srvsvc_NetNameValidate test

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
7 months agoselftest: Add more testing of wkssvc in source3
Andrew Bartlett [Wed, 22 May 2019 23:19:10 +0000 (11:19 +1200)]
selftest: Add more testing of wkssvc in source3

The samba3.wkssvc test is not as comprehensive, but rpc.wkssvc needs to run against the
ad_member environment to get past a builtin administrators check.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
7 months agoRun test for initshutdown
Andrew Bartlett [Wed, 22 May 2019 22:46:27 +0000 (10:46 +1200)]
Run test for initshutdown

The test already existed but was not run.

Found by LCOV

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
7 months 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

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

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