The branch, master has been updated
       via  e9586a6 torture:smb2: add durable-v2-open.reopen1a-lease
       via  b853040 torture:smb2: for oplocks, durable reconnect works with 
different client-guid
       via  cd22980 torture:smb2: get rid of supefluous io2 var in 
durable-v2-open.reopen1a
       via  b0f592d torture:smb2: fix crashes in smb2.durable-v2-open.reopen1a 
test
       via  186cd70 torture:smb2: use assert, not warning in error case in 
durable-v2-open.reopen1a
       via  3e90abe torture:smb2: add durable-open.reopen1a-lease
       via  7b55761 torture:smb2: for oplocks, durable reconnect works with 
different client guid
       via  505546b torture:smb2: durable-open.reopen1a only needs one io struct
       via  37c05f4 torture:smb2: fix crashes in smb2.durable-open.reopen1a test
       via  b7186a0 torture:smb2: use assert, not warning in error case in 
durable-open.reopen1a
       via  e095a61 torture:smb2: Add test replay6 to verify Error Codes for 
DurableHandleReqV2 replay
       via  c5c3f91 lib/torture: add torture_assert_u64_not_equal_goto macro
       via  2b79988 torture:smb2: add test for checking sequence number wrap 
around.
       via  ccda60e libcli:smb:smbXcli_base: add 
smb2cli_session_current_channel_sequence() call.
       via  f81f3a2 smbd:smb2: add some asserts before decrementing the counters
       via  7dbb170 smbd:smb2: update outstanding request counters before 
sending a reply
       via  71d2b19 smbd:smb2: implement channel sequence checks and request 
counters in dispatch
       via  ae6967e smbd:smb2: add request_counters_updated to the 
smbd_smb2_request struct
       via  0884681 smbd:smb2: add a modify flag to dispatch table
       via  31f33a3 s3:smbXsrv.idl: add 8 byte channel_sequence number and 
request counters to IDL.
       via  b9d93e7 lib: Update nss_wrapper to version 1.1.3
       via  9e8876a lib: Update uid_wrapper to version 1.2.1
       via  092d6f9 lib: Update socket_wrapper to version 1.1.6
       via  e4f5925 ctdb-daemon: Replace an unsafe strcpy(3) call
       via  0ffa5d8 ctdb-daemon: Validate length of new interface names
      from  e806824 ldb client controls: avoid talloc_memdup(x, y, (size_t)-1);

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


- Log -----------------------------------------------------------------
commit e9586a653c62b996f1a183c897308ea0794c1cb7
Author: Michael Adam <ob...@samba.org>
Date:   Tue Mar 15 09:06:56 2016 +0100

    torture:smb2: add durable-v2-open.reopen1a-lease
    
    Lease variant of the reopen1a test which tests the
    relevance of the client guid.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Tue Mar 22 03:47:02 CET 2016 on sn-devel-144

commit b853040d5f27f0faf8d9a6071e6e6e6b2f840360
Author: Michael Adam <ob...@samba.org>
Date:   Tue Mar 15 09:02:28 2016 +0100

    torture:smb2: for oplocks, durable reconnect works with different 
client-guid
    
    for durable-v2-open.reopen1a
    
    Try both different and original client guid.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit cd2298087583de8d6b352dbbbecb00b1dbffe25c
Author: Michael Adam <ob...@samba.org>
Date:   Thu Mar 17 02:35:35 2016 +0100

    torture:smb2: get rid of supefluous io2 var in durable-v2-open.reopen1a
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit b0f592d05f66114427b26cd4aeea918e41a2e952
Author: Michael Adam <ob...@samba.org>
Date:   Tue Mar 15 09:44:06 2016 +0100

    torture:smb2: fix crashes in smb2.durable-v2-open.reopen1a test
    
    If the test failed too early, we dereferenced tree2 which
    was still NULL.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 186cd708291641c507cda0c89cc9c24900634ed2
Author: Michael Adam <ob...@samba.org>
Date:   Tue Mar 15 09:39:43 2016 +0100

    torture:smb2: use assert, not warning in error case in 
durable-v2-open.reopen1a
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 3e90abe6704a1af62ce22a6e62539a28a8abfe22
Author: Michael Adam <ob...@samba.org>
Date:   Tue Mar 15 10:02:14 2016 +0100

    torture:smb2: add durable-open.reopen1a-lease
    
    Lease variant of the reopen1a test which tests the
    relevance of the client guid.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 7b557617e48e17c2f02801fcd089719f7994488b
Author: Michael Adam <ob...@samba.org>
Date:   Tue Mar 15 08:59:53 2016 +0100

    torture:smb2: for oplocks, durable reconnect works with different client 
guid
    
    in durabble-open.reopen1a test
    
    Try both original and a different client guid.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 505546be57043c81e38ddcfe1b8bcdf0ad5963b0
Author: Michael Adam <ob...@samba.org>
Date:   Thu Mar 17 02:45:16 2016 +0100

    torture:smb2: durable-open.reopen1a only needs one io struct
    
    Using two is confusing.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 37c05f4ade3a2d0e5076941095e7d5c09631ac1b
Author: Michael Adam <ob...@samba.org>
Date:   Fri Mar 4 22:55:40 2016 +0100

    torture:smb2: fix crashes in smb2.durable-open.reopen1a test
    
    If the test failed too early, we dereferenced tree2 which
    was still NULL.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit b7186a00bb985b5b878ccf2c47a1ac4e0c2a7c79
Author: Michael Adam <ob...@samba.org>
Date:   Tue Mar 15 09:35:03 2016 +0100

    torture:smb2: use assert, not warning in error case in durable-open.reopen1a
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit e095a61c4b36e71b03d8afc724da09c91603a29b
Author: Anubhav Rakshit <anubhav.raks...@gmail.com>
Date:   Thu Oct 30 13:20:57 2014 +0530

    torture:smb2: Add test replay6 to verify Error Codes for DurableHandleReqV2 
replay
    
    Pair-Programmed-With: Stefan Metzmacher <me...@samba.org>
    Pair-Programmed-With: Guenther Deschner <g...@samba.org>
    Pair-Programmed-With: Michael Adam <ob...@samba.org>
    
    Signed-off-by: Anubhav Rakshit <anubhav.raks...@gmail.com>
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Signed-off-by: Guenther Deschner <g...@samba.org>
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit c5c3f91c6fd1ac3282d2fa27e262af097f0adfca
Author: Günther Deschner <g...@samba.org>
Date:   Wed Feb 24 19:23:21 2016 +0100

    lib/torture: add torture_assert_u64_not_equal_goto macro
    
    Guenther
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 2b799880b91f2ee44531644c62916f9a50531d04
Author: Günther Deschner <g...@samba.org>
Date:   Thu Feb 25 11:15:06 2016 +0100

    torture:smb2: add test for checking sequence number wrap around.
    
    Guenther
    
    Signed-off-by: Guenther Deschner <g...@samba.org>
    Reviewed-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit ccda60ed9b33bb22ec2e162401a949aeaa631c8d
Author: Günther Deschner <g...@samba.org>
Date:   Tue Mar 1 15:15:10 2016 +0100

    libcli:smb:smbXcli_base: add smb2cli_session_current_channel_sequence() 
call.
    
    Guenther
    
    Signed-off-by: Guenther Deschner <g...@samba.org>
    Reviewed-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit f81f3a2d78832258b09bcc63d5cce2b4594cbbc8
Author: Michael Adam <ob...@samba.org>
Date:   Sat Feb 27 14:02:02 2016 +0100

    smbd:smb2: add some asserts before decrementing the counters
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 7dbb1707d96e39bed8898db08339d3b2d768c87c
Author: Michael Adam <ob...@samba.org>
Date:   Tue Feb 23 20:54:34 2016 +0100

    smbd:smb2: update outstanding request counters before sending a reply
    
    This is part of the channel sequence number treatment of multi-channel.
    
    Pair-Programmed-With: Guenther Deschner <g...@samba.org>
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Signed-off-by: Guenther Deschner <g...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 71d2b190646bdf5fce65a776dfe6873da8d82479
Author: Michael Adam <ob...@samba.org>
Date:   Wed Feb 24 15:54:41 2016 +0100

    smbd:smb2: implement channel sequence checks and request counters in 
dispatch
    
    Pair-Programmed-With: Stefan Metzmacher <me...@samba.org>
    Pair-Programmed-With: Guenther Deschner <g...@samba.org>
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Signed-off-by: Guenther Deschner <g...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit ae6967ea3e39a1a5401be4a4c969b467dd22dce4
Author: Michael Adam <ob...@samba.org>
Date:   Tue Mar 15 12:36:59 2016 +0100

    smbd:smb2: add request_counters_updated to the smbd_smb2_request struct
    
    This will be used to keep track of whether the outstanding request
    counters have been updated in the dispatch, so that the reply
    code can act accordingly.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 088468195b7f7f04eab0ce6fb928bda1c703e2fa
Author: Michael Adam <ob...@samba.org>
Date:   Wed Feb 24 15:51:14 2016 +0100

    smbd:smb2: add a modify flag to dispatch table
    
    This indicates that an operation is a modifying operation.
    Some parts of the upcoming channel sequence number logic
    only applies to modify operations.
    
    Pair-Programmed-With: Stefan Metzmacher <me...@samba.org>
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 31f33a3f3996a5fff9833540c8227600f4aa2a55
Author: Günther Deschner <g...@samba.org>
Date:   Wed Jan 27 16:18:25 2016 +0100

    s3:smbXsrv.idl: add 8 byte channel_sequence number and request counters to 
IDL.
    
    Guenther
    
    Signed-off-by: Guenther Deschner <g...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit b9d93e718746b3904f3d93632fa17677a73cdf97
Author: Andreas Schneider <a...@samba.org>
Date:   Fri Mar 18 12:03:28 2016 +0100

    lib: Update nss_wrapper to version 1.1.3
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 9e8876a9d7cd98d5c012dd95eb273487b6920870
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Mar 16 15:12:41 2016 +0100

    lib: Update uid_wrapper to version 1.2.1
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 092d6f9ec1fbe2171c04976427f3091f9c491425
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Mar 15 15:47:08 2016 +0100

    lib: Update socket_wrapper to version 1.1.6
    
    Signed-off-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit e4f592539d89473426530c8e401c2623b1ebe838
Author: Martin Schwenke <mar...@meltin.net>
Date:   Fri Mar 18 11:49:49 2016 +1100

    ctdb-daemon: Replace an unsafe strcpy(3) call
    
    Tweak another strncpy(3) call.
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 0ffa5d8d9e6c935f360f1dfbfa52ead46d3bd386
Author: Martin Schwenke <mar...@meltin.net>
Date:   Fri Mar 18 20:41:45 2016 +1100

    ctdb-daemon: Validate length of new interface names
    
    Interface names that are too long will be truncated by strncpy(3)
    later on.  It is better to validate the length of each new interface
    name to ensure it will be usable.
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Jeremy Allison <j...@samba.org>

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

Summary of changes:
 ctdb/server/ctdb_takeover.c            |  13 +-
 lib/nss_wrapper/nss_wrapper.c          |  34 ++-
 lib/nss_wrapper/wscript                |   2 +-
 lib/socket_wrapper/socket_wrapper.c    | 158 ++++++++++-
 lib/socket_wrapper/wscript             |   2 +-
 lib/torture/torture.h                  |  12 +
 lib/uid_wrapper/uid_wrapper.c          |   2 +-
 lib/uid_wrapper/wscript                |   2 +-
 libcli/smb/smbXcli_base.c              |   5 +
 libcli/smb/smbXcli_base.h              |   1 +
 selftest/knownfail                     |   3 +
 source3/librpc/idl/smbXsrv.idl         |   3 +
 source3/smbd/globals.h                 |   7 +
 source3/smbd/smb2_server.c             | 163 +++++++++++
 source4/torture/smb2/durable_open.c    | 285 +++++++++++++++++---
 source4/torture/smb2/durable_v2_open.c | 287 ++++++++++++++++++--
 source4/torture/smb2/replay.c          | 477 ++++++++++++++++++++++++++++++++-
 17 files changed, 1381 insertions(+), 75 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index b3660ab..0cf8599 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -68,6 +68,11 @@ static int ctdb_add_local_iface(struct ctdb_context *ctdb, 
const char *iface)
 {
        struct ctdb_interface *i;
 
+       if (strlen(iface) > CTDB_IFACE_SIZE) {
+               DEBUG(DEBUG_ERR, ("Interface name too long \"%s\"\n", iface));
+               return -1;
+       }
+
        /* Verify that we don't have an entry for this ip yet */
        for (i=ctdb->ifaces;i;i=i->next) {
                if (strcmp(i->name, iface) == 0) {
@@ -2511,7 +2516,9 @@ int32_t ctdb_control_get_public_ip_info(struct 
ctdb_context *ctdb,
                if (vnn->iface == cur) {
                        info->active_idx = i;
                }
-               strncpy(info->ifaces[i].name, cur->name, 
sizeof(info->ifaces[i].name)-1);
+               strncpy(info->ifaces[i].name, cur->name,
+                       sizeof(info->ifaces[i].name));
+               info->ifaces[i].name[sizeof(info->ifaces[i].name)-1] = '\0';
                info->ifaces[i].link_state = cur->link_up;
                info->ifaces[i].references = cur->references;
        }
@@ -2546,7 +2553,9 @@ int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
 
        i = 0;
        for (cur=ctdb->ifaces;cur;cur=cur->next) {
-               strcpy(ifaces->ifaces[i].name, cur->name);
+               strncpy(ifaces->ifaces[i].name, cur->name,
+                       sizeof(ifaces->ifaces[i].name));
+               ifaces->ifaces[i].name[sizeof(ifaces->ifaces[i].name)-1] = '\0';
                ifaces->ifaces[i].link_state = cur->link_up;
                ifaces->ifaces[i].references = cur->references;
                i++;
diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c
index c4f1b33..82581b1 100644
--- a/lib/nss_wrapper/nss_wrapper.c
+++ b/lib/nss_wrapper/nss_wrapper.c
@@ -154,6 +154,14 @@ typedef nss_status_t NSS_STATUS;
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
 #endif
 
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#endif
+
+#ifndef discard_const_p
+#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
+#endif
+
 #ifdef HAVE_IPV6
 #define NWRAP_INET_ADDRSTRLEN INET6_ADDRSTRLEN
 #else
@@ -1963,6 +1971,28 @@ static bool nwrap_pw_parse_line(struct nwrap_cache 
*nwrap, char *line)
 
        NWRAP_LOG(NWRAP_LOG_TRACE, "gid[%u]\n", pw->pw_gid);
 
+#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
+       pw->pw_class = discard_const_p(char, "");
+
+       NWRAP_LOG(NWRAP_LOG_TRACE, "class[%s]", pw->pw_class);
+#endif /* HAVE_STRUCT_PASSWD_PW_CLASS */
+
+#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
+       pw->pw_change = 0;
+
+       NWRAP_LOG(NWRAP_LOG_TRACE,
+                 "change[%lu]",
+                 (unsigned long)pw->pw_change);
+#endif /* HAVE_STRUCT_PASSWD_PW_CHANGE */
+
+#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
+       pw->pw_expire = 0;
+
+       NWRAP_LOG(NWRAP_LOG_TRACE,
+                 "expire[%lu]",
+                 (unsigned long)pw->pw_expire);
+#endif /* HAVE_STRUCT_PASSWD_PW_EXPIRE */
+
        /* gecos */
        p = strchr(c, ':');
        if (!p) {
@@ -5421,7 +5451,7 @@ static int nwrap_getnameinfo(const struct sockaddr *sa, 
socklen_t salen,
                if (he != NULL && he->h_name != NULL) {
                        if (strlen(he->h_name) >= hostlen)
                                return EAI_OVERFLOW;
-                       strcpy(host, he->h_name);
+                       snprintf(host, hostlen, "%s", he->h_name);
                        if (flags & NI_NOFQDN)
                                host[strcspn(host, ".")] = '\0';
                } else {
@@ -5439,7 +5469,7 @@ static int nwrap_getnameinfo(const struct sockaddr *sa, 
socklen_t salen,
                if (service != NULL) {
                        if (strlen(service->s_name) >= servlen)
                                return EAI_OVERFLOW;
-                       strcpy(serv, service->s_name);
+                       snprintf(serv, servlen, "%s", service->s_name);
                } else {
                        if (snprintf(serv, servlen, "%u", port) >= (int) 
servlen)
                                return EAI_OVERFLOW;
diff --git a/lib/nss_wrapper/wscript b/lib/nss_wrapper/wscript
index 6c3d7f7..32bdbbd 100644
--- a/lib/nss_wrapper/wscript
+++ b/lib/nss_wrapper/wscript
@@ -2,7 +2,7 @@
 
 import os
 
-VERSION="1.1.2"
+VERSION="1.1.3"
 
 def configure(conf):
     if conf.CHECK_BUNDLED_SYSTEM('nss_wrapper', minversion=VERSION, 
set_target=False):
diff --git a/lib/socket_wrapper/socket_wrapper.c 
b/lib/socket_wrapper/socket_wrapper.c
index 45282ed..3b0499d 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -248,6 +248,7 @@ struct socket_info
        int connected;
        int defer_connect;
        int pktinfo;
+       int tcp_nodelay;
 
        /* The unix path so we can unlink it on close() */
        struct sockaddr_un un_addr;
@@ -397,6 +398,7 @@ struct swrap_libc_fns {
 #ifdef HAVE_TIMERFD_CREATE
        int (*libc_timerfd_create)(int clockid, int flags);
 #endif
+       ssize_t (*libc_write)(int fd, const void *buf, size_t count);
        ssize_t (*libc_writev)(int fd, const struct iovec *iov, int iovcnt);
 };
 
@@ -836,6 +838,13 @@ static int libc_timerfd_create(int clockid, int flags)
 }
 #endif
 
+static ssize_t libc_write(int fd, const void *buf, size_t count)
+{
+       swrap_load_lib_function(SWRAP_LIBC, write);
+
+       return swrap.fns.libc_write(fd, buf, count);
+}
+
 static ssize_t libc_writev(int fd, const struct iovec *iov, int iovcnt)
 {
        swrap_load_lib_function(SWRAP_LIBSOCKET, writev);
@@ -1846,11 +1855,10 @@ static uint8_t *swrap_pcap_packet_init(struct timeval 
*tval,
                alloc_len = SWRAP_PACKET_MIN_ALLOC;
        }
 
-       base = (uint8_t *)malloc(alloc_len);
+       base = (uint8_t *)calloc(1, alloc_len);
        if (base == NULL) {
                return NULL;
        }
-       memset(base, 0x0, alloc_len);
 
        buf = base;
 
@@ -2375,6 +2383,9 @@ static int swrap_socket(int family, int type, int 
protocol)
        case AF_INET6:
 #endif
                break;
+#ifdef AF_NETLINK
+       case AF_NETLINK:
+#endif /* AF_NETLINK */
        case AF_UNIX:
                return libc_socket(family, type, protocol);
        default:
@@ -2426,8 +2437,7 @@ static int swrap_socket(int family, int type, int 
protocol)
                swrap_remove_stale(fd);
        }
 
-       si = (struct socket_info *)malloc(sizeof(struct socket_info));
-       memset(si, 0, sizeof(struct socket_info));
+       si = (struct socket_info *)calloc(1, sizeof(struct socket_info));
        if (si == NULL) {
                errno = ENOMEM;
                return -1;
@@ -2621,8 +2631,12 @@ static int swrap_accept(int s, struct sockaddr *addr, 
socklen_t *addrlen)
                return ret;
        }
 
-       child_si = (struct socket_info *)malloc(sizeof(struct socket_info));
-       memset(child_si, 0, sizeof(struct socket_info));
+       child_si = (struct socket_info *)calloc(1, sizeof(struct socket_info));
+       if (child_si == NULL) {
+               close(fd);
+               errno = ENOMEM;
+               return -1;
+       }
 
        child_fi = (struct socket_info_fd *)calloc(1, sizeof(struct 
socket_info_fd));
        if (child_fi == NULL) {
@@ -3145,6 +3159,14 @@ static int swrap_listen(int s, int backlog)
                return libc_listen(s, backlog);
        }
 
+       if (si->bound == 0) {
+               ret = swrap_auto_bind(s, si, si->family);
+               if (ret == -1) {
+                       errno = EADDRINUSE;
+                       return ret;
+               }
+       }
+
        ret = libc_listen(s, backlog);
 
        return ret;
@@ -3350,6 +3372,29 @@ static int swrap_getsockopt(int s, int level, int 
optname,
                                               optval,
                                               optlen);
                }
+       } else if (level == IPPROTO_TCP) {
+               switch (optname) {
+#ifdef TCP_NODELAY
+               case TCP_NODELAY:
+                       /*
+                        * This enables sending packets directly out over TCP.
+                        * As a unix socket is doing that any way, report it as
+                        * enabled.
+                        */
+                       if (optval == NULL || optlen == NULL ||
+                           *optlen < (socklen_t)sizeof(int)) {
+                               errno = EINVAL;
+                               return -1;
+                       }
+
+                       *optlen = sizeof(int);
+                       *(int *)optval = si->tcp_nodelay;
+
+                       return 0;
+#endif /* TCP_NODELAY */
+               default:
+                       break;
+               }
        }
 
        errno = ENOPROTOOPT;
@@ -3388,6 +3433,35 @@ static int swrap_setsockopt(int s, int level, int 
optname,
                                       optname,
                                       optval,
                                       optlen);
+       } else if (level == IPPROTO_TCP) {
+               switch (optname) {
+#ifdef TCP_NODELAY
+               case TCP_NODELAY: {
+                       int i;
+
+                       /*
+                        * This enables sending packets directly out over TCP.
+                        * A unix socket is doing that any way.
+                        */
+                       if (optval == NULL || optlen == 0 ||
+                           optlen < (socklen_t)sizeof(int)) {
+                               errno = EINVAL;
+                               return -1;
+                       }
+
+                       i = *discard_const_p(int, optval);
+                       if (i != 0 && i != 1) {
+                               errno = EINVAL;
+                               return -1;
+                       }
+                       si->tcp_nodelay = i;
+
+                       return 0;
+               }
+#endif /* TCP_NODELAY */
+               default:
+                       break;
+               }
        }
 
        switch (si->family) {
@@ -3686,9 +3760,7 @@ static int swrap_sendmsg_copy_cmsg(struct cmsghdr *cmsg,
        size_t cmspace;
        uint8_t *p;
 
-       cmspace =
-               (*cm_data_space) +
-               CMSG_SPACE(cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr)));
+       cmspace = *cm_data_space + CMSG_ALIGN(cmsg->cmsg_len);
 
        p = realloc((*cm_data), cmspace);
        if (p == NULL) {
@@ -3799,7 +3871,8 @@ static ssize_t swrap_sendmsg_before(int fd,
                msg->msg_iovlen = i;
                if (msg->msg_iovlen == 0) {
                        *tmp_iov = msg->msg_iov[0];
-                       tmp_iov->iov_len = MIN(tmp_iov->iov_len, (size_t)mtu);
+                       tmp_iov->iov_len = MIN((size_t)tmp_iov->iov_len,
+                                              (size_t)mtu);
                        msg->msg_iov = tmp_iov;
                        msg->msg_iovlen = 1;
                }
@@ -4016,7 +4089,8 @@ static int swrap_recvmsg_before(int fd,
                msg->msg_iovlen = i;
                if (msg->msg_iovlen == 0) {
                        *tmp_iov = msg->msg_iov[0];
-                       tmp_iov->iov_len = MIN(tmp_iov->iov_len, (size_t)mtu);
+                       tmp_iov->iov_len = MIN((size_t)tmp_iov->iov_len,
+                                              (size_t)mtu);
                        msg->msg_iov = tmp_iov;
                        msg->msg_iovlen = 1;
                }
@@ -4491,6 +4565,58 @@ ssize_t read(int s, void *buf, size_t len)
 }
 
 /****************************************************************************
+ *   WRITE
+ ***************************************************************************/
+
+static ssize_t swrap_write(int s, const void *buf, size_t len)
+{
+       struct msghdr msg;
+       struct iovec tmp;
+       struct sockaddr_un un_addr;
+       ssize_t ret;
+       int rc;
+       struct socket_info *si;
+
+       si = find_socket_info(s);
+       if (si == NULL) {
+               return libc_write(s, buf, len);
+       }
+
+       tmp.iov_base = discard_const_p(char, buf);
+       tmp.iov_len = len;
+
+       ZERO_STRUCT(msg);
+       msg.msg_name = NULL;           /* optional address */
+       msg.msg_namelen = 0;           /* size of address */
+       msg.msg_iov = &tmp;            /* scatter/gather array */
+       msg.msg_iovlen = 1;            /* # elements in msg_iov */
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL
+       msg.msg_control = NULL;        /* ancillary data, see below */
+       msg.msg_controllen = 0;        /* ancillary data buffer len */
+       msg.msg_flags = 0;             /* flags on received message */
+#endif
+
+       rc = swrap_sendmsg_before(s, si, &msg, &tmp, &un_addr, NULL, NULL, 
NULL);
+       if (rc < 0) {
+               return -1;
+       }
+
+       buf = msg.msg_iov[0].iov_base;
+       len = msg.msg_iov[0].iov_len;
+
+       ret = libc_write(s, buf, len);
+
+       swrap_sendmsg_after(s, si, &msg, NULL, ret);
+
+       return ret;
+}
+
+ssize_t write(int s, const void *buf, size_t len)
+{
+       return swrap_write(s, buf, len);
+}
+
+/****************************************************************************
  *   SEND
  ***************************************************************************/
 
@@ -4550,6 +4676,9 @@ static ssize_t swrap_recvmsg(int s, struct msghdr *omsg, 
int flags)
        struct swrap_address from_addr = {
                .sa_socklen = sizeof(struct sockaddr_un),
        };
+       struct swrap_address convert_addr = {
+               .sa_socklen = sizeof(struct sockaddr_storage),
+       };
        struct socket_info *si;
        struct msghdr msg;
        struct iovec tmp;
@@ -4608,6 +4737,13 @@ static ssize_t swrap_recvmsg(int s, struct msghdr *omsg, 
int flags)
        }
 #endif
 
+       /*
+        * We convert the unix address to a IP address so we need a buffer
+        * which can store the address in case of SOCK_DGRAM, see below.
+        */
+       msg.msg_name = &convert_addr.sa;
+       msg.msg_namelen = convert_addr.sa_socklen;
+
        rc = swrap_recvmsg_after(s,
                                 si,
                                 &msg,
diff --git a/lib/socket_wrapper/wscript b/lib/socket_wrapper/wscript
index 9d9bf01..724237b 100644
--- a/lib/socket_wrapper/wscript
+++ b/lib/socket_wrapper/wscript
@@ -2,7 +2,7 @@
 
 import os
 
-VERSION="1.1.4"
+VERSION="1.1.6"
 
 def configure(conf):
     if conf.CHECK_BUNDLED_SYSTEM('socket_wrapper', minversion=VERSION, 
set_target=False):
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index 356922a..e710873 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -479,6 +479,18 @@ void torture_result(struct torture_context *test,
        } \
        } while(0)
 
+#define 
torture_assert_u64_not_equal_goto(torture_ctx,got,not_expected,ret,label,cmt)\
+       do { uint64_t __got = (got), __not_expected = (not_expected); \
+       if (__got == __not_expected) { \
+               torture_result(torture_ctx, TORTURE_FAIL, \
+                       __location__": "#got" was %llu (0x%llX), expected a 
different number: %s", \
+                       (unsigned long long)__got, (unsigned long long)__got, \
+                       cmt); \
+               ret = false; \
+               goto label; \
+       } \
+       } while(0)
+
 #define torture_assert_errno_equal(torture_ctx,expected,cmt)\
        do { int __expected = (expected); \
        if (errno != __expected) { \
diff --git a/lib/uid_wrapper/uid_wrapper.c b/lib/uid_wrapper/uid_wrapper.c
index ab47dd0..743d590 100644
--- a/lib/uid_wrapper/uid_wrapper.c
+++ b/lib/uid_wrapper/uid_wrapper.c
@@ -156,7 +156,7 @@ static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const 
char *function, const ch
        va_end(va);
 
        if (lvl >= dbglvl) {
-               const char *prefix;
+               const char *prefix = "UWRAP";
                switch (dbglvl) {
                        case UWRAP_LOG_ERROR:
                                prefix = "UWRAP_ERROR";
diff --git a/lib/uid_wrapper/wscript b/lib/uid_wrapper/wscript
index 1c87236..8745fd0 100644
--- a/lib/uid_wrapper/wscript
+++ b/lib/uid_wrapper/wscript
@@ -3,7 +3,7 @@
 import Options
 import os, sys
 
-VERSION="1.2.0"
+VERSION="1.2.1"
 
 def configure(conf):
     if conf.CHECK_BUNDLED_SYSTEM('uid_wrapper', minversion=VERSION, 
set_target=False):
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index ad6a254..48388b6 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -5486,6 +5486,11 @@ uint16_t smb2cli_session_reset_channel_sequence(struct 
smbXcli_session *session,
        return prev_cs;
 }
 
+uint16_t smb2cli_session_current_channel_sequence(struct smbXcli_session 
*session)
+{
+       return session->smb2->channel_sequence;
+}
+
 void smb2cli_session_start_replay(struct smbXcli_session *session)
 {
        session->smb2->replay_active = true;
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index e4cfb10..ffccd7e 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -410,6 +410,7 @@ void smb2cli_session_set_id_and_flags(struct 
smbXcli_session *session,
 void smb2cli_session_increment_channel_sequence(struct smbXcli_session 
*session);
 uint16_t smb2cli_session_reset_channel_sequence(struct smbXcli_session 
*session,
                                                uint16_t channel_sequence);
+uint16_t smb2cli_session_current_channel_sequence(struct smbXcli_session 
*session);
 void smb2cli_session_start_replay(struct smbXcli_session *session);
 void smb2cli_session_stop_replay(struct smbXcli_session *session);
 NTSTATUS smb2cli_session_update_preauth(struct smbXcli_session *session,
diff --git a/selftest/knownfail b/selftest/knownfail
index c15d263..83cf2d6 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -193,6 +193,8 @@
 ^samba3.smb2.notify.rec
 ^samba3.smb2.durable-open.delete_on_close2
 ^samba3.smb2.durable-v2-open.app-instance
+^samba3.smb2.durable-open.reopen1a-lease\(ad_dc\)$
+^samba3.smb2.durable-v2-open.reopen1a-lease\(ad_dc\)$
 ^samba4.smb2.ioctl.req_resume_key\(ad_dc_ntvfs\) # not supported by s4 ntvfs 
server
 ^samba4.smb2.ioctl.copy_chunk_\w*\(ad_dc_ntvfs\)       # not supported by s4 
ntvfs server
 ^samba3.smb2.dir.one
@@ -207,6 +209,7 @@
 ^samba3.smb2.setinfo.setinfo
 ^samba3.smb2.session.*reauth5 # some special anonymous checks?


-- 
Samba Shared Repository

Reply via email to