r336: added a -X command line option to smbtorture to enable dangerous or
authorAndrew Tridgell <tridge@samba.org>
Fri, 23 Apr 2004 05:40:18 +0000 (05:40 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:51:33 +0000 (12:51 -0500)
possibly destructive tests. Use with care!

Added IDL and test code for samr_Shutdown() and samr_SetDsrmPassword()

source/librpc/idl/samr.idl
source/torture/raw/setfileinfo.c
source/torture/rpc/autoidl.c
source/torture/rpc/samr.c
source/torture/torture.c

index 170ccda08bdafd41edec736961eb710e3108f254..65219bf78c9c7535d7c80376bb3639604f6885de 100644 (file)
 
        /************************/
        /* Function    0x42     */
-       NTSTATUS samr_SET_DSRM_PASSWORD();
+
+       /*
+         this should set the DSRM password for the server, which is used
+         when booting into Directory Services Recovery Mode on a DC. Win2003
+         gives me NT_STATUS_NOT_SUPPORTED
+       */
+
+       NTSTATUS samr_SetDsrmPassword(
+               [in]       samr_Name *name,
+               [in]       uint32 unknown,
+               [in]       samr_Hash *hash
+               );
+
 
        /************************/
        /* Function    0x43     */
-
        /*
          I haven't been able to work out the format of this one yet.
          Seems to start with a switch level for a union?
index 247e54a4b06b0b2a20017b3a733019f7ce89792a..3a49c8bafff72e55e381f37d3ddc8c48e7077682 100644 (file)
@@ -525,6 +525,11 @@ BOOL torture_raw_sfileinfo_bug(int dummy)
        NTSTATUS status;
        int fnum;
 
+       if (lp_parm_int(-1, "torture", "dangerous") != 1) {
+               printf("torture_raw_sfileinfo_bug disabled - enable dangerous tests to use\n");
+               return True;
+       }
+
        if (!torture_open_connection(&cli)) {
                return False;
        }
index 6021f10c4930ef26b04dc2f631e81cd6f53b12a0..1c164af33301675d2242f54d3557fba67471450c 100644 (file)
@@ -227,7 +227,7 @@ static void test_scan_call(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_ta
 
 static void test_auto_scan(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *iface)
 {
-       test_scan_call(mem_ctx, iface, 0x26);
+       test_scan_call(mem_ctx, iface, 0x42);
 }
 
 BOOL torture_rpc_autoidl(int dummy)
index 7433627743bd87d0fd0fd45a2a00c408d37f68a5..3e8ff537712b2d1ff7d859b3a17770aad56978ae 100644 (file)
@@ -61,6 +61,62 @@ static BOOL test_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        return True;
 }
 
+static BOOL test_Shutdown(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
+                      struct policy_handle *handle)
+{
+       NTSTATUS status;
+       struct samr_Shutdown r;
+
+       if (lp_parm_int(-1, "torture", "dangerous") != 1) {
+               printf("samr_Shutdown disabled - enable dangerous tests to use\n");
+               return True;
+       }
+
+       r.in.handle = handle;
+
+       printf("testing samr_Shutdown\n");
+
+       status = dcerpc_samr_Shutdown(p, mem_ctx, &r);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("samr_Shutdown failed - %s\n", nt_errstr(status));
+               return False;
+       }
+
+       return True;
+}
+
+static BOOL test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
+                                struct policy_handle *handle)
+{
+       NTSTATUS status;
+       struct samr_SetDsrmPassword r;
+       struct samr_Name name;
+       struct samr_Hash hash;
+
+       if (lp_parm_int(-1, "torture", "dangerous") != 1) {
+               printf("samr_SetDsrmPassword disabled - enable dangerous tests to use\n");
+               return True;
+       }
+
+       E_md4hash("TeSTDSRM123", hash.hash);
+
+       init_samr_Name(&name, "Administrator");
+
+       r.in.name = &name;
+       r.in.unknown = 0;
+       r.in.hash = &hash;
+
+       printf("testing samr_SetDsrmPassword\n");
+
+       status = dcerpc_samr_SetDsrmPassword(p, mem_ctx, &r);
+       if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
+               printf("samr_SetDsrmPassword failed - %s\n", nt_errstr(status));
+               return False;
+       }
+
+       return True;
+}
+
 
 static BOOL test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
                               struct policy_handle *handle)
@@ -241,10 +297,10 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        TEST_USERINFO_INT(2, code_page, 21, code_page, __LINE__, 0);
        TEST_USERINFO_INT(21, code_page, 21, code_page, __LINE__, 0x00800000);
 
-       TEST_USERINFO_INT(4, logon_hours.bitmap[3],  3, logon_hours.bitmap[3], __LINE__, 0);
-       TEST_USERINFO_INT(4, logon_hours.bitmap[3],  5, logon_hours.bitmap[3], __LINE__, 0);
-       TEST_USERINFO_INT(4, logon_hours.bitmap[3], 21, logon_hours.bitmap[3], __LINE__, 0);
-       TEST_USERINFO_INT(21, logon_hours.bitmap[3], 21, logon_hours.bitmap[3], __LINE__, 0x00002000);
+       TEST_USERINFO_INT(4, logon_hours.bitmap[3],  3, logon_hours.bitmap[3], 1, 0);
+       TEST_USERINFO_INT(4, logon_hours.bitmap[3],  5, logon_hours.bitmap[3], 2, 0);
+       TEST_USERINFO_INT(4, logon_hours.bitmap[3], 21, logon_hours.bitmap[3], 3, 0);
+       TEST_USERINFO_INT(21, logon_hours.bitmap[3], 21, logon_hours.bitmap[3], 4, 0x00002000);
 
 #if 0
        /* these fail with win2003 - it appears you can't set the primary gid?
@@ -2637,6 +2693,14 @@ BOOL torture_rpc_samr(int dummy)
                ret = False;
        }
 
+       if (!test_SetDsrmPassword(p, mem_ctx, &handle)) {
+               ret = False;
+       }
+
+       if (!test_Shutdown(p, mem_ctx, &handle)) {
+               ret = False;
+       }
+
        if (!test_Close(p, mem_ctx, &handle)) {
                ret = False;
        }
index 5c1ede691924400e630911a4e9a20f0fae6388b2..17aba4fb79f5560527303c2babd335b704946b48 100644 (file)
@@ -4070,6 +4070,7 @@ static void usage(void)
        printf("\t-s seed\n");
        printf("\t-f max failures\n");
        printf("\t-b bypass I/O (NBENCH)\n");
+       printf("\t-X enable dangerous tests\n");
        printf("\n\n");
 
        printf("tests are:");
@@ -4139,7 +4140,7 @@ static void usage(void)
 
        srandom(time(NULL));
 
-       while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:e:m:Ld:Ac:ks:f:s:t:C:")) != EOF) {
+       while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:e:m:Ld:Ac:ks:f:s:t:C:X")) != EOF) {
                switch (opt) {
                case 'p':
                        lp_set_cmdline("smb ports", optarg);
@@ -4202,6 +4203,10 @@ static void usage(void)
                        torture_failures = atoi(optarg);
                        break;
 
+               case 'X':
+                       lp_set_cmdline("torture:dangerous", "1");
+                       break;
+
                default:
                        printf("Unknown option %c (%d)\n", (char)opt, opt);
                        usage();