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

Jule Anger janger at samba.org
Wed Jan 31 20:42:02 UTC 2024


The branch, v4-18-stable has been updated
       via  51a13a23371 VERSION: Disable GIT_SNAPSHOT for the 4.18.10 release.
       via  13709fd743d WHATSNEW: Add release notes for Samba 4.18.10.
       via  974a8908223 smbd: use dirfsp and atname in open_directory()
       via  ab7d69665d0 smbd: use safe_symlink_target_path() in symlink_target_below_conn()
       via  0086f3d4b7b smbd: add a directory argument to safe_symlink_target_path()
       via  f495f6d2778 smbd: pass symlink target path to safe_symlink_target_path()
       via  8bac9003342 CI: disable /proc/fds and RESOLVE_NO_SYMLINK in samba-no-opath-build runner
       via  4b1f0c6e8bb vfs_default: allow disabling /proc/fds and RESOLVE_NO_SYMLINK at compile time
       via  e6745b15107 s3:passdb: smbpasswd reset permissions only if not 0600
       via  161efeac21d system.c: fix fake directory create times
       via  0d75a9acaf3 time.c: fix ctime which was feeded with the mtime seconds
       via  ee2df0bbb34 smbd: move access override for previous versions to the SMB layer
       via  1e108b3ac07 smbd: check for previous versions in check_any_access_fsp()
       via  d3f062e2122 smbd: use check_any_access_fsp() for all access checks
       via  77a71bc9932 smbd: replace CHECK_WRITE() macro with calls to check_any_access_fsp()
       via  15536403f63 smbd: set fsp->fsp_flags.can_write to false for access to previous-versions
       via  8ee0768d6f2 smbd: return correct error when trying to create a hardlink to a VSS file
       via  8c08511f97d smbd: fix check_any_access_fsp() for non-fsa fsps
       via  b775434b7eb smbd: rename check_access_fsp() to check_any_access_fsp()
       via  d87294724e6 smbd: set fsp_flags.is_fsa to true on printer file handles
       via  c8e1d26cea5 smbd: return the correct error in can_rename()
       via  7080c5b4850 smbtorture: expand smb2.twrp.write test
       via  469c91c4133 s4/libcli/raw: implemement RAW_SFILEINFO_LINK_INFORMATION
       via  29f629a155f selftest: remove error_inject from shadow_write share
       via  a9862b23e00 docs-xml: use XML_CATALOG_FILES env var if defined
       via  96897774dd7 winbind_nss_netbsd: fix missing semicolon
       via  49d9e55edd9 doc-xml: fix name of vfs_linux_xfs man page
       via  529fb888a6c smbd: Fix traversing snapshot dirs that vanished in current fileset
       via  7f4d5a3737f shadow_copy: Add test for missing directory in "current" fileset
       via  9f8a73d7cc4 s3:smbd multichannel: always refresh the network information
       via  c2c111688c4 s3:ctdbd_conn: fix ctdbd_public_ip_foreach() for ipv6 addresses
       via  a149a96eaf2 ctdb-server: Drop unnecessary copy of destination address
       via  ff4ed4d760a ctdb-daemon: Use ctdb_connection_to_buf() to simplify
       via  279187965b8 smbd: Remove callback for release_ip when "state" is free'ed
       via  f8c02609f48 s3:selftest: add samba3.blackbox.smbXsrv_client_ctdb_registered_ips
       via  d9ed96c908c selftest: export/use CTDB related envvars in order to run the ctdb command
       via  6ca3ce4db30 ctdbd_conn: add ctdbd_passed_ips()
       via  18d34cea2a1 ctdbd_conn: add ctdbd_unregister_ips()
       via  ecc0acbbff2 ctdbd_conn: Add deregister_from_ctdbd()
       via  562e360ed7c ctdbd_conn: let register_with_ctdbd() call CTDB_CONTROL_REGISTER_SRVID just once
       via  24d960d02b8 ctdbd_conn: don't use uninitialized memory in ctdbd_register_ips()
       via  813e7186719 ctdb: add/implement CTDB_CONTROL_TCP_CLIENT_PASSED
       via  f7694157993 ctdb: add/implement CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
       via  0de804ac5d6 ctdb: add ctdb_connection_same() helper
       via  9d8768ffd35 ctdb: make use of ctdb_canonicalize_ip_inplace() in ctdb_control_tcp_client()
       via  d7249b3cbd2 ctdb: add ctdb_canonicalize_ip_inplace() helper
       via  30fddc01431 ctdb: remove unused ctdb->client_ip_list and print debug on ctdb_tcp_list instead
       via  849c370d92a vfs_ceph: call 'ceph_fgetxattr' only if valid fd
       via  0a8cf4f1c06 testprogs: Add net offlinejoin composeodj tests
       via  ce29bbfb7db testprogs: Cleanup machine account in net offlinejoin tests
       via  69475590970 s3:net: Allow to load ODJ blob from stdin
       via  1f066b595f9 s3:net: Load ODJ blob from file only if "loadfile" parameter is present
       via  ca6ba984095 s3:net: Add "net offlinejoin composeodj" command
       via  4e43af11c3a s3:libnetapi: Implement NetComposeOfflineDomainJoin_l()
       via  ad2196fd792 s3:libnetapi: Add NetComposeOfflineDomainJoin() to API.
       via  fddbff3d44a s3:libnetapi: Add NetComposeOfflineDomainJoin() boilerplate
       via  a85441249de s3:libnetapi: Add NetComposeOfflineDomainJoin() to IDL
       via  f8021a241e5 s3:libnetapi: Add some comments to document ODJ blob charset conversions
       via  f731d75081f s3:libnetapi: Return error from RequestOfflineJoin
       via  6c06c9ed427 VERSION: Bump version up to Samba 4.18.10...
      from  2669b77d97b VERSION: Disable GIT_SNAPSHOT for the 4.18.9 release.

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


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

Summary of changes:
 VERSION                                            |   2 +-
 WHATSNEW.txt                                       |  82 +++++-
 buildtools/wafsamba/wafsamba.py                    |   2 +-
 ctdb/common/common.h                               |   1 +
 ctdb/common/ctdb_util.c                            |   7 +
 ctdb/include/ctdb_private.h                        |   7 +-
 ctdb/protocol/protocol.h                           |   2 +
 ctdb/protocol/protocol_control.c                   |  30 ++
 ctdb/protocol/protocol_debug.c                     |   2 +
 ctdb/protocol/protocol_util.c                      |  18 ++
 ctdb/protocol/protocol_util.h                      |   3 +
 ctdb/server/ctdb_control.c                         |   8 +
 ctdb/server/ctdb_takeover.c                        | 292 ++++++++++++-------
 docs-xml/manpages/vfs_linux_xfs_sgid.8.xml         |   4 +-
 lib/util/time.c                                    |   2 +-
 nsswitch/winbind_nss_netbsd.c                      |   2 +-
 script/autobuild.py                                |   2 +-
 selftest/skip.opath-required                       |   4 +
 selftest/target/Samba.pm                           |  19 ++
 selftest/target/Samba3.pm                          |  26 +-
 source3/include/ctdbd_conn.h                       |  32 +++
 source3/include/proto.h                            |   6 +
 source3/include/smb_macros.h                       |   5 -
 source3/lib/ctdb_dummy.c                           |  42 +++
 source3/lib/ctdbd_conn.c                           | 261 ++++++++++++++++-
 source3/lib/netapi/joindomain.c                    | 206 +++++++++++++-
 source3/lib/netapi/libnetapi.c                     |  67 +++++
 source3/lib/netapi/libnetapi.h                     |  17 ++
 source3/lib/netapi/netapi.h                        |  43 +++
 source3/lib/system.c                               |   1 +
 source3/librpc/idl/libnetapi.idl                   |  20 ++
 source3/modules/offload_token.c                    |   7 +-
 source3/modules/vfs_acl_common.c                   |   7 +-
 source3/modules/vfs_ceph.c                         |  27 +-
 source3/modules/vfs_default.c                      |   6 +
 source3/modules/vfs_nfs4acl_xattr.c                |   7 +-
 source3/modules/vfs_shadow_copy2.c                 |  30 +-
 source3/passdb/pdb_smbpasswd.c                     |  36 ++-
 source3/printing/printspoolss.c                    |   1 +
 source3/script/tests/test_shadow_copy.sh           |  27 ++
 .../test_smbXsrv_client_ctdb_registered_ips.sh     | 159 +++++++++++
 source3/selftest/tests.py                          |   8 +-
 source3/smbd/dir.c                                 |   5 +-
 source3/smbd/dosmode.c                             |  20 +-
 source3/smbd/file_access.c                         |  10 +-
 source3/smbd/filename.c                            |  87 +++---
 source3/smbd/files.c                               |   3 +
 source3/smbd/notify.c                              |   5 +-
 source3/smbd/open.c                                | 120 ++++----
 source3/smbd/proto.h                               |   4 +-
 source3/smbd/smb1_reply.c                          |  37 ++-
 source3/smbd/smb2_flush.c                          |   7 +-
 source3/smbd/smb2_getinfo.c                        |   8 +-
 source3/smbd/smb2_ioctl_filesys.c                  |   6 +-
 source3/smbd/smb2_ioctl_network_fs.c               |  12 +-
 source3/smbd/smb2_negprot.c                        |   7 +
 source3/smbd/smb2_nttrans.c                        |  45 +--
 source3/smbd/smb2_process.c                        |  33 +++
 source3/smbd/smb2_reply.c                          |  15 +-
 source3/smbd/smb2_trans2.c                         |  80 +++++-
 source3/smbd/smb2_write.c                          |   6 +-
 source3/utils/net_offlinejoin.c                    | 312 ++++++++++++++++++++-
 source3/utils/net_proto.h                          |   2 +
 source4/libcli/raw/rawsetfileinfo.c                |  14 +
 source4/torture/smb2/create.c                      | 245 +++++++++++++++-
 testprogs/blackbox/test_net_offline.sh             |  94 +++++++
 66 files changed, 2335 insertions(+), 372 deletions(-)
 create mode 100755 source3/script/tests/test_smbXsrv_client_ctdb_registered_ips.sh


Changeset truncated at 500 lines:

diff --git a/VERSION b/VERSION
index 9c7625dd758..5c79a0c8dde 100644
--- a/VERSION
+++ b/VERSION
@@ -25,7 +25,7 @@
 ########################################################
 SAMBA_VERSION_MAJOR=4
 SAMBA_VERSION_MINOR=18
-SAMBA_VERSION_RELEASE=9
+SAMBA_VERSION_RELEASE=10
 
 ########################################################
 # If a official release has a serious bug              #
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 3c77ebfd0f6..be2f81f823b 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,3 +1,82 @@
+                   ===============================
+                   Release Notes for Samba 4.18.10
+                          January 31, 2024
+                   ===============================
+
+
+This is the latest stable release of the Samba 4.18 release series.
+
+
+Changes since 4.18.9
+--------------------
+
+o  Ralph Boehme <slow at samba.org>
+   * BUG 13688: Windows 2016 fails to restore previous version of a file from a
+     shadow_copy2 snapshot.
+   * BUG 15549: Symlinks on AIX are broken in 4.19 (and a few version before
+     that).
+
+o  Samuel Cabrero <scabrero at samba.org>
+   * BUG 13577: net changesecretpw cannot set the machine account password if
+     secrets.tdb is empty.
+
+o  Bjoern Jacke <bj at sernet.de>
+   * BUG 12421: Fake directory create times has no effect.
+
+o  Björn Jacke <bjacke at samba.org>
+   * BUG 15540: For generating doc, take, if defined, env XML_CATALOG_FILES.
+   * BUG 15541: Trivial C typo in nsswitch/winbind_nss_netbsd.c.
+   * BUG 15542: vfs_linux_xfs is incorrectly named.
+   * BUG 15550: ctime mixed up with mtime by smbd.
+
+o  Volker Lendecke <vl at samba.org>
+   * BUG 15523: ctdb RELEASE_IP causes a crash in release_ip if a connection to
+     a non-public address disconnects first.
+   * BUG 15544: shadow_copy2 broken when current fileset's directories are
+     removed.
+
+o  Stefan Metzmacher <metze at samba.org>
+   * BUG 15523: ctdb RELEASE_IP causes a crash in release_ip if a connection to
+     a non-public address disconnects first.
+   * BUG 15534: smbd does not detect ctdb public ipv6 addresses for multichannel
+     exclusion.
+
+o  Martin Schwenke <mschwenke at ddn.com>
+   * BUG 15523: ctdb RELEASE_IP causes a crash in release_ip if a connection to
+     a non-public address disconnects first.
+
+o  Shachar Sharon <ssharon at redhat.com>
+   * BUG 15440: Unable to copy and write files from clients to Ceph cluster via
+     SMB Linux gateway with Ceph VFS module.
+
+o  Jones Syue <jonessyue at qnap.com>
+   * BUG 15547: Multichannel refresh network information.
+   * BUG 15555: smbpasswd reset permissions only if not 0600.
+
+
+#######################################
+Reporting bugs & Development Discussion
+#######################################
+
+Please discuss this release on the samba-technical mailing list or by
+joining the #samba-technical:matrix.org matrix room, or
+#samba-technical IRC channel on irc.libera.chat.
+
+If you do report problems then please try to send high quality
+feedback. If you don't provide vital information to help us track down
+the problem then you will probably be ignored.  All bug reports should
+be filed under the Samba 4.1 and newer product in the project's Bugzilla
+database (https://bugzilla.samba.org/).
+
+
+======================================================================
+== Our Code, Our Bugs, Our Responsibility.
+== The Samba Team
+======================================================================
+
+
+Release notes for older releases follow:
+----------------------------------------
                    ==============================
                    Release Notes for Samba 4.18.9
                          November 29, 2023
@@ -117,8 +196,7 @@ database (https://bugzilla.samba.org/).
 ======================================================================
 
 
-Release notes for older releases follow:
-----------------------------------------
+----------------------------------------------------------------------
                    ==============================
                    Release Notes for Samba 4.18.8
                           October 10, 2023
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 17a188f5036..12b1bbcea96 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -1181,7 +1181,7 @@ def SAMBAMANPAGES(bld, manpages, extra_source=None):
     bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
     bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
     bld.env.SAMBA_CATALOG = bld.bldnode.abspath() + '/docs-xml/build/catalog.xml'
-    bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld.env.SAMBA_CATALOG
+    bld.env.SAMBA_CATALOGS = os.getenv('XML_CATALOG_FILES', 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog') + ' file://' + bld.env.SAMBA_CATALOG
 
     for m in manpages.split():
         source = [m + '.xml']
diff --git a/ctdb/common/common.h b/ctdb/common/common.h
index c50b52a5eb5..9a73bec1ac6 100644
--- a/ctdb/common/common.h
+++ b/ctdb/common/common.h
@@ -132,6 +132,7 @@ struct ctdb_rec_data_old *ctdb_marshall_loop_next(
 					TDB_DATA *key, TDB_DATA *data);
 
 void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip);
+void ctdb_canonicalize_ip_inplace(ctdb_sock_addr *ip);
 
 bool ctdb_same_ip(const ctdb_sock_addr *tip1, const ctdb_sock_addr *tip2);
 
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index 3f8fff925f0..5c7731c5d2a 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -388,6 +388,13 @@ void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip)
 	}
 }
 
+void ctdb_canonicalize_ip_inplace(ctdb_sock_addr *ip)
+{
+	ctdb_sock_addr tmp;
+	ctdb_canonicalize_ip(ip, &tmp);
+	memcpy(ip, &tmp, sizeof(tmp));
+}
+
 bool ctdb_same_ip(const ctdb_sock_addr *tip1, const ctdb_sock_addr *tip2)
 {
 	ctdb_sock_addr ip1, ip2;
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 3395f077ab9..80278123778 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -296,7 +296,6 @@ struct ctdb_context {
 	struct ctdb_statistics statistics_history[MAX_STAT_HISTORY];
 	struct ctdb_vnn_map *vnn_map;
 	uint32_t num_clients;
-	struct ctdb_client_ip *client_ip_list;
 	bool do_checkpublicip;
 	bool do_setsched;
 	const char *event_script_dir;
@@ -893,6 +892,12 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses);
 
 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
 				TDB_DATA indata);
+int32_t ctdb_control_tcp_client_disconnected(struct ctdb_context *ctdb,
+					     uint32_t client_id,
+					     TDB_DATA indata);
+int32_t ctdb_control_tcp_client_passed(struct ctdb_context *ctdb,
+				       uint32_t client_id,
+				       TDB_DATA indata);
 int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata,
 			     bool tcp_update_needed);
 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h
index fb6e39f33b5..3b66c403ab8 100644
--- a/ctdb/protocol/protocol.h
+++ b/ctdb/protocol/protocol.h
@@ -381,6 +381,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
 		    CTDB_CONTROL_ECHO_DATA               = 156,
 		    CTDB_CONTROL_DISABLE_NODE            = 157,
 		    CTDB_CONTROL_ENABLE_NODE             = 158,
+		    CTDB_CONTROL_TCP_CLIENT_DISCONNECTED = 159,
+		    CTDB_CONTROL_TCP_CLIENT_PASSED       = 160,
 };
 
 #define MAX_COUNT_BUCKETS 16
diff --git a/ctdb/protocol/protocol_control.c b/ctdb/protocol/protocol_control.c
index a7c797f5dbc..83ed6cb4ee1 100644
--- a/ctdb/protocol/protocol_control.c
+++ b/ctdb/protocol/protocol_control.c
@@ -410,6 +410,14 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
 
 	case CTDB_CONTROL_ENABLE_NODE:
 		break;
+
+	case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED:
+		len = ctdb_connection_len(cd->data.conn);
+		break;
+
+	case CTDB_CONTROL_TCP_CLIENT_PASSED:
+		len = ctdb_connection_len(cd->data.conn);
+		break;
 	}
 
 	return len;
@@ -1016,6 +1024,22 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
 					  &cd->data.echo_data,
 					  &np);
 		break;
+
+	case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED:
+		ret = ctdb_connection_pull(buf,
+					   buflen,
+					   mem_ctx,
+					   &cd->data.conn,
+					   &np);
+		break;
+
+	case CTDB_CONTROL_TCP_CLIENT_PASSED:
+		ret = ctdb_connection_pull(buf,
+					   buflen,
+					   mem_ctx,
+					   &cd->data.conn,
+					   &np);
+		break;
 	}
 
 	if (ret != 0) {
@@ -1376,6 +1400,12 @@ static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd)
 
 	case CTDB_CONTROL_ENABLE_NODE:
 		break;
+
+	case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED:
+		break;
+
+	case CTDB_CONTROL_TCP_CLIENT_PASSED:
+		break;
 	}
 
 	return len;
diff --git a/ctdb/protocol/protocol_debug.c b/ctdb/protocol/protocol_debug.c
index d94cb548d68..ae091b04d32 100644
--- a/ctdb/protocol/protocol_debug.c
+++ b/ctdb/protocol/protocol_debug.c
@@ -245,6 +245,8 @@ static void ctdb_opcode_print(uint32_t opcode, FILE *fp)
 		{ CTDB_CONTROL_ECHO_DATA, "ECHO_DATA" },
 		{ CTDB_CONTROL_DISABLE_NODE, "DISABLE_NODE" },
 		{ CTDB_CONTROL_ENABLE_NODE, "ENABLE_NODE" },
+		{ CTDB_CONTROL_TCP_CLIENT_DISCONNECTED, "TCP_CLIENT_DISCONNECTED" },
+		{ CTDB_CONTROL_TCP_CLIENT_PASSED, "TCP_CLIENT_PASSED" },
 		{ MAP_END, "" },
 	};
 
diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c
index fe757658f48..87ecc87ac36 100644
--- a/ctdb/protocol/protocol_util.c
+++ b/ctdb/protocol/protocol_util.c
@@ -497,6 +497,24 @@ bool ctdb_sock_addr_same(const ctdb_sock_addr *addr1,
 	return (ctdb_sock_addr_cmp(addr1, addr2) == 0);
 }
 
+bool ctdb_connection_same(const struct ctdb_connection *conn1,
+			  const struct ctdb_connection *conn2)
+{
+	bool same;
+
+	same = ctdb_sock_addr_same(&conn1->src, &conn2->src);
+	if (!same) {
+		return false;
+	}
+
+	same = ctdb_sock_addr_same(&conn1->dst, &conn2->dst);
+	if (!same) {
+		return false;
+	}
+
+	return true;
+}
+
 int ctdb_connection_to_buf(char *buf,
 			   size_t buflen,
 			   struct ctdb_connection *conn,
diff --git a/ctdb/protocol/protocol_util.h b/ctdb/protocol/protocol_util.h
index 2bdbb0c2ad0..70f35d122a8 100644
--- a/ctdb/protocol/protocol_util.h
+++ b/ctdb/protocol/protocol_util.h
@@ -55,6 +55,9 @@ bool ctdb_sock_addr_same_ip(const ctdb_sock_addr *addr1,
 bool ctdb_sock_addr_same(const ctdb_sock_addr *addr1,
 			 const ctdb_sock_addr *addr2);
 
+bool ctdb_connection_same(const struct ctdb_connection *conn1,
+			  const struct ctdb_connection *conn2);
+
 int ctdb_connection_to_buf(char *buf,
 			   size_t buflen,
 			   struct ctdb_connection * conn,
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index 08268512bfa..422c4cf1e58 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -868,6 +868,14 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 		CHECK_CONTROL_DATA_SIZE(0);
 		return ctdb_control_enable_node(ctdb);
 
+	case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED:
+		CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_connection));
+		return ctdb_control_tcp_client_disconnected(ctdb, client_id, indata);
+
+	case CTDB_CONTROL_TCP_CLIENT_PASSED:
+		CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_connection));
+		return ctdb_control_tcp_client_passed(ctdb, client_id, indata);
+
 	default:
 		DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
 		return -1;
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index 4d2d0416752..3ecb7382e2a 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -348,20 +348,10 @@ struct ctdb_takeover_arp {
  */
 struct ctdb_tcp_list {
 	struct ctdb_tcp_list *prev, *next;
+	struct ctdb_client *client;
 	struct ctdb_connection connection;
 };
 
-/*
-  list of clients to kill on IP release
- */
-struct ctdb_client_ip {
-	struct ctdb_client_ip *prev, *next;
-	struct ctdb_context *ctdb;
-	ctdb_sock_addr addr;
-	uint32_t client_id;
-};
-
-
 /*
   send a gratuitous arp
  */
@@ -1233,16 +1223,37 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses)
 }
 
 /*
-  destroy a ctdb_client_ip structure
+  destroy a ctdb_tcp_list structure
  */
-static int ctdb_client_ip_destructor(struct ctdb_client_ip *ip)
+static int ctdb_tcp_list_destructor(struct ctdb_tcp_list *tcp)
 {
-	DEBUG(DEBUG_DEBUG,("destroying client tcp for %s:%u (client_id %u)\n",
-		ctdb_addr_to_str(&ip->addr),
-		ntohs(ip->addr.ip.sin_port),
-		ip->client_id));
+	struct ctdb_client *client = tcp->client;
+	struct ctdb_connection *conn = &tcp->connection;
+	char conn_str[132] = { 0, };
+	int ret;
+
+	ret = ctdb_connection_to_buf(conn_str,
+				     sizeof(conn_str),
+				     conn,
+				     false,
+				     " -> ");
+	if (ret != 0) {
+		strlcpy(conn_str, "UNKNOWN", sizeof(conn_str));
+	}
+
+	D_DEBUG("removing client TCP connection %s "
+		"(client_id %u pid %d)\n",
+		conn_str, client->client_id, client->pid);
+
+	DLIST_REMOVE(client->tcp_list, tcp);
+
+	/*
+	 * We don't call ctdb_remove_connection(vnn, conn) here
+	 * as we want the caller to decide if it's called
+	 * directly (local only) or indirectly via a
+	 * CTDB_CONTROL_TCP_REMOVE broadcast
+	 */
 
-	DLIST_REMOVE(ip->ctdb->client_ip_list, ip);
 	return 0;
 }
 
@@ -1259,10 +1270,8 @@ int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
 	struct ctdb_connection t;
 	int ret;
 	TDB_DATA data;
-	struct ctdb_client_ip *ip;
 	struct ctdb_vnn *vnn;
-	ctdb_sock_addr src_addr;
-	ctdb_sock_addr dst_addr;
+	char conn_str[132] = { 0, };
 
 	/* If we don't have public IPs, tickles are useless */
 	if (ctdb->vnn == NULL) {
@@ -1271,75 +1280,44 @@ int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
 
 	tcp_sock = (struct ctdb_connection *)indata.dptr;
 
-	src_addr = tcp_sock->src;
-	ctdb_canonicalize_ip(&src_addr,  &tcp_sock->src);
-	ZERO_STRUCT(src_addr);
-	memcpy(&src_addr, &tcp_sock->src, sizeof(src_addr));
+	ctdb_canonicalize_ip_inplace(&tcp_sock->src);
+	ctdb_canonicalize_ip_inplace(&tcp_sock->dst);
 
-	dst_addr = tcp_sock->dst;
-	ctdb_canonicalize_ip(&dst_addr, &tcp_sock->dst);
-	ZERO_STRUCT(dst_addr);
-	memcpy(&dst_addr, &tcp_sock->dst, sizeof(dst_addr));
+	ret = ctdb_connection_to_buf(conn_str,
+				     sizeof(conn_str),
+				     tcp_sock,
+				     false,
+				     " -> ");
+	if (ret != 0) {
+		strlcpy(conn_str, "UNKNOWN", sizeof(conn_str));
+	}
 
-	vnn = find_public_ip_vnn(ctdb, &dst_addr);
+	vnn = find_public_ip_vnn(ctdb, &tcp_sock->dst);
 	if (vnn == NULL) {
-		char *src_addr_str = NULL;
-		char *dst_addr_str = NULL;
-
-		switch (dst_addr.sa.sa_family) {
-		case AF_INET:
-			if (ntohl(dst_addr.ip.sin_addr.s_addr) == INADDR_LOOPBACK) {
-				/* ignore ... */
-				return 0;
-			}
-			break;
-		case AF_INET6:
-			break;
-		default:
-			DEBUG(DEBUG_ERR,(__location__ " Unknown family type %d\n",
-			      dst_addr.sa.sa_family));
-			return 0;
-		}
-
-		src_addr_str = ctdb_sock_addr_to_string(client, &src_addr, false);
-		dst_addr_str = ctdb_sock_addr_to_string(client, &dst_addr, false);
-		DEBUG(DEBUG_ERR,(
-		      "Could not register TCP connection from "
-		      "%s to %s (not a public address) (port %u) "
-		      "(client_id %u pid %u).\n",
-		      src_addr_str,
-		      dst_addr_str,
-		      ctdb_sock_addr_port(&dst_addr),
-		      client_id, client->pid));
-		TALLOC_FREE(src_addr_str);
-		TALLOC_FREE(dst_addr_str);
+		D_ERR("Could not register TCP connection %s - "
+		      "not a public address (client_id %u pid %u)\n",
+			conn_str, client_id, client->pid);
 		return 0;
 	}
 
 	if (vnn->pnn != ctdb->pnn) {
-		DEBUG(DEBUG_ERR,("Attempt to register tcp client for IP %s we don't hold - failing (client_id %u pid %u)\n",
-			ctdb_addr_to_str(&dst_addr),
-			client_id, client->pid));
+		D_ERR("Attempt to register tcp client for IP %s we don't hold - "
+		      "failing (client_id %u pid %u)\n",
+		      ctdb_addr_to_str(&tcp_sock->dst),
+		      client_id, client->pid);
 		/* failing this call will tell smbd to die */
 		return -1;
 	}
 
-	ip = talloc(client, struct ctdb_client_ip);
-	CTDB_NO_MEMORY(ctdb, ip);
-
-	ip->ctdb      = ctdb;
-	ip->addr      = dst_addr;
-	ip->client_id = client_id;
-	talloc_set_destructor(ip, ctdb_client_ip_destructor);
-	DLIST_ADD(ctdb->client_ip_list, ip);
-
 	tcp = talloc(client, struct ctdb_tcp_list);
 	CTDB_NO_MEMORY(ctdb, tcp);
+	tcp->client = client;
 
 	tcp->connection.src = tcp_sock->src;
 	tcp->connection.dst = tcp_sock->dst;
 
 	DLIST_ADD(client->tcp_list, tcp);
+	talloc_set_destructor(tcp, ctdb_tcp_list_destructor);
 
 	t.src = tcp_sock->src;
 	t.dst = tcp_sock->dst;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list