metze/samba/wip.git
4 years agos3-smbcontrol: Replace && with || to declare variables in do_sleep() master4-dcerpc-base master4-dcerpc-ok
Anoop C S [Wed, 29 May 2019 06:10:55 +0000 (11:40 +0530)]
s3-smbcontrol: Replace && with || to declare variables in do_sleep()

--enable-developer internally use --enable-selftest alongside. But when
configured only with --enable-selftest the following code block becomes
invalid:

 #if defined(DEVELOPER) && defined(ENABLE_SELFTEST)
        unsigned int seconds;
        long input;
        const long MAX_SLEEP = 60 * 60; /* One hour maximum sleep */
 #endif

making those variables undeclared for further use. Therefore replace &&
with || to have those variables declared with --enable-selftest
configure option.

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri May 31 20:38:09 UTC 2019 on sn-devel-184

4 years ago.gitlab-ci.yml: avoid using != to compare variables to support old versions
Joe Guo [Wed, 29 May 2019 03:35:08 +0000 (15:35 +1200)]
.gitlab-ci.yml: avoid using != to compare variables to support old versions

`!=` was only introduced after 11.11, according to doc at:

https://docs.gitlab.com/ee/ci/variables/README.html#environment-variables-expressions

For private gitlab instance, the version may not be new enough.
Use `==` to make it backward compatible.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri May 31 09:48:37 UTC 2019 on sn-devel-184

4 years agoselftest: Don't use global dirs when parsing customdc realm
Tim Beale [Thu, 30 May 2019 02:55:52 +0000 (14:55 +1200)]
selftest: Don't use global dirs when parsing customdc realm

When creating the customdc, testparm would default to using
/usr/local/samba sub-directories for creating sockets and lock files.
Instead, pass in the tmpdir we just created as an option to the command.

Normally this didn't cause a noticeable problem, however, if we run the
command with UID-wrapper but without socket-wrapper (i.e.
USE_NAMESPACES=1), then it fails completely.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri May 31 06:34:36 UTC 2019 on sn-devel-184

4 years agoselftest: Add check customdc has valid realm/domain
Tim Beale [Thu, 30 May 2019 02:46:35 +0000 (14:46 +1200)]
selftest: Add check customdc has valid realm/domain

If we couldn't determine the realm/domain from the backup file, it's a
lot nicer to fail early with a clear error message (rather than failing
later on with a really obscure message).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoprovision: Fallback to assumption root-UID==zero
Tim Beale [Tue, 2 Oct 2018 19:56:45 +0000 (08:56 +1300)]
provision: Fallback to assumption root-UID==zero

Which is not a terrible assumption to make. The super-user on linux will
always have UID of zero, however, the super-user will not necessarily be
called "root".

This makes the provision/join commands work better when run in a
container. (And while deploying Samba in a container is perhaps not the
smartest move, this gives us some versatility when testing Samba).

This is needed to get the provision commands working in the domain_backup
tests when run with USE_NAMESPACES=1.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoselftest: Add more notes on using selftest with namespaces
Tim Beale [Thu, 30 May 2019 23:23:49 +0000 (11:23 +1200)]
selftest: Add more notes on using selftest with namespaces

In particular, document how to hook up a testenv to a Windows VM
(ideally there should be a helper script to do this, but in the
meantime some instructions are better than nothing).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoselftest: Add helper scripts for accessing the testenv namespace
Tim Beale [Thu, 28 Mar 2019 04:40:46 +0000 (17:40 +1300)]
selftest: Add helper scripts for accessing the testenv namespace

This patch adds some helper scripts that make talking to a given
testenv's namespace slightly easier.

One of the really cool things about namespaces is you can run multiple
different programs that can all talk to the testenv DC. However, the
command to do this is a bit unweildly, it's based on PID so it changes
everytime you start up a testenv, and you loose all the environment
variables that selftest normally sets up.

This patch adds a couple of helper scripts:
- nsenter-helper.sh: this takes the variables defined in an exports_file
  and exports them all. It prints some basic help and then starts a new
  shell session (this whole script gets run in the new namespace).
  Essentially this achieves something similar to the legacy
  selftest-vars.sh script (except this one actually works).
- mk_nsenter.sh: this generates a simple wrapper script that'll run
  nsenter and then call nsenter-helper.sh. A separate wrapper script
  gets created for each testenv. E.g. to run it, just go:
    ./st/ad_dc/nsenter.sh

  This is a wrapper for a more complicated command underneath like:
    nsenter -t 437353 --net --user --preserve-credentials \
      /home/timbeale/code/samba/selftest/ns/nsenter-helper.sh \
      /home/timbeale/code/samba/st/ad_dc/exports.sh

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoselftest: Add linux namespace support (USE_NAMESPACES=1)
Tim Beale [Thu, 23 May 2019 05:44:37 +0000 (17:44 +1200)]
selftest: Add linux namespace support (USE_NAMESPACES=1)

This hooks up the selftest/ns/* scripts added earlier with the selftest
system, so developers can optionally run a testenv or test using linux
namespaces instead of socket-wrapper.

The idea is this is experimental functionality that we can extend
further in future, in order to make testing Samba more versatile.

+ The top-level WAF script now does an 'unshare' to create a new
top-level 'selftest' namespace in which to create the testenv(s).
+ selftest.pl creates a common 'selftest0' bridge to connect together
the individual DCs.
+ Update Samba.pm so it can use real IPs instead of loopback addresses.
In fork_and_exec(), we add a couple of hooks so that the binary gets
started in a different namespace (using unshare/start_in_ns.sh), and
the parent process connects the new child namespace up to the common
selftest0 bridge (using add_bridge_iface.sh).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoselftest: Add TESTENV_DIR "env" variable
Tim Beale [Thu, 14 Mar 2019 04:38:22 +0000 (17:38 +1300)]
selftest: Add TESTENV_DIR "env" variable

We store the testenv directory path for the 'ctx' hashmap, but not for
the testenv-vars hashmap (and that can be really annoying sometimes).
Add it into the second hashmap that selftest actually keeps track of.
Currently it's only stored in the hashmap, not actually exported as an
environment variable (but we could easily do that if a test-case need
this info).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoselftest: Add helper scripts to run selftest in namespaces
Tim Beale [Tue, 26 Feb 2019 02:54:34 +0000 (15:54 +1300)]
selftest: Add helper scripts to run selftest in namespaces

This adds the underlying scripts, but they are not actually hooked up to
the selftest code yet, and so are not actually used.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoselftest: Allow for wider range of terminals (besides xterm)
Tim Beale [Fri, 31 May 2019 00:33:59 +0000 (12:33 +1200)]
selftest: Allow for wider range of terminals (besides xterm)

Allow developers to override the default @term_args, as well as the
terminal itself.

Currently, due to the nature of the args we pass to xterm (i.e. 'echo -e
"blah.." && bash'), it doesn't make it very flexible for use with other
terminals. By dropping these additional @term_args, it makes it much
easier to slot in an alternative terminal.

For example, these commands now work (more or less).

TERMINAL="terminator" TERMINAL_ARGS="-x bash" \
 SELFTEST_TESTENV=ad_dc make testenv

TERMINAL="bash" TERMINAL_ARGS="" \
 SELFTEST_TESTENV=nt4_dc make testenv

TERMINAL="bash" TERMINAL_ARGS="--norc" \
 SELFTEST_TESTENV=none make testenv

bash is usable, but a little weird because its output is still being
piped. Also bash with ad_dc is a little weird because we're using tee
for the DC's stdout. (I'd also recommend --norc, as it makes it easier
to differentiate between the testenv shell).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agovfs_fruit: remove a now unnecessary include
Ralph Boehme [Fri, 24 May 2019 13:15:59 +0000 (15:15 +0200)]
vfs_fruit: remove a now unnecessary include

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

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

4 years agovfs_fruit: use VFS functions in ad_read_rsrc_adouble()
Ralph Boehme [Fri, 24 May 2019 12:51:17 +0000 (14:51 +0200)]
vfs_fruit: use VFS functions in ad_read_rsrc_adouble()

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: use fsp and remove syscalls from ad_convert_blank_rfork()
Ralph Boehme [Fri, 24 May 2019 10:51:15 +0000 (12:51 +0200)]
vfs_fruit: use fsp and remove syscalls from ad_convert_blank_rfork()

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: use VFS function in ad_convert_truncate()
Ralph Boehme [Fri, 24 May 2019 10:07:55 +0000 (12:07 +0200)]
vfs_fruit: use VFS function in ad_convert_truncate()

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: add VFS handle to ad_convert_truncate()
Ralph Boehme [Fri, 24 May 2019 10:05:51 +0000 (12:05 +0200)]
vfs_fruit: add VFS handle to ad_convert_truncate()

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: use fsp and remove mmap in ad_convert_xattr()
Ralph Boehme [Fri, 24 May 2019 09:54:51 +0000 (11:54 +0200)]
vfs_fruit: use fsp and remove mmap in ad_convert_xattr()

No need to mmap() anyway, the xattr data is already available in ad->ad_data.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: remove use of mmap() from ad_convert_move_reso()
Ralph Boehme [Thu, 23 May 2019 20:44:21 +0000 (22:44 +0200)]
vfs_fruit: remove use of mmap() from ad_convert_move_reso()

We now have an fsp that we can use, so we can get rid of mmap() and
sys_pread()/sys_pwrite().

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: convert ad_open_rsrc() to open a proper fsp with SMB_VFS_CREATE_FILE()
Ralph Boehme [Thu, 23 May 2019 14:42:52 +0000 (16:42 +0200)]
vfs_fruit: convert ad_open_rsrc() to open a proper fsp with SMB_VFS_CREATE_FILE()

A first step in converting all raw syscalls to use proper VFS functions. All
existing users of the raw system filedescriptor continue to use the fd from
fsp->fh for now.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: only do cross protocol locking on non-internal opens
Ralph Boehme [Thu, 23 May 2019 14:22:39 +0000 (16:22 +0200)]
vfs_fruit: only do cross protocol locking on non-internal opens

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: remove a layer of indirection
Ralph Boehme [Thu, 23 May 2019 06:27:37 +0000 (08:27 +0200)]
vfs_fruit: remove a layer of indirection

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass VFS handle to ad_convert_move_reso()
Ralph Boehme [Thu, 23 May 2019 06:14:18 +0000 (08:14 +0200)]
vfs_fruit: pass VFS handle to ad_convert_move_reso()

Not used for now, that comes next.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: remove xattr code from the AppleDouble subsystem
Ralph Boehme [Wed, 22 May 2019 19:15:22 +0000 (21:15 +0200)]
vfs_fruit: remove xattr code from the AppleDouble subsystem

The subsystem consumers have been reworked in the previous commits, so this is
not used anymore. ad_init() doesn't need a handle argument anymore due to this,
remove it as well.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: remove now unused AppleDouble code for resource fork in xattr
Ralph Boehme [Fri, 17 May 2019 12:31:15 +0000 (14:31 +0200)]
vfs_fruit: remove now unused AppleDouble code for resource fork in xattr

This was only needed to get the resourcefork size via the ad_* AppleDouble
function. This is now done with a fstat on the low level xattr fd (remember,
this is Solaris only code...), so we can remove the xattr special casing from
the AppleDouble functions.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: use stream code for resource fork size calculation in readdir_attr_rfork_s...
Ralph Boehme [Wed, 22 May 2019 16:08:14 +0000 (18:08 +0200)]
vfs_fruit: use stream code for resource fork size calculation in readdir_attr_rfork_size()

This works as well, using an fstat() on the filehandle to get the size. This is
tested by the torture test "vfs.fruit.SMB2/CREATE context AAPL".

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: use correct case FRUIT_RSRC_STREAM in readdir_attr_rfork_size()
Ralph Boehme [Wed, 22 May 2019 15:02:20 +0000 (17:02 +0200)]
vfs_fruit: use correct case FRUIT_RSRC_STREAM in readdir_attr_rfork_size()

This is a genuine bug, but luckily this would only impact configs which nobody
uses:

  fruit:metadata = netatalk
  fruit:resource = stream

With the above configuration the switch in readdir_attr_rfork_size() would hit
the default case and so always report resource forks as 0 bytes in size.

All deployment that I've seen that use fruit:resource=stream also use
fruit:metadata=stream, so the switch takes FRUIT_META_STREAM case which runs the
correct code readdir_attr_rfork_size_stream().

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: ignore AppleDouble files in fruit_unlink()
Ralph Boehme [Tue, 21 May 2019 09:42:47 +0000 (11:42 +0200)]
vfs_fruit: ignore AppleDouble files in fruit_unlink()

Otherwise, if SMB_VFS_UNLINK() is called for an AppleDouble path "._file", we
try to delete "._._file" which doesn't make sense. AppleDouble files don't have
AppleDouble themselves.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: add a missing else
Ralph Boehme [Tue, 21 May 2019 09:40:33 +0000 (11:40 +0200)]
vfs_fruit: add a missing else

Luckily the missing else has the same control flow due to the previous if and
else blocks calling return.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: add and use is_adouble_file()
Ralph Boehme [Tue, 21 May 2019 09:39:18 +0000 (11:39 +0200)]
vfs_fruit: add and use is_adouble_file()

This adds a helper function that checks whether the last component of a path is
an AppleDouble sidecar file with "._" name prefix.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: finally, remove ad_handle from struct adouble
Ralph Boehme [Fri, 17 May 2019 10:19:06 +0000 (12:19 +0200)]
vfs_fruit: finally, remove ad_handle from struct adouble

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_convert_delete_adfile()
Ralph Boehme [Fri, 17 May 2019 10:17:28 +0000 (12:17 +0200)]
vfs_fruit: pass handle to ad_convert_delete_adfile()

On the course of removing ad_handle from struct adouble, step 10.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_convert_finderinfo()
Ralph Boehme [Fri, 17 May 2019 10:05:07 +0000 (12:05 +0200)]
vfs_fruit: pass handle to ad_convert_finderinfo()

On the course of removing ad_handle from struct adouble, step 9.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_convert_blank_rfork()
Ralph Boehme [Fri, 17 May 2019 10:02:46 +0000 (12:02 +0200)]
vfs_fruit: pass handle to ad_convert_blank_rfork()

On the course of removing ad_handle from struct adouble, step 8.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_convert_xattr()
Ralph Boehme [Fri, 17 May 2019 09:54:10 +0000 (11:54 +0200)]
vfs_fruit: pass handle to ad_convert_xattr()

On the course of removing ad_handle from struct adouble, step 7.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: indentation fix
Ralph Boehme [Fri, 17 May 2019 09:23:17 +0000 (11:23 +0200)]
vfs_fruit: indentation fix

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_read_rsrc() and all the way down
Ralph Boehme [Fri, 17 May 2019 09:47:26 +0000 (11:47 +0200)]
vfs_fruit: pass handle to ad_read_rsrc() and all the way down

On the course of removing ad_handle from struct adouble, step 5.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: use proper VFS function in ad_read_meta()
Ralph Boehme [Fri, 17 May 2019 09:42:06 +0000 (11:42 +0200)]
vfs_fruit: use proper VFS function in ad_read_meta()

Continuing to ignore a possible error for now, this is in an error codepath
anyway.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: indentation fix
Ralph Boehme [Fri, 17 May 2019 09:23:17 +0000 (11:23 +0200)]
vfs_fruit: indentation fix

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_read_meta()
Ralph Boehme [Fri, 17 May 2019 09:22:24 +0000 (11:22 +0200)]
vfs_fruit: pass handle to ad_read_meta()

On the course of removing ad_handle from struct adouble, step 4.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_read()
Ralph Boehme [Fri, 17 May 2019 09:19:53 +0000 (11:19 +0200)]
vfs_fruit: pass handle to ad_read()

On the course of removing ad_handle from struct adouble, step 3.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_set()
Ralph Boehme [Fri, 17 May 2019 08:43:55 +0000 (10:43 +0200)]
vfs_fruit: pass handle to ad_set()

On the course of removing ad_handle from struct adouble, step 2.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agovfs_fruit: pass handle to ad_fset()
Ralph Boehme [Fri, 17 May 2019 08:41:29 +0000 (10:41 +0200)]
vfs_fruit: pass handle to ad_fset()

On the course of removing ad_handle from struct adouble, step 1.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosamba-tool: add 'import samba.drs_utils' to fsmo.py
Björn Baumbach [Tue, 28 May 2019 12:52:36 +0000 (14:52 +0200)]
samba-tool: add 'import samba.drs_utils' to fsmo.py

On some systems we're seeing this:

 ERROR(<type 'exceptions.AttributeError'>): uncaught exception - 'module' object has no attribute 'drs_utils'
   File "/usr/lib/python2.7/dist-packages/samba/netcmd/__init__.py", line 185, in _run
     return self.run(*args, **kwargs)
   File "/usr/lib/python2.7/dist-packages/samba/netcmd/fsmo.py", line 533, in run
     transfer_dns_role(self.outf, sambaopts, credopts, role, samdb)
   File "/usr/lib/python2.7/dist-packages/samba/netcmd/fsmo.py", line 136, in transfer_dns_role
     except samba.drs_utils.drsException as e:

E.g. it happens on debian stretch (9.9) with python 2.7.13 (on 4.10.4)

While it doesn't happen on ubuntu 18.04 with python 2.7.15rc1 or
with python 3.6.7.

There were also some reports on the mailing lists, see:
https://lists.samba.org/archive/samba-technical/2019-May/133624.html

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

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

Signed-off-by: Björn Baumbach <bbaumbach@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu May 30 08:27:24 UTC 2019 on sn-devel-184

4 years agosamba-tool: use only one LDAP modify for dns partition fsmo role transfer
Stefan Metzmacher [Tue, 28 May 2019 12:54:19 +0000 (14:54 +0200)]
samba-tool: use only one LDAP modify for dns partition fsmo role transfer

We should not risk that we end with no role owner.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:torture:fsmo.py: remove unused 'net_cmd' variable
Björn Baumbach [Tue, 28 May 2019 12:57:15 +0000 (14:57 +0200)]
s4:torture:fsmo.py: remove unused 'net_cmd' variable

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

Signed-off-by: Björn Baumbach <bbaumbach@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agosamba-tool: fix replication after dns partition fsmo role transfer
Stefan Metzmacher [Tue, 28 May 2019 12:53:09 +0000 (14:53 +0200)]
samba-tool: fix replication after dns partition fsmo role transfer

The new role owner need to replicate from the old role owner.

Before we told the old role owner to replicate from itself.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:torture:fsmo.py: test role transfers of dns partitions
Björn Baumbach [Fri, 24 May 2019 13:46:17 +0000 (15:46 +0200)]
s4:torture:fsmo.py: test role transfers of dns partitions

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

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

Signed-off-by: Björn Baumbach <bbaumbach@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4 lib rpc pyrpc: Fix error message
Gary Lockyer [Mon, 27 May 2019 00:56:08 +0000 (12:56 +1200)]
s4 lib rpc pyrpc: Fix error message

Fix the error message returned when unable to initialise an event context.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoldb: Avoid read beyond buffer
Michael Hanselmann [Thu, 11 Apr 2019 22:46:37 +0000 (00:46 +0200)]
ldb: Avoid read beyond buffer

Calling the "ldb_parse_tree" function with a filter consisting of
exactly a single space (" ") would trigger a read beyond the input
buffer. A unittest is included.

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

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Tim Beale <timbeale@catalyst.net.nz>
4 years agosamba-tool dns: use bytes for inet_ntop
Douglas Bagnall [Thu, 23 May 2019 21:58:12 +0000 (09:58 +1200)]
samba-tool dns: use bytes for inet_ntop

From Python's point of view, array.AddrArray is a list of byte-valued
integers. In Python 3 we can convert directly using the likes of

         bytes(array.AddrArray[i].MaxSa[8:24])

but in 4.10 we need to support both, so we use struct.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Wed May 29 11:29:17 UTC 2019 on sn-devel-184

4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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

4 years 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>

4 years 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>

4 years 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>

4 years 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>

4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>

4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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

4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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>
4 years 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

4 years 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>
4 years 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>
4 years 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

4 years 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>
4 years 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>
4 years 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>
4 years 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>