metze/samba/wip.git
22 months agos3:vfs_glusterfs: Use SAFE_FREE
Andreas Schneider [Thu, 26 Oct 2017 06:05:20 +0000 (08:05 +0200)]
s3:vfs_glusterfs: Use SAFE_FREE

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Oct 26 17:31:40 CEST 2017 on sn-devel-144

22 months agoctdb-tests: Process-exists unit tests should wait until PID is registered
Martin Schwenke [Wed, 25 Oct 2017 01:15:23 +0000 (12:15 +1100)]
ctdb-tests: Process-exists unit tests should wait until PID is registered

Otherwise the client registration can race with the check in the test.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Oct 26 13:32:24 CEST 2017 on sn-devel-144

22 months agoctdb-tests: Wait for fake_ctdbd to start, fail if it doesn't
Martin Schwenke [Wed, 25 Oct 2017 06:52:04 +0000 (17:52 +1100)]
ctdb-tests: Wait for fake_ctdbd to start, fail if it doesn't

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-tests: Skip starting fake_ctdbd when current node is disconnected
Martin Schwenke [Wed, 25 Oct 2017 10:43:56 +0000 (21:43 +1100)]
ctdb-tests: Skip starting fake_ctdbd when current node is disconnected

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-tests: Wait for ctdb_eventd to start, fail if it doesn't
Martin Schwenke [Wed, 25 Oct 2017 07:52:10 +0000 (18:52 +1100)]
ctdb-tests: Wait for ctdb_eventd to start, fail if it doesn't

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-tests: Allow wait_until() to be used in unit tests
Martin Schwenke [Wed, 25 Oct 2017 01:04:49 +0000 (12:04 +1100)]
ctdb-tests: Allow wait_until() to be used in unit tests

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agos3:vfs_glusterfs: Fix a double free in vfs_gluster_getwd()
Andreas Schneider [Wed, 25 Oct 2017 17:39:34 +0000 (19:39 +0200)]
s3:vfs_glusterfs: Fix a double free in vfs_gluster_getwd()

Found by cppcheck.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Oct 26 09:34:40 CEST 2017 on sn-devel-144

22 months agolinked attribute tests: correct add_all_at_once test
Douglas Bagnall [Tue, 24 Oct 2017 23:57:09 +0000 (12:57 +1300)]
linked attribute tests: correct add_all_at_once test

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Oct 26 05:36:11 CEST 2017 on sn-devel-144

22 months agolinked_attribute tests: helper assert function for expected LdbError
Douglas Bagnall [Tue, 24 Oct 2017 22:57:50 +0000 (11:57 +1300)]
linked_attribute tests: helper assert function for expected LdbError

The logic involved in asserting that a function raises an LdbError with
a particular error value has shown itself to be too complicated for me
to repeat too often.

To test this function, you would want a put a test in a bit like this:

    def test_assertRaisesLdbError(self):
        for i in [1, 2, ldb.ERR_ENTRY_ALREADY_EXISTS, 999]:
            def f(*args, **kwargs):
                raise ldb.LdbError(i, 'msg %s' % i)
            self.assertRaisesLdbError(i, 'a message', f, 'la la', la='la')

            def f2(*args, **kwargs):
                raise ldb.LdbError(i + 1, 'msg %s' % i)
            def f3(*args, **kwargs):
                pass
            for f in (f2, f3):
                try:
                    self.assertRaisesLdbError(i, 'a message', f, 'la la', la='la')
                except AssertionError as e:
                    print i, e, f
                    pass
                else:
                    print i, f
                    self.fail('assertRaisesLdbError() failed to fail!')

..but a self-testing test-tester is getting a too meta to run in every
autobuild.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: use check_parsed_dn_duplicates() more widely
Douglas Bagnall [Tue, 24 Oct 2017 23:31:08 +0000 (12:31 +1300)]
replmd: use check_parsed_dn_duplicates() more widely

replmd_add_fix_la() was already making the same check; here we move it
a bit earlier.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agolinked attribute tests: fix logic for add test
Douglas Bagnall [Tue, 24 Oct 2017 23:17:05 +0000 (12:17 +1300)]
linked attribute tests: fix logic for add test

We were ensuring that when we got an LdbError it was the right type,
but we weren't ensuring we got one at all.

The new test doesn't fail.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agolinked attribute tests: ensure duplicate deletes fail
Douglas Bagnall [Tue, 24 Oct 2017 23:13:57 +0000 (12:13 +1300)]
linked attribute tests: ensure duplicate deletes fail

We can't remove the same thing twice in the same message.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: check for duplicate values in MOD_REPLACE case
Douglas Bagnall [Tue, 24 Oct 2017 21:12:09 +0000 (10:12 +1300)]
replmd: check for duplicate values in MOD_REPLACE case

Because we already have a sorted parsed_dn list, this is a simple
linear scan.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agolinked attribute tests: test against duplicates in replace
Douglas Bagnall [Tue, 24 Oct 2017 21:54:42 +0000 (10:54 +1300)]
linked attribute tests: test against duplicates in replace

We should not be able to introduce duplicate links using MOD_REPLACE.
It turns out we could and weren't testing.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agos4:scripting: Fix ntstatus_gen.h generation on 32bit
Andreas Schneider [Wed, 25 Oct 2017 15:37:24 +0000 (17:37 +0200)]
s4:scripting: Fix ntstatus_gen.h generation on 32bit

The hex() function results in different output on 32bit systems. It adds
a L for long for some numbers. Thus we have a different header file.

This patch makes sure we have a consistent file generation on different
paltforms.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Wed Oct 25 22:28:39 CEST 2017 on sn-devel-144

22 months agos3: smbclient: Test we can rename with a name containing.
Jeremy Allison [Mon, 23 Oct 2017 22:40:04 +0000 (15:40 -0700)]
s3: smbclient: Test we can rename with a name containing.

Samba always allowed this anyway, but it's a good place
to ensure we don't regress.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Oct 24 23:32:58 CEST 2017 on sn-devel-144

22 months agos3: smbclient: Ensure we call client_clean_name() before all operations on remote...
Jeremy Allison [Fri, 20 Oct 2017 22:09:38 +0000 (15:09 -0700)]
s3: smbclient: Ensure we call client_clean_name() before all operations on remote pathnames.

This allows names containing .. components to be resolved on the client side
before being sent to the server. Relative names work in SMB1 but not in SMB2.
Fix both client.c and clitar.c

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agos3: client: Add new utility function client_clean_name().
Jeremy Allison [Sat, 21 Oct 2017 00:08:08 +0000 (00:08 +0000)]
s3: client: Add new utility function client_clean_name().

Correctly canonicalizes a remote pathname removing '..'
elements before sending to a remote server. '..' elements
work in SMB1 pathnames, but not in SMB2.

Not yet used.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoctdb-client: Fix CID 1419820
Amitay Isaacs [Wed, 18 Oct 2017 05:16:27 +0000 (16:16 +1100)]
ctdb-client: Fix CID 1419820

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Mon Oct 23 19:45:08 CEST 2017 on sn-devel-144

22 months agoctdb-tools: Drop duplicate output from dbstatistics
Amitay Isaacs [Fri, 13 Oct 2017 01:57:08 +0000 (12:57 +1100)]
ctdb-tools: Drop duplicate output from dbstatistics

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
22 months agopython: Port tests of samba.messaging to Python 3 compatible form.
Lumir Balhar [Thu, 14 Sep 2017 07:31:17 +0000 (09:31 +0200)]
python: Port tests of samba.messaging to Python 3 compatible form.

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Oct 23 15:40:48 CEST 2017 on sn-devel-144

22 months agopython: Port samba.messaging module to Python 3 compatible form.
Lumir Balhar [Thu, 14 Sep 2017 07:30:28 +0000 (09:30 +0200)]
python: Port samba.messaging module to Python 3 compatible form.

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoxattr.idl: Don't generate an interface table
Volker Lendecke [Tue, 15 Aug 2017 06:25:34 +0000 (08:25 +0200)]
xattr.idl: Don't generate an interface table

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sun Oct 22 21:40:16 CEST 2017 on sn-devel-144

22 months agonfs4acls: Don't generate an interface table for nfs4acls.idl
Volker Lendecke [Tue, 15 Aug 2017 06:17:22 +0000 (08:17 +0200)]
nfs4acls: Don't generate an interface table for nfs4acls.idl

Nobody uses the function nfs4acl_test.

It took a while to figure out how to get this to build. The "uuid" line in the
idl file triggers pidl to generate the function table entry, which in turn then
triggers tables.pl to register this interface
./bin/default/source4/librpc/gen_ndr/tables.c. We could for example do the same
with xattr_parse_DOSATTRIB. Nobody uses this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
22 months agonfs4acls: Slightly simplify smb_add_ace4
Volker Lendecke [Tue, 15 Aug 2017 04:02:13 +0000 (06:02 +0200)]
nfs4acls: Slightly simplify smb_add_ace4

The comment was a bit confusing to me, it took a few seconds too many to figure
out *why* setting NULL is not required. Remove it :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
22 months agonfs4acls: Fix a debug message
Volker Lendecke [Tue, 15 Aug 2017 03:58:05 +0000 (05:58 +0200)]
nfs4acls: Fix a debug message

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
22 months agos3/smbd: update some more DEBUG macros in smbd_smb2_create_send
Ralph Boehme [Sat, 22 Jul 2017 17:34:25 +0000 (19:34 +0200)]
s3/smbd: update some more DEBUG macros in smbd_smb2_create_send

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): Sat Oct 21 18:08:46 CEST 2017 on sn-devel-144

22 months agos3/smbd: use early returns in smbd_smb2_create_send
Ralph Boehme [Fri, 21 Jul 2017 16:59:55 +0000 (18:59 +0200)]
s3/smbd: use early returns in smbd_smb2_create_send

Now that we have the nice smbd_smb2_create_after_exec() and
smbd_smb2_create_finish() functions, use early returns for the create
replay and durable handle reconnect case.

No change in behaviour, best viewed with

$ git show -w COMMIT

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: factor out smbd_smb2_create_after_exec from smbd_smb2_create_send
Ralph Boehme [Thu, 20 Jul 2017 14:14:31 +0000 (16:14 +0200)]
s3/smbd: factor out smbd_smb2_create_after_exec from smbd_smb2_create_send

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: factor out smbd_smb2_create_before_exec from smbd_smb2_create_send
Ralph Boehme [Thu, 20 Jul 2017 14:14:31 +0000 (16:14 +0200)]
s3/smbd: factor out smbd_smb2_create_before_exec from smbd_smb2_create_send

No change in behaviour, best viewed with:

$ git show --diff-algorithm=histogram COMMIT

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: remove all stack variables of smbd_smb2_create_send into smbd_smb2_create_state
Ralph Boehme [Fri, 21 Jul 2017 16:02:05 +0000 (18:02 +0200)]
s3/smbd: remove all stack variables of smbd_smb2_create_send into smbd_smb2_create_state

This allows factoring out smbd_smb2_create_after|before_exec() in the
next steps.

Moving all variable in one big fell swoop instead of one per commit,
because if I'd miss to adjust a variable access the commit wouldn't
compile.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: move create ctx extraction and validation to a helper func
Ralph Boehme [Thu, 20 Jul 2017 10:51:37 +0000 (12:51 +0200)]
s3/smbd: move create ctx extraction and validation to a helper func

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: move create contexts into smbd_smb2_create_state
Ralph Boehme [Thu, 20 Jul 2017 10:15:19 +0000 (12:15 +0200)]
s3/smbd: move create contexts into smbd_smb2_create_state

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: remove unneeded args from smbd_smb2_create_finish
Ralph Boehme [Thu, 20 Jul 2017 09:29:46 +0000 (11:29 +0200)]
s3/smbd: remove unneeded args from smbd_smb2_create_finish

The previous commits moved all arguments into smbd_smb2_create_state.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: move info into smbd_smb2_create_state
Ralph Boehme [Sat, 22 Jul 2017 16:49:50 +0000 (18:49 +0200)]
s3/smbd: move info into smbd_smb2_create_state

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: add in_create_disposition to smbd_smb2_create_state
Ralph Boehme [Sat, 22 Jul 2017 16:47:17 +0000 (18:47 +0200)]
s3/smbd: add in_create_disposition to smbd_smb2_create_state

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: add in_oplock_level to smbd_smb2_create_state
Ralph Boehme [Sat, 22 Jul 2017 16:43:33 +0000 (18:43 +0200)]
s3/smbd: add in_oplock_level to smbd_smb2_create_state

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: move requested_oplock_level into smbd_smb2_create_state
Ralph Boehme [Sat, 22 Jul 2017 16:40:16 +0000 (18:40 +0200)]
s3/smbd: move requested_oplock_level into smbd_smb2_create_state

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: move replay_operation into smbd_smb2_create_state
Ralph Boehme [Sat, 22 Jul 2017 16:32:50 +0000 (18:32 +0200)]
s3/smbd: move replay_operation into smbd_smb2_create_state

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: move result into smbd_smb2_create_state
Ralph Boehme [Sat, 22 Jul 2017 13:31:05 +0000 (15:31 +0200)]
s3/smbd: move result into smbd_smb2_create_state

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: leverage early return added in the previous commit
Ralph Boehme [Wed, 19 Jul 2017 17:07:55 +0000 (19:07 +0200)]
s3/smbd: leverage early return added in the previous commit

Now that the other cases handled in the if/else blocks do early returns,
we can move the logic handling file opens out of the final else block.

No change in behaviour, best viewed with

$ git show -w COMMIT

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: factor out smbd_smb2_create_finish from smbd_smb2_create_send
Ralph Boehme [Wed, 19 Jul 2017 17:04:46 +0000 (19:04 +0200)]
s3/smbd: factor out smbd_smb2_create_finish from smbd_smb2_create_send

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: modernize a DEBUG statement
Ralph Boehme [Fri, 21 Jul 2017 13:34:02 +0000 (15:34 +0200)]
s3/smbd: modernize a DEBUG statement

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: move some setup code in smbd_smb2_create_send a few lines up
Ralph Boehme [Thu, 20 Jul 2017 04:03:34 +0000 (06:03 +0200)]
s3/smbd: move some setup code in smbd_smb2_create_send a few lines up

This is just one of the last steps before splitting out large code parts
into _before() and _after() functions. No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: add tevent context to smbd_smb2_create_state
Ralph Boehme [Fri, 21 Jul 2017 14:23:53 +0000 (16:23 +0200)]
s3/smbd: add tevent context to smbd_smb2_create_state

...and use it in everywhere in smbd_smb2_create_send().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3/smbd: use struct initializer for smbd_smb2_create_state
Ralph Boehme [Thu, 20 Jul 2017 04:49:46 +0000 (06:49 +0200)]
s3/smbd: use struct initializer for smbd_smb2_create_state

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib: Remove fncall.c
Volker Lendecke [Wed, 18 Oct 2017 15:15:53 +0000 (17:15 +0200)]
lib: Remove fncall.c

This was meant as a nice wrapper around pthreadpool_add_job.

pthreadpool_tevent_job_send does the same thing. The
getaddrinfo_send/recv was the only example and can easily be re-added on
top of pthreadpool_tevent_job_send.

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): Sat Oct 21 00:04:59 CEST 2017 on sn-devel-144

22 months agolib: Remove unused getaddinfo_send/recv
Volker Lendecke [Wed, 18 Oct 2017 15:13:04 +0000 (17:13 +0200)]
lib: Remove unused getaddinfo_send/recv

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
22 months agotorture: Remove GETADDRINFO test
Volker Lendecke [Wed, 18 Oct 2017 15:11:21 +0000 (17:11 +0200)]
torture: Remove GETADDRINFO test

This was the only user of getaddrinfo_send and not run anyway

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
22 months agosmbd: Simplify cleanupdb a bit
Volker Lendecke [Wed, 18 Oct 2017 14:56:49 +0000 (16:56 +0200)]
smbd: Simplify cleanupdb a bit

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
22 months agosmbd: cleanupdb.c is used in smbd only
Volker Lendecke [Wed, 18 Oct 2017 15:02:56 +0000 (17:02 +0200)]
smbd: cleanupdb.c is used in smbd only

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
22 months agovfs_glusterfs: Fix exporting subdirs with shadow_copy2
Michael Adam [Fri, 20 Oct 2017 12:55:10 +0000 (14:55 +0200)]
vfs_glusterfs: Fix exporting subdirs with shadow_copy2

Since the glusterfs vfs module does not operate on a
locally mounted path, but on a "virtual" path starting
at the volume root, some assumptions of the code about
the vfs connect path fail. One example is the shadow_copy2
module which tries to detect the mount point from the
connectpath. In order to circumvent this problem, this
patch forces the "shadow:mountpoint" option to "/", which
skips the mount-point-detection code.

This patch will only have an effect if both the glusterfs
and the shadow_copy2 module are listed in vfs objects
in the right order, i.e. first shadow_copy2, and then
glusterfs.

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

Pair-Programmed-With: Anoop C S <anoopcs@redhat.com>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
22 months agoselftest: Print link meta-data when developer debugging is used
Tim Beale [Tue, 26 Sep 2017 22:21:48 +0000 (11:21 +1300)]
selftest: Print link meta-data when developer debugging is used

For Windows, DRS is the only way to see the RMD_VERSION of a link, or to
tell what inactive links the DC. Add some debug to display this
information. By default, this debug is turned off.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Oct 20 08:01:35 CEST 2017 on sn-devel-144

22 months agoreplmd: Remove unnecessary replmd_build_la_val() param
Tim Beale [Thu, 28 Sep 2017 03:13:05 +0000 (16:13 +1300)]
replmd: Remove unnecessary replmd_build_la_val() param

replmd_build_la_val() is creating a new link attribute. In this case,
the RMD_ORIGINATING_USN and RMD_LOCAL_USN are always going to be the
same thing, so we don't need to pass them in as 2 separate parameters.

This isn't required for any bug fix, but is just a general code
tidy-up.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Get rid of duplicated replmd_build_la_val() code
Tim Beale [Thu, 28 Sep 2017 02:48:58 +0000 (15:48 +1300)]
replmd: Get rid of duplicated replmd_build_la_val() code

replmd_build_la_val() and replmd_set_la_val() are pretty much identical.
Keep the replmd_build_la_val() API (as it makes it clearer we're
creating a new linked attribute), but replace the code with a call to
replmd_set_la_val().

This isn't required for any bug fix, but is just a general tidy-up to
avoid code duplication.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Fix RMD_VERSION inital value to match Windows
Tim Beale [Thu, 28 Sep 2017 02:09:34 +0000 (15:09 +1300)]
replmd: Fix RMD_VERSION inital value to match Windows

The initial value for RMD_VERSION is one on Windows. The MS-DRSR spec
states the following in section 5.11 AttributeStamp:

  dwVersion: A 32-bit integer. Set to 1 when a value for the attribute is
  set for the first time. On each subsequent originating update, if the
  current value of dwVersion is less than 0xFFFFFFFF, then increment it
  by 1; otherwise set it to 0

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Remove static values passed to replmd_build_la_val()
Tim Beale [Thu, 28 Sep 2017 02:01:21 +0000 (15:01 +1300)]
replmd: Remove static values passed to replmd_build_la_val()

replmd_build_la_val() is used to populate a new link attribute value
from scratch. The version parameter is always passed in as the initial
value (zero), and deleted is always passed in as false.

For cases (like replication) where we want to set version/deleted to
something other than the defaults, we can use replmd_set_la_val()
instead.

This patch changes these 2 parameters to variables instead.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoselftest: Add test for initial link attribute RMD_VERSION value
Tim Beale [Thu, 28 Sep 2017 01:42:08 +0000 (14:42 +1300)]
selftest: Add test for initial link attribute RMD_VERSION value

While testing link conflicts I noticed that links on Windows start from
a different RMD_VERSION compared to Samba. This adds a simple test to
highlight the problem.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Small refactor to replmd_check_singleval_la_conflict()
Tim Beale [Wed, 27 Sep 2017 23:10:11 +0000 (12:10 +1300)]
replmd: Small refactor to replmd_check_singleval_la_conflict()

Now that the code is all in one place we can refactor it to make it
slightly more readable.

- added more code comments
- tweaked the 'no conflict' return logic to try to make what it's checking
  for more obvious
- removed conflict_pdn (we can just use active_pdn instead)
- added a placeholder variable and tweaked a parameter name

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Change replmd_check_singleval_la_conflict() logic flow
Tim Beale [Wed, 27 Sep 2017 23:01:34 +0000 (12:01 +1300)]
replmd: Change replmd_check_singleval_la_conflict() logic flow

Return immediately if there's no conflict, which reduces nesting.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Move link conflict handling into separate function
Tim Beale [Wed, 27 Sep 2017 21:22:55 +0000 (10:22 +1300)]
replmd: Move link conflict handling into separate function

Link conflict handling is a corner-case. The logic in
replmd_process_linked_attribute() is already reasonably busy/complex.
Split out the handling of link conflicts into a separate function so
that it doesn't detract from the core replmd_process_linked_attribute()
logic too much.

This refactor should not alter functionality.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Handle single-valued conflicts for an existing link
Tim Beale [Wed, 27 Sep 2017 20:42:14 +0000 (09:42 +1300)]
replmd: Handle single-valued conflicts for an existing link

Currently the code only handles the case where the received link
attribute is a new link (i.e. pdn == NULL). As well as this, we need to
handle the case where the conflicting link already exists, i.e. it's a
deleted link that has been re-added on another DC.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Mark link conflicts as inactive correctly
Tim Beale [Wed, 27 Sep 2017 03:37:59 +0000 (16:37 +1300)]
replmd: Mark link conflicts as inactive correctly

The previous patch to handle link conflicts was simply overriding the
received information and marking the link as deleted. We should be doing
this as a separate operation to make it clear what has happened, and so
that the new (i.e. inactive) link details get replicated out.

This patch changes it so that when a conflict occurs, we immediately
overwrite the received information to mark it as deleted, and to update
the version/USN/timestamp/originating_invocation_id to make it clear
that this is a new change.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Use replmd_set_la_val() when adding new links
Tim Beale [Wed, 27 Sep 2017 03:23:29 +0000 (16:23 +1300)]
replmd: Use replmd_set_la_val() when adding new links

replmd_set_la_val() and replmd_build_la_val() are almost identical. When
we were processing the replicated link attributes we were calling one
function if the link was new, and a different one if the link existed.
I think we should be able to get away with using replmd_set_la_val() in
both cases.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Fix talloc inconsistency in replmd_set_la_val()
Tim Beale [Thu, 28 Sep 2017 03:19:29 +0000 (16:19 +1300)]
replmd: Fix talloc inconsistency in replmd_set_la_val()

All the other talloc_asprintf()s in this function use the mem_ctx, but
for some reason the vstring was using the dsdb_dn->dn. This probably
isn't a big deal, but might have unintentional side-effects.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Make replmd_set_la_val() closer to replmd_build_la_val()
Tim Beale [Thu, 28 Sep 2017 02:58:16 +0000 (15:58 +1300)]
replmd: Make replmd_set_la_val() closer to replmd_build_la_val()

These two functions are almost identical. The main difference between
them is the RMD_ADDTIME. replmd_set_la_val() tries to use the
RMD_ADDTIME of the old_dsdb_dn. Whereas replmd_build_la_val() always
uses the time passed in.

Change replmd_set_la_val() so it can accept a NULL old_dsdb_dn (i.e. if
it's a new linked attribute that's being set). If so, it'll end up using
the nttime parameter passed in, same as replmd_build_la_val() does.

Also update replmd_process_linked_attribute (which used to use
replmd_build_la_val()) to now pass in a NULL old_dsdb_dn. There
shouldn't be a difference in behaviour either way, but this exercises
the code change.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Handle conflicts for single-valued link attributes better
Tim Beale [Wed, 27 Sep 2017 00:44:29 +0000 (13:44 +1300)]
replmd: Handle conflicts for single-valued link attributes better

If 2 DCs independently set a single-valued linked attribute to differing
values, Samba should be able to resolve this problem when replication
occurs.

If the received information is better, then we want to set the existing
link attribute in our DB as inactive.

If our own information is better, then we still want to add the received
link attribute, but mark it as inactive so that it doesn't clobber our
own link.

This still isn't a complete solution. When we add the received attribute
as inactive, we really should be incrementing the version, updating the
USN, etc. Also this only deals with the case where the received link is
completely new (i.e. a received link conflicting with an existing
inactive link isn't handled).

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Partial fix for single-valued link conflict
Tim Beale [Mon, 18 Sep 2017 23:59:58 +0000 (11:59 +1200)]
replmd: Partial fix for single-valued link conflict

This is the first part of the fix for resolving a single-valued link
conflict.

When processing the replication data for a linked attribute, if we don't
find a match for the link target value, check if the link is a
single-valued attribute and it currently has an active link. If so, then
use the active link instead.

This change means we delete the existing active link (and backlink)
before adding the new link. This prevents the failure in the subsequent
dsdb_check_single_valued_link() check that was happening previously
(because the link would end up with 2 active values).

This is only a partial fix. It stops replication from failing completely
if we ever hit this situation (which means the test is no longer
hitting an assertion when replicating). However, ideally the existing
active link should be retained and just marked as deleted (with this
change, the existing link is overwritten completely).

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoselftest: Add conflict test where the single-valued link already exists
Tim Beale [Wed, 27 Sep 2017 01:43:53 +0000 (14:43 +1300)]
selftest: Add conflict test where the single-valued link already exists

As well as testing scenarios where both variants of the link are new, we
should also check the case where the received link already exists on the
DC as an inactive (i.e. previously deleted) link.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoselftest: Add test for deleted single-valued link conflict
Tim Beale [Tue, 26 Sep 2017 00:55:11 +0000 (13:55 +1300)]
selftest: Add test for deleted single-valued link conflict

Currently we're only testing the case where the links have been modified
independently on 2 different DCs and both the links are active. We also
want to test the case where one link is active and the other is deleted.

Technically, this isn't really a conflict - the links involve different
target DNs, and the end result is still only one active link.

It's still probably worth having these tests to prove that fixing bug
13055 doesn't break anything.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoselftest: Make sure single-link conflict retains the deleted link
Tim Beale [Tue, 19 Sep 2017 01:41:02 +0000 (13:41 +1200)]
selftest: Make sure single-link conflict retains the deleted link

There should only ever be one active value for a single-valued link
attribute. When a conflict occurs the 'losing' value should still be
present, but should be marked as deleted.

This change is just making the test criteria stricter to make sure that
we fix the bug correctly.

Note that the only way to query the deleted link attributes present
is to send a DRS request.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Remove unused originating_usn variable
Tim Beale [Mon, 18 Sep 2017 04:39:44 +0000 (16:39 +1200)]
replmd: Remove unused originating_usn variable

The previous refactor makes it obvious that we aren't actually using
this variable for anything.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Refactor logic to check if replicated link is newer
Tim Beale [Mon, 18 Sep 2017 04:33:30 +0000 (16:33 +1200)]
replmd: Refactor logic to check if replicated link is newer

This is precursor work for supporting single-link conflicts.

Split out the code to check if the link update is newer. It's now safe
to call this from the main codepath. This also means we can combine the 2
calls to get the seqnum into a single common call.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplmd: Refactor adding the backlink in replmd_process_linked_attribute()
Tim Beale [Mon, 18 Sep 2017 01:47:56 +0000 (13:47 +1200)]
replmd: Refactor adding the backlink in replmd_process_linked_attribute()

The code to add the backlink is the same in both the 'if' and the 'else'
case, so move it outside the if-else block.

(We're going to rework this block of code quite a bit in order to
support single-value linked attribute conflicts, aka bug #13055).

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agoreplace: Link to -lbsd when building replace.c by hand
Andrew Bartlett [Sat, 14 Oct 2017 09:38:18 +0000 (22:38 +1300)]
replace: Link to -lbsd when building replace.c by hand

This ensures that we correctly detect HAVE_IFACE_GETIFADDRS
et al, which are based on a "build the source" style test.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
22 months agos3:cli_netlogon: let rpccli_connect_netlogon() retry once after NT_STATUS_NETWORK_ACC...
Stefan Metzmacher [Wed, 18 Oct 2017 11:36:59 +0000 (13:36 +0200)]
s3:cli_netlogon: let rpccli_connect_netlogon() retry once after NT_STATUS_NETWORK_ACCESS_DENIED

Otherwise we could easily endup with an endless loop.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agos3:cli_netlogon: make sure rpccli_connect_netlogon only returns NT_STATUS_OK on success
Stefan Metzmacher [Wed, 18 Oct 2017 11:36:59 +0000 (13:36 +0200)]
s3:cli_netlogon: make sure rpccli_connect_netlogon only returns NT_STATUS_OK on success

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agos3:tests: Fix the smblcient utimes test in Europe
Andreas Schneider [Thu, 19 Oct 2017 16:03:27 +0000 (18:03 +0200)]
s3:tests: Fix the smblcient utimes test in Europe

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Oct 20 03:37:31 CEST 2017 on sn-devel-144

22 months agos4:smbd: Add missing unistd.h include to fix build of process_prefork
Andreas Schneider [Thu, 19 Oct 2017 15:27:23 +0000 (17:27 +0200)]
s4:smbd: Add missing unistd.h include to fix build of process_prefork

error: implicit declaration of function ‘getpgrp’; did you mean ‘getpt’?
[-Werror=implicit-function-declaration]

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
22 months agonwrap: Fix strotoul checks for NSS_WRAPPER_MAX_HOSTENTS
Douglas Bagnall [Thu, 19 Oct 2017 08:56:15 +0000 (10:56 +0200)]
nwrap: Fix strotoul checks for NSS_WRAPPER_MAX_HOSTENTS

The env and endptr pointers need to be dereferenced, but that is not
enough: we don't really want to regard an empty string (*env == '\0')
as a valid number.

Found by GCC 8.0.0 20170705 (experimental).

[2095/4103] Compiling lib/nss_wrapper/nss_wrapper.c
../lib/nss_wrapper/nss_wrapper.c: In function "nwrap_init":
../lib/nss_wrapper/nss_wrapper.c:1571:13: warning: comparison between pointer and zero character constant [-Wpointer-compare]
   if (((env != '\0') && (endptr == '\0')) ||
                ^~
                ../lib/nss_wrapper/nss_wrapper.c:1571:9: note: did you mean to dereference the pointer?
   if (((env != '\0') && (endptr == '\0')) ||
            ^
            ../lib/nss_wrapper/nss_wrapper.c:1571:33: warning: comparison between pointer and zero character constant [-Wpointer-compare]
   if (((env != '\0') && (endptr == '\0')) ||
                                    ^~
                                    ../lib/nss_wrapper/nss_wrapper.c:1571:26: note: did you mean to dereference the pointer?
   if (((env != '\0') && (endptr == '\0')) ||

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Oct 19 16:42:17 CEST 2017 on sn-devel-144

22 months agopython: use communicate to fix Popen deadlock
Joe Guo [Fri, 15 Sep 2017 04:13:26 +0000 (16:13 +1200)]
python: use communicate to fix Popen deadlock

`Popen.wait()` will deadlock when using stdout=PIPE and/or stderr=PIPE and the
child process generates large output to a pipe such that it blocks waiting for
the OS pipe buffer to accept more data. Use communicate() to avoid that.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Oct 19 09:27:16 CEST 2017 on sn-devel-144

22 months agopython: add a failed test to show Popen deadlock
Joe Guo [Fri, 15 Sep 2017 03:31:34 +0000 (15:31 +1200)]
python: add a failed test to show Popen deadlock

`Popen.wait()` will deadlock when using stdout=PIPE and/or stderr=PIPE and the
child process generates large output to a pipe such that it blocks waiting for
the OS pipe buffer to accept more data. Use communicate() to avoid that.

This patch is commited to show the issue, a fix patch will come later.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
22 months agosource4/smbd: replace DEBUG( with DBG_
Gary Lockyer [Sun, 10 Sep 2017 23:39:39 +0000 (11:39 +1200)]
source4/smbd: replace DEBUG( with DBG_

Update the debug logging to use the currently preferred debug macros

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agoselftest: set ad_dc process model to prefork
Gary Lockyer [Tue, 5 Sep 2017 00:31:52 +0000 (12:31 +1200)]
selftest: set ad_dc process model to prefork

Set the process model for ad_dc to prefork, so that the pre-fork gets
exercised during self test.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agosource4/smbd: add a prefork process model.
Gary Lockyer [Thu, 7 Sep 2017 02:30:15 +0000 (14:30 +1200)]
source4/smbd: add a prefork process model.

Add a pre fork process model to bound the number processes forked by
samba.  Currently workers are only pre-forked for the ldap server,  all
the other services have pre-fork support disabled.

When pre-fork support is disabled a new process is started for each
service, and requests are processed by that process.

This commit partially reverts commit
b5be45c453bd51373bade26c29828b500ba586ec.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agosource4/smbd: Fix code formatting after refactoring.
Gary Lockyer [Thu, 14 Sep 2017 21:15:35 +0000 (09:15 +1200)]
source4/smbd: Fix code formatting after refactoring.

Fix code formatting from the refactoring in the previous commits.
Done as a separate patch to make the changes to functionality easier
to review.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agoprocess_standard: Do not log at level 2 every time a child exits
Gary Lockyer [Mon, 18 Sep 2017 01:02:13 +0000 (13:02 +1200)]
process_standard: Do not log at level 2 every time a child exits

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agosource4/smbd: Do not overstamp the process model with "single"
Gary Lockyer [Mon, 18 Sep 2017 01:05:24 +0000 (13:05 +1200)]
source4/smbd: Do not overstamp the process model with "single"

Instead, except in RPC which is a special SNOWFLAKE, we rely on the struct
service_details in the init function.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agoprocess_standard: Honour proc_ctx->inhibit_fork_on_accept
Gary Lockyer [Thu, 19 Oct 2017 02:15:33 +0000 (15:15 +1300)]
process_standard: Honour proc_ctx->inhibit_fork_on_accept

This allows the service to control if it should fork per accept() without needing
to replace the whole process model with process_single.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agoprocess_standard: Move child pipe setup further down standard_accept_connection()
Gary Lockyer [Thu, 19 Oct 2017 02:14:16 +0000 (15:14 +1300)]
process_standard: Move child pipe setup further down standard_accept_connection()

This avoids cleaning up on error from accept() but more importantly
allows a future mode that acts like process_single and so has no child.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agoprocess_standard: Use the new process_context
Gary Lockyer [Mon, 18 Sep 2017 00:56:09 +0000 (12:56 +1200)]
process_standard: Use the new process_context

Use the new process_context to control the from_parent_fd
This avoids the use of global variables, and will in the next patch
allow process_standard to run as what was known as single without
over-stamping a different process model.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months ago source4/smbd: refactor the process model for prefork
Gary Lockyer [Thu, 14 Sep 2017 19:09:23 +0000 (07:09 +1200)]
 source4/smbd: refactor the process model for prefork

    Refactor the process model code to allow the addition of a prefork
    process model.

    - Add a process context to contain process model specific state
    - Add a service details structure to allow service to indicate which
      process model options they can support.

    In the new code the services advertise the features they support to the
    process model.  The process model context is plumbed through to allow the
    process model to keep track of the supported options, and any state
    the process model may require.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agotests: Add a blackbox test for smbcontrol
Gary Lockyer [Tue, 12 Sep 2017 23:21:02 +0000 (11:21 +1200)]
tests: Add a blackbox test for smbcontrol

Add tests to check that samba processes have started and that they can be
pinged.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
22 months agorpc_client: Fix wording in a DEBUG statement
Volker Lendecke [Wed, 18 Oct 2017 11:26:07 +0000 (13:26 +0200)]
rpc_client: Fix wording in a DEBUG statement

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 Oct 19 04:57:44 CEST 2017 on sn-devel-144

22 months agoRemoved unused 'oplock contention limit' config parameter
Christof Schmitt [Tue, 17 Oct 2017 21:49:17 +0000 (14:49 -0700)]
Removed unused 'oplock contention limit' config parameter

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
22 months agos3: tests: Add smbclient test for utimes command.
Jeremy Allison [Wed, 18 Oct 2017 20:54:22 +0000 (13:54 -0700)]
s3: tests: Add smbclient test for utimes command.

Signed-off-by: Jeremy Allison <jra@samba.org>
22 months agos3:Add a utimes command to smbclient so we can set the Windows times.
Richard Sharpe [Mon, 16 Oct 2017 20:51:51 +0000 (13:51 -0700)]
s3:Add a utimes command to smbclient so we can set the Windows times.

Add an update to the smbclient man page.

Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
22 months agodbcheck: Allow removal of one-way links to missing objects
Andrew Bartlett [Tue, 17 Oct 2017 10:01:51 +0000 (23:01 +1300)]
dbcheck: Allow removal of one-way links to missing objects

If dbcheck is not run within the tombstone lifetime, these links can
persist in the database forever.  The risk of unintentional information loss
is why these links are only removed within the same partition.  A
replication may be in progress which has created only one end of
the link, so we must keep that.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Rowland Penny <rpenny@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Oct 19 00:50:19 CEST 2017 on sn-devel-144

22 months agounittests: Fix missing include of signal.h
Lumir Balhar [Wed, 11 Oct 2017 19:02:24 +0000 (21:02 +0200)]
unittests: Fix missing include of signal.h

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Oct 18 14:24:39 CEST 2017 on sn-devel-144

22 months agopython: Fix Python 2.6 compatibility
Lumir Balhar [Wed, 11 Oct 2017 19:00:29 +0000 (21:00 +0200)]
python: Fix Python 2.6 compatibility

PyErr_NewExceptionWithDoc() isn't available in Python 2.6 so it can
be used only in higher versions of Python.

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>