[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Thu Feb 6 16:25:01 UTC 2020


The branch, master has been updated
       via  c8e3c78d4f2 selftest: Test behaviour of DNS scavenge with an existing dNSTombstoned value
       via  3657bbc2118 dsdb: Correctly handle memory in objectclass_attrs
       via  d3b385d5963 source4/scripting/bin: Swap machine account password scripts
       via  76e1206717e smb2_server: use sendmsg/recvmsg instead of writev/readv
       via  7d1b560804b selftest: create a pcap file for the environment setup
       via  f182c9a36b4 selftest: create pcap files for invidual env services
       via  4effc5585ec selftest: move {setup,cleanup}_pcap() to selftest/target/Samba.pm
       via  c48ae9cf4db selftest: force LC_ALL=en_US.utf8 LANG=en_US.utf8
       via  cc7b909b8bb s3:rpclient: simplify rpc_tstream_next_vector()
       via  8b80145a2c0 s4:torture: make rpc.handles.random-assoc test even more robust
      from  f705629a171 smbd: avoid double chdir() in chdir_current_service()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c8e3c78d4f2a6f3e122fe458aa6835772290a700
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jan 30 16:44:05 2020 +1300

    selftest: Test behaviour of DNS scavenge with an existing dNSTombstoned value
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14258
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Thu Feb  6 16:24:25 UTC 2020 on sn-devel-184

commit 3657bbc21182d764ddfcd603025f24ec240fd263
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jan 30 16:41:39 2020 +1300

    dsdb: Correctly handle memory in objectclass_attrs
    
    el->values is caller-provided memory that should be thought of as constant,
    it should not be assumed to be a talloc context.
    
    Otherwise, if the caller gives constant memory or a stack
    pointer we will get an abort() in talloc when it expects
    a talloc magic in the memory preceeding the el->values.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14258
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit d3b385d59634927a4ddbfa7885ac5f2e004f4e03
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 3 16:45:45 2020 +1300

    source4/scripting/bin: Swap machine account password scripts
    
    I regularly get requests for my simple script to print the
    password from the secrets.tdb (or secrets.ldb on the AD DC).
    
    This removes the old script that only reads the secrets.ldb.
    
    Neither new nor old script has tests, however it seems
    better to have it in the tree where it can be found rather
    that me digging it out of my outbound e-mail.
    
    Originally posted here:
     https://lists.samba.org/archive/samba/2017-November/212362.html
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 76e1206717e76dadc212f3363d3faeb66b18c7e7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 27 13:02:50 2018 +0200

    smb2_server: use sendmsg/recvmsg instead of writev/readv
    
    This avoids a few function calls inside the kernel
    in order to reach sock_sendmsg() quicker:
    
        entry_SYSCALL_64_after_hwframe
           do_syscall_64
              __x64_sys_writev
                 do_writev
                    vfs_writev
                       do_iter_write
                          do_iter_readv_writev
                             sock_write_iter
                                sock_sendmsg
    
        entry_SYSCALL_64_after_hwframe
           do_syscall_64
              __x64_sys_sendmsg
                 __sys_sendmsg
                    ___sys_sendmsg
                       sock_sendmsg
    
    As a side effect it will be useful for SMB-Direct invalidation
    messages via msg->msg_control and CMSG_*.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 7d1b560804b46fd6de83fa1b478d180a4184b5d3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Nov 14 17:36:36 2019 +0100

    selftest: create a pcap file for the environment setup
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit f182c9a36b4a6f083aac0c7137ffad248006f297
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Oct 30 21:53:39 2019 +0100

    selftest: create pcap files for invidual env services
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 4effc5585ec5fca0c232b3b8fe772cea75941bb7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Feb 4 17:03:17 2020 +0100

    selftest: move {setup,cleanup}_pcap() to selftest/target/Samba.pm
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit c48ae9cf4dbbcd4154f6642f18a73c871024cccb
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Nov 18 22:02:13 2019 +0100

    selftest: force LC_ALL=en_US.utf8 LANG=en_US.utf8
    
    That makes sure we have the same as on gitlab runners
    (see bootstrap/config.py).
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit cc7b909b8bb5ac3874892fdf54bd3e14389f88c4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 22 15:14:21 2020 +0000

    s3:rpclient: simplify rpc_tstream_next_vector()
    
    We always now how many bytes our caller requires,
    so there's no need to use tstream_pending_bytes().
    
    This makes it possible to read socket_wrapper generated
    captures again, as wireshark requires the fixed (16 bytes) DCERPC
    header to be in one TCP packet.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 8b80145a2c0686cd6b95df89236edeb61192d917
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jan 27 16:45:44 2020 +0100

    s4:torture: make rpc.handles.random-assoc test even more robust
    
    This improves commit bebee47e6386476e9948089484f89d213fcc2660 a bit
    further.
    
    I just got this:
    
      connect samr pipe1
      use assoc_group_id[0x00000001] for new connections
      connect lsa pipe2
      got assoc_group_id[0x00000001] for p2
      samr_Connect to open a policy handle on samr p1
      use policy handle on lsa p2 - should fail
      closing policy handle on samr p1
      connect samr pipe3 - should fail
      Failed to bind to uuid 12345778-1234-abcd-ef00-0123456789ac for ncacn_np:localdc[\pipe\samr,validate,assoc_group_id=0x00000001,abstract_syntax=12345778-1234-abcd-ef00-0123456789ac/0x00000001] NT_STATUS_UNSUCCESSFUL
      connect lsa pipe4 - should fail
      Failed to bind to uuid 12345778-1234-abcd-ef00-0123456789ab for ncacn_np:localdc[\pipe\lsarpc,validate,assoc_group_id=0x00000001,abstract_syntax=12345778-1234-abcd-ef00-0123456789ab/0x00000000] NT_STATUS_UNSUCCESSFUL
      connect samr pipe5 with assoc_group_id[0xFFFFFFFF]- should fail
      Failed to bind to uuid 12345778-1234-abcd-ef00-0123456789ac for ncacn_np:localdc[\pipe\samr,validate,assoc_group_id=0xffffffff,abstract_syntax=12345778-1234-abcd-ef00-0123456789ac/0x00000001] NT_STATUS_UNSUCCESSFUL
      connect lsa pipe6 with assoc_group_id[0x00000000]- should fail
      UNEXPECTED(failure): samba4.rpc.handles on ncacn_np with validate.mixed-shared(ad_dc_ntvfs)
      REASON: Exception: Exception: ../../source4/torture/rpc/handles.c:500: status was NT_STATUS_OK, expected NT_STATUS_UNSUCCESSFUL: opening lsa pipe6
      FAILED (1 failures, 0 errors and 0 unexpected successes in 0 testsuites)
      A summary with detailed information can be found in:
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 python/samba/tests/dns.py                          | 39 ++++++++++++++
 selftest/knownfail.d/usage                         |  2 +-
 selftest/selftest.pl                               | 42 ++++-----------
 selftest/target/Samba.pm                           | 45 ++++++++++++++--
 selftest/target/Samba3.pm                          |  6 ++-
 selftest/target/Samba4.pm                          | 12 ++---
 source3/rpc_client/rpc_transport_tstream.c         | 36 ++-----------
 source3/smbd/smb2_server.c                         | 16 +++++-
 source4/dsdb/samdb/ldb_modules/objectclass_attrs.c | 17 +++++-
 source4/scripting/bin/machineaccountpw             | 42 +++++++++++++++
 source4/scripting/bin/mymachinepw                  | 61 ----------------------
 source4/torture/rpc/handles.c                      |  2 +-
 12 files changed, 176 insertions(+), 144 deletions(-)
 create mode 100755 source4/scripting/bin/machineaccountpw
 delete mode 100755 source4/scripting/bin/mymachinepw


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py
index 1dd1f549a33..bc05076c615 100644
--- a/python/samba/tests/dns.py
+++ b/python/samba/tests/dns.py
@@ -1523,26 +1523,51 @@ class TestZones(DNSTest):
         name, txt = 'agingtest', ['test txt']
         name2, txt2 = 'agingtest2', ['test txt2']
         name3, txt3 = 'agingtest3', ['test txt3']
+        name4, txt4 = 'agingtest4', ['test txt4']
+        name5, txt5 = 'agingtest5', ['test txt5']
         self.dns_update_record(name, txt)
         self.dns_update_record(name2, txt)
         self.dns_update_record(name2, txt2)
         self.dns_update_record(name3, txt)
         self.dns_update_record(name3, txt2)
+
+        # Create a tomb stoned record.
+        self.dns_update_record(name4, txt4)
+        self.dns_tombstone(name4, txt4, self.zone)
+        records = self.ldap_get_records(name4)
+        self.assertTrue("dNSTombstoned" in records[0])
+        self.assertEqual(records[0]["dNSTombstoned"][0], b"TRUE")
+
+        # Create an un-tombstoned record, with dnsTombstoned: FALSE
+        self.dns_update_record(name5, txt5)
+        self.dns_tombstone(name5, txt5, self.zone)
+        self.dns_update_record(name5, txt5)
+        records = self.ldap_get_records(name5)
+        self.assertTrue("dNSTombstoned" in records[0])
+        self.assertEqual(records[0]["dNSTombstoned"][0], b"FALSE")
+
         last_add = self.dns_update_record(name3, txt3)
 
         def mod_ts(rec):
             self.assertTrue(rec.dwTimeStamp > 0)
             if rec.data.str == txt:
                 rec.dwTimeStamp -= interval * 5
+
+        def mod_ts_all(rec):
+            rec.dwTimeStamp -= interval * 5
         self.ldap_modify_dnsrecs(name, mod_ts)
         self.ldap_modify_dnsrecs(name2, mod_ts)
         self.ldap_modify_dnsrecs(name3, mod_ts)
+        self.ldap_modify_dnsrecs(name5, mod_ts_all)
         self.assertTrue(callable(getattr(dsdb, '_scavenge_dns_records', None)))
         dsdb._scavenge_dns_records(self.samdb)
 
         recs = self.ldap_get_dns_records(name)
         self.assertEqual(len(recs), 1)
         self.assertEqual(recs[0].wType, dnsp.DNS_TYPE_TOMBSTONE)
+        records = self.ldap_get_records(name)
+        self.assertTrue("dNSTombstoned" in records[0])
+        self.assertEqual(records[0]["dNSTombstoned"][0], b"TRUE")
 
         recs = self.ldap_get_dns_records(name2)
         self.assertEqual(len(recs), 1)
@@ -1556,6 +1581,20 @@ class TestZones(DNSTest):
         self.assertEqual(recs[0].wType, dnsp.DNS_TYPE_TXT)
         self.assertEqual(recs[1].wType, dnsp.DNS_TYPE_TXT)
 
+        recs = self.ldap_get_dns_records(name4)
+        self.assertEqual(len(recs), 1)
+        self.assertEqual(recs[0].wType, dnsp.DNS_TYPE_TOMBSTONE)
+        records = self.ldap_get_records(name4)
+        self.assertTrue("dNSTombstoned" in records[0])
+        self.assertEqual(records[0]["dNSTombstoned"][0], b"TRUE")
+
+        recs = self.ldap_get_dns_records(name5)
+        self.assertEqual(len(recs), 1)
+        self.assertEqual(recs[0].wType, dnsp.DNS_TYPE_TOMBSTONE)
+        records = self.ldap_get_records(name5)
+        self.assertTrue("dNSTombstoned" in records[0])
+        self.assertEqual(records[0]["dNSTombstoned"][0], b"TRUE")
+
         for make_it_work in [False, True]:
             inc = -1 if make_it_work else 1
 
diff --git a/selftest/knownfail.d/usage b/selftest/knownfail.d/usage
index 3e54f80a2de..47a5783f6de 100644
--- a/selftest/knownfail.d/usage
+++ b/selftest/knownfail.d/usage
@@ -11,7 +11,6 @@ samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_ctdb_etcd_lock.no
 samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_depfilter_py.none.
 samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_dns_hub_py.none.
 samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_gen_hresult_py.none.
-samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_mymachinepw.none.
 samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_repl_cleartext_pwd_py.none.
 samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_run_py.none.
 samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_run_py_.none.
@@ -21,6 +20,7 @@ samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_tests_py_.none.
 samba.tests.usage.samba.tests.usage.PythonScriptHelpTests.test_waf.none.
 samba.tests.usage.samba.tests.usage.PythonScriptUsageTests.test_chgtdcpass.none.
 samba.tests.usage.samba.tests.usage.PythonScriptUsageTests.test_findprovisionusnranges.none.
+samba.tests.usage.samba.tests.usage.PythonScriptUsageTests.test_machineaccountpw.none.
 samba.tests.usage.samba.tests.usage.PythonScriptUsageTests.test_rebuildextendeddn.none.
 samba.tests.usage.samba.tests.usage.PythonScriptUsageTests.test_renamedc.none.
 samba.tests.usage.samba.tests.usage.PythonScriptUsageTests.test_repl_cleartext_pwd_py.none.
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 087fcefc502..02848f83794 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -105,35 +105,6 @@ sub skip
 
 sub getlog_env($);
 
-sub setup_pcap($)
-{
-	my ($name) = @_;
-
-	return unless ($opt_socket_wrapper_pcap);
-	return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR});
-
-	my $fname = $name;
-	$fname =~ s%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g;
-
-	my $pcap_file = "$ENV{SOCKET_WRAPPER_PCAP_DIR}/$fname.pcap";
-
-	SocketWrapper::setup_pcap($pcap_file);
-
-	return $pcap_file;
-}
-
-sub cleanup_pcap($$)
-{
-	my ($pcap_file, $exitcode) = @_;
-
-	return unless ($opt_socket_wrapper_pcap);
-	return if ($opt_socket_wrapper_keep_pcap);
-	return unless ($exitcode == 0);
-	return unless defined($pcap_file);
-
-	unlink($pcap_file);
-}
-
 # expand strings from %ENV
 sub expand_environment_strings($)
 {
@@ -145,10 +116,12 @@ sub expand_environment_strings($)
 	return $s;
 }
 
+my $target;
+
 sub run_testsuite($$$$$)
 {
 	my ($envname, $name, $cmd, $i, $totalsuites) = @_;
-	my $pcap_file = setup_pcap($name);
+	my $pcap_file = $target->setup_pcap($name);
 
 	Subunit::start_testsuite($name);
 	Subunit::progress_push();
@@ -186,7 +159,7 @@ sub run_testsuite($$$$$)
 		Subunit::end_testsuite($name, "failure", "Exit code was $exitcode");
 	}
 
-	cleanup_pcap($pcap_file, $exitcode);
+	$target->cleanup_pcap($pcap_file, $exitcode);
 
 	if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) {
 		print "PCAP FILE: $pcap_file\n";
@@ -298,7 +271,9 @@ unless (defined($ENV{VALGRIND})) {
 $ENV{PYTHONUNBUFFERED} = 1;
 
 # do not depend on the users setup
+# see also bootstrap/config.py
 $ENV{TZ} = "UTC";
+$ENV{LC_ALL} = $ENV{LANG} = "en_US.utf8";
 
 my $bindir_abs = abs_path($bindir);
 
@@ -447,7 +422,6 @@ if ($opt_use_dns_faking) {
 	$ENV{SAMBA_DNS_FAKING} = 1;
 }
 
-my $target;
 my $testenv_default = "none";
 
 if ($opt_mitkrb5 == 1) {
@@ -471,7 +445,9 @@ if (defined($ENV{SMBD_MAXTIME}) and $ENV{SMBD_MAXTIME} ne "") {
     $server_maxtime = $ENV{SMBD_MAXTIME};
 }
 
-$target = new Samba($bindir, $srcdir, $server_maxtime);
+$target = new Samba($bindir, $srcdir, $server_maxtime,
+		    $opt_socket_wrapper_pcap,
+		    $opt_socket_wrapper_keep_pcap);
 unless ($opt_list) {
 	if ($opt_target eq "samba") {
 		$testenv_default = "ad_dc";
diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm
index b7b46413b68..26b838981f6 100644
--- a/selftest/target/Samba.pm
+++ b/selftest/target/Samba.pm
@@ -14,12 +14,15 @@ use Cwd qw(abs_path);
 use IO::Poll qw(POLLIN);
 
 sub new($$$$$) {
-	my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
+	my ($classname, $bindir, $srcdir, $server_maxtime,
+	    $opt_socket_wrapper_pcap, $opt_socket_wrapper_keep_pcap) = @_;
 
 	my $self = {
-	    samba3 => new Samba3($bindir, $srcdir, $server_maxtime),
-	    samba4 => new Samba4($bindir, $srcdir, $server_maxtime),
+	    opt_socket_wrapper_pcap => $opt_socket_wrapper_pcap,
+	    opt_socket_wrapper_keep_pcap => $opt_socket_wrapper_keep_pcap,
 	};
+	$self->{samba3} = new Samba3($self, $bindir, $srcdir, $server_maxtime);
+	$self->{samba4} = new Samba4($self, $bindir, $srcdir, $server_maxtime);
 	bless $self;
 	return $self;
 }
@@ -44,6 +47,35 @@ foreach my $env (keys %Samba3::ENV_DEPS) {
     $ENV_NEEDS_AD_DC{$env} = ($env =~ /^ad_/);
 }
 
+sub setup_pcap($$)
+{
+	my ($self, $name) = @_;
+
+	return unless ($self->{opt_socket_wrapper_pcap});
+	return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR});
+
+	my $fname = $name;
+	$fname =~ s%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g;
+
+	my $pcap_file = "$ENV{SOCKET_WRAPPER_PCAP_DIR}/$fname.pcap";
+
+	SocketWrapper::setup_pcap($pcap_file);
+
+	return $pcap_file;
+}
+
+sub cleanup_pcap($$$)
+{
+	my ($self, $pcap_file, $exitcode) = @_;
+
+	return unless ($self->{opt_socket_wrapper_pcap});
+	return if ($self->{opt_socket_wrapper_keep_pcap});
+	return unless ($exitcode == 0);
+	return unless defined($pcap_file);
+
+	unlink($pcap_file);
+}
+
 sub setup_env($$$)
 {
 	my ($self, $envname, $path) = @_;
@@ -84,7 +116,10 @@ sub setup_env($$$)
 
 	my $setup_name = $ENV_TARGETS{$envname}."::setup_".$envname;
 	my $setup_sub = \&$setup_name;
+	my $setup_pcap_file = $self->setup_pcap("env-$ENV{ENVNAME}-setup");
 	my $env = &$setup_sub($target, "$path/$envname", @dep_vars);
+	$self->cleanup_pcap($setup_pcap_file, not defined($env));
+	SocketWrapper::setup_pcap(undef);
 
 	if (not defined($env)) {
 		warn("failed to start up environment '$envname'");
@@ -638,6 +673,8 @@ sub get_env_for_process
 sub fork_and_exec
 {
 	my ($self, $env_vars, $daemon_ctx, $STDIN_READER) = @_;
+	my $SambaCtx = $self;
+	$SambaCtx = $self->{SambaCtx} if defined($self->{SambaCtx});
 
 	unlink($daemon_ctx->{LOG_FILE});
 	print "STARTING $daemon_ctx->{NAME} for $ENV{ENVNAME}...";
@@ -662,7 +699,7 @@ sub fork_and_exec
 
 		SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
 		if (defined($daemon_ctx->{PCAP_FILE})) {
-			SocketWrapper::setup_pcap($daemon_ctx->{PCAP_FILE});
+			$SambaCtx->setup_pcap("$daemon_ctx->{PCAP_FILE}");
 		}
 
 		# setup ENV variables in the child process
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index a3e2129b185..0c9adcc76fd 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -54,8 +54,9 @@ sub get_fs_specific_conf($$)
 }
 
 sub new($$) {
-	my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
+	my ($classname, $SambaCtx, $bindir, $srcdir, $server_maxtime) = @_;
 	my $self = { vars => {},
+		     SambaCtx => $SambaCtx,
 		     bindir => $bindir,
 		     srcdir => $srcdir,
 		     server_maxtime => $server_maxtime
@@ -1346,6 +1347,7 @@ sub check_or_start($$$$$) {
 		BINARY_PATH => $binary,
 		FULL_CMD => [ @full_cmd ],
 		LOG_FILE => $env_vars->{NMBD_TEST_LOG},
+		PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
 		ENV_VARS => $nmbd_envs,
 	};
 	if ($nmbd ne "yes") {
@@ -1370,6 +1372,7 @@ sub check_or_start($$$$$) {
 		BINARY_PATH => $binary,
 		FULL_CMD => [ @full_cmd ],
 		LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
+		PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
 	};
 	if ($winbindd ne "yes") {
 		$daemon_ctx->{SKIP_DAEMON} = 1;
@@ -1390,6 +1393,7 @@ sub check_or_start($$$$$) {
 		BINARY_PATH => $binary,
 		FULL_CMD => [ @full_cmd ],
 		LOG_FILE => $env_vars->{SMBD_TEST_LOG},
+		PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
 	};
 	if ($smbd ne "yes") {
 		$daemon_ctx->{SKIP_DAEMON} = 1;
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index e181289b66b..3f25317ea8c 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -20,14 +20,15 @@ use Archive::Tar;
 use File::Path 'make_path';
 
 sub new($$$$$) {
-	my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
+	my ($classname, $SambaCtx, $bindir, $srcdir, $server_maxtime) = @_;
 
 	my $self = {
 		vars => {},
+		SambaCtx => $SambaCtx,
 		bindir => $bindir,
 		srcdir => $srcdir,
 		server_maxtime => $server_maxtime,
-		target3 => new Samba3($bindir, $srcdir, $server_maxtime)
+		target3 => new Samba3($SambaCtx, $bindir, $srcdir, $server_maxtime)
 	};
 	bless $self;
 	return $self;
@@ -89,6 +90,7 @@ sub check_or_start($$$)
 		FULL_CMD => [ @full_cmd ],
 		LOG_FILE => $env_vars->{SAMBA_TEST_LOG},
 		TEE_STDOUT => 1,
+		PCAP_FILE => "env-$ENV{ENVNAME}-samba",
 		ENV_VARS => $samba_envs,
 	};
 	my $pid = Samba::fork_and_exec($self, $env_vars, $daemon_ctx, $STDIN_READER);
@@ -323,14 +325,10 @@ sub setup_dns_hub_internal($$$)
 		FULL_CMD => [ @full_cmd ],
 		LOG_FILE => $env->{DNS_HUB_LOG},
 		TEE_STDOUT => 1,
+		PCAP_FILE => "env-$ENV{ENVNAME}-dns_hub",
 		ENV_VARS => {},
 	};
 
-	my $pcap_dir = $ENV{SOCKET_WRAPPER_PCAP_DIR};
-	if (defined $pcap_dir) {
-		$daemon_ctx->{PCAP_FILE} = "$pcap_dir/env-$hostname$.pcap",
-	}
-
 	# use a pipe for stdin in the child processes. This allows
 	# those processes to monitor the pipe for EOF to ensure they
 	# exit when the test script exits
diff --git a/source3/rpc_client/rpc_transport_tstream.c b/source3/rpc_client/rpc_transport_tstream.c
index 3f4b616f3e8..3103fa46037 100644
--- a/source3/rpc_client/rpc_transport_tstream.c
+++ b/source3/rpc_client/rpc_transport_tstream.c
@@ -89,7 +89,6 @@ struct rpc_tstream_next_vector_state {
 	uint8_t *buf;
 	size_t len;
 	off_t ofs;
-	size_t remaining;
 };
 
 static void rpc_tstream_next_vector_init(
@@ -111,8 +110,6 @@ static int rpc_tstream_next_vector(struct tstream_context *stream,
 	struct rpc_tstream_next_vector_state *state =
 		(struct rpc_tstream_next_vector_state *)private_data;
 	struct iovec *vector;
-	ssize_t pending;
-	size_t wanted;
 
 	if (state->ofs == state->len) {
 		*_vector = NULL;
@@ -120,42 +117,15 @@ static int rpc_tstream_next_vector(struct tstream_context *stream,
 		return 0;
 	}
 
-	pending = tstream_pending_bytes(stream);
-	if (pending == -1) {
-		return -1;
-	}
-
-	if (pending == 0 && state->ofs != 0) {
-		/* return a short read */
-		*_vector = NULL;
-		*count = 0;
-		return 0;
-	}
-
-	if (pending == 0) {
-		/* we want at least one byte and recheck again */
-		wanted = 1;
-	} else {
-		size_t missing = state->len - state->ofs;
-		if (pending > missing) {
-			/* there's more available */
-			state->remaining = pending - missing;
-			wanted = missing;
-		} else {
-			/* read what we can get and recheck in the next cycle */
-			wanted = pending;
-		}
-	}
-
 	vector = talloc_array(mem_ctx, struct iovec, 1);
 	if (!vector) {
 		return -1;
 	}
 
-	vector[0].iov_base = state->buf + state->ofs;
-	vector[0].iov_len = wanted;
+	vector[0].iov_base = state->buf;
+	vector[0].iov_len = state->len;
 
-	state->ofs += wanted;
+	state->ofs = state->len;
 
 	*_vector = vector;
 	*count = 1;
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index 8c66d74c8de..a4372bf1145 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -3758,6 +3758,7 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn)
 	while (xconn->smb2.send_queue != NULL) {
 		struct smbd_smb2_send_queue *e = xconn->smb2.send_queue;
 		bool ok;
+		struct msghdr msg;
 
 		if (e->sendfile_header != NULL) {
 			size_t size = 0;
@@ -3806,7 +3807,12 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn)
 			continue;
 		}
 
-		ret = writev(xconn->transport.sock, e->vector, e->count);
+		msg = (struct msghdr) {
+			.msg_iov = e->vector,
+			.msg_iovlen = e->count,
+		};
+
+		ret = sendmsg(xconn->transport.sock, &msg, 0);
 		if (ret == 0) {
 			/* propagate end of file */
 			return NT_STATUS_INTERNAL_ERROR;
@@ -3862,6 +3868,7 @@ static NTSTATUS smbd_smb2_io_handler(struct smbXsrv_connection *xconn,
 	bool retry;
 	NTSTATUS status;
 	NTTIME now;
+	struct msghdr msg;
 
 	if (!NT_STATUS_IS_OK(xconn->transport.status)) {
 		/*
@@ -3896,7 +3903,12 @@ again:
 		state->vector.iov_len = NBT_HDR_SIZE;
 	}
 
-	ret = readv(xconn->transport.sock, &state->vector, 1);
+	msg = (struct msghdr) {
+		.msg_iov = &state->vector,
+		.msg_iovlen = 1,
+	};
+
+	ret = recvmsg(xconn->transport.sock, &msg, 0);
 	if (ret == 0) {
 		/* propagate end of file */
 		return NT_STATUS_END_OF_FILE;
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
index e5f86d260f4..0b9725e2767 100644
--- a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
+++ b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
@@ -133,7 +133,16 @@ static int oc_auto_normalise(struct ldb_context *ldb, const struct dsdb_attribut
 	for (i=0; i<el->num_values; i++) {
 		struct ldb_val v;
 		int ret;
-		ret = attr->ldb_schema_attribute->syntax->canonicalise_fn(ldb, el->values, &el->values[i], &v);
+		/*
+		 * We use msg->elements (owned by this module due to
+		 * ldb_msg_copy_shallow()) as a memory context and
+		 * then steal from there to the right spot if we don't
+		 * free it.
+		 */
+		ret = attr->ldb_schema_attribute->syntax->canonicalise_fn(ldb,
+									  msg->elements,
+									  &el->values[i],
+									  &v);
 		if (ret != LDB_SUCCESS) {
 			return ret;
 		}
@@ -156,6 +165,12 @@ static int oc_auto_normalise(struct ldb_context *ldb, const struct dsdb_attribut


-- 
Samba Shared Repository



More information about the samba-cvs mailing list