[SCM] Socket Wrapper Repository - branch master updated

2020-06-19 Thread Stefan Metzmacher
The branch, master has been updated
   via  49aeafa Revert "socket_wrapper.c: implement getsockopt(TCP_INFO) if 
the platform supports it"
   via  a6f95ed Revert "test_echo_tcp_socket_options.c: add tests for 
TCP_INFO"
   via  f13db2b Revert "socket_wrapper.c: make FIONREAD handling more 
robust in swrap_vioctl()"
   via  22cfac3 Revert "socket_wrapper.c: let swrap_vioctl() handle 
SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly"
   via  f4fc52b Merge branch 'tcp_info' into 'master'
   via  f317ebc socket_wrapper.c: let swrap_vioctl() handle 
SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly
   via  c95b7cb socket_wrapper.c: make FIONREAD handling more robust in 
swrap_vioctl()
   via  a37c017 test_echo_tcp_socket_options.c: add tests for TCP_INFO
   via  300de6e socket_wrapper.c: implement getsockopt(TCP_INFO) if the 
platform supports it
  from  bbc1d65 tests: do not truncate pid to 16 bits

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


- Log -
commit 49aeafa2c530e35a43358977766899d45a0c8b28
Author: Stefan Metzmacher 
Date:   Fri Jun 19 23:26:28 2020 +0200

Revert "socket_wrapper.c: implement getsockopt(TCP_INFO) if the platform 
supports it"

This reverts commit 300de6e099ea82ee5361918de8c3abb389e0782d.

This got merged automatically by gitlab without review.

Signed-off-by: Stefan Metzmacher 

commit a6f95ed59e2bc5a5d732738be7046e1e8422fb26
Author: Stefan Metzmacher 
Date:   Fri Jun 19 23:26:25 2020 +0200

Revert "test_echo_tcp_socket_options.c: add tests for TCP_INFO"

This reverts commit a37c0175492fb1b35257b785c71dea4e4f6d4750.

This got merged automatically by gitlab without review.

Signed-off-by: Stefan Metzmacher 

commit f13db2b166dd9cc0ee31b5cdffdacb34945d615a
Author: Stefan Metzmacher 
Date:   Fri Jun 19 23:26:22 2020 +0200

Revert "socket_wrapper.c: make FIONREAD handling more robust in 
swrap_vioctl()"

This reverts commit c95b7cb1d7b9348472276edceff71889aa676d25.

This got merged automatically by gitlab without review.

Signed-off-by: Stefan Metzmacher 

commit 22cfac3bfca20eedbd0e3e428f085b24fb553047
Author: Stefan Metzmacher 
Date:   Fri Jun 19 23:25:40 2020 +0200

Revert "socket_wrapper.c: let swrap_vioctl() handle 
SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly"

This reverts commit f317ebcdcdd626ed9e06de2eb60031306994c803.

This got merged automatically by gitlab without review.

Signed-off-by: Stefan Metzmacher 

commit f4fc52be79edc74bd24b3ee968c5358af81b17bd
Merge: bbc1d65 f317ebc
Author: Stefan Metzmacher 
Date:   Fri Jun 19 21:07:09 2020 +

Merge branch 'tcp_info' into 'master'

Add support for TCP_INFO and SIOCOUTQ/TIOCOUTQ/FIONWRITE

See merge request cwrap/socket_wrapper!11

commit f317ebcdcdd626ed9e06de2eb60031306994c803
Author: Stefan Metzmacher 
Date:   Mon Jun 8 14:21:25 2020 +0200

socket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE 
explicitly

They are used to ask for the number of unacked bytes in the send queue,
with AF_UNIX sockets get strange result, on linux 5.3 I get more bytes
reported than I sent into the socket. All bytes reach the destination
directly, so we can just always report 0 unacked bytes.

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

Signed-off-by: Stefan Metzmacher 

commit c95b7cb1d7b9348472276edceff71889aa676d25
Author: Stefan Metzmacher 
Date:   Mon Jun 8 14:18:44 2020 +0200

socket_wrapper.c: make FIONREAD handling more robust in swrap_vioctl()

We should only dereference the va args when the kernel already checked
they are valid.

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

Signed-off-by: Stefan Metzmacher 

commit a37c0175492fb1b35257b785c71dea4e4f6d4750
Author: Stefan Metzmacher 
Date:   Fri Jun 19 20:52:23 2020 +0200

test_echo_tcp_socket_options.c: add tests for TCP_INFO

Signed-off-by: Stefan Metzmacher 

commit 300de6e099ea82ee5361918de8c3abb389e0782d
Author: Stefan Metzmacher 
Date:   Mon Jun 8 10:32:28 2020 +0200

socket_wrapper.c: implement getsockopt(TCP_INFO) if the platform supports it

This just implements a few basics, which are required by Samba.

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

Signed-off-by: Stefan Metzmacher 

---

Summary of changes:


Changeset truncated at 500 lines:



-- 
Socket Wrapper Repository



[SCM] Samba Shared Repository - branch master updated

2020-06-19 Thread Andreas Schneider
The branch, master has been updated
   via  27709178e02 python: Fix get_max_worker_count() to always have two 
runners
  from  e478470f201 python: Run cmdline tools for arbitary docs test in 
parallel

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


- Log -
commit 27709178e02fcd955d3f142b0e83f429aa31e33d
Author: Andreas Schneider 
Date:   Fri Jun 19 17:35:19 2020 +0200

python: Fix get_max_worker_count() to always have two runners

Thanks to Jim Brown.

Signed-off-by: Andreas Schneider 
Reviewed-by: Alexander Bokovoy 
Reviewed-by: David Mulder 

Autobuild-User(master): Andreas Schneider 
Autobuild-Date(master): Fri Jun 19 19:54:04 UTC 2020 on sn-devel-184

---

Summary of changes:
 python/samba/tests/docs.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py
index 5fb04ab4e2e..10339702a97 100644
--- a/python/samba/tests/docs.py
+++ b/python/samba/tests/docs.py
@@ -57,12 +57,12 @@ def get_max_worker_count():
 cpu_count = multiprocessing.cpu_count()
 
 # Always run two processes in parallel
-if cpu_count <= 2:
+if cpu_count < 2:
 return 2
 
 max_workers = int(cpu_count / 2)
-if max_workers < 1:
-return 1
+if max_workers < 2:
+return 2
 
 return max_workers
 


-- 
Samba Shared Repository



[SCM] Samba Shared Repository - branch master updated

2020-06-19 Thread Andreas Schneider
The branch, master has been updated
   via  e478470f201 python: Run cmdline tools for arbitary docs test in 
parallel
   via  a2bc150a31d python: Run cmdline tools for default docs test in 
parallel
  from  990a0fc4a04 ldb_ldap: fix off-by-one increment in lldb_add_msg_attr

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


- Log -
commit e478470f20184cdf4210a1abf24d4e226c51d637
Author: Andreas Schneider 
Date:   Wed Jun 17 11:24:13 2020 +0200

python: Run cmdline tools for arbitary docs test in parallel

Running samba.tests.docs on my machine:
before -> (2m6.952s)
after  -> (22.298s)

Signed-off-by: Andreas Schneider 
Reviewed-by: Alexander Bokovoy 

Autobuild-User(master): Andreas Schneider 
Autobuild-Date(master): Fri Jun 19 10:59:30 UTC 2020 on sn-devel-184

commit a2bc150a31d990fd1dee05c2f6eaf7e1d1797c79
Author: Andreas Schneider 
Date:   Wed Jun 17 10:04:27 2020 +0200

python: Run cmdline tools for default docs test in parallel

Running samba.tests.docs on my machine:
before -> (3m52.582s)
after  -> (2m6.952s)

Signed-off-by: Andreas Schneider 
Reviewed-by: Alexander Bokovoy 

---

Summary of changes:
 python/samba/tests/docs.py | 359 +++--
 1 file changed, 213 insertions(+), 146 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py
index 3657d3d85cb..5fb04ab4e2e 100644
--- a/python/samba/tests/docs.py
+++ b/python/samba/tests/docs.py
@@ -25,6 +25,9 @@ import samba.tests
 import os
 import subprocess
 import xml.etree.ElementTree as ET
+import multiprocessing
+import concurrent.futures
+import tempfile
 
 config_h = os.path.join("bin/default/include/config.h")
 config_hash = dict()
@@ -50,6 +53,94 @@ class TestCase(samba.tests.TestCaseInTempDir):
 parameters.sort()
 return message + '\n\n%s' % ('\n'.join(parameters))
 
+def get_max_worker_count():
+cpu_count = multiprocessing.cpu_count()
+
+# Always run two processes in parallel
+if cpu_count <= 2:
+return 2
+
+max_workers = int(cpu_count / 2)
+if max_workers < 1:
+return 1
+
+return max_workers
+
+def check_or_set_smbconf_default(cmdline, topdir, param, default_param):
+p = subprocess.Popen(cmdline,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ cwd=topdir).communicate()
+result = p[0].decode().upper().strip()
+if result != default_param.upper():
+if not (result == "" and default_param == '""'):
+return result, param, default_param
+
+return None
+
+def set_smbconf_arbitary(cmdline, topdir, param, param_type, value_to_use):
+p = subprocess.Popen(cmdline,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ cwd=topdir).communicate()
+result = p[0].decode().upper().strip()
+if result != value_to_use.upper():
+# currently no way to distinguish command lists
+if param_type == 'list':
+if ", ".join(result.split()) == value_to_use.upper():
+return None
+
+# currently no way to identify octal
+if param_type == 'integer':
+try:
+if int(value_to_use, 8) == int(p[0].strip(), 8):
+return None
+except:
+pass
+
+return result, param, value_to_use
+
+return None
+
+def set_smbconf_arbitary_opposite(cmdline, topdir, tempdir, section, param, 
opposite_value, value_to_use):
+g = tempfile.NamedTemporaryFile(mode='w', dir=tempdir, delete=False)
+try:
+towrite = section + "\n"
+towrite += param + " = " + opposite_value
+g.write(towrite)
+finally:
+g.close()
+
+p = subprocess.Popen(cmdline + ["-s", g.name],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ cwd=topdir).communicate()
+os.unlink(g.name)
+
+# testparm doesn't display a value if they are equivalent
+if (value_to_use.lower() != opposite_value.lower()):
+for line in p[0].decode().splitlines():
+if not line.strip().startswith(param):
+return None
+
+value_found = line.split("=")[1].upper().strip()
+if value_found != value_to_use.upper():
+# currently no way to distinguish command lists
+if param_type == 'list':
+if ", ".join(value_found.split()) == value_to_use.upper():
+return None
+
+# currently no way to identify octal
+if param_type == 'integer':
+try:
+if 

[SCM] Samba Shared Repository - branch master updated

2020-06-19 Thread Andreas Schneider
The branch, master has been updated
   via  990a0fc4a04 ldb_ldap: fix off-by-one increment in lldb_add_msg_attr
   via  36bd6edd8a6 lib/ldb: add unit test for ldb_ldap internal code
  from  9a447fb7e07 Properly handle msDS-AdditionalDnsHostName returned 
from Windows DC

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


- Log -
commit 990a0fc4a0481aed817fad7575d8df453fbe7af9
Author: Alexander Bokovoy 
Date:   Thu Jun 18 10:45:41 2020 +0300

ldb_ldap: fix off-by-one increment in lldb_add_msg_attr

Fix regression introduced by commit ce2bf5c72b6423fff680b3d6a9042103a6cdda55

lldb_add_msg_attr() calls ldb_msg_add_empty() which, in turn, calls
calls _ldb_msg_add_el() which already increments msg->num_elements by one.

As a result, msg->num_elements is bigger than the actual number of
elements and any iteration over elements would step over elements array
boundary.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14413
Signed-off-by: Alexander Bokovoy 
Reviewed-by: Andreas Schneider 

Autobuild-User(master): Andreas Schneider 
Autobuild-Date(master): Fri Jun 19 08:35:33 UTC 2020 on sn-devel-184

commit 36bd6edd8a603f3aa34aff81c43ef26efd3ad4cf
Author: Alexander Bokovoy 
Date:   Thu Jun 18 11:49:08 2020 +0300

lib/ldb: add unit test for ldb_ldap internal code

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14413
Signed-off-by: Alexander Bokovoy 
Reviewed-by: Andreas Schneider 

---

Summary of changes:
 lib/ldb/ldb_ldap/ldb_ldap.c |   2 -
 lib/ldb/tests/lldb_ldap.c   | 105 
 lib/ldb/wscript |  14 ++
 3 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 lib/ldb/tests/lldb_ldap.c


Changeset truncated at 500 lines:

diff --git a/lib/ldb/ldb_ldap/ldb_ldap.c b/lib/ldb/ldb_ldap/ldb_ldap.c
index d7222997732..0531f8a62ae 100644
--- a/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -176,8 +176,6 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
el->num_values++;
}
 
-   msg->num_elements++;
-
return 0;
 }
 
diff --git a/lib/ldb/tests/lldb_ldap.c b/lib/ldb/tests/lldb_ldap.c
new file mode 100644
index 000..eea9f22f6b9
--- /dev/null
+++ b/lib/ldb/tests/lldb_ldap.c
@@ -0,0 +1,105 @@
+/*
+ * from cmocka.c:
+ * These headers or their equivalents should be included prior to
+ * including
+ * this header file.
+ *
+ * #include 
+ * #include 
+ * #include 
+ *
+ * This allows test applications to use custom definitions of C standard
+ * library functions and types.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+int ldb_ldap_init(const char *version);
+
+#include "ldb_ldap/ldb_ldap.c"
+
+struct test_ctx {
+   struct tevent_context *ev;
+   struct ldb_context *ldb;
+   struct ldb_message *msg;
+};
+
+static int lldb_msg_setup(void **state)
+{
+   struct test_ctx *test_ctx;
+
+   test_ctx = talloc_zero(NULL, struct test_ctx);
+   assert_non_null(test_ctx);
+
+   test_ctx->ev = tevent_context_init(test_ctx);
+   assert_non_null(test_ctx->ev);
+
+   test_ctx->ldb = ldb_init(test_ctx, test_ctx->ev);
+   assert_non_null(test_ctx->ldb);
+
+   test_ctx->msg = ldb_msg_new(test_ctx);
+   assert_non_null(test_ctx->msg);
+
+   *state = test_ctx;
+   return 0;
+}
+
+static int lldb_msg_teardown(void **state)
+{
+   struct test_ctx *test_ctx = talloc_get_type_abort(*state,
+ struct test_ctx);
+
+   talloc_free(test_ctx);
+   return 0;
+}
+
+static void test_lldb_add_msg_attr(void **state)
+{
+   struct test_ctx *test_ctx = talloc_get_type_abort(*state,
+ struct test_ctx);
+   struct ldb_message *msg = test_ctx->msg;
+   int ret;
+   unsigned int num_elements = 0;
+   struct berval **v = NULL;
+
+   v = talloc_zero_array(test_ctx, struct berval *, 2);
+   assert_non_null(v);
+
+   v[0] = talloc_zero(v, struct berval);
+   assert_non_null(v[0]);
+
+   v[0]->bv_val = talloc_strdup(msg, "dc=example,dc=test");
+   assert_non_null(v[0]->bv_val);
+
+   v[0]->bv_len = strlen(v[0]->bv_val);
+
+   num_elements = msg->num_elements;
+
+   ret = lldb_add_msg_attr(test_ctx->ldb, msg, "defaultNamingContext", v);
+   assert_int_equal(ret, LDB_SUCCESS);
+   assert_int_equal(msg->num_elements, num_elements + 1);
+}
+
+
+int main(int argc, const char **argv)
+{
+   const struct CMUnitTest tests[] = {
+   cmocka_unit_test_setup_teardown(test_lldb_add_msg_attr,
+   lldb_msg_setup,
+