The branch, master has been updated
       via  26bc731212b winbindd: Apply some const to normalize_name_map()
       via  f815ad9bb80 smbd: Fix a DEBUG message
       via  b5705cc70ce srvsrvc: Reload conf after changing a share
       via  81d01a1addb lib: Fix file_ploadv_send/recv cleanup
       via  023f68cb761 g_lock: Add extensive debug information
       via  c74213830d4 librpc: Simplify struct dcesrv_handle
       via  833fcdc0246 libcli: Simplify tstream_npa_connect_readv_done()
       via  9d656edffb9 libcli: Add a NULL check to tstream_npa
       via  bcbfae42795 lib: Fix samba_sockaddr_[get|set]_port
       via  da906fbc87f lib: Protect "messaging_dgm_init()" from NULL dirs
       via  559b4df1431 rpc_server: Use any_nt_status_not_ok() in 
srv_netlog_nt.c
       via  3e58a4d9d75 rpc_server: Use direct struct initialization instead of 
ZERO_STRUCT
       via  a53cc3adc6c epmapper: talloc_stackframe() panics on failure
       via  3a7f099b6bc rpc_server: talloc_stackframe() panics on failure
       via  49efd6113b6 rpc_client: Save a few lines with direct struct 
initialization
       via  e0ce7169348 rpcclient: talloc_stackframe() panics on failure
       via  9db63646c7a lib: Align integer types
       via  4f83814d443 lib: Avoid a cast in messages_dgm
       via  723a4648dd2 lib: Avoid a memleak in pidfile_unlink()
       via  4b8dc750851 lib: Avoid ZERO_STRUCT in pidfile_pid()
       via  15dad4dba85 lib: Make socket options output less chatty
       via  2fc974fdfa7 lib: Fix an uninitialized variable read
       via  dead4d05aba librpc: Fix typos
       via  ce9df5080d1 smbd: Fix a typo (recieve->receive), reformat comment
       via  b1ba5d58727 librpc: Fix a typo, while there linewrap the comment
       via  dd56d415b15 rpc_server: Fix a typo
       via  8d4f0242658 winbindd: Fix a typo
       via  72cc8dce4c9 lib: Fix a typo
       via  409da523a71 rpc_client: Fix a typo
       via  dab793469f9 lib: Fix a typo
       via  06b740e2fb4 ctdb: Fix a typo
       via  ca1f67406f9 rpc_server: Align integer types
       via  6d1049796fe rpc_server: Fix a typo
       via  1ea49c426cc samba: Fix indentation
      from  77f96a3079e samba-tool: Add a gpo command for setting VGP Issue 
Group Policy

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


- Log -----------------------------------------------------------------
commit 26bc731212ba9be439757b5084492d01354b54e0
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 23 16:27:44 2021 +0100

    winbindd: Apply some const to normalize_name_map()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Tue Mar  9 23:45:51 UTC 2021 on sn-devel-184

commit f815ad9bb807be3baa8265362be5ef8f4a56a25e
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Mar 5 11:36:20 2021 +0100

    smbd: Fix a DEBUG message
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit b5705cc70ce26c6ebd86abed15c0ffd8573bf84e
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Mar 9 08:50:26 2021 +0100

    srvsrvc: Reload conf after changing a share
    
    The call to messaging_send_all() skips ourselves. This is tested in
    source3/script/tests/test_rpcclientsrvsvc.sh, which right now we only
    survive because the rpcclient call spawns a new smbd, which reloads
    smb.conf. Once you start running srvsvcd in a long-running daemon,
    this fails.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 81d01a1addb52100d6de7eb89dbc6b161a8c6c22
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Feb 13 11:40:34 2021 +0100

    lib: Fix file_ploadv_send/recv cleanup
    
    We have to first TALLOC_FREE() the waiting event before closing the
    pipe. Otherwise EPOLL_CTL_DEL is unhappy and might remove an unrelated
    file descriptor.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 023f68cb761de2d3b9dcd587f6de906c5909ea8e
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Feb 4 18:46:59 2021 +0100

    g_lock: Add extensive debug information
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit c74213830d498fde113a59f77e49bf7a6f679949
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 27 14:59:16 2021 +0100

    librpc: Simplify struct dcesrv_handle
    
    This saves a tiny bit of memory: dom_sid_dup() allocates a full struct
    dom_sid, although it might not have to. Save the additional talloc
    object and the pointer, be more cache-friendly
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 833fcdc02467f20dfec3b1e220f8b8db60a7fb5c
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 16 17:21:57 2021 +0100

    libcli: Simplify tstream_npa_connect_readv_done()
    
    tevent_req_error takes care of the ==0 case
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 9d656edffb94027475fd91c6a3a875c37a268b34
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 16 17:21:33 2021 +0100

    libcli: Add a NULL check to tstream_npa
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit bcbfae42795f4dadb35a8f59a0165467708c3e71
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Feb 13 11:16:17 2021 +0100

    lib: Fix samba_sockaddr_[get|set]_port
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit da906fbc87fce50a21a65d3e5bcc1ccd7ab3323e
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Mar 6 15:49:46 2021 +0100

    lib: Protect "messaging_dgm_init()" from NULL dirs
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 559b4df143159d5effffd5de4be291b34bb8ed2a
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 24 16:01:27 2021 +0100

    rpc_server: Use any_nt_status_not_ok() in srv_netlog_nt.c
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 3e58a4d9d75253fb1d01d2477e10b825da658025
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 24 15:49:49 2021 +0100

    rpc_server: Use direct struct initialization instead of ZERO_STRUCT
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit a53cc3adc6cc8006535779f559cd8e2736da8b41
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jan 26 14:17:02 2021 +0100

    epmapper: talloc_stackframe() panics on failure
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 3a7f099b6bc97d849aef701c5eaddf842d77284d
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 5 08:06:57 2021 +0100

    rpc_server: talloc_stackframe() panics on failure
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 49efd6113b6e30ccc66d202d54b562055efe6d45
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Feb 6 08:32:36 2021 +0100

    rpc_client: Save a few lines with direct struct initialization
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit e0ce71693488918edaeb167a0e1db107dcadb458
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Feb 6 15:56:52 2021 +0100

    rpcclient: talloc_stackframe() panics on failure
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 9db63646c7acae3e6650b6f9994281e28b8e7c4e
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 12 19:17:34 2021 +0100

    lib: Align integer types
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 4f83814d443faf11d021a82a9fc00287c408880f
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Feb 14 09:15:15 2021 +0100

    lib: Avoid a cast in messages_dgm
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 723a4648dd2885a8bef92673012f72997f103f56
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Feb 13 22:19:42 2021 +0100

    lib: Avoid a memleak in pidfile_unlink()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 4b8dc75085129346d67efe5e6718961699f297c7
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Feb 13 22:19:12 2021 +0100

    lib: Avoid ZERO_STRUCT in pidfile_pid()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 15dad4dba8581d8c4acc635c1f654cf15295a5e0
Author: Volker Lendecke <v...@samba.org>
Date:   Sat Feb 13 12:49:57 2021 +0100

    lib: Make socket options output less chatty
    
    All the socket options were a large block in debug output. Put them on
    one line.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 2fc974fdfa75e89206a8c3537cbb2060e7c216b2
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Feb 11 08:03:38 2021 +0100

    lib: Fix an uninitialized variable read
    
    If cli_rpc_pipe_open_noauth() fails, we end up in TALLOC_FREE() of
    "p", which is uninitialized.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit dead4d05aba6be4d99e71d615675642dff2d5d6d
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Jan 29 10:13:13 2021 +0100

    librpc: Fix typos
    
    While there, wrap the long comment lines
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit ce9df5080d12c38d69e269a1434cd4c6838264a0
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 12 12:49:22 2021 +0100

    smbd: Fix a typo (recieve->receive), reformat comment
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit b1ba5d58727eff385eb2d3a570a655376b441ee6
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 27 14:53:15 2021 +0100

    librpc: Fix a typo, while there linewrap the comment
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit dd56d415b15b5a65b07573de4a291a13c7f79868
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 24 13:33:58 2021 +0100

    rpc_server: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 8d4f02426580f64bcfebb2216f5e81810b914e76
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Feb 22 19:32:00 2021 +0100

    winbindd: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 72cc8dce4c9f592b3e28dce36f611b0093da62ce
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 24 21:30:59 2021 +0100

    lib: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 409da523a71573c03cc963589c9d3ff57f6b17da
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 26 21:38:19 2021 +0100

    rpc_client: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit dab793469f9bfa8f1701162dbd7f3b28830117fb
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Mar 1 13:36:45 2021 +0100

    lib: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 06b740e2fb4348331c11dffaa77a4b37e716d2c4
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Mar 3 09:58:50 2021 +0100

    ctdb: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit ca1f67406f9b7ae873400201cca6eb535df9243a
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 24 13:33:44 2021 +0100

    rpc_server: Align integer types
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 6d1049796fe95374a17ce2b8a77ee67d9dda4874
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 7 09:57:05 2021 +0100

    rpc_server: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 1ea49c426cc3b7a9dec97da41dc9b8b93a87f4e9
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Mar 7 10:11:09 2021 +0100

    samba: Fix indentation
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

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

Summary of changes:
 ctdb/server/ctdb_recover.c                  |  2 +-
 lib/messaging/messages_dgm.c                |  6 ++-
 lib/util/pidfile.c                          | 13 ++---
 lib/util/tests/strv_util.c                  |  5 +-
 lib/util/util_net.c                         | 62 ++++++++++++++--------
 libcli/named_pipe_auth/npa_tstream.c        |  6 ++-
 librpc/rpc/dcesrv_core.h                    |  5 +-
 librpc/rpc/dcesrv_handles.c                 | 16 +++---
 source3/lib/g_lock.c                        | 33 ++++++++++--
 source3/lib/popt_common.c                   |  2 +-
 source3/lib/util_file.c                     | 35 ++++++++-----
 source3/lib/util_sd.c                       |  2 +-
 source3/lib/util_sock.c                     |  2 +-
 source3/rpc_client/cli_lsarpc.c             | 23 ++-------
 source3/rpc_client/cli_pipe.c               |  2 +-
 source3/rpc_server/epmapper/srv_epmapper.c  |  3 --
 source3/rpc_server/netlogon/srv_netlog_nt.c | 80 +++++++----------------------
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c   |  2 +
 source3/rpcclient/rpcclient.c               |  9 +---
 source3/smbd/files.c                        |  2 +-
 source3/smbd/server.c                       |  7 ++-
 source3/winbindd/winbindd_proto.h           |  2 +-
 source3/winbindd/winbindd_util.c            |  4 +-
 source4/samba/server.c                      |  2 +-
 24 files changed, 159 insertions(+), 166 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index 108d8bb404b..c59b4ad20ec 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -183,7 +183,7 @@ ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, 
uint32_t opcode)
                }
        }
 
-       /* tell the recovery daemon to reaload the nodes file too */
+       /* tell the recovery daemon to reload the nodes file too */
        ctdb_daemon_send_message(ctdb, ctdb->pnn, CTDB_SRVID_RELOAD_NODES, 
tdb_null);
 
        talloc_free(tmp_ctx);
diff --git a/lib/messaging/messages_dgm.c b/lib/messaging/messages_dgm.c
index 7c9dd8eb42f..733cd19d3b8 100644
--- a/lib/messaging/messages_dgm.c
+++ b/lib/messaging/messages_dgm.c
@@ -939,7 +939,7 @@ static int messaging_dgm_lockfile_create(struct 
messaging_dgm_context *ctx,
                generate_random_buffer((uint8_t *)&unique, sizeof(unique));
        } while (unique == UINT64_C(0xFFFFFFFFFFFFFFFF));
 
-       unique_len = snprintf(buf, sizeof(buf), "%ju\n", (uintmax_t)unique);
+       unique_len = snprintf(buf, sizeof(buf), "%"PRIu64"\n", unique);
 
        /* shorten a potentially preexisting file */
 
@@ -1002,6 +1002,10 @@ int messaging_dgm_init(struct tevent_context *ev,
                return EEXIST;
        }
 
+       if ((socket_dir == NULL) || (lockfile_dir == NULL)) {
+               return EINVAL;
+       }
+
        ctx = talloc_zero(NULL, struct messaging_dgm_context);
        if (ctx == NULL) {
                goto fail_nomem;
diff --git a/lib/util/pidfile.c b/lib/util/pidfile.c
index b90ff12a8c7..b7daa089223 100644
--- a/lib/util/pidfile.c
+++ b/lib/util/pidfile.c
@@ -134,7 +134,7 @@ pid_t pidfile_pid(const char *piddir, const char *name)
        size_t len = strlen(piddir) + strlen(name) + 6;
        char pidFile[len];
        int fd;
-       char pidstr[20];
+       char pidstr[20] = { 0, };
        pid_t ret = -1;
 
        snprintf(pidFile, sizeof(pidFile), "%s/%s.pid", piddir, name);
@@ -145,8 +145,6 @@ pid_t pidfile_pid(const char *piddir, const char *name)
                return 0;
        }
 
-       ZERO_STRUCT(pidstr);
-
        if (read(fd, pidstr, sizeof(pidstr)-1) <= 0) {
                goto noproc;
        }
@@ -210,13 +208,12 @@ void pidfile_create(const char *piddir, const char *name)
 
 void pidfile_unlink(const char *piddir, const char *name)
 {
+       size_t len = strlen(piddir) + strlen(name) + 6;
+       char pidFile[len];
        int ret;
-       char *pidFile = NULL;
 
-       if (asprintf(&pidFile, "%s/%s.pid", piddir, name) < 0) {
-               DEBUG(0,("ERROR: Out of memory\n"));
-               exit(1);
-       }
+       snprintf(pidFile, sizeof(pidFile), "%s/%s.pid", piddir, name);
+
        ret = unlink(pidFile);
        if (ret == -1) {
                DEBUG(0,("Failed to delete pidfile %s. Error was %s\n",
diff --git a/lib/util/tests/strv_util.c b/lib/util/tests/strv_util.c
index 3dd93d2eb46..b1496c74384 100644
--- a/lib/util/tests/strv_util.c
+++ b/lib/util/tests/strv_util.c
@@ -106,10 +106,11 @@ static bool test_strv_split_some(struct torture_context 
*tctx)
        };
        const char *t;
        char *strv = NULL;
-       int j;
+       size_t j;
 
        for (j = 0; j < ARRAY_SIZE(data); j++) {
-               int i, num, ret;
+               size_t i, num;
+               int ret;
                const struct test_str_split_data *d = &data[j];
 
                num = 0;
diff --git a/lib/util/util_net.c b/lib/util/util_net.c
index f97d4d43f3c..fe474dc16be 100644
--- a/lib/util/util_net.c
+++ b/lib/util/util_net.c
@@ -979,26 +979,48 @@ static const smb_socket_option socket_options[] = {
 
 static void print_socket_options(int s)
 {
-       int value;
-       socklen_t vlen = 4;
+       TALLOC_CTX *frame = NULL;
        const smb_socket_option *p = &socket_options[0];
+       char *str = NULL;
 
-       /* wrapped in if statement to prevent streams
-        * leak in SCO Openserver 5.0 */
-       /* reported on samba-technical  --jerry */
-       if ( DEBUGLEVEL >= 5 ) {
-               DEBUG(5,("Socket options:\n"));
-               for (; p->name != NULL; p++) {
-                       if (getsockopt(s, p->level, p->option,
-                                               (void *)&value, &vlen) == -1) {
-                               DEBUGADD(5,("\tCould not test socket option 
%s.\n",
-                                                       p->name));
-                       } else {
-                               DEBUGADD(5,("\t%s = %d\n",
-                                                       p->name,value));
-                       }
+       if (DEBUGLEVEL < 5) {
+               return;
+       }
+
+       frame = talloc_stackframe();
+
+       str = talloc_strdup(frame, "");
+       if (str == NULL) {
+               DBG_WARNING("talloc failed\n");
+               goto done;
+       }
+
+       for (; p->name != NULL; p++) {
+               int ret, val;
+               socklen_t vlen = sizeof(val);
+
+               ret = getsockopt(s, p->level, p->option, (void *)&val, &vlen);
+               if (ret == -1) {
+                       DBG_INFO("Could not test socket option %s: %s.\n",
+                                p->name, strerror(errno));
+                       continue;
+               }
+
+               str = talloc_asprintf_append_buffer(
+                       str,
+                       "%s%s=%d",
+                       str[0] != '\0' ? ", " : "",
+                       p->name,
+                       val);
+               if (str == NULL) {
+                       DBG_WARNING("talloc_asprintf_append_buffer failed\n");
+                       goto done;
                }
        }
+
+       DEBUG(5, ("socket options: %s\n", str));
+done:
+       TALLOC_FREE(frame);
  }
 
 /****************************************************************************
@@ -1095,12 +1117,12 @@ bool sockaddr_storage_to_samba_sockaddr(
 bool samba_sockaddr_set_port(struct samba_sockaddr *sa, uint16_t port)
 {
        if (sa->u.sa.sa_family == AF_INET) {
-               sa->u.in.sin_port = port;
+               sa->u.in.sin_port = htons(port);
                return true;
        }
 #ifdef HAVE_IPV6
        if (sa->u.sa.sa_family == AF_INET6) {
-               sa->u.in6.sin6_port = port;
+               sa->u.in6.sin6_port = htons(port);
                return true;
        }
 #endif
@@ -1110,12 +1132,12 @@ bool samba_sockaddr_set_port(struct samba_sockaddr *sa, 
uint16_t port)
 bool samba_sockaddr_get_port(const struct samba_sockaddr *sa, uint16_t *port)
 {
        if (sa->u.sa.sa_family == AF_INET) {
-               *port = sa->u.in.sin_port;
+               *port = ntohs(sa->u.in.sin_port);
                return true;
        }
 #ifdef HAVE_IPV6
        if (sa->u.sa.sa_family == AF_INET6) {
-               *port = sa->u.in6.sin6_port;
+               *port = ntohs(sa->u.in6.sin6_port);
                return true;
        }
 #endif
diff --git a/libcli/named_pipe_auth/npa_tstream.c 
b/libcli/named_pipe_auth/npa_tstream.c
index bc9d1ecb187..8c07f2e76f9 100644
--- a/libcli/named_pipe_auth/npa_tstream.c
+++ b/libcli/named_pipe_auth/npa_tstream.c
@@ -233,6 +233,9 @@ static void tstream_npa_connect_writev_done(struct 
tevent_req *subreq)
 
        subreq = tstream_u32_read_send(
                state, state->caller.ev, 0x00FFFFFF, state->unix_stream);
+       if (tevent_req_nomem(subreq, req)) {
+               return;
+       }
        tevent_req_set_callback(subreq, tstream_npa_connect_readv_done, req);
 }
 
@@ -250,8 +253,7 @@ static void tstream_npa_connect_readv_done(struct 
tevent_req *subreq)
 
        err = tstream_u32_read_recv(subreq, state, &in.data, &in.length);
        TALLOC_FREE(subreq);
-       if (err != 0) {
-               tevent_req_error(req, err);
+       if (tevent_req_error(req, err)) {
                return;
        }
 
diff --git a/librpc/rpc/dcesrv_core.h b/librpc/rpc/dcesrv_core.h
index 333671cc3e3..6371552a56d 100644
--- a/librpc/rpc/dcesrv_core.h
+++ b/librpc/rpc/dcesrv_core.h
@@ -26,6 +26,7 @@
 
 #include "librpc/rpc/rpc_common.h"
 #include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/security.h"
 
 /* modules can use the following to determine if the interface has changed
  * please increment the version number after each interface change
@@ -115,7 +116,7 @@ struct dcesrv_call_state {
         * and skip the reply
         *
         * this is only allowed to the backend when 
DCESRV_CALL_STATE_FLAG_MAY_ASYNC
-        * is alerady set by the frontend
+        * is already set by the frontend
         *
         * the backend then needs to call dcesrv_reply() when it's
         * ready to send the reply
@@ -191,7 +192,7 @@ struct dcesrv_handle {
        struct dcesrv_handle *next, *prev;
        struct dcesrv_assoc_group *assoc_group;
        struct policy_handle wire_handle;
-       struct dom_sid *sid;
+       struct dom_sid sid;
        enum dcerpc_AuthLevel min_auth_level;
        const struct dcesrv_interface *iface;
        void *data;
diff --git a/librpc/rpc/dcesrv_handles.c b/librpc/rpc/dcesrv_handles.c
index 589a1ebb208..d50831bcf0a 100644
--- a/librpc/rpc/dcesrv_handles.c
+++ b/librpc/rpc/dcesrv_handles.c
@@ -49,7 +49,8 @@ struct dcesrv_handle *dcesrv_handle_create(struct 
dcesrv_call_state *call,
        struct dom_sid *sid;
 
        /*
-        * For simplicty, ensure we abort here for an interface that has no 
handles (programmer error)
+        * For simplicity, ensure we abort here for an interface that
+        * has no handles (programmer error)
         */
        SMB_ASSERT((context->iface->flags & 
DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED) == 0);
 
@@ -60,11 +61,7 @@ struct dcesrv_handle *dcesrv_handle_create(struct 
dcesrv_call_state *call,
                return NULL;
        }
        h->data = NULL;
-       h->sid = dom_sid_dup(h, sid);
-       if (h->sid == NULL) {
-               talloc_free(h);
-               return NULL;
-       }
+       sid_copy(&h->sid, sid);
        h->min_auth_level = call->auth_state->auth_level;
        h->assoc_group = context->conn->assoc_group;
        h->iface = context->iface;
@@ -95,7 +92,8 @@ struct dcesrv_handle *dcesrv_handle_lookup(struct 
dcesrv_call_state *call,
        struct dom_sid *sid;
 
        /*
-        * For simplicty, ensure we abort here for an interface that has no 
handles (programmer error)
+        * For simplicity, ensure we abort here for an interface that
+        * has no handles (programmer error)
         */
        SMB_ASSERT((context->iface->flags & 
DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED) == 0);
 
@@ -115,10 +113,10 @@ struct dcesrv_handle *dcesrv_handle_lookup(struct 
dcesrv_call_state *call,
                                         p->handle_type, handle_type));
                                return NULL;
                        }
-                       if (!dom_sid_equal(h->sid, sid)) {
+                       if (!dom_sid_equal(&h->sid, sid)) {
                                struct dom_sid_buf buf1, buf2;
                                DBG_ERR("Attempt to use invalid sid %s - %s\n",
-                                       dom_sid_str_buf(h->sid, &buf1),
+                                       dom_sid_str_buf(&h->sid, &buf1),
                                        dom_sid_str_buf(sid, &buf2));
                                return NULL;
                        }
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 36b527706da..7eae374fbcf 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -438,6 +438,9 @@ static NTSTATUS g_lock_trylock(
                                return NT_STATUS_POSSIBLE_DEADLOCK;
                        }
 
+                       DBG_DEBUG("Waiting for lck.exclusive=%s\n",
+                                 server_id_str_buf(lck.exclusive, &tmp));
+
                        *blocker = lck.exclusive;
                        return NT_STATUS_LOCK_NOT_GRANTED;
                }
@@ -559,6 +562,10 @@ static void g_lock_lock_fn(
        struct server_id blocker = {0};
 
        state->status = g_lock_trylock(rec, state, value, &blocker);
+       if (!NT_STATUS_IS_OK(state->status)) {
+               DBG_DEBUG("g_lock_trylock returned %s\n",
+                         nt_errstr(state->status));
+       }
        if (!NT_STATUS_EQUAL(state->status, NT_STATUS_LOCK_NOT_GRANTED)) {
                return;
        }
@@ -729,6 +736,7 @@ static void g_lock_lock_simple_fn(
        void *private_data)
 {
        struct g_lock_lock_simple_state *state = private_data;
+       struct server_id_buf buf;
        struct g_lock lck = { .exclusive.pid = 0 };
        bool ok;
 
@@ -740,11 +748,14 @@ static void g_lock_lock_simple_fn(
        }
 
        if (lck.exclusive.pid != 0) {
+               DBG_DEBUG("locked by %s\n",
+                         server_id_str_buf(lck.exclusive, &buf));
                goto not_granted;
        }
 
        if (state->type == G_LOCK_WRITE) {
                if (lck.num_shared != 0) {
+                       DBG_DEBUG("num_shared=%zu\n", lck.num_shared);
                        goto not_granted;
                }
                lck.exclusive = state->me;
@@ -792,6 +803,11 @@ NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, TDB_DATA key,
                                  nt_errstr(status));
                        return status;
                }
+
+               DBG_DEBUG("status=%s, state.status=%s\n",
+                         nt_errstr(status),
+                         nt_errstr(state.status));
+
                if (NT_STATUS_IS_OK(state.status)) {
                        if (ctx->lock_order != DBWRAP_LOCK_ORDER_NONE) {
                                const char *name = dbwrap_name(ctx->db);
@@ -846,7 +862,7 @@ static void g_lock_unlock_fn(
        void *private_data)
 {
        struct g_lock_unlock_state *state = private_data;
-       struct server_id_buf tmp;
+       struct server_id_buf tmp1, tmp2;
        struct g_lock lck;
        size_t i;
        bool ok, exclusive;
@@ -871,7 +887,7 @@ static void g_lock_unlock_fn(
        if (i < lck.num_shared) {
                if (exclusive) {
                        DBG_DEBUG("%s both exclusive and shared (%zu)\n",
-                                 server_id_str_buf(state->self, &tmp),
+                                 server_id_str_buf(state->self, &tmp1),
                                  i);
                        state->status = NT_STATUS_INTERNAL_DB_CORRUPTION;
                        return;
@@ -879,8 +895,10 @@ static void g_lock_unlock_fn(
                g_lock_del_shared(&lck, i);
        } else {
                if (!exclusive) {
-                       DBG_DEBUG("Lock %s not found, num_rec=%zu\n",
-                                 server_id_str_buf(state->self, &tmp),
+                       DBG_DEBUG("Lock not found, self=%s, lck.exclusive=%s, "
+                                 "num_rec=%zu\n",
+                                 server_id_str_buf(state->self, &tmp1),
+                                 server_id_str_buf(lck.exclusive, &tmp2),
                                  lck.num_shared);
                        state->status = NT_STATUS_NOT_FOUND;
                        return;
@@ -962,7 +980,12 @@ static void g_lock_writev_data_fn(
        exclusive &= (lck.num_shared == 0);
 
        if (!exclusive) {
-               DBG_DEBUG("Not locked by us\n");
+               struct server_id_buf buf1, buf2;
+               DBG_DEBUG("Not locked by us: self=%s, lck.exclusive=%s, "
+                         "lck.num_shared=%zu\n",
+                         server_id_str_buf(state->self, &buf1),
+                         server_id_str_buf(lck.exclusive, &buf2),
+                         lck.num_shared);
                state->status = NT_STATUS_NOT_LOCKED;
                return;
        }
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index d5b60c69ef7..772c85c5c91 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -29,7 +29,7 @@
  *             -s,--configfile 
  *             -O,--socket-options 
  *             -V,--version
- *             -l,--log-base
+ *             -l,--log-basename
  *             -n,--netbios-name
  *             -W,--workgroup
  *             -i,--scope
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index 2425281f139..ba96eeee365 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -28,19 +28,21 @@
 
 struct file_ploadv_state {
        struct tevent_context *ev;
+       struct tevent_req *subreq;
        size_t maxsize;
        int fd;
        uint8_t *buf;
 };
 
-static int file_ploadv_state_destructor(struct file_ploadv_state *s);
+static void file_ploadv_cleanup_fn(
+       struct tevent_req *req, enum tevent_req_state req_state);
 static void file_ploadv_readable(struct tevent_req *subreq);
 
 struct tevent_req *file_ploadv_send(TALLOC_CTX *mem_ctx,
                                   struct tevent_context *ev,
                                   char * const argl[], size_t maxsize)
 {
-       struct tevent_req *req = NULL, *subreq = NULL;
+       struct tevent_req *req = NULL;
        struct file_ploadv_state *state = NULL;
 
        req = tevent_req_create(mem_ctx, &state, struct file_ploadv_state);
@@ -55,23 +57,27 @@ struct tevent_req *file_ploadv_send(TALLOC_CTX *mem_ctx,
                tevent_req_error(req, errno);
                return tevent_req_post(req, ev);
        }
-       talloc_set_destructor(state, file_ploadv_state_destructor);
+       tevent_req_set_cleanup_fn(req, file_ploadv_cleanup_fn);
 
-       subreq = wait_for_read_send(state, state->ev, state->fd, false);
-       if (tevent_req_nomem(subreq, req)) {
+       state->subreq = wait_for_read_send(state, state->ev, state->fd, false);
+       if (tevent_req_nomem(state->subreq, req)) {
                return tevent_req_post(req, ev);
        }
-       tevent_req_set_callback(subreq, file_ploadv_readable, req);
+       tevent_req_set_callback(state->subreq, file_ploadv_readable, req);
        return req;
 }
 
-static int file_ploadv_state_destructor(struct file_ploadv_state *s)
+static void file_ploadv_cleanup_fn(
+       struct tevent_req *req, enum tevent_req_state req_state)
 {
-       if (s->fd != -1) {
-               sys_pclose(s->fd);
-               s->fd = -1;
+       struct file_ploadv_state *state = tevent_req_data(
+               req, struct file_ploadv_state);
+
+       TALLOC_FREE(state->subreq);
+       if (state->fd != -1) {
+               sys_pclose(state->fd);
+               state->fd = -1;
        }
-       return 0;
 }
 
 static void file_ploadv_readable(struct tevent_req *subreq)
@@ -89,6 +95,7 @@ static void file_ploadv_readable(struct tevent_req *subreq)
 
        ok = wait_for_read_recv(subreq, &err);
        TALLOC_FREE(subreq);
+       state->subreq = NULL;
        if (!ok) {
                tevent_req_error(req, err);
                return;
@@ -134,11 +141,11 @@ static void file_ploadv_readable(struct tevent_req 
*subreq)
        memcpy(state->buf + bufsize, buf, nread);
        state->buf[bufsize+nread] = '\0';
 
-       subreq = wait_for_read_send(state, state->ev, state->fd, false);
-       if (tevent_req_nomem(subreq, req)) {
+       state->subreq = wait_for_read_send(state, state->ev, state->fd, false);
+       if (tevent_req_nomem(state->subreq, req)) {
                return;
        }
-       tevent_req_set_callback(subreq, file_ploadv_readable, req);


-- 
Samba Shared Repository

Reply via email to