[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Apr 13 19:43:11 MDT 2010


The branch, master has been updated
       via  a1e0e1c... Add basic DFS tests.
       via  f3b8e31... Split out the client unix capabilities to those the server offered, and those the client asked for.
      from  589a42e... s4:auth Change auth_generate_session_info to take an auth context

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


- Log -----------------------------------------------------------------
commit a1e0e1cbcfefa513982f8351fb8b13fbd61c2d54
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 13 18:42:24 2010 -0700

    Add basic DFS tests.
    
    Jeremy.

commit f3b8e31f83c44f1e72b15711542d817af7ec9506
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 13 18:41:14 2010 -0700

    Split out the client unix capabilities to those the server offered, and those the client asked for.
    
    This fixes a bug when using encrypted transport and DFS links. Found
    by my basic DFS torture test, which I'll check in next. Testing *rocks* :-).
    
    Jeremy.

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

Summary of changes:
 source3/client/client.c                   |    2 +-
 source3/include/client.h                  |    5 ++-
 source3/libsmb/clidfs.c                   |    4 +-
 source3/libsmb/clifsinfo.c                |   18 ++++++-
 source3/libsmb/clireadwrite.c             |    4 +-
 source3/script/tests/selftest.sh          |   18 +++++++
 source3/script/tests/test_smbclient_s3.sh |   74 +++++++++++++++++++++++++++++
 7 files changed, 116 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index 7dc412f..1361715 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -332,7 +332,7 @@ static int cmd_pwd(void)
 
 static void normalize_name(char *newdir)
 {
-	if (!(cli->posix_capabilities & CIFS_UNIX_POSIX_PATHNAMES_CAP)) {
+	if (!(cli->requested_posix_capabilities & CIFS_UNIX_POSIX_PATHNAMES_CAP)) {
 		string_replace(newdir,'/','\\');
 	}
 }
diff --git a/source3/include/client.h b/source3/include/client.h
index 457c02a..71232b3 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -248,7 +248,10 @@ struct cli_state {
 	int win95;
 	bool is_samba;
 	uint32 capabilities;
-	uint32 posix_capabilities;
+	/* What the server offered. */
+	uint32_t server_posix_capabilities;
+	/* What the client requested. */
+	uint32_t requested_posix_capabilities;
 	bool dfsroot;
 
 #if 0
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index d5ae11f..345d0f9 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -320,7 +320,7 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
 		DLIST_ADD_END(referring_cli, cli, struct cli_state *);
 	}
 
-	if (referring_cli && referring_cli->posix_capabilities) {
+	if (referring_cli && referring_cli->requested_posix_capabilities) {
 		uint16 major, minor;
 		uint32 caplow, caphigh;
 		NTSTATUS status;
@@ -564,7 +564,7 @@ static char *cli_dfs_make_full_path(TALLOC_CTX *ctx,
 		dir++;
 	}
 
-	if (cli->posix_capabilities & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
+	if (cli->requested_posix_capabilities & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
 		path_sep = '/';
 	}
 	return talloc_asprintf(ctx, "%c%s%c%s%c%s",
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
index 3297ec7..b8430a5 100644
--- a/source3/libsmb/clifsinfo.c
+++ b/source3/libsmb/clifsinfo.c
@@ -27,6 +27,7 @@
 ****************************************************************************/
 
 struct cli_unix_extensions_version_state {
+	struct cli_state *cli;
 	uint16_t setup[1];
 	uint8_t param[2];
 	uint16_t major, minor;
@@ -47,6 +48,7 @@ struct tevent_req *cli_unix_extensions_version_send(TALLOC_CTX *mem_ctx,
 	if (req == NULL) {
 		return NULL;
 	}
+	state->cli = cli;
 	SSVAL(state->setup, 0, TRANSACT2_QFSINFO);
 	SSVAL(state->param, 0, SMB_QUERY_CIFS_UNIX_INFO);
 
@@ -104,6 +106,7 @@ NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
 	*pminor = state->minor;
 	*pcaplow = state->caplow;
 	*pcaphigh = state->caphigh;
+	state->cli->server_posix_capabilities = *pcaplow;
 	return NT_STATUS_OK;
 }
 
@@ -143,9 +146,6 @@ NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
 
 	status = cli_unix_extensions_version_recv(req, pmajor, pminor, pcaplow,
 						  pcaphigh);
-	if (NT_STATUS_IS_OK(status)) {
-		cli->posix_capabilities = *pcaplow;
-	}
  fail:
 	TALLOC_FREE(frame);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -159,6 +159,7 @@ NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
 ****************************************************************************/
 
 struct cli_set_unix_extensions_capabilities_state {
+	struct cli_state *cli;
 	uint16_t setup[1];
 	uint8_t param[4];
 	uint8_t data[12];
@@ -181,6 +182,7 @@ struct tevent_req *cli_set_unix_extensions_capabilities_send(
 		return NULL;
 	}
 
+	state->cli = cli;
 	SSVAL(state->setup+0, 0, TRANSACT2_SETFSINFO);
 
 	SSVAL(state->param, 0, 0);
@@ -207,8 +209,16 @@ struct tevent_req *cli_set_unix_extensions_capabilities_send(
 static void cli_set_unix_extensions_capabilities_done(
 	struct tevent_req *subreq)
 {
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct cli_set_unix_extensions_capabilities_state *state = tevent_req_data(
+		req, struct cli_set_unix_extensions_capabilities_state);
+
 	NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, 0, NULL,
 					 NULL, 0, NULL, NULL, 0, NULL);
+	if (NT_STATUS_IS_OK(status)) {
+		state->cli->requested_posix_capabilities = IVAL(state->data, 4);
+	}
 	tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
@@ -245,6 +255,8 @@ fail:
 	TALLOC_FREE(ev);
 	if (!NT_STATUS_IS_OK(status)) {
 		cli_set_error(cli, status);
+	} else {
+		cli->requested_posix_capabilities = caplow;
 	}
 	return status;
 }
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 7b688d4..e9a9e0e 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -25,7 +25,7 @@
 static size_t cli_read_max_bufsize(struct cli_state *cli)
 {
 	if (!client_is_signing_on(cli) && !cli_encryption_on(cli)
-	    && (cli->posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) {
+	    && (cli->server_posix_capabilities & CIFS_UNIX_LARGE_READ_CAP)) {
 		return CLI_SAMBA_MAX_POSIX_LARGE_READX_SIZE;
 	}
 	if (cli->capabilities & CAP_LARGE_READX) {
@@ -44,7 +44,7 @@ static size_t cli_write_max_bufsize(struct cli_state *cli, uint16_t write_mode)
         if (write_mode == 0 &&
 	    !client_is_signing_on(cli) &&
 	    !cli_encryption_on(cli) &&
-	    (cli->posix_capabilities & CIFS_UNIX_LARGE_WRITE_CAP) &&
+	    (cli->server_posix_capabilities & CIFS_UNIX_LARGE_WRITE_CAP) &&
 	    (cli->capabilities & CAP_LARGE_FILES)) {
 		/* Only do massive writes if we can do them direct
 		 * with no signing or encrypting - not on a pipe. */
diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh
index a13877d..2248ecf 100755
--- a/source3/script/tests/selftest.sh
+++ b/source3/script/tests/selftest.sh
@@ -190,6 +190,20 @@ mkdir -p $RO_SHRDIR
 chmod 755 $RO_SHRDIR
 touch $RO_SHRDIR/unreadable_file
 chmod 600 $RO_SHRDIR/unreadable_file
+##
+## Create an MS-DFS root share.
+##
+MSDFS_SHRDIR=`echo $SHRDIR | sed -e 's:/[^/]*$::'`
+MSDFS_SHRDIR=$MSDFS_SHRDIR/msdfsshare
+mkdir -p $MSDFS_SHRDIR
+chmod 777 $MSDFS_SHRDIR
+mkdir -p $MSDFS_SHRDIR/deeppath
+chmod 777 $MSDFS_SHRDIR/deeppath
+## Create something visible in the target.
+touch $RO_SHRDIR/msdfs-target
+chmod 666 $RO_SHRDIR/msdfs-target
+ln -s msdfs:$SERVER_IP\\ro-tmp $MSDFS_SHRDIR/msdfs-src1
+ln -s msdfs:$SERVER_IP\\ro-tmp $MSDFS_SHRDIR/deeppath/msdfs-src2
 
 ##
 ## Create the common config include file with the basic settings
@@ -325,6 +339,10 @@ cat >$SERVERCONFFILE<<EOF
 [ro-tmp]
 	path = $RO_SHRDIR
 	guest ok = yes
+[msdfs-share]
+	path = $MSDFS_SHRDIR
+	msdfs root = yes
+	guest ok = yes
 [hideunread]
 	copy = tmp
 	hide unreadable = yes
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index dc9853d..965e275 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -291,6 +291,76 @@ EOF
     fi
 }
 
+# Test accessing an msdfs path.
+test_msdfs_link()
+{
+    tmpfile=/tmp/smbclient.in.$$
+    prompt="  msdfs-target  "
+
+    cat > $tmpfile <<EOF
+ls
+cd \\msdfs-src1
+ls msdfs-target
+quit
+EOF
+
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    rm -f $tmpfile
+
+    if [ $ret != 0 ] ; then
+	echo "$out"
+	echo "failed accessing \\msdfs-src1 link with error $ret"
+	false
+	return
+    fi
+
+    echo "$out" | grep "$prompt" >/dev/null 2>&1
+
+    ret=$?
+    if [ $ret != 0 ] ; then
+	echo "$out"
+	echo "failed listing \\msdfs-src1 - grep failed with $ret"
+	false
+    fi
+
+    cat > $tmpfile <<EOF
+ls
+cd \\deeppath\\msdfs-src2
+ls msdfs-target
+quit
+EOF
+
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    rm -f $tmpfile
+
+    if [ $ret != 0 ] ; then
+	echo "$out"
+	echo "failed accessing \\deeppath\\msdfs-src2 link with error $ret"
+	false
+	return
+    fi
+
+    echo "$out" | grep "$prompt" >/dev/null 2>&1
+
+    ret=$?
+    if [ $ret != 0 ] ; then
+	echo "$out"
+	echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret"
+	false
+	return
+    else
+	true
+	return
+    fi
+}
+
+
 testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
 
@@ -326,4 +396,8 @@ testit "Reading a owner-only file fails" \
    test_owner_only_file || \
    failed=`expr $failed + 1`
 
+testit "Accessing an MS-DFS link" \
+   test_msdfs_link || \
+   failed=`expr $failed + 1`
+
 testok $0 $failed


-- 
Samba Shared Repository


More information about the samba-cvs mailing list