[SCM] Samba Shared Repository - branch master updated

Günther Deschner gd at samba.org
Tue May 11 16:22:06 MDT 2010


The branch, master has been updated
       via  73d654e... s4-smbtorture: create/delete testusers via SAMR in RAP-SAM.
       via  b73b237... s4-smbtorture: add test_oemchangepassword to RAP-SAM.
       via  1cee92c... s4-selftest: skip RAP-SAM tests against Samba 4.
       via  3ce8bcd... s3-selftest: enable RAP-SAM against Samba 3.
       via  931b7fc... s4-smbtorture: add RAP-SAM testsuite with a rap_NetUserPasswordSet2 test.
      from  84ab762... s4-smbtorture: getting serious about checking rap status return codes.

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


- Log -----------------------------------------------------------------
commit 73d654ec2fcadf3c195017349ad4a727c8179f35
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 12 00:18:42 2010 +0200

    s4-smbtorture: create/delete testusers via SAMR in RAP-SAM.
    
    Unless we spent time researching the RAP useradd calls (and implement them in
    s3) it is far more easy to use existing SAMR calls to create and delete test
    users that are used for RAP change password operations.
    
    Guenther

commit b73b237a6b5e2a596c89608301454f0577f650ab
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 7 22:58:42 2010 +0200

    s4-smbtorture: add test_oemchangepassword to RAP-SAM.
    
    Guenther

commit 1cee92caaaca9f98e4e18aa597666297c2d347e1
Author: Günther Deschner <gd at samba.org>
Date:   Mon May 10 12:14:58 2010 +0200

    s4-selftest: skip RAP-SAM tests against Samba 4.
    
    Guenther

commit 3ce8bcdd83d0758b2da6da2e89afb4923801406c
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 7 22:18:30 2010 +0200

    s3-selftest: enable RAP-SAM against Samba 3.
    
    Guenther

commit 931b7fcc8ae1d382c5402deb3baeafb9025056b2
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 7 15:45:23 2010 +0200

    s4-smbtorture: add RAP-SAM testsuite with a rap_NetUserPasswordSet2 test.
    
    Guenther

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

Summary of changes:
 source3/script/tests/test_posix_s3.sh |    2 +-
 source4/selftest/skip                 |    1 +
 source4/torture/config.mk             |    2 +-
 source4/torture/rap/rap.c             |    1 +
 source4/torture/rap/sam.c             |  162 +++++++++++++++++++++++++++++++++
 source4/torture/wscript_build         |    2 +-
 6 files changed, 167 insertions(+), 3 deletions(-)
 create mode 100644 source4/torture/rap/sam.c


Changeset truncated at 500 lines:

diff --git a/source3/script/tests/test_posix_s3.sh b/source3/script/tests/test_posix_s3.sh
index 47fb2c6..c1ca4d1 100755
--- a/source3/script/tests/test_posix_s3.sh
+++ b/source3/script/tests/test_posix_s3.sh
@@ -55,7 +55,7 @@ local="LOCAL-NSS-WRAPPER LOCAL-NDR"
 
 winbind="WINBIND-STRUCT WINBIND-WBCLIENT"
 
-rap="RAP-BASIC RAP-RPC RAP-PRINTING"
+rap="RAP-BASIC RAP-RPC RAP-PRINTING RAP-SAM"
 
 # NOTE: to enable the UNIX-WHOAMI test, we need to change the default share
 # config to allow guest access. I'm not sure whether this would break other
diff --git a/source4/selftest/skip b/source4/selftest/skip
index 06acff2..0e6820e 100644
--- a/source4/selftest/skip
+++ b/source4/selftest/skip
@@ -64,6 +64,7 @@ rpc.autoidl  # this one just generates a lot of noise, and is no longer useful
 samba4.rpc.countcalls # this is not useful now we have full IDL
 samba4.rap.scan # same thing here - we have docs now
 samba4.rap.printing # Not provided by Samba 4
+samba4.rap.sam # Not provided by Samba 4
 samba4.gensec.python # not finished
 bench # don't run benchmarks in our selftest
 trans2.scan # uses huge number of file descriptors
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 3d566c0..50d4009 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -140,7 +140,7 @@ PRIVATE_DEPENDENCIES = TORTURE_UTIL LIBCLI_SMB NDR_RAP
 # End SUBSYSTEM TORTURE_RAP
 #################################
 
-TORTURE_RAP_OBJ_FILES = $(torturesrcdir)/rap/rap.o $(torturesrcdir)/rap/rpc.o $(torturesrcdir)/rap/printing.o
+TORTURE_RAP_OBJ_FILES = $(torturesrcdir)/rap/rap.o $(torturesrcdir)/rap/rpc.o $(torturesrcdir)/rap/printing.o $(torturesrcdir)/rap/sam.o
 
 $(eval $(call proto_header_template,$(torturesrcdir)/rap/proto.h,$(TORTURE_RAP_OBJ_FILES:.o=.c)))
 
diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c
index 74f7188..5412c1b 100644
--- a/source4/torture/rap/rap.c
+++ b/source4/torture/rap/rap.c
@@ -1760,6 +1760,7 @@ NTSTATUS torture_rap_init(void)
 	torture_suite_add_suite(suite, suite_basic);
 	torture_suite_add_suite(suite, torture_rap_rpc(suite));
 	torture_suite_add_suite(suite, torture_rap_printing(suite));
+	torture_suite_add_suite(suite, torture_rap_sam(suite));
 
 	torture_suite_add_1smb_test(suite_basic, "netserverenum", 
 				    test_netserverenum);
diff --git a/source4/torture/rap/sam.c b/source4/torture/rap/sam.c
new file mode 100644
index 0000000..d99c348
--- /dev/null
+++ b/source4/torture/rap/sam.c
@@ -0,0 +1,162 @@
+/*
+   Unix SMB/CIFS implementation.
+   test suite for RAP sam operations
+
+   Copyright (C) Guenther Deschner 2010
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "libcli/libcli.h"
+#include "torture/torture.h"
+#include "torture/util.h"
+#include "torture/smbtorture.h"
+#include "torture/util.h"
+#include "../librpc/gen_ndr/rap.h"
+#include "torture/rap/proto.h"
+#include "param/param.h"
+#include "../lib/crypto/crypto.h"
+#include "../libcli/auth/libcli_auth.h"
+#include "torture/rpc/torture_rpc.h"
+
+#define TEST_RAP_USER "torture_rap_user"
+
+static char *samr_rand_pass(TALLOC_CTX *mem_ctx, int min_len)
+{
+	size_t len = MAX(8, min_len);
+	char *s = generate_random_password(mem_ctx, len, len+6);
+	printf("Generated password '%s'\n", s);
+	return s;
+}
+
+static bool test_userpasswordset2_args(struct torture_context *tctx,
+				       struct smbcli_state *cli,
+				       const char *username,
+				       const char **password)
+{
+	struct rap_NetUserPasswordSet2 r;
+	char *newpass = samr_rand_pass(tctx, 8);
+
+	r.in.UserName = username;
+	r.in.OldPassword = *password;
+	r.in.NewPassword = newpass;
+	r.in.EncryptedPassword = 0;
+	r.in.RealPasswordLength = strlen(r.in.NewPassword);
+
+	torture_comment(tctx, "Testing rap_NetUserPasswordSet2(%s)\n", r.in.UserName);
+
+	torture_assert_ntstatus_ok(tctx,
+		smbcli_rap_netuserpasswordset2(cli->tree, lp_iconv_convenience(tctx->lp_ctx), tctx, &r),
+		"smbcli_rap_netuserpasswordset2 failed");
+	if (!W_ERROR_IS_OK(W_ERROR(r.out.status))) {
+		torture_warning(tctx, "RAP NetUserPasswordSet2 gave: %s\n",
+			win_errstr(W_ERROR(r.out.status)));
+	} else {
+		*password = newpass;
+	}
+
+	return true;
+}
+
+static bool test_userpasswordset2(struct torture_context *tctx,
+				  struct smbcli_state *cli)
+{
+	struct test_join *join_ctx;
+	const char *password;
+	bool ret;
+
+	join_ctx = torture_create_testuser_max_pwlen(tctx, TEST_RAP_USER,
+						     torture_setting_string(tctx, "workgroup", NULL),
+						     ACB_NORMAL,
+						     &password, 14);
+	if (join_ctx == NULL) {
+		torture_fail(tctx, "failed to create user\n");
+	}
+
+	ret = test_userpasswordset2_args(tctx, cli, TEST_RAP_USER, &password);
+
+	torture_leave_domain(tctx, join_ctx);
+
+	return ret;
+}
+
+static bool test_oemchangepassword_args(struct torture_context *tctx,
+					struct smbcli_state *cli,
+					const char *username,
+					const char **password)
+{
+	struct rap_NetOEMChangePassword r;
+
+	const char *oldpass = *password;
+	char *newpass = samr_rand_pass(tctx, 9);
+	uint8_t old_pw_hash[16];
+	uint8_t new_pw_hash[16];
+
+	r.in.UserName = username;
+
+	E_deshash(oldpass, old_pw_hash);
+	E_deshash(newpass, new_pw_hash);
+
+	encode_pw_buffer(r.in.crypt_password, newpass, STR_ASCII);
+	arcfour_crypt(r.in.crypt_password, old_pw_hash, 516);
+	E_old_pw_hash(new_pw_hash, old_pw_hash, r.in.password_hash);
+
+	torture_comment(tctx, "Testing rap_NetOEMChangePassword(%s)\n", r.in.UserName);
+
+	torture_assert_ntstatus_ok(tctx,
+		smbcli_rap_netoemchangepassword(cli->tree, lp_iconv_convenience(tctx->lp_ctx), tctx, &r),
+		"smbcli_rap_netoemchangepassword failed");
+	if (!W_ERROR_IS_OK(W_ERROR(r.out.status))) {
+		torture_warning(tctx, "RAP NetOEMChangePassword gave: %s\n",
+			win_errstr(W_ERROR(r.out.status)));
+	} else {
+		*password = newpass;
+	}
+
+	return true;
+}
+
+static bool test_oemchangepassword(struct torture_context *tctx,
+				   struct smbcli_state *cli)
+{
+
+	struct test_join *join_ctx;
+	const char *password;
+	bool ret;
+
+	join_ctx = torture_create_testuser_max_pwlen(tctx, TEST_RAP_USER,
+						     torture_setting_string(tctx, "workgroup", NULL),
+						     ACB_NORMAL,
+						     &password, 14);
+	if (join_ctx == NULL) {
+		torture_fail(tctx, "failed to create user\n");
+	}
+
+	ret = test_oemchangepassword_args(tctx, cli, TEST_RAP_USER, &password);
+
+	torture_leave_domain(tctx, join_ctx);
+
+	return ret;
+}
+
+struct torture_suite *torture_rap_sam(TALLOC_CTX *mem_ctx)
+{
+	struct torture_suite *suite = torture_suite_create(mem_ctx, "SAM");
+
+	torture_suite_add_1smb_test(suite, "userpasswordset2", test_userpasswordset2);
+	torture_suite_add_1smb_test(suite, "oemchangepassword", test_oemchangepassword);
+
+	return suite;
+}
diff --git a/source4/torture/wscript_build b/source4/torture/wscript_build
index 33f9f15..b91ba08 100644
--- a/source4/torture/wscript_build
+++ b/source4/torture/wscript_build
@@ -51,7 +51,7 @@ bld.SAMBA_MODULE('torture_rpc',
 bld.RECURSE('drs')
 
 bld.SAMBA_MODULE('TORTURE_RAP',
-	source='rap/rap.c rap/rpc.c rap/printing.c',
+	source='rap/rap.c rap/rpc.c rap/printing.c rap/sam.c',
 	autoproto='rap/proto.h',
 	subsystem='smbtorture',
 	init_function='torture_rap_init',


-- 
Samba Shared Repository


More information about the samba-cvs mailing list