[SCM] Samba Shared Repository - branch master updated

2017-02-16 Thread Jeremy Allison
The branch, master has been updated
   via  adbdce7 Modify smbspool_krb5_wrapper to just fall through to 
smbspool if AUTH_INFO_REQUIRED is not set or is not "negotiate".
  from  40d813c s3: torture: Regression test for smbd trying to open an 
invalid symlink.

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


- Log -
commit adbdce78ecb4e852596108b69eeb8a4cba32fa83
Author: Bryan Mason 
Date:   Wed Feb 15 22:57:42 2017 -0800

Modify smbspool_krb5_wrapper to just fall through to smbspool if 
AUTH_INFO_REQUIRED is not set or is not "negotiate".

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

Signed-off-by: Bryan Mason 
Reviewed-by: Andreas Schneider 
Reviewed-by: Jeremy Allison 

Autobuild-User(master): Jeremy Allison 
Autobuild-Date(master): Fri Feb 17 04:27:26 CET 2017 on sn-devel-144

---

Summary of changes:
 source3/client/smbspool_krb5_wrapper.c | 32 +---
 1 file changed, 17 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/smbspool_krb5_wrapper.c 
b/source3/client/smbspool_krb5_wrapper.c
index d26a7a6..bf97d82 100644
--- a/source3/client/smbspool_krb5_wrapper.c
+++ b/source3/client/smbspool_krb5_wrapper.c
@@ -90,27 +90,29 @@ int main(int argc, char *argv[])
int cmp;
int rc;
 
-   uid = getuid();
-
-   CUPS_SMB_DEBUG("Started with uid=%d\n", uid);
-   if (uid != 0) {
-   goto smbspool;
-   }
-
/* Check if AuthInfoRequired is set to negotiate */
env = getenv("AUTH_INFO_REQUIRED");
+
+/* If not set, then just call smbspool. */
if (env == NULL) {
CUPS_SMB_ERROR("AUTH_INFO_REQUIRED is not set");
-   fprintf(stderr, "ATTR: auth-info-required=negotiate\n");
-   return CUPS_BACKEND_AUTH_REQUIRED;
+goto smbspool;
+   } else {
+CUPS_SMB_DEBUG("AUTH_INFO_REQUIRED=%s", env);
+cmp = strcmp(env, "negotiate");
+/* If AUTH_INFO_REQUIRED != "negotiate" then call smbspool. */
+if (cmp != 0) {
+  CUPS_SMB_ERROR(
+"AUTH_INFO_REQUIRED is not set to negotiate");
+  goto smbspool;
+}
}
 
-   CUPS_SMB_DEBUG("AUTH_INFO_REQUIRED=%s", env);
-   cmp = strcmp(env, "negotiate");
-   if (cmp != 0) {
-   CUPS_SMB_ERROR("AUTH_INFO_REQUIRED is not set to negotiate");
-   fprintf(stderr, "ATTR: auth-info-required=negotiate\n");
-   return CUPS_BACKEND_AUTH_REQUIRED;
+   uid = getuid();
+
+   CUPS_SMB_DEBUG("Started with uid=%d\n", uid);
+   if (uid != 0) {
+   goto smbspool;
}
 
/*


-- 
Samba Shared Repository



autobuild[sn-devel-144]: intermittent test failure detected

2017-02-16 Thread autobuild
The autobuild test system (on sn-devel-144) has detected an intermittent 
failing test in 
the current master tree.

The autobuild log of the failure is available here:

   http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-17-0324/flakey.log

The samba build logs are available here:

   
http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-17-0324/samba.stderr
   
http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-17-0324/samba.stdout
  
The top commit at the time of the failure was:

commit 40d813cdb312fd8378db310543e0778193a1a684
Author: Jeremy Allison 
Date:   Tue Feb 14 12:59:58 2017 -0800

s3: torture: Regression test for smbd trying to open an invalid symlink.

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

Pair-programmed-with: Ralph Boehme 

Signed-off-by: Jeremy Allison 
Signed-off-by: Ralph Boehme 
Reviewed-by: Ralph Boehme 

Autobuild-User(master): Jeremy Allison 
Autobuild-Date(master): Thu Feb 16 22:06:51 CET 2017 on sn-devel-144



[SCM] Samba Shared Repository - branch master updated

2017-02-16 Thread Jeremy Allison
The branch, master has been updated
   via  40d813c s3: torture: Regression test for smbd trying to open an 
invalid symlink.
   via  10c3e39 s3: smbd: Don't loop infinitely on bad-symlink resolution.
  from  295f757 WHATSNEW: Add link to known issues.

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


- Log -
commit 40d813cdb312fd8378db310543e0778193a1a684
Author: Jeremy Allison 
Date:   Tue Feb 14 12:59:58 2017 -0800

s3: torture: Regression test for smbd trying to open an invalid symlink.

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

Pair-programmed-with: Ralph Boehme 

Signed-off-by: Jeremy Allison 
Signed-off-by: Ralph Boehme 
Reviewed-by: Ralph Boehme 

Autobuild-User(master): Jeremy Allison 
Autobuild-Date(master): Thu Feb 16 22:06:51 CET 2017 on sn-devel-144

commit 10c3e3923022485c720f322ca4f0aca5d7501310
Author: Jeremy Allison 
Date:   Wed Feb 15 15:42:52 2017 -0800

s3: smbd: Don't loop infinitely on bad-symlink resolution.

In the FILE_OPEN_IF case we have O_CREAT, but not
O_EXCL. Previously we went into a loop trying first
~(O_CREAT|O_EXCL), and if that returned ENOENT
try (O_CREAT|O_EXCL). We kept looping indefinately
until we got an error, or the file was created or
opened.

The big problem here is dangling symlinks. Opening
without O_NOFOLLOW means both bad symlink
and missing path return -1, ENOENT from open(). As POSIX
is pathname based it's not possible to tell
the difference between these two cases in a
non-racy way, so change to try only two attempts before
giving up.

We don't have this problem for the O_NOFOLLOW
case as we just return NT_STATUS_OBJECT_PATH_NOT_FOUND
mapped from the ELOOP POSIX error and immediately
returned.

Unroll the loop logic to two tries instead.

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

Pair-programmed-with: Ralph Boehme 

Signed-off-by: Jeremy Allison 
Signed-off-by: Ralph Boehme 
Reviewed-by: Ralph Boehme 

---

Summary of changes:
 selftest/skip |   1 +
 source3/selftest/tests.py |   2 +-
 source3/smbd/open.c   | 104 +-
 source3/torture/torture.c | 101 
 4 files changed, 159 insertions(+), 49 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/skip b/selftest/skip
index 1e6d311..fd9932a 100644
--- a/selftest/skip
+++ b/selftest/skip
@@ -48,6 +48,7 @@
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).POSIX-SYMLINK-EA # Fails against 
the s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).POSIX-OFD-LOCK # Fails against the 
s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).POSIX-STREAM-DELETE # Fails against 
the s4 ntvfs server
+^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).WINDOWS-BAD-SYMLINK # Fails against 
the s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).RENAME-ACCESS # Fails against the 
s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).OWNER-RIGHTS # Don't test against 
the s4 ntvfs server anymore
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).PIDHIGH # Fails against the s4 
ntvfs server
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 8e1c33d..4215eb0 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -89,7 +89,7 @@ for t in tests:
 plantestsuite("samba3.smbtorture_s3.vfs_aio_fork(simpleserver).%s" % t, 
"simpleserver", [os.path.join(samba3srcdir, 
"script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/vfs_aio_fork', 
'$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
 
 posix_tests = ["POSIX", "POSIX-APPEND", "POSIX-SYMLINK-ACL", 
"POSIX-SYMLINK-EA", "POSIX-OFD-LOCK",
-  "POSIX-STREAM-DELETE" ]
+  "POSIX-STREAM-DELETE", "WINDOWS-BAD-SYMLINK" ]
 
 for t in posix_tests:
 plantestsuite("samba3.smbtorture_s3.plain(nt4_dc).%s" % t, "nt4_dc", 
[os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, 
'//$SERVER_IP/posix_share', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l 
$LOCAL_PATH"])
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 931d76d..37c630b 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -640,7 +640,9 @@ static NTSTATUS fd_open_atomic(struct connection_struct 
*conn,
bool *file_created)
 {
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+   NTSTATUS retry_status;
bool file_existed = VALID_STAT(fsp->fsp_name->st);
+   int curr_flags;
 
*file_created = false;
 
@@ -672,59 +674,65 @@ static NTSTATUS fd_open_atomic(struct connection_struct 
*conn,
 * we can never call O_CREAT without O_EXCL. So if
 * we think the file existed, try without O_CREAT|O_EXCL.
  

[SCM] Samba Shared Repository - branch master updated

2017-02-16 Thread Karolin Seeger
The branch, master has been updated
   via  295f757 WHATSNEW: Add link to known issues.
  from  5e7ae1b ctdb-scripts: Initialise CTDB_NFS_CALLOUT in statd-callout

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


- Log -
commit 295f757fe16d508368095936a8d3cba096bceb5d
Author: Karolin Seeger 
Date:   Thu Feb 16 10:28:40 2017 +0100

WHATSNEW: Add link to known issues.

Signed-off-by: Karolin Seeger 
Reviewed-by: Stefan Metzmacher 

Autobuild-User(master): Karolin Seeger 
Autobuild-Date(master): Thu Feb 16 14:37:11 CET 2017 on sn-devel-144

---

Summary of changes:
 WHATSNEW.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 761f73f..dd60cd2 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -27,7 +27,8 @@ smb.conf changes
 KNOWN ISSUES
 
 
-Currently none.
+https://wiki.samba.org/index.php/Release_Planning_for_Samba_4.7#Release_blocking_bugs
+
 
 ###
 Reporting bugs & Development Discussion


-- 
Samba Shared Repository



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

2017-02-16 Thread Karolin Seeger
The branch, v4-6-test has been updated
   via  0c2a848 WHATSNEW: Add link to known issues.
  from  b975620 VERSION: Bump version up to 4.6.0rc4...

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


- Log -
commit 0c2a848296a4cd511988a6e526772ca439cb1dfa
Author: Karolin Seeger 
Date:   Thu Feb 16 10:26:34 2017 +0100

WHATSNEW: Add link to known issues.

Signed-off-by: Karolin Seeger 
Reviewed-by: Stefan Metzmacher 

Autobuild-User(v4-6-test): Karolin Seeger 
Autobuild-Date(v4-6-test): Thu Feb 16 14:16:52 CET 2017 on sn-devel-144

---

Summary of changes:
 WHATSNEW.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 751704b..d380a86 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -237,7 +237,7 @@ smb.conf changes
 KNOWN ISSUES
 
 
-Currently none.
+https://wiki.samba.org/index.php/Release_Planning_for_Samba_4.6#Release_blocking_bugs
 
 
 CHANGES SINCE 4.5.0rc2


-- 
Samba Shared Repository



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

2017-02-16 Thread Karolin Seeger
The branch, v4-5-test has been updated
   via  1a73c19 s3:librpc: remove bigendian argument from 
dcerpc_pull_ncacn_packet()
  from  ed83c31 ctdb-build: Install CTDB tests correctly from toplevel

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


- Log -
commit 1a73c1902c5a1ad64082a76086c41f24346b335f
Author: Stefan Metzmacher 
Date:   Wed Oct 28 12:16:05 2015 +0100

s3:librpc: remove bigendian argument from dcerpc_pull_ncacn_packet()

We should get this from the packet itself.

Signed-off-by: Stefan Metzmacher 
Reviewed-by: Günther Deschner 
Reviewed-by: Andreas Schneider 
(cherry picked from commit 1bfba2c5161c0e27f8c27301f258360aedf1b018)

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12581
smbclient fails on bad endianess when listing shares from Solaris kernel SMB
server on SPARC

Autobuild-User(v4-5-test): Karolin Seeger 
Autobuild-Date(v4-5-test): Thu Feb 16 13:37:57 CET 2017 on sn-devel-144

---

Summary of changes:
 source3/librpc/rpc/dcerpc.h | 3 +--
 source3/librpc/rpc/dcerpc_helpers.c | 9 -
 source3/rpc_client/cli_pipe.c   | 3 +--
 3 files changed, 6 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/librpc/rpc/dcerpc.h b/source3/librpc/rpc/dcerpc.h
index 1838012..f58ef4c 100644
--- a/source3/librpc/rpc/dcerpc.h
+++ b/source3/librpc/rpc/dcerpc.h
@@ -61,8 +61,7 @@ NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
  DATA_BLOB *blob);
 NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
  const DATA_BLOB *blob,
- struct ncacn_packet *r,
- bool bigendian);
+ struct ncacn_packet *r);
 NTSTATUS dcerpc_push_dcerpc_auth(TALLOC_CTX *mem_ctx,
 enum dcerpc_AuthType auth_type,
 enum dcerpc_AuthLevel auth_level,
diff --git a/source3/librpc/rpc/dcerpc_helpers.c 
b/source3/librpc/rpc/dcerpc_helpers.c
index aab43a1..11b445f 100644
--- a/source3/librpc/rpc/dcerpc_helpers.c
+++ b/source3/librpc/rpc/dcerpc_helpers.c
@@ -88,14 +88,12 @@ NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
 *  elements
 * @param blob  The blob of data to decode
 * @param r An empty ncacn_packet, must not be NULL
-* @param bigendian Whether the packet is bignedian encoded
 *
 * @return a NTSTATUS error code
 */
 NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
  const DATA_BLOB *blob,
- struct ncacn_packet *r,
- bool bigendian)
+ struct ncacn_packet *r)
 {
enum ndr_err_code ndr_err;
struct ndr_pull *ndr;
@@ -104,11 +102,12 @@ NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
if (!ndr) {
return NT_STATUS_NO_MEMORY;
}
-   if (bigendian) {
+
+   if (!(CVAL(ndr->data, DCERPC_DREP_OFFSET) & DCERPC_DREP_LE)) {
ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
}
 
-   if (CVAL(blob->data, DCERPC_PFC_OFFSET) & DCERPC_PFC_FLAG_OBJECT_UUID) {
+   if (CVAL(ndr->data, DCERPC_PFC_OFFSET) & DCERPC_PFC_FLAG_OBJECT_UUID) {
ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT;
}
 
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 47e2854..84d1121 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -948,8 +948,7 @@ static void rpc_api_pipe_got_pdu(struct tevent_req *subreq)
 
status = dcerpc_pull_ncacn_packet(state->pkt,
  &state->incoming_frag,
- state->pkt,
- !state->endianess);
+ state->pkt);
if (!NT_STATUS_IS_OK(status)) {
/*
 * TODO: do a real async disconnect ...


-- 
Samba Shared Repository



autobuild[sn-devel-144]: intermittent test failure detected

2017-02-16 Thread autobuild
The autobuild test system (on sn-devel-144) has detected an intermittent 
failing test in 
the current master tree.

The autobuild log of the failure is available here:

   http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-16-1210/flakey.log

The samba build logs are available here:

   
http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-16-1210/samba.stderr
   
http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-16-1210/samba.stdout
  
The top commit at the time of the failure was:

commit 5e7ae1b1e2fa8137aaa6a2a2f446156ae61f4c84
Author: Martin Schwenke 
Date:   Tue Feb 14 09:04:41 2017 +1100

ctdb-scripts: Initialise CTDB_NFS_CALLOUT in statd-callout

Some configurations may set CTDB_NFS_CALLOUT to the empty string.
They may do this if they allow a choice of NFS implementations.  In
this case the default call-out for Linux kernel NFS should be used.
However, statd-callout does not call nfs_callout_init() to set the
default.  Therefore, statd-callout is unable to restart the lock
manager, so the grace period is never entered.

statd-callout must call nfs_callout_init() before trying to restart
the lock manager.

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

Signed-off-by: Martin Schwenke 
Reviewed-by: Amitay Isaacs 

Autobuild-User(master): Martin Schwenke 
Autobuild-Date(master): Thu Feb 16 09:21:03 CET 2017 on sn-devel-144



autobuild[sn-devel-144]: intermittent test failure detected

2017-02-16 Thread autobuild
The autobuild test system (on sn-devel-144) has detected an intermittent 
failing test in 
the current master tree.

The autobuild log of the failure is available here:

   http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-16-1200/flakey.log

The samba build logs are available here:

   
http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-16-1200/samba.stderr
   
http://git.samba.org/autobuild.flakey.sn-devel-144/2017-02-16-1200/samba.stdout
  
The top commit at the time of the failure was:

commit 5e7ae1b1e2fa8137aaa6a2a2f446156ae61f4c84
Author: Martin Schwenke 
Date:   Tue Feb 14 09:04:41 2017 +1100

ctdb-scripts: Initialise CTDB_NFS_CALLOUT in statd-callout

Some configurations may set CTDB_NFS_CALLOUT to the empty string.
They may do this if they allow a choice of NFS implementations.  In
this case the default call-out for Linux kernel NFS should be used.
However, statd-callout does not call nfs_callout_init() to set the
default.  Therefore, statd-callout is unable to restart the lock
manager, so the grace period is never entered.

statd-callout must call nfs_callout_init() before trying to restart
the lock manager.

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

Signed-off-by: Martin Schwenke 
Reviewed-by: Amitay Isaacs 

Autobuild-User(master): Martin Schwenke 
Autobuild-Date(master): Thu Feb 16 09:21:03 CET 2017 on sn-devel-144



[SCM] Samba Shared Repository - branch master updated

2017-02-16 Thread Martin Schwenke
The branch, master has been updated
   via  5e7ae1b ctdb-scripts: Initialise CTDB_NFS_CALLOUT in statd-callout
   via  024a2c2 ctdb-tests: Add more comm tests
   via  9db7785 ctdb-common: Fix use-after-free error in comm_fd_handler()
  from  07bbd7f docs/vfs_ceph: document user_id parameter

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


- Log -
commit 5e7ae1b1e2fa8137aaa6a2a2f446156ae61f4c84
Author: Martin Schwenke 
Date:   Tue Feb 14 09:04:41 2017 +1100

ctdb-scripts: Initialise CTDB_NFS_CALLOUT in statd-callout

Some configurations may set CTDB_NFS_CALLOUT to the empty string.
They may do this if they allow a choice of NFS implementations.  In
this case the default call-out for Linux kernel NFS should be used.
However, statd-callout does not call nfs_callout_init() to set the
default.  Therefore, statd-callout is unable to restart the lock
manager, so the grace period is never entered.

statd-callout must call nfs_callout_init() before trying to restart
the lock manager.

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

Signed-off-by: Martin Schwenke 
Reviewed-by: Amitay Isaacs 

Autobuild-User(master): Martin Schwenke 
Autobuild-Date(master): Thu Feb 16 09:21:03 CET 2017 on sn-devel-144

commit 024a2c20d2bcdbcc43d16d492c7cd2d09b93c8f0
Author: Amitay Isaacs 
Date:   Tue Feb 7 15:18:02 2017 +1100

ctdb-tests: Add more comm tests

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

Signed-off-by: Amitay Isaacs 
Reviewed-by: Martin Schwenke 

commit 9db7785fc6ffbaad434ee189c0f46c488358aab5
Author: Amitay Isaacs 
Date:   Mon Feb 6 15:54:55 2017 +1100

ctdb-common: Fix use-after-free error in comm_fd_handler()

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

comm_write_send() creates a new tevent_req and adds it to the queue
of requests to be processed.  If this tevent_req is freed, then the
queue entry is not removed causing use-after-free error.

If the tevent_req returned by comm_write_send() is freed, then that
request should be removed from the queue and any pending actions based
on that request should also be removed.

Signed-off-by: Amitay Isaacs 
Reviewed-by: Martin Schwenke 

---

Summary of changes:
 ctdb/common/comm.c|  46 +-
 ctdb/config/statd-callout |   1 +
 ctdb/tests/cunit/comm_test_001.sh |  10 +-
 ctdb/tests/src/comm_test.c| 309 +-
 4 files changed, 324 insertions(+), 42 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/comm.c b/ctdb/common/comm.c
index 7f370da..12f4970 100644
--- a/ctdb/common/comm.c
+++ b/ctdb/common/comm.c
@@ -251,14 +251,22 @@ static void comm_read_failed(struct tevent_req *req)
  * Write packets
  */
 
+struct comm_write_entry {
+   struct comm_context *comm;
+   struct tevent_queue_entry *qentry;
+   struct tevent_req *req;
+};
+
 struct comm_write_state {
struct tevent_context *ev;
struct comm_context *comm;
+   struct comm_write_entry *entry;
struct tevent_req *subreq;
uint8_t *buf;
size_t buflen, nwritten;
 };
 
+static int comm_write_entry_destructor(struct comm_write_entry *entry);
 static void comm_write_trigger(struct tevent_req *req, void *private_data);
 static void comm_write_done(struct tevent_req *subreq);
 
@@ -269,6 +277,7 @@ struct tevent_req *comm_write_send(TALLOC_CTX *mem_ctx,
 {
struct tevent_req *req;
struct comm_write_state *state;
+   struct comm_write_entry *entry;
 
req = tevent_req_create(mem_ctx, &state, struct comm_write_state);
if (req == NULL) {
@@ -280,15 +289,38 @@ struct tevent_req *comm_write_send(TALLOC_CTX *mem_ctx,
state->buf = buf;
state->buflen = buflen;
 
-   if (!tevent_queue_add_entry(comm->queue, ev, req,
-   comm_write_trigger, NULL)) {
-   talloc_free(req);
-   return NULL;
+   entry = talloc_zero(state, struct comm_write_entry);
+   if (tevent_req_nomem(entry, req)) {
+   return tevent_req_post(req, ev);
}
 
+   entry->comm = comm;
+   entry->req = req;
+   entry->qentry = tevent_queue_add_entry(comm->queue, ev, req,
+  comm_write_trigger, NULL);
+   if (tevent_req_nomem(entry->qentry, req)) {
+   return tevent_req_post(req, ev);
+   }
+
+   state->entry = entry;
+   talloc_set_destructor(entry, comm_write_entry_destructor);
+
return req;
 }
 
+static int comm_write_entry_destructor(struct comm_write_entry *entry)
+{
+   struct comm_context *comm = entry->comm;
+
+   if (comm->write_req == entry->req) {
+