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

Karolin Seeger kseeger at samba.org
Mon Jan 26 15:06:03 MST 2015


The branch, v4-1-test has been updated
       via  7ef12e4 Revert "dsdb: Add tokenGroupsGlobalAndUniversal, tokenGroups, tokenGroupsNoGCAcceptable"
       via  8d6a64d s3-pam_smbpass: Fix memory leak in pam_sm_authenticate().
       via  553ac4f utils: Fix 'net time' segfault.
       via  8648ebf cli_connect_nb_send: don't segfault on host == NULL.
       via  549d320 vfs_glusterfs: Add comments to the pipe(2) code.
       via  33cef98 vfs: Fix a typo
       via  1e58c87 vfs:glusterfs: whitespace fix.
       via  bff63a0 vfs_glusterfs: Replace eventfd with pipes, for AIO use
       via  478851d vfs/glusterfs: Change xattr key to match gluster key.
       via  be67c85 vfs_glusterfs: Implement AIO support
       via  efa4c88 vfs_glusterfs: Change sys_get_acl_file/fd to return ACLs corresponding to mode bits when there are no ACLs set.
       via  238b052 vfs_glusterfs: Set connectpath as snapdir-entry-path.
       via  7eebeaa vfs_glusterfs: Remember the connect path too for reopening.
       via  95a9146 vfs_glusterfs: In vfs_gluster_sys_acl_get_file/fd, reduce the number of getxattr calls.
       via  f7a9ec5 libsmb: provide authinfo domain for encrypted session referrals
       via  34704a6 libsmb: provide authinfo domain for DFS referral auth
       via  333eac4 libsmb: reuse connections derived from DFS referrals
      from  c4e46cd VERSION: Bump version up to 4.1.17.

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


- Log -----------------------------------------------------------------
commit 7ef12e4e565f3a97aaf888a47be35a173de787bf
Author: Karolin Seeger <kseeger at samba.org>
Date:   Mon Jan 26 20:51:50 2015 +0100

    Revert "dsdb: Add tokenGroupsGlobalAndUniversal, tokenGroups, tokenGroupsNoGCAcceptable"
    
    This reverts commit 333d25739eb5a0d347ff8c57726ea184af4c1ec9.
    
    Autobuild-User(v4-1-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-1-test): Mon Jan 26 23:05:21 CET 2015 on sn-devel-104

commit 8d6a64dc40e7f8107a19f2ec2831b93e9c9d3921
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jan 22 10:27:59 2015 +0100

    s3-pam_smbpass: Fix memory leak in pam_sm_authenticate().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11066
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 0cb9b28acb7008cd30c6de3add9876eb5607a5a6)

commit 553ac4f02de689a711dc2dd3b46c9e5a603dadfa
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jan 13 17:04:26 2015 +0100

    utils: Fix 'net time' segfault.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11058
    
    This is part two of the bugfix. Make sure we pass the IP we found to
    cli_servertime(). Hence we always pass at least one of name or IP.
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 45829800eb3f3a8aeccfe7c1114dcf9df60371d5)

commit 8648ebfec9595cda7275dc62aca5c2ae1a3d4f27
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jan 16 16:18:45 2015 +0100

    cli_connect_nb_send: don't segfault on host == NULL.
    
    The functions called futher down can cope with host == NULL.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11058
    
    This is part one of the bugfix:
    This ensures that it is enough to pass one of host or address to the function.
    
    Pair-Programmed-With: Andreas Schneider <asn at samba.org>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit a0a254f74234bed6c9a0c71a5bda8254fa6f633f)

commit 549d320bd9f2b8d8e380bdb174d5f8e5864f6f63
Author: Ira Cooper <ira at samba.org>
Date:   Thu Jan 22 17:14:31 2015 -0500

    vfs_glusterfs: Add comments to the pipe(2) code.
    
    The guarantees around read(2) and write(2) and pipes are critical
    to understanding this code.  Hopefully these comments will help.
    
    Signed-off-by: Ira Cooper <ira at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Jan 23 20:58:51 CET 2015 on sn-devel-104
    
    (cherry picked from commit 3b2d8bdbb1851961536241d3aaaf6ac936964517)
    
    The last 10 patches address
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11069
    Backport remaining performance patches for vfs_glusterfs to 4.2/4.1.

commit 33cef98dd7c66fac366c65c96c4d590ad593407e
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Jan 21 20:49:24 2015 +0100

    vfs: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Thu Jan 22 13:14:38 CET 2015 on sn-devel-104
    
    (cherry picked from commit db63e4887c81c3e458194004353d7ef92c67b393)

commit 1e58c8788d0323389bd9b919085a387ab91df912
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 22:07:53 2015 +0100

    vfs:glusterfs: whitespace fix.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Jan 22 03:20:17 CET 2015 on sn-devel-104
    
    (cherry picked from commit cde5d380e192487ae77734afcb3eb3d327aafb98)

commit bff63a0321ad4842dfa24e387af3c58daeca5342
Author: Ira Cooper <ira at samba.org>
Date:   Mon Jan 19 23:08:17 2015 -0500

    vfs_glusterfs: Replace eventfd with pipes, for AIO use
    
    Pipes clean up the AIO implementation substantially, due to the fact
    that they implement a natural ithread safe queue instead of us
    creating our own queue.
    
    Signed-off-by: Ira Cooper <ira at samba.org>
    Signed-off-by: Poornima G <pgurusid at redhat.com>
    Reviewed-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Ira Cooper <ira at samba.org>
    Autobuild-Date(master): Wed Jan 21 20:40:11 CET 2015 on sn-devel-104
    
    (cherry picked from commit 4c3a3d9e6adc95d0f0e1f6030b2406613d9f9f53)

commit 478851de95be1bbfc54c087ff51055e20515577c
Author: raghavendra talur <raghavendra.talur at gmail.com>
Date:   Wed Dec 10 21:15:03 2014 +0530

    vfs/glusterfs: Change xattr key to match gluster key.
    
    Gluster changed the key used to do get_real_filename
    in 3.5. This changes Samba's glusterfs vfs-module
    to use the same key.
    
    This will render SMB_VFS_GET_REALFILENAME() working
    again under 3.5 and will remove support for that functionality
    for Gluster 3.4 and older.
    
    Signed-off-by: raghavendra talur <raghavendra.talur at gmail.com>
    Reviewed-by: Ira Cooper <ira at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit af9ec9fea5a730023cdee6e236f9585e3a18b0e6)

commit be67c85974037b796a39dba6433f36bcfe04656a
Author: Poornima G <pgurusid at redhat.com>
Date:   Thu Dec 11 07:35:10 2014 +0530

    vfs_glusterfs: Implement AIO support
    
    Signed-off-by: Poornima G <pgurusid at redhat.com>
    
    Reviewed-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Wed Dec 17 16:35:37 CET 2014 on sn-devel-104
    
    (cherry picked from commit 051b81aac81c7ccb234da221e9f8272b70b265ce)

commit efa4c88d8b88b78ed40e6102f6875698e90f4db3
Author: Poornima G <pgurusid at redhat.com>
Date:   Fri Dec 12 14:11:49 2014 +0100

    vfs_glusterfs: Change sys_get_acl_file/fd to return ACLs corresponding to mode bits when there are no ACLs set.
    
    Signed-off-by: Poornima G <pgurusid at redhat.com>
    
    Reviewed-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 26b3544251babdfcdf5ada338a4ed39ff18bc47a)

commit 238b052fc9ca9e30a88403404c0f4016db4ad0da
Author: raghavendra talur <raghavendra.talur at gmail.com>
Date:   Wed Dec 10 12:30:10 2014 +0530

    vfs_glusterfs: Set connectpath as snapdir-entry-path.
    
    snapview client in gluster would require connectpath
    in order add snapdir entry to readdir result.
    
    Signed-off-by: raghavendra talur <raghavendra.talur at gmail.com>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Wed Dec 10 16:38:27 CET 2014 on sn-devel-104
    
    (cherry picked from commit a12ae815b01b372cbf8697d32d5d45d7b2d5f93d)

commit 7eebeaa568249f45676df12122315a8b0f7f1814
Author: raghavendra talur <raghavendra.talur at gmail.com>
Date:   Wed Dec 10 12:26:34 2014 +0530

    vfs_glusterfs: Remember the connect path too for reopening.
    
    As Samba allows us to share subdirs, lets re-use preopened
    connections to glusterfs only if they are for same volume
    AND same connectpath.
    
    Signed-off-by: raghavendra talur <raghavendra.talur at gmail.com>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 2fb4317352a165d0dd4af78fcf0a576fa246eab2)

commit 95a9146ce54d2adf41283ee8fe16a4f49caef13a
Author: Poornima G <pgurusid at redhat.com>
Date:   Thu Oct 30 17:14:51 2014 +0530

    vfs_glusterfs: In vfs_gluster_sys_acl_get_file/fd, reduce the number of getxattr calls.
    
    Signed-off-by: Poornima G <pgurusid at redhat.com>
    Reviewed-by: Ira Cooper <ira at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit a4fa9ca5a7a4c0b770079ab126f8172ff6d6851c)

commit f7a9ec5ffd9c9e45891c46eece31b5ba4cf62ae4
Author: David Disseldorp <ddiss at samba.org>
Date:   Mon Jan 19 13:39:35 2015 +0100

    libsmb: provide authinfo domain for encrypted session referrals
    
    6c9de0cd056afc0b478c02f1bdb0e06532388037 requires this extra change.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11059
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Jan 21 04:29:06 CET 2015 on sn-devel-104
    
    (cherry picked from commit 6da86012a2ca521efe0cf1bf05fcd04c3099b190)

commit 34704a62ecb90db456eb330baacdfe24ea24853c
Author: David Disseldorp <ddiss at samba.org>
Date:   Fri Jan 16 16:21:23 2015 +0100

    libsmb: provide authinfo domain for DFS referral auth
    
    libsmbclient uses the smbc_init->smbc_get_auth_data_fn() provided
    workgroup/domain in initial connections, but then switches to the
    default smb.conf workgroup/domain when handling DFS referrals.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11059
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6c9de0cd056afc0b478c02f1bdb0e06532388037)
    [ddiss at samba.org: 4.1 rebase with cli_init_creds() call]

commit 333eac480adfba5e7023d1461734baf99c820e54
Author: David Disseldorp <ddiss at samba.org>
Date:   Fri Jan 16 16:21:22 2015 +0100

    libsmb: reuse connections derived from DFS referrals
    
    [MS-DFSC] 3.2.1.1 and 3.2.1.2 states that DFS targets with the same site
    location or relative cost are placed in random order in a DFS referral
    response.
    
    libsmbclient currently resolves DFS referrals on every API call, always
    using the first entry in the referral response. With random ordering,
    libsmbclient may open a new server connection, rather than reuse an
    existing (cached) connection established in a previous DFS referred API
    call.
    
    This change sees libsmbclient check the connection cache for any of the
    DFS referral response entries before creating a new connection.
    
    This change is based on a patch by Har Gagan Sahai
    <SHarGagan at novell.com>.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10123
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 7b7d4f740fe5017107d3100041cc8c7982f0eac7)

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

Summary of changes:
 source3/libsmb/cliconnect.c                  |  22 +-
 source3/libsmb/clidfs.c                      | 118 ++++++---
 source3/modules/vfs_glusterfs.c              | 365 ++++++++++++++++++++++++---
 source3/pam_smbpass/pam_smb_auth.c           |  11 +-
 source3/utils/net_time.c                     |  21 +-
 source4/dsdb/samdb/ldb_modules/operational.c |  66 +----
 source4/dsdb/tests/python/token_group.py     | 347 +------------------------
 7 files changed, 470 insertions(+), 480 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 13e7704..5255e8a 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -2995,21 +2995,29 @@ static struct tevent_req *cli_connect_nb_send(
 {
 	struct tevent_req *req, *subreq;
 	struct cli_connect_nb_state *state;
-	char *p;
 
 	req = tevent_req_create(mem_ctx, &state, struct cli_connect_nb_state);
 	if (req == NULL) {
 		return NULL;
 	}
-	state->desthost = host;
 	state->signing_state = signing_state;
 	state->flags = flags;
 
-	p = strchr(host, '#');
-	if (p != NULL) {
-		name_type = strtol(p+1, NULL, 16);
-		host = talloc_strndup(state, host, p - host);
-		if (tevent_req_nomem(host, req)) {
+	if (host != NULL) {
+		char *p = strchr(host, '#');
+
+		if (p != NULL) {
+			name_type = strtol(p+1, NULL, 16);
+			host = talloc_strndup(state, host, p - host);
+			if (tevent_req_nomem(host, req)) {
+				return tevent_req_post(req, ev);
+			}
+		}
+
+		state->desthost = host;
+	} else {
+		state->desthost = print_canonical_sockaddr(state, dest_ss);
+		if (tevent_req_nomem(state->desthost, req)) {
 			return tevent_req_post(req, ev);
 		}
 	}
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index 840084f..729f4fe 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -111,6 +111,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 	char *newserver, *newshare;
 	const char *username;
 	const char *password;
+	const char *domain;
 	NTSTATUS status;
 	int flags = 0;
 
@@ -184,11 +185,15 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 
 	username = get_cmdline_auth_info_username(auth_info);
 	password = get_cmdline_auth_info_password(auth_info);
+	domain = get_cmdline_auth_info_domain(auth_info);
+	if ((domain == NULL) || (domain[0] == '\0')) {
+		domain = lp_workgroup();
+	}
 
 	status = cli_session_setup(c, username,
 				   password, strlen(password),
 				   password, strlen(password),
-				   lp_workgroup());
+				   domain);
 	if (!NT_STATUS_IS_OK(status)) {
 		/* If a password was not supplied then
 		 * try again with a null username. */
@@ -209,7 +214,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 		d_printf("Anonymous login successful\n");
 		status = cli_init_creds(c, "", lp_workgroup(), "");
 	} else {
-		status = cli_init_creds(c, username, lp_workgroup(), password);
+		status = cli_init_creds(c, username, domain, password);
 	}
 
 	if (!NT_STATUS_IS_OK(status)) {
@@ -240,7 +245,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 				force_encrypt,
 				username,
 				password,
-				lp_workgroup())) {
+				domain)) {
 		cli_shutdown(c);
 		return do_connect(ctx, newserver,
 				newshare, auth_info, false,
@@ -262,7 +267,7 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 		status = cli_cm_force_encryption(c,
 					username,
 					password,
-					lp_workgroup(),
+					domain,
 					sharename);
 		if (!NT_STATUS_IS_OK(status)) {
 			cli_shutdown(c);
@@ -837,6 +842,11 @@ NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
 
 /********************************************************************
 ********************************************************************/
+struct cli_dfs_path_split {
+	char *server;
+	char *share;
+	char *extrapath;
+};
 
 NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 			  const char *mountpt,
@@ -854,9 +864,9 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 	char *cleanpath = NULL;
 	char *extrapath = NULL;
 	int pathlen;
-	char *server = NULL;
-	char *share = NULL;
 	struct cli_state *newcli = NULL;
+	struct cli_state *ccli = NULL;
+	int count = 0;
 	char *newpath = NULL;
 	char *newmount = NULL;
 	char *ppath = NULL;
@@ -865,6 +875,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 	NTSTATUS status;
 	struct smbXcli_tcon *root_tcon = NULL;
 	struct smbXcli_tcon *target_tcon = NULL;
+	struct cli_dfs_path_split *dfs_refs = NULL;
 
 	if ( !rootcli || !path || !targetcli ) {
 		return NT_STATUS_INVALID_PARAMETER;
@@ -954,26 +965,83 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 		return status;
 	}
 
-	/* Just store the first referral for now. */
-
 	if (!refs[0].dfspath) {
 		return NT_STATUS_NOT_FOUND;
 	}
-	if (!split_dfs_path(ctx, refs[0].dfspath, &server, &share,
-			    &extrapath)) {
-		return NT_STATUS_NOT_FOUND;
+
+	/*
+	 * Bug#10123 - DFS referal entries can be provided in a random order,
+	 * so check the connection cache for each item to avoid unnecessary
+	 * reconnections.
+	 */
+	dfs_refs = talloc_array(ctx, struct cli_dfs_path_split, num_refs);
+	if (dfs_refs == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	for (count = 0; count < num_refs; count++) {
+		if (!split_dfs_path(dfs_refs, refs[count].dfspath,
+				    &dfs_refs[count].server,
+				    &dfs_refs[count].share,
+				    &dfs_refs[count].extrapath)) {
+			TALLOC_FREE(dfs_refs);
+			return NT_STATUS_NOT_FOUND;
+		}
+
+		ccli = cli_cm_find(rootcli, dfs_refs[count].server,
+				   dfs_refs[count].share);
+		if (ccli != NULL) {
+			extrapath = dfs_refs[count].extrapath;
+			*targetcli = ccli;
+			break;
+		}
+	}
+
+	/*
+	 * If no cached connection was found, then connect to the first live
+	 * referral server in the list.
+	 */
+	for (count = 0; (ccli == NULL) && (count < num_refs); count++) {
+		/* Connect to the target server & share */
+		status = cli_cm_connect(ctx, rootcli,
+				dfs_refs[count].server,
+				dfs_refs[count].share,
+				dfs_auth_info,
+				false,
+				smb1cli_conn_encryption_on(rootcli->conn),
+				smbXcli_conn_protocol(rootcli->conn),
+				0,
+				0x20,
+				targetcli);
+		if (!NT_STATUS_IS_OK(status)) {
+			d_printf("Unable to follow dfs referral [\\%s\\%s]\n",
+				 dfs_refs[count].server,
+				 dfs_refs[count].share);
+			continue;
+		} else {
+			extrapath = dfs_refs[count].extrapath;
+			break;
+		}
+	}
+
+	/* No available referral server for the connection */
+	if (*targetcli == NULL) {
+		TALLOC_FREE(dfs_refs);
+		return status;
 	}
 
 	/* Make sure to recreate the original string including any wildcards. */
 
 	dfs_path = cli_dfs_make_full_path(ctx, rootcli, path);
 	if (!dfs_path) {
+		TALLOC_FREE(dfs_refs);
 		return NT_STATUS_NO_MEMORY;
 	}
 	pathlen = strlen(dfs_path);
 	consumed = MIN(pathlen, consumed);
 	*pp_targetpath = talloc_strdup(ctx, &dfs_path[consumed]);
 	if (!*pp_targetpath) {
+		TALLOC_FREE(dfs_refs);
 		return NT_STATUS_NO_MEMORY;
 	}
 	dfs_path[consumed] = '\0';
@@ -984,23 +1052,6 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 	 * (in \server\share\path format).
  	 */
 
-	/* Open the connection to the target server & share */
-	status = cli_cm_open(ctx, rootcli,
-			     server,
-			     share,
-			     dfs_auth_info,
-			     false,
-			     smb1cli_conn_encryption_on(rootcli->conn),
-			     smbXcli_conn_protocol(rootcli->conn),
-			     0,
-			     0x20,
-			     targetcli);
-	if (!NT_STATUS_IS_OK(status)) {
-		d_printf("Unable to follow dfs referral [\\%s\\%s]\n",
-			server, share );
-		return status;
-	}
-
 	if (extrapath && strlen(extrapath) > 0) {
 		/* EMC Celerra NAS version 5.6.50 (at least) doesn't appear to */
 		/* put the trailing \ on the path, so to be save we put one in if needed */
@@ -1016,6 +1067,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 						  *pp_targetpath);
 		}
 		if (!*pp_targetpath) {
+			TALLOC_FREE(dfs_refs);
 			return NT_STATUS_NO_MEMORY;
 		}
 	}
@@ -1029,18 +1081,21 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 		d_printf("cli_resolve_path: "
 			"dfs_path (%s) not in correct format.\n",
 			dfs_path );
+		TALLOC_FREE(dfs_refs);
 		return NT_STATUS_NOT_FOUND;
 	}
 
 	ppath++; /* Now pointing at start of server name. */
 
 	if ((ppath = strchr_m( dfs_path, '\\' )) == NULL) {
+		TALLOC_FREE(dfs_refs);
 		return NT_STATUS_NOT_FOUND;
 	}
 
 	ppath++; /* Now pointing at start of share name. */
 
 	if ((ppath = strchr_m( ppath+1, '\\' )) == NULL) {
+		TALLOC_FREE(dfs_refs);
 		return NT_STATUS_NOT_FOUND;
 	}
 
@@ -1048,6 +1103,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 
 	newmount = talloc_asprintf(ctx, "%s\\%s", mountpt, ppath );
 	if (!newmount) {
+		TALLOC_FREE(dfs_refs);
 		return NT_STATUS_NOT_FOUND;
 	}
 
@@ -1072,6 +1128,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
  			 */
 			*targetcli = newcli;
 			*pp_targetpath = newpath;
+			TALLOC_FREE(dfs_refs);
 			return status;
 		}
 	}
@@ -1088,14 +1145,17 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx,
 	if (smbXcli_tcon_is_dfs_share(target_tcon)) {
 		dfs_path = talloc_strdup(ctx, *pp_targetpath);
 		if (!dfs_path) {
+			TALLOC_FREE(dfs_refs);
 			return NT_STATUS_NO_MEMORY;
 		}
 		*pp_targetpath = cli_dfs_make_full_path(ctx, *targetcli, dfs_path);
 		if (*pp_targetpath == NULL) {
+			TALLOC_FREE(dfs_refs);
 			return NT_STATUS_NO_MEMORY;
 		}
 	}
 
+	TALLOC_FREE(dfs_refs);
 	return NT_STATUS_OK;
 }
 
@@ -1152,7 +1212,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 		status = cli_cm_force_encryption(cli,
 					username,
 					password,
-					lp_workgroup(),
+					domain,
 					"IPC$");
 		if (!NT_STATUS_IS_OK(status)) {
 			return false;
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index ba2d8e8..cfdd195 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -26,8 +26,6 @@
  * @brief  Samba VFS module for glusterfs
  *
  * @todo
- *   - AIO support\n
- *     See, for example \c vfs_aio_linux.c in the \c sourc3/modules directory
  *   - sendfile/recvfile support
  *
  * A Samba VFS module for GlusterFS, based on Gluster's libgfapi.
@@ -42,9 +40,16 @@
 #include <stdio.h>
 #include "api/glfs.h"
 #include "lib/util/dlinklist.h"
+#include "lib/util/tevent_unix.h"
+#include "lib/tevent/tevent_internal.h"
+#include "smbd/globals.h"
 
 #define DEFAULT_VOLFILE_SERVER "localhost"
 
+static int read_fd = -1;
+static int write_fd = -1;
+static struct tevent_fd *aio_read_event = NULL;
+
 /**
  * Helper to convert struct stat to struct stat_ex.
  */
@@ -78,13 +83,14 @@ static void smb_stat_ex_from_stat(struct stat_ex *dst, const struct stat *src)
 
 static struct glfs_preopened {
 	char *volume;
+	char *connectpath;
 	glfs_t *fs;
 	int ref;
 	struct glfs_preopened *next, *prev;
 } *glfs_preopened;
 
 
-static int glfs_set_preopened(const char *volume, glfs_t *fs)
+static int glfs_set_preopened(const char *volume, const char *connectpath, glfs_t *fs)
 {
 	struct glfs_preopened *entry = NULL;
 
@@ -101,6 +107,13 @@ static int glfs_set_preopened(const char *volume, glfs_t *fs)
 		return -1;
 	}
 
+	entry->connectpath = talloc_strdup(entry, connectpath);
+	if (entry->connectpath == NULL) {
+		talloc_free(entry);
+		errno = ENOMEM;
+		return -1;
+	}
+
 	entry->fs = fs;
 	entry->ref = 1;
 
@@ -109,12 +122,14 @@ static int glfs_set_preopened(const char *volume, glfs_t *fs)
 	return 0;
 }
 
-static glfs_t *glfs_find_preopened(const char *volume)
+static glfs_t *glfs_find_preopened(const char *volume, const char *connectpath)
 {
 	struct glfs_preopened *entry = NULL;
 
 	for (entry = glfs_preopened; entry; entry = entry->next) {
-		if (strcmp(entry->volume, volume) == 0) {
+		if (strcmp(entry->volume, volume) == 0 &&
+		    strcmp(entry->connectpath, connectpath) == 0)
+		{
 			entry->ref++;
 			return entry->fs;
 		}
@@ -176,7 +191,7 @@ static int vfs_gluster_connect(struct vfs_handle_struct *handle,
 		volume = service;
 	}
 
-	fs = glfs_find_preopened(volume);
+	fs = glfs_find_preopened(volume, handle->conn->connectpath);
 	if (fs) {
 		goto done;
 	}
@@ -200,6 +215,17 @@ static int vfs_gluster_connect(struct vfs_handle_struct *handle,
 		goto done;
 	}
 
+
+	ret = glfs_set_xlator_option(fs, "*-snapview-client",
+				     "snapdir-entry-path",
+				     handle->conn->connectpath);
+	if (ret < 0) {
+		DEBUG(0, ("%s: Failed to set xlator option:"
+			  " snapdir-entry-path\n", volume));
+		glfs_fini(fs);
+		return -1;
+	}
+
 	ret = glfs_set_logging(fs, logfile, loglevel);
 	if (ret < 0) {
 		DEBUG(0, ("%s: Failed to set logfile %s loglevel %d\n",
@@ -214,7 +240,7 @@ static int vfs_gluster_connect(struct vfs_handle_struct *handle,
 		goto done;
 	}
 
-	ret = glfs_set_preopened(volume, fs);
+	ret = glfs_set_preopened(volume, handle->conn->connectpath, fs);
 	if (ret < 0) {
 		DEBUG(0, ("%s: Failed to register volume (%s)\n",
 			  volume, strerror(errno)));
@@ -461,20 +487,157 @@ static ssize_t vfs_gluster_pread(struct vfs_handle_struct *handle,
 	return glfs_pread(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, offset, 0);
 }
 
+struct glusterfs_aio_state {
+	ssize_t ret;
+	int err;
+};
+
+/*
+ * This function is the callback that will be called on glusterfs
+ * threads once the async IO submitted is complete. To notify
+ * Samba of the completion we use a pipe based queue.
+ */
+static void aio_glusterfs_done(glfs_fd_t *fd, ssize_t ret, void *data)
+{
+	struct tevent_req *req = NULL;
+	struct glusterfs_aio_state *state = NULL;
+	int sts = 0;
+
+	req = talloc_get_type_abort(data, struct tevent_req);
+	state = tevent_req_data(req, struct glusterfs_aio_state);
+
+	if (ret < 0) {
+		state->ret = -1;
+		state->err = errno;
+	} else {
+		state->ret = ret;
+		state->err = 0;
+	}
+
+	/*
+	 * Write the pointer to each req that needs to be completed
+	 * by calling tevent_req_done(). tevent_req_done() cannot
+	 * be called here, as it is not designed to be executed
+	 * in the multithread environment, tevent_req_done() must be
+	 * executed from the smbd main thread.
+	 *
+	 * write(2) on pipes with sizes under _POSIX_PIPE_BUF
+	 * in size is atomic, without this, the use op pipes in this
+	 * code would not work.
+	 *
+	 * sys_write is a thin enough wrapper around write(2)
+	 * that we can trust it here.
+	 */
+
+	sts = sys_write(write_fd, &req, sizeof(struct tevent_req *));
+	if (sts < 0) {
+		DEBUG(0,("\nWrite to pipe failed (%s)", strerror(errno)));
+	}
+
+	return;
+}
+
+/*
+ * Read each req off the pipe and process it.
+ */
+static void aio_tevent_fd_done(struct tevent_context *event_ctx,
+				struct tevent_fd *fde,
+				uint16 flags, void *data)
+{
+	struct tevent_req *req = NULL;
+	int sts = 0;
+
+	/*
+	 * read(2) on pipes is atomic if the needed data is available
+	 * in the pipe, per SUS and POSIX.  Because we always write
+	 * to the pipe in sizeof(struct tevent_req *) chunks, we can
+	 * always read in those chunks, atomically.
+	 *
+	 * sys_read is a thin enough wrapper around read(2) that we
+	 * can trust it here.


-- 
Samba Shared Repository


More information about the samba-cvs mailing list