svn commit: samba r21668 - in branches/SAMBA_4_0/source: auth/credentials libcli/raw torture/rpc torture/unix

jpeach at samba.org jpeach at samba.org
Fri Mar 2 23:24:28 GMT 2007


Author: jpeach
Date: 2007-03-02 23:24:27 +0000 (Fri, 02 Mar 2007)
New Revision: 21668

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21668

Log:
Add SMB_QFS_POSIX_WHOAMI to trans2.h so it's easy to find. Add
convenience API to create an anonymous credential. Don't clobber
cmdline_credentials in the UNIX-WHOAMI test.

Modified:
   branches/SAMBA_4_0/source/auth/credentials/credentials.c
   branches/SAMBA_4_0/source/libcli/raw/trans2.h
   branches/SAMBA_4_0/source/torture/rpc/srvsvc.c
   branches/SAMBA_4_0/source/torture/unix/whoami.c


Changeset:
Modified: branches/SAMBA_4_0/source/auth/credentials/credentials.c
===================================================================
--- branches/SAMBA_4_0/source/auth/credentials/credentials.c	2007-03-02 23:06:53 UTC (rev 21667)
+++ branches/SAMBA_4_0/source/auth/credentials/credentials.c	2007-03-02 23:24:27 UTC (rev 21668)
@@ -68,6 +68,21 @@
 	return cred;
 }
 
+/**
+ * Create a new anonymous credential
+ * @param mem_ctx TALLOC_CTX parent for credentials structure 
+ */
+struct cli_credentials *cli_credentials_init_anon(TALLOC_CTX *mem_ctx) 
+{
+	struct cli_credentials *anon_credentials;
+
+	anon_credentials = cli_credentials_init(mem_ctx);
+	cli_credentials_set_conf(anon_credentials);
+	cli_credentials_set_anonymous(anon_credentials);
+
+	return anon_credentials;
+}
+
 void cli_credentials_set_kerberos_state(struct cli_credentials *creds, 
 					enum credentials_use_kerberos use_kerberos)
 {

Modified: branches/SAMBA_4_0/source/libcli/raw/trans2.h
===================================================================
--- branches/SAMBA_4_0/source/libcli/raw/trans2.h	2007-03-02 23:06:53 UTC (rev 21667)
+++ branches/SAMBA_4_0/source/libcli/raw/trans2.h	2007-03-02 23:24:27 UTC (rev 21668)
@@ -74,6 +74,7 @@
 #define SMB_QFS_ATTRIBUTE_INFO                         0x105
 #define SMB_QFS_UNIX_INFO                              0x200
 #define SMB_QFS_POSIX_INFO                             0x201
+#define SMB_QFS_POSIX_WHOAMI                           0x202
 #define SMB_QFS_VOLUME_INFORMATION			1001
 #define SMB_QFS_SIZE_INFORMATION			1003
 #define SMB_QFS_DEVICE_INFORMATION			1004

Modified: branches/SAMBA_4_0/source/torture/rpc/srvsvc.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/srvsvc.c	2007-03-02 23:06:53 UTC (rev 21667)
+++ branches/SAMBA_4_0/source/torture/rpc/srvsvc.c	2007-03-02 23:24:27 UTC (rev 21668)
@@ -1125,9 +1125,7 @@
 		return False;
 	}
 
-	anon_credentials = cli_credentials_init(mem_ctx);
-	cli_credentials_set_conf(anon_credentials);
-	cli_credentials_set_anonymous(anon_credentials);
+	anon_credentials = cli_credentials_init_anon(mem_ctx);
 
 	status = dcerpc_pipe_connect(mem_ctx, 
 				     &p, binding, &dcerpc_table_srvsvc,

Modified: branches/SAMBA_4_0/source/torture/unix/whoami.c
===================================================================
--- branches/SAMBA_4_0/source/torture/unix/whoami.c	2007-03-02 23:06:53 UTC (rev 21667)
+++ branches/SAMBA_4_0/source/torture/unix/whoami.c	2007-03-02 23:24:27 UTC (rev 21668)
@@ -26,8 +26,6 @@
 #include "lib/cmdline/popt_common.h"
 #include "auth/credentials/credentials.h"
 
-#define SMB_QUERY_POSIX_WHOAMI     0x202
-
 /* Size (in bytes) of the required fields in the SMBwhoami response. */
 #define WHOAMI_REQUIRED_SIZE	40
 
@@ -68,7 +66,8 @@
 	struct dom_sid ** sid_list;
 };
 
-static struct smbcli_state *connect_to_server(void *mem_ctx)
+static struct smbcli_state *connect_to_server(void *mem_ctx,
+		struct cli_credentials *creds)
 {
 	NTSTATUS status;
 	struct smbcli_state *cli;
@@ -78,7 +77,7 @@
 
 	status = smbcli_full_connection(mem_ctx, &cli,
 					host, share, NULL,
-					cmdline_credentials, NULL);
+					creds, NULL);
 
 	if (!NT_STATUS_IS_OK(status)) {
 		printf("failed to connect to //%s/%s: %s\n",
@@ -154,13 +153,13 @@
 	tp.in.max_data = (uint16_t)max_data;
 	tp.in.setup = &setup;
 	tp.in.trans_name = NULL;
-	SSVAL(&info_level, 0, SMB_QUERY_POSIX_WHOAMI);
+	SSVAL(&info_level, 0, SMB_QFS_POSIX_WHOAMI);
 	tp.in.params = data_blob_talloc(mem_ctx, &info_level, 2);
 	tp.in.data = data_blob_talloc(mem_ctx, NULL, 0);
 
 	status = smb_raw_trans2(cli->tree, mem_ctx, &tp);
 	torture_assert_ntstatus_equal(torture, status, NT_STATUS_OK,
-			"doing SMB_QUERY_POSIX_WHOAMI");
+			"doing SMB_QFS_POSIX_WHOAMI");
 
 	/* Make sure we got back all the required fields. */
 	torture_assert(torture, tp.out.params.length == 0,
@@ -269,18 +268,19 @@
 BOOL torture_unix_whoami(struct torture_context *torture)
 {
 	struct smbcli_state *cli;
+	struct cli_credentials *anon_credentials;
 	struct smb_whoami whoami;
 	void *mem_ctx;
 
 	mem_ctx = talloc_init("smb_query_posix_whoami");
 	torture_assert(torture, mem_ctx != NULL, "malloc failed");
 
-	if (!(cli = connect_to_server(mem_ctx))) {
+	if (!(cli = connect_to_server(mem_ctx, cmdline_credentials))) {
 		goto fail;
 	}
 
 	/* Test basic authenticated mapping. */
-	printf("calling SMB_QUERY_POSIX_WHOAMI on an authenticated connection\n");
+	printf("calling SMB_QFS_POSIX_WHOAMI on an authenticated connection\n");
 	if (!smb_raw_query_posix_whoami(mem_ctx, torture,
 				cli, &whoami, 0xFFFF)) {
 		smbcli_tdis(cli);
@@ -288,7 +288,7 @@
 	}
 
 	/* Test that the server drops the UID and GID list. */
-	printf("calling SMB_QUERY_POSIX_WHOAMI with a small buffer\n");
+	printf("calling SMB_QFS_POSIX_WHOAMI with a small buffer\n");
 	if (!smb_raw_query_posix_whoami(mem_ctx, torture,
 				cli, &whoami, 0x40)) {
 		smbcli_tdis(cli);
@@ -303,13 +303,14 @@
 			"invalid SID bytes count");
 
 	smbcli_tdis(cli);
-	cli_credentials_set_anonymous(cmdline_credentials);
 
-	if (!(cli = connect_to_server(mem_ctx))) {
+	printf("calling SMB_QFS_POSIX_WHOAMI on an anonymous connection\n");
+	anon_credentials = cli_credentials_init_anon(mem_ctx);
+
+	if (!(cli = connect_to_server(mem_ctx, anon_credentials))) {
 		goto fail;
 	}
 
-	printf("calling SMB_QUERY_POSIX_WHOAMI on an anonymous connection\n");
 	if (!smb_raw_query_posix_whoami(mem_ctx, torture,
 				cli, &whoami, 0xFFFF)) {
 		smbcli_tdis(cli);



More information about the samba-cvs mailing list