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

Karolin Seeger kseeger at samba.org
Tue Feb 28 20:09:17 UTC 2017


The branch, v4-6-stable has been updated
       via  7600d32 VERSION: Disable git snapshots for the 4.6.0rc4 release.
       via  351ff91 WHATSNEW: Add release notes for Samba 4.6.0rc4.
       via  8d0e014 ctdb-build: Fix RPM build
       via  be23d38 ctdb-build: Add WAFLOCK magic to manpages target
       via  e10c2a4 dbchecker: Stop ignoring linked cases where both objects are alive
       via  9a40cea tests/dbcheck: Add a test for two live objects, with a dangling forward link
       via  ea70487 tests/dbcheck: Add a test for two live objects, with a dangling backlink
       via  e598a66 pidl:Python: use of pytalloc_GenericObject_reference*() for pyrpc_{ex,im}port_union() wrapping
       via  b93c412 pidl:Python: replace pytalloc_CObject_FromTallocPtr() with pytalloc_GenericObject_reference_ex()
       via  1f144b9 pidl:Python: make sure print HASH references for STRUCT types
       via  10aebdc py_net: make use of pytalloc_GenericObject_steal()
       via  9fd7e54 talloc: version 2.1.9
       via  3655e7c pytalloc: add pytalloc_GenericObject_{steal,reference}[_ex]()
       via  b359915 talloc: fix TALLOC_VERSION_* mismatch detection
       via  d5f579e talloc/wscript: avoid passing pointless enabled=True to SAMBA_PYTHON()
       via  d96ce9c lib: talloc: Make it clear that talloc_get_size(NULL) returns 0.
       via  ac59b3a s3:idmap_ad: make use of pdb_get_trust_credentials() to get the machine account creds
       via  3569a97 s3:winbindd: allow a fallback to NTLMSSP for LDAP connections
       via  94c58e6 s3:libads: add more debugging to ads_sasl_spnego_bind()
       via  e90dead s3:winbindd: rely on the kerberos_state from pdb_get_trust_credentials()
       via  b7e0a56 s3:winbindd: add more debugging to cm_prepare_connection()
       via  7a96e98 s3:passdb: use cli_credentials_set_kerberos_state() for trusts in pdb_get_trust_credentials()
       via  5779c43 s3:winbindd: fix the valid usage anonymous smb authentication
       via  9e4be46 auth/credentials: try to use kerberos with the machine account unless we're in an AD domain
       via  e084c42 s3:winbindd: try a NETLOGON connection with noauth over NCACN_NP against trusted domains.
       via  45abd7b Revert "s3-winbind: Fix schannel connections against trusted domain DCs"
       via  1e6322c s3:winbindd: make sure cm_prepare_connection() only returns OK with a valid tree connect
       via  39582f3 vfs_streams_xattr: use fsp, not base_fsp
       via  0c9bc50 libcli/auth: use the correct creds value against servers without LogonSamLogonEx
       via  8ee5fe5 librpc/rpc: fix regression in NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE error mapping
       via  8cb9f77 build: Fix generation of CTDB manpages while creating tarball
       via  a39218d ctdb-build: Add make target for generating manpages
       via  706141a ctdb-build: Split dist() target to generate manpages separately
       via  a2c013b krb5_wrap: use our own code to calculate the ENCTYPE_ARCFOUR_HMAC key
       via  dfb3795 s4:scripting: use generate_random_machine_password() for machine passwords
       via  6153b15 samba-tool:provision: use generate_random_machine_password() for machine passwords
       via  f5df4eb samba-tool:domain: use generate_random_machine_password() for machine passwords
       via  f6dc073 samba-tool:domain: use generate_random_machine_password() for trusted domains
       via  40366fd pyglue: add generate_random_machine_password() wrapper
       via  705686e python/samba: use an explicit .encode('utf-8') where we expect utf8 passwords
       via  00d3c8e python/samba: provision_dns_add_samba.ldif expects utf-16-le passwords
       via  c5a4e47 s4:dsdb: autogenerate a random utf16 buffer for krbtgt password resets.
       via  7c75976 s4:libnet: make use of generate_random_machine_password()
       via  53ef65b s4:libcli/raw: remove unused DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH
       via  e0119dd s3:include: remove unused DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH
       via  aa79c0d s3:net_rpc_trust: make use of trust_pw_new_value()
       via  2e125de s3:libnet_join: make use of trust_pw_new_value()
       via  fd09929 s3:libads: use trust_pw_new_value() for krb5 machine passwords
       via  c01b2c2 s3:libsmb: use trust_pw_new_value() in trust_pw_change()
       via  ae300c7 s3:libsmb: add trust_pw_new_value() helper function
       via  38cfd61 s3:libsmb: let trust_pw_change() verify the new password at the end.
       via  60d48a8 s3:libsmb: let trust_pw_change() debug more verbose information
       via  39ebdf7 lib/util: add generate_random_machine_password() function
       via  7132f093 libcli/auth: add netlogon_creds_cli_debug_string()
       via  bcfa544 libcli/auth: check E_md4hash() result in netlogon_creds_cli_ServerPasswordSet_send()
       via  7567c0e WHATSNEW: Fix spelling of Messages
       via  e049016 WHATSNEW: Clarify and extend the the AD DC performance improvement text
       via  632a38e Modify smbspool_krb5_wrapper to just fall through to smbspool if AUTH_INFO_REQUIRED is not set or is not "negotiate".
       via  6bc0acf ctdb-scripts: Initialise CTDB_NFS_CALLOUT in statd-callout
       via  00723fa ctdb-tests: Add more comm tests
       via  1284283 ctdb-common: Fix use-after-free error in comm_fd_handler()
       via  dd79298 s3: torture: Regression test for smbd trying to open an invalid symlink.
       via  27c25fc s3: smbd: Don't loop infinitely on bad-symlink resolution.
       via  7c74e90 s3-vfs: Only walk the directory once in open_and_sort_dir()
       via  91c0bf9 s3/rpc_server/mdssvc: add attribute "kMDItemContentType"
       via  caf33c5 s3/smbd: check for invalid access_mask smbd_calculate_access_mask()
       via  964ecb1 selftest: also run test base.createx_access against ad_dc
       via  ca34320 WHATSNEW: vfs_fruit metadata xattr name on *BSD and mvxattr
       via  6b3f1be s3/util: mvxattr, a tool to rename extended attributes
       via  6745bf2 lib/replace: validate xattr namespace prefix on FreeBSD
       via  0e22dda vfs_fruit: fix resource fork xattr name
       via  1a79870 vfs_fruit: cleanup metadata and resource xattr name defines
       via  283cfd4 vfs_fruit: correct Netatalk metadata xattr on FreeBSD
       via  c28902d WHATSNEW: Fix obvious typo.
       via  0c2a848 WHATSNEW: Add link to known issues.
       via  b975620 VERSION: Bump version up to 4.6.0rc4...
      from  a7d9079 VERSION: Disable git snapshots for the 4.6.0rc3 release.

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


- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 VERSION                                            |   2 +-
 WHATSNEW.txt                                       | 124 ++++++++-
 auth/credentials/credentials_secrets.c             |  17 +-
 ctdb/Makefile                                      |   4 +
 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 ++++++++++++++++++---
 ctdb/wscript                                       |  47 ++--
 docs-xml/manpages/mvxattr.1.xml                    | 100 +++++++
 docs-xml/wscript_build                             |   1 +
 lib/krb5_wrap/krb5_samba.c                         |  37 +++
 lib/replace/xattr.c                                | 105 +++++--
 ...oc-util-2.1.7.sigs => pytalloc-util-2.1.9.sigs} |   3 +
 ...til-2.1.7.sigs => pytalloc-util.py3-2.1.9.sigs} |   4 +-
 .../ABI/{talloc-2.1.4.sigs => talloc-2.1.9.sigs}   |   0
 lib/talloc/pytalloc.c                              |  13 +
 lib/talloc/pytalloc.h                              |  28 +-
 lib/talloc/pytalloc_guide.txt                      |  73 ++++-
 lib/talloc/pytalloc_util.c                         |  95 ++++++-
 lib/talloc/talloc.c                                |  14 +-
 lib/talloc/talloc.h                                |   2 +-
 lib/talloc/wscript                                 |   8 +-
 lib/util/genrand_util.c                            | 168 ++++++++++-
 lib/util/samba_util.h                              |  32 ++-
 libcli/auth/netlogon_creds_cli.c                   |  33 ++-
 libcli/auth/netlogon_creds_cli.h                   |   4 +
 librpc/rpc/dcerpc_error.c                          |   8 +-
 pidl/lib/Parse/Pidl/Samba4/Python.pm               | 113 ++------
 python/pyglue.c                                    |  26 +-
 python/samba/__init__.py                           |   1 +
 python/samba/dbchecker.py                          |  23 +-
 python/samba/join.py                               |  11 +-
 python/samba/netcmd/domain.py                      |  29 +-
 python/samba/netcmd/user.py                        |   2 +-
 python/samba/provision/__init__.py                 |   6 +-
 python/samba/provision/sambadns.py                 |   2 +-
 python/samba/samdb.py                              |   2 +-
 python/samba/upgradehelpers.py                     |   4 +-
 selftest/skip                                      |   1 +
 source3/client/smbspool_krb5_wrapper.c             |  32 ++-
 source3/include/proto.h                            |   3 +
 source3/include/smb.h                              |   6 -
 source3/libads/sasl.c                              |  26 +-
 source3/libads/util.c                              |   9 +-
 source3/libnet/libnet_join.c                       |  16 +-
 source3/libsmb/trusts_util.c                       | 143 ++++++++--
 source3/modules/vfs_dirsort.c                      |  63 +++--
 source3/modules/vfs_fruit.c                        |  12 +-
 source3/modules/vfs_streams_xattr.c                |  41 ++-
 source3/passdb/passdb.c                            |  17 ++
 source3/rpc_server/mdssvc/sparql_mapping.c         |   5 +
 source3/selftest/tests.py                          |   6 +-
 source3/smbd/open.c                                | 110 ++++----
 source3/torture/torture.c                          | 101 +++++++
 source3/utils/mvxattr.c                            | 178 ++++++++++++
 source3/utils/net_rpc_trust.c                      |   6 +-
 source3/utils/wscript_build                        |   8 +
 source3/winbindd/idmap_ad.c                        |  36 +--
 source3/winbindd/winbindd_ads.c                    |   2 +
 source3/winbindd/winbindd_cm.c                     |  94 ++++---
 source3/wscript                                    |   3 +
 source3/wscript_build                              |   1 +
 source4/dsdb/samdb/ldb_modules/password_hash.c     |  84 ++++++
 source4/dsdb/samdb/ldb_modules/samldb.c            |  25 +-
 source4/libcli/raw/smb.h                           |   7 -
 source4/libnet/libnet_vampire.c                    |   2 +-
 source4/libnet/py_net.c                            |   5 +-
 source4/librpc/rpc/pyrpc_util.c                    |  44 +--
 source4/scripting/bin/renamedc                     |   2 +-
 .../add-dangling-backlink-user.ldif                |   3 +
 .../release-4-5-0-pre1/add-dangling-backlink.ldif  |   4 +
 .../add-dangling-forwardlink-user.ldif             |   3 +
 .../add-initially-normal-link.ldif                 |   4 +
 .../release-4-5-0-pre1/delete-only-backlink.ldif   |   4 +
 .../expected-dbcheck-link-output.txt               |  10 +-
 testprogs/blackbox/dbcheck-links.sh                |  37 +++
 wscript                                            |   2 +-
 78 files changed, 2088 insertions(+), 574 deletions(-)
 create mode 100644 docs-xml/manpages/mvxattr.1.xml
 copy lib/talloc/ABI/{pytalloc-util-2.1.7.sigs => pytalloc-util-2.1.9.sigs} (77%)
 copy lib/talloc/ABI/{pytalloc-util-2.1.7.sigs => pytalloc-util.py3-2.1.9.sigs} (75%)
 copy lib/talloc/ABI/{talloc-2.1.4.sigs => talloc-2.1.9.sigs} (100%)
 create mode 100644 source3/utils/mvxattr.c
 create mode 100644 source4/selftest/provisions/release-4-5-0-pre1/add-dangling-backlink-user.ldif
 create mode 100644 source4/selftest/provisions/release-4-5-0-pre1/add-dangling-backlink.ldif
 create mode 100644 source4/selftest/provisions/release-4-5-0-pre1/add-dangling-forwardlink-user.ldif
 create mode 100644 source4/selftest/provisions/release-4-5-0-pre1/add-initially-normal-link.ldif
 create mode 100644 source4/selftest/provisions/release-4-5-0-pre1/delete-only-backlink.ldif


Changeset truncated at 500 lines:

diff --git a/VERSION b/VERSION
index e33652e..ba5e85f 100644
--- a/VERSION
+++ b/VERSION
@@ -87,7 +87,7 @@ SAMBA_VERSION_PRE_RELEASE=
 # e.g. SAMBA_VERSION_RC_RELEASE=1                      #
 #  ->  "3.0.0rc1"                                      #
 ########################################################
-SAMBA_VERSION_RC_RELEASE=3
+SAMBA_VERSION_RC_RELEASE=4
 
 ########################################################
 # To mark SVN snapshots this should be set to 'yes'    #
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 751704b..a2f647a 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,7 +1,7 @@
 Release Announcements
 =====================
 
-This is the third release candidate of Samba 4.6.  This is *not*
+This is the fourth release candidate of Samba 4.6.  This is *not*
 intended for production environments and is designed for testing
 purposes only.  Please report any defects via the Samba bug reporting
 system at https://bugzilla.samba.org/.
@@ -44,6 +44,26 @@ configured as the default backend.
 To avoid problems in future we advise all users to run 'testparm' after
 changing the smb.conf file!
 
+vfs_fruit Netatalk metadata xattr name on *BSD
+----------------------------------------------
+
+Users on *BSD must rename the metadata xattr used by vfs_fruit when
+using the default setting "fruit:metadata = netatalk".
+
+Due to a glitch in the Samba xattr API compatibility layer for FreeBSD and a
+mistake in vfs_fruit, vfs_fruit ended up using the wrong xattr name when
+configured with "fruit:metadata = netatalk" (default). Instead of the correct
+
+  org.netatalk.Metadata
+
+it used
+
+  netatalk.Metadata
+
+Starting with Samba 4.6 vfs_fruit will use the correct "org.netatalk.Metadata"
+which means existing installations must rename this xattrs. For this purpose
+Samba now includes a new tool `mvxattr`. See below for further details.
+
 
 NEW FEATURES/CHANGES
 ====================
@@ -97,7 +117,7 @@ As part of this change, the NETLOGON service will now run on a distinct
 TCP port, rather than being shared with all other RPC services (LSA,
 SAMR, DRSUAPI etc).
 
-new options for controlling TCP ports used for RPC services
+New options for controlling TCP ports used for RPC services
 -----------------------------------------------------------
 
 The new 'rpc server port' option controls the default port used for
@@ -105,14 +125,23 @@ RPC services other than Netlogon.  The Netlogon server honours instead
 the 'rpc server port:netlogon' option.  The default value for both
 these options is the first available port including or after 1024.
 
-Improve AD performance and replication improvements
----------------------------------------------------
+AD LDAP and replication performance improvements
+------------------------------------------------
+
+Samba's LDB (the database holding the AD directory tree, as seen via
+LDAP) and our DRSUAPI replication code continues to improve,
+particularly in respect to the handling of large numbers of objects or
+linked attributes.
 
-Samba's LDB and replication code continues to improve, particularly in
-respect to the handling of large numbers of linked attributes.  We now
-respect an 'uptodateness vector' which will dramatically reduce the
-over-replication of links from new DCs.  We have also made the parsing
-of on-disk linked attributes much more efficient.
+ * We now respect an 'uptodateness vector' which will dramatically
+   reduce the over-replication of links from new DCs.
+
+ * We have also made the parsing of on-disk linked attributes much
+   more efficient.
+
+ * We rely on ldb 1.1.28.  This ldb version has improved memory
+   handling for ldb search results, improving poorly indexed and
+   unindexed search result processing speed by around 20%.
 
 DNS improvements
 ----------------
@@ -152,7 +181,7 @@ CTDB changes
   ctdb-recoverd: Messages from CTDB's recovery daemon
   ctdb-recovery: Messages from CTDB database recovery
   ctdb-eventd: Messages from CTDB's event daemon
-  ctdb-takeover: Messgaes from CTDB's public IP takeover subsystem
+  ctdb-takeover: Messages from CTDB's public IP takeover subsystem
 
 * The mapping between symbolic and numeric debug levels has changed
 
@@ -221,6 +250,24 @@ to retrieve the home directory and login shell from the "Unix
 Attributes" of the user. This supersedes the "winbind nss info"
 parameter with a per-domain configuration option.
 
+mvxattr
+-------
+
+mvxattr is a simple utility to recursively rename extended attributes of all
+files and directories in a directory tree.
+
+  Usage: mvxattr -s STRING -d STRING PATH [PATH ...]
+    -s, --from=STRING         xattr source name
+    -d, --to=STRING           xattr destination name
+    -l, --follow-symlinks     follow symlinks, the default is to ignore them
+    -p, --print               print files where the xattr got renamed
+    -v, --verbose             print files as they are checked
+    -f, --force               force overwriting of destination xattr
+
+  Help options:
+    -?, --help                Show this help message
+    --usage                   Display brief usage message
+
 
 smb.conf changes
 ================
@@ -237,10 +284,61 @@ 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.6.0rc3
+======================
+
+o  Jeremy Allison <jra at samba.org>
+   * BUG 12545: s3: rpc_server/mdssvc: Add attribute "kMDItemContentType".
+   * BUG 12572: s3: smbd: Don't loop infinitely on bad-symlink resolution.
+
+o  Ralph Boehme <slow at samba.org>
+   * BUG 12490: vfs_fruit: Correct Netatalk metadata xattr on FreeBSD.
+   * BUG 12536: s3/smbd: Check for invalid access_mask
+     smbd_calculate_access_mask().
+   * BUG 12591: vfs_streams_xattr: use fsp, not base_fsp.
+
+o  Amitay Isaacs <amitay at gmail.com>
+   * BUG 12580: ctdb-common: Fix use-after-free error in comm_fd_handler().
+   * BUG 12595: build: Fix generation of CTDB manpages while creating tarball.
+
+o  Bryan Mason <bmason at redhat.com>
+   * BUG 12575: Modify smbspool_krb5_wrapper to just fall through to smbspool if
+     AUTH_INFO_REQUIRED is not set or is not "negotiate".
+
+o  Stefan Metzmacher <metze at samba.org>
+   * BUG 11830: s3:winbindd: Try a NETLOGON connection with noauth over NCACN_NP
+     against trusted domains.
+   * BUG 12262: 'net ads testjoin' and smb access fails after winbindd changed the
+     trust password.
+   * BUG 12585: librpc/rpc: fix regression in
+     NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE error mapping.
+   * BUG 12586: netlogon_creds_cli_LogonSamLogon doesn't work without
+     netr_LogonSamLogonEx.
+   * BUG 12587: winbindd child segfaults on connect to an NT4 domain.
+   * BUG 12588: s3:winbindd: Make sure cm_prepare_connection() only returns OK
+     with a valid tree connect.
+   * BUG 12598: winbindd (as member) requires kerberos against trusted ad domain,
+     while it shouldn't.
+   * BUG 12601: Backport pytalloc_GenericObject_reference() related changes to
+     4.6.
+
+o  Garming Sam <garming at catalyst.net.nz>
+   * BUG 12600: dbchecker: Stop ignoring linked cases where both objects are
+     alive.
+
+o  Andreas Schneider <asn at samba.org>
+   * BUG 12571: s3-vfs: Only walk the directory once in open_and_sort_dir().
+
+o  Martin Schwenke <martin at meltin.net>
+   * BUG 12589: CTDB statd-callout does not cause grace period when
+     CTDB_NFS_CALLOUT="".
+   * BUG 12595: ctdb-build: Fix RPM build.
 
 
-CHANGES SINCE 4.5.0rc2
+CHANGES SINCE 4.6.0rc2
 ======================
 
 o  Jeremy Allison <jra at samba.org>
@@ -292,7 +390,7 @@ o  Uri Simchoni <uri at samba.org>
    * BUG 12529: waf: Backport finding of pkg-config.
 
 
-CHANGES SINCE 4.5.0rc1
+CHANGES SINCE 4.6.0rc1
 ======================
 
 o  Amitay Isaacs <amitay at gmail.com>
diff --git a/auth/credentials/credentials_secrets.c b/auth/credentials/credentials_secrets.c
index d5a37cf..ed148fd 100644
--- a/auth/credentials/credentials_secrets.c
+++ b/auth/credentials/credentials_secrets.c
@@ -39,7 +39,7 @@
 #include "dbwrap/dbwrap.h"
 #include "dbwrap/dbwrap_open.h"
 #include "lib/util/util_tdb.h"
-
+#include "libds/common/roles.h"
 
 /**
  * Fill in credentials for the machine trust account, from the secrets database.
@@ -276,6 +276,8 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account_db_ctx(struct cli_credenti
 	char *secrets_tdb_password = NULL;
 	char *secrets_tdb_old_password = NULL;
 	uint32_t secrets_tdb_secure_channel_type = SEC_CHAN_NULL;
+	int server_role = lpcfg_server_role(lp_ctx);
+	int security = lpcfg_security(lp_ctx);
 	char *keystr;
 	char *keystr_upper = NULL;
 	TALLOC_CTX *tmp_ctx = talloc_named(cred, 0, "cli_credentials_set_secrets from ldb");
@@ -354,13 +356,26 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account_db_ctx(struct cli_credenti
 	}
 
 	if (secrets_tdb_password_more_recent) {
+		enum credentials_use_kerberos use_kerberos = CRED_DONT_USE_KERBEROS;
 		char *machine_account = talloc_asprintf(tmp_ctx, "%s$", lpcfg_netbios_name(lp_ctx));
 		cli_credentials_set_password(cred, secrets_tdb_password, CRED_SPECIFIED);
 		cli_credentials_set_old_password(cred, secrets_tdb_old_password, CRED_SPECIFIED);
 		cli_credentials_set_domain(cred, domain, CRED_SPECIFIED);
 		if (strequal(domain, lpcfg_workgroup(lp_ctx))) {
 			cli_credentials_set_realm(cred, lpcfg_realm(lp_ctx), CRED_SPECIFIED);
+
+			switch (server_role) {
+			case ROLE_DOMAIN_MEMBER:
+				if (security != SEC_ADS) {
+					break;
+				}
+				/* fall through */
+			case ROLE_ACTIVE_DIRECTORY_DC:
+				use_kerberos = CRED_AUTO_USE_KERBEROS;
+				break;
+			}
 		}
+		cli_credentials_set_kerberos_state(cred, use_kerberos);
 		cli_credentials_set_username(cred, machine_account, CRED_SPECIFIED);
 		cli_credentials_set_password_last_changed_time(cred, secrets_tdb_lct);
 		cli_credentials_set_secure_channel_type(cred, secrets_tdb_secure_channel_type);
diff --git a/ctdb/Makefile b/ctdb/Makefile
index b0912f2..10ac9ab 100644
--- a/ctdb/Makefile
+++ b/ctdb/Makefile
@@ -27,6 +27,10 @@ show_version:
 	@touch .tmplock
 	@WAFLOCK=.tmplock $(WAF) show_version
 
+manpages:
+	touch .tmplock
+	WAFLOCK=.tmplock $(WAF) manpages
+
 dist:
 	touch .tmplock
 	WAFLOCK=.tmplock $(WAF) dist
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) {
+		comm->write_req = NULL;
+		TEVENT_FD_NOT_WRITEABLE(comm->fde);
+	}
+
+	TALLOC_FREE(entry->qentry);
+	return 0;
+}
+
 static void comm_write_trigger(struct tevent_req *req, void *private_data)
 {
 	struct comm_write_state *state = tevent_req_data(
@@ -333,6 +365,8 @@ static void comm_write_done(struct tevent_req *subreq)
 	}
 
 	state->nwritten = nwritten;
+	state->entry->qentry = NULL;
+	TALLOC_FREE(state->entry);
 	tevent_req_done(req);
 }
 
@@ -382,8 +416,8 @@ static void comm_fd_handler(struct tevent_context *ev,
 		struct comm_write_state *write_state;
 
 		if (comm->write_req == NULL) {
-			/* This should never happen */
-			abort();
+			TEVENT_FD_NOT_WRITEABLE(comm->fde);
+			return;
 		}
 
 		write_state = tevent_req_data(comm->write_req,
diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout
index 3f2dd39..38f847b 100755
--- a/ctdb/config/statd-callout
+++ b/ctdb/config/statd-callout
@@ -128,6 +128,7 @@ case "$1" in
 	# where the lock manager will respond "strangely" immediately
 	# after restarting it, which causes clients to fail to reclaim
 	# their locks.
+	nfs_callout_init
 	"$CTDB_NFS_CALLOUT" "stop" "nlockmgr" >/dev/null 2>&1
         sleep 2
 	"$CTDB_NFS_CALLOUT" "start" "nlockmgr" >/dev/null 2>&1
diff --git a/ctdb/tests/cunit/comm_test_001.sh b/ctdb/tests/cunit/comm_test_001.sh
index 5d20db2..ac09f5c 100755
--- a/ctdb/tests/cunit/comm_test_001.sh
+++ b/ctdb/tests/cunit/comm_test_001.sh
@@ -2,6 +2,12 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-ok "100 2048 500 4096 1024 8192 200 16384 300 32768 400 65536 1048576 "
 
-unit_test comm_test
+ok_null
+unit_test comm_test 1
+
+ok_null
+unit_test comm_test 2
+
+ok "100 2048 500 4096 1024 8192 200 16384 300 32768 400 65536 1048576 "
+unit_test comm_test 3
diff --git a/ctdb/tests/src/comm_test.c b/ctdb/tests/src/comm_test.c
index 2189435..5e1d694 100644
--- a/ctdb/tests/src/comm_test.c
+++ b/ctdb/tests/src/comm_test.c
@@ -26,7 +26,218 @@
 #include "common/pkt_write.c"
 #include "common/comm.c"
 
-static void dead_handler(void *private_data)
+/*
+ * Test read_handler and dead_handler
+ */
+
+static void test1_read_handler(uint8_t *buf, size_t buflen,
+			       void *private_data)
+{
+	int *result = (int *)private_data;
+
+	*result = -1;
+}
+
+static void test1_dead_handler(void *private_data)
+{
+	int *result = (int *)private_data;
+
+	*result = 1;
+}
+
+static void test1(void)
+{
+	TALLOC_CTX *mem_ctx;
+	struct tevent_context *ev;
+	struct comm_context *comm;
+	int fd[2];
+	int result = 0;
+	uint32_t data[2];
+	int ret;
+	ssize_t n;
+
+	mem_ctx = talloc_new(NULL);
+	assert(mem_ctx != NULL);
+
+	ev = tevent_context_init(mem_ctx);
+	assert(ev != NULL);
+
+	ret = pipe(fd);
+	assert(ret == 0);
+
+	ret = comm_setup(ev, ev, fd[0], test1_read_handler, &result,
+			 test1_dead_handler, &result, &comm);
+	assert(ret == 0);
+
+	data[0] = 2 * sizeof(uint32_t);
+	data[1] = 0;
+
+	n = write(fd[1], (void *)&data, data[0]);
+	assert(n == data[0]);
+
+	while (result == 0) {
+		tevent_loop_once(ev);
+	}
+
+	assert(result == -1);
+
+	result = 0;
+	close(fd[1]);
+
+	while (result == 0) {
+		tevent_loop_once(ev);
+	}
+
+	assert(result == 1);
+
+	talloc_free(mem_ctx);
+}
+
+/*
+ * Test that the tevent_req returned by comm_write_send() can be free'd.
+ */
+
+struct test2_state {
+	TALLOC_CTX *mem_ctx;
+	bool done;
+};
+
+static void test2_read_handler(uint8_t *buf, size_t buflen,
+			       void *private_data)
+{
+	struct test2_state *state = (struct test2_state *)private_data;
+
+	TALLOC_FREE(state->mem_ctx);
+}
+
+static void test2_dead_handler(void *private_data)
+{
+	abort();
+}
+
+struct test2_write_state {
+	int count;
+};
+
+static void test2_write_done(struct tevent_req *subreq);
+
+static struct tevent_req *test2_write_send(TALLOC_CTX *mem_ctx,
+					   struct tevent_context *ev,
+					   struct comm_context *comm,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list