[SCM] Samba Shared Repository - branch master updated

2021-02-09 Thread Jeremy Allison
The branch, master has been updated
   via  d0529682605 samba-tool: Add a gpo command for setting VGP OpenSSH 
Group Policy
   via  be8f0d8ddbb samba-tool: Test gpo manage openssh set command
   via  3c47a81472b samba-tool: Add a gpo command for listing VGP OpenSSH 
Group Policy
   via  61394e5dd10 samba-tool: Test gpo manage openssh list command
   via  ddf1cbd3452 gpo: Apply Group Policy OpenSSH settings from VGP
   via  e9c1cc4e74b gpo: Test Group Policy OpenSSH for VGP
  from  6816135a2cd s3 lib system: Change signature of sys_proc_fd_path

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


- Log -
commit d052968260582290b3ced8f951d75603f642979d
Author: David Mulder 
Date:   Wed Dec 23 14:52:35 2020 -0700

samba-tool: Add a gpo command for setting VGP OpenSSH Group Policy

Signed-off-by: David Mulder 
Reviewed-by: Jeremy Allison 

Autobuild-User(master): Jeremy Allison 
Autobuild-Date(master): Tue Feb  9 21:24:14 UTC 2021 on sn-devel-184

commit be8f0d8ddbb9a145bd171618ef7183b9ed648203
Author: David Mulder 
Date:   Wed Dec 23 14:29:58 2020 -0700

samba-tool: Test gpo manage openssh set command

Signed-off-by: David Mulder 
Reviewed-by: Jeremy Allison 

commit 3c47a81472b71642ef92522a27cbd2c14865bf43
Author: David Mulder 
Date:   Wed Dec 23 14:14:49 2020 -0700

samba-tool: Add a gpo command for listing VGP OpenSSH Group Policy

Signed-off-by: David Mulder 
Reviewed-by: Jeremy Allison 

commit 61394e5dd10112190c4af875eed6fcc071ca3920
Author: David Mulder 
Date:   Wed Dec 23 12:25:11 2020 -0700

samba-tool: Test gpo manage openssh list command

Signed-off-by: David Mulder 
Reviewed-by: Jeremy Allison 

commit ddf1cbd345237162ac19596ac1db787e0d77de65
Author: David Mulder 
Date:   Thu Nov 5 09:08:26 2020 -0700

gpo: Apply Group Policy OpenSSH settings from VGP

Signed-off-by: David Mulder 
Reviewed-by: Jeremy Allison 

commit e9c1cc4e74be01c963a704ee9ed9466b1420da6d
Author: David Mulder 
Date:   Wed Nov 4 10:24:26 2020 -0700

gpo: Test Group Policy OpenSSH for VGP

Signed-off-by: David Mulder 
Reviewed-by: Jeremy Allison 

---

Summary of changes:
 docs-xml/manpages/samba-tool.8.xml   |  10 ++
 python/samba/netcmd/gpo.py   | 194 +++
 python/samba/tests/gpo.py|  67 
 python/samba/tests/samba_tool/gpo.py |  90 
 python/samba/vgp_openssh_ext.py  |  82 +++
 source4/scripting/bin/samba-gpupdate |   2 +
 6 files changed, 445 insertions(+)
 create mode 100644 python/samba/vgp_openssh_ext.py


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/samba-tool.8.xml 
b/docs-xml/manpages/samba-tool.8.xml
index 4de7602570b..ea1f5f8d0e7 100644
--- a/docs-xml/manpages/samba-tool.8.xml
+++ b/docs-xml/manpages/samba-tool.8.xml
@@ -914,6 +914,16 @@
Remove VGP Files Group Policy from the sysvol
 
 
+
+   gpo manage openssh list
+   List VGP OpenSSH Group Policy from the sysvol
+
+
+
+   gpo manage openssh set
+   Sets a VGP OpenSSH Group Policy to the sysvol
+
+
 
group
Manage groups.
diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py
index 8decbe0a8af..a0629feb4cd 100644
--- a/python/samba/netcmd/gpo.py
+++ b/python/samba/netcmd/gpo.py
@@ -2763,6 +2763,199 @@ class cmd_files(SuperCommand):
 subcommands["add"] = cmd_add_files()
 subcommands["remove"] = cmd_remove_files()
 
+class cmd_list_openssh(Command):
+"""List VGP OpenSSH Group Policy from the sysvol
+
+This command lists openssh options from the sysvol that will be applied to 
winbind clients.
+
+Example:
+samba-tool gpo manage openssh list {31B2F340-016D-11D2-945F-00C04FB984F9}
+"""
+
+synopsis = "%prog  [options]"
+
+takes_optiongroups = {
+"sambaopts": options.SambaOptions,
+"versionopts": options.VersionOptions,
+"credopts": options.CredentialsOptions,
+}
+
+takes_options = [
+Option("-H", "--URL", help="LDB URL for database or target server", 
type=str,
+metavar="URL", dest="H"),
+]
+
+takes_args = ["gpo"]
+
+def run(self, gpo, H=None, sambaopts=None, credopts=None, 
versionopts=None):
+self.lp = sambaopts.get_loadparm()
+self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
+
+# We need to know writable DC to setup SMB connection
+if H and H.startswith('ldap://'):
+dc_hostname = H[7:]
+self.url = H
+else:
+dc_hostname = netcmd_finddc(self.lp, self.creds)
+self.url = dc_url(self.lp, self.creds, dc=dc_hostname)
+
+# SMB connect to DC
+conn = smb_connection(dc_hostname,
+  'sysvol',
+

[SCM] Socket Wrapper Repository - branch master updated

2021-02-09 Thread Andreas Schneider
The branch, master has been updated
   via  db594f1 swrap: don't touch msg_tmp in swrap_recvmsg_after_unix() on 
error
   via  2b8a9e3 swrap: fix possible memory leak between 
swrap_recvmsg_{before,after}_unix()
  from  3af2bf7 Bump version to 1.3.1

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


- Log -
commit db594f106d9737e0415a268439fc9003bb636473
Author: Stefan Metzmacher 
Date:   Tue Feb 9 16:09:59 2021 +0100

swrap: don't touch msg_tmp in swrap_recvmsg_after_unix() on error

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Andreas Schneider 

commit 2b8a9e3255f2c9bf440cbae404ca8ac8f3f910f6
Author: Stefan Metzmacher 
Date:   Tue Feb 9 15:57:22 2021 +0100

swrap: fix possible memory leak between swrap_recvmsg_{before,after}_unix()

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Andreas Schneider 

---

Summary of changes:
 src/socket_wrapper.c | 36 ++--
 1 file changed, 30 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index ece3493..59fb07d 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -5960,7 +5960,8 @@ static ssize_t swrap_sendmsg_after_unix(struct msghdr 
*msg_tmp,
 }
 
 static int swrap_recvmsg_before_unix(struct msghdr *msg_in,
-struct msghdr *msg_tmp)
+struct msghdr *msg_tmp,
+uint8_t **tmp_control)
 {
 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
const size_t cm_extra_space = CMSG_SPACE(sizeof(int));
@@ -5968,6 +5969,7 @@ static int swrap_recvmsg_before_unix(struct msghdr 
*msg_in,
size_t cm_data_space = 0;
 
*msg_tmp = *msg_in;
+   *tmp_control = NULL;
 
SWRAP_LOG(SWRAP_LOG_TRACE,
  "msg_in->msg_controllen=%zu",
@@ -5995,6 +5997,7 @@ static int swrap_recvmsg_before_unix(struct msghdr 
*msg_in,
 
msg_tmp->msg_controllen = cm_data_space;
msg_tmp->msg_control = cm_data;
+   *tmp_control = cm_data;
 
SWRAP_LOG(SWRAP_LOG_TRACE,
  "msg_tmp->msg_controllen=%zu",
@@ -6002,11 +6005,13 @@ static int swrap_recvmsg_before_unix(struct msghdr 
*msg_in,
return 0;
 #else /* HAVE_STRUCT_MSGHDR_MSG_CONTROL */
*msg_tmp = *msg_in;
+   *tmp_control = NULL;
return 0;
 #endif /* ! HAVE_STRUCT_MSGHDR_MSG_CONTROL */
 }
 
 static ssize_t swrap_recvmsg_after_unix(struct msghdr *msg_tmp,
+   uint8_t **tmp_control,
struct msghdr *msg_out,
ssize_t ret)
 {
@@ -6016,13 +6021,26 @@ static ssize_t swrap_recvmsg_after_unix(struct msghdr 
*msg_tmp,
size_t cm_data_space = 0;
int rc = -1;
 
+   if (ret < 0) {
+   int saved_errno = errno;
+   SWRAP_LOG(SWRAP_LOG_TRACE, "ret=%zd - %d - %s", ret,
+ saved_errno, strerror(saved_errno));
+   SAFE_FREE(*tmp_control);
+   /* msg_out should not be touched on error */
+   errno = saved_errno;
+   return ret;
+   }
+
SWRAP_LOG(SWRAP_LOG_TRACE,
  "msg_tmp->msg_controllen=%zu",
  (size_t)msg_tmp->msg_controllen);
 
/* Nothing to do */
if (msg_tmp->msg_controllen == 0 || msg_tmp->msg_control == NULL) {
+   int saved_errno = errno;
*msg_out = *msg_tmp;
+   SAFE_FREE(*tmp_control);
+   errno = saved_errno;
return ret;
}
 
@@ -6045,16 +6063,17 @@ static ssize_t swrap_recvmsg_after_unix(struct msghdr 
*msg_tmp,
if (rc < 0) {
int saved_errno = errno;
SAFE_FREE(cm_data);
+   SAFE_FREE(*tmp_control);
errno = saved_errno;
return rc;
}
}
 
/*
-* msg_tmp->msg_control was created by swrap_recvmsg_before_unix()
-* and msg_out->msg_control is still the buffer of the caller.
+* msg_tmp->msg_control (*tmp_control) was created by
+* swrap_recvmsg_before_unix() and msg_out->msg_control
+* is still the buffer of the caller.
 */
-   SAFE_FREE(msg_tmp->msg_control);
msg_tmp->msg_control = msg_out->msg_control;
msg_tmp->msg_controllen = msg_out->msg_controllen;
*msg_out = *msg_tmp;
@@ -6063,13 +6082,17 @@ static ssize_t swrap_recvmsg_after_unix(struct msghdr 
*msg_tmp,
memcpy(msg_out->msg_control, cm_data, cm_data_space);
msg_out->msg_controllen = cm_data_space;
SAFE_FREE(cm_data);
+   SAFE_FREE(*tmp_control);
 
SWRAP_LOG(SWRAP_LOG_TRACE,
 

[SCM] Samba Shared Repository - branch v4-14-test updated

2021-02-09 Thread Karolin Seeger
The branch, v4-14-test has been updated
   via  938b89616a1 lib:util: Avoid free'ing our own pointer
   via  27d93c8d46a lib:util: Add cache oversize test for memcache
   via  805b8be9497 lib:util: Add basic memcache unit test
  from  ea2f9ebf787 VERSION: Bump version up to Samba 4.14.0rc3...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-14-test


- Log -
commit 938b89616a18161d3cef32f62c3bc48f80adeb70
Author: Andreas Schneider 
Date:   Tue Feb 2 18:10:38 2021 +0100

lib:util: Avoid free'ing our own pointer

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

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 
(cherry picked from commit 0bdbe50fac680be3fe21043246b8c75005611351)

Autobuild-User(v4-14-test): Karolin Seeger 
Autobuild-Date(v4-14-test): Tue Feb  9 13:31:03 UTC 2021 on sn-devel-184

commit 27d93c8d46ac5dd61bd47b9ba88d5bedb651b86b
Author: Andreas Schneider 
Date:   Wed Feb 3 10:37:12 2021 +0100

lib:util: Add cache oversize test for memcache

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

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 
(cherry picked from commit 00543ab3b29e3fbfe8314e51919629803e14ede6)

commit 805b8be9497e03f3dbcfc94cc1aa3634b135a065
Author: Andreas Schneider 
Date:   Wed Feb 3 10:30:08 2021 +0100

lib:util: Add basic memcache unit test

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

Signed-off-by: Andreas Schneider 
Reviewed-by: Ralph Boehme 
(cherry picked from commit bebbf621d6052f797c5cf19a2a9bbc13e699d3f0)

---

Summary of changes:
 lib/util/memcache.c|  19 -
 lib/util/tests/test_memcache.c | 161 +
 lib/util/wscript_build |   6 ++
 selftest/tests.py  |   2 +
 4 files changed, 184 insertions(+), 4 deletions(-)
 create mode 100644 lib/util/tests/test_memcache.c


Changeset truncated at 500 lines:

diff --git a/lib/util/memcache.c b/lib/util/memcache.c
index 1e616bd0e9a..7b0b27eaddb 100644
--- a/lib/util/memcache.c
+++ b/lib/util/memcache.c
@@ -223,14 +223,25 @@ static void memcache_delete_element(struct memcache 
*cache,
TALLOC_FREE(e);
 }
 
-static void memcache_trim(struct memcache *cache)
+static void memcache_trim(struct memcache *cache, struct memcache_element *e)
 {
+   struct memcache_element *tail = NULL;
+
if (cache->max_size == 0) {
return;
}
 
-   while ((cache->size > cache->max_size) && DLIST_TAIL(cache->mru)) {
-   memcache_delete_element(cache, DLIST_TAIL(cache->mru));
+   for (tail = DLIST_TAIL(cache->mru);
+(cache->size > cache->max_size) && (tail != NULL);
+tail = DLIST_TAIL(cache->mru))
+   {
+   if (tail == e) {
+   tail = DLIST_PREV(tail);
+   if (tail == NULL) {
+   break;
+   }
+   }
+   memcache_delete_element(cache, tail);
}
 }
 
@@ -351,7 +362,7 @@ void memcache_add(struct memcache *cache, enum 
memcache_number n,
memcpy(, cache_value.data, sizeof(mtv));
cache->size += mtv.len;
}
-   memcache_trim(cache);
+   memcache_trim(cache, e);
 }
 
 void memcache_add_talloc(struct memcache *cache, enum memcache_number n,
diff --git a/lib/util/tests/test_memcache.c b/lib/util/tests/test_memcache.c
new file mode 100644
index 000..8a3997817c1
--- /dev/null
+++ b/lib/util/tests/test_memcache.c
@@ -0,0 +1,161 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * Copyright (C) 2021  Andreas Schneider 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lib/replace/replace.h"
+#include "lib/util/talloc_stack.h"
+#include "lib/util/memcache.h"
+
+static int setup_talloc_context(void **state)
+{
+   TALLOC_CTX *frame = talloc_stackframe();
+
+   *state = frame;
+   return 0;
+}
+
+static int teardown_talloc_context(void **state)
+{
+   TALLOC_CTX *frame = *state;
+   TALLOC_FREE(frame);
+   return 0;
+}
+
+static void